Pārlūkot izejas kodu

微信管理端数据展示修改

fllmoyu 4 gadi atpakaļ
vecāks
revīzija
54acbacef3

+ 2 - 0
common/src/main/java/com/jpsoft/bus/modules/bus/dao/RouteAccountDAO.java

@@ -16,4 +16,6 @@ public interface RouteAccountDAO {
 	int delete(String id);
 	List<RouteAccount> list();
 	List<RouteAccount> search(Map<String,Object> searchParams,List<Sort> sortList);
+
+    List<RouteAccount> findByAccountId(String accountId);
 }

+ 4 - 0
common/src/main/java/com/jpsoft/bus/modules/bus/dao/VehicleInfoDAO.java

@@ -25,4 +25,8 @@ public interface VehicleInfoDAO {
     List<VehicleInfo> findByCompanyId(String companyId);
 
     List<VehicleInfo> getRunningList();
+
+    List<VehicleInfo> findByRouteId(String routeId);
+
+	List<VehicleInfo> findByAccountId(String accountId);
 }

+ 2 - 0
common/src/main/java/com/jpsoft/bus/modules/bus/service/RouteAccountService.java

@@ -14,4 +14,6 @@ public interface RouteAccountService {
 	int delete(String id);
 	List<RouteAccount> list();
 	Page<RouteAccount> pageSearch(Map<String, Object> searchParams,int pageNum,int pageSize,boolean count,List<Sort> sortList);
+
+    List<RouteAccount> findByAccountId(String accountId);
 }

+ 7 - 0
common/src/main/java/com/jpsoft/bus/modules/bus/service/VehicleInfoService.java

@@ -5,6 +5,7 @@ import java.util.Map;
 import com.jpsoft.bus.modules.bus.entity.VehicleInfo;
 import com.github.pagehelper.Page;
 import com.jpsoft.bus.modules.common.dto.Sort;
