From 30d8e227e8d823b6c38c3b9c90ac2df03b63befe Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 25 二月 2025 16:41:22 +0800 Subject: [PATCH] 淘宝转链接口更新 --- fanli/src/main/java/com/yeshi/fanli/util/rocketmq/consumer/user/TearcherMessageListener.java | 214 ++++++++++++++++++++++++++-------------------------- 1 files changed, 107 insertions(+), 107 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/util/rocketmq/consumer/user/TearcherMessageListener.java b/fanli/src/main/java/com/yeshi/fanli/util/rocketmq/consumer/user/TearcherMessageListener.java index 5bccc82..22abae3 100644 --- a/fanli/src/main/java/com/yeshi/fanli/util/rocketmq/consumer/user/TearcherMessageListener.java +++ b/fanli/src/main/java/com/yeshi/fanli/util/rocketmq/consumer/user/TearcherMessageListener.java @@ -1,107 +1,107 @@ -package com.yeshi.fanli.util.rocketmq.consumer.user; - -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -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.user.UserTopicTagEnum; -import com.yeshi.fanli.dto.mq.user.body.InviteCodeActiveMQMsg; -import com.yeshi.fanli.dto.mq.user.body.UserActiveMQMsg; -import com.yeshi.fanli.entity.bus.user.UserInfo; -import com.yeshi.fanli.entity.bus.user.vip.TearcherInfo; -import com.yeshi.fanli.log.LogHelper; -import com.yeshi.fanli.service.inter.user.UserInfoService; -import com.yeshi.fanli.service.inter.user.invite.ThreeSaleSerivce; -import com.yeshi.fanli.service.inter.user.vip.TearcherService; -import com.yeshi.fanli.util.rocketmq.MQTopicName; - -import net.sf.json.JSONObject; - -/** - * 鐢ㄦ埛瓒呯骇浼氬憳 - * - * @author Administrator - * - */ -@Component -public class TearcherMessageListener implements MessageListener { - - @Resource - private ThreeSaleSerivce threeSaleSerivce; - - @Resource - private TearcherService tearcherService; - - @Resource - private UserInfoService userInfoService; - - private static Set<Long> officialUids = null; - - @Override - public Action consume(Message message, ConsumeContext context) { - LogHelper.mqInfo("consumer-TearcherMessageListener", message.getMsgID(), message.getTopic(), message.getTag(), - new String(message.getBody())); - String tag = message.getTag(); - if (tag == null) - tag = ""; - String topic = message.getTopic(); - - if (MQTopicName.TOPIC_USER.name().equalsIgnoreCase(topic)) { - - // 閭�璇锋縺娲� - if (tag.equalsIgnoreCase(UserTopicTagEnum.inviteCodeActive.name())) { - - JSONObject json = JSONObject.fromObject(new String(message.getBody())); - - InviteCodeActiveMQMsg inviteCodeActiveMQMsg = new Gson().fromJson(json.toString(), - InviteCodeActiveMQMsg.class); - if (inviteCodeActiveMQMsg != null) { - // 椤剁骇涓烘祴璇曠敤鎴风殑鍏ㄩ儴鍒嗛厤瀹樻柟瀵煎笀寰俊 - initTearcher(inviteCodeActiveMQMsg.getUid()); - } - } else if (tag.equalsIgnoreCase(UserTopicTagEnum.userActve.name())) { - UserActiveMQMsg userActiveMQMsg = new Gson().fromJson(new String(message.getBody()), - UserActiveMQMsg.class); - if (userActiveMQMsg != null) { - initTearcher(userActiveMQMsg.getUid()); - } - } - } - - return Action.CommitMessage; - } - - private void initTearcher(Long uid) { - if (tearcherService.selectByUid(uid) != null) - return; - - // 鑾峰彇椤剁骇boss - Long bossId = threeSaleSerivce.getTopBoss(uid); - if (bossId != null) { - - if (officialUids == null) { - officialUids = new HashSet<>(); - List<UserInfo> userList = userInfoService.listByType(1, 1, 10000); - - for (UserInfo user : userList) - officialUids.add(user.getId()); - } - - if (officialUids.contains(bossId)) { - List<TearcherInfo> tearcherList = tearcherService.listByType(TearcherInfo.TYPE_OFFICIAL, 1, 1); - if (tearcherList != null && tearcherList.size() > 0) { - tearcherService.addUserTearcherMap(tearcherList.get(0).getId(), uid); - } - } - } - } -} +package com.yeshi.fanli.util.rocketmq.consumer.user; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +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.user.UserTopicTagEnum; +import com.yeshi.fanli.dto.mq.user.body.InviteCodeActiveMQMsg; +import com.yeshi.fanli.dto.mq.user.body.UserActiveMQMsg; +import com.yeshi.fanli.entity.bus.user.UserInfo; +import com.yeshi.fanli.entity.bus.user.vip.TearcherInfo; +import com.yeshi.fanli.log.LogHelper; +import com.yeshi.fanli.service.inter.user.UserInfoService; +import com.yeshi.fanli.service.inter.user.invite.ThreeSaleSerivce; +import com.yeshi.fanli.service.inter.user.vip.TearcherService; +import com.yeshi.fanli.util.rocketmq.MQTopicName; + +import net.sf.json.JSONObject; + +/** + * 鐢ㄦ埛瓒呯骇浼氬憳 + * + * @author Administrator + * + */ +@Component +public class TearcherMessageListener implements MessageListener { + + @Resource + private ThreeSaleSerivce threeSaleSerivce; + + @Resource + private TearcherService tearcherService; + + @Resource + private UserInfoService userInfoService; + + private static Set<Long> officialUids = null; + + @Override + public Action consume(Message message, ConsumeContext context) { + LogHelper.mqInfo("consumer-TearcherMessageListener", message.getMsgID(), message.getTopic(), message.getTag(), + new String(message.getBody())); + String tag = message.getTag(); + if (tag == null) + tag = ""; + String topic = message.getTopic(); + + if (MQTopicName.TOPIC_USER.name().equalsIgnoreCase(topic)) { + + // 閭�璇锋縺娲� + if (tag.equalsIgnoreCase(UserTopicTagEnum.inviteCodeActive.name())) { + + JSONObject json = JSONObject.fromObject(new String(message.getBody())); + + InviteCodeActiveMQMsg inviteCodeActiveMQMsg = new Gson().fromJson(json.toString(), + InviteCodeActiveMQMsg.class); + if (inviteCodeActiveMQMsg != null) { + // 椤剁骇涓烘祴璇曠敤鎴风殑鍏ㄩ儴鍒嗛厤瀹樻柟瀵煎笀寰俊 + initTearcher(inviteCodeActiveMQMsg.getUid()); + } + } else if (tag.equalsIgnoreCase(UserTopicTagEnum.userActve.name())) { + UserActiveMQMsg userActiveMQMsg = new Gson().fromJson(new String(message.getBody()), + UserActiveMQMsg.class); + if (userActiveMQMsg != null) { + initTearcher(userActiveMQMsg.getUid()); + } + } + } + + return Action.CommitMessage; + } + + private void initTearcher(Long uid) { + if (tearcherService.selectByUid(uid) != null) + return; + + // 鑾峰彇椤剁骇boss + Long bossId = threeSaleSerivce.getTopBoss(uid); + if (bossId != null) { + + if (officialUids == null) { + officialUids = new HashSet<>(); + List<UserInfo> userList = userInfoService.listByType(1, 1, 10000); + + for (UserInfo user : userList) + officialUids.add(user.getId()); + } + + if (officialUids.contains(bossId)) { + List<TearcherInfo> tearcherList = tearcherService.listByType(TearcherInfo.TYPE_OFFICIAL, 1, 1); + if (tearcherList != null && tearcherList.size() > 0) { + tearcherService.addUserTearcherMap(tearcherList.get(0).getId(), uid); + } + } + } + } +} -- Gitblit v1.8.0