From 78bbc1dae1bb20acb51fd454adf53b3ab5ae97b3 Mon Sep 17 00:00:00 2001 From: xiaoyong931011 <15274802129@163.com> Date: Fri, 23 Dec 2022 15:20:11 +0800 Subject: [PATCH] 20221221 --- src/main/java/cc/mrbird/febs/rabbit/producter/AgentProducer.java | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 42 insertions(+), 1 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 8e4f150..2bef42e 100644 --- a/src/main/java/cc/mrbird/febs/rabbit/producter/AgentProducer.java +++ b/src/main/java/cc/mrbird/febs/rabbit/producter/AgentProducer.java @@ -2,12 +2,18 @@ import cc.mrbird.febs.rabbit.constants.ExchangeConstants; import cc.mrbird.febs.rabbit.constants.RouteKeyConstants; +import cc.mrbird.febs.rabbit.enumerates.RabbitQueueEnum; import lombok.extern.slf4j.Slf4j; +import org.springframework.amqp.AmqpException; +import org.springframework.amqp.core.Message; +import org.springframework.amqp.core.MessagePostProcessor; import org.springframework.amqp.rabbit.connection.CorrelationData; 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; /** @@ -42,6 +48,41 @@ public void sendOrderReturn(Long id) { log.info("发送消息:{}", id); CorrelationData correlationData = new CorrelationData(UUID.randomUUID().toString()); - rabbitTemplate.convertAndSend(ExchangeConstants.EXCHANGE_DEFAULT, RouteKeyConstants.ROUTE_KEY_DEFAULT, id, correlationData); + 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 + */ + public void sendAutoLevelUpMsg(@NotNull Long memberId) { + log.info("发送代理自动升级消息:{}", memberId); + rabbitTemplate.convertAndSend(ExchangeConstants.EXCHANGE_DEFAULT, RouteKeyConstants.ROUTE_KEY_DEFAULT, memberId); + } + + public void sendReturnMoneyMsg(Long orderId) { + log.info("发送返利消息:{}", orderId); + rabbitTemplate.convertAndSend(RabbitQueueEnum.AGENT_REUTRN_MONEY.getExchange(), RabbitQueueEnum.AGENT_REUTRN_MONEY.getRoute(), orderId); + } + + /** + * 发送直推奖励消息 + * @param directRewardId 订单ID + */ + public void sendDirectRewardMsg(@NotNull Long directRewardId) { + log.info("发送补贴奖励、直推返利、分享奖励直推上级、分享奖励直推上级的直推、团队管理补贴消息:{}", directRewardId); + rabbitTemplate.convertAndSend(RabbitQueueEnum.MALL_COIN_DIRECT_REWARD.getExchange(), RabbitQueueEnum.MALL_COIN_DIRECT_REWARD.getRoute(), directRewardId); } } -- Gitblit v1.9.1