From 729a5a0592cac7750e8b476c5fcb25bfc3ff8d25 Mon Sep 17 00:00:00 2001
From: liujie <1793218484@qq.com>
Date: 星期日, 27 七月 2025 09:06:31 +0800
Subject: [PATCH] Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/java/QianYunTong

---
 UserQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/server/impl/OrderLogisticsServiceImpl.java |  159 +++++++++++++++++++++++++++++++---------------------
 1 files changed, 94 insertions(+), 65 deletions(-)

diff --git a/UserQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/server/impl/OrderLogisticsServiceImpl.java b/UserQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/server/impl/OrderLogisticsServiceImpl.java
index ed0fbc8..b916a87 100644
--- a/UserQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/server/impl/OrderLogisticsServiceImpl.java
+++ b/UserQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/server/impl/OrderLogisticsServiceImpl.java
@@ -9,7 +9,6 @@
 import com.stylefeng.guns.modular.account.controller.AppOrderController;
 import com.stylefeng.guns.modular.crossCity.dao.OrderCrossCityMapper;
 import com.stylefeng.guns.modular.crossCity.model.OrderCrossCity;
-import com.stylefeng.guns.modular.crossCity.server.IOrderCrossCityService;
 import com.stylefeng.guns.modular.smallLogistics.dao.OrderLogisticsMapper;
 import com.stylefeng.guns.modular.smallLogistics.model.OrderLogistics;
 import com.stylefeng.guns.modular.smallLogistics.model.OrderLogisticsSpread;
@@ -17,24 +16,24 @@
 import com.stylefeng.guns.modular.smallLogistics.server.IOrderLogisticsSpreadService;
 import com.stylefeng.guns.modular.specialTrain.dao.OrderPrivateCarMapper;
 import com.stylefeng.guns.modular.specialTrain.model.OrderPrivateCar;
-import com.stylefeng.guns.modular.specialTrain.server.IOrderPrivateCarService;
 import com.stylefeng.guns.modular.system.dao.*;
 import com.stylefeng.guns.modular.system.model.*;
+import com.stylefeng.guns.modular.system.model.vo.UnPayOrderVO;
 import com.stylefeng.guns.modular.system.service.*;
 import com.stylefeng.guns.modular.system.util.*;
 import com.stylefeng.guns.modular.system.warpper.BaseWarpper;
 import com.stylefeng.guns.modular.system.warpper.CouponsListVo;
+import com.stylefeng.guns.modular.system.warpper.DriverInfoWarpper;
 import com.stylefeng.guns.modular.system.warpper.PreferentialDataVo;
 import com.stylefeng.guns.modular.taxi.dao.OrderTaxiMapper;
 import com.stylefeng.guns.modular.taxi.model.OrderTaxi;
 import com.stylefeng.guns.modular.taxi.model.PaymentRecord;
-import com.stylefeng.guns.modular.taxi.service.IOrderTaxiService;
 import com.stylefeng.guns.modular.taxi.service.IPaymentRecordService;
 import com.stylefeng.guns.modular.taxi.service.ITransactionDetailsService;
-import com.unionpay.upyzt.exception.UpyztException;
 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.stereotype.Service;
 import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
@@ -95,28 +94,28 @@
 
     @Autowired
     private ICompanyService companyService;
-
+    
     @Autowired
     private IIncomeService incomeService;
-
+    
     @Autowired
     private IOrderCancelService orderCancelService;
-
+    
     @Autowired
     private IOrderLogisticsSpreadService orderLogisticsSpreadService;
-
-    @Autowired
-    private RedisUtil redisUtil;
-
+    
+    @Resource
+    private RedisTemplate<String, Object> redisTemplate;
+    
     @Resource
     private RegionMapper regionMapper;
-
+    
     @Autowired
     private GDMapElectricFenceUtil gdMapElectricFenceUtil;
-
+    
     @Autowired
     private PayMoneyUtil payMoneyUtil;
-
+    
     @Resource
     private OrderPrivateCarMapper orderPrivateCarMapper;
 
@@ -195,7 +194,7 @@
         Double price1 = 0D;
         Double price2 = 0D;
         if(type == 4){//同城
-            Map<String, Object> query1 = systemPriceMapper.query(query.getId(), type, null);
+            Map<String, Object> query1 = systemPriceMapper.query(query.getId(), type, null, null);
             if(null == query1){
                 return ResultUtil.error("请先完善价格设定");
             }
@@ -204,7 +203,7 @@
             price1 = jsonObject.getDouble("num2");
             price2 = jsonObject.getDouble("num13");
         }else{
-            Map<String, Object> query1 = systemPriceMapper.query(query.getId(), type, null);
+            Map<String, Object> query1 = systemPriceMapper.query(query.getId(), type, null, null);
             if(null == query1){
                 return ResultUtil.error("请先完善价格设定");
             }
@@ -399,7 +398,7 @@
         // TODO: 2023/11/4 无法修改
         Map<String, String> distance = gdMapElectricFenceUtil.getDistance(startLon + "," + startLat, location, 1);
         double distance1 = new BigDecimal(distance.get("distance")).divide(new BigDecimal(1000)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue();
-        Map<String, Object> query1 = systemPriceMapper.query(query.getId(), type, null);
+        Map<String, Object> query1 = systemPriceMapper.query(query.getId(), type, null, null);
         if(null != query1){
             if(type == 4){
                 JSONObject jsonObject = JSON.parseObject(query1.get("content").toString());
@@ -497,7 +496,7 @@
         Double price1 = 0D;
         Double price2 = 0D;
         if(type == 4){//同城
-            Map<String, Object> query1 = systemPriceMapper.query(query.getId(), type, null);
+            Map<String, Object> query1 = systemPriceMapper.query(query.getId(), type, null, null);
             // TODO: 2023/11/4 已优化
             if(null == dist){
                 Map<String, String> distance = gdMapElectricFenceUtil.getDistance(startLon + "," + startLat, endLon + "," + endLat, 1);
@@ -540,7 +539,7 @@
                 price2 = jsonObject.getDouble("num22");
             }
         }else{
-            Map<String, Object> query1 = systemPriceMapper.query(query.getId(), type, null);
+            Map<String, Object> query1 = systemPriceMapper.query(query.getId(), type, null, null);
             String content = String.valueOf(query1.get("content"));
             JSONObject jsonObject = JSON.parseObject(content);
             price1 = jsonObject.getDouble("num1");
@@ -566,19 +565,20 @@
                 try {
                     Integer id = orderLogistics.getId();
                     orderIds.add(orderLogistics.getId());//添加记录,防止调用接口重复提醒无人接单
-                    String vehicle = redisUtil.getValue("VEHICLE");
+                    String vehicle = (String) redisTemplate.opsForValue().get("VEHICLE");
                     List<Integer> integers = new ArrayList<>();
                     if(ToolUtil.isNotEmpty(vehicle)){
                         integers = JSON.parseArray(vehicle).toJavaList(Integer.class);
                     }
-                    Company query = companyCityService.query(String.valueOf(orderLogistics.getStartLon()), String.valueOf(orderLogistics.getStartLat()));//获取起点所属分公司
-                    List<PushOrder> querys = pushOrderService.querys(null, 1, query.getId());//用专车的推单配置
-                    for(int i = 1; i <= querys.size(); i++){
+                    OpenCity openCity = openCityService.openCity1(orderLogistics.getStartLon().toString(), orderLogistics.getStartLat().toString());
+                    List<PushOrder> querys = pushOrderService.querys(null, 1, openCity.getId());//用专车的推单配置
+                    for(int i = 1; i <= querys.size() + 5; i++){
 //                        OrderLogistics orderLogistics = orderLogisticsMapper.selectById(id);
 //                        if (null == orderLogistics || orderLogistics.getState() > 1) {
 //                            break;
 //                        }
-                        PushOrder pushOrder = pushOrderService.querys(i, 1, query.getId()).get(0);
+                        int finalI = i;
+                        PushOrder pushOrder = querys.stream().filter(s -> s.getType() == (finalI <= 3 ? finalI : 3)).findFirst().orElse(null);
 
                         int i2 = pushOrder.getPushTime() / 10;
                         if(i2==0){
@@ -616,7 +616,7 @@
                                 orderIds.remove(orderLogistics.getId());
                                 return;
                             }
-                            if (i == querys.size() && state == 1) {
+                            if (i == querys.size() + 5 && state == 1) {
                                 orderIds.remove(orderLogistics.getId());
                             }
                         }
@@ -665,8 +665,9 @@
             }
 
             userInfo.setBalance(new BigDecimal(userInfo.getBalance()).subtract(new BigDecimal(orderMoney)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
-
-            SysIntegral query1 = sysIntegralMapper.query(orderLogistics.getCompanyId());
+    
+            OpenCity openCity = openCityService.openCity1(orderLogistics.getStartLon().toString(), orderLogistics.getStartLat().toString());
+            SysIntegral query1 = sysIntegralMapper.query(openCity.getId());
             userInfo.setIntegral(userInfo.getIntegral() + (orderMoney.intValue() * query1.getIntegral()));//积分
 
             //添加交易明细
@@ -695,7 +696,6 @@
     }
 
     @Override
-    @Transactional(rollbackFor = UpyztException.class,propagation = Propagation.REQUIRES_NEW)
     public ResultUtil payLogisticsOrder1(Integer payType, Integer orderId, Integer objectId, Integer objectType, Integer type) throws Exception {
         OrderLogistics orderLogistics = this.selectById(orderId);
         if(orderLogistics.getState() != 7){
@@ -779,24 +779,25 @@
             paymentRecordService.saveData(1, orderLogistics.getUserId(), 1, orderId, orderLogistics.getType(), 2, orderMoney, "", 1);//添加预支付数据
         }
         if(payType == 3){//余额支付
-            if(userInfo.getBalance() == null || userInfo.getBalance() < orderMoney){
+            if (userInfo.getBalance() == null || userInfo.getBalance() < orderMoney) {
                 return ResultUtil.error("余额不足,无法完成支付");
             }
-            if(orderMoney>0) {
-                resultUtil = appOrderController.moneyPay(orderId, userInfo.getId(), orderMoney);
-                if (resultUtil.getCode() == 500) {
-                    return ResultUtil.error("电子余额不足,无法完成支付");
-                }
-            }
+//            if(orderMoney>0) {
+//                resultUtil = appOrderController.moneyPay(orderId, userInfo.getId(), orderMoney);
+//                if (resultUtil.getCode() == 500) {
+//                    return ResultUtil.error("电子余额不足,无法完成支付");
+//                }
+//            }
             userInfo.setBalance(new BigDecimal(userInfo.getBalance()).subtract(new BigDecimal(orderMoney)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
-
-            SysIntegral query1 = sysIntegralMapper.query(orderLogistics.getCompanyId());
+    
+            OpenCity openCity = openCityService.openCity1(orderLogistics.getStartLon().toString(), orderLogistics.getStartLat().toString());
+            SysIntegral query1 = sysIntegralMapper.query(openCity.getId());
             userInfo.setIntegral(userInfo.getIntegral() + (orderMoney.intValue() * query1.getIntegral()));//积分
-
+    
             //添加交易明细
             transactionDetailsService.saveData(uid, (orderLogistics.getType() == 4 ? "同城" : "跨城") + "小件物流下单", orderMoney, 2, 1, 1, 4, orderId);
             userInfoService.updateById(userInfo);
-
+    
             orderLogistics.setState(1);//小件物流先支付后司机抢单
             orderLogistics.setPayType(3);
             orderLogistics.setPayMoney(orderMoney);
@@ -868,24 +869,25 @@
             resultUtil = payMoneyUtil.alipay("小件物流补差价", "小件物流补差价", "", orderId + "_" + orderLogistics.getType() + "_" + UUIDUtil.getRandomCode(5), orderMoney.toString(), "/base/aliPayOrderLogisticsSpread");
             paymentRecordService.saveData(1, orderLogistics.getUserId(), 1, orderId, orderLogistics.getType(), 2, orderMoney, "", 1);//添加预支付数据
         }
-        if(payType == 3){//余额支付
-            if(userInfo.getBalance() == null || userInfo.getBalance() < orderMoney){
+        if(payType == 3) {//余额支付
+            if (userInfo.getBalance() == null || userInfo.getBalance() < orderMoney) {
                 return ResultUtil.error("余额不足,无法完成支付");
             }
-            resultUtil= appOrderController.moneyPay(orderId,userInfo.getId(),orderMoney);
-            if(resultUtil.getCode()==500){
-                return ResultUtil.error("电子余额不足,无法完成支付");
-            }
-
+//            resultUtil= appOrderController.moneyPay(orderId,userInfo.getId(),orderMoney);
+//            if(resultUtil.getCode()==500){
+//                return ResultUtil.error("电子余额不足,无法完成支付");
+//            }
+    
             userInfo.setBalance(new BigDecimal(userInfo.getBalance()).subtract(new BigDecimal(orderMoney)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
-
-            SysIntegral query1 = sysIntegralMapper.query(orderLogistics.getCompanyId());
+    
+            OpenCity openCity = openCityService.openCity1(orderLogistics.getStartLon().toString(), orderLogistics.getStartLat().toString());
+            SysIntegral query1 = sysIntegralMapper.query(openCity.getId());
             userInfo.setIntegral(userInfo.getIntegral() + (orderMoney.intValue() * query1.getIntegral()));//积分
-
+    
             //添加交易明细
             transactionDetailsService.saveData(uid, (orderLogistics.getType() == 4 ? "同城" : "跨城") + "小件物流补差价", orderMoney, 2, 1, 1, 4, orderId);
             userInfoService.updateById(userInfo);
-
+    
             orderLogistics.setState(12);//已支付差价
             this.updateById(orderLogistics);
 
@@ -962,7 +964,8 @@
             this.updateById(orderLogistics);
 
             UserInfo userInfo = userInfoService.selectById(orderLogistics.getUserId());
-            SysIntegral query1 = sysIntegralMapper.query(orderLogistics.getCompanyId());
+            OpenCity openCity = openCityService.openCity1(orderLogistics.getStartLon().toString(), orderLogistics.getStartLat().toString());
+            SysIntegral query1 = sysIntegralMapper.query(openCity.getId());
             userInfo.setIntegral(userInfo.getIntegral() + (query.getAmount().intValue() * query1.getIntegral()));//积分
             userInfoService.updateById(userInfo);
 
@@ -1026,7 +1029,8 @@
             orderLogisticsSpreadService.updateById(orderLogisticsSpread);
 
             UserInfo userInfo = userInfoService.selectById(orderLogistics.getUserId());
-            SysIntegral query1 = sysIntegralMapper.query(orderLogistics.getCompanyId());
+            OpenCity openCity = openCityService.openCity1(orderLogistics.getStartLon().toString(), orderLogistics.getStartLat().toString());
+            SysIntegral query1 = sysIntegralMapper.query(openCity.getId());
             userInfo.setIntegral(userInfo.getIntegral() + (query.getAmount().intValue() * query1.getIntegral()));//积分
             userInfoService.updateById(userInfo);
 
@@ -1619,24 +1623,25 @@
             resultUtil = payMoneyUtil.alipay("感谢费", "感谢费", "", orderId + "_" + orderLogistics.getType() + "_" + UUIDUtil.getRandomCode(5), money.toString(), "/base/aliPayThankYouFee");
             paymentRecordService.saveData(1, uid, 1, orderId, orderLogistics.getType(), 2, money, "", 1);//添加预支付数据
         }
-        if(payType == 3){//余额支付
-            if(userInfo.getBalance() == null || userInfo.getBalance() < money){
+        if(payType == 3) {//余额支付
+            if (userInfo.getBalance() == null || userInfo.getBalance() < money) {
                 return ResultUtil.error("余额不足,无法完成支付");
             }
-            resultUtil= appOrderController.moneyPay(orderId,userInfo.getId(),money);
-            if(resultUtil.getCode()==500){
-                return ResultUtil.error("电子余额不足,无法完成支付");
-            }
-
+//            resultUtil= appOrderController.moneyPay(orderId,userInfo.getId(),money);
+//            if(resultUtil.getCode()==500){
+//                return ResultUtil.error("电子余额不足,无法完成支付");
+//            }
+    
             userInfo.setBalance(new BigDecimal(userInfo.getBalance()).subtract(new BigDecimal(money)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
-
-            SysIntegral query1 = sysIntegralMapper.query(orderLogistics.getCompanyId());
+    
+            OpenCity openCity = openCityService.openCity1(orderLogistics.getStartLon().toString(), orderLogistics.getStartLat().toString());
+            SysIntegral query1 = sysIntegralMapper.query(openCity.getId());
             userInfo.setIntegral(userInfo.getIntegral() + (money.intValue() * query1.getIntegral()));//积分
-
+    
             //添加交易明细
             transactionDetailsService.saveData(uid, (orderLogistics.getType() == 4 ? "同城小件物流-" : "跨城小件物流-") + "感谢费", money, 2, 1, 1, orderLogistics.getType(), orderId);
             userInfoService.updateById(userInfo);
-
+    
             orderLogistics.setThankYouFee(money);
             this.updateById(orderLogistics);
 
@@ -1667,8 +1672,9 @@
         query.setState(2);
         query.setCode(order_id);
         paymentRecordService.updateById(query);
-
-        SysIntegral query1 = sysIntegralMapper.query(orderLogistics.getCompanyId());
+    
+        OpenCity openCity = openCityService.openCity1(orderLogistics.getStartLon().toString(), orderLogistics.getStartLat().toString());
+        SysIntegral query1 = sysIntegralMapper.query(openCity.getId());
         userInfo.setIntegral(userInfo.getIntegral() + (query.getAmount().intValue() * query1.getIntegral()));//积分
 
         //添加交易明细
@@ -1687,4 +1693,27 @@
         driverService.updateById(driver);
         systemNoticeService.addSystemNotice(1, "您已使用" + (payType == 1 ? "微信" : (payType==2?"支付宝":"云闪付")) + "成功完成感谢费支付,谢谢使用!", userInfo.getId(), 1);
     }
+
+    @Override
+    public List<UnPayOrderVO> getUnpayLogisticsOrders(Integer uid) {
+        EntityWrapper<OrderLogistics> wrapper = new EntityWrapper<>();
+        wrapper.eq("userId", uid);
+        wrapper.eq("state", 7);
+        List<OrderLogistics> orderLogisticsList = this.selectList(wrapper);
+        List<UnPayOrderVO> unPayOrderVOList = new ArrayList<>();
+        for (OrderLogistics orderLogistics:orderLogisticsList) {
+
+            UnPayOrderVO unPayOrderVO = new UnPayOrderVO();
+            //添加司机信息
+            DriverInfoWarpper driverInfoWarpper = new DriverInfoWarpper();
+            Driver driver = driverService.selectById(orderLogistics.getDriverId());
+            BeanUtils.copyProperties(driver, driverInfoWarpper);            unPayOrderVO.setDriverInfoWarpper(driverInfoWarpper);
+            //其余信息
+            BeanUtils.copyProperties(orderLogistics, unPayOrderVO);
+            unPayOrderVOList.add(unPayOrderVO);
+
+        }
+        return unPayOrderVOList;
+
+    }
 }

--
Gitblit v1.7.1