From 818937959bb19d3669585fa87a526bffe9ce77a4 Mon Sep 17 00:00:00 2001
From: Pu Zhibing <393733352@qq.com>
Date: 星期四, 24 四月 2025 09:28:41 +0800
Subject: [PATCH] 修改默认验证码

---
 UserOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/taxi/service/impl/OrderTaxiServiceImpl.java |  282 +++++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 206 insertions(+), 76 deletions(-)

diff --git a/UserOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/taxi/service/impl/OrderTaxiServiceImpl.java b/UserOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/taxi/service/impl/OrderTaxiServiceImpl.java
index 10394c3..64696e9 100644
--- a/UserOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/taxi/service/impl/OrderTaxiServiceImpl.java
+++ b/UserOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/taxi/service/impl/OrderTaxiServiceImpl.java
@@ -5,6 +5,7 @@
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.mapper.EntityWrapper;
 import com.baomidou.mybatisplus.service.impl.ServiceImpl;
+import com.stylefeng.guns.core.util.GpsCoordinateUtils;
 import com.stylefeng.guns.core.util.ToolUtil;
 import com.stylefeng.guns.modular.crossCity.server.IOrderCrossCityService;
 import com.stylefeng.guns.modular.crossCity.server.impl.OrderCrossCityServiceImpl;
@@ -20,9 +21,11 @@
 import com.stylefeng.guns.modular.system.warpper.OrderServerWarpper;
 import com.stylefeng.guns.modular.taxi.dao.OrderTaxiMapper;
 import com.stylefeng.guns.modular.taxi.dao.TPhoneMapper;
+import com.stylefeng.guns.modular.taxi.dao.TransactionDetailsMapper;
 import com.stylefeng.guns.modular.taxi.model.OrderTaxi;
 import com.stylefeng.guns.modular.taxi.model.PaymentRecord;
 import com.stylefeng.guns.modular.taxi.model.TPhone;
+import com.stylefeng.guns.modular.taxi.model.TransactionDetails;
 import com.stylefeng.guns.modular.taxi.service.IOrderTaxiService;
 import com.stylefeng.guns.modular.taxi.service.IPaymentRecordService;
 import com.stylefeng.guns.modular.taxi.service.ITransactionDetailsService;
@@ -164,7 +167,6 @@
 
 
 
-
     @Resource
     private TPhoneMapper tPhoneMapper;
 
@@ -177,7 +179,8 @@
      * @throws Exception
      */
     @Override
