Pu Zhibing
2024-12-12 f4c42ef27bf35c59dc7f23e49e8f7671b4baa378
UserIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/specialTrain/server/impl/OrderPrivateCarServiceImpl.java
@@ -902,10 +902,10 @@
        //修改行程信息
        if(orderPrivateCar.getState() == 10 || orderPrivateCar.getState() == 12){
            Car car = carService.selectById(orderPrivateCar.getCarId());
            boolean updateTrip = fleetEngineUtil.updateTrip("CANCELED", car.getVehicleId(), null, orderPrivateCar.getTripId(), null, null, null, null);
            boolean updateTrip = fleetEngineUtil.updateTrip("CANCELED", (null != car ? car.getVehicleId() : null), null, orderPrivateCar.getTripId(), null, null, null, null);
            if(!updateTrip){
                for (int i = 0; i < 5; i++) {
                    updateTrip = fleetEngineUtil.updateTrip("CANCELED", car.getVehicleId(), null, orderPrivateCar.getTripId(), null, null, null, null);
                    updateTrip = fleetEngineUtil.updateTrip("CANCELED", (null != car ? car.getVehicleId() : null), null, orderPrivateCar.getTripId(), null, null, null, null);
                    if(updateTrip){
                        break;
                    }
@@ -1258,7 +1258,7 @@
    @Override
    @Transactional
    @Transactional(rollbackFor = Exception.class)
    public ResultUtil payPrivateCarOrder(Integer payType, Integer bankCardId, Integer orderId, Integer couponId, Integer redDeduction, Integer type, Integer language) throws Exception {
        OrderPrivateCar orderPrivateCar = this.selectById(orderId);
        if(orderPrivateCar.getState() == 8 || orderPrivateCar.getState() == 9){
@@ -1323,10 +1323,9 @@
        if(null != redDeduction && 1 == redDeduction && null == orderPrivateCar.getRedPacketId()){
            RedEnvelopePaymentSettings redEnvelopePaymentSettings = redEnvelopePaymentSettingsService.getRedEnvelopePaymentSettings();
            if(null != redEnvelopePaymentSettings){
                Double total = userRedPacketRecordService.queryRemainingAmount(uid);
                List<UserRedPacketRecord> userRedPacketRecords = userRedPacketRecordService.selectList(new EntityWrapper<UserRedPacketRecord>().eq("userId", uid)
                        .eq("state", 1).eq("companyId", orderPrivateCar.getCompanyId()).gt("remainingAmount", 0).orderBy("insertTime", false));
                Double total = userRedPacketRecords.stream().mapToDouble(UserRedPacketRecord::getRemainingAmount).sum();
                BigDecimal deductionRatio = redEnvelopePaymentSettings.getDeductionRatio();
                BigDecimal multiply1 = orderMoney.multiply(deductionRatio.divide(new BigDecimal(100))).setScale(2, RoundingMode.HALF_EVEN);
                if(total > 0 && multiply1.doubleValue() > 0 && total.compareTo(multiply1.doubleValue()) >= 0){
@@ -1336,12 +1335,10 @@
                    //获取红包id
                    JSONArray jsonArray = new JSONArray();
                    for (UserRedPacketRecord userRedPacketRecord : userRedPacketRecords) {
                        if(multiply1.compareTo(BigDecimal.ZERO) == 0){
                            break;
                        }
                        JSONObject jsonObject = new JSONObject();
                        jsonObject.put("id", userRedPacketRecord.getId());
                        BigDecimal remainingAmount = new BigDecimal(userRedPacketRecord.getRemainingAmount());
                        if(multiply1.compareTo(remainingAmount) >= 0){
                            userRedPacketRecord.setRemainingAmount(0D);
                            userRedPacketRecord.setEndTime(new Date());
@@ -1354,14 +1351,14 @@
                            jsonObject.put("money", multiply1.setScale(2, RoundingMode.HALF_EVEN));
                            jsonArray.add(jsonObject);
                            multiply1 = BigDecimal.ZERO;
                            break;
                        }
                    }
                    if(userRedPacketRecords.size() > 0){
                        userRedPacketRecordService.updateBatchById(userRedPacketRecords);
                    }
                    orderPrivateCar.setRedPacketId(jsonArray.toJSONString());
                }
                if(total > 0 && total.compareTo(multiply1.doubleValue()) < 0){
                }else if(total > 0 && total.compareTo(multiply1.doubleValue()) < 0){
                    orderPrivateCar.setRedPacketMoney(total);
                    orderMoney = orderMoney.subtract(new BigDecimal(total)).setScale(2, RoundingMode.HALF_EVEN);
                    //获取红包id