admin
2019-11-23 486e22c57ca8a1e2dc6877b539e2f3add67250f1
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
package com.yeshi.fanli.util.rocketmq.consumer.integral;
 
import org.springframework.stereotype.Component;
 
import com.aliyun.openservices.ons.api.Action;
import com.aliyun.openservices.ons.api.ConsumeContext;
import com.aliyun.openservices.ons.api.Message;
import com.aliyun.openservices.ons.api.MessageListener;
import com.google.gson.Gson;
import com.yeshi.fanli.dto.mq.order.OrderTopicTagEnum;
import com.yeshi.fanli.dto.mq.order.body.OrderMoneyRecievedMQMsg;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.util.rocketmq.MQTopicName;
 
/**
 * 金币消息监听
 * 
 * @author Administrator
 *
 */
@Component
public class IntegralMessageListener implements MessageListener {
    public IntegralMessageListener() {
 
    }
 
    @Override
    public Action consume(Message message, ConsumeContext context) {
 
        LogHelper.mqInfo("consumer:IntegralMessageListener", message.getMsgID(), message.getTopic(), message.getTag(),
                new String(message.getBody()));
        String tag = message.getTag();
 
        if (MQTopicName.TOPIC_ORDER.name().equalsIgnoreCase(message.getTopic())) {
            if (OrderTopicTagEnum.orderFanLiActual.name().equalsIgnoreCase(tag)) {// 实时到账
                OrderMoneyRecievedMQMsg msg = new Gson().fromJson(new String(message.getBody()),
                        OrderMoneyRecievedMQMsg.class);
                if (msg != null && msg.getType() == OrderMoneyRecievedMQMsg.TYPE_ZIGOU) {// 自购到账
                    // 得金币
                } else if (msg != null && msg.getType() == OrderMoneyRecievedMQMsg.TYPE_SHARE) {// 分享订单
 
                } else if (msg != null && msg.getType() == OrderMoneyRecievedMQMsg.TYPE_INVITE) {// 邀请订单
 
                }
                return Action.CommitMessage;
            }
        }
        return Action.CommitMessage;
    }
 
}