-    public synchronized ResultUtil<BaseWarpper> taxiOrder(OrderTaxi orderTaxi, Integer uid) throws Exception {
+    public synchronized ResultUtil<BaseWarpper> taxiOrder(OrderTaxi orderTaxi, Integer uid,String areaCode) throws Exception {
+        System.out.println("出租车==========================================="+orderTaxi);
         //定义用户所属公司
         UserInfo userInfo1 = userInfoService.selectById(uid);
         if (userInfo1.getIsBlack()==1){
@@ -212,7 +215,7 @@
             return ResultUtil.error("有未完成的订单");
         }
 
-        list = orderTaxiMapper.queryByState_(uid, 2, 1, 1, 2, 3, 4, 5, 6, 11);
+        list = orderTaxiMapper.queryByState_(uid, 2, 1, 1, 2, 3, 4, 5, 6, 7, 11, 12);
         if(list.size() > 0 && orderTaxi.getOrderType() == 2){
             return ResultUtil.error("有未完成的订单");
         }
@@ -559,8 +562,27 @@
                 }
 
                 userInfo.setBalance(new BigDecimal(userInfo.getBalance()).subtract(new BigDecimal(query.getMoney())).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
+                Integer placeOrderWay = null;
+                switch (orderTaxi.getOrderSource()){
+                    case 2:
+                        placeOrderWay = 4;
+                        break;
+                    case 3:
+                        placeOrderWay = 4;
+                        break;
+                    case 6:
+                        placeOrderWay = 1;
+                        break;
+                    case 7:
+                        placeOrderWay = 2;
+                        break;
+                    case 5:
+                        placeOrderWay = 3;
+                        break;
+                }
+                Company company = companyService.selectById(orderTaxi.getCompanyId());
                 //添加交易明细
-                transactionDetailsService.saveData(uid, "取消订单", query.getMoney(), 2, 1, 1, 2, id);
+                transactionDetailsService.saveDataTaxi(uid, "取消订单", query.getMoney(), 2, 1, 1, 2, id,placeOrderWay,company.getId());
                 userInfoService.updateById(userInfo);
 
                 //解除小号绑定
@@ -632,8 +654,8 @@
         UserInfo userInfo = userInfoService.selectById(uid);
         map.put("balance", userInfo.getBalance());
         OrderTaxi orderTaxi = this.selectById(orderId);
-        int i = userCouponRecordService.queryAvailable(uid, orderTaxi.getCompanyId(), 1, 2, orderTaxi.getOrderMoney());
-        i = i + userCouponRecordService.queryAvailable(uid, orderTaxi.getCompanyId(), 1, 0, orderTaxi.getOrderMoney());
+        int i = userCouponRecordService.queryAvailable(uid, null, 1, 2, orderTaxi.getOrderMoney());
+        i = i + userCouponRecordService.queryAvailable(uid, null, 1, 0, orderTaxi.getOrderMoney());
         map.put("coupon", i);
         return map;
     }
@@ -648,8 +670,8 @@
     @Override
     public List<Map<String, Object>> queryCoupon(Integer orderId, Integer uid, Integer pageNum, Integer size) throws Exception {
         OrderTaxi orderTaxi = this.selectById(orderId);
-        List<Map<String, Object>> list = userCouponRecordService.queryCoupon(uid, orderTaxi.getCompanyId(), 1, 2, orderTaxi.getOrderMoney(), pageNum, size);
-        List<Map<String, Object>> list1 = userCouponRecordService.queryCoupon(uid, orderTaxi.getCompanyId(), 1, 0, orderTaxi.getOrderMoney(), pageNum, size);
+        List<Map<String, Object>> list = userCouponRecordService.queryCoupon(uid, null, 1, 2, orderTaxi.getOrderMoney(), pageNum, size);
+        List<Map<String, Object>> list1 = userCouponRecordService.queryCoupon(uid, null, 1, 0, orderTaxi.getOrderMoney(), pageNum, size);
         list.addAll(list1);
         return list;
     }
@@ -682,9 +704,9 @@
         UserCouponRecord userCouponRecord = null;
         if(null != couponId){
             userCouponRecord = userCouponRecordService.selectById(couponId);
-            if(userCouponRecord.getCompanyId() != orderTaxi.getCompanyId()){
-                return ResultUtil.error("优惠券不能用于此订单", "");
-            }
+//            if(userCouponRecord.getCompanyId() != orderTaxi.getCompanyId()){
+//                return ResultUtil.error("优惠券不能用于此订单", "");
+//            }
             if(userCouponRecord.getState() == 2){
                 return ResultUtil.error("优惠券已使用", "");
             }
@@ -733,12 +755,15 @@
                 appletsOpenId = userInfo.getAppletsOpenId();
             }
             Map<String, String> map = icbcPayUtil.placeAnOrder(orderId + ",2", 9, 5, uid.toString(), "完成订单", orderMoney, callbackPath + "/base/wxPayOrderTaxi", "", type, appletsOpenId);
-            if(map.get("code").equals("200")){
-                paymentRecordService.saveData(1, orderTaxi.getUserId(), 1, orderId, 2, 1, orderMoney, map.get("order_id"), 1);//添加预支付数据
-                resultUtil = ResultUtil.success(map.get("data"));
-            }else{
-                resultUtil = ResultUtil.error(map.get("msg"), "");
-            }
+            String app = type == 1 ? "APP" : "JSAPI";
+            resultUtil = payMoneyUtil.weixinpay("完成订单", "", orderId + "_2_" + UUIDUtil.getRandomCode(5), orderMoney.toString(), "/base/wxPayOrderTaxi", app, userInfo.getAppletsOpenId());
+            paymentRecordService.saveData(1, orderTaxi.getUserId(), 1, orderId, 2, 1, orderMoney, "", 1);//添加预支付数据
+//            if(map.get("code").equals("200")){
+//                paymentRecordService.saveData(1, orderTaxi.getUserId(), 1, orderId, 2, 1, orderMoney, map.get("order_id"), 1);//添加预支付数据
+//                resultUtil = ResultUtil.success(map.get("data"));
+//            }else{
+//                resultUtil = ResultUtil.error(map.get("msg"), "");
+//            }
         }
         if(payType == 2){//支付宝支付
             Map<String, String> map = icbcPayUtil.placeAnOrder(orderId + ",2", 10, 5, uid.toString(), "完成订单", orderMoney, callbackPath + "/base/aliPayOrderTaxi", "", type, null);
@@ -757,10 +782,27 @@
             userInfo.setBalance(new BigDecimal(userInfo.getBalance()).subtract(new BigDecimal(orderMoney)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue());
 
             SysIntegral query1 = sysIntegralMapper.query(orderTaxi.getCompanyId());
-            userInfo.setIntegral(userInfo.getIntegral() + (orderMoney.intValue() * query1.getIntegral()));//积分
-
+//            userInfo.setIntegral(userInfo.getIntegral() + (orderMoney.intValue() * query1.getIntegral()));//积分
+            Integer placeOrderWay = null;
+            switch (orderTaxi.getOrderSource()){
+                case 2:
+                    placeOrderWay = 4;
+                    break;
+                case 3:
+                    placeOrderWay = 4;
+                    break;
+                case 6:
+                    placeOrderWay = 1;
+                    break;
+                case 7:
+                    placeOrderWay = 2;
+                    break;
+                case 5:
+                    placeOrderWay = 3;
+                    break;
+            }
             //添加交易明细
-            transactionDetailsService.saveData(uid, "完成订单", orderMoney, 2, 1, 1, 2, orderId);
+//            transactionDetailsService.saveDataTaxi(uid, "完成订单", orderMoney, 2, 1, 1, 2, orderId,placeOrderWay);
             userInfoService.updateById(userInfo);
 
             orderTaxi.setState(8);
@@ -780,24 +822,46 @@
             }
 
             //添加已收入明细
-            Company company = companyService.selectById(orderTaxi.getCompanyId());
-            Double taxi = company.getTaxiMoney();
-            BigDecimal d = null;//企业收入
-            BigDecimal c = null;//司机收入
-            if(company.getIsTaxiFixedOrProportional() == 2){//固定
-                d = new BigDecimal(taxi);
-                c = new BigDecimal(orderTaxi.getOrderMoney()).subtract(d);//只有出行金额参与抽成,其余归属司机
-            }
-            if(company.getIsTaxiFixedOrProportional() == 1){//比例
-                d = new BigDecimal(orderTaxi.getTravelMoney()).multiply(new BigDecimal(taxi).divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_HALF_EVEN);
-                c = new BigDecimal(orderTaxi.getOrderMoney()).subtract(d).setScale(2, BigDecimal.ROUND_HALF_EVEN);
-            }
-            incomeService.saveData(1, orderTaxi.getCompanyId(), 2, orderTaxi.getId(), 2, d.doubleValue());
-            incomeService.saveData(2, orderTaxi.getDriverId(), 2, orderTaxi.getId(), 2, c.doubleValue());
+//            Company company = companyService.selectById(orderTaxi.getCompanyId());
+//            Double taxi = company.getTaxiMoney();
+//            BigDecimal d = null;//企业收入
+//            BigDecimal c = null;//司机收入
+//            if(company.getIsTaxiFixedOrProportional() == 2){//固定
+//                d = new BigDecimal(taxi);
+//                c = new BigDecimal(orderTaxi.getOrderMoney()).subtract(d);//只有出行金额参与抽成,其余归属司机
+//            }
+//            if(company.getIsTaxiFixedOrProportional() == 1){//比例
+//                d = new BigDecimal(orderTaxi.getTravelMoney()).multiply(new BigDecimal(taxi).divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_HALF_EVEN);
+//                c = new BigDecimal(orderTaxi.getOrderMoney()).subtract(d).setScale(2, BigDecimal.ROUND_HALF_EVEN);
+//            }
+//            incomeService.saveData(1, orderTaxi.getCompanyId(), 2, orderTaxi.getId(), 2, d.doubleValue());
+//            incomeService.saveData(2, orderTaxi.getDriverId(), 2, orderTaxi.getId(), 2, c.doubleValue());
             Driver driver = driverService.selectById(orderTaxi.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());
+//            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());
+            Company company = companyService.selectById(driver.getFranchiseeId());
+            if(Objects.isNull(company)){
+                company = companyService.selectById(driver.getCompanyId());
+            }
+            // 司机收入
+            double moneyTwo;
+            // 平台收入
+            double money;
+            if(orderTaxi.getOrderSource() == 2 || orderTaxi.getOrderSource() == 3){
+                double v = company.getPercentageDeduction() / 100;
+                money = v * orderTaxi.getOrderMoney();
+                moneyTwo = orderTaxi.getOrderMoney()-money;
+            }else {
+                money = company.getFixedDeduction();
+                moneyTwo = orderTaxi.getOrderMoney()-money;
+            }
+            driver.setBalance(driver.getBalance() + moneyTwo);
+            // 新增扣除使用费记录
+            transactionDetailsService.saveDataTaxi(driver.getId(), "软件使用费", money, 2, 1, 2, 6, orderTaxi.getId(),placeOrderWay,company.getId());
+            // 司机订单收入
+            transactionDetailsService.saveDataTaxi(driver.getId(), "完成订单", moneyTwo, 1, 1, 2, 2, orderTaxi.getId(),placeOrderWay,company.getId());
+
             driverService.updateById(driver);
 
             // TODO: 2020/5/24 这里需要给司机和用户推送订单状态
@@ -1009,7 +1073,10 @@
                 value = map.get("lon") + "," + map.get("lat");
             }
         }
