无关风月
2024-10-21 82e5f5968a77bde806f45a0ae1fe16f40852d6d6
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TChargingOrderController.java
@@ -309,18 +309,38 @@
    @ResponseBody
    @PostMapping(value = "/chargingOrderInfo")
    @ApiOperation(value = "充电桩订单列表查看详情", tags = {"管理后台-订单管理"})
    public AjaxResult<ChargingOrderInfoVO> chargingOrderInfo(String orderId) {
    public AjaxResult<ChargingOrderInfoVO> chargingOrderInfo(String strategyId) {
        TChargingOrder byId = chargingOrderService.getById(strategyId);
        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()!=null?byId.getCurrent()+"":"");
        chargingOrderInfoVO.setCdVoltage(byId.getVoltage()!=null?byId.getVoltage()+"":"");
        chargingOrderInfoVO.setSurplus(byId.getTotalElectricity()!=null?byId.getTotalElectricity()+"":"");
        chargingOrderInfoVO.setTotalPower(byId.getPower()!=null?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, strategyId).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);
    }