From 19c35c58f8b767d7d9c57d0cf910fd091dc7669f Mon Sep 17 00:00:00 2001
From: 无关风月 <443237572@qq.com>
Date: 星期四, 27 二月 2025 16:37:08 +0800
Subject: [PATCH] 2.0新增

---
 DriverOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/OrderController.java |   30 +++++++++++++++++++++++++++++-
 1 files changed, 29 insertions(+), 1 deletions(-)

diff --git a/DriverOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/OrderController.java b/DriverOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/OrderController.java
index 578f7e7..7f5cd8f 100644
--- a/DriverOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/OrderController.java
+++ b/DriverOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/api/OrderController.java
@@ -4,6 +4,7 @@
 import com.stylefeng.guns.modular.smallLogistics.server.IOrderLogisticsService;
 import com.stylefeng.guns.modular.system.dao.DriverWorkMapper;
 import com.stylefeng.guns.modular.system.dao.TUseMoneyMapper;
+import com.stylefeng.guns.modular.system.dao.UserCouponRecordMapper;
 import com.stylefeng.guns.modular.system.model.*;
 import com.stylefeng.guns.modular.system.service.*;
 import com.stylefeng.guns.modular.system.util.ChinaMobileUtil;
@@ -448,6 +449,8 @@
     private IPaymentRecordService paymentRecordService;
     @Autowired
     private ITransactionDetailsService transactionDetailsService;
+    @Autowired
+    private UserCouponRecordMapper userCouponRecordMapper;
     /**
      * 司机手动确认收款
      * @param orderId
@@ -497,7 +500,7 @@
             // 平台收入
             double money;
             Driver driver = driverService.selectById(orderTaxi.getDriverId());
-            Company company = companyService.selectById(driver.getFranchiseeId());
+            Company company = companyService.selectById(driver.getCompanyId());
 
             if(orderTaxi.getOrderSource() == 2 || orderTaxi.getOrderSource() == 3){
                 double v = company.getPercentageDeduction() / 100;
@@ -507,6 +510,31 @@
                 money = company.getFixedDeduction();
                 moneyTwo = orderTaxi.getOrderMoney()-money;
             }
+            Double orderMoney = orderTaxi.getOrderMoney();
+            if (orderTaxi.getCouponId()!=null){
+                UserCouponRecord userCouponRecord = userCouponRecordMapper.selectById(orderTaxi.getCouponId());
+//                    if(userCouponRecord.getCompanyId() != orderTaxi.getCompanyId()){
+//                        return ResultUtil.error("优惠券不能用于此订单", "");
+//                    }
+//                    if(userCouponRecord.getState() == 2){
+//                        return ResultUtil.error("优惠券已使用", "");
+//                    }
+//                    if(userCouponRecord.getState() == 3){
+//                        return ResultUtil.error("优惠券已过期", "");
+//                    }
+//                    if(userCouponRecord.getCouponUseType() != 0 && userCouponRecord.getCouponUseType() != 2){
+//                        return ResultUtil.error("优惠券不能用于此类型订单", "");
+//                    }
+//                    if(userCouponRecord.getCouponType() == 2 && orderMoney.compareTo(userCouponRecord.getFullMoney()) < 0){
+//                        return ResultUtil.error("优惠券不能用于此订单", "");
+//                    }
+                    orderMoney = orderMoney - userCouponRecord.getMoney();
+                    orderTaxi.setCouponMoney(userCouponRecord.getMoney());
+                    orderTaxi.setCouponId(orderTaxi.getCouponId());
+            }
+            orderTaxi.setPayMoney(orderMoney);
+            orderTaxiService.updateById(orderTaxi);
+
             driver.setBalance(driver.getBalance() + moneyTwo);
             // 新增扣除使用费记录
             transactionDetailsService.saveDataTaxi(driver.getId(), "软件使用费", money, 2, 1, 2, 6, orderTaxi.getId(),placeOrderWay,company.getId());

--
Gitblit v1.7.1