From 2f5935ed11672046c37f733d855214f6147b4b58 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期一, 28 三月 2022 11:33:19 +0800
Subject: [PATCH] TDMQ兼容
---
fanli/src/main/java/com/yeshi/fanli/util/rocketmq/consumer/user/UserTeamMessageListener.java | 262 +++++++++++++++++++++++++++++++---------------------
1 files changed, 155 insertions(+), 107 deletions(-)
diff --git a/fanli/src/main/java/com/yeshi/fanli/util/rocketmq/consumer/user/UserTeamMessageListener.java b/fanli/src/main/java/com/yeshi/fanli/util/rocketmq/consumer/user/UserTeamMessageListener.java
index 67f47ad..1e9e45d 100644
--- a/fanli/src/main/java/com/yeshi/fanli/util/rocketmq/consumer/user/UserTeamMessageListener.java
+++ b/fanli/src/main/java/com/yeshi/fanli/util/rocketmq/consumer/user/UserTeamMessageListener.java
@@ -1,107 +1,155 @@
-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.user.UserTopicTagEnum;
-import com.yeshi.fanli.dto.mq.user.body.BeComeValidUserMQMsg;
-import com.yeshi.fanli.dto.mq.user.body.TaoBaoBindSuccessMQMsg;
-import com.yeshi.fanli.dto.mq.user.body.UserActiveMQMsg;
-import com.yeshi.fanli.dto.mq.user.body.UserInfoUpdateMQMsg;
-import com.yeshi.fanli.dto.mq.user.body.UserInfoUpdateMQMsg.UserInfoUpdateTypeEnum;
-import com.yeshi.fanli.dto.mq.user.body.UserInviteMQMsg;
-import com.yeshi.fanli.dto.mq.user.body.UserMoneyChangeMQMsg;
-import com.yeshi.fanli.log.LogHelper;
-import com.yeshi.fanli.service.inter.user.invite.TeamFansInfoService;
-import com.yeshi.fanli.util.rocketmq.MQTopicName;
-
-import net.sf.json.JSONObject;
-
-/**
- * 鐢ㄦ埛绮変笣娑堟伅
- *
- * @author Administrator
- *
- */
-@Component
-public class UserTeamMessageListener implements MessageListener {
-
- @Resource
- private TeamFansInfoService teamFansInfoService;
-
-
- @Override
- public Action consume(Message message, ConsumeContext context) {
-
- LogHelper.mqInfo("consumer-UserTeamMessageListener", 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.userActve.name())) {// 鐢ㄦ埛娲昏穬
- JSONObject json = JSONObject.fromObject(new String(message.getBody()));
- UserActiveMQMsg userActiveMQMsg = new Gson().fromJson(json.toString(),UserActiveMQMsg.class);
- if (userActiveMQMsg != null) {
- // 鏇存敼鐢ㄦ埛娲昏穬鏃堕棿
- teamFansInfoService.updateActiveTime(userActiveMQMsg.getUid(), userActiveMQMsg.getCreateTime());
- }
- } else if (tag.equalsIgnoreCase(UserTopicTagEnum.userInfoUpdate.name())) {// 鐢ㄦ埛淇℃伅鏇存柊
- JSONObject json = JSONObject.fromObject(new String(message.getBody()));
- UserInfoUpdateMQMsg mqMsg = new Gson().fromJson(json.toString(),UserInfoUpdateMQMsg.class);
- if (mqMsg != null) {
- if (UserInfoUpdateTypeEnum.nickName == mqMsg.getType()) { // 鏇存敼鏄电О
- teamFansInfoService.updateNickName(mqMsg.getUid(), mqMsg.getValue());
- } else if (UserInfoUpdateTypeEnum.wxId == mqMsg.getType()) { // 寰俊鍙风粦瀹�
- teamFansInfoService.updateWeixinBind(mqMsg.getUid(), true);
- }
- }
- } else if (tag.equalsIgnoreCase(UserTopicTagEnum.taobaoBindSuccess.name())) {// 娣樺疂缁戝畾鎴愬姛
- // 鏇存敼娣樺疂缁戝畾鐘舵�佷笌鍘熺敤鎴锋窐瀹濈粦瀹氱姸鎬�
- JSONObject json = JSONObject.fromObject(new String(message.getBody()));
- TaoBaoBindSuccessMQMsg mqMsg = new Gson().fromJson(json.toString(),TaoBaoBindSuccessMQMsg.class);
- if (mqMsg != null) {
- // 鏇存柊娣樺疂缁戝畾
- teamFansInfoService.updateWeixinBind(mqMsg.getUid(), true);
- Long fromUid = mqMsg.getFromUid();
- if (fromUid != null) { // 娣樺疂琚В缁�
- teamFansInfoService.updateWeixinBind(fromUid, false);
- }
- }
- } else if (tag.equalsIgnoreCase(UserTopicTagEnum.inviteSuccess.name())) {// 閭�璇锋垚鍔�
- // 鏇存柊绮変笣鏁伴噺
- JSONObject json = JSONObject.fromObject(new String(message.getBody()));
- UserInviteMQMsg mqMsg = new Gson().fromJson(json.toString(),UserInviteMQMsg.class);
- if (mqMsg != null) {
- teamFansInfoService.updateFansNum(mqMsg.getBossId());
-
- }
- } else if (tag.equalsIgnoreCase(UserTopicTagEnum.userMoneyAdd.name())) {// 璧勯噾鍒拌处
- // 鏇存柊杩�60澶╁埌璐�
- JSONObject json = JSONObject.fromObject(new String(message.getBody()));
- UserMoneyChangeMQMsg mqMsg = new Gson().fromJson(json.toString(),UserMoneyChangeMQMsg.class);
- if (mqMsg != null) {
- teamFansInfoService.updateIncome(mqMsg.getUid(), mqMsg.getChangeMoney());
- }
- } else if (tag.equalsIgnoreCase(UserTopicTagEnum.becomeValidUser.name())) {// 鎴愪负鏈夋晥鐢ㄦ埛
- // 鏈夋晥鐢ㄦ埛鏍囪瘑
- JSONObject json = JSONObject.fromObject(new String(message.getBody()));
- BeComeValidUserMQMsg mqMsg = new Gson().fromJson(json.toString(),BeComeValidUserMQMsg.class);
- if (mqMsg != null) {
- // 鏇存柊鎴愪负鏈夋晥绮変笣
- teamFansInfoService.updateStateValid(mqMsg.getUid(), true);
- }
- }
- }
- return Action.CommitMessage;
- }
-}
+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.user.UserTopicTagEnum;
+import com.yeshi.fanli.dto.mq.user.body.BeComeValidUserMQMsg;
+import com.yeshi.fanli.dto.mq.user.body.TaoBaoBindSuccessMQMsg;
+import com.yeshi.fanli.dto.mq.user.body.UserAccountBindingMQMsg;
+import com.yeshi.fanli.dto.mq.user.body.UserActiveMQMsg;
+import com.yeshi.fanli.dto.mq.user.body.UserInfoUpdateMQMsg;
+import com.yeshi.fanli.dto.mq.user.body.UserInfoUpdateMQMsg.UserInfoUpdateTypeEnum;
+import com.yeshi.fanli.dto.mq.user.body.UserInviteMQMsg;
+import com.yeshi.fanli.dto.mq.user.body.UserLevelChangedMQMsg;
+import com.yeshi.fanli.dto.mq.user.body.UserMoneyChangeMQMsg;
+import com.yeshi.fanli.dto.mq.user.body.UserPhoneOpenMQMsg;
+import com.yeshi.fanli.entity.bus.user.ThreeSale;
+import com.yeshi.fanli.entity.bus.user.UserInfo;
+import com.yeshi.fanli.log.LogHelper;
+import com.yeshi.fanli.service.inter.user.invite.TeamFansInfoService;
+import com.yeshi.fanli.service.inter.user.invite.ThreeSaleDetailService;
+import com.yeshi.fanli.service.inter.user.invite.ThreeSaleSerivce;
+import com.yeshi.fanli.service.inter.user.vip.TeamUserLevelStatisticService;
+import com.yeshi.fanli.util.rocketmq.MQTopicName;
+
+import net.sf.json.JSONObject;
+
+/**
+ * 鐢ㄦ埛绮変笣娑堟伅
+ *
+ * @author Administrator
+ *
+ */
+@Component
+public class UserTeamMessageListener implements MessageListener {
+
+ @Resource
+ private TeamFansInfoService teamFansInfoService;
+
+ @Resource
+ private ThreeSaleDetailService threeSaleDetailService;
+
+ @Resource
+ private ThreeSaleSerivce threeSaleSerivce;
+
+ @Resource
+ private TeamUserLevelStatisticService teamUserLevelStatisticService;
+
+ @Override
+ public Action consume(Message message, ConsumeContext context) {
+
+ LogHelper.mqInfo("consumer-UserTeamMessageListener", 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.userActve.name())) {// 鐢ㄦ埛娲昏穬
+ JSONObject json = JSONObject.fromObject(new String(message.getBody()));
+ UserActiveMQMsg userActiveMQMsg = new Gson().fromJson(json.toString(), UserActiveMQMsg.class);
+ if (userActiveMQMsg != null) {
+ // 鏇存敼鐢ㄦ埛娲昏穬鏃堕棿
+ teamFansInfoService.updateActiveTime(userActiveMQMsg.getUid(), userActiveMQMsg.getCreateTime());
+ }
+ } else if (tag.equalsIgnoreCase(UserTopicTagEnum.userInfoUpdate.name())) {// 鐢ㄦ埛淇℃伅鏇存柊
+ JSONObject json = JSONObject.fromObject(new String(message.getBody()));
+ UserInfoUpdateMQMsg mqMsg = new Gson().fromJson(json.toString(), UserInfoUpdateMQMsg.class);
+ if (mqMsg != null) {
+ if (UserInfoUpdateTypeEnum.nickName == mqMsg.getType()) { // 鏇存敼鏄电О
+ teamFansInfoService.updateNickName(mqMsg.getUid(), mqMsg.getValue());
+ } else if (UserInfoUpdateTypeEnum.wxId == mqMsg.getType()) { // 寰俊鍙风粦瀹�
+ teamFansInfoService.updateWeixinId(mqMsg.getUid(), mqMsg.getValue());
+ } else if (UserInfoUpdateTypeEnum.inviteCode == mqMsg.getType()) { // 閭�璇风爜鏇存敼
+ teamFansInfoService.updateInviteCode(mqMsg.getUid(), mqMsg.getValue());
+ }
+ }
+ } else if (tag.equalsIgnoreCase(UserTopicTagEnum.taobaoBindSuccess.name())) {// 娣樺疂缁戝畾鎴愬姛
+ // 鏇存敼娣樺疂缁戝畾鐘舵�佷笌鍘熺敤鎴锋窐瀹濈粦瀹氱姸鎬�
+ JSONObject json = JSONObject.fromObject(new String(message.getBody()));
+ TaoBaoBindSuccessMQMsg mqMsg = new Gson().fromJson(json.toString(), TaoBaoBindSuccessMQMsg.class);
+ if (mqMsg != null) {
+ teamFansInfoService.updateTaobaoBind(mqMsg.getUid(), true);
+ Long fromUid = mqMsg.getFromUid();
+ if (fromUid != null) { // 娣樺疂琚В缁�
+ teamFansInfoService.updateTaobaoBind(fromUid, false);
+ }
+ }
+ } else if (tag.equalsIgnoreCase(UserTopicTagEnum.inviteSuccess.name())) {// 閭�璇锋垚鍔�
+ JSONObject json = JSONObject.fromObject(new String(message.getBody()));
+ UserInviteMQMsg mqMsg = new Gson().fromJson(json.toString(), UserInviteMQMsg.class);
+ if (mqMsg != null) {
+ ThreeSale ts = threeSaleSerivce.selectByWorkerId(mqMsg.getWorkerId());
+ if (ts == null)
+ return Action.ReconsumeLater;
+
+ // 鏇存柊涓婄骇鐨勭矇涓濇暟閲�
+ teamFansInfoService.updateFansNum(mqMsg.getBossId());
+
+ threeSaleDetailService.addByWorkerUid(mqMsg.getWorkerId());
+
+ // 鏇存柊闃熷憳缁熻淇℃伅
+ teamUserLevelStatisticService.initData(mqMsg.getBossId());
+ UserInfo boss = threeSaleSerivce.getBoss(mqMsg.getBossId());
+ if (boss != null) {
+ teamUserLevelStatisticService.initData(boss.getId());
+ }
+
+ }
+ } else if (tag.equalsIgnoreCase(UserTopicTagEnum.userMoneyAdd.name())) {// 璧勯噾鍒拌处
+ JSONObject json = JSONObject.fromObject(new String(message.getBody()));
+ UserMoneyChangeMQMsg mqMsg = new Gson().fromJson(json.toString(), UserMoneyChangeMQMsg.class);
+ if (mqMsg != null) {
+ // 鏇存柊杩�60澶╁埌璐�
+ teamFansInfoService.updateIncome(mqMsg.getUid(), mqMsg.getChangeMoney());
+ }
+ } else if (tag.equalsIgnoreCase(UserTopicTagEnum.becomeValidUser.name())) {// 鎴愪负鏈夋晥鐢ㄦ埛
+ JSONObject json = JSONObject.fromObject(new String(message.getBody()));
+ BeComeValidUserMQMsg mqMsg = new Gson().fromJson(json.toString(), BeComeValidUserMQMsg.class);
+ if (mqMsg != null) {
+ // 鏇存柊鎴愪负鏈夋晥绮変笣
+ teamFansInfoService.updateStateValid(mqMsg.getUid(), true);
+ }
+ } else if (tag.equalsIgnoreCase(UserTopicTagEnum.userAccountBinding.name())) {// 缁戝畾淇℃伅
+ JSONObject json = JSONObject.fromObject(new String(message.getBody()));
+ UserAccountBindingMQMsg mqMsg = new Gson().fromJson(json.toString(), UserAccountBindingMQMsg.class);
+ if (mqMsg != null) {
+ if (mqMsg.getType() == UserAccountBindingMQMsg.TYPE_PHONE) { // 缁戝畾鐢佃瘽鍙风爜
+ teamFansInfoService.updatePhone(mqMsg.getUid(), mqMsg.getValue());
+ }
+ }
+ } else if (tag.equalsIgnoreCase(UserTopicTagEnum.userLevelChanged.name())) {// 绛夌骇鍙樺寲
+ JSONObject json = JSONObject.fromObject(new String(message.getBody()));
+ UserLevelChangedMQMsg mqMsg = new Gson().fromJson(json.toString(), UserLevelChangedMQMsg.class);
+ if (mqMsg != null) {
+ teamFansInfoService.updateLevel(mqMsg.getUid(), mqMsg.getToLevel());
+ }
+ } else if (tag.equalsIgnoreCase(UserTopicTagEnum.userPhoneOpen.name())) {// 鐢佃瘽鍙风爜鍏紑
+ JSONObject json = JSONObject.fromObject(new String(message.getBody()));
+ UserPhoneOpenMQMsg mqMsg = new Gson().fromJson(json.toString(), UserPhoneOpenMQMsg.class);
+ if (mqMsg != null) {
+ teamFansInfoService.updatePhoneOpen(mqMsg.getUid(), mqMsg.isState());
+ }
+ }
+ }
+ return Action.CommitMessage;
+ }
+}
--
Gitblit v1.8.0