From 5af10f175689549ca44b74e9fc1c7ee0ec92c2d7 Mon Sep 17 00:00:00 2001
From: yujian <yujian@163.com>
Date: 星期二, 21 四月 2020 14:26:38 +0800
Subject: [PATCH] 后台改造

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/user/vip/UserVIPPreInfoServiceImpl.java |   34 +++++++++++++++++++++++++++++-----
 1 files changed, 29 insertions(+), 5 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 41863dd..809be6d 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
@@ -14,7 +14,11 @@
 import org.springframework.transaction.annotation.Transactional;
 import org.yeshi.utils.DateUtil;
 
+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;
 import com.yeshi.fanli.entity.bus.user.HongBaoV2;
 import com.yeshi.fanli.entity.bus.user.ThreeSale;
 import com.yeshi.fanli.entity.bus.user.UserInfo;
@@ -47,7 +51,10 @@
 import com.yeshi.fanli.service.inter.user.vip.UserVipConfigService;
 import com.yeshi.fanli.util.Constant;
 import com.yeshi.fanli.util.StringUtil;
+import com.yeshi.fanli.util.TimeUtil;
 import com.yeshi.fanli.util.annotation.RequestSerializableByKeyService;
+import com.yeshi.fanli.util.rocketmq.MQMsgBodyFactory;
+import com.yeshi.fanli.util.rocketmq.MQTopicName;
 
 @Service
 public class UserVIPPreInfoServiceImpl implements UserVIPPreInfoService {
@@ -103,6 +110,9 @@
 	
 	@Resource(name = "taskExecutor")
 	private TaskExecutor executor;
+	
+	@Resource(name = "producer")
+	private Producer producer;
 	
 
 	@Override
@@ -371,7 +381,7 @@
 			if (userInfoRegister != null && userInfoRegister.getCreateTime() != null) {
 				registerTime = userInfoRegister.getCreateTime();
 			}
-			int daysBetween = DateUtil.daysBetween(registerTime, new Date());
+			int daysBetween = TimeUtil.getDayDifferenceCount(registerTime, new Date());
 			userAccountMsgNotificationService.vipPreUpgrade(uid, "蹇渷杈句汉", "鏅�氫細鍛�", daysBetween, limit1, limit2, type);
 			
 			// 鍗囩骇寮规鎻愮ず
@@ -390,6 +400,12 @@
 			userInviteSeparateService.updateInvalidByBossId(uid);
 			// 鎻愰啋涓婄骇
 			remindBoss(uid, "鏅�氫細鍛�", item, upgradeTime, true);
+			
+			if (!Constant.IS_TEST) {
+				UserLevelChangedMQMsg msg = new UserLevelChangedMQMsg(uid, UserLevelEnum.daRen,UserLevelEnum.normalVIP, new Date());
+				Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.userLevelChanged, msg);
+				producer.send(message);
+			}
 		} catch (Exception e) {
 		   e.printStackTrace();
 		}
@@ -444,6 +460,7 @@
 			}
 						
 			// 鍗囩骇娑堟伅
+			UserLevelEnum fromLevel = UserLevelEnum.normalVIP;
 			int daysBetween = 0;
 			boolean divorced = false;
 			String beforeName = "蹇渷杈句汉";
@@ -457,17 +474,25 @@
 				if (userInfoRegister != null && userInfoRegister.getCreateTime() != null) {
 					registerTime = userInfoRegister.getCreateTime();
 				}
-				daysBetween = DateUtil.daysBetween(registerTime, upgradeTime);
+				daysBetween = TimeUtil.getDayDifferenceCount(registerTime, upgradeTime);
 				
 				// 閲戝竵濂栧姳 锛堢洿鎺ュ崌绾ч珮绾т細鍛樿ˉ榻愪竴绾у鍔憋級
 				goldcoinReward(uid);
 				// 闇�瑕佸彂閫佽劚绂讳俊鎭�
 				divorced = true;
+				fromLevel = UserLevelEnum.daRen;
 			}
 			userAccountMsgNotificationService.vipPreUpgrade(uid, beforeName, "楂樼骇浼氬憳", daysBetween, limit1, limit2, type);
 
 			// 鎻愰啋涓婄骇
 			remindBoss(uid, "楂樼骇浼氬憳", item, upgradeTime, divorced);
+			
+			
+			if (!Constant.IS_TEST) {
+				UserLevelChangedMQMsg msg = new UserLevelChangedMQMsg(uid, fromLevel,UserLevelEnum.highVIP, new Date());
+				Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.userLevelChanged, msg);
+				producer.send(message);
+			}
 		} catch (Exception e) {
 			e.printStackTrace();
 			LogHelper.error(e);
@@ -523,9 +548,8 @@
 			return;
 		}
 		
-		// 楠岃瘉涓婄骇鏄惁宸叉槸浼氬憳
-		UserVIPPreInfo oldInfo = userVIPPreInfoMapper.selectByUidAndProcess(bossId, UserVIPPreInfo.PROCESS_1);
-		if (oldInfo == null) {
+		UserVIPPreInfo latestInfo = getLatestProcessInfo(bossId);
+		if (latestInfo == null) {
 			// 娣诲姞鑴辩鍏崇郴鍊掕鏃�
 			userInviteSeparateService.addPreSeparateRecord(uid, bossId);
 			

--
Gitblit v1.8.0