提交代码

dev-discount
胡锐 2 years ago
parent 5955bec57a
commit ea723f08f0
  1. 30
      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;
import com.hai.entity.HighDiscountAgentCode;
import com.hai.entity.HighDiscountUserRel;
import com.hai.entity.HighOrder;
import com.hai.entity.HighOrderRefund;
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.OrderStatus;
import com.hai.service.BsMsgService;
import com.hai.service.HighDiscountAgentCodeService;
import com.hai.service.HighDiscountUserRelService;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.math.BigDecimal;
@Component
@Slf4j
@ -26,15 +31,36 @@ public class OrderRefundSuccessConsumer implements RocketMQListener<HighOrderRef
@Resource
private OrderRefundService orderRefundService;
@Resource
private OrderRefundHandleService refundHandleService;
@Resource
private HighDiscountUserRelService discountUserRelService;
@Resource
private HighDiscountAgentCodeService discountAgentCodeService;
@Resource
private BsMsgService bsMsgService;
@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())) {
refundHandleService.couponHandle(orderRefund);

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

Loading…
Cancel
Save