puzhibing
2024-02-23 9b3f6f5952d45ceeb0770fe4622721007b8fc79d
UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/specialTrain/server/impl/OrderPrivateCarServiceImpl.java
@@ -1417,24 +1417,33 @@
                    if(null != settlementAllocation){
                        JSONObject jsonObject = JSON.parseObject(settlementAllocation.getContent());
                        Double maxPrice = jsonObject.getDouble("maxPrice");
                        List<SettlementDetail> settlementDetailList = settlementDetailService.selectList(new EntityWrapper<SettlementDetail>().eq("driverId", driver.getId()).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(driver.getId());
                            settlementRecord.setType(1);
                            settlementRecord.setPaymentStatus(1);
                            settlementRecord.setPayMoney(total.doubleValue());
                            settlementRecord.setInsertTime(new Date());
                            settlementRecordService.insert(settlementRecord);
                        Integer type1 = jsonObject.getInteger("type");
                        if(1 == type1){
                            List<SettlementDetail> settlementDetailList = settlementDetailService.selectList(new EntityWrapper<SettlementDetail>().eq("driverId", driver.getId()).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) {
                                detail.setSettlementRecordId(settlementRecord.getId());
                                settlementDetailService.updateById(detail);
                                total = total.add(new BigDecimal(detail.getPrice()));
                            }
                            if(maxPrice.compareTo(total.doubleValue()) <= 0){
                                SettlementRecord settlementRecord = settlementRecordService.selectOne(new EntityWrapper<SettlementRecord>().eq("driverId", orderPrivateCar.getDriverId())
                                        .eq("type", type1).eq("paymentStatus", 1).last(" and day = DATE_FORMAT(now(), '%Y-%m-%d')"));
                                if(null == settlementRecord){
                                    settlementRecord = new SettlementRecord();
                                    settlementRecord.setDay(new Date());
                                    settlementRecord.setDriverId(orderPrivateCar.getDriverId());
                                    settlementRecord.setType(type1);
                                    settlementRecord.setPaymentStatus(1);
                                    settlementRecord.setPayMoney(total.doubleValue());
                                    settlementRecord.setInsertTime(new Date());
                                    settlementRecordService.insert(settlementRecord);
                                }else{
                                    settlementRecord.setPayMoney(total.doubleValue());
                                    settlementRecordService.updateById(settlementRecord);
                                }
                                for (SettlementDetail detail : settlementDetailList) {
                                    detail.setSettlementRecordId(settlementRecord.getId());
                                    settlementDetailService.updateById(detail);
                                }
                            }
                        }
                    }