-        Map<String, String> distance = gdMapElectricFenceUtil.getDistance(value, orderTaxi.getStartLon() + "," + orderTaxi.getStartLat(), 1);
+        // todo 注意 因更换地图为百度 两者lon和lat位置互换了
+        String[] split = value.split(",");
+        value = split[1] + "," + split[0];
+        Map<String, String> distance = gdMapElectricFenceUtil.getDistance(value, orderTaxi.getStartLat() + "," + orderTaxi.getStartLon(), 1);
         String d = "0";
         String t = "0";
         if(null == distance){
@@ -1022,8 +1089,20 @@
         orderServerWarpper.setOrderId(orderTaxi.getId());
         orderServerWarpper.setOrderType(2);
         orderServerWarpper.setState(orderTaxi.getState());
-        orderServerWarpper.setLon(null != value ? value.split(",")[0] : "0.0");
-        orderServerWarpper.setLat(null != value ? value.split(",")[1] : "0.0");
+        orderServerWarpper.setLon(null != value ? value.split(",")[1] : "0.0");
+        orderServerWarpper.setLat(null != value ? value.split(",")[0] : "0.0");
+        value = value == null ? "0.0,0.0" : value;
+        double[] doubles = GpsCoordinateUtils.calBD09toGCJ02(Double.parseDouble(value.split(",")[1]), Double.parseDouble(value.split(",")[0]));
+        orderServerWarpper.setNextLongitude(String.valueOf(doubles[0]));
+        orderServerWarpper.setNextLatitude(String.valueOf(doubles[1]));
+        // 起点地址转换
+        doubles = GpsCoordinateUtils.calBD09toGCJ02(orderTaxi.getStartLat(), orderTaxi.getStartLon());
+        orderServerWarpper.setStartLat(String.valueOf(doubles[0]));
+        orderServerWarpper.setStartLon(String.valueOf(doubles[1]));
+        // 终点地址转换
+        doubles = GpsCoordinateUtils.calBD09toGCJ02(orderTaxi.getEndLat(), orderTaxi.getEndLon());
+        orderServerWarpper.setEndLat(String.valueOf(doubles[0]));
+        orderServerWarpper.setEndLon(String.valueOf(doubles[1]));
         orderServerWarpper.setReassignNotice(orderTaxi.getReassignNotice());
         if(orderTaxi.getState() == 2 || orderTaxi.getState() == 3){//前往预约地
             orderServerWarpper.setReservationMileage(d);
@@ -1034,12 +1113,12 @@
             orderServerWarpper.setLaveTime("0");
         }
         if(orderTaxi.getState() == 5 || orderTaxi.getState() == 6){//服务中
-            distance = gdMapElectricFenceUtil.getDistance(value, orderTaxi.getEndLon() + "," + orderTaxi.getEndLat(), 1);
+            distance = gdMapElectricFenceUtil.getDistance(value, orderTaxi.getEndLat() + "," + orderTaxi.getEndLon(), 1);
             if(null == distance){
                 System.err.println("查询距离出错了");
             }else{
-                d = new BigDecimal(distance.get("distance")).divide(new BigDecimal(1000)).setScale(2, BigDecimal.ROUND_HALF_EVEN).toString();
-                t = new BigDecimal(distance.get("duration")).divide(new BigDecimal(60)).setScale(2, BigDecimal.ROUND_HALF_EVEN).intValue() + "";
+                d = new BigDecimal(distance.get("distance")).divide(new BigDecimal(1000),2, RoundingMode.HALF_UP).toString();
+                t = new BigDecimal(distance.get("duration")).divide(new BigDecimal(60),2, RoundingMode.HALF_UP) + "";
             }
             orderServerWarpper.setReservationMileage("0");
             orderServerWarpper.setReservationTime("0");
@@ -1170,17 +1249,36 @@
         OrderTaxi orderTaxi = this.selectById(id);
         PaymentRecord query = paymentRecordService.query(1, orderTaxi.getUserId(), 1, Integer.valueOf(id), 2, type, 1);
         if(null != query){
-            //添加交易明细
-            transactionDetailsService.saveData(orderTaxi.getUserId(), "完成订单", query.getAmount(), 2, 1, 1, 2, query.getOrderId());
+            Integer placeOrderWay = null;
+            switch (orderTaxi.getOrderSource()){
+                case 2:
+                    placeOrderWay = 4;
+                    break;
+                case 3:
+                    placeOrderWay = 4;
+                    break;
+                case 6:
+                    placeOrderWay = 1;
+                    break;
+                case 7:
+                    placeOrderWay = 2;
+                    break;
+                case 5:
+                    placeOrderWay = 3;
+                    break;
+            }
+//            Company company = companyService.selectById(orderTaxi.getCompanyId());
+//            //添加交易明细
+//            transactionDetailsService.saveDataTaxi(orderTaxi.getUserId(), "完成订单", query.getAmount(), 2, 1, 1, 2, query.getOrderId(),placeOrderWay,company.getId());
             orderTaxi.setState(8);
             orderTaxi.setPayType(type);
             orderTaxi.setPayMoney(query.getAmount());
             this.updateById(orderTaxi);
 
-            UserInfo userInfo = userInfoService.selectById(orderTaxi.getUserId());
-            SysIntegral query1 = sysIntegralMapper.query(orderTaxi.getCompanyId());
-            userInfo.setIntegral(userInfo.getIntegral() + (query.getAmount().intValue() * query1.getIntegral()));//积分
-            userInfoService.updateById(userInfo);
+//            UserInfo userInfo = userInfoService.selectById(orderTaxi.getUserId());
+//            SysIntegral query1 = sysIntegralMapper.query(orderTaxi.getCompanyId());
+//            userInfo.setIntegral(userInfo.getIntegral() + (query.getAmount().intValue() * query1.getIntegral()));//积分
+//            userInfoService.updateById(userInfo);
 
             //处理优惠券和红包
             if(null != orderTaxi.getCouponId()){
@@ -1202,24 +1300,46 @@
             paymentRecordService.updateById(query);
 
             //添加已收入明细
-            Company company = companyService.selectById(orderTaxi.getCompanyId());
-            Double taxi = company.getTaxiMoney();
-            BigDecimal d = null;//企业收入
-            BigDecimal c = null;//司机收入
-            if(company.getIsTaxiFixedOrProportional() == 2){//固定
-                d = new BigDecimal(taxi);
-                c = new BigDecimal(orderTaxi.getOrderMoney()).subtract(d).setScale(2, BigDecimal.ROUND_HALF_EVEN);
-            }
-            if(company.getIsTaxiFixedOrProportional() == 1){//比例
-                d = new BigDecimal(orderTaxi.getTravelMoney()).multiply(new BigDecimal(taxi).divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_HALF_EVEN);
-                c = new BigDecimal(orderTaxi.getOrderMoney()).subtract(d).setScale(2, BigDecimal.ROUND_HALF_EVEN);
-            }
-            incomeService.saveData(1, orderTaxi.getCompanyId(), 2, orderTaxi.getId(), 2, d.doubleValue());
-            incomeService.saveData(2, orderTaxi.getDriverId(), 2, orderTaxi.getId(), 2, c.doubleValue());
+//            Company company = companyService.selectById(orderTaxi.getCompanyId());
+//            Double taxi = company.getTaxiMoney();
+//            BigDecimal d = null;//企业收入
+//            BigDecimal c = null;//司机收入
+//            if(company.getIsTaxiFixedOrProportional() == 2){//固定
+//                d = new BigDecimal(taxi);
+//                c = new BigDecimal(orderTaxi.getOrderMoney()).subtract(d).setScale(2, BigDecimal.ROUND_HALF_EVEN);
+//            }
+//            if(company.getIsTaxiFixedOrProportional() == 1){//比例
+//                d = new BigDecimal(orderTaxi.getTravelMoney()).multiply(new BigDecimal(taxi).divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_HALF_EVEN);
+//                c = new BigDecimal(orderTaxi.getOrderMoney()).subtract(d).setScale(2, BigDecimal.ROUND_HALF_EVEN);
+//            }
+//            incomeService.saveData(1, orderTaxi.getCompanyId(), 2, orderTaxi.getId(), 2, d.doubleValue());
+//            incomeService.saveData(2, orderTaxi.getDriverId(), 2, orderTaxi.getId(), 2, c.doubleValue());
             Driver driver = driverService.selectById(orderTaxi.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());
+//            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());
+            Company company = companyService.selectById(driver.getFranchiseeId());
+            if(Objects.isNull(company)){
+                company = companyService.selectById(driver.getCompanyId());
+            }
+            // 司机收入
+            double moneyTwo;
+            // 平台收入
+            double money;
+            if(orderTaxi.getOrderSource() == 2 || orderTaxi.getOrderSource() == 3){
+                double v = company.getPercentageDeduction() / 100;
+                money = v * orderTaxi.getOrderMoney();
+                moneyTwo = orderTaxi.getOrderMoney()-money;
+            }else {
+                money = company.getFixedDeduction();
+                moneyTwo = orderTaxi.getOrderMoney()-money;
+            }
+            driver.setBalance(driver.getBalance() + moneyTwo);
+            // 新增扣除使用费记录
+            transactionDetailsService.saveDataTaxi(driver.getId(), "软件使用费", money, 2, 1, 2, 6, orderTaxi.getId(),placeOrderWay,company.getId());
+            // 司机订单收入
+            transactionDetailsService.saveDataTaxi(driver.getId(), "完成订单", moneyTwo, 1, 1, 2, 2, orderTaxi.getId(),placeOrderWay,company.getId());
+
             driverService.updateById(driver);
 
             // TODO: 2020/5/24 这里需要给司机和用户推送订单状态
@@ -1264,8 +1384,27 @@
         OrderTaxi orderTaxi = this.selectById(id);
         PaymentRecord query = paymentRecordService.query(1, orderTaxi.getUserId(), 1, Integer.valueOf(id), 2, type, 1);
         if(null != query){
+            Integer placeOrderWay = null;
+            switch (orderTaxi.getOrderSource()){
+                case 2:
+                    placeOrderWay = 4;
+                    break;
+                case 3:
+                    placeOrderWay = 4;
+                    break;
+                case 6:
+                    placeOrderWay = 1;
+                    break;
+                case 7:
+                    placeOrderWay = 2;
+                    break;
+                case 5:
+                    placeOrderWay = 3;
+                    break;
+            }
+            Company company = companyService.selectById(orderTaxi.getCompanyId());
             //添加交易明细
-            transactionDetailsService.saveData(orderTaxi.getUserId(), "取消订单", query.getAmount(), 2, 1, 1, 2, query.getOrderId());
+            transactionDetailsService.saveDataTaxi(orderTaxi.getUserId(), "取消订单", query.getAmount(), 2, 1, 1, 2, query.getOrderId(),placeOrderWay,company.getId());
             orderTaxi.setState(10);
             //解除小号绑定
             if(orderTaxi.getBindId() != null){
@@ -1316,20 +1455,15 @@
             @Override
             public void run() {
                 try {
-                    System.out.println("进入订单推送111111111111");
                     orderIds.add(orderTaxi.getId());//添加记录,防止调用接口重复提醒无人接单
                     String vehicle = redisUtil.getValue("VEHICLE");
                     List<Integer> integers = new ArrayList<>();
                     if(ToolUtil.isNotEmpty(vehicle)){
                         integers = JSON.parseArray(vehicle).toJavaList(Integer.class);
                     }
-                    System.out.println("进入订单推送22222222222222=========="+integers);
                     Company query = companyCityService.query(String.valueOf(orderTaxi.getStartLon()), String.valueOf(orderTaxi.getStartLat()));//获取起点所属分公司
-                    System.out.println("进入订单推送=========3==========="+query);
                     List<PushOrder> querys = pushOrderService.querys(null, 2, query.getId());//获取需要推送的次数
-                    System.out.println("进入订单推送=========4==========="+querys);
                     for(int i = 1; i <= querys.size(); i++){
-                        System.out.println("进入订单推送");
                         PushOrder pushOrder = pushOrderService.querys(i, 2, query.getId()).get(0);
                         System.out.println("进入订单推送");
                         //获取空闲司机
@@ -1338,11 +1472,8 @@
                         if(list.size() > 0){
                             System.out.println("进入司机推送");
                             double driverProportion = pushOrder.getDriverProportion() / 100;//推送占比计算成小数
-                            System.out.println("推送占比计算成小数======="+driverProportion);
                             int lastIndex = Double.valueOf(list.size() * driverProportion).intValue();//计算占比转成整数(下标截取)
-                            System.out.println("计算占比转成整数======="+lastIndex);
                             list = list.subList(0, lastIndex);//获取空闲司机中占比数据
-                            System.out.println("获取空闲司机中占比数据======="+list);
                             for(Driver driver : list){//开始进行推送
                                 System.out.println("开始进行推送======="+driver);
                                 //查询是否在限制推单范围内
@@ -1356,7 +1487,6 @@
                                 if(bo){
                                     continue;
                                 }
-                                System.out.println("推送订单前");
                                 pushUtil.pushOrderState(2, driver.getId(), orderTaxi.getId(), 2, orderTaxi.getState(), pushOrder.getPushTime());
                                 System.out.println("推送订单后");
                             }

--
Gitblit v1.7.1