+import com.jpsoft.bus.modules.merchant.entity.AccountInfo;
 
 public interface VehicleInfoService {
 	VehicleInfo get(String id);
@@ -26,4 +27,10 @@ public interface VehicleInfoService {
     List<VehicleInfo> findByCompanyId(String companyId);
 
     List<VehicleInfo> getRunningList();
+
+    List<VehicleInfo> findByRouteId(String routeId);
+
+	List<VehicleInfo> findByAccountId(String accountId);
+
+	List<VehicleInfo> getAllVehicleByAccount(AccountInfo accountInfo);
 }

+ 11 - 6
common/src/main/java/com/jpsoft/bus/modules/bus/service/impl/RouteAccountServiceImpl.java

@@ -30,14 +30,14 @@ public class RouteAccountServiceImpl implements RouteAccountService {
 	public int insert(RouteAccount model) {
 		// TODO Auto-generated method stub
 		//model.setId(UUID.randomUUID().toString());
-		
+
 		return routeAccountDAO.insert(model);
 	}
 
 	@Override
 	public int update(RouteAccount model) {
 		// TODO Auto-generated method stub
-		return routeAccountDAO.update(model);		
+		return routeAccountDAO.update(model);
 	}
 
 	@Override
@@ -50,22 +50,27 @@ public class RouteAccountServiceImpl implements RouteAccountService {
 	public boolean exist(String id) {
 		// TODO Auto-generated method stub
 		int count = routeAccountDAO.exist(id);
-		
+
 		return count > 0 ? true : false;
 	}
-	
+
 	@Override
 	public List<RouteAccount> list() {
 		// TODO Auto-generated method stub
 		return routeAccountDAO.list();
 	}
-		
+
 	@Override
 	public Page<RouteAccount> pageSearch(Map<String, Object> searchParams, int pageNumber, int pageSize,boolean count,List<Sort> sortList) {
         Page<RouteAccount> page = PageHelper.startPage(pageNumber,pageSize,count).doSelectPage(()->{
             routeAccountDAO.search(searchParams,sortList);
         });
-        
+
         return page;
 	}
+
+	@Override
+	public List<RouteAccount> findByAccountId(String accountId) {
+		return routeAccountDAO.findByAccountId(accountId);
+	}
 }

+ 66 - 0
common/src/main/java/com/jpsoft/bus/modules/bus/service/impl/VehicleInfoServiceImpl.java

@@ -1,9 +1,19 @@
 package com.jpsoft.bus.modules.bus.service.impl;
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 import javax.annotation.Resource;
+
+import com.jpsoft.bus.modules.bus.dto.VehicleDTO;
+import com.jpsoft.bus.modules.bus.entity.CompanyInfo;
+import com.jpsoft.bus.modules.bus.entity.RouteAccount;
+import com.jpsoft.bus.modules.bus.service.CompanyInfoService;
+import com.jpsoft.bus.modules.bus.service.RouteAccountService;
+import com.jpsoft.bus.modules.merchant.entity.AccountInfo;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import org.springframework.transaction.annotation.Transactional;
 import com.jpsoft.bus.modules.bus.dao.VehicleInfoDAO;
@@ -19,6 +29,12 @@ public class VehicleInfoServiceImpl implements VehicleInfoService {
 	@Resource(name="vehicleInfoDAO")
 	private VehicleInfoDAO vehicleInfoDAO;
 
+	@Autowired
+	private CompanyInfoService companyInfoService;
+
+	@Autowired
+	private RouteAccountService routeAccountService;
+
 	@Override
 	public VehicleInfo get(String id) {
 		// TODO Auto-generated method stub
@@ -96,4 +112,54 @@ public class VehicleInfoServiceImpl implements VehicleInfoService {
 	public List<VehicleInfo> getRunningList() {
 		return vehicleInfoDAO.getRunningList();
 	}
+
+	@Override
+	public List<VehicleInfo> findByRouteId(String routeId) {
+		return vehicleInfoDAO.findByRouteId(routeId);
+	}
+
+	@Override
+	public List<VehicleInfo> findByAccountId(String accountId) {
+		return vehicleInfoDAO.findByAccountId(accountId);
+	}
+
+	@Override
+	public List<VehicleInfo> getAllVehicleByAccount(AccountInfo accountInfo) {
+
+		CompanyInfo companyInfo = companyInfoService.get(accountInfo.getCompanyId());
+		List<VehicleInfo> vehicleInfoList = findByCompanyId(companyInfo.getId());
+		List<VehicleInfo> list = new ArrayList<>();
+		if (vehicleInfoList.size()>0){
+			for (VehicleInfo vehicleInfo : vehicleInfoList){
+				list.add(vehicleInfo);
+			}
+		}
+
+		List<RouteAccount> routeAccountList = routeAccountService.findByAccountId(accountInfo.getId());
+		if (routeAccountList.size()>0){
+			for (RouteAccount routeAccount : routeAccountList){
+				List<VehicleInfo> vehicleInfoList1 = findByRouteId(routeAccount.getRouteId());
+				if (vehicleInfoList1.size()>0){
+					for (VehicleInfo vehicleInfo:vehicleInfoList1){
+						if (!list.contains(vehicleInfo)){
+							list.add(vehicleInfo);
+						}
+					}
+				}
+			}
+		}
+
+		List<VehicleInfo> vehicleInfoList2 = findByAccountId(accountInfo.getId());
+		if (vehicleInfoList2.size() > 0){
+			for (VehicleInfo vehicleInfo : vehicleInfoList2){
+				if (!list.contains(vehicleInfo)){
+					list.add(vehicleInfo);
+				}
+			}
+
+		}
+
+
+		return list;
+	}
 }

+ 10 - 2
common/src/main/resources/mapper/bus/RouteAccount.xml

@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" 
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <!-- namespace必须指向DAO接口 -->
 <mapper namespace="com.jpsoft.bus.modules.bus.dao.RouteAccountDAO">
@@ -66,7 +66,7 @@
 	where id_=#{id}
 	</update>
 	<select id="get" parameterType="string" resultMap="RouteAccountMap">
-		select 
+		select
 id_,route_id,account_id,create_by,create_time,update_by,update_time,del_flag		from bus_route_account where id_=#{0}
 	</select>
 	<select id="exist" parameterType="string" resultType="int">
@@ -88,4 +88,12 @@ id_,route_id,account_id,create_by,create_time,update_by,update_time,del_flag		fr
 	        ${sort.name} ${sort.order}
 	 	</foreach>
 	</select>
+
+	<select id="findByAccountId" resultMap="RouteAccountMap">
+		<![CDATA[
+		select * from bus_route_account
+		where del_flag = 0
+		and account_id = #{accountId}
+		]]>
+	</select>
 </mapper>

+ 15 - 0
common/src/main/resources/mapper/bus/VehicleInfo.xml

@@ -233,4 +233,19 @@
         where del_flag=0
         and running_=1
     </select>
+
+    <select id="findByRouteId" resultMap="VehicleInfoMap">
+        <![CDATA[
+        select * from bus_vehicle_info
+        where del_flag = 0
+        and route_id = #{routeId}
+        ]]>
+    </select>
+    <select id="findByAccountId" resultMap="VehicleInfoMap">
+        <![CDATA[
+        select * from bus_vehicle_info
+        where del_flag = 0
+        and account_id = #{accountId}
+        ]]>
+    </select>
 </mapper>

+ 203 - 204
web/src/main/java/com/jpsoft/bus/modules/mobile/controller/MerchantApiController.java

@@ -68,6 +68,9 @@ public class MerchantApiController {
     @Autowired
     private DriverInfoService driverInfoService;
 
+    @Autowired
+    private RouteAccountService routeAccountService;
+
     @Autowired
     private RouteInfoService routeInfoService;
 
@@ -191,7 +194,7 @@ public class MerchantApiController {
             messageResult.setResult(true);
             messageResult.setCode(200);
         } catch (Exception ex) {
-            log.error(ex.getMessage(),ex);
+            log.error(ex.getMessage(), ex);
             messageResult.setCode(400);
             messageResult.setResult(false);
             messageResult.setMessage(ex.getMessage());
@@ -233,7 +236,6 @@ public class MerchantApiController {
     }
 
 
-
     @PostMapping("revenueStatisticsUp")
     @ApiOperation(value = "营收统计(上)")
     public MessageResult<Map> revenueStatisticsUp(String token, @RequestAttribute String subject) {
@@ -242,11 +244,11 @@ public class MerchantApiController {
         try {
 
             AccountInfo accountInfo = accountInfoService.get(subject);
-            if (accountInfo == null){
+            if (accountInfo == null) {
                 throw new Exception("请重新登录");
             }
             CompanyInfo companyInfo = companyInfoService.get(accountInfo.getCompanyId());
-            List<VehicleInfo> vehicleInfoList = vehicleInfoService.findByCompanyId(companyInfo.getId());
+            List<VehicleInfo> vehicleInfoList = vehicleInfoService.getAllVehicleByAccount(accountInfo);
             //今日收益
             BigDecimal todayRevenue = BigDecimal.ZERO;
             //昨日收益
@@ -255,36 +257,36 @@ public class MerchantApiController {
             BigDecimal totalRevenue = BigDecimal.ZERO;
 
             CapitalInfo capitalInfo = capitalInfoService.findByMerchantId(accountInfo.getId());
-            if (capitalInfo != null){
+            if (capitalInfo != null) {
                 totalRevenue = capitalInfo.getTotalRevenue();
             }
 
-      //      if (vehicleInfoList.size()>0){
-                //今日收益
-                BigDecimal todaySum = orderInfoService.paySum(null,companyInfo.getId(),null, DateUtil.beginOfDay(new Date()),DateUtil.endOfDay(new Date()),null);
-                if (todaySum != null){
-                    todayRevenue = todaySum;
-                }
-                //昨日收益
-                BigDecimal yesterdaySum = orderInfoService.paySum(null,companyInfo.getId(),null,DateUtil.beginOfDay(DateUtil.offsetDay(new Date(),-1)),DateUtil.endOfDay(DateUtil.offsetDay(new Date(),-1)),null);
-                if (yesterdaySum != null){
-                    yesterdayRevenue = yesterdaySum;
-                }
+            //      if (vehicleInfoList.size()>0){
+            //今日收益
+            BigDecimal todaySum = orderInfoService.paySum(vehicleInfoList, null, null, DateUtil.beginOfDay(new Date()), DateUtil.endOfDay(new Date()), null);
+            if (todaySum != null) {
+                todayRevenue = todaySum;
+            }
+            //昨日收益
+            BigDecimal yesterdaySum = orderInfoService.paySum(vehicleInfoList, null, null, DateUtil.beginOfDay(DateUtil.offsetDay(new Date(), -1)), DateUtil.endOfDay(DateUtil.offsetDay(new Date(), -1)), null);
+            if (yesterdaySum != null) {
+                yesterdayRevenue = yesterdaySum;
+            }
 
-                //总收益
-                BigDecimal totalSum = orderInfoService.paySum(null,companyInfo.getId(),null,null,new cn.hutool.core.date.DateTime(),null);
+            //总收益
+            BigDecimal totalSum = orderInfoService.paySum(vehicleInfoList, null, null, null, new cn.hutool.core.date.DateTime(), null);
 
-                if (totalSum != null){
-                    totalRevenue = totalSum;
-                }
+            if (totalSum != null) {
+                totalRevenue = totalSum;
+            }
 
 
-      //      }
+            //      }
 
-            Map<String,Object> map = new HashMap<>();
-            map.put("todayRevenue",todayRevenue);
-            map.put("yesterdayRevenue",yesterdayRevenue);
-            map.put("totalRevenue",totalRevenue);
+            Map<String, Object> map = new HashMap<>();
+            map.put("todayRevenue", todayRevenue);
+            map.put("yesterdayRevenue", yesterdayRevenue);
+            map.put("totalRevenue", totalRevenue);
 
             messageResult.setData(map);
             messageResult.setResult(true);
@@ -307,11 +309,11 @@ public class MerchantApiController {
         try {
 
             AccountInfo accountInfo = accountInfoService.get(subject);
-            if (accountInfo == null){
+            if (accountInfo == null) {
                 throw new Exception("请重新登录");
             }
             CompanyInfo companyInfo = companyInfoService.get(accountInfo.getCompanyId());
-            List<VehicleInfo> vehicleInfoList = vehicleInfoService.findByCompanyId(companyInfo.getId());
+            List<VehicleInfo> vehicleInfoList = vehicleInfoService.getAllVehicleByAccount(accountInfo);
             //线上购票款
             BigDecimal onlineRevenue = BigDecimal.ZERO;
             //微信收款
@@ -326,46 +328,45 @@ public class MerchantApiController {
             Integer num = 0;
 
 
+            //  if (vehicleInfoList.size()>0){
+            //微信
+            BigDecimal wechatSum = orderInfoService.paySum(vehicleInfoList, null, "wechat", DateUtil.beginOfDay(new Date()), DateUtil.endOfDay(new Date()), null);
+            if (wechatSum != null) {
+                wechatRevenue = wechatSum;
+            }
+            //支付宝
+            BigDecimal alipaySum = orderInfoService.paySum(vehicleInfoList, null, "alipay", DateUtil.beginOfDay(new Date()), DateUtil.endOfDay(new Date()), null);
+            if (alipaySum != null) {
+                alipayRevenue = alipaySum;
+            }
 
-          //  if (vehicleInfoList.size()>0){
-                //微信
-                BigDecimal wechatSum = orderInfoService.paySum(null,companyInfo.getId(),"wechat", DateUtil.beginOfDay(new Date()),DateUtil.endOfDay(new Date()),null);
-                if (wechatSum != null){
-                    wechatRevenue = wechatSum;
-                }
-                //支付宝
-                BigDecimal alipaySum = orderInfoService.paySum(null,companyInfo.getId(),"alipay",DateUtil.beginOfDay(new Date()),DateUtil.endOfDay(new Date()),null);
-                if (alipaySum != null){
-                    alipayRevenue = alipaySum;
-                }
-
-                //现金
-                BigDecimal cashSum = orderInfoService.paySum(null,companyInfo.getId(),"cash",DateUtil.beginOfDay(new Date()),DateUtil.endOfDay(new Date()),null);
-                if (cashSum != null){
-                    cashRevenue = cashSum;
-                }
+            //现金
+            BigDecimal cashSum = orderInfoService.paySum(vehicleInfoList, null, "cash", DateUtil.beginOfDay(new Date()), DateUtil.endOfDay(new Date()), null);
+            if (cashSum != null) {
+                cashRevenue = cashSum;
+            }
 
-                //车票
-                BigDecimal ticketSum = orderInfoService.paySum(null,companyInfo.getId(),"ticket",DateUtil.beginOfDay(new Date()),DateUtil.endOfDay(new Date()),null);
-                if (ticketSum != null){
-                    ticketRevenue = ticketSum;
-                }
+            //车票
+            BigDecimal ticketSum = orderInfoService.paySum(vehicleInfoList, null, "ticket", DateUtil.beginOfDay(new Date()), DateUtil.endOfDay(new Date()), null);
+            if (ticketSum != null) {
+                ticketRevenue = ticketSum;
+            }
 
-                Integer ticketNum = orderInfoService.payNum(null,companyInfo.getId(),null,DateUtil.beginOfDay(new Date()),DateUtil.endOfDay(new Date()),null);
-                if (ticketNum != null){
-                    num = ticketNum;
-                }
+            Integer ticketNum = orderInfoService.payNum(vehicleInfoList, null, null, DateUtil.beginOfDay(new Date()), DateUtil.endOfDay(new Date()), null);
+            if (ticketNum != null) {
+                num = ticketNum;
+            }
 
 
-      //      }
+            //      }
 
-            Map<String,Object> map = new HashMap<>();
-            map.put("onlineRevenue",wechatRevenue.add(alipayRevenue));
-            map.put("wechatRevenue",wechatRevenue);
-            map.put("alipayRevenue",alipayRevenue);
-            map.put("cashRevenue",cashRevenue);
-            map.put("ticketRevenue",ticketRevenue);
-            map.put("num",num);
+            Map<String, Object> map = new HashMap<>();
+            map.put("onlineRevenue", wechatRevenue.add(alipayRevenue));
+            map.put("wechatRevenue", wechatRevenue);
+            map.put("alipayRevenue", alipayRevenue);
+            map.put("cashRevenue", cashRevenue);
+            map.put("ticketRevenue", ticketRevenue);
+            map.put("num", num);
 
             messageResult.setData(map);
             messageResult.setResult(true);
@@ -389,20 +390,20 @@ public class MerchantApiController {
         try {
 
             AccountInfo accountInfo = accountInfoService.get(subject);
-            if (accountInfo == null){
+            if (accountInfo == null) {
                 throw new Exception("请重新登录");
             }
-            CompanyInfo companyInfo = companyInfoService.get(accountInfo.getCompanyId());
-            List<VehicleInfo> vehicleInfoList = vehicleInfoService.findByCompanyId(companyInfo.getId());
+
+            List<VehicleInfo> vehicleInfoList = vehicleInfoService.getAllVehicleByAccount(accountInfo);
+
             List<VehicleDTO> list = new ArrayList<>();
-            if (vehicleInfoList.size()>0){
-                for (VehicleInfo vehicleInfo : vehicleInfoList){
+            if (vehicleInfoList.size() > 0) {
+                for (VehicleInfo vehicleInfo : vehicleInfoList) {
                     VehicleDTO vehicleDTO = new VehicleDTO();
-                    BeanUtils.copyProperties(vehicleInfo,vehicleDTO);
+                    BeanUtils.copyProperties(vehicleInfo, vehicleDTO);
                     list.add(vehicleDTO);
                 }
             }
-
             messageResult.setData(list);
             messageResult.setResult(true);
             messageResult.setCode(200);
@@ -424,47 +425,45 @@ public class MerchantApiController {
             @ApiImplicitParam(name = "payName", value = "支付方式(微信:wechat,支付宝:alipay,现金:cash,车票:ticket)", required = false, paramType = "form"),
             @ApiImplicitParam(name = "dateStr", value = "时间(格式:yyyy-MM)", required = false, paramType = "form")
     })
-    public MessageResult<ProfitListDTO> profitList(String vehicleId,String payName,String dateStr,String token, @RequestAttribute String subject) {
+    public MessageResult<ProfitListDTO> profitList(String vehicleId, String payName, String dateStr, String token, @RequestAttribute String subject) {
         MessageResult<ProfitListDTO> messageResult = new MessageResult<>();
 
         try {
 
             ProfitListDTO profitListDTO = new ProfitListDTO();
             AccountInfo accountInfo = accountInfoService.get(subject);
-            if (accountInfo == null){
+            if (accountInfo == null) {
                 throw new Exception("请重新登录");
             }
             CompanyInfo companyInfo = companyInfoService.get(accountInfo.getCompanyId());
             List<VehicleInfo> vehicleInfoList = new ArrayList<>();
-            if (StringUtils.isNotBlank(vehicleId)){
+            if (StringUtils.isNotBlank(vehicleId)) {
                 VehicleInfo vehicleInfo = vehicleInfoService.get(vehicleId);
-                if (vehicleInfo != null){
+                if (vehicleInfo != null) {
                     vehicleInfoList.add(vehicleInfo);
                 }
-            }else {
-                vehicleInfoList = vehicleInfoService.findByCompanyId(companyInfo.getId());
+            } else {
+                vehicleInfoList = vehicleInfoService.getAllVehicleByAccount(accountInfo);
             }
 
 
-
-
             int n = 0;
             //开始计算的日期
             Date startDate = DateUtil.endOfDay(new Date());
             Date newDate = DateUtil.beginOfMonth(new Date());
-            String dateDesc = DateUtil.format(newDate,"yyyy年MM月");
-            if (StringUtils.isNotBlank(dateStr)){
-                Date date = DateUtil.parse(dateStr,"yyyy-MM");
+            String dateDesc = DateUtil.format(newDate, "yyyy年MM月");
+            if (StringUtils.isNotBlank(dateStr)) {
+                Date date = DateUtil.parse(dateStr, "yyyy-MM");
 
-                dateDesc = DateUtil.format(date,"yyyy年MM月");
-                if (newDate.compareTo(DateUtil.beginOfMonth(date))>0){
+                dateDesc = DateUtil.format(date, "yyyy年MM月");
+                if (newDate.compareTo(DateUtil.beginOfMonth(date)) > 0) {
                     Date endOfMonth = DateUtil.endOfMonth(date);
                     n = DateUtil.dayOfMonth(endOfMonth);
-                    startDate =  DateUtil.endOfMonth(date);
-                }else if(newDate.compareTo(DateUtil.beginOfMonth(date))==0){
+                    startDate = DateUtil.endOfMonth(date);
+                } else if (newDate.compareTo(DateUtil.beginOfMonth(date)) == 0) {
                     n = DateUtil.thisDayOfMonth();
                 }
-            }else {
+            } else {
                 n = DateUtil.thisDayOfMonth();
             }
 
@@ -474,32 +473,33 @@ public class MerchantApiController {
 
 
             List<ProfitListDTO> list = new ArrayList<>();
-            if (n>0){
-                for (int m = 0 ; m <n; m++){
+            if (n > 0) {
+                for (int m = 0; m < n; m++) {
                     ProfitListDTO profitListDTO1 = new ProfitListDTO();
-                    Date baseDate = DateUtil.offsetDay(startDate,-m);
+                    Date baseDate = DateUtil.offsetDay(startDate, -m);
                     Date baseStartDate = DateUtil.beginOfDay(baseDate);
-                 //   BigDecimal baseSum = BigDecimal.ZERO;
-                  //  if (vehicleInfoList.size()>0){
-                    BigDecimal baseSum  = orderInfoService.paySum(null,companyInfo.getId(),payName,baseStartDate,baseDate,null);
-                //    }
+                    BigDecimal baseSum = BigDecimal.ZERO;
+                    //  if (vehicleInfoList.size()>0){
+                    baseSum = orderInfoService.paySum(vehicleInfoList, null, payName, baseStartDate, baseDate, null);
+
 
-                    profitListDTO1.setDateDesc(DateUtil.format(baseDate,"yyyy-MM-dd"));
-                    profitListDTO1.setRevenue(baseSum == null?BigDecimal.ZERO:baseSum);
+                    //    }
+
+                    profitListDTO1.setDateDesc(DateUtil.format(baseDate, "yyyy-MM-dd"));
+                    profitListDTO1.setRevenue(baseSum == null ? BigDecimal.ZERO : baseSum);
                     list.add(profitListDTO1);
-                    revenue = revenue.add(baseSum == null?BigDecimal.ZERO:baseSum);
+                    revenue = revenue.add(baseSum == null ? BigDecimal.ZERO : baseSum);
                 }
             }
 
 
-
             profitListDTO.setRevenue(revenue);
             profitListDTO.setList(list);
             messageResult.setData(profitListDTO);
             messageResult.setResult(true);
             messageResult.setCode(200);
         } catch (Exception ex) {
-            log.error(ex.getMessage(),ex);
+            log.error(ex.getMessage(), ex);
             messageResult.setCode(400);
             messageResult.setResult(false);
             messageResult.setMessage(ex.getMessage());
@@ -516,85 +516,85 @@ public class MerchantApiController {
             @ApiImplicitParam(name = "dateStr", value = "时间(格式:yyyy-MM)", required = true, paramType = "form"),
             @ApiImplicitParam(name = "dateType", value = "全天:0,上半天:1,下半天:2", required = true, paramType = "form")
     })
-    public MessageResult<Map> sellList(String vehicleId, String payName, String dateStr,String dateType, @RequestParam(value = "pageIndex", defaultValue = "1") int pageIndex, @RequestParam(value = "pageSize", defaultValue = "20") int pageSize,String token, @RequestAttribute String subject) {
+    public MessageResult<Map> sellList(String vehicleId, String payName, String dateStr, String dateType, @RequestParam(value = "pageIndex", defaultValue = "1") int pageIndex, @RequestParam(value = "pageSize", defaultValue = "20") int pageSize, String token, @RequestAttribute String subject) {
         MessageResult<Map> messageResult = new MessageResult<>();
 
         try {
 
             AccountInfo accountInfo = accountInfoService.get(subject);
-            if (accountInfo == null){
+            if (accountInfo == null) {
                 throw new Exception("请重新登录");
             }
             CompanyInfo companyInfo = companyInfoService.get(accountInfo.getCompanyId());
             List<VehicleInfo> vehicleInfoList = new ArrayList<>();
-            if (StringUtils.isNotBlank(vehicleId)){
+            if (StringUtils.isNotBlank(vehicleId)) {
                 VehicleInfo vehicleInfo = vehicleInfoService.get(vehicleId);
-                if (vehicleInfo != null){
+                if (vehicleInfo != null) {
                     vehicleInfoList.add(vehicleInfo);
                 }
-            }else {
-                vehicleInfoList = vehicleInfoService.findByCompanyId(companyInfo.getId());
+            } else {
+                vehicleInfoList = vehicleInfoService.getAllVehicleByAccount(accountInfo);
             }
 
-            Map<String,Object> searchParams = new HashMap<>();
-            searchParams.put("payStatus",20);
-            if (StringUtils.isNotBlank(payName)){
-                searchParams.put("payName",payName);
+            Map<String, Object> searchParams = new HashMap<>();
+            searchParams.put("payStatus", 20);
+            if (StringUtils.isNotBlank(payName)) {
+                searchParams.put("payName", payName);
             }
 
-            Date date = DateUtil.parse(dateStr,"yyyy-MM-dd");
+            Date date = DateUtil.parse(dateStr, "yyyy-MM-dd");
             Date startTime = DateUtil.beginOfDay(date);
             Date endTime = DateUtil.endOfDay(date);
-            Date middleTime = DateUtil.parse(dateStr + " 12:00:00","yyyy-MM-dd HH:mm:ss");
-            if ("1".equals(dateType)){
+            Date middleTime = DateUtil.parse(dateStr + " 12:00:00", "yyyy-MM-dd HH:mm:ss");
+            if ("1".equals(dateType)) {
                 endTime = middleTime;
             }
-            if ("2".equals(dateType)){
+            if ("2".equals(dateType)) {
                 startTime = middleTime;
             }
 
-            searchParams.put("payBeginTime",startTime);
-            searchParams.put("payEndTime",endTime);
-            if (StringUtils.isNotBlank(vehicleId)){
-                searchParams.put("vehicleId",vehicleId);
+            searchParams.put("payBeginTime", startTime);
+            searchParams.put("payEndTime", endTime);
+            if (StringUtils.isNotBlank(vehicleId)) {
+                searchParams.put("vehicleId", vehicleId);
             }
-            searchParams.put("orderCompanyId",companyInfo.getId());
-       //     searchParams.put("vehicleInfoList",vehicleInfoList);
+           // searchParams.put("orderCompanyId", companyInfo.getId());
+            searchParams.put("vehicleInfoList",vehicleInfoList);
 
             List<Sort> sortList = new ArrayList<>();
-            sortList.add(new Sort("a.pay_time","desc"));
+            sortList.add(new Sort("a.pay_time", "desc"));
 
-            Page<OrderInfo> page = orderInfoService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);
+            Page<OrderInfo> page = orderInfoService.pageSearch(searchParams, pageIndex, pageSize, true, sortList);
 
             List<OrderInfo> orderInfoList = page.getResult();
             List<SellListDTO> list = new ArrayList<>();
-            if (orderInfoList.size()>0){
-                for (OrderInfo orderInfo : orderInfoList){
+            if (orderInfoList.size() > 0) {
+                for (OrderInfo orderInfo : orderInfoList) {
                     SellListDTO sellListDTO = new SellListDTO();
-                    BeanUtils.copyProperties(orderInfo,sellListDTO);
+                    BeanUtils.copyProperties(orderInfo, sellListDTO);
 
                     MergeOrderInfo mergeOrderInfo = mergeOrderInfoService.get(orderInfo.getMergeOrderId());
                     ShiftInfo shiftInfo = shiftInfoService.get(mergeOrderInfo.getVehicleShiftId());
-                    StationInfo start =  stationInfoService.get(shiftInfo.getStartStationId());
+                    StationInfo start = stationInfoService.get(shiftInfo.getStartStationId());
                     StationInfo end = stationInfoService.get(shiftInfo.getEndStationId());
                     sellListDTO.setRouteName(start.getName() + "-" + end.getName());
                     sellListDTO.setPayNameStr(orderInfo.getPayNameStr(orderInfo.getPayName()));
                     list.add(sellListDTO);
                 }
             }
-            Map<String,Object> pageMap = new HashMap<>();
-            pageMap.put("recordsTotal",page.getTotal());
-            pageMap.put("recordsFiltered",page.getTotal());
-            pageMap.put("totalPage",page.getPages());
-            pageMap.put("pageNumber",page.getPageNum());
-            pageMap.put("pageSize",page.getPageSize());
+            Map<String, Object> pageMap = new HashMap<>();
+            pageMap.put("recordsTotal", page.getTotal());
+            pageMap.put("recordsFiltered", page.getTotal());
+            pageMap.put("totalPage", page.getPages());
+            pageMap.put("pageNumber", page.getPageNum());
+            pageMap.put("pageSize", page.getPageSize());
             pageMap.put("data", list);
 
             messageResult.setData(pageMap);
             messageResult.setResult(true);
             messageResult.setCode(200);
         } catch (Exception ex) {
-            log.error(ex.getMessage(),ex);
+            log.error(ex.getMessage(), ex);
             messageResult.setCode(400);
             messageResult.setResult(false);
             messageResult.setMessage(ex.getMessage());
@@ -608,18 +608,18 @@ public class MerchantApiController {
     @ApiImplicitParams({
             @ApiImplicitParam(name = "id", value = "id", required = true, paramType = "form")
     })
-    public MessageResult<Map> sellDetail(String id,String token, @RequestAttribute String subject) {
+    public MessageResult<Map> sellDetail(String id, String token, @RequestAttribute String subject) {
         MessageResult<Map> messageResult = new MessageResult<>();
 
         try {
 
             AccountInfo accountInfo = accountInfoService.get(subject);
-            if (accountInfo == null){
+            if (accountInfo == null) {
                 throw new Exception("请重新登录");
             }
             OrderInfo orderInfo = orderInfoService.get(id);
 
-            if (orderInfo == null){
+            if (orderInfo == null) {
                 throw new Exception("订单不存在");
             }
             //乘客记录
@@ -645,45 +645,45 @@ public class MerchantApiController {
             //车辆
             VehicleInfo vehicleInfo = vehicleInfoService.get(shiftInfo.getVehicleId());
 
-            Map<String,Object> map = new HashMap<>();
-
-            map.put("outOrderNo",orderInfo.getOutOrderNo());
-            map.put("payName",orderInfo.getPayName());
-            map.put("payNameStr",orderInfo.getPayNameStr(orderInfo.getPayName()));
-            map.put("ticketType",orderInfo.getTicketType());
-            map.put("ticketTypeStr",orderInfo.getTicketTypeStr(orderInfo.getTicketType()));
-            map.put("goodTicketFee",orderInfo.getGoodsTicket());
-            map.put("ticketFee",orderInfo.getTotalFee().subtract(orderInfo.getGoodsTicket()));
-            map.put("totalFee",orderInfo.getTotalFee());
-            map.put("ticketTrip",ticketUpStation.getName() + "-" +ticketDownStation.getName());
-            if ("2".equals(passengerInfo.getStatus())){
-                map.put("ticketStatus","已过期");
-            }
-            if ("1".equals(passengerInfo.getStatus())){
-                map.put("ticketStatus","乘车中");
-            }
-            map.put("createTime",DateUtil.format(orderInfo.getCreateTime(),"yyyy-MM-dd HH:mm:ss"));
-            map.put("payTime",DateUtil.format(orderInfo.getPayTime(),"yyyy-MM-dd HH:mm:ss"));
+            Map<String, Object> map = new HashMap<>();
+
+            map.put("outOrderNo", orderInfo.getOutOrderNo());
+            map.put("payName", orderInfo.getPayName());
+            map.put("payNameStr", orderInfo.getPayNameStr(orderInfo.getPayName()));
+            map.put("ticketType", orderInfo.getTicketType());
+            map.put("ticketTypeStr", orderInfo.getTicketTypeStr(orderInfo.getTicketType()));
+            map.put("goodTicketFee", orderInfo.getGoodsTicket());
+            map.put("ticketFee", orderInfo.getTotalFee().subtract(orderInfo.getGoodsTicket()));
+            map.put("totalFee", orderInfo.getTotalFee());
+            map.put("ticketTrip", ticketUpStation.getName() + "-" + ticketDownStation.getName());
+            if ("2".equals(passengerInfo.getStatus())) {
+                map.put("ticketStatus", "已过期");
+            }
+            if ("1".equals(passengerInfo.getStatus())) {
+                map.put("ticketStatus", "乘车中");
+            }
+            map.put("createTime", DateUtil.format(orderInfo.getCreateTime(), "yyyy-MM-dd HH:mm:ss"));
+            map.put("payTime", DateUtil.format(orderInfo.getPayTime(), "yyyy-MM-dd HH:mm:ss"));
             Date closeTime = null;
-            if (passengerInfo.getDownTime() != null){
+            if (passengerInfo.getDownTime() != null) {
                 closeTime = passengerInfo.getDownTime();
 
             }
-            map.put("closeTime",DateUtil.format(closeTime,"yyyy-MM-dd HH:mm:ss"));
+            map.put("closeTime", DateUtil.format(closeTime, "yyyy-MM-dd HH:mm:ss"));
 
-            map.put("routeName",routeInfo.getName());
-            map.put("routeTrip",start.getName() + "-" + end.getName());
-            map.put("routeTime",routeInfo.getStartTime() + "-" + routeInfo.getEndTime());
-            map.put("licensePlateNumber",vehicleInfo.getLicensePlateNumber());
-            map.put("driverName",driverInfo.getName());
-            map.put("phone",driverInfo.getPhone());
+            map.put("routeName", routeInfo.getName());
+            map.put("routeTrip", start.getName() + "-" + end.getName());
+            map.put("routeTime", routeInfo.getStartTime() + "-" + routeInfo.getEndTime());
+            map.put("licensePlateNumber", vehicleInfo.getLicensePlateNumber());
+            map.put("driverName", driverInfo.getName());
+            map.put("phone", driverInfo.getPhone());
 
 
             messageResult.setData(map);
             messageResult.setResult(true);
             messageResult.setCode(200);
         } catch (Exception ex) {
-            log.error(ex.getMessage(),ex);
+            log.error(ex.getMessage(), ex);
             messageResult.setCode(400);
             messageResult.setResult(false);
             messageResult.setMessage(ex.getMessage());
@@ -701,7 +701,7 @@ public class MerchantApiController {
         try {
 
             AccountInfo accountInfo = accountInfoService.get(subject);
-            if (accountInfo == null){
+            if (accountInfo == null) {
                 throw new Exception("请重新登录");
             }
             BigDecimal withdrawalAmount = BigDecimal.ZERO;
@@ -710,29 +710,29 @@ public class MerchantApiController {
             BigDecimal alreadyWithdrawalAmount = BigDecimal.ZERO;
 
             CapitalInfo capitalInfo = capitalInfoService.findByMerchantId(accountInfo.getId());
-            if (capitalInfo != null){
+            if (capitalInfo != null) {
                 withdrawalAmount = capitalInfo.getWithdrawalAmount();
                 onlineTotalRevenue = capitalInfo.getOnlineTotalRevenue();
                 alreadyWithdrawalAmount = capitalInfo.getAlreadyWithdrawalAmount();
             }
             CompanyInfo companyInfo = companyInfoService.get(accountInfo.getCompanyId());
             List<VehicleInfo> vehicleInfoList = vehicleInfoService.findByCompanyId(companyInfo.getId());
-         //   if (vehicleInfoList.size()>0){
-                BigDecimal wechatTodaySum = orderInfoService.paySum(null,companyInfo.getId(),"wechat",DateUtil.beginOfDay(new Date()),DateUtil.endOfDay(new Date()),false);
-                BigDecimal alipayTodaySum = orderInfoService.paySum(null,companyInfo.getId(),"alipay",DateUtil.beginOfDay(new Date()),DateUtil.endOfDay(new Date()),false);
-                todayRevenue = (wechatTodaySum == null?BigDecimal.ZERO:wechatTodaySum).add(alipayTodaySum==null?BigDecimal.ZERO:alipayTodaySum);
+            //   if (vehicleInfoList.size()>0){
+            BigDecimal wechatTodaySum = orderInfoService.paySum(null, companyInfo.getId(), "wechat", DateUtil.beginOfDay(new Date()), DateUtil.endOfDay(new Date()), false);
+            BigDecimal alipayTodaySum = orderInfoService.paySum(null, companyInfo.getId(), "alipay", DateUtil.beginOfDay(new Date()), DateUtil.endOfDay(new Date()), false);
+            todayRevenue = (wechatTodaySum == null ? BigDecimal.ZERO : wechatTodaySum).add(alipayTodaySum == null ? BigDecimal.ZERO : alipayTodaySum);
 
-        //    }
+            //    }
 
 
             DataDictionary dataDictionary = dataDictionaryService.findByName("提现日期");
-            Map<String,Object> map = new HashMap<>();
-            map.put("withdrawalAmount",withdrawalAmount);
-            map.put("todayRevenue",todayRevenue);
-            map.put("onlineTotalRevenue",onlineTotalRevenue.add(todayRevenue));
-            map.put("alreadyWithdrawalAmount",alreadyWithdrawalAmount);
-            map.put("account",accountInfo);
-            map.put("date",dataDictionary.getValue());
+            Map<String, Object> map = new HashMap<>();
+            map.put("withdrawalAmount", withdrawalAmount);
+            map.put("todayRevenue", todayRevenue);
+            map.put("onlineTotalRevenue", onlineTotalRevenue.add(todayRevenue));
+            map.put("alreadyWithdrawalAmount", alreadyWithdrawalAmount);
+            map.put("account", accountInfo);
+            map.put("date", dataDictionary.getValue());
 
 
             messageResult.setData(map);
@@ -757,7 +757,7 @@ public class MerchantApiController {
         try {
 
             AccountInfo accountInfo = accountInfoService.get(subject);
-            if (accountInfo == null){
+            if (accountInfo == null) {
                 throw new Exception("请重新登录");
             }
 
@@ -779,30 +779,30 @@ public class MerchantApiController {
 
     @PostMapping("withdrawalRecordList")
     @ApiOperation(value = "提现记录")
-    public MessageResult<Map> withdrawalRecordList(String token, @RequestAttribute String subject,@RequestParam(value = "pageIndex", defaultValue = "1") int pageIndex, @RequestParam(value = "pageSize", defaultValue = "20") int pageSize) {
+    public MessageResult<Map> withdrawalRecordList(String token, @RequestAttribute String subject, @RequestParam(value = "pageIndex", defaultValue = "1") int pageIndex, @RequestParam(value = "pageSize", defaultValue = "20") int pageSize) {
         MessageResult<Map> messageResult = new MessageResult<>();
 
         try {
 
             AccountInfo accountInfo = accountInfoService.get(subject);
-            if (accountInfo == null){
+            if (accountInfo == null) {
                 throw new Exception("请重新登录");
             }
 
-            Map<String,Object> searchParams = new HashMap<>();
-            searchParams.put("merchantId",accountInfo.getId());
+            Map<String, Object> searchParams = new HashMap<>();
+            searchParams.put("merchantId", accountInfo.getId());
             List<Sort> sortList = new ArrayList<>();
-            sortList.add(new Sort("create_time","desc"));
-            Page<WithdrawalRecord> page = withdrawalRecordService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);
+            sortList.add(new Sort("create_time", "desc"));
+            Page<WithdrawalRecord> page = withdrawalRecordService.pageSearch(searchParams, pageIndex, pageSize, true, sortList);
 
             List<WithdrawalRecord> withdrawalRecordList = page.getResult();
             List<WithdrawalRecordListDTO> list = new ArrayList<>();
-            if (withdrawalRecordList.size()>0){
-                for (WithdrawalRecord withdrawalRecord : withdrawalRecordList){
+            if (withdrawalRecordList.size() > 0) {
+                for (WithdrawalRecord withdrawalRecord : withdrawalRecordList) {
                     WithdrawalRecordListDTO withdrawalRecordListDTO = new WithdrawalRecordListDTO();
                     withdrawalRecordListDTO.setId(withdrawalRecord.getId());
                     withdrawalRecordListDTO.setName("账户提现");
-                    withdrawalRecordListDTO.setTime(DateUtil.format(withdrawalRecord.getCreateTime(),"yyyy-MM-dd HH:mm:ss"));
+                    withdrawalRecordListDTO.setTime(DateUtil.format(withdrawalRecord.getCreateTime(), "yyyy-MM-dd HH:mm:ss"));
                     withdrawalRecordListDTO.setStatus(withdrawalRecord.getStatus());
                     withdrawalRecordListDTO.setStatusStr(withdrawalRecord.getStatusStr(withdrawalRecord.getStatus()));
                     withdrawalRecordListDTO.setAmount("-" + withdrawalRecord.getApplyWithdrawalAmount());
@@ -810,12 +810,12 @@ public class MerchantApiController {
 
                 }
             }
-            Map<String,Object> pageMap = new HashMap<>();
-            pageMap.put("recordsTotal",page.getTotal());
-            pageMap.put("recordsFiltered",page.getTotal());
-            pageMap.put("totalPage",page.getPages());
-            pageMap.put("pageNumber",page.getPageNum());
-            pageMap.put("pageSize",page.getPageSize());
+            Map<String, Object> pageMap = new HashMap<>();
+            pageMap.put("recordsTotal", page.getTotal());
+            pageMap.put("recordsFiltered", page.getTotal());
+            pageMap.put("totalPage", page.getPages());
+            pageMap.put("pageNumber", page.getPageNum());
+            pageMap.put("pageSize", page.getPageSize());
             pageMap.put("data", list);
 
             messageResult.setData(pageMap);
@@ -840,25 +840,24 @@ public class MerchantApiController {
         try {
 
             AccountInfo accountInfo = accountInfoService.get(subject);
-            if (accountInfo == null){
+            if (accountInfo == null) {
                 throw new Exception("请重新登录");
             }
 
             WithdrawalRecord withdrawalRecord = withdrawalRecordService.get(id);
-            if (withdrawalRecord == null){
+            if (withdrawalRecord == null) {
                 throw new Exception("记录不存在");
             }
             WithdrawalRecordDetailDTO withdrawalRecordDetailDTO = new WithdrawalRecordDetailDTO();
             withdrawalRecordDetailDTO.setName("账户提现");
-            withdrawalRecordDetailDTO.setAmount("-"+withdrawalRecord.getApplyWithdrawalAmount());
+            withdrawalRecordDetailDTO.setAmount("-" + withdrawalRecord.getApplyWithdrawalAmount());
             withdrawalRecordDetailDTO.setStatus(withdrawalRecord.getStatus());
             withdrawalRecordDetailDTO.setStatusStr(withdrawalRecord.getStatusStr(withdrawalRecord.getStatus()));
             withdrawalRecordDetailDTO.setWithdrawalNo(withdrawalRecord.getWithdrawalNo());
-            if ("0".equals(withdrawalRecord.getStatus())){
-                withdrawalRecordDetailDTO.setTime(DateUtil.format(withdrawalRecord.getCreateTime(),"yyyy-MM-dd HH:mm:ss"));
-            }
-            else {
-                withdrawalRecordDetailDTO.setTime(DateUtil.format(withdrawalRecord.getExamineTime(),"yyyy-MM-dd HH:mm:ss"));
+            if ("0".equals(withdrawalRecord.getStatus())) {
+                withdrawalRecordDetailDTO.setTime(DateUtil.format(withdrawalRecord.getCreateTime(), "yyyy-MM-dd HH:mm:ss"));
+            } else {
+                withdrawalRecordDetailDTO.setTime(DateUtil.format(withdrawalRecord.getExamineTime(), "yyyy-MM-dd HH:mm:ss"));
             }
 
             withdrawalRecordDetailDTO.setRemark(withdrawalRecord.getRemark());
@@ -885,21 +884,21 @@ public class MerchantApiController {
         try {
 
             AccountInfo accountInfo = accountInfoService.get(subject);
-            if (accountInfo == null){
+            if (accountInfo == null) {
                 throw new Exception("请重新登录");
             }
 
             CapitalInfo capitalInfo = capitalInfoService.findByMerchantId(accountInfo.getId());
-            if (capitalInfo == null){
+            if (capitalInfo == null) {
                 throw new Exception("没有相关账户信息");
             }
-            List<WithdrawalRecord> withdrawalRecordList = withdrawalRecordService.findByMerchantIdAndStatus(accountInfo.getId(),"0");
+            List<WithdrawalRecord> withdrawalRecordList = withdrawalRecordService.findByMerchantIdAndStatus(accountInfo.getId(), "0");
 
-            if (withdrawalRecordList.size()>0){
+            if (withdrawalRecordList.size() > 0) {
                 throw new Exception("有一笔正在审核的提现记录,不可再次申请");
             }
             BigDecimal bigAmount = new BigDecimal(amount);
-            if (bigAmount.compareTo(capitalInfo.getWithdrawalAmount()) >0){
+            if (bigAmount.compareTo(capitalInfo.getWithdrawalAmount()) > 0) {
                 throw new Exception("提现金额不可超过可提现金额");
             }