瀏覽代碼

乘客端修改订单

fllmoyu 4 年之前
父節點
當前提交
31d53e28b4

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

@@ -3,6 +3,7 @@ package com.jpsoft.bus.modules.bus.service;
 import java.util.List;
 import java.util.Map;
 
+import com.jpsoft.bus.modules.base.entity.OrderInfo;
 import com.jpsoft.bus.modules.bus.dto.DriverBuyTicketDTO;
 import com.jpsoft.bus.modules.bus.entity.PassengerInfo;
 import com.github.pagehelper.Page;
@@ -28,4 +29,6 @@ public interface PassengerInfoService {
     List<PassengerInfo> findByShiftStatusPayStatusNotTicketDown(String shiftId, String status, String payStatus,String ticketDownStationId);
 
 	void 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);
 }

+ 30 - 7
common/src/main/java/com/jpsoft/bus/modules/bus/service/impl/PassengerInfoServiceImpl.java

@@ -278,6 +278,12 @@ public class PassengerInfoServiceImpl implements PassengerInfoService {
     public void createOrder(VehicleInfo vehicleInfo, ShiftInfo shiftInfo, String openId, String mergeOrderId,String passengerIds, String ticketUpStationId, String ticketDownStationId, String ticketType, String goodsTicket, String totalFee) throws Exception {
 
 
+        //乘客id集合
+        List<String> passengerList = Arrays.asList(passengerIds.split(","));
+        if (passengerList.size() == 0) {
+            throw new Exception("乘客不存在");
+        }
+
         PriceInfo priceInfo = priceInfoService.findByStartStationAndEndStation(ticketUpStationId, ticketDownStationId);
         if (priceInfo == null) {
             PriceInfo priceInfo1 = priceInfoService.findByStartStationAndEndStation(ticketDownStationId, ticketUpStationId);
@@ -291,9 +297,11 @@ public class PassengerInfoServiceImpl implements PassengerInfoService {
             price = price.divide(new BigDecimal(2));
         }
 
+        BigDecimal totalTicketPrice =price.multiply(new BigDecimal(passengerList.size()));
+
         BigDecimal goodTicketPrice = new BigDecimal(goodsTicket);
 
-        BigDecimal total = price.add(goodTicketPrice);
+        BigDecimal total = totalTicketPrice.add(goodTicketPrice);
         if (total.compareTo(new BigDecimal(totalFee)) != 0) {
             throw new Exception("票价有误,请重新创建");
         }
@@ -322,11 +330,7 @@ public class PassengerInfoServiceImpl implements PassengerInfoService {
             throw new Exception("对应公司收款账户异常,请核验");
         }
 
-        //乘客id集合
-        List<String> passengerList = Arrays.asList(passengerIds.split(","));
-        if (passengerList.size() == 0) {
-            throw new Exception("乘客不存在");
-        }
+
 
         String mergeId = mergeOrderId;
         if (StringUtils.isBlank(mergeOrderId)){
@@ -346,6 +350,7 @@ public class PassengerInfoServiceImpl implements PassengerInfoService {
 
         String upStationId = passengerInfo0.getUpStationId();
 
+        Boolean goodTicketStatus = false;
         for (String passengerId : passengerList) {
 
             OrderInfo orderInfo0 = orderInfoService.findByPassengerIdMergeOrderId(passengerId,mergeId);
@@ -370,15 +375,33 @@ public class PassengerInfoServiceImpl implements PassengerInfoService {
                 orderInfo.setPaymentId(paymentId);
                 orderInfo.setPassengerId(passengerId);
                 orderInfo.setTicketType(ticketType);
-                orderInfo.setGoodsTicket(new BigDecimal(goodsTicket));
+
+                if (!goodTicketStatus){
+                    orderInfo.setGoodsTicket(new BigDecimal(goodsTicket));
+                    goodTicketStatus = true;
+                }
+
                 orderInfo.setMergeOrderId(mergeId);
                 orderInfo.setTicketUpStationId(ticketUpStationId);
                 orderInfo.setTicketDownStationId(ticketDownStationId);
                 orderInfoService.insert(orderInfo);
 
+            }else {
+                throw new Exception("乘客已下车或已购票");
             }
         }
 
 
     }
+
+    @Override
+    public void updatePassengerOrder(OrderInfo orderInfo, String ticketUpStationId, String ticketDownStationId, String ticketType, String goodsTicket, String totalFee) {
+
+        orderInfo.setTicketUpStationId(ticketUpStationId);
+        orderInfo.setTicketDownStationId(ticketDownStationId);
+        orderInfo.setTotalFee(new BigDecimal(totalFee));
+        orderInfo.setTicketType(ticketType);
+        orderInfo.setGoodsTicket(new BigDecimal(goodsTicket));
+        orderInfoService.update(orderInfo);
+    }
 }

+ 1 - 0
web/src/main/java/com/jpsoft/bus/config/WebMvcConfig.java

@@ -69,6 +69,7 @@ public class WebMvcConfig implements WebMvcConfigurer {
 				.excludePathPatterns("/mobile/passengerApi/upBusNoTicketList")
 				.excludePathPatterns("/mobile/passengerApi/createPassengerOrder")
 				.excludePathPatterns("/mobile/passengerApi/deletePassengerOrder")
+				.excludePathPatterns("/mobile/passengerApi/updatePassengerOrder")
 				.excludePathPatterns("/aliPay/**")
 				.excludePathPatterns("/wxPay/**")
 				;

+ 50 - 0
web/src/main/java/com/jpsoft/bus/modules/mobile/controller/PassengerApiController.java

@@ -623,6 +623,56 @@ public class PassengerApiController {
 
 
 
+            messageResult.setResult(true);
+            messageResult.setCode(200);
+        } catch (Exception ex) {
+            log.error(ex.getMessage());
+            messageResult.setCode(400);
+            messageResult.setResult(false);
+            messageResult.setMessage(ex.getMessage());
+        }
+
+        return messageResult;
+    }
+
+    @PostMapping("updatePassengerOrder")
+    @ApiOperation(value = "修改乘客订单")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "id", value = "乘客id", required = true, paramType = "form"),
+            @ApiImplicitParam(name = "mergeOrderId", value = "综合账单id", required = true, paramType = "form"),
+            @ApiImplicitParam(name = "ticketUpStationId", value = "购票起站", required = true, paramType = "form"),
+            @ApiImplicitParam(name = "ticketDownStationId", value = "购票终点站", required = true, paramType = "form"),
+            @ApiImplicitParam(name = "ticketType", value = "购票类型(1:儿童票,2:成人票)", required = true, paramType = "form"),
+            @ApiImplicitParam(name = "goodsTicket", value = "货票金额", required = true, paramType = "form"),
+            @ApiImplicitParam(name = "totalFee", value = "总金额", required = true, paramType = "form")
+    })
+    public MessageResult<Map> updatePassengerOrder(String id,String mergeOrderId,String ticketUpStationId,String ticketDownStationId,String ticketType,String goodsTicket,String totalFee) {
+        MessageResult<Map> messageResult = new MessageResult<>();
+
+        try {
+
+
+            MergeOrderInfo mergeOrderInfo = mergeOrderInfoService.get(mergeOrderId);
+            if (mergeOrderInfo == null){
+                throw new Exception("账单不存在");
+            }
+
+            if (mergeOrderInfo.getPayStatus() == 20){
+                throw new Exception("已支付账单不可修改");
+            }
+
+            OrderInfo orderInfo = orderInfoService.findByPassengerIdMergeOrderId(id,mergeOrderId);
+
+            if (orderInfo != null){
+                if (orderInfo.getPayStatus() == 20){
+                    throw new Exception("已支付账单不可修改");
+                }
+            }
+
+            passengerInfoService.updatePassengerOrder(orderInfo,ticketUpStationId,ticketDownStationId,ticketType,goodsTicket,totalFee);
+
+
+
             messageResult.setResult(true);
             messageResult.setCode(200);
         } catch (Exception ex) {