From 288e2a2ca2e7c2f7158507174a42f8a417380d23 Mon Sep 17 00:00:00 2001
From: KKSU <15274802129@163.com>
Date: Tue, 17 Dec 2024 18:03:35 +0800
Subject: [PATCH] feat(mall): 实现 VIP购买功能

---
 src/main/java/cc/mrbird/febs/rabbit/producter/AgentProducer.java |   76 +++++++++++--------------------------
 1 files changed, 23 insertions(+), 53 deletions(-)

diff --git a/src/main/java/cc/mrbird/febs/rabbit/producter/AgentProducer.java b/src/main/java/cc/mrbird/febs/rabbit/producter/AgentProducer.java
index 501fdbb..99a93d4 100644
--- a/src/main/java/cc/mrbird/febs/rabbit/producter/AgentProducer.java
+++ b/src/main/java/cc/mrbird/febs/rabbit/producter/AgentProducer.java
@@ -1,8 +1,8 @@
 package cc.mrbird.febs.rabbit.producter;
 
-import cc.mrbird.febs.rabbit.constants.ExchangeConstants;
-import cc.mrbird.febs.rabbit.constants.RouteKeyConstants;
+import cc.mrbird.febs.mall.dto.ApiMemberChargeFailDto;
 import cc.mrbird.febs.rabbit.enumerates.RabbitQueueEnum;
+import com.alibaba.fastjson.JSON;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.amqp.AmqpException;
 import org.springframework.amqp.core.Message;
@@ -11,10 +11,6 @@
 import org.springframework.amqp.rabbit.core.RabbitTemplate;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
-
-import javax.validation.constraints.NotNull;
-import java.util.Date;
-import java.util.UUID;
 
 /**
  * @author wzy
@@ -45,56 +41,30 @@
 
     }
 
-    public void sendOrderReturn(Long id) {
-        log.info("发送消息:{}", id);
-        CorrelationData correlationData = new CorrelationData(UUID.randomUUID().toString());
-        rabbitTemplate.convertAndSend(RabbitQueueEnum.ORDER_RETURN_MONEY.getExchange(), RabbitQueueEnum.ORDER_RETURN_MONEY.getRoute(), id, correlationData);
-    }
-
-    public void sendOrderCancelDelayMsg(Long id, Long times) {
-        log.info("发送自动取消订单消息:{}, {}", id, times);
-        rabbitTemplate.convertAndSend(RabbitQueueEnum.ORDER_CANCEL_DELAY_TTL.getExchange(), RabbitQueueEnum.ORDER_CANCEL_DELAY_TTL.getRoute(), id, new MessagePostProcessor() {
-            @Override
-            public Message postProcessMessage(Message message) throws AmqpException {
-                message.getMessageProperties().setExpiration(String.valueOf(times));
-                return message;
-            }
-        });
-    }
-
     /**
-     * 发送代理自动升级消息
-     *
-     * @param memberId
+     * 购买VIP自动过期
+     * @param apiMemberChargeFailDto
      */
-    public void sendAutoLevelUpMsg(@NotNull Long memberId) {
-        log.info("发送代理自动升级消息:{}", memberId);
-        rabbitTemplate.convertAndSend(ExchangeConstants.EXCHANGE_DEFAULT, RouteKeyConstants.ROUTE_KEY_DEFAULT, memberId);
+    public void sendMemberChargeFailMsg(ApiMemberChargeFailDto apiMemberChargeFailDto) {
+        log.info("发送购买VIP自动过期: {}", JSON.toJSONString(apiMemberChargeFailDto));
+        rabbitTemplate.convertAndSend(
+                RabbitQueueEnum.RUN_VIP_OPERATION_CHARGE_FAIL_TTL.getExchange(),
+                RabbitQueueEnum.RUN_VIP_OPERATION_CHARGE_FAIL_TTL.getRoute(),
+                apiMemberChargeFailDto,
+                new MessagePostProcessor() {
+                    @Override
+                    public Message postProcessMessage(Message message) throws AmqpException {
+                        message.getMessageProperties().setExpiration(String.valueOf(apiMemberChargeFailDto.getFailTime()));
+                        return message;
+                    }
+                });
     }
 
-    public void sendReturnMoneyMsg(Long orderId) {
-        log.info("发送返利消息:{}", orderId);
-        rabbitTemplate.convertAndSend(RabbitQueueEnum.AGENT_REUTRN_MONEY.getExchange(), RabbitQueueEnum.AGENT_REUTRN_MONEY.getRoute(), orderId);
-    }
-
-
-    public void sendOrderCoupon(Long id) {
-        log.info("发送使用优惠卷消息:{}", id);
-        CorrelationData correlationData = new CorrelationData(UUID.randomUUID().toString());
-        rabbitTemplate.convertAndSend(RabbitQueueEnum.ORDER_COUPON.getExchange(), RabbitQueueEnum.ORDER_COUPON.getRoute(), id, correlationData);
-    }
-
-    public void sendGetScoreMsg(Long orderId) {
-        log.info("发送获得积分消息:{}", orderId);
-
-        CorrelationData correlationData = new CorrelationData(UUID.randomUUID().toString());
-        rabbitTemplate.convertAndSend(RabbitQueueEnum.GET_SCORE_MSG.getExchange(), RabbitQueueEnum.GET_SCORE_MSG.getRoute(), orderId, correlationData);
-    }
-
-    public void sendVipLevelUp(Long orderId) {
-        log.info("发送会员升级消息:{}", orderId);
-
-        CorrelationData correlationData = new CorrelationData(UUID.randomUUID().toString());
-        rabbitTemplate.convertAndSend(RabbitQueueEnum.VIP_LEVEL_UP.getExchange(), RabbitQueueEnum.VIP_LEVEL_UP.getRoute(), orderId, correlationData);
+    public void sendBuyVipSuccessMsg(Long id) {
+        log.info("发送购买成功消息:{}",id);
+        rabbitTemplate.convertAndSend(
+                RabbitQueueEnum.RUN_VIP_OPERATION_CHARGE.getExchange(),
+                RabbitQueueEnum.RUN_VIP_OPERATION_CHARGE.getRoute(),
+                id);
     }
 }

--
Gitblit v1.9.1