From 28e3ff6cfc3d21d3e99d769b4105819a75afc063 Mon Sep 17 00:00:00 2001 From: puzhibing <393733352@qq.com> Date: 星期三, 07 二月 2024 14:05:55 +0800 Subject: [PATCH] Merge branch 'dev' of http://120.76.84.145:10101/gitblit/r/java/IgoTravel --- DriverIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/smallLogistics/server/impl/OrderLogisticsServiceImpl.java | 86 ++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 85 insertions(+), 1 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 58884b2..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://出发前往预约点 @@ -305,6 +319,76 @@ 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); + } + + 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; @@ -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