From 387f61d55a8e20bc772b026cba4f8c34dfce5665 Mon Sep 17 00:00:00 2001
From: puzhibing <393733352@qq.com>
Date: 星期三, 07 二月 2024 11:20:28 +0800
Subject: [PATCH] 更新代码

---
 DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/server/impl/OrderLogisticsServiceImpl.java |   92 ++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 88 insertions(+), 4 deletions(-)

diff --git a/DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/server/impl/OrderLogisticsServiceImpl.java b/DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/server/impl/OrderLogisticsServiceImpl.java
index 59e4378..dbb8ca4 100644
--- a/DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/server/impl/OrderLogisticsServiceImpl.java
+++ b/DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/server/impl/OrderLogisticsServiceImpl.java
@@ -1,5 +1,7 @@
 package com.stylefeng.guns.modular.smallLogistics.server.impl;
 
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.mapper.EntityWrapper;
 import com.baomidou.mybatisplus.service.impl.ServiceImpl;
 import com.stylefeng.guns.core.util.ToolUtil;
@@ -230,7 +232,16 @@
         return map;
     }
 
+    @Autowired
+    private ISettlementDetailService settlementDetailService;
+    @Autowired
+    private ISettlementAllocationService settlementAllocationService;
 
+    @Autowired
+    private ISettlementRecordService settlementRecordService;
+
+    @Autowired
+    private  OrderLogisticsSpreadService spreadService;
     /**
      * 走订单流程
      * @param orderId
@@ -253,6 +264,9 @@
                 return ResultUtil.error(language == 1 ? "验证失败" : language == 2 ? "Verification failed" : "Echec de la validation");
             }
         }
+
+        List<OrderLogisticsSpread> orderLogisticsId = spreadService.selectList(new EntityWrapper<OrderLogisticsSpread>().eq("orderLogisticsId", orderLogistics.getId()).eq("payType",4));
+
 
         switch (state){
             case 3://出发前往预约点
@@ -307,6 +321,76 @@
                     driverService.updateById(driver);
                 }
 
+                if (orderLogistics.getPayType()==4||!orderLogisticsId.isEmpty()){
+
+                    System.err.println("1111111111111111111111111");
+
+                    double sum = 0;
+                    if (orderLogistics.getPayType()==4){
+                        sum= orderLogistics.getOrderMoney();
+                    }
+
+                    if (!orderLogisticsId.isEmpty()){
+                        for (OrderLogisticsSpread orderLogisticsSpread : orderLogisticsId) {
+                            sum = sum +orderLogisticsSpread.getPrice();
+                        }
+                    }
+
+
+
+                    Company company = companyService.selectById(orderLogistics.getCompanyId());
+                    Double speMoney = company.getSameLogisticsMoney();
+                    BigDecimal d = null;//企业收入
+                    BigDecimal c = null;//司机收入
+                    if(company.getIsSameLogisticsFixedOrProportional() == 2){//固定
+                        d = new BigDecimal(speMoney);
+                        c = new BigDecimal(orderLogistics.getOrderMoney()).subtract(d);//只有出行金额参与抽成,其余归属司机
+                    }
+                    if(company.getIsSameLogisticsFixedOrProportional() == 1){//比例
+                        Double price = orderLogistics.getOrderMoney();
+                        d = new BigDecimal(price).multiply(new BigDecimal(speMoney).divide(new BigDecimal(100), new MathContext(2, RoundingMode.HALF_EVEN)));
+                        c = new BigDecimal(orderLogistics.getOrderMoney()).subtract(d).setScale(2, BigDecimal.ROUND_HALF_EVEN);
+                    }
+                    //记录司机待结算金额
+                    if(d.compareTo(new BigDecimal(0)) > 0){
+                        System.err.println("2222222222222222222222");
+                        SettlementDetail settlementDetail = new SettlementDetail();
+                        settlementDetail.setOrderId(orderId);
+                        settlementDetail.setOrderType(1);
+                        settlementDetail.setDriverId(orderLogistics.getDriverId());
+                        settlementDetail.setOrderMoney(sum);
+                        settlementDetail.setPrice(d.doubleValue());
+                        settlementDetail.setCreateTime(new Date());
+                        settlementDetailService.insert(settlementDetail);
+
+                        SettlementAllocation settlementAllocation = settlementAllocationService.selectOne(null);
+                        if(null != settlementAllocation){
+                            JSONObject jsonObject = JSON.parseObject(settlementAllocation.getContent());
+                            Double maxPrice = jsonObject.getDouble("maxPrice");
+                            List<SettlementDetail> settlementDetailList = settlementDetailService.selectList(new EntityWrapper<SettlementDetail>().eq("driverId", orderLogistics.getDriverId()).isNull("settlementRecordId").last(" and DATE_FORMAT(now(), '%Y-%m-%d') = DATE_FORMAT(createTime, '%Y-%m-%d')"));
+                            BigDecimal total = new BigDecimal(0);
+                            for (SettlementDetail detail : settlementDetailList) {
+                                total = total.add(new BigDecimal(detail.getPrice()));
+                            }
+                            if(maxPrice.compareTo(total.doubleValue()) <= 0){
+                                SettlementRecord settlementRecord = new SettlementRecord();
+                                settlementRecord.setDay(new Date());
+                                settlementRecord.setDriverId(orderLogistics.getDriverId());
+                                settlementRecord.setType(1);
+                                settlementRecord.setPaymentStatus(1);
+                                settlementRecord.setPayMoney(sum);
+                                settlementRecord.setInsertTime(new Date());
+                                settlementRecordService.insert(settlementRecord);
+
+                                for (SettlementDetail detail : settlementDetailList) {
+                                    detail.setSettlementRecordId(settlementRecord.getId());
+                                    settlementDetailService.updateById(detail);
+                                }
+                            }
+                        }
+                    }
+                }
+
                 break;
         }
         this.updateById(orderLogistics);
@@ -346,7 +430,7 @@
                         document.getElementById("french").remove();
                         document.getElementsByTag("title").get(0).text("I-GO电子收据");
                         Element title_chinese = document.getElementById("title_chinese");
-                        title_chinese.text(DateUtil.conversionFormat(language, sdf.format(orderLogistics.getTravelTime())) + ",您在I-GO1个订单消费GHS " + orderLogistics.getPayMoney());
+                        title_chinese.text(DateUtil.conversionFormat(language, sdf.format(orderLogistics.getTravelTime())) + ",您在I-GO此订单消费GHS " + orderLogistics.getPayMoney());
                         Element xcf_chinese = document.getElementById("xcf_chinese");
                         xcf_chinese.text("GHS " + orderLogistics.getOrderMoney());
                         if(null != orderLogistics.getCouponMoney() && orderLogistics.getCouponMoney() > 0){
@@ -592,7 +676,7 @@
                         document.getElementById("french").remove();
                         document.getElementsByTag("title").get(0).text("I-GO电子收据");
                         Element title_chinese = document.getElementById("title_chinese");
-                        title_chinese.text(DateUtil.conversionFormat(language, sdf.format(orderLogistics.getTravelTime())) + ",您在I-GO1个订单消费GHS " + orderLogistics.getPayMoney());
+                        title_chinese.text(DateUtil.conversionFormat(language, sdf.format(orderLogistics.getTravelTime())) + ",您在I-GO此订单消费GHS " + orderLogistics.getPayMoney());
                         Element xcf_chinese = document.getElementById("xcf_chinese");
                         xcf_chinese.text("GHS " + orderLogistics.getOrderMoney());
                         if(null != orderLogistics.getCouponMoney() && orderLogistics.getCouponMoney() > 0){
@@ -838,7 +922,7 @@
                         document.getElementById("french").remove();
                         document.getElementsByTag("title").get(0).text("I-GO电子收据");
                         Element title_chinese = document.getElementById("title_chinese");
-                        title_chinese.text(DateUtil.conversionFormat(language, sdf2.format(orderLogistics.getTravelTime())) + ",您在I-GO1个订单消费GHS " + orderLogistics.getPayMoney());
+                        title_chinese.text(DateUtil.conversionFormat(language, sdf2.format(orderLogistics.getTravelTime())) + ",您在I-GO此订单消费GHS " + orderLogistics.getPayMoney());
                         Element xcf_chinese = document.getElementById("xcf_chinese");
                         xcf_chinese.text("GHS " + orderLogistics.getOrderMoney());
                         if(null != orderLogistics.getCouponMoney() && orderLogistics.getCouponMoney() > 0){
@@ -1085,7 +1169,7 @@
         if(!"1246".equals(pickUpCode) && !orderLogistics.getPickUpCode().equals(pickUpCode)){
             return ResultUtil.error(language == 1 ? "验证失败" : language == 2 ? "Verification failed" : "Echec de la validation");
         }
-        orderLogistics.setState(9);
+        orderLogistics.setState(6);
         this.updateById(orderLogistics);
         return ResultUtil.success();
     }

--
Gitblit v1.7.1