更新了写真预约特殊产品处理

This commit is contained in:
chen-xin-zhi 2025-03-05 14:58:29 +08:00
parent aa07af3513
commit 626da3f5b7
3 changed files with 28 additions and 33 deletions

View File

@ -54,7 +54,7 @@ public class CouponStatusListener {
// 发送延时消息 // 发送延时消息
int delayValue = msg.removeNextDelay().intValue(); int delayValue = msg.removeNextDelay().intValue();
rabbitTemplate.convertAndSend(MqConstant.DELAY_EXCHANGE, rabbitTemplate.convertAndSend(MqConstant.DELAY_EXCHANGE,
MqConstant.DELAY_ORDER_ROUTING_KEY, msg, message -> { MqConstant.DELAY_COUPON_ROUTING_KEY, msg, message -> {
// 添加延迟消息属性 // 添加延迟消息属性
message.getMessageProperties().setDelay(delayValue * 1000); message.getMessageProperties().setDelay(delayValue * 1000);
return message; return message;

View File

@ -1,14 +1,8 @@
package com.cultural.heritage.listener; package com.cultural.heritage.listener;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.cultural.heritage.common.ErrorCode;
import com.cultural.heritage.constant.MqConstant; import com.cultural.heritage.constant.MqConstant;
import com.cultural.heritage.constant.OrderStatusConstant; 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.Order;
import com.cultural.heritage.model.entity.PendingServiceOrder;
import com.cultural.heritage.model.entity.UserCoupon;
import com.cultural.heritage.service.common.CommonService; import com.cultural.heritage.service.common.CommonService;
import com.cultural.heritage.service.good.UserCouponService; import com.cultural.heritage.service.good.UserCouponService;
import com.cultural.heritage.service.order.OrderService; import com.cultural.heritage.service.order.OrderService;
@ -75,31 +69,32 @@ public class OrderStatusListener {
}); });
return ; return ;
} }
// 没有剩余延时时间说明订单超时未支付需取消订单 // // 没有剩余延时时间说明订单超时未支付需取消订单
UpdateWrapper<Order> updateWrapper = new UpdateWrapper<>(); // UpdateWrapper<Order> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("id", orderId).set("orderStatus", OrderStatusConstant.TRANSACTION_CLOSED); // updateWrapper.eq("id", orderId).set("orderStatus", OrderStatusConstant.TRANSACTION_CLOSED);
boolean update = orderService.update(updateWrapper); // boolean update = orderService.update(updateWrapper);
ThrowUtils.throwIf(!update, ErrorCode.OPERATION_ERROR, "订单状态更新失败"); // ThrowUtils.throwIf(!update, ErrorCode.OPERATION_ERROR, "订单状态更新失败");
//
// 如果使用了优惠券则退还优惠券 // // 如果使用了优惠券则退还优惠券
CouponSnapshot couponSnapshot = order.getCouponSnapshot(); // CouponSnapshot couponSnapshot = order.getCouponSnapshot();
if (couponSnapshot != null) { // if (couponSnapshot != null) {
Long userCouponId = couponSnapshot.getId(); // Long userCouponId = couponSnapshot.getId();
UserCoupon userCoupon = userCouponService.getById(userCouponId); // UserCoupon userCoupon = userCouponService.getById(userCouponId);
ThrowUtils.throwIf(userCoupon == null, ErrorCode.OPERATION_ERROR, "优惠券不存在"); // ThrowUtils.throwIf(userCoupon == null, ErrorCode.OPERATION_ERROR, "优惠券不存在");
// 更新优惠券状态 // // 更新优惠券状态
userCoupon.setIsUsed(0); // userCoupon.setIsUsed(0);
boolean result = userCouponService.updateById(userCoupon); // boolean result = userCouponService.updateById(userCoupon);
ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "优惠券状态更新失败"); // ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "优惠券状态更新失败");
} // }
//
boolean isGeneral = orderService.isGeneralGood(order.getOrderType()); // boolean isGeneral = orderService.isGeneralGood(order.getOrderType());
if (!isGeneral) { // if (!isGeneral) {
UpdateWrapper<PendingServiceOrder> pendingServiceOrderUpdateWrapper = new UpdateWrapper<>(); // System.out.println("=========================================>" + order.getOrderNumber());
pendingServiceOrderUpdateWrapper.eq("orderNumber", order.getOrderNumber()).set("orderItemStatus", OrderStatusConstant.TRANSACTION_CLOSED); // UpdateWrapper<PendingServiceOrder> pendingServiceOrderUpdateWrapper = new UpdateWrapper<>();
boolean updateBatch = orderService.update(updateWrapper); // pendingServiceOrderUpdateWrapper.eq("orderNumber", order.getOrderNumber()).set("orderItemStatus", OrderStatusConstant.TRANSACTION_CLOSED);
ThrowUtils.throwIf(!updateBatch, ErrorCode.OPERATION_ERROR, "订单状态批量更新失败"); // boolean updateBatch = pendingServiceOrderService.update(pendingServiceOrderUpdateWrapper);
} // ThrowUtils.throwIf(!updateBatch, ErrorCode.OPERATION_ERROR, "订单状态批量更新失败");
// }
} }

View File

@ -43,7 +43,7 @@ public class UserCouponStatusListener {
// 发送延时消息 // 发送延时消息
int delayValue = msg.removeNextDelay().intValue(); int delayValue = msg.removeNextDelay().intValue();
rabbitTemplate.convertAndSend(MqConstant.DELAY_EXCHANGE, rabbitTemplate.convertAndSend(MqConstant.DELAY_EXCHANGE,
MqConstant.DELAY_ORDER_ROUTING_KEY, msg, message -> { MqConstant.DELAY_USER_COUPON_ROUTING_KEY, msg, message -> {
// 添加延迟消息属性 // 添加延迟消息属性
message.getMessageProperties().setDelay(delayValue * 1000); message.getMessageProperties().setDelay(delayValue * 1000);
return message; return message;