From dc5be7d38446f70e6ff86df311119c32b41fe7f8 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期六, 28 十一月 2020 16:37:05 +0800
Subject: [PATCH] 大淘客搜索接口升级

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/user/vip/UserVIPPreInfoServiceImpl.java |   38 ++++++++++++++++++++++++++++----------
 1 files changed, 28 insertions(+), 10 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/vip/UserVIPPreInfoServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/vip/UserVIPPreInfoServiceImpl.java
index de35d84..594041e 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/vip/UserVIPPreInfoServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/vip/UserVIPPreInfoServiceImpl.java
@@ -12,7 +12,6 @@
 import org.springframework.transaction.annotation.Transactional;
 
 import com.aliyun.openservices.ons.api.Message;
-import com.aliyun.openservices.ons.api.Producer;
 import com.yeshi.fanli.dao.mybatis.user.vip.UserVIPPreInfoMapper;
 import com.yeshi.fanli.dto.mq.user.UserTopicTagEnum;
 import com.yeshi.fanli.dto.mq.user.body.UserLevelChangedMQMsg;
@@ -38,9 +37,10 @@
 import com.yeshi.fanli.service.inter.user.vip.UserLevelUpgradedNotifyService;
 import com.yeshi.fanli.service.inter.user.vip.UserVIPPreInfoService;
 import com.yeshi.fanli.service.inter.user.vip.UserVipConfigService;
+import com.yeshi.fanli.service.manger.msg.RocketMQManager;
 import com.yeshi.fanli.util.Constant;
 import com.yeshi.fanli.util.StringUtil;
-import com.yeshi.fanli.util.TimeUtil;
+import org.yeshi.utils.TimeUtil;
 import com.yeshi.fanli.util.annotation.RequestSerializableByKeyService;
 import com.yeshi.fanli.util.rocketmq.MQMsgBodyFactory;
 import com.yeshi.fanli.util.rocketmq.MQTopicName;
@@ -88,12 +88,13 @@
 	@Resource(name = "taskExecutor")
 	private TaskExecutor executor;
 
-	@Resource(name = "producer")
-	private Producer producer;
+	@Resource
+	private RocketMQManager rocketMQManager;
 
 	@Resource
 	private TeamUserLevelStatisticService teamUserLevelStatisticService;
 
+	@Transactional
 	@Override
 	public void addUserVIPPreInfo(UserVIPPreInfo info) throws UserVIPPreInfoException {
 		if (info == null || info.getUid() == null || info.getProcess() == null || info.getSourceType() == null)
@@ -108,9 +109,32 @@
 			throw new UserVIPPreInfoException(2, "杩涘害宸插瓨鍦�");
 		if (info.getCreateTime() == null)
 			info.setCreateTime(new Date());
+
+		UserVIPPreInfo old = getLatestProcessInfo(info.getUid());
+
 		userVIPPreInfoMapper.insertSelective(info);
 		// 璁剧疆缁熻鏁版嵁
 		teamUserLevelStatisticService.setUserLevel(info.getUid(), UserLevelUtil.getByLevel(info.getProcess()));
+
+		// 鍙戦�佺瓑绾у彉鍖栨秷鎭�
+		if (!Constant.IS_TEST) {
+			UserLevelEnum oldLevel = null;
+			if (old == null)
+				oldLevel = UserLevelEnum.daRen;
+			else {
+				oldLevel = UserLevelUtil.getByLevel(old.getProcess());
+			}
+
+			if (oldLevel == UserLevelEnum.normalVIP)
+				oldLevel = UserLevelEnum.daRen;
+
+			UserLevelChangedMQMsg msg = new UserLevelChangedMQMsg(info.getUid(), oldLevel,
+					UserLevelUtil.getByLevel(info.getProcess()), new Date());
+			Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.userLevelChanged, msg);
+			//寤舵椂10s鍙戦��
+			rocketMQManager.sendNormalMsg(message,1000*10L, null);
+		}
+
 	}
 
 	@Override
@@ -315,12 +339,6 @@
 			LogHelper.error(e);
 		}
 
-		if (!Constant.IS_TEST) {
-			UserLevelChangedMQMsg msg = new UserLevelChangedMQMsg(uid, UserLevelEnum.daRen, UserLevelEnum.highVIP,
-					new Date());
-			Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.userLevelChanged, msg);
-			producer.send(message);
-		}
 	}
 
 	@Override

--
Gitblit v1.8.0