From 4fd8e9902b92b2a1f78c9550b274cb4e1e191e08 Mon Sep 17 00:00:00 2001
From: xuhy <3313886187@qq.com>
Date: 星期一, 20 一月 2025 18:55:47 +0800
Subject: [PATCH] 线下支付

---
 DriverNTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/specialTrain/server/impl/OrderPrivateCarServiceImpl.java |   61 +++++++++++++++++++++++-------
 1 files changed, 46 insertions(+), 15 deletions(-)

diff --git a/DriverNTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/specialTrain/server/impl/OrderPrivateCarServiceImpl.java b/DriverNTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/specialTrain/server/impl/OrderPrivateCarServiceImpl.java
index 2a21b94..2a2830d 100644
--- a/DriverNTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/specialTrain/server/impl/OrderPrivateCarServiceImpl.java
+++ b/DriverNTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/specialTrain/server/impl/OrderPrivateCarServiceImpl.java
@@ -8,13 +8,10 @@
 import com.stylefeng.guns.modular.specialTrain.model.OrderPrivateCar;
 import com.stylefeng.guns.modular.specialTrain.server.IOrderPrivateCarService;
 import com.stylefeng.guns.modular.system.dao.RegionMapper;
+import com.stylefeng.guns.modular.system.dao.SysIntegralMapper;
 import com.stylefeng.guns.modular.system.dao.SystemPriceMapper;
-import com.stylefeng.guns.modular.system.model.Driver;
-import com.stylefeng.guns.modular.system.model.OrderPosition;
-import com.stylefeng.guns.modular.system.model.Region;
-import com.stylefeng.guns.modular.system.service.IDriverService;
-import com.stylefeng.guns.modular.system.service.IOrderPositionService;
-import com.stylefeng.guns.modular.system.service.ISystemNoticeService;
+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.taxi.model.OrderTaxi;
 import com.stylefeng.guns.modular.taxi.service.IOrderTaxiService;
@@ -25,6 +22,8 @@
 
 import javax.annotation.Resource;
 import java.math.BigDecimal;
+import java.math.MathContext;
+import java.math.RoundingMode;
 import java.util.*;
 
 
@@ -39,7 +38,8 @@
 
     @Autowired
     private IDriverService driverService;
-
+    @Autowired
+    private IIncomeService incomeService;
     @Autowired
     private PushUtil pushUtil;
 
@@ -75,9 +75,10 @@
 
     @Value("${pushMinistryOfTransport}")
     private boolean pushMinistryOfTransport;
-
-
-
+    @Autowired
+    private ICompanyService companyService;
+    @Autowired
+    private ITransactionDetailsService transactionDetailsService;
 
 
     /**
@@ -361,16 +362,46 @@
     @Override
     public ResultUtil confirmFees(Integer orderId, Integer type, Double parkingFee, Double crossingFee) throws Exception {
         OrderPrivateCar orderPrivateCar = this.selectById(orderId);
-        if(type == 3){
-            orderPrivateCar.setState(8);
-        }else {
-            orderPrivateCar.setState(7);
-        }
         orderPrivateCar = this.setMoney(orderPrivateCar, 0D, 0D);//计算费用
         orderPrivateCar.setPayManner(type);
         orderPrivateCar.setParkMoney(null == parkingFee ? 0D : parkingFee);
         orderPrivateCar.setRoadTollMoney(null == crossingFee ? 0D : crossingFee);
         orderPrivateCar.setOrderMoney(orderPrivateCar.getOrderMoney() + orderPrivateCar.getParkMoney() + orderPrivateCar.getRoadTollMoney());
+        if(type == 3){
+            Double orderMoney = orderPrivateCar.getOrderMoney();
+            //添加交易明细
+            transactionDetailsService.saveData(orderPrivateCar.getDriverId(), "完成订单", orderMoney, 2, 1, 1, 1, orderId);
+
+            orderPrivateCar.setState(8);
+            // 线下支付
+            orderPrivateCar.setPayType(4);
+            orderPrivateCar.setPayMoney(orderMoney);
+
+            //添加已收入明细
+            Company company = companyService.selectById(orderPrivateCar.getCompanyId());
+            Double speMoney = company.getSpeMoney();
+            BigDecimal d = null;//企业收入
+            BigDecimal c = null;//司机收入
+            if(company.getIsSpeFixedOrProportional() == 2){//固定
+                d = new BigDecimal(speMoney);
+                c = new BigDecimal(orderPrivateCar.getOrderMoney()).subtract(d);//只有出行金额参与抽成,其余归属司机
+            }
+            if(company.getIsSpeFixedOrProportional() == 1){//比例
+                Double price = orderPrivateCar.getStartMoney() + orderPrivateCar.getMileageMoney() + orderPrivateCar.getWaitMoney() + orderPrivateCar.getDurationMoney() + orderPrivateCar.getLongDistanceMoney();
+                d = new BigDecimal(price).multiply(new BigDecimal(speMoney).divide(new BigDecimal(100), new MathContext(2, RoundingMode.HALF_EVEN))).setScale(2, BigDecimal.ROUND_HALF_EVEN);
+                c = new BigDecimal(orderPrivateCar.getOrderMoney()).subtract(d).setScale(2, BigDecimal.ROUND_HALF_EVEN);
+            }
+            incomeService.saveData(1, orderPrivateCar.getCompanyId(), 2, orderPrivateCar.getId(), 1, d.doubleValue());
+            incomeService.saveData(2, orderPrivateCar.getDriverId(), 2, orderPrivateCar.getId(), 1, c.doubleValue());
+            Driver driver = driverService.selectById(orderPrivateCar.getDriverId());
+            driver.setBusinessMoney(new BigDecimal(null != driver.getBusinessMoney() ? driver.getBusinessMoney() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
+            driver.setLaveBusinessMoney(new BigDecimal(null != driver.getLaveBusinessMoney() ? driver.getLaveBusinessMoney() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
+            driver.setBalance(new BigDecimal(null != driver.getBalance() ? driver.getBalance() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
+            driverService.updateById(driver);
+            orderPrivateCar.setState(8);
+        }else {
+            orderPrivateCar.setState(7);
+        }
         this.updateById(orderPrivateCar);
 
         pushUtil.removeTask(orderId, 1);//删除定时任务,结束推送数据

--
Gitblit v1.7.1