| | |
| | | //获取订单的计费策略 |
| | | List<AccountingStrategyDetailOrder> accountingStrategyDetailOrderList = accountingStrategyDetailOrderClient.getAllAccountingStrategyDetailOrder(chargingOrder.getId()).getData(); |
| | | chargingOrderAccountingStrategyService.remove(new LambdaQueryWrapper<TChargingOrderAccountingStrategy>().eq(TChargingOrderAccountingStrategy::getChargingOrderId, chargingOrder.getId())); |
| | | for (int i = 0; i < 12; i++) { |
| | | for (int i = 0; i < accountingStrategyDetailOrderList.size(); i++) { |
| | | Class<? extends TransactionRecordMessageVO> clazz = vo.getClass(); |
| | | try { |
| | | Object invoke1 = clazz.getMethod("getBilling_model_code" + (i + 1)).invoke(vo); |
| | | if(null != invoke1){ |
| | | Integer id = Integer.valueOf(invoke1.toString()); |
| | | AccountingStrategyDetailOrder strategyDetail = accountingStrategyDetailOrderList.stream().filter(s -> s.getId().equals(id)).findFirst().get(); |
| | | //阶段(1=尖阶段,2=峰阶段,3=平阶段,4=谷阶段) |
| | | Object invoke = null; |
| | | switch (strategyDetail.getType()){ |
| | | case 1: |
| | | //充电度数 |
| | | invoke = clazz.getMethod("getSpike_charge" + (i + 1)).invoke(vo); |
| | | break; |
| | | case 2: |
| | | //充电度数 |
| | | invoke = clazz.getMethod("getPeak_charge" + (i + 1)).invoke(vo); |
| | | break; |
| | | case 3: |
| | | //充电度数 |
| | | invoke = clazz.getMethod("getFlat_charge" + (i + 1)).invoke(vo); |
| | | break; |
| | | case 4: |
| | | //充电度数 |
| | | invoke = clazz.getMethod("getValley_amount" + (i + 1)).invoke(vo); |
| | | break; |
| | | } |
| | | if(null == invoke || invoke.toString().equals("0")){ |
| | | continue; |
| | | } |
| | | BigDecimal Sharp_peak_charge = new BigDecimal(invoke.toString()); |
| | | TChargingOrderAccountingStrategy chargingOrderAccountingStrategy = new TChargingOrderAccountingStrategy(); |
| | | chargingOrderAccountingStrategy.setChargingOrderId(chargingOrder.getId()); |
| | | chargingOrderAccountingStrategy.setAccountingStrategyDetailId(strategyDetail.getId()); |
| | | chargingOrderAccountingStrategy.setType(strategyDetail.getType()); |
| | | chargingOrderAccountingStrategy.setStartTime(chargingOrder.getStartTime().format(DateTimeFormatter.ofPattern("HH:mm"))); |
| | | chargingOrderAccountingStrategy.setEndTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("HH:mm"))); |
| | | chargingOrderAccountingStrategy.setElectrovalence(strategyDetail.getElectrovalence()); |
| | | chargingOrderAccountingStrategy.setServiceCharge(strategyDetail.getServiceCharge()); |
| | | chargingOrderAccountingStrategy.setCostServiceCharge(strategyDetail.getCostServiceCharge()); |
| | | //已充电总度数 |
| | | BigDecimal electrovalenc = strategyDetail.getElectrovalence().multiply(Sharp_peak_charge); |
| | | BigDecimal originalServicePrice = strategyDetail.getServiceCharge().multiply(Sharp_peak_charge); |
| | | BigDecimal serviceCharge = originalServicePrice; |
| | | //计算优惠金额 |
| | | if(null != chargingOrder.getVipDiscount()){ |
| | | serviceCharge = serviceCharge.multiply(chargingOrder.getVipDiscount().divide(new BigDecimal(10))); |
| | | } |
| | | chargingOrderAccountingStrategy.setChargingCapacity(Sharp_peak_charge); |
| | | chargingOrderAccountingStrategy.setPeriodElectricPrice(electrovalenc); |
| | | chargingOrderAccountingStrategy.setPeriodServicePrice(serviceCharge); |
| | | chargingOrderAccountingStrategy.setPeriodOriginalServicePrice(originalServicePrice); |
| | | chargingOrderAccountingStrategy.setCreateTime(LocalDateTime.now()); |
| | | chargingOrderAccountingStrategyService.save(chargingOrderAccountingStrategy); |
| | | |
| | | BigDecimal periodElectricPrice = chargingOrderAccountingStrategy.getPeriodElectricPrice(); |
| | | BigDecimal periodServicePrice = chargingOrderAccountingStrategy.getPeriodOriginalServicePrice(); |
| | | periodElectricPrice_total = periodElectricPrice_total.add(periodElectricPrice); |
| | | periodServicePrice_total = periodServicePrice_total.add(periodServicePrice); |
| | | total = total.add(periodElectricPrice).add(periodServicePrice); |
| | | AccountingStrategyDetailOrder strategyDetail = accountingStrategyDetailOrderList.get(i); |
| | | //阶段(1=尖阶段,2=峰阶段,3=平阶段,4=谷阶段) |
| | | Object invoke = null; |
| | | switch (strategyDetail.getType()){ |
| | | case 1: |
| | | //充电度数 |
| | | invoke = clazz.getMethod("getSpike_charge" + (i + 1)).invoke(vo); |
| | | break; |
| | | case 2: |
| | | //充电度数 |
| | | invoke = clazz.getMethod("getPeak_charge" + (i + 1)).invoke(vo); |
| | | break; |
| | | case 3: |
| | | //充电度数 |
| | | invoke = clazz.getMethod("getFlat_charge" + (i + 1)).invoke(vo); |
| | | break; |
| | | case 4: |
| | | //充电度数 |
| | | invoke = clazz.getMethod("getValley_amount" + (i + 1)).invoke(vo); |
| | | break; |
| | | } |
| | | if(null == invoke || invoke.toString().equals("0")){ |
| | | continue; |
| | | } |
| | | BigDecimal Sharp_peak_charge = new BigDecimal(invoke.toString()); |
| | | TChargingOrderAccountingStrategy chargingOrderAccountingStrategy = new TChargingOrderAccountingStrategy(); |
| | | chargingOrderAccountingStrategy.setChargingOrderId(chargingOrder.getId()); |
| | | chargingOrderAccountingStrategy.setAccountingStrategyDetailId(strategyDetail.getId()); |
| | | chargingOrderAccountingStrategy.setType(strategyDetail.getType()); |
| | | chargingOrderAccountingStrategy.setStartTime(chargingOrder.getStartTime().format(DateTimeFormatter.ofPattern("HH:mm"))); |
| | | chargingOrderAccountingStrategy.setEndTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("HH:mm"))); |
| | | chargingOrderAccountingStrategy.setElectrovalence(strategyDetail.getElectrovalence()); |
| | | chargingOrderAccountingStrategy.setServiceCharge(strategyDetail.getServiceCharge()); |
| | | chargingOrderAccountingStrategy.setCostServiceCharge(strategyDetail.getCostServiceCharge()); |
| | | //已充电总度数 |
| | | BigDecimal electrovalenc = strategyDetail.getElectrovalence().multiply(Sharp_peak_charge); |
| | | BigDecimal originalServicePrice = strategyDetail.getServiceCharge().multiply(Sharp_peak_charge); |
| | | BigDecimal serviceCharge = originalServicePrice; |
| | | //计算优惠金额 |
| | | if(null != chargingOrder.getVipDiscount()){ |
| | | serviceCharge = serviceCharge.multiply(chargingOrder.getVipDiscount().divide(new BigDecimal(10))); |
| | | } |
| | | chargingOrderAccountingStrategy.setChargingCapacity(Sharp_peak_charge); |
| | | chargingOrderAccountingStrategy.setPeriodElectricPrice(electrovalenc); |
| | | chargingOrderAccountingStrategy.setPeriodServicePrice(serviceCharge); |
| | | chargingOrderAccountingStrategy.setPeriodOriginalServicePrice(originalServicePrice); |
| | | chargingOrderAccountingStrategy.setCreateTime(LocalDateTime.now()); |
| | | chargingOrderAccountingStrategyService.save(chargingOrderAccountingStrategy); |
| | | |
| | | BigDecimal periodElectricPrice = chargingOrderAccountingStrategy.getPeriodElectricPrice(); |
| | | BigDecimal periodServicePrice = chargingOrderAccountingStrategy.getPeriodOriginalServicePrice(); |
| | | periodElectricPrice_total = periodElectricPrice_total.add(periodElectricPrice); |
| | | periodServicePrice_total = periodServicePrice_total.add(periodServicePrice); |
| | | total = total.add(periodElectricPrice).add(periodServicePrice); |
| | | } catch (IllegalAccessException e) { |
| | | throw new RuntimeException(e); |
| | | } catch (InvocationTargetException e) { |