无关风月
2024-10-23 02aa8adb8ce9ca916dd1ef0afd2adbea54dd1ee6
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TChargingOrderController.java
@@ -328,10 +328,10 @@
        TChargingOrder byId = chargingOrderService.getById(strategyId);
        ChargingOrderInfoVO chargingOrderInfoVO = new ChargingOrderInfoVO();
        chargingOrderInfoVO.setCdElectronic(byId.getCurrent()!=null?byId.getCurrent()+"":"");
        chargingOrderInfoVO.setCdVoltage(byId.getVoltage()!=null?byId.getVoltage()+"":"");
        chargingOrderInfoVO.setSurplus(byId.getTotalElectricity()!=null?byId.getTotalElectricity()+"":"");
        chargingOrderInfoVO.setTotalPower(byId.getPower()!=null?byId.getPower()+"":"");
        chargingOrderInfoVO.setCdElectronic(byId.getCurrent()!=null?byId.getCurrent().setScale(2, BigDecimal.ROUND_HALF_DOWN)+"":"");
        chargingOrderInfoVO.setCdVoltage(byId.getVoltage()!=null?byId.getVoltage().setScale(2, BigDecimal.ROUND_HALF_DOWN)+"":"");
        chargingOrderInfoVO.setSurplus(byId.getTotalElectricity()!=null?byId.getTotalElectricity().setScale(2, BigDecimal.ROUND_HALF_DOWN)+"":"");
        chargingOrderInfoVO.setTotalPower(byId.getPower()!=null?byId.getPower().setScale(2, BigDecimal.ROUND_HALF_DOWN)+"":"");
        if (byId.getAppUserCarId()!=null){
            List<TAppUserCar> data = appUserCarClient.getCarByIds(Collections.singletonList(byId.getAppUserCarId())).getData();
            if (!data.isEmpty()){
@@ -344,16 +344,20 @@
        // 时段总服务费
        BigDecimal bigDecimal = new BigDecimal("0");
        List<TChargingOrderAccountingStrategy> list = chargingOrderAccountingStrategyService.lambdaQuery().eq(TChargingOrderAccountingStrategy::getChargingOrderId, strategyId).orderByDesc(TChargingOrderAccountingStrategy::getStartTime).list();
        for (TChargingOrderAccountingStrategy tChargingOrderAccountingStrategy : list) {
            if (byId.getVipDiscountAmount()!=null){
                BigDecimal multiply = byId.getVipDiscountAmount().divide(byId.getServiceCharge(), 2)
                        .multiply(tChargingOrderAccountingStrategy.getPeriodOriginalServicePrice());
                tChargingOrderAccountingStrategy.setVipDiscount(multiply);
            }
            bigDecimal = bigDecimal.add(tChargingOrderAccountingStrategy.getPeriodOriginalServicePrice());
            tChargingOrderAccountingStrategy.setVipDiscount(
                    tChargingOrderAccountingStrategy.getPeriodOriginalServicePrice()
                            .subtract(tChargingOrderAccountingStrategy.getPeriodServicePrice())
            );
            tChargingOrderAccountingStrategy.setCouponDiscount(
                    tChargingOrderAccountingStrategy.getPeriodOriginalServicePrice()
                            .subtract(tChargingOrderAccountingStrategy.getPeriodServicePrice())
            );
            if (byId.getCouponDiscountAmount()!=null){
                BigDecimal multiply = byId.getCouponDiscountAmount().divide(byId.getServiceCharge(), 2)
                        .multiply(tChargingOrderAccountingStrategy.getPeriodOriginalServicePrice());
                tChargingOrderAccountingStrategy.setCouponDiscount(multiply);
            }
        }
        chargingOrderInfoVO.setList(list);
        return AjaxResult.success(chargingOrderInfoVO);