From 18d2ac4785e5ff819fe077bdd4eb4ee9731ab454 Mon Sep 17 00:00:00 2001 From: Pu Zhibing <393733352@qq.com> Date: 星期四, 24 十月 2024 11:46:26 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TChargingOrderController.java | 59 +++++++++++++++++++++++++++++++++++++++++++---------------- 1 files changed, 43 insertions(+), 16 deletions(-) diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TChargingOrderController.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TChargingOrderController.java index 429e443..f41efe0 100644 --- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TChargingOrderController.java +++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TChargingOrderController.java @@ -92,7 +92,8 @@ private TokenService tokenService; @Autowired private TOrderEvaluateService orderEvaluateService; - + @Autowired + private TGrantVipService tGrantVipService; @Resource private WxPaymentClient wxPaymentClient; @@ -133,6 +134,15 @@ @Resource private TOrderInvoiceService invoiceService; + /** + * 远程调用 增加管理后台赠送会员记录 + * @return + */ + @ResponseBody + @PostMapping(value = "/management/give/vip") + public R managementGiveVip(@RequestBody TGrantVip grantVip) { + return R.ok(tGrantVipService.save(grantVip)); + } /** * 远程调用根据枪id 查询最新的订单id 用户后台结束充电 @@ -248,7 +258,7 @@ @ResponseBody @GetMapping(value = "/pay/order/charging") @ApiOperation(value = "充电信息", tags = {"管理后台-支付订单-订单信息"}) - public R refundDetail(Long orderId) { + public R<PayOrderChargingInfo> refundDetail(Long orderId) { PayOrderChargingInfo payOrderChargingInfo = new PayOrderChargingInfo(); TChargingOrder byId = chargingOrderService.getById(orderId); List<Site> data = siteClient.getSiteByIds(Collections.singletonList(byId.getSiteId())).getData(); @@ -261,7 +271,20 @@ List<TAppUserCar> data3 = appUserCarClient.getCarByIds(Collections.singletonList(byId.getAppUserCarId())).getData(); payOrderChargingInfo.setCarNum(data3.get(0).getLicensePlate()); } - return R.ok(); + payOrderChargingInfo.setTChargingOrder(byId); + + Long count = chargingOrderAccountingStrategyService.lambdaQuery().eq(TChargingOrderAccountingStrategy::getChargingOrderId, orderId).count(); + payOrderChargingInfo.setPeriodCount(count); + if (byId.getAppUserCarId()!=null) { + List<Long> carid = new ArrayList<>(); + carid.add(byId.getAppUserCarId()); + R<List<TAppUserCar>> carByIds = appUserCarClient.getCarByIds(carid); + payOrderChargingInfo.setCarNum(carByIds.getData().get(0).getLicensePlate()); + } + payOrderChargingInfo.setStartTime(byId.getStartTime()); + payOrderChargingInfo.setEndTime(byId.getEndTime()); + payOrderChargingInfo.setTimeCount(payOrderChargingInfo.calculateDuration()); + return R.ok(payOrderChargingInfo); } @ResponseBody @@ -315,12 +338,12 @@ 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(); + List<TAppUserCar> data = appUserCarClient.getCarByIds(Arrays.asList(byId.getAppUserCarId())).getData(); if (!data.isEmpty()){ chargingOrderInfoVO.setLicensePlate(data.get(0).getLicensePlate()); chargingOrderInfoVO.setVehicleBrand(data.get(0).getVehicleBrand()); @@ -331,16 +354,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); -- Gitblit v1.7.1