From aecfea75f2a6e5b93f02821a8d39d4018852a80a Mon Sep 17 00:00:00 2001 From: b2894lxlx <517289602@qq.com> Date: Tue, 1 Apr 2025 13:00:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=97=A0=E6=B3=95=E6=94=AF?= =?UTF-8?q?=E4=BB=98=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../shop/controller/OrderPayController.java | 44 ++++++++++--------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/gxwebsoft/shop/controller/OrderPayController.java b/src/main/java/com/gxwebsoft/shop/controller/OrderPayController.java index cd0fcb2..3423173 100644 --- a/src/main/java/com/gxwebsoft/shop/controller/OrderPayController.java +++ b/src/main/java/com/gxwebsoft/shop/controller/OrderPayController.java @@ -78,7 +78,7 @@ public class OrderPayController extends BaseController { @GetMapping() public ApiResult> list(OrderPayParam param) { - List orderPays = orderPayService.listRel(param); + List orderPays = orderPayService.listRel(param); if (null != param.getRentOrderId() && 0 != param.getRentOrderId()) {//如果是单个查询 Order order = orderService.getById(param.getRentOrderId()); if (null != order && !orderPays.isEmpty()) { @@ -98,26 +98,28 @@ public class OrderPayController extends BaseController { @GetMapping("/{id}") public ApiResult get(@PathVariable("id") Integer id) { - final OrderPay orderPay = orderPayService.getById(id); - final BigDecimal rent = orderPay.getBatteryRent(); - final OrderPay one = orderPayService.getOne(new LambdaQueryWrapper() - .eq(OrderPay::getRentOrderId, orderPay.getRentOrderId()) - .eq(OrderPay::getUserId, orderPay.getUserId()) - .eq(OrderPay::getPayStatus, PAY_STATUS_SUCCESS) - .orderByDesc(OrderPay::getId) - .last("limit 1") - ); - final Integer goodsId = orderPay.getGoodsId(); - final EquipmentGoods goods = equipmentGoodsService.getByIdRel(goodsId); - final BigDecimal batteryRent = goods.getBatteryRent(); - // 按新的续费价格 - orderPay.setTotalPrice(batteryRent); - final long between = DateUtil.between(new Date(), one.getExpirationTime(), DateUnit.DAY, false); - if(between < 0){ - // 有逾期的订单不能享受折扣 - orderPay.setTotalPrice(rent); - } - return success(orderPay); + final OrderPay orderPay = orderPayService.getById(id); + final BigDecimal rent = orderPay.getBatteryRent(); + final OrderPay one = orderPayService.getOne(new LambdaQueryWrapper() + .eq(OrderPay::getRentOrderId, orderPay.getRentOrderId()) + .eq(OrderPay::getUserId, orderPay.getUserId()) + .eq(OrderPay::getPayStatus, PAY_STATUS_SUCCESS) + .orderByDesc(OrderPay::getId) + .last("limit 1") + ); + final Integer goodsId = orderPay.getGoodsId(); + final EquipmentGoods goods = equipmentGoodsService.getByIdRel(goodsId); + final BigDecimal batteryRent = goods.getBatteryRent(); + // 按新的续费价格 + orderPay.setTotalPrice(batteryRent); + if (one != null) { + final long between = DateUtil.between(new Date(), one.getExpirationTime(), DateUnit.DAY, false); + if (between < 0) { + // 有逾期的订单不能享受折扣 + orderPay.setTotalPrice(rent); + } + } + return success(orderPay); } @GetMapping("/change-order-no")