提交代码

dev-discount
胡锐 2 years ago
parent 5955bec57a
commit ea723f08f0
  1. 28
      hai-order/src/main/java/com/web/rocketmq/consumer/OrderRefundSuccessConsumer.java
  2. 1
      hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java

@ -1,5 +1,7 @@
package com.web.rocketmq.consumer; package com.web.rocketmq.consumer;
import com.hai.entity.HighDiscountAgentCode;
import com.hai.entity.HighDiscountUserRel;
import com.hai.entity.HighOrder; import com.hai.entity.HighOrder;
import com.hai.entity.HighOrderRefund; import com.hai.entity.HighOrderRefund;
import com.hai.order.service.OrderRefundHandleService; import com.hai.order.service.OrderRefundHandleService;
@ -9,12 +11,15 @@ import com.hai.order.type.OrderChildGoodsType;
import com.hai.order.type.OrderProductType; import com.hai.order.type.OrderProductType;
import com.hai.order.type.OrderStatus; import com.hai.order.type.OrderStatus;
import com.hai.service.BsMsgService; import com.hai.service.BsMsgService;
import com.hai.service.HighDiscountAgentCodeService;
import com.hai.service.HighDiscountUserRelService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener; import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener; import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal;
@Component @Component
@Slf4j @Slf4j
@ -26,16 +31,37 @@ public class OrderRefundSuccessConsumer implements RocketMQListener<HighOrderRef
@Resource @Resource
private OrderRefundService orderRefundService; private OrderRefundService orderRefundService;
@Resource @Resource
private OrderRefundHandleService refundHandleService; private OrderRefundHandleService refundHandleService;
@Resource
private HighDiscountUserRelService discountUserRelService;
@Resource
private HighDiscountAgentCodeService discountAgentCodeService;
@Resource @Resource
private BsMsgService bsMsgService; private BsMsgService bsMsgService;
@Override @Override
public void onMessage(HighOrderRefund orderRefund) { public void onMessage(HighOrderRefund orderRefund) {
// 交易订单
HighOrder order = orderService.getOrderDetailByNo(orderRefund.getOrderNo());
if (order != null && order.getMemDiscountId() != null) {
// 交易订单可退金额为0,才会退还优惠券
if (order.getSurplusRefundIntegral() == 0 && order.getSurplusRefundPrice().compareTo(new BigDecimal("0")) == 0) {
HighDiscountUserRel rel = discountUserRelService.getRelById(order.getMemDiscountId());
if (rel != null) {
rel.setStatus(1); // 状态 0:已过期 1:未使用 2:已使用
rel.setUseTime(null);
discountUserRelService.updateDiscountUserRel(rel);
HighDiscountAgentCode code = discountAgentCodeService.getCodeById(rel.getDiscountAgentCodeId());
code.setStatus(2);
discountAgentCodeService.updateCode(code);
}
}
}
if (orderRefund.getGoodsType().equals(OrderChildGoodsType.TYPE1.getNumber())) { if (orderRefund.getGoodsType().equals(OrderChildGoodsType.TYPE1.getNumber())) {
refundHandleService.couponHandle(orderRefund); refundHandleService.couponHandle(orderRefund);

@ -581,7 +581,6 @@ public class OrderServiceImpl implements OrderService {
rocketMQTemplate.syncSend(OrderTopic.ORDER_TOPIC_REFUND_SUCCESS.getTopic(), orderRefund); rocketMQTemplate.syncSend(OrderTopic.ORDER_TOPIC_REFUND_SUCCESS.getTopic(), orderRefund);
} }
return updateOrderData(order); return updateOrderData(order);
} }

Loading…
Cancel
Save