From d22d18f40d088277195e5c3ab587d07450f1a94d Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期三, 22 四月 2020 18:22:17 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/div' into div

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/user/vip/UserVIPPreInfoServiceImpl.java |   38 +++++++++++++++++++++++++++++++-------
 1 files changed, 31 insertions(+), 7 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..5a3221c 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,14 +381,14 @@
 			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);
 			
 			// 鍗囩骇寮规鎻愮ず
 			UserLevelUpgradedNotify notify = new UserLevelUpgradedNotify();
 			notify.setUid(uid);
 			notify.setFromLevel(UserLevelEnum.daRen);
-			notify.setToLevel(UserLevelEnum.normalVIP);
+//			notify.setToLevel(UserLevelEnum.normalVIP);
 			notify.setValid(true);
 			notify.setCreateTime(new Date());
 			userLevelUpgradedNotifyService.addUserLevelUpgradedNotify(notify);
@@ -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();
 		}
@@ -429,7 +445,7 @@
 			// 鍗囩骇寮规鎻愮ず
 			UserLevelUpgradedNotify notify = new UserLevelUpgradedNotify();
 			notify.setUid(uid);
-			notify.setFromLevel(UserLevelEnum.normalVIP);
+//			notify.setFromLevel(UserLevelEnum.normalVIP);
 			notify.setToLevel(UserLevelEnum.highVIP);
 			notify.setValid(true);
 			notify.setCreateTime(new Date());
@@ -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