From 0a6f905b50a88993da05b9b3114394fb91dbc7d0 Mon Sep 17 00:00:00 2001
From: puzhibing <393733352@qq.com>
Date: 星期三, 31 五月 2023 19:05:56 +0800
Subject: [PATCH] 修改bug

---
 driver/guns-admin/src/main/java/com/agentdriving/driver/modular/system/service/impl/OrderServiceImpl.java |   56 +++++++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 47 insertions(+), 9 deletions(-)

diff --git a/driver/guns-admin/src/main/java/com/agentdriving/driver/modular/system/service/impl/OrderServiceImpl.java b/driver/guns-admin/src/main/java/com/agentdriving/driver/modular/system/service/impl/OrderServiceImpl.java
index 35829aa..4441c08 100644
--- a/driver/guns-admin/src/main/java/com/agentdriving/driver/modular/system/service/impl/OrderServiceImpl.java
+++ b/driver/guns-admin/src/main/java/com/agentdriving/driver/modular/system/service/impl/OrderServiceImpl.java
@@ -600,7 +600,7 @@
         List<HallOrderList> hallOrderLists = this.baseMapper.queryOrderHall(pageNum, pageSize);
         hallOrderLists.forEach(hallOrderList -> {
             if(ToolUtil.isEmpty(hallOrderList.getAvatar())){
-                hallOrderList.setAvatar("https://csxdj.obs.cn-south-1.myhuaweicloud.com:443/66cc269703a84e4da87fb21e2c21ab1f.png");
+                hallOrderList.setAvatar("https://fanghuadaijia.obs.cn-southwest-2.myhuaweicloud.com:443/img%2Fc68f32a7e78e4ef1b0c018fd2c15d7a7.png");
             }
             hallOrderList.setCurrentDistance(0D);
             if(ToolUtil.isNotEmpty(value)){
@@ -750,8 +750,10 @@
                     orderTransferService.insert(orderTransfer);
                 }
 
-                pushUtil.pushTransferSuccessful(order.getUserId(), 1, order.getId());
                 pushUtil.pushTransferSuccessful(oldDriverId, 2, order.getId());
+                if(null != order.getUserId()){
+                    pushUtil.pushTransferSuccessful(order.getUserId(), 1, order.getId());
+                }
             }
 
             //推动订单数据
@@ -865,7 +867,7 @@
                 Driver driver = driverService.selectById(order.getDriverId());
                 driver.setServerStatus(1);
                 driverService.updateById(driver);
-                accountChangeDetailService.deductionInsurance();//扣减保险费
+                accountChangeDetailService.deductionInsurance(order.getDriverId());//扣减保险费
                 saveIntegral(order);
                 break;
             case 401:
@@ -992,7 +994,7 @@
                 }
                 pushOrderInfoWarpper.setWaitTime(order.getWaitTime() + w);
                 pushOrderInfoWarpper.setState(order.getState());
-                pushOrderInfoWarpper.setActualMileage(Double.valueOf(order.getActualMileage() / 1000));
+                pushOrderInfoWarpper.setActualMileage(new BigDecimal(order.getActualMileage() / 1000).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
                 pushOrderInfoWarpper.setTravelTime(0);
                 if(null != order.getStartTime()){
                     int travelTime = Double.valueOf((System.currentTimeMillis() - order.getStartTime().getTime()) / 60000).intValue();
@@ -1150,7 +1152,9 @@
             driverService.updateById(driver);
         }
 
-        pushUtil.pushOrderStatus(order.getUserId(), 1, order.getId(), order.getStatus());
+        if(null != order.getUserId()){
+            pushUtil.pushOrderStatus(order.getUserId(), 1, order.getId(), order.getStatus());
+        }
         return ResultUtil.success();
     }
 
@@ -1215,6 +1219,8 @@
                 order.setCouponId(coupon.getId());
                 order.setDiscountAmount(coupon.getCouponPreferentialAmount());
                 order.setPayMoney(order.getOrderMoney() - coupon.getCouponPreferentialAmount());
+            }else{
+                order.setPayMoney(order.getOrderMoney());
             }
         }
 
@@ -1226,9 +1232,6 @@
                     userToCoupon.setValidCount(userToCoupon.getValidCount() - 1);
                     userToCouponService.updateById(userToCoupon);
                     Coupon coupon = couponService.selectById(userToCoupon.getCouponId());
-                    order.setPayMoney(order.getPayMoney() - coupon.getCouponPreferentialAmount());
-                    order.setCouponId(coupon.getId());
-                    order.setDiscountedPrice(coupon.getCouponPreferentialAmount());
 
                     Driver driver = driverService.selectById(order.getDriverId());
                     AccountChangeDetail accountChangeDetail = new AccountChangeDetail();
@@ -1685,6 +1688,41 @@
      */
     @Override
     public void completeCollection() {
-        this.baseMapper.completeCollection();
+        List<Order> orders = this.selectList(new EntityWrapper<Order>().eq("state", 107).eq("status", 1).eq("payType", 3));
+        for (Order order : orders) {
+            order.setState(108);
+            order.setPayTime(new Date());
+            if(null != order.getCouponId()){
+                UserToCoupon userToCoupon = userToCouponService.selectById(order.getCouponId());
+                if(userToCoupon.getValidCount() > 0){
+                    userToCoupon.setValidCount(userToCoupon.getValidCount() - 1);
+                    userToCouponService.updateById(userToCoupon);
+                    Coupon coupon = couponService.selectById(userToCoupon.getCouponId());
+
+                    Driver driver = driverService.selectById(order.getDriverId());
+                    AccountChangeDetail accountChangeDetail = new AccountChangeDetail();
+                    accountChangeDetail.setCode(System.currentTimeMillis() + UUIDUtil.getNumberRandom(3));
+                    accountChangeDetail.setUserType(2);
+                    accountChangeDetail.setUserId(order.getDriverId());
+                    accountChangeDetail.setCreateTime(new Date());
+                    accountChangeDetail.setOldData(driver.getBalance() + driver.getBackgroundBalance() + driver.getCouponBalance() + driver.getCommission());
+                    accountChangeDetail.setType(1);
+                    accountChangeDetail.setChangeType(7);
+                    accountChangeDetail.setOrderId(order.getId());
+                    accountChangeDetail.setExplain("优惠券收入");
+                    driver.setCouponBalance(driver.getCouponBalance() + coupon.getCouponPreferentialAmount());
+                    accountChangeDetail.setNewData(driver.getBalance() + driver.getBackgroundBalance() + driver.getCouponBalance() + driver.getCommission());
+                    driverService.updateById(driver);
+                    accountChangeDetailService.insert(accountChangeDetail);
+                }
+            }
+            this.updateById(order);
+
+            try {
+                saveRevenue(order);
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
     }
 }

--
Gitblit v1.7.1