Преглед изворни кода

创建订单返回数据修改

fllmoyu пре 4 година
родитељ
комит
970a3f205e

+ 18 - 0
common/src/main/java/com/jpsoft/bus/modules/base/dto/MergeOrderDTO.java

@@ -0,0 +1,18 @@
+package com.jpsoft.bus.modules.base.dto;
+
+import com.jpsoft.bus.modules.bus.dto.PassengerRecordDTO;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * @author 墨鱼_mo
+ * @date 2021-4-20 11:50
+ */
+@Data
+public class MergeOrderDTO {
+
+    private String id;
+
+    private List<PassengerRecordDTO> passengerRecordDTOList;
+}

+ 3 - 1
common/src/main/java/com/jpsoft/bus/modules/bus/service/PassengerInfoService.java

@@ -3,6 +3,8 @@ package com.jpsoft.bus.modules.bus.service;
 import java.util.List;
 import java.util.Map;
 
+import com.jpsoft.bus.modules.base.dto.MergeOrderDTO;
+import com.jpsoft.bus.modules.base.entity.MergeOrderInfo;
 import com.jpsoft.bus.modules.base.entity.OrderInfo;
 import com.jpsoft.bus.modules.bus.dto.DriverBuyTicketDTO;
 import com.jpsoft.bus.modules.bus.entity.PassengerInfo;
@@ -28,7 +30,7 @@ public interface PassengerInfoService {
 
     List<PassengerInfo> findByShiftStatusPayStatusNotTicketDown(String shiftId, String status, String payStatus,String ticketDownStationId);
 
-	String createOrder(VehicleInfo vehicleInfo, ShiftInfo shiftInfo,String openId,String mergeOrderId, String passengerIds, String ticketUpStationId, String ticketDownStationId, String ticketType, String goodsTicket, String totalFee) throws Exception;
+	MergeOrderDTO createOrder(VehicleInfo vehicleInfo, ShiftInfo shiftInfo, String openId, String mergeOrderId, String passengerIds, String ticketUpStationId, String ticketDownStationId, String ticketType, String goodsTicket, String totalFee) throws Exception;
 
 	void updatePassengerOrder(OrderInfo orderInfo, String ticketUpStationId, String ticketDownStationId, String ticketType, String goodsTicket, String totalFee);
 }

+ 32 - 6
common/src/main/java/com/jpsoft/bus/modules/bus/service/impl/PassengerInfoServiceImpl.java

@@ -8,6 +8,7 @@ import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.StrUtil;
 import com.google.common.collect.Ordering;
 import com.jpsoft.bus.config.WxJpsoftConfig;
+import com.jpsoft.bus.modules.base.dto.MergeOrderDTO;
 import com.jpsoft.bus.modules.base.entity.MergeOrderInfo;
 import com.jpsoft.bus.modules.base.entity.OrderInfo;
 import com.jpsoft.bus.modules.base.entity.PaymentInfo;
@@ -15,10 +16,9 @@ import com.jpsoft.bus.modules.base.service.MergeOrderInfoService;
 import com.jpsoft.bus.modules.base.service.OrderInfoService;
 import com.jpsoft.bus.modules.base.service.PaymentInfoService;
 import com.jpsoft.bus.modules.bus.dto.DriverBuyTicketDTO;
+import com.jpsoft.bus.modules.bus.dto.PassengerRecordDTO;
 import com.jpsoft.bus.modules.bus.entity.*;
-import com.jpsoft.bus.modules.bus.service.BaiduService;
-import com.jpsoft.bus.modules.bus.service.CompanyInfoService;
-import com.jpsoft.bus.modules.bus.service.PriceInfoService;
+import com.jpsoft.bus.modules.bus.service.*;
 import com.jpsoft.bus.modules.common.utils.CommonUtil;
 import com.jpsoft.bus.modules.pay.service.AlipayService;
 import com.jpsoft.bus.modules.pay.service.WechatService;
@@ -27,7 +27,6 @@ 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.PassengerInfoDAO;
-import com.jpsoft.bus.modules.bus.service.PassengerInfoService;
 import com.github.pagehelper.Page;
 import com.jpsoft.bus.modules.common.dto.Sort;
 import com.github.pagehelper.PageHelper;
@@ -41,6 +40,9 @@ public class PassengerInfoServiceImpl implements PassengerInfoService {
     @Autowired
     private MergeOrderInfoService mergeOrderInfoService;
 
+    @Autowired
+    private StationInfoService stationInfoService;
+
     @Autowired
     private WxJpsoftConfig wxJpsoftConfig;
 
@@ -288,9 +290,10 @@ public class PassengerInfoServiceImpl implements PassengerInfoService {
     }
 
     @Override
-    public String createOrder(VehicleInfo vehicleInfo, ShiftInfo shiftInfo, String openId, String mergeOrderId,String passengerIds, String ticketUpStationId, String ticketDownStationId, String ticketType, String goodsTicket, String totalFee) throws Exception {
+    public MergeOrderDTO createOrder(VehicleInfo vehicleInfo, ShiftInfo shiftInfo, String openId, String mergeOrderId, String passengerIds, String ticketUpStationId, String ticketDownStationId, String ticketType, String goodsTicket, String totalFee) throws Exception {
 
 
+        MergeOrderDTO mergeOrderDTO = new MergeOrderDTO();
 
         //乘客id集合
         List<String> passengerList = Arrays.asList(passengerIds.split(","));
@@ -361,13 +364,18 @@ public class PassengerInfoServiceImpl implements PassengerInfoService {
             mergeId = mergeOrderInfo.getId();
         }
 
+        mergeOrderDTO.setId(mergeId);
+
         PassengerInfo passengerInfo0 = get(passengerList.get(0));
 
         String upStationId = passengerInfo0.getUpStationId();
 
         Boolean goodTicketStatus = false;
+        List<PassengerRecordDTO> passengerRecordDTOList = new ArrayList<>();
         for (String passengerId : passengerList) {
 
+            PassengerRecordDTO passengerRecordDTO = new PassengerRecordDTO();
+
             OrderInfo orderInfo0 = orderInfoService.findByPassengerIdMergeOrderId(passengerId,mergeId);
             if (orderInfo0 != null){
                 throw new Exception("有乘客已加入此账单,不可重复添加");
@@ -401,6 +409,23 @@ public class PassengerInfoServiceImpl implements PassengerInfoService {
                     orderInfo.setTicketUpStationId(ticketUpStationId);
                     orderInfo.setTicketDownStationId(ticketDownStationId);
                     orderInfoService.insert(orderInfo);
+
+                    passengerRecordDTO.setId(orderInfo.getId());
+                    passengerRecordDTO.setImageUrl(passengerInfo.getImageUrl());
+
+                    //开始站点
+                    StationInfo startStation = stationInfoService.get(orderInfo.getTicketUpStationId());
+                    //终点站
+                    StationInfo endStation = stationInfoService.get(orderInfo.getTicketDownStationId());
+                    passengerRecordDTO.setStartStation(startStation.getName());
+                    passengerRecordDTO.setEndStation(endStation.getName());
+                    passengerRecordDTO.setTicketType(orderInfo.getTicketType());
+                    passengerRecordDTO.setTicketTypeName(passengerRecordDTO.getTicketTypeName(passengerRecordDTO.getTicketType()));
+                    passengerRecordDTO.setGoodTicket(orderInfo.getGoodsTicket());
+                    passengerRecordDTO.setPayTime(DateUtil.format(orderInfo.getPayTime(),"yyyy-MM-dd HH:mm:ss"));
+                    passengerRecordDTO.setTotalFee(orderInfo.getTotalFee());
+                    passengerRecordDTOList.add(passengerRecordDTO);
+
                 }else {
                     throw new Exception("乘客已购票");
                 }
@@ -411,9 +436,10 @@ public class PassengerInfoServiceImpl implements PassengerInfoService {
                 throw new Exception("乘客已下车");
             }
         }
+        mergeOrderDTO.setPassengerRecordDTOList(passengerRecordDTOList);
 
 
-        return mergeId;
+        return mergeOrderDTO;
     }
 
     @Override

+ 3 - 2
web/src/main/java/com/jpsoft/bus/modules/mobile/controller/PassengerApiController.java

@@ -7,6 +7,7 @@ import cn.hutool.db.sql.Order;
 import com.alibaba.fastjson.JSONObject;
 import com.github.pagehelper.Page;
 import com.jpsoft.bus.config.OSSConfig;
+import com.jpsoft.bus.modules.base.dto.MergeOrderDTO;
 import com.jpsoft.bus.modules.base.dto.PassengerOrderDTO;
 import com.jpsoft.bus.modules.base.entity.MergeOrderInfo;
 import com.jpsoft.bus.modules.base.entity.OrderInfo;
@@ -593,10 +594,10 @@ public class PassengerApiController {
             ShiftInfo shiftInfo = shiftInfoList.get(0);
 
 
-            String mergeId =  passengerInfoService.createOrder(vehicleInfo, shiftInfo, openId, mergeOrderId, passengerIds, ticketUpStationId, ticketDownStationId, ticketType, goodsTicket, totalFee);
+            MergeOrderDTO mergeOrderDTO =  passengerInfoService.createOrder(vehicleInfo, shiftInfo, openId, mergeOrderId, passengerIds, ticketUpStationId, ticketDownStationId, ticketType, goodsTicket, totalFee);
 
             Map<String,Object> map = new HashMap<>();
-            map.put("id",mergeId);
+            map.put("MergeOrderDTO",mergeOrderDTO);
             messageResult.setData(map);
             messageResult.setResult(true);
             messageResult.setCode(200);