luodangjia
2024-10-21 0cffe10d0563f7e2c98b4eca1467699244051b07
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TChargingOrderController.java
@@ -310,17 +310,36 @@
    @PostMapping(value = "/chargingOrderInfo")
    @ApiOperation(value = "充电桩订单列表查看详情", tags = {"管理后台-订单管理"})
    public AjaxResult<ChargingOrderInfoVO> chargingOrderInfo(String orderId) {
        TChargingOrder byId = chargingOrderService.getById(orderId);
        ChargingOrderInfoVO chargingOrderInfoVO = new ChargingOrderInfoVO();
        chargingOrderInfoVO.setCdElectronic("");
        chargingOrderInfoVO.setCdVoltage("");
        chargingOrderInfoVO.setSurplus("");
        chargingOrderInfoVO.setTotalPower("");
        chargingOrderInfoVO.setLicensePlate("");
        chargingOrderInfoVO.setVehicleBrand("");
        chargingOrderInfoVO.setVehicleModel("");
        chargingOrderInfoVO.setVehicleUse("");
        List<TChargingOrderAccountingStrategy> tChargingOrderAccountingStrategies = new ArrayList<>();
        chargingOrderInfoVO.setList(tChargingOrderAccountingStrategies);
        chargingOrderInfoVO.setCdElectronic(byId.getCurrent()+"");
        chargingOrderInfoVO.setCdVoltage(byId.getVoltage()+"");
        chargingOrderInfoVO.setSurplus(byId.getTotalElectricity()+"");
        chargingOrderInfoVO.setTotalPower(byId.getPower()+"");
        if (byId.getAppUserCarId()!=null){
            List<TAppUserCar> data = appUserCarClient.getCarByIds(Collections.singletonList(byId.getAppUserCarId())).getData();
            if (!data.isEmpty()){
                chargingOrderInfoVO.setLicensePlate(data.get(0).getLicensePlate());
                chargingOrderInfoVO.setVehicleBrand(data.get(0).getVehicleBrand());
                chargingOrderInfoVO.setVehicleModel(data.get(0).getVehicleModel());
                chargingOrderInfoVO.setVehicleUse(data.get(0).getVehicleUse());
            }
        }
        // 时段总服务费
        BigDecimal bigDecimal = new BigDecimal("0");
        List<TChargingOrderAccountingStrategy> list = chargingOrderAccountingStrategyService.lambdaQuery().eq(TChargingOrderAccountingStrategy::getChargingOrderId, orderId).orderByDesc(TChargingOrderAccountingStrategy::getStartTime).list();
        for (TChargingOrderAccountingStrategy tChargingOrderAccountingStrategy : list) {
            bigDecimal = bigDecimal.add(tChargingOrderAccountingStrategy.getPeriodOriginalServicePrice());
            tChargingOrderAccountingStrategy.setVipDiscount(
                    tChargingOrderAccountingStrategy.getPeriodOriginalServicePrice()
                            .subtract(tChargingOrderAccountingStrategy.getPeriodServicePrice())
            );
            tChargingOrderAccountingStrategy.setCouponDiscount(
                    tChargingOrderAccountingStrategy.getPeriodOriginalServicePrice()
                            .subtract(tChargingOrderAccountingStrategy.getPeriodServicePrice())
            );
        }
        chargingOrderInfoVO.setList(list);
        return AjaxResult.success(chargingOrderInfoVO);
    }