From d617e84caebaf2e7aa09c55cb2bd89c5a23ef8ac Mon Sep 17 00:00:00 2001 From: huliguo <2023611923@qq.com> Date: 星期六, 28 六月 2025 15:58:33 +0800 Subject: [PATCH] bug修改 --- ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/order/OrderServiceImpl.java | 67 +++++++++++++++++++++++++++++++-- 1 files changed, 63 insertions(+), 4 deletions(-) diff --git a/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/order/OrderServiceImpl.java b/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/order/OrderServiceImpl.java index 4640431..fcd22cb 100644 --- a/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/order/OrderServiceImpl.java +++ b/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/order/OrderServiceImpl.java @@ -29,7 +29,7 @@ import com.ruoyi.common.redis.service.RedisService; import com.ruoyi.common.security.utils.CodeFactoryUtil; import com.ruoyi.common.security.utils.SecurityUtils; -import com.ruoyi.goods.api.domain.LotteryEvent; +import com.ruoyi.goods.api.domain.TLotteryEvent; import com.ruoyi.goods.api.service.LotteryEventClient; import com.ruoyi.order.config.WxPayConfiguration; import com.ruoyi.order.domain.dto.*; @@ -1579,10 +1579,13 @@ appPlaceOrderVo.setPaySign(payArr[5]); appPlaceOrderVo.setPrepayId(orderPayment.getPrepayId()); // 返回AppPlaceOrderVo对象 - List<LotteryEvent> data = lotteryEventClient.getLotteryEventList(2).getData(); + List<TLotteryEvent> data = lotteryEventClient.getLotteryEventList(2).getData(); if (data.size() > 0) { - long count = data.stream().filter(s -> s.getPayMoney().compareTo(order.getPayMoney()) >= 0).count(); - appPlaceOrderVo.setLotteryDraw(count > 0); + List<TLotteryEvent> collect = data.stream().filter(s -> s.getPayMoney().compareTo(order.getPayMoney()) >= 0).collect(Collectors.toList()); + appPlaceOrderVo.setLotteryDraw(collect.size() > 0); + if (collect.size() > 0) { + appPlaceOrderVo.setLotteryEventId(collect.get(0).getId()); + } } else { appPlaceOrderVo.setLotteryDraw(false); } @@ -6706,4 +6709,60 @@ } return new ArrayList<>(); } + /** + * 后台取消订单 + * 订单状态变为已取消 不退款 + * @param dto + */ + @Override + public R cancelOrderBySys(CancelOrderDTO dto) { + Order order = this.getById(dto.getOrderId()); + // 订单状态-1.删除 0.已取消 1.待支付 2.待核销 3.已完成 + if(null == order || order.getDelFlag() == -1){ + return R.fail("订单不存在"); + } + + if (order.getOrderStatus() == 0) { + return R.fail(AppErrorConstant.CANCEL_CANCEL_ORDER); + } else if (order.getOrderStatus() == 1) { + //删除待支付超时取消延时任务 + redisService.deleteObject(DelayTaskEnum.ORDER_AUTOMATIC_CANCEL.getCode() + "-" + order.getOrderId()); + remoteConfigService.deleteDelayTask(DelayTaskEnum.ORDER_AUTOMATIC_CANCEL.getCode()+"-"+order.getOrderId()); + order.setOrderStatus(0); + order.setCancelTime(new Date()); + this.saveOrUpdate(order); + } else if (order.getOrderStatus() == 2) { + // 2.待核销 + order.setOrderStatus(0); + order.setCancelTime(new Date()); + this.saveOrUpdate(order); + } else { + return R.fail(AppErrorConstant.CANCEL_ERROR_ORDER); + } + return R.ok(); + } + + @Override + public R refundOrderBySys(CancelOrderDTO dto) { + Order order = this.getById(dto.getOrderId()); + // 订单状态-1.删除 0.已取消 1.待支付 2.待核销 3.已完成 + if(null == order || order.getDelFlag() == -1){ + return R.fail("订单不存在"); + } + if (order.getOrderStatus() == 0) { + return R.fail(AppErrorConstant.CANCEL_CANCEL_ORDER); + }else if (order.getOrderStatus() == 1) { + //删除待支付超时取消延时任务 + redisService.deleteObject(DelayTaskEnum.ORDER_AUTOMATIC_CANCEL.getCode() + "-" + order.getOrderId()); + remoteConfigService.deleteDelayTask(DelayTaskEnum.ORDER_AUTOMATIC_CANCEL.getCode()+"-"+ order.getOrderId()); + this.autoCancelOrder( order.getOrderId()); + } else if (order.getOrderStatus() == 2) { + // 2.待核销 -> 订单退款 + this.refundOrder( order.getOrderId()); + } else { + return R.fail("已核销订单不能退款"); + } + return R.ok(); + + } } -- Gitblit v1.7.1