diff --git a/src/main/java/com/cultural/heritage/constant/MqConstant.java b/src/main/java/com/cultural/heritage/constant/MqConstant.java index f3fd6f7..208295c 100644 --- a/src/main/java/com/cultural/heritage/constant/MqConstant.java +++ b/src/main/java/com/cultural/heritage/constant/MqConstant.java @@ -1,7 +1,13 @@ package com.cultural.heritage.constant; +import java.util.List; + public interface MqConstant { +// List DELAY_MILLIS = List.of(10000L, 10000L, 10000L, 15000L, 15000L, 30000L, 30000L, 60000L, 60000L, 120000L, 300000L, 600000L, 600000L)); + + List DELAY_MILLIS = List.of(10000L, 10000L, 10000L, 15000L, 15000L, 30000L, 30000L); + String DELAY_EXCHANGE = "delay.topic"; String DELAY_ORDER_QUEUE = "order.delay.queue"; diff --git a/src/main/java/com/cultural/heritage/controller/order/PendingServiceGoodController.java b/src/main/java/com/cultural/heritage/controller/order/PendingServiceGoodController.java index 5d6f373..6652724 100644 --- a/src/main/java/com/cultural/heritage/controller/order/PendingServiceGoodController.java +++ b/src/main/java/com/cultural/heritage/controller/order/PendingServiceGoodController.java @@ -7,6 +7,7 @@ import com.cultural.heritage.annotation.AuthCheck; import com.cultural.heritage.common.BaseResponse; import com.cultural.heritage.common.ErrorCode; import com.cultural.heritage.common.ResultUtils; +import com.cultural.heritage.constant.OrderStatusConstant; import com.cultural.heritage.constant.UserConstant; import com.cultural.heritage.exception.BusinessException; import com.cultural.heritage.model.dto.CommonRequest; @@ -35,6 +36,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; @RestController @RequestMapping("/pending") @@ -103,7 +105,6 @@ public class PendingServiceGoodController { pendingServiceGoodVOList.add(pendingServiceGoodVO); } - long current = bookingOrderQueryRequest.getCurrent(); long pageSize = bookingOrderQueryRequest.getPageSize(); long total = pendingServiceOrderList.size(); @@ -136,6 +137,13 @@ public class PendingServiceGoodController { List pendingServiceGoodList = commonService.findByFieldEqTargetField("goodId", id, pendingServiceGoodService); // 获取当前服务类商品的预约情况 List pendingServiceOrderList = commonService.findByFieldInTargetField(pendingServiceGoodList, pendingServiceOrderService, PendingServiceGood::getId, "pendingId"); + + // 过滤掉已退款和交易关闭的订单 + pendingServiceOrderList = pendingServiceOrderList.stream().filter(pendingServiceOrder -> { + String orderItemStatus = pendingServiceOrder.getOrderItemStatus(); + return !orderItemStatus.equals(OrderStatusConstant.TRANSACTION_CLOSED) && !orderItemStatus.equals(OrderStatusConstant.PAYMENT_REFUNDED); + }).collect(Collectors.toList()); + // 封装Map集合(键:服务类商品待处理id,值:预约人数) Map countMap = new HashMap<>(); for (PendingServiceOrder pendingServiceOrder : pendingServiceOrderList) { diff --git a/src/main/java/com/cultural/heritage/controller/wx/WeChatPayController.java b/src/main/java/com/cultural/heritage/controller/wx/WeChatPayController.java index 5599ae2..34dcd30 100644 --- a/src/main/java/com/cultural/heritage/controller/wx/WeChatPayController.java +++ b/src/main/java/com/cultural/heritage/controller/wx/WeChatPayController.java @@ -169,7 +169,7 @@ public class WeChatPayController { * @param commonRequest 订单id */ @PostMapping("/refund/photo/create") - @Operation(summary = "Web端管理员全额退款(商品类)", description = "参数:订单id, 权限:web端管理员, 方法名:createPhotoProductsRefund") + @Operation(summary = "Web端管理员全额退款(写真预约类)", description = "参数:订单id, 权限:web端管理员, 方法名:createPhotoProductsRefund") @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) public BaseResponse createPhotoProductsRefund(@RequestBody CommonRequest commonRequest) { if (commonRequest == null || commonRequest.getId() <= 0) { diff --git a/src/main/java/com/cultural/heritage/listener/OrderStatusListener.java b/src/main/java/com/cultural/heritage/listener/OrderStatusListener.java index 5993911..00cd598 100644 --- a/src/main/java/com/cultural/heritage/listener/OrderStatusListener.java +++ b/src/main/java/com/cultural/heritage/listener/OrderStatusListener.java @@ -5,6 +5,7 @@ import com.cultural.heritage.common.ErrorCode; import com.cultural.heritage.constant.MqConstant; import com.cultural.heritage.constant.OrderStatusConstant; import com.cultural.heritage.exception.ThrowUtils; +import com.cultural.heritage.model.dto.snapshot.CouponSnapshot; import com.cultural.heritage.model.entity.Order; import com.cultural.heritage.model.entity.PendingServiceOrder; import com.cultural.heritage.model.entity.UserCoupon; @@ -81,8 +82,9 @@ public class OrderStatusListener { ThrowUtils.throwIf(!update, ErrorCode.OPERATION_ERROR, "订单状态更新失败"); // 如果使用了优惠券,则退还优惠券 - Long userCouponId = order.getCouponSnapshot().getId(); - if (userCouponId != null) { + CouponSnapshot couponSnapshot = order.getCouponSnapshot(); + if (couponSnapshot != null) { + Long userCouponId = couponSnapshot.getId(); UserCoupon userCoupon = userCouponService.getById(userCouponId); ThrowUtils.throwIf(userCoupon == null, ErrorCode.OPERATION_ERROR, "优惠券不存在"); // 更新优惠券状态 @@ -94,7 +96,7 @@ public class OrderStatusListener { boolean isGeneral = orderService.isGeneralGood(order.getOrderType()); if (!isGeneral) { UpdateWrapper pendingServiceOrderUpdateWrapper = new UpdateWrapper<>(); - pendingServiceOrderUpdateWrapper.eq("orderNumber", order.getOrderNumber()).set("orderStatus", OrderStatusConstant.TRANSACTION_CLOSED); + pendingServiceOrderUpdateWrapper.eq("orderNumber", order.getOrderNumber()).set("orderItemStatus", OrderStatusConstant.TRANSACTION_CLOSED); boolean updateBatch = orderService.update(updateWrapper); ThrowUtils.throwIf(!updateBatch, ErrorCode.OPERATION_ERROR, "订单状态批量更新失败"); } diff --git a/src/main/java/com/cultural/heritage/service/book/impl/AdvanceOrderServiceImpl.java b/src/main/java/com/cultural/heritage/service/book/impl/AdvanceOrderServiceImpl.java index 7dc827f..e9f4bbe 100644 --- a/src/main/java/com/cultural/heritage/service/book/impl/AdvanceOrderServiceImpl.java +++ b/src/main/java/com/cultural/heritage/service/book/impl/AdvanceOrderServiceImpl.java @@ -25,6 +25,8 @@ import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.stereotype.Service; import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; @Service public class AdvanceOrderServiceImpl extends ServiceImpl implements AdvanceOrderService { @@ -100,10 +102,10 @@ public class AdvanceOrderServiceImpl extends ServiceImpl newDelayMillis = new ArrayList<>(MqConstant.DELAY_MILLIS); // 延迟检查订单状态信息 - MultiDelayMessage msg = new MultiDelayMessage<>(orderId, - 10000L, 10000L, 10000L, 15000L, 15000L, 30000L, 30000L, 60000L, 60000L, 120000L, 300000L, 600000L, 600000L); - // 10000L, 10000L, 10000L, 15000L, 15000L, 30000L, 30000L, 60000L, 60000L, 120000L, 300000L, 600000L, 600000L + MultiDelayMessage msg = new MultiDelayMessage<>(orderId, newDelayMillis); int delayValue = msg.removeNextDelay().intValue(); rabbitTemplate.convertAndSend(MqConstant.DELAY_EXCHANGE, MqConstant.DELAY_ADVANCE_ROUTING_KEY, msg, message -> { diff --git a/src/main/java/com/cultural/heritage/service/order/impl/OrderServiceImpl.java b/src/main/java/com/cultural/heritage/service/order/impl/OrderServiceImpl.java index 2a31dc0..9d1e4ac 100644 --- a/src/main/java/com/cultural/heritage/service/order/impl/OrderServiceImpl.java +++ b/src/main/java/com/cultural/heritage/service/order/impl/OrderServiceImpl.java @@ -426,10 +426,10 @@ public class OrderServiceImpl extends ServiceImpl implements */ @Override public void sendCreateOrderMessage(Long orderId) { + // 复制 DELAY_MILLIS 到一个新的 ArrayList + List newDelayMillis = new ArrayList<>(MqConstant.DELAY_MILLIS); // 延迟检查订单状态信息 - MultiDelayMessage msg = new MultiDelayMessage<>(orderId, - 10000L, 10000L, 10000L, 15000L, 15000L, 30000L, 30000L, 60000L, 60000L, 120000L, 300000L, 600000L, 600000L); - // 10000L, 10000L, 10000L, 15000L, 15000L, 30000L, 30000L, 60000L, 60000L, 120000L, 300000L, 600000L, 600000L + MultiDelayMessage msg = new MultiDelayMessage<>(orderId, newDelayMillis); int delayValue = msg.removeNextDelay().intValue(); rabbitTemplate.convertAndSend(MqConstant.DELAY_EXCHANGE, MqConstant.DELAY_ORDER_ROUTING_KEY, msg, message -> {