From e809f5955584e600d8612540ea814977c49774c2 Mon Sep 17 00:00:00 2001
From: Pu Zhibing <393733352@qq.com>
Date: 星期三, 27 八月 2025 23:51:54 +0800
Subject: [PATCH] 修改bug

---
 ManagementQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/specialTrain/TAbnormalOrderCarController.java |  269 ++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 182 insertions(+), 87 deletions(-)

diff --git a/ManagementQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/specialTrain/TAbnormalOrderCarController.java b/ManagementQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/specialTrain/TAbnormalOrderCarController.java
index d126c3b..42aec37 100644
--- a/ManagementQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/specialTrain/TAbnormalOrderCarController.java
+++ b/ManagementQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/specialTrain/TAbnormalOrderCarController.java
@@ -1,5 +1,6 @@
 package com.stylefeng.guns.modular.system.controller.specialTrain;
 
+import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.mapper.EntityWrapper;
 import com.baomidou.mybatisplus.mapper.Wrapper;
 import com.baomidou.mybatisplus.plugins.Page;
@@ -10,9 +11,13 @@
 import com.stylefeng.guns.core.util.SinataUtil;
 import com.stylefeng.guns.core.util.ToolUtil;
 import com.stylefeng.guns.modular.system.dao.OrderCancelMapper;
+import com.stylefeng.guns.modular.system.dao.TCompanyMapper;
 import com.stylefeng.guns.modular.system.model.*;
 import com.stylefeng.guns.modular.system.service.*;
 import com.stylefeng.guns.modular.system.util.*;
+import com.stylefeng.guns.modular.system.util.qianyuntong.OrderUtil;
+import com.stylefeng.guns.modular.system.util.qianyuntong.model.*;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.data.domain.Sort;
@@ -35,6 +40,7 @@
  * @author fengshuonan
  * @Date 2020-09-02 17:28:59
  */
+@Slf4j
 @Controller
 @RequestMapping("/abnormal")
 public class TAbnormalOrderCarController extends BaseController {
@@ -80,8 +86,14 @@
 
     @Autowired
     private TAbnormalPayOrderService tAbnormalPayOrderService;
-    
-    
+
+
+    @Autowired
+    private ITSystemNoticeService systemNoticeService;
+    @Autowired
+    private TCompanyMapper tCompanyMapper;
+
+
     /**
      * 跳转到快车订单首页
      */
@@ -100,7 +112,7 @@
     public String tOrderPrivateCarUpdate(Integer tOrderPrivateCarId,Integer type, Model model) {
         if(type==1){
             Map<String, Object> item = tOrderPrivateCarService.getPrivateCarOrderDetailById(tOrderPrivateCarId);
-
+            TOrderPrivateCar tOrderPrivateCar1 = tOrderPrivateCarService.selectById(tOrderPrivateCarId);
             Object o1 = item.get("abnormalImg");
             if(o1!=null){
                 String[] split = o1.toString().split(",");
@@ -109,12 +121,11 @@
                 model.addAttribute("abnormalImg",new String[]{});
             }
             // money是修改后的金额
-            model.addAttribute("money",0);
+            model.addAttribute("money","");
             Object o2 = item.get("responsibilityType");
             if(o2!=null){
                 if(Integer.valueOf(o2.toString())>2){
-                    TAbnormalPayOrder tAbnormalPayOrder = tAbnormalPayOrderService.selectOne(new EntityWrapper<TAbnormalPayOrder>().eq("type", 1).eq("orderNum", item.get("orderNum")));
-                    model.addAttribute("money",tAbnormalPayOrder.getPayMoney());
+                    model.addAttribute("money", tOrderPrivateCar1.getResponsibilityMoney());
                 }
             }
             model.addAttribute("item",item);
@@ -132,6 +143,7 @@
             model.addAttribute("maps",maps);
         }else if(type==2){
             Map<String, Object> item = tOrderCrossCityService.getCrossCityOrderDetailById(tOrderPrivateCarId);
+            TOrderCrossCity tOrderCrossCity = tOrderCrossCityService.selectById(tOrderPrivateCarId);
             Object o1 = item.get("abnormalImg");
             if(o1!=null){
                 String[] split = o1.toString().split(",");
@@ -140,18 +152,18 @@
                 model.addAttribute("abnormalImg",new String[]{});
             }
             Object o2 = item.get("responsibilityType");
-            model.addAttribute("money",0);
+            model.addAttribute("money","");
             model.addAttribute("show",0);
             if(o2!=null){
                 if(Integer.valueOf(o2.toString())>2){
-                    TAbnormalPayOrder tAbnormalPayOrder = tAbnormalPayOrderService.selectOne(new EntityWrapper<TAbnormalPayOrder>().eq("type", 2).eq("orderNum", item.get("orderNum")));
-                    model.addAttribute("money",tAbnormalPayOrder.getPayMoney());
+                    model.addAttribute("money", tOrderCrossCity.getResponsibilityMoney());
                 }
             }
             model.addAttribute("type",2);
             model.addAttribute("item",item);
         }else if(type==3){
             Map<String, Object> item = tOrderTaxiService.getTaxiOrderDetailById(tOrderPrivateCarId);
+            TOrderTaxi tOrderTaxi = tOrderTaxiService.selectById(tOrderPrivateCarId);
             Object o1 = item.get("abnormalImg");
             if(o1!=null){
                 String[] split = o1.toString().split(",");
@@ -159,13 +171,12 @@
             }else {
                 model.addAttribute("abnormalImg",new String[]{});
             }
-            model.addAttribute("money",0);
+            model.addAttribute("money","");
             model.addAttribute("show",0);
             Object o2 = item.get("responsibilityType");
             if(o2!=null){
                 if(Integer.valueOf(o2.toString())>2){
-                    TAbnormalPayOrder tAbnormalPayOrder = tAbnormalPayOrderService.selectOne(new EntityWrapper<TAbnormalPayOrder>().eq("type", 3).eq("orderNum", item.get("orderNum")));
-                    model.addAttribute("money",tAbnormalPayOrder.getPayMoney());
+                    model.addAttribute("money", tOrderTaxi.getResponsibilityMoney());
                 }
             }
             model.addAttribute("type",3);
@@ -191,7 +202,7 @@
             Object o2 = item.get("responsibilityType");
             if(o2!=null){
                 if(Integer.valueOf(o2.toString())>2){
-                    TAbnormalPayOrder tAbnormalPayOrder = tAbnormalPayOrderService.selectOne(new EntityWrapper<TAbnormalPayOrder>().eq("type", 1).eq("orderNum", item.get("orderNum")));
+                    TAbnormalPayOrder tAbnormalPayOrder = tAbnormalPayOrderService.selectOne(new EntityWrapper<TAbnormalPayOrder>().eq("type", 1).eq("orderNum", tOrderPrivateCarId));
                     model.addAttribute("money",tAbnormalPayOrder.getPayMoney());
                 }
             }
@@ -222,7 +233,7 @@
             model.addAttribute("show",1);
             if(o2!=null){
                 if(Integer.valueOf(o2.toString())>2){
-                    TAbnormalPayOrder tAbnormalPayOrder = tAbnormalPayOrderService.selectOne(new EntityWrapper<TAbnormalPayOrder>().eq("type", 2).eq("orderNum", item.get("orderNum")));
+                    TAbnormalPayOrder tAbnormalPayOrder = tAbnormalPayOrderService.selectOne(new EntityWrapper<TAbnormalPayOrder>().eq("type", 2).eq("orderNum", tOrderPrivateCarId));
                     model.addAttribute("money",tAbnormalPayOrder.getPayMoney());
                 }
             }
@@ -242,7 +253,7 @@
             Object o2 = item.get("responsibilityType");
             if(o2!=null){
                 if(Integer.valueOf(o2.toString())>2){
-                    TAbnormalPayOrder tAbnormalPayOrder = tAbnormalPayOrderService.selectOne(new EntityWrapper<TAbnormalPayOrder>().eq("type", 3).eq("orderNum", item.get("orderNum")));
+                    TAbnormalPayOrder tAbnormalPayOrder = tAbnormalPayOrderService.selectOne(new EntityWrapper<TAbnormalPayOrder>().eq("type", 3).eq("orderNum", tOrderPrivateCarId));
                     model.addAttribute("money",tAbnormalPayOrder.getPayMoney());
                 }
             }
@@ -291,10 +302,13 @@
         }
         abnormal = 2;
         Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage();
+        if(type==null){
+            type=1;
+        }
         // 快车
         if(type==1){
             page.setRecords(tOrderPrivateCarService.getPrivateCarOrderList(page, beginTime, endTime, shiroExtUtil.getUser().getRoleType(), shiroExtUtil.getUser().getObjectId(),
-                    orderNum, orderSource, userName, userPhone, passengers, passengersPhone, serverCarModelId, driver, state, rideType, abnormal, promotion, promotionUser,abnormalStatus));
+                    orderNum, orderSource, userName, userPhone, passengers, passengersPhone, serverCarModelId, driver, state, rideType, abnormal, promotion, promotionUser,abnormalStatus, null));
             return super.packForBT(page);
             // 跨城
         }else if(type==2){
@@ -670,101 +684,182 @@
     @RequestMapping(value = "/save")
     @ResponseBody
     public Object save(Integer responsibilityTypeVal,String remark,String money,Integer type,String orderNum) {
+        Integer userId =null;
         if(type==1){
-            TOrderPrivateCar tOrderPrivateCar = tOrderPrivateCarService.selectOne(new EntityWrapper<TOrderPrivateCar>().eq("orderNum",orderNum));
+            TOrderPrivateCar tOrderPrivateCar = tOrderPrivateCarService.selectOne(new EntityWrapper<TOrderPrivateCar>().eq("id",orderNum));
+            userId = tOrderPrivateCar.getUserId();
+
+            //平台全责需要调起备付金支付
+            if(1 == responsibilityTypeVal){
+                TDriver driver = tDriverService.selectById(tOrderPrivateCar.getDriverId());
+                TCompany company = tCompanyMapper.selectById(driver.getCompanyId());
+                TUser userInfo = userService.selectById(tOrderPrivateCar.getUserId());
+                if(null == tOrderPrivateCar.getIsCreated()){
+                    //先调中台创建订单
+                    CreateOrderRequest createOrderRequest = new CreateOrderRequest();
+                    createOrderRequest.setTreatShopId(driver.getEmpId().toString());
+                    createOrderRequest.setField1("{\"profitSharing\":\"1\",\"isPromote\":\"" + (tOrderPrivateCar.getPromotion() == 2 ? 1 : 0) + "\"}");
+                    createOrderRequest.setCharge(tOrderPrivateCar.getOrderMoney());
+                    createOrderRequest.setOrderNo("PR" + tOrderPrivateCar.getId());
+                    createOrderRequest.setOrderId(tOrderPrivateCar.getTravelId());
+                    createOrderRequest.setCustomerId(userInfo.getOnconUUID());
+                    OrderInfo orderInfo = com.stylefeng.guns.modular.system.util.qianyuntong.OrderUtil.tradeOrderCreate(createOrderRequest);
+                    tOrderPrivateCar.setIsCreated(1);
+                    tOrderPrivateCar.setTravelId(orderInfo.getOrderId());
+                    tOrderPrivateCarService.updateById(tOrderPrivateCar);
+                }
+                //使用备付金进行支付订单
+                TradePayOffData tradePayOffData = new TradePayOffData();
+                tradePayOffData.setPartnerPayId(tOrderPrivateCar.getTravelId());
+                tradePayOffData.setTotalFee(tOrderPrivateCar.getOrderMoney().multiply(new BigDecimal(100)).toString());
+                tradePayOffData.setOrderDesc("完成订单");
+                PayInfo payInfo = com.stylefeng.guns.modular.system.util.qianyuntong.OrderUtil.tradePayOff(tradePayOffData);
+                String retCode = payInfo.getRetCode();
+                if (!"000000".equals(retCode)) {
+                    log.error("备付金支付失败:{}", payInfo.getRetMsg());
+                    return "备付金支付失败:" + payInfo.getRetMsg();
+                }
+                PayInfoData data = payInfo.getData();
+                String status = data.getStatus();
+                if ("3".equals(status)) {
+                    log.error("备付金支付失败:{}", payInfo.getRetMsg());
+                    return "备付金支付失败:" + payInfo.getRetMsg();
+                }
+                if("0".equals(status)){
+                    //查询支付信息
+                    GetPaymentInfoDataRequest getPaymentInfoDataRequest = new GetPaymentInfoDataRequest();
+                    getPaymentInfoDataRequest.setPartnerPayId(tOrderPrivateCar.getTravelId());
+                    GetPaymentInfo getPaymentInfo = com.stylefeng.guns.modular.system.util.qianyuntong.OrderUtil.paymentInfo(getPaymentInfoDataRequest);
+                    status = getPaymentInfo.getStatus();
+                }
+                PayInfoData payInfoData = payInfo.getData();
+                PaymentInfo paymentInfo = payInfoData.getPaymentInfos().get(0);
+                if(!"0".equals(status)) {
+                    //支付成功,通知三方
+                    PaymentOrderRequest paymentOrderRequest = new PaymentOrderRequest();
+                    paymentOrderRequest.setPayItemId(paymentInfo.getPayItemId());
+                    paymentOrderRequest.setPaymentInfo(JSON.toJSONString(payInfoData.getPaymentInfos()));
+                    paymentOrderRequest.setOrderId(tOrderPrivateCar.getTravelId());
+                    paymentOrderRequest.setCharge(tOrderPrivateCar.getOrderMoney());
+                    paymentOrderRequest.setPayTime(data.getPayTime());
+                    paymentOrderRequest.setPaymentSerialNumber(payInfoData.getPayId());
+                    OrderInfo orderInfo1 = OrderUtil.paymentOrder(paymentOrderRequest);
+
+                    //中台修改订单状态
+                    ModifyTravelItineraryRequest request1 = new ModifyTravelItineraryRequest();
+                    request1.setOrderId(tOrderPrivateCar.getTravelId());
+                    request1.setStatus(9);
+                    if (null != tOrderPrivateCar.getDriverId()) {
+                        request1.setDriverId(driver.getEmpId().toString());
+                        request1.setSupplierShopId(company.getEnterCode());
+                    }
+                    if (2 == tOrderPrivateCar.getPromotion()) {
+                        TDriver driver2 = tDriverService.selectById(tOrderPrivateCar.getPromotionDriverId());
+                        request1.setPromoterId(driver2.getEmpId().toString());
+                    }
+                    OrderUtil.modifyTravelItinerary(request1);
+                }
+
+                tOrderPrivateCar.setPayType(5);
+                tOrderPrivateCar.setPayMoney(tOrderPrivateCar.getOrderMoney());
+                tOrderPrivateCar.setState(9);
+                tOrderPrivateCar.setResponsibilityMoney(tOrderPrivateCar.getOrderMoney());
+            }
+
+            //司机全责
+            if(responsibilityTypeVal == 2){
+                tOrderPrivateCar.setState(9);
+                tOrderPrivateCar.setPayMoney(BigDecimal.ZERO);
+                tOrderPrivateCar.setResponsibilityMoney(BigDecimal.ZERO);
+            }
+            //乘客全责,不做任何修改
+            if(responsibilityTypeVal == 3){
+                tOrderPrivateCar.setResponsibilityMoney(tOrderPrivateCar.getOrderMoney());
+            }
+            //平台部分责任/司机部分责任
+            if(responsibilityTypeVal == 4 || responsibilityTypeVal == 5){
+                tOrderPrivateCar.setResponsibilityMoney(new BigDecimal(money));
+            }
             tOrderPrivateCar.setResponsibilityType(responsibilityTypeVal);
             tOrderPrivateCar.setAbnormalStatus(2);
-            if(responsibilityTypeVal>3){
-                tOrderPrivateCar.setResponsibilityMoney(tOrderPrivateCar.getPayMoney());
-                tOrderPrivateCar.setPayMoney(new BigDecimal(money));
-            }
-            if(responsibilityTypeVal>2){
-                // 追偿订单记录表
-                TAbnormalPayOrder tAbnormalPayOrder = new TAbnormalPayOrder();
-                tAbnormalPayOrder.setOrderNum(orderNum);
-                tAbnormalPayOrder.setType(1);
-                tAbnormalPayOrder.setUserId(tOrderPrivateCar.getUserId());
-                tAbnormalPayOrder.setPayStatus(1);
-                tAbnormalPayOrder.setPayTime(new Date());
-                if(responsibilityTypeVal==3){
-                    tAbnormalPayOrder.setPayMoney(tOrderPrivateCar.getPayMoney());
-                }else {
-                    tAbnormalPayOrder.setPayMoney(new BigDecimal( money));
-                }
-                tAbnormalPayOrder.setCompanyId(tOrderPrivateCar.getCompanyId());
-                tAbnormalPayOrderService.insert(tAbnormalPayOrder);
-            }
-
-            if(responsibilityTypeVal<3){
-                tOrderPrivateCar.setState(9);
-            }
             tOrderPrivateCar.setAbnormalRemark(remark);
+            tOrderPrivateCar.setAbnormalTime(new Date());
             tOrderPrivateCarService.updateById(tOrderPrivateCar);
-        }
 
+        }
         if(type==2){
-            TOrderCrossCity tOrderCrossCity = tOrderCrossCityService.selectOne(new EntityWrapper<TOrderCrossCity>().eq("orderNum", orderNum));
+            TOrderCrossCity tOrderCrossCity = tOrderCrossCityService.selectOne(new EntityWrapper<TOrderCrossCity>().eq("id", orderNum));
+            userId = tOrderCrossCity.getUserId();
             tOrderCrossCity.setResponsibilityType(responsibilityTypeVal);
             tOrderCrossCity.setAbnormalStatus(2);
-            if(responsibilityTypeVal>3) {
-                tOrderCrossCity.setResponsibilityMoney(tOrderCrossCity.getPayMoney());
-                tOrderCrossCity.setPayMoney(new BigDecimal(money));
-            }
-            if(responsibilityTypeVal>2){
-                // 追偿订单记录表
-                TAbnormalPayOrder tAbnormalPayOrder = new TAbnormalPayOrder();
-                tAbnormalPayOrder.setOrderNum(orderNum);
-                tAbnormalPayOrder.setType(2);
-                tAbnormalPayOrder.setUserId(tOrderCrossCity.getUserId());
-                tAbnormalPayOrder.setPayStatus(1);
-                tAbnormalPayOrder.setPayTime(new Date());
-                if(responsibilityTypeVal==3){
-                    tAbnormalPayOrder.setPayMoney(tOrderCrossCity.getPayMoney());
-                }else {
-                    tAbnormalPayOrder.setPayMoney(new BigDecimal(money));
-                }
-                tAbnormalPayOrder.setCompanyId(tOrderCrossCity.getCompanyId());
-                tAbnormalPayOrderService.insert(tAbnormalPayOrder);
-            }
-            if(responsibilityTypeVal<3){
+            //平台全责
+            if(responsibilityTypeVal == 1) {
+                tOrderCrossCity.setPayType(5);
+                tOrderCrossCity.setPayMoney(tOrderCrossCity.getOrderMoney());
                 tOrderCrossCity.setState(9);
+                tOrderCrossCity.setResponsibilityMoney(tOrderCrossCity.getOrderMoney());
+            }
+            //司机全责
+            if(responsibilityTypeVal == 2){
+                tOrderCrossCity.setState(9);
+                tOrderCrossCity.setPayMoney(BigDecimal.ZERO);
+                tOrderCrossCity.setResponsibilityMoney(BigDecimal.ZERO);
+            }
+            //乘客全责,不做任何修改
+            if(responsibilityTypeVal == 3){
+                tOrderCrossCity.setResponsibilityMoney(tOrderCrossCity.getOrderMoney());
+            }
+            //平台部分责任/司机部分责任
+            if(responsibilityTypeVal == 4 || responsibilityTypeVal == 5){
+                tOrderCrossCity.setResponsibilityMoney(new BigDecimal(money));
             }
             tOrderCrossCity.setAbnormalRemark(remark);
             tOrderCrossCityService.updateById(tOrderCrossCity);
 
         }
         if(type==3){
-            TOrderTaxi tOrderTaxi = tOrderTaxiService.selectOne(new EntityWrapper<TOrderTaxi>().eq("orderNum", orderNum));
+            TOrderTaxi tOrderTaxi = tOrderTaxiService.selectOne(new EntityWrapper<TOrderTaxi>().eq("id", orderNum));
+            userId = tOrderTaxi.getUserId();
             tOrderTaxi.setResponsibilityType(responsibilityTypeVal);
             tOrderTaxi.setAbnormalStatus(2);
-            if(responsibilityTypeVal>3) {
-                tOrderTaxi.setResponsibilityMoney(tOrderTaxi.getPayMoney());
-                tOrderTaxi.setPayMoney(new BigDecimal(money));
-            }
-            if(responsibilityTypeVal>2){
-                // 追偿订单记录表
-                TAbnormalPayOrder tAbnormalPayOrder = new TAbnormalPayOrder();
-                tAbnormalPayOrder.setOrderNum(orderNum);
-                tAbnormalPayOrder.setType(3);
-                tAbnormalPayOrder.setUserId(tOrderTaxi.getUserId());
-                tAbnormalPayOrder.setPayStatus(1);
-                tAbnormalPayOrder.setPayTime(new Date());
-                if(responsibilityTypeVal==3){
-                    tAbnormalPayOrder.setPayMoney(tOrderTaxi.getPayMoney());
-                }else {
-                    tAbnormalPayOrder.setPayMoney(new BigDecimal( money));
-                }
-
-                tAbnormalPayOrder.setCompanyId(tOrderTaxi.getCompanyId());
-                tAbnormalPayOrderService.insert(tAbnormalPayOrder);
-            }
-            if(responsibilityTypeVal<3){
+            //平台全责
+            if(responsibilityTypeVal == 1) {
+                tOrderTaxi.setPayType(5);
+                tOrderTaxi.setPayMoney(tOrderTaxi.getOrderMoney());
+                tOrderTaxi.setResponsibilityMoney(tOrderTaxi.getOrderMoney());
                 tOrderTaxi.setState(9);
             }
+            //司机全责
+            if(responsibilityTypeVal == 2){
+                tOrderTaxi.setState(9);
+                tOrderTaxi.setPayMoney(BigDecimal.ZERO);
+                tOrderTaxi.setResponsibilityMoney(BigDecimal.ZERO);
+            }
+            //乘客全责,不做任何修改
+            if(responsibilityTypeVal == 3){
+                tOrderTaxi.setResponsibilityMoney(tOrderTaxi.getOrderMoney());
+            }
+            //平台部分责任/司机部分责任
+            if(responsibilityTypeVal == 4 || responsibilityTypeVal == 5){
+                tOrderTaxi.setResponsibilityMoney(new BigDecimal(money));
+            }
             tOrderTaxi.setAbnormalRemark(remark);
+            tOrderTaxi.setAbnormalTime(new Date());
             tOrderTaxiService.updateById(tOrderTaxi);
         }
+
+
+        TSystemNotice tSystemNotice = new TSystemNotice();
+        tSystemNotice.setType(2);
+        tSystemNotice.setNoticeType(1);
+        tSystemNotice.setUserType(1);
+        tSystemNotice.setUserId(userId);
+        tSystemNotice.setContent("您提交的申诉平台已处理");
+        tSystemNotice.setRead(1);
+        tSystemNotice.setInsertTime(new Date());
+        systemNoticeService.insert(tSystemNotice);
         return SUCCESS_TIP;
+
     }
 
 

--
Gitblit v1.7.1