|
@@ -8,7 +8,10 @@ import com.jpsoft.bus.modules.base.entity.OrderInfo;
|
|
|
import com.jpsoft.bus.modules.base.entity.ProblemFeedback;
|
|
|
import com.jpsoft.bus.modules.base.service.MergeOrderInfoService;
|
|
|
import com.jpsoft.bus.modules.base.service.OrderInfoService;
|
|
|
+import com.jpsoft.bus.modules.bus.dto.ShiftRevenueDTO;
|
|
|
import com.jpsoft.bus.modules.bus.dto.VehicleDTO;
|
|
|
+import com.jpsoft.bus.modules.bus.dto.VehicleShiftDTO;
|
|
|
+import com.jpsoft.bus.modules.bus.dto.VehicleShiftListDTO;
|
|
|
import com.jpsoft.bus.modules.bus.entity.*;
|
|
|
import com.jpsoft.bus.modules.bus.service.*;
|
|
|
import com.jpsoft.bus.modules.common.dto.MessageResult;
|
|
@@ -238,7 +241,7 @@ public class MerchantApiController {
|
|
|
|
|
|
@PostMapping("revenueStatisticsUp")
|
|
|
@ApiOperation(value = "营收统计(上)")
|
|
|
- public MessageResult<Map> revenueStatisticsUp(String token, @RequestAttribute String subject) {
|
|
|
+ public MessageResult<Map> revenueStatisticsUp(String vehicleId, String token, @RequestAttribute String subject) {
|
|
|
MessageResult<Map> messageResult = new MessageResult<>();
|
|
|
|
|
|
try {
|
|
@@ -248,7 +251,14 @@ public class MerchantApiController {
|
|
|
throw new Exception("请重新登录");
|
|
|
}
|
|
|
CompanyInfo companyInfo = companyInfoService.get(accountInfo.getCompanyId());
|
|
|
- List<VehicleInfo> vehicleInfoList = vehicleInfoService.getAllVehicleByAccount(accountInfo);
|
|
|
+ List<VehicleInfo> vehicleInfoList = new ArrayList<>();
|
|
|
+ if (StringUtils.isBlank(vehicleId)) {
|
|
|
+ vehicleInfoList = vehicleInfoService.getAllVehicleByAccount(accountInfo);
|
|
|
+ } else {
|
|
|
+ VehicleInfo vehicleInfo = vehicleInfoService.get(vehicleId);
|
|
|
+ vehicleInfoList.add(vehicleInfo);
|
|
|
+ }
|
|
|
+
|
|
|
//今日收益
|
|
|
BigDecimal todayRevenue = BigDecimal.ZERO;
|
|
|
//昨日收益
|
|
@@ -303,7 +313,7 @@ public class MerchantApiController {
|
|
|
|
|
|
@PostMapping("revenueStatisticsDown")
|
|
|
@ApiOperation(value = "营收统计(下)")
|
|
|
- public MessageResult<Map> revenueStatisticsDown(String token, @RequestAttribute String subject) {
|
|
|
+ public MessageResult<Map> revenueStatisticsDown(String vehicleId, String token, @RequestAttribute String subject) {
|
|
|
MessageResult<Map> messageResult = new MessageResult<>();
|
|
|
|
|
|
try {
|
|
@@ -313,7 +323,15 @@ public class MerchantApiController {
|
|
|
throw new Exception("请重新登录");
|
|
|
}
|
|
|
CompanyInfo companyInfo = companyInfoService.get(accountInfo.getCompanyId());
|
|
|
- List<VehicleInfo> vehicleInfoList = vehicleInfoService.getAllVehicleByAccount(accountInfo);
|
|
|
+ // List<VehicleInfo> vehicleInfoList = vehicleInfoService.getAllVehicleByAccount(accountInfo);
|
|
|
+
|
|
|
+ List<VehicleInfo> vehicleInfoList = new ArrayList<>();
|
|
|
+ if (StringUtils.isBlank(vehicleId)) {
|
|
|
+ vehicleInfoList = vehicleInfoService.getAllVehicleByAccount(accountInfo);
|
|
|
+ } else {
|
|
|
+ VehicleInfo vehicleInfo = vehicleInfoService.get(vehicleId);
|
|
|
+ vehicleInfoList.add(vehicleInfo);
|
|
|
+ }
|
|
|
//线上购票款
|
|
|
BigDecimal onlineRevenue = BigDecimal.ZERO;
|
|
|
//微信收款
|
|
@@ -381,6 +399,185 @@ public class MerchantApiController {
|
|
|
return messageResult;
|
|
|
}
|
|
|
|
|
|
+ @PostMapping("vehicleShiftList")
|
|
|
+ @ApiOperation(value = "商户的车辆班次列表")
|
|
|
+ public MessageResult<Map> vehicleShiftList(String vehicleId, String date, 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) {
|
|
|
+ throw new Exception("请重新登录");
|
|
|
+ }
|
|
|
+ Map<String, Object> searchParams = new HashMap<>();
|
|
|
+ List<VehicleInfo> vehicleInfoList = new ArrayList<>();
|
|
|
+ if (StringUtils.isBlank(vehicleId)) {
|
|
|
+ vehicleInfoList = vehicleInfoService.getAllVehicleByAccount(accountInfo);
|
|
|
+ } else {
|
|
|
+ VehicleInfo vehicleInfo = vehicleInfoService.get(vehicleId);
|
|
|
+ vehicleInfoList.add(vehicleInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+ searchParams.put("vehicleInfoList", vehicleInfoList);
|
|
|
+ if (StringUtils.isNotBlank(date)){
|
|
|
+ searchParams.put("startTime", DateUtil.beginOfDay(DateUtil.parse(date)));
|
|
|
+ searchParams.put("endTime", DateUtil.endOfDay(DateUtil.parse(date)));
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Sort> sortList = new ArrayList<>();
|
|
|
+ sortList.add(new Sort("a.vehicle_id", "desc"));
|
|
|
+ sortList.add(new Sort("a.create_time", "desc"));
|
|
|
+ Page<ShiftInfo> page = shiftInfoService.pageSearch(searchParams, pageIndex, pageSize, true, sortList);
|
|
|
+ List<ShiftInfo> shiftInfoList = page.getResult();
|
|
|
+ List<VehicleShiftListDTO> list = new ArrayList<>();
|
|
|
+ if (shiftInfoList.size() > 0) {
|
|
|
+ for (ShiftInfo shiftInfo : shiftInfoList) {
|
|
|
+ VehicleShiftListDTO vehicleShiftListDTO = new VehicleShiftListDTO();
|
|
|
+ VehicleInfo vehicleInfo = vehicleInfoService.get(shiftInfo.getVehicleId());
|
|
|
+ String dateStr1 = DateUtil.format(shiftInfo.getCreateTime(), "yyyy-MM-dd");
|
|
|
+ String dateStr2 = DateUtil.format(shiftInfo.getCreateTime(), "HH:mm");
|
|
|
+ if ("1".equals(shiftInfo.getStatus())) {
|
|
|
+ dateStr2 = dateStr2 + "-" + "待结束";
|
|
|
+ }
|
|
|
+ if ("2".equals(shiftInfo.getStatus())) {
|
|
|
+ dateStr2 = dateStr2 + "-" + DateUtil.format(shiftInfo.getFinishTime(), "HH:mm");
|
|
|
+ }
|
|
|
+ vehicleShiftListDTO.setId(shiftInfo.getId());
|
|
|
+ vehicleShiftListDTO.setCarNum(vehicleInfo.getLicensePlateNumber());
|
|
|
+ vehicleShiftListDTO.setDateStr(dateStr1 + " " + dateStr2);
|
|
|
+
|
|
|
+ Map<String, Object> searchParams1 = new HashMap<>();
|
|
|
+ searchParams1.put("payStatus",20);
|
|
|
+ searchParams1.put("vehicleShiftId",shiftInfo.getId());
|
|
|
+ List<Sort> sortList1 = new ArrayList<>();
|
|
|
+ sortList1.add(new Sort("a.pay_time","desc"));
|
|
|
+ List<OrderInfo> orderInfoList = orderInfoService.findBySearchParams(searchParams1,sortList1);
|
|
|
+ BigDecimal total = BigDecimal.ZERO;
|
|
|
+ if (orderInfoList.size()>0){
|
|
|
+ for (OrderInfo orderInfo : orderInfoList){
|
|
|
+ total = total.add(orderInfo.getPayFee());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ vehicleShiftListDTO.setTotal(total);
|
|
|
+ list.add(vehicleShiftListDTO);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ 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);
|
|
|
+ messageResult.setCode(400);
|
|
|
+ messageResult.setResult(false);
|
|
|
+ messageResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return messageResult;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @PostMapping("vehicleShiftDetail")
|
|
|
+ @ApiOperation(value = "商户的车辆班次详情")
|
|
|
+ public MessageResult<VehicleShiftDTO> vehicleShiftDetail(String id, String token, @RequestAttribute String subject) {
|
|
|
+ MessageResult<VehicleShiftDTO> messageResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+
|
|
|
+ AccountInfo accountInfo = accountInfoService.get(subject);
|
|
|
+ if (accountInfo == null) {
|
|
|
+ throw new Exception("请重新登录");
|
|
|
+ }
|
|
|
+ VehicleShiftDTO vehicleShiftDTO = new VehicleShiftDTO();
|
|
|
+ ShiftInfo shiftInfo = shiftInfoService.get(id);
|
|
|
+ VehicleInfo vehicleInfo = vehicleInfoService.get(shiftInfo.getVehicleId());
|
|
|
+ DriverInfo driverInfo = driverInfoService.get(shiftInfo.getDriverId());
|
|
|
+ //开始站
|
|
|
+ StationInfo startStation = stationInfoService.get(shiftInfo.getStartStationId());
|
|
|
+ //终点站
|
|
|
+ StationInfo endStation = stationInfoService.get(shiftInfo.getEndStationId());
|
|
|
+
|
|
|
+ String shiftDateStr = DateUtil.format(shiftInfo.getCreateTime(), "HH:mm");
|
|
|
+ if ("1".equals(shiftInfo.getStatus())) {
|
|
|
+ shiftDateStr = shiftDateStr + "-" + "待结束";
|
|
|
+ }
|
|
|
+ if ("2".equals(shiftInfo.getStatus())) {
|
|
|
+ shiftDateStr = shiftDateStr + "-" + DateUtil.format(shiftInfo.getFinishTime(), "HH:mm");
|
|
|
+ }
|
|
|
+ vehicleShiftDTO.setRouteName(startStation.getName()+"-" + endStation.getName());
|
|
|
+ vehicleShiftDTO.setCarNum(vehicleInfo.getLicensePlateNumber());
|
|
|
+ vehicleShiftDTO.setDriverName(driverInfo.getName());
|
|
|
+ vehicleShiftDTO.setDateStr(DateUtil.format(shiftInfo.getCreateTime(),"yyyy-MM-dd"));
|
|
|
+ vehicleShiftDTO.setShiftDateStr(shiftDateStr);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ Map<String, Object> searchParams = new HashMap<>();
|
|
|
+ searchParams.put("shiftId", shiftInfo.getId());
|
|
|
+ searchParams.put("payStatus", 20);
|
|
|
+ List<Sort> sortList = new ArrayList<>();
|
|
|
+ sortList.add(new Sort("a.pay_fee", "asc"));
|
|
|
+ Page<OrderInfo> page = orderInfoService.pageSearch(searchParams, 1, 5000, false, sortList);
|
|
|
+
|
|
|
+ List<OrderInfo> orderInfoList = page.getResult();
|
|
|
+ BigDecimal total = BigDecimal.ZERO;
|
|
|
+ Integer personNum = orderInfoList.size();
|
|
|
+ List<ShiftRevenueDTO> shiftRevenueDTOList = new ArrayList<>();
|
|
|
+ List<BigDecimal> ticketPrice = new ArrayList<>();
|
|
|
+ Map<BigDecimal, List<OrderInfo>> map = new LinkedHashMap<>();
|
|
|
+ if (orderInfoList.size() > 0) {
|
|
|
+ BigDecimal key;
|
|
|
+ List<OrderInfo> listTmp;
|
|
|
+ for (OrderInfo val : orderInfoList) {
|
|
|
+ total = total.add(val.getPayFee());
|
|
|
+ key = val.getPayFee();//按这个属性分组,map的Key
|
|
|
+ listTmp = map.get(key);
|
|
|
+ if (null == listTmp) {
|
|
|
+ listTmp = new ArrayList<OrderInfo>();
|
|
|
+ map.put(key, listTmp);
|
|
|
+ }
|
|
|
+ listTmp.add(val);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (Map.Entry<BigDecimal, List<OrderInfo>> date : map.entrySet()){
|
|
|
+ BigDecimal payFee = date.getKey();
|
|
|
+ List<OrderInfo> orderInfos = date.getValue();
|
|
|
+ ShiftRevenueDTO shiftRevenueDTO = new ShiftRevenueDTO();
|
|
|
+ shiftRevenueDTO.setPrice(payFee);
|
|
|
+ shiftRevenueDTO.setNum(orderInfos.size());
|
|
|
+ shiftRevenueDTO.setTotal(payFee.multiply(new BigDecimal(orderInfos.size())));
|
|
|
+ shiftRevenueDTOList.add(shiftRevenueDTO);
|
|
|
+ }
|
|
|
+ vehicleShiftDTO.setList(shiftRevenueDTOList);
|
|
|
+ vehicleShiftDTO.setPassengerNum(personNum);
|
|
|
+ vehicleShiftDTO.setTotal(total);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ messageResult.setData(vehicleShiftDTO);
|
|
|
+ messageResult.setResult(true);
|
|
|
+ messageResult.setCode(200);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ log.error(ex.getMessage(), ex);
|
|
|
+ messageResult.setCode(400);
|
|
|
+ messageResult.setResult(false);
|
|
|
+ messageResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return messageResult;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
@PostMapping("merchantVehicleList")
|
|
|
@ApiOperation(value = "商户的车辆列表")
|
|
@@ -558,8 +755,8 @@ public class MerchantApiController {
|
|
|
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"));
|