| | |
| | | //修改行程信息 |
| | | 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; |
| | | } |
| | |
| | | |
| | | |
| | | @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){ |
| | |
| | | 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){ |
| | |
| | | //获取红包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()); |
| | |
| | | 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 |