KKSU
2024-03-22 2c7890dc25f0cf08b30663eb6c91f83ff29ac24b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
package cc.mrbird.febs.rabbit.consumer;
 
import cc.mrbird.febs.mall.service.IAgentService;
import cc.mrbird.febs.mall.service.IApiMallOrderInfoService;
import cc.mrbird.febs.mall.service.IMemberProfitService;
import cc.mrbird.febs.rabbit.constants.QueueConstants;
import cc.mrbird.febs.rabbit.enumerates.RabbitQueueEnum;
import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
 
import java.util.Date;
 
/**
 * @author wzy
 * @date 2021-09-25
 **/
@Slf4j
@Component
public class AgentConsumer {
 
    @Autowired
    private IApiMallOrderInfoService orderInfoService;
    @Autowired
    private IAgentService agentService;
    @Autowired
    private IMemberProfitService memberProfitService;
 
    @RabbitListener(queues = QueueConstants.QUEUE_DEFAULT)
    public void agentReturn(Message message, Channel channel) {
        log.info("消费者:{}", new String(message.getBody()));
    }
 
    @RabbitListener(queues = "hlm_queue_order_delay")
    public void orderCancelDelay(String id) {
        try {
            orderInfoService.autoCancelOrder(Long.parseLong(id));
        } catch (Exception e) {
            log.error("订单超时支付异常", e);
        }
    }
 
    @RabbitListener(queues = QueueConstants.AGENT_AUTO_LEVEL_UP)
    public void agentAutoLevelUp(String id) {
        log.info("收到合伙人自动升级消息:{}", id);
        try {
            agentService.autoUpAgentLevel(Long.parseLong(id));
        } catch (Exception e) {
            log.error("合伙人自动升级异常", e);
        }
    }
 
    @RabbitListener(queues = QueueConstants.AGENT_RETURN_MONEY)
    public void agentReturnMoney(String orderId) {
        log.info("收到返利消息:{}", orderId);
        try {
            agentService.returnMoneyToAgent(Long.parseLong(orderId));
        } catch (Exception e) {
            log.error("返利异常", e);
        }
    }
 
    @RabbitListener(queues = QueueConstants.ORDER_RETURN_MONEY)
    public void orderReturnMoney(String orderId) {
        log.info("收到订单返利消息:{}", orderId);
        try {
            memberProfitService.dynamicProfit(Long.parseLong(orderId));
        } catch (Exception e) {
            log.error("订单返利异常:", e);
        }
    }
 
    @RabbitListener(queues = QueueConstants.PERK_MONEY)
    public void perkMoneyConsumer(String id) {
        log.info("收到补贴消息:{}", id);
        try {
            agentService.perkMoneyConsumer(Long.parseLong(id));
        } catch (Exception e) {
            log.error("用户补贴异常", e);
            // todo 更新表
 
        }
    }
 
    @RabbitListener(queues = QueueConstants.FORCE_VOUCHER_SALE)
    public void forceVoucherSaleConsumer(String price) {
        log.info("收到强制卖出消息,价格:{}",price);
        try {
            memberProfitService.selaHalfVoucher(price);
        } catch (Exception e) {
            log.error("强制卖出异常", e);
            // todo 更新表
 
        }
    }
 
    @RabbitListener(queues = QueueConstants.QUEUE_FCM_NFT_EXCHANGE)
    public void fcmNFTExchangeMsg(String cnt) {
        log.info("收到FCM实时兑换销毁数量:{}",cnt);
        try {
            memberProfitService.fcmNFTExchangeMsg(cnt);
        } catch (Exception e) {
            log.error("收到FCM实时兑换销毁数量异常", e);
            // todo 更新表
 
        }
    }
 
    @RabbitListener(queues = QueueConstants.QUEUE_FCM_ORDER_SELL_INSURE)
    public void fcmOrderSellInsureMsg(Long sellRecordId) {
        log.info("收到卖单用户确认:{}",sellRecordId);
        try {
            memberProfitService.fcmOrderSellInsureMsg(sellRecordId);
        } catch (Exception e) {
            log.error("收到卖单用户确认异常", e);
            // todo 更新表
 
        }
    }
 
    @RabbitListener(queues = QueueConstants.QUEUE_FCM_ORDER_BUY_CANCEL)
    public void fcmOrderBuyCancelMsg(Long buyRecordId) {
        log.info("收到买单取消确认:{}",buyRecordId);
        try {
            memberProfitService.fcmOrderBuyCancelMsg(buyRecordId);
        } catch (Exception e) {
            log.error("收到买单取消确认异常", e);
            // todo 更新表
 
        }
    }
 
    @RabbitListener(queues = QueueConstants.QUEUE_FCMPAY_BUY_TIME)
    public void fcmPayBuyTimeTTLMsg(Long id) {
        try {
            orderInfoService.fcmPayBuyTimeTTLMsg(id);
        } catch (Exception e) {
            log.error("订单待收款异常", e);
        }
    }
}