|
|
|
@ -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); |
|
|
|
|