admin
2020-03-19 0d91bad397c1a1b41bc77d9cd9f7555ed78f7f1a
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
package com.yeshi.fanli.util.rocketmq.consumer.user;
 
import javax.annotation.Resource;
 
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.dto.mq.user.UserTopicTagEnum;
import com.yeshi.fanli.dto.mq.user.body.UserInviteMQMsg;
import com.yeshi.fanli.exception.money.OrderMoneySettleException;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.inter.user.vip.UserVIPPreInfoService;
import com.yeshi.fanli.util.rocketmq.MQTopicName;
 
/**
 * 用户超级会员
 * 
 * @author Administrator
 *
 */
//@Component implements MessageListener
public class UserVIPMessageListener  {
 
    @Resource
    private UserVIPPreInfoService userVIPPreInfoService;
 
//    @Override
//    public Action consume(Message message, ConsumeContext context) {
//        
//        LogHelper.mqInfo("consumer-UserVIPMessageListener", message.getMsgID(), message.getTopic(),
//                message.getTag(), new String(message.getBody()));
//        String tag = message.getTag();
//        if (tag == null)
//            tag = "";
//
//        // 邀请相关
//        if (MQTopicName.TOPIC_USER.name().equalsIgnoreCase(message.getTopic())) {
//            // 邀请成功
//            if (tag.equalsIgnoreCase(UserTopicTagEnum.inviteSuccess.name())) {
//                UserInviteMQMsg msg = new Gson().fromJson(new String(message.getBody()),UserInviteMQMsg.class);
//                // 会员等级升级
//                userVIPPreInfoService.verifyVipPreInfo(msg.getBossId(), true);
//            }
//        }
//        
//        // 订单到账相关
//        if (tag.equalsIgnoreCase(OrderTopicTagEnum.orderFanLiActual.name())) {
//            OrderMoneyRecievedMQMsg dto = new Gson().fromJson(new String(message.getBody()),
//                    OrderMoneyRecievedMQMsg.class);
//            if (dto != null) {
//                if (dto.getType() == OrderMoneyRecievedMQMsg.TYPE_ZIGOU) {// 自购到账
//                    // 会员等级升级
//                    userVIPPreInfoService.verifyVipPreInfo(dto.getUid(), false);
//                } else if (dto.getType() == OrderMoneyRecievedMQMsg.TYPE_SHARE) {// 分享到账
//                    // 会员等级升级
//                    userVIPPreInfoService.verifyVipPreInfo(dto.getUid(), false);
//                }
//            }
//        }
//        
//        return Action.CommitMessage;
//    }
}