|
@@ -2,18 +2,25 @@ package com.jpsoft.bus.modules.mobile.controller;
|
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.github.pagehelper.Page;
|
|
|
+import com.jpsoft.bus.modules.base.entity.MergeOrderInfo;
|
|
|
+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.VehicleDTO;
|
|
|
-import com.jpsoft.bus.modules.bus.entity.CompanyInfo;
|
|
|
-import com.jpsoft.bus.modules.bus.entity.UserInfo;
|
|
|
-import com.jpsoft.bus.modules.bus.entity.VehicleInfo;
|
|
|
+import com.jpsoft.bus.modules.bus.entity.*;
|
|
|
import com.jpsoft.bus.modules.bus.service.CompanyInfoService;
|
|
|
+import com.jpsoft.bus.modules.bus.service.ShiftInfoService;
|
|
|
+import com.jpsoft.bus.modules.bus.service.StationInfoService;
|
|
|
import com.jpsoft.bus.modules.bus.service.VehicleInfoService;
|
|
|
import com.jpsoft.bus.modules.common.dto.MessageResult;
|
|
|
+import com.jpsoft.bus.modules.common.dto.Sort;
|
|
|
import com.jpsoft.bus.modules.common.utils.DES3;
|
|
|
import com.jpsoft.bus.modules.common.utils.JwtUtil;
|
|
|
import com.jpsoft.bus.modules.common.utils.SMSUtil;
|
|
|
+import com.jpsoft.bus.modules.merchant.dto.ProfitListDTO;
|
|
|
+import com.jpsoft.bus.modules.merchant.dto.SellListDTO;
|
|
|
import com.jpsoft.bus.modules.merchant.entity.AccountInfo;
|
|
|
import com.jpsoft.bus.modules.merchant.entity.CapitalInfo;
|
|
|
import com.jpsoft.bus.modules.merchant.service.AccountInfoService;
|
|
@@ -29,10 +36,7 @@ import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestAttribute;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
@@ -57,12 +61,21 @@ public class MerchantApiController {
|
|
|
@Autowired
|
|
|
private CapitalInfoService capitalInfoService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private MergeOrderInfoService mergeOrderInfoService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private OrderInfoService orderInfoService;
|
|
|
|
|
|
@Autowired
|
|
|
private VehicleInfoService vehicleInfoService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private StationInfoService stationInfoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ShiftInfoService shiftInfoService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private RedisTemplate redisTemplate;
|
|
|
|
|
@@ -159,7 +172,7 @@ public class MerchantApiController {
|
|
|
messageResult.setResult(true);
|
|
|
messageResult.setCode(200);
|
|
|
} catch (Exception ex) {
|
|
|
- log.error(ex.getMessage());
|
|
|
+ log.error(ex.getMessage(),ex);
|
|
|
messageResult.setCode(400);
|
|
|
messageResult.setResult(false);
|
|
|
messageResult.setMessage(ex.getMessage());
|
|
@@ -387,13 +400,14 @@ public class MerchantApiController {
|
|
|
@ApiImplicitParams({
|
|
|
@ApiImplicitParam(name = "vehicleId", value = "车辆id", required = false, paramType = "form"),
|
|
|
@ApiImplicitParam(name = "payName", value = "支付方式(微信:wechat,支付宝:alipay,现金:cash,车票:ticket)", required = false, paramType = "form"),
|
|
|
- @ApiImplicitParam(name = "date", value = "时间(格式:yyyy-MM)", required = false, paramType = "form")
|
|
|
+ @ApiImplicitParam(name = "dateStr", value = "时间(格式:yyyy-MM)", required = false, paramType = "form")
|
|
|
})
|
|
|
- public MessageResult<Map> profitList(String vehicleId,String payName,String date,String token, @RequestAttribute String subject) {
|
|
|
- MessageResult<Map> messageResult = new MessageResult<>();
|
|
|
+ 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){
|
|
|
throw new Exception("请重新登录");
|
|
@@ -412,15 +426,145 @@ public class MerchantApiController {
|
|
|
|
|
|
|
|
|
|
|
|
+ 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");
|
|
|
+
|
|
|
+ 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){
|
|
|
+ n = DateUtil.thisDayOfMonth();
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ n = DateUtil.thisDayOfMonth();
|
|
|
+ }
|
|
|
+
|
|
|
+ BigDecimal revenue = BigDecimal.ZERO;
|
|
|
+
|
|
|
+ profitListDTO.setDateDesc(dateDesc);
|
|
|
+
|
|
|
+
|
|
|
+ List<ProfitListDTO> list = new ArrayList<>();
|
|
|
+ if (n>0){
|
|
|
+ for (int m = 0 ; m <n; m++){
|
|
|
+ ProfitListDTO profitListDTO1 = new ProfitListDTO();
|
|
|
+ Date baseDate = DateUtil.offsetDay(startDate,-m);
|
|
|
+ Date baseStartDate = DateUtil.beginOfDay(baseDate);
|
|
|
+ BigDecimal baseSum = orderInfoService.paySum(vehicleInfoList,payName,baseStartDate,baseDate,null);
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ profitListDTO.setRevenue(revenue);
|
|
|
+ profitListDTO.setList(list);
|
|
|
+ messageResult.setData(profitListDTO);
|
|
|
+ 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("sellList")
|
|
|
+ @ApiOperation(value = "售票明细")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "vehicleId", value = "车辆id", required = false, paramType = "form"),
|
|
|
+ @ApiImplicitParam(name = "payName", value = "支付方式(微信:wechat,支付宝:alipay,现金:cash,车票:ticket)", required = false, paramType = "form"),
|
|
|
+ @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) {
|
|
|
+ MessageResult<Map> messageResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+
|
|
|
+ AccountInfo accountInfo = accountInfoService.get(subject);
|
|
|
+ if (accountInfo == null){
|
|
|
+ throw new Exception("请重新登录");
|
|
|
+ }
|
|
|
+ CompanyInfo companyInfo = companyInfoService.get(accountInfo.getCompanyId());
|
|
|
+ List<VehicleInfo> vehicleInfoList = new ArrayList<>();
|
|
|
+ if (StringUtils.isNotBlank(vehicleId)){
|
|
|
+ VehicleInfo vehicleInfo = vehicleInfoService.get(vehicleId);
|
|
|
+ if (vehicleInfo != null){
|
|
|
+ vehicleInfoList.add(vehicleInfo);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ vehicleInfoList = vehicleInfoService.findByCompanyId(companyInfo.getId());
|
|
|
+ }
|
|
|
|
|
|
+ Map<String,Object> searchParams = new HashMap<>();
|
|
|
+ searchParams.put("payStatus",20);
|
|
|
+ if (StringUtils.isNotBlank(payName)){
|
|
|
+ searchParams.put("payName",payName);
|
|
|
+ }
|
|
|
|
|
|
- // map.put("token", token);
|
|
|
+ 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)){
|
|
|
+ endTime = middleTime;
|
|
|
+ }
|
|
|
+ if ("2".equals(dateType)){
|
|
|
+ startTime = middleTime;
|
|
|
+ }
|
|
|
|
|
|
- // messageResult.setData(map);
|
|
|
+ searchParams.put("payBeginTime",startTime);
|
|
|
+ searchParams.put("payEndTime",endTime);
|
|
|
+ searchParams.put("vehicleInfoList",vehicleInfoList);
|
|
|
+
|
|
|
+ List<Sort> sortList = new ArrayList<>();
|
|
|
+ sortList.add(new Sort("a.pay_time","desc"));
|
|
|
+
|
|
|
+ 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){
|
|
|
+ SellListDTO sellListDTO = new SellListDTO();
|
|
|
+ BeanUtils.copyProperties(orderInfo,sellListDTO);
|
|
|
+
|
|
|
+ MergeOrderInfo mergeOrderInfo = mergeOrderInfoService.get(orderInfo.getMergeOrderId());
|
|
|
+ ShiftInfo shiftInfo = shiftInfoService.get(mergeOrderInfo.getVehicleShiftId());
|
|
|
+ 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());
|
|
|
+ pageMap.put("data", list);
|
|
|
+
|
|
|
+ messageResult.setData(pageMap);
|
|
|
messageResult.setResult(true);
|
|
|
messageResult.setCode(200);
|
|
|
} catch (Exception ex) {
|
|
|
- log.error(ex.getMessage());
|
|
|
+ log.error(ex.getMessage(),ex);
|
|
|
messageResult.setCode(400);
|
|
|
messageResult.setResult(false);
|
|
|
messageResult.setMessage(ex.getMessage());
|