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

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/user/vip/UserVIPPreInfoServiceImpl.java |  562 ++++++++++++++++++++++++++++++-------------------------
 1 files changed, 306 insertions(+), 256 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 5b69e0c..41863dd 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
@@ -9,6 +9,7 @@
 import javax.annotation.Resource;
 
 import org.springframework.context.annotation.Lazy;
+import org.springframework.core.task.TaskExecutor;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.yeshi.utils.DateUtil;
@@ -99,6 +100,10 @@
 	
 	@Resource
 	private UserLevelUpgradedNotifyService userLevelUpgradedNotifyService;
+	
+	@Resource(name = "taskExecutor")
+	private TaskExecutor executor;
+	
 
 	@Override
 	public void addUserVIPPreInfo(UserVIPPreInfo info) throws UserVIPPreInfoException {
@@ -158,69 +163,179 @@
 		return null;
 	}
 
+
+	@Override
 	@RequestSerializableByKeyService(key = "#uid")
 	@Transactional(rollbackFor = Exception.class)
+	public void upgradeVipByFanLiOrder(Long uid) {
+		UserVIPPreInfo latest = getLatestProcessInfo(uid);
+		if (latest != null && latest.getProcess() == UserVIPPreInfo.PROCESS_2) {
+			return;
+		}
+		
+		if (latest == null) {
+			String inviteCode = userInfoExtraService.getInviteCodeByUid(uid);
+			if (StringUtil.isNullOrEmpty(inviteCode)) {
+				return; //鏈縺娲婚個璇风爜
+			}
+		} 
+		
+		// 鑷喘璁㈠崟鍒拌处
+		long doneZiGou = hongBaoV2CountService.counOrderByUidAndOrderType(uid, Constant.VIP_ORDER_PAY, HongBaoV2.TYPE_ZIGOU);
+		// 楂樼骇浼氬憳闄愬埗鏉′欢
+		long limitZiGou7 = 0;
+		String zigou7 = userVipConfigService.getValueByKey("vip_pre_7_zigou_order_count");
+		if (!StringUtil.isNullOrEmpty(zigou7)) {
+			limitZiGou7 = Long.parseLong(zigou7);
+		}
+		
+		// 楠岃瘉鏄惁婊¤冻鍗囩骇楂樼骇浼氬憳
+		if (doneZiGou >= limitZiGou7) {
+			twoProcess(uid, limitZiGou7, null, Constant.TYPE_REBATE);
+			return;
+		} 
+		
+		// 宸茬粡鎴愪负鏅�氫細鍛�
+		if (latest != null && latest.getProcess() == UserVIPPreInfo.PROCESS_1) {
+			return;
+		}
+		
+		// 鏅�氫細鍛樻潯浠�
+		long limitZiGou3 = 0;
+		String zigou3 = userVipConfigService.getValueByKey("vip_pre_3_zigou_order_count");
+		if (!StringUtil.isNullOrEmpty(zigou3)) {
+			limitZiGou3 = Long.parseLong(zigou3);
+		}
+		if (doneZiGou >= limitZiGou3) {
+			oneProcess(uid, limitZiGou3, null, Constant.TYPE_REBATE);
+		} 
+	}
+	
+	
 	@Override
-	public void verifyVipPreInfo(Long uid, boolean inviteSuccess) {
-		if (uid == null || uid <= 0)
+	@RequestSerializableByKeyService(key = "#uid")
+	@Transactional(rollbackFor = Exception.class)
+	public void upgradeVipByShareOrder(Long uid) {
+		UserVIPPreInfo latest = getLatestProcessInfo(uid);
+		if (latest != null && latest.getProcess() == UserVIPPreInfo.PROCESS_2) {
 			return;
-
-		verifyCondition(uid);
-
-		// 楠岃瘉涓婄骇
-		if (inviteSuccess) {
-			UserInfo boss = threeSaleSerivce.getBoss(uid);
-			if (boss != null) {
-				verifyVipPreInfoBoss(boss.getId());
+		}
+		
+		if (latest == null) {
+			String inviteCode = userInfoExtraService.getInviteCodeByUid(uid);
+			if (StringUtil.isNullOrEmpty(inviteCode)) {
+				return; //鏈縺娲婚個璇风爜
 			}
+		} 
+		
+		// 鍒嗕韩璁㈠崟宸插埌璐�
+		long doneShare = hongBaoV2CountService.counOrderByUidAndOrderType(uid, Constant.VIP_ORDER_PAY,
+				HongBaoV2.TYPE_SHARE_GOODS);
+		// 楂樼骇浼氬憳闄愬埗鏉′欢
+		long limitShare7 = 0;
+		String share7 = userVipConfigService.getValueByKey("vip_pre_7_share_order_count");
+		if (!StringUtil.isNullOrEmpty(share7)) {
+			limitShare7 = Long.parseLong(share7);
+		}
+		
+		// 楠岃瘉鏄惁婊¤冻鍗囩骇楂樼骇浼氬憳
+		if (doneShare >= limitShare7) {
+			twoProcess(uid, limitShare7, null, Constant.TYPE_SHAER);
+			return;
+		} 
+		
+		// 宸茬粡鎴愪负鏅�氫細鍛�
+		if (latest != null && latest.getProcess() == UserVIPPreInfo.PROCESS_1) {
+			return;
+		}
+		
+		// 鏅�氫細鍛樻潯浠�
+		long limitShare3 = 0;
+		String share3 = userVipConfigService.getValueByKey("vip_pre_3_share_order_count");
+		if (!StringUtil.isNullOrEmpty(share3)) {
+			limitShare3 = Long.parseLong(share3);
+		}
+		if (doneShare >= limitShare3) {
+			oneProcess(uid, limitShare3, null, Constant.TYPE_SHAER);
+		} 
+	}
+	
+	
+	@Override
+	@RequestSerializableByKeyService(key = "#tid")
+	@Transactional(rollbackFor = Exception.class)
+	public void upgradeVipByTeamNum(Long tid) {
+		UserInfo boss = threeSaleSerivce.getBoss(tid);
+		if (boss == null) {
+			return;
+		}
+		Long bossId = boss.getId();
+		
+		// 楠岃瘉涓婁笂绾� -闂存帴绮変笣鏄惁婊¤冻
+		executor.execute(new Runnable() {
+			@Override
+			public void run() {
+				upgradeVipByTeamNum(bossId);
+			}
+		});
+		
+		UserVIPPreInfo latest = getLatestProcessInfo(bossId);
+		if (latest != null && latest.getProcess() == UserVIPPreInfo.PROCESS_2) {
+			return;
+		}
+		
+		// 鏈夋晥绮変笣
+		int doneFirst = 0;
+		int doneSecond = 0;
+		UserInviteValidNum userInviteValidNum = userInviteValidNumService.selectByPrimaryKey(bossId);
+		if (userInviteValidNum != null) {
+			doneFirst = userInviteValidNum.getNumFirst() == null ? 0 : userInviteValidNum.getNumFirst();
+			doneSecond = userInviteValidNum.getNumSecond() == null ? 0 : userInviteValidNum.getNumSecond();
+		}
+					
+		long limitFirst7 = 0;
+		String first7 = userVipConfigService.getValueByKey("vip_pre_7_first_level_team_count");
+		if (!StringUtil.isNullOrEmpty(first7)) {
+			limitFirst7 = Long.parseLong(first7);
+		}
+		long limitSecond7 = 0;
+		String second7 = userVipConfigService.getValueByKey("vip_pre_7_second_level_team_count");
+		if (!StringUtil.isNullOrEmpty(second7)) {
+			limitSecond7 = Long.parseLong(second7);
+		}
+		
+		// 楠岃瘉鏄惁婊¤冻鍗囩骇楂樼骇浼氬憳
+		if (doneFirst >= limitFirst7 && doneSecond >= limitSecond7) {
+			twoProcess(bossId, limitFirst7, limitSecond7, null);
+			return;
+		}
+
+		// 宸茬粡鎴愪负鏅�氫細鍛�
+		if (latest != null && latest.getProcess() == UserVIPPreInfo.PROCESS_1) {
+			return;
+		}
+		
+		// 鏅�氫細鍛� 鏉′欢
+		long limitFirst3 = 0;
+		String first = userVipConfigService.getValueByKey("vip_pre_3_first_level_team_count");
+		if (!StringUtil.isNullOrEmpty(first)) {
+			limitFirst3 = Long.parseLong(first);
+		}
+		
+		long limitSecond3 = 0;
+		String second = userVipConfigService.getValueByKey("vip_pre_3_second_level_team_count");
+		if (!StringUtil.isNullOrEmpty(second)) {
+			limitSecond3 = Long.parseLong(second);
+		}
+		
+		if (doneFirst >= limitFirst3 && doneSecond >= limitSecond3) {
+			oneProcess(bossId, limitFirst3, limitSecond3, null);
 		}
 	}
-
-	// 涓婄骇楠岃瘉
-	private void verifyVipPreInfoBoss(Long uid) {
-		if (uid == null || uid <= 0)
-			return;
-
-		verifyCondition(uid);
-	}
-
-	private void verifyCondition(Long uid) {
-		try {
-			// 楠岃瘉浜岄樁娈�
-			UserVIPPreInfo oldInfo = userVIPPreInfoMapper.selectByUidAndProcess(uid, UserVIPPreInfo.PROCESS_2);
-			if (oldInfo != null) {
-				return;
-			}
-			
-			// 鑷喘璁㈠崟
-			long doneZiGou = hongBaoV2CountService.counOrderByUidAndOrderType(uid, Constant.VIP_ORDER_PAY,
-					HongBaoV2.TYPE_ZIGOU);
-			// 鍒嗕韩璁㈠崟
-			long doneShare = hongBaoV2CountService.counOrderByUidAndOrderType(uid, Constant.VIP_ORDER_PAY,
-					HongBaoV2.TYPE_SHARE_GOODS);
-			
-			// 鏈夋晥绮変笣
-			int doneFirst = 0;
-			int doneSecond = 0;
-			UserInviteValidNum userInviteValidNum = userInviteValidNumService.selectByPrimaryKey(uid);
-			if (userInviteValidNum != null) {
-				doneFirst = userInviteValidNum.getNumFirst() == null ? 0 : userInviteValidNum.getNumFirst();
-				doneSecond = userInviteValidNum.getNumSecond() == null ? 0 : userInviteValidNum.getNumSecond();
-			}
-
-			// 涓�闃舵
-			boolean process1 = oneProcess(uid, doneZiGou, doneShare, doneFirst, doneSecond);
-			if (!process1) {
-				return;
-			}
-
-			// 浜岄樁娈�
-			twoProcess(uid, doneZiGou, doneShare, doneFirst, doneSecond);
-		} catch (Exception e) {
-			LogHelper.errorDetailInfo(e);
-		}
-	}
-
+	
+	
+	
+	
 	/**
 	 * 涓�闃舵
 	 * 
@@ -231,120 +346,55 @@
 	 * @param secondTeam
 	 */
 	@Transactional(rollbackFor = Exception.class)
-	private boolean oneProcess(Long uid, long countZiGou, long countShare, long firstTeam, long secondTeam) throws Exception{
-		UserVIPPreInfo oldInfo = userVIPPreInfoMapper.selectByUidAndProcess(uid, UserVIPPreInfo.PROCESS_1);
-		if (oldInfo != null) {
-			return true;
-		}
-					
-		long limitZiGou = 0;
-		String zigou = userVipConfigService.getValueByKey("vip_pre_3_zigou_order_count");
-		if (!StringUtil.isNullOrEmpty(zigou)) {
-			limitZiGou = Long.parseLong(zigou);
-		}
-		
-		long limitShare = 0;
-		String share = userVipConfigService.getValueByKey("vip_pre_3_share_order_count");
-		if (!StringUtil.isNullOrEmpty(share)) {
-			limitShare = Long.parseLong(share);
-		}
-		
-		long limitFirst = 0;
-		String first = userVipConfigService.getValueByKey("vip_pre_3_first_level_team_count");
-		if (!StringUtil.isNullOrEmpty(first)) {
-			limitFirst = Long.parseLong(first);
-		}
-		
-		long limitSecond = 0;
-		String second = userVipConfigService.getValueByKey("vip_pre_3_second_level_team_count");
-		if (!StringUtil.isNullOrEmpty(second)) {
-			limitSecond = Long.parseLong(second);
-		}
-		
-		String item = "";
-		Integer type = null;
-		long targetNum1 = 0L;
-		Long targetNum2 = 0L;
-		boolean process = false;
-		if (countZiGou >= limitZiGou) {
-			process = true;
-			type = Constant.TYPE_REBATE;
-			targetNum1 = limitZiGou;
-			item = "杩斿埄璁㈠崟";
-		} else if (countShare >= limitShare) {
-			process = true;
-			type = Constant.TYPE_SHAER;
-			targetNum1 = limitShare;
-			item = "鍒嗕韩璁㈠崟";
-		} else if (firstTeam >= limitFirst && secondTeam >= limitSecond) {
-			process = true;
-			targetNum1 = limitFirst;
-			targetNum2 = limitSecond;
-			item = "閭�璇风矇涓�";
-		}
-
-		if (process) {
-			try {
-				Date upgradeTime = new Date();
-				UserVIPPreInfo info = new UserVIPPreInfo();
-				info.setUid(uid);
-				info.setProcess(UserVIPPreInfo.PROCESS_1);
-				info.setCreateTime(upgradeTime);
-				info.setUpdateTime(upgradeTime);
-				addUserVIPPreInfo(info);
-
-				// 鍗囩骇娑堟伅
-				Date registerTime = new Date(1577836800000L);
-				UserInfoRegister userInfoRegister = userInfoRegisterService.selectByPrimaryKey(uid);
-				if (userInfoRegister != null && userInfoRegister.getCreateTime() != null) {
-					registerTime = userInfoRegister.getCreateTime();
-				}
-				int daysBetween = DateUtil.daysBetween(registerTime, new Date());
-				userAccountMsgNotificationService.vipPreUpgrade(uid, "蹇渷杈句汉", "鏅�氫細鍛�", daysBetween, targetNum1, targetNum2, type);
-				
-				
-				// 鍗囩骇寮规鎻愮ず
-				UserLevelUpgradedNotify notify = new UserLevelUpgradedNotify();
-				notify.setUid(uid);
-				notify.setFromLevel(UserLevelEnum.daRen);
-				notify.setToLevel(UserLevelEnum.normalVIP);
-				notify.setValid(true);
-				notify.setCreateTime(new Date());
-				userLevelUpgradedNotifyService.addUserLevelUpgradedNotify(notify);
-				
-				// 璧犻�侀噾甯�
-				String goldcoin = userVipConfigService.getValueByKey("vip_pre_3_gift_goldcoin");
-				if (!StringUtil.isNullOrEmpty(goldcoin)) {
-					
-					int goldcoinNum = Integer.parseInt(goldcoin);
-					// 娣诲姞閲戝竵鏄庣粏
-					IntegralDetail detail = new IntegralDetail();
-					detail.setTitle("鍗囩骇VIP绂忓埄");
-					detail.setUid(uid);
-					detail.setMoney(Integer.parseInt(goldcoin));
-					detail.setCreateTime(upgradeTime);
-					detail.setUniqueKey("VIP-3-" + uid);
-					integralDetailService.insertSelective(detail);
-					
-					// 娣诲姞閲戝竵
-					userInfoExtraService.addGoldCoinByUid(uid, Integer.parseInt(goldcoin));
-					
-					// 娑堟伅
-					UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
-					userOtherMsgNotificationService.goldCoinSystemGiveMsg(uid, goldcoinNum, userInfoExtra.getGoldCoin());
-				}
-				// 鏄惁瀛樺湪涓嬬骇鑴辩鏈熼檺 -鏇存柊涓嶈劚绂�
-				userInviteSeparateService.updateInvalidByBossId(uid);
-				
-				// 鎻愰啋涓婄骇
-				remindBoss(uid, "鏅�氫細鍛�", item, upgradeTime, true);
-				
-			} catch (UserVIPPreInfoException e) {
-				e.printStackTrace();
+	private void oneProcess(Long uid, long limit1, Long limit2, Integer type) {
+		try {
+			String item = null;
+			if (type == null) {
+				item = "閭�璇风矇涓�";
+			} else if (type == Constant.TYPE_REBATE) {
+				item = "杩斿埄璁㈠崟";
+			} else {
+				item = "鍒嗕韩璁㈠崟";
 			}
+
+			Date upgradeTime = new Date();
+			UserVIPPreInfo info = new UserVIPPreInfo();
+			info.setUid(uid);
+			info.setProcess(UserVIPPreInfo.PROCESS_1);
+			info.setCreateTime(upgradeTime);
+			info.setUpdateTime(upgradeTime);
+			addUserVIPPreInfo(info);
+
+			// 鍗囩骇娑堟伅
+			Date registerTime = new Date(1577836800000L);
+			UserInfoRegister userInfoRegister = userInfoRegisterService.selectByPrimaryKey(uid);
+			if (userInfoRegister != null && userInfoRegister.getCreateTime() != null) {
+				registerTime = userInfoRegister.getCreateTime();
+			}
+			int daysBetween = DateUtil.daysBetween(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.setValid(true);
+			notify.setCreateTime(new Date());
+			userLevelUpgradedNotifyService.addUserLevelUpgradedNotify(notify);
+			
+			// 閲戝竵濂栧姳
+			goldcoinReward(uid);
+			
+			// 鏄惁瀛樺湪涓嬬骇鑴辩鏈熼檺 -鏇存柊涓嶈劚绂�
+			userInviteSeparateService.updateInvalidByBossId(uid);
+			// 鎻愰啋涓婄骇
+			remindBoss(uid, "鏅�氫細鍛�", item, upgradeTime, true);
+		} catch (Exception e) {
+		   e.printStackTrace();
 		}
-		return process;
 	}
+	
 	
 	
 	/**
@@ -357,97 +407,98 @@
 	 * @param secondTeam
 	 */
 	@Transactional(rollbackFor = Exception.class)
-	private boolean twoProcess(Long uid, long countZiGou, long countShare, long firstTeam, long secondTeam) {
-		long limitZiGou = 0;
-		String zigou = userVipConfigService.getValueByKey("vip_pre_7_zigou_order_count");
-		if (!StringUtil.isNullOrEmpty(zigou)) {
-			limitZiGou = Long.parseLong(zigou);
-		}
-		
-		long limitShare = 0;
-		String share = userVipConfigService.getValueByKey("vip_pre_7_share_order_count");
-		if (!StringUtil.isNullOrEmpty(share)) {
-			limitShare = Long.parseLong(share);
-		}
-		
-		long limitFirst = 0;
-		String first = userVipConfigService.getValueByKey("vip_pre_7_first_level_team_count");
-		if (!StringUtil.isNullOrEmpty(first)) {
-			limitFirst = Long.parseLong(first);
-		}
-		
-		long limitSecond = 0;
-		String second = userVipConfigService.getValueByKey("vip_pre_7_second_level_team_count");
-		if (!StringUtil.isNullOrEmpty(second)) {
-			limitSecond = Long.parseLong(second);
-		}
-		
-		Integer type = null;
-		long targetNum1 = 0L;
-		Long targetNum2 = 0L;
-		String item = "";
-		boolean process = false;
-		if (countZiGou >= limitZiGou) {
-			process = true;
-			targetNum1 = limitZiGou;
-			type = Constant.TYPE_REBATE;
-			item = "杩斿埄璁㈠崟";
-		} else if (countShare >= limitShare) {
-			process = true;
-			targetNum1 = limitShare;
-			type = Constant.TYPE_SHAER;
-			item = "鍒嗕韩璁㈠崟";
-		} else if (firstTeam >= limitFirst && secondTeam >= limitSecond) {
-			process = true;
-			targetNum1 = limitFirst;
-			targetNum2 = limitSecond;
-			item = "閭�璇风矇涓�";
-		}
-
-		if (process) {
-			try {
-				Date upgradeTime = new Date();
-				UserVIPPreInfo info = new UserVIPPreInfo();
-				info.setUid(uid);
-				info.setProcess(UserVIPPreInfo.PROCESS_2);
-				info.setCreateTime(upgradeTime);
-				info.setUpdateTime(upgradeTime);
-				addUserVIPPreInfo(info);
-				
-				// 鍗囩骇寮规鎻愮ず
-				UserLevelUpgradedNotify notify = new UserLevelUpgradedNotify();
-				notify.setUid(uid);
-				notify.setFromLevel(UserLevelEnum.normalVIP);
-				notify.setToLevel(UserLevelEnum.highVIP);
-				notify.setValid(true);
-				notify.setCreateTime(new Date());
-				userLevelUpgradedNotifyService.addUserLevelUpgradedNotify(notify);
-				
-				// 鍗囩骇娑堟伅
-				UserVIPPreInfo pre1 = userVIPPreInfoMapper.selectByUidAndProcess(uid, UserVIPPreInfo.PROCESS_1);
-				int daysBetween = DateUtil.daysBetween(pre1.getCreateTime(), upgradeTime);
-				userAccountMsgNotificationService.vipPreUpgrade(uid, "鏅�氫細鍛�", "楂樼骇浼氬憳", daysBetween, targetNum1, targetNum2, type);
-				
-				// 璧犻�佸鍔卞埜
-				String rewardCoupon = userVipConfigService.getValueByKey("vip_pre_7_gift_reward_coupon");
-				if (!StringUtil.isNullOrEmpty(rewardCoupon)) {
-					int num = Integer.parseInt(rewardCoupon);
-					BigDecimal percent = new BigDecimal(configService.get(ConfigKeyEnum.exchangeRebatePercent.getKey()));
-					userSystemCouponService.rewardCouponWin(uid, UserSystemCoupon.SOURCE_SYSTEM_PUSH, num, true, percent);
-				}
-				
-				// 鎻愰啋涓婄骇
-				remindBoss(uid, "楂樼骇浼氬憳", item, upgradeTime, false);
-				
-			} catch (Exception e) {
-				e.printStackTrace();
-				LogHelper.error(e);
+	private void twoProcess(Long uid, long limit1, Long limit2, Integer type) {
+		try {
+			String item = null;
+			if (type == null) {
+				item = "閭�璇风矇涓�";
+			} else if (type == Constant.TYPE_REBATE) {
+				item = "杩斿埄璁㈠崟";
+			} else {
+				item = "鍒嗕韩璁㈠崟";
 			}
+
+			Date upgradeTime = new Date();
+			UserVIPPreInfo info = new UserVIPPreInfo();
+			info.setUid(uid);
+			info.setProcess(UserVIPPreInfo.PROCESS_2);
+			info.setCreateTime(upgradeTime);
+			info.setUpdateTime(upgradeTime);
+			addUserVIPPreInfo(info);
+
+			// 鍗囩骇寮规鎻愮ず
+			UserLevelUpgradedNotify notify = new UserLevelUpgradedNotify();
+			notify.setUid(uid);
+			notify.setFromLevel(UserLevelEnum.normalVIP);
+			notify.setToLevel(UserLevelEnum.highVIP);
+			notify.setValid(true);
+			notify.setCreateTime(new Date());
+			userLevelUpgradedNotifyService.addUserLevelUpgradedNotify(notify);
+
+			// 鍗囩骇绂忓埄-璧犻�佸鍔卞埜
+			String rewardCoupon = userVipConfigService.getValueByKey("vip_pre_7_gift_reward_coupon");
+			if (!StringUtil.isNullOrEmpty(rewardCoupon)) {
+				int num = Integer.parseInt(rewardCoupon);
+				BigDecimal percent = new BigDecimal(configService.get(ConfigKeyEnum.exchangeRebatePercent.getKey()));
+				userSystemCouponService.rewardCouponWin(uid, UserSystemCoupon.SOURCE_SYSTEM_PUSH, num, true, percent);
+			}
+						
+			// 鍗囩骇娑堟伅
+			int daysBetween = 0;
+			boolean divorced = false;
+			String beforeName = "蹇渷杈句汉";
+			UserVIPPreInfo pre1 = userVIPPreInfoMapper.selectByUidAndProcess(uid, UserVIPPreInfo.PROCESS_1);
+			if (pre1 != null) {
+				beforeName = "鏅�氫細鍛�";
+				daysBetween = DateUtil.daysBetween(pre1.getCreateTime(), upgradeTime);
+			} else {
+				Date registerTime = new Date(1577836800000L);
+				UserInfoRegister userInfoRegister = userInfoRegisterService.selectByPrimaryKey(uid);
+				if (userInfoRegister != null && userInfoRegister.getCreateTime() != null) {
+					registerTime = userInfoRegister.getCreateTime();
+				}
+				daysBetween = DateUtil.daysBetween(registerTime, upgradeTime);
+				
+				// 閲戝竵濂栧姳 锛堢洿鎺ュ崌绾ч珮绾т細鍛樿ˉ榻愪竴绾у鍔憋級
+				goldcoinReward(uid);
+				// 闇�瑕佸彂閫佽劚绂讳俊鎭�
+				divorced = true;
+			}
+			userAccountMsgNotificationService.vipPreUpgrade(uid, beforeName, "楂樼骇浼氬憳", daysBetween, limit1, limit2, type);
+
+			// 鎻愰啋涓婄骇
+			remindBoss(uid, "楂樼骇浼氬憳", item, upgradeTime, divorced);
+		} catch (Exception e) {
+			e.printStackTrace();
+			LogHelper.error(e);
 		}
-		return process;
 	}
 	
-
+	/**
+	 * 鍗囩骇濂栧姳閲戝竵
+	 * @param uid
+	 */
+	private void goldcoinReward(Long uid) {
+		String goldcoin = userVipConfigService.getValueByKey("vip_pre_3_gift_goldcoin");
+		if (!StringUtil.isNullOrEmpty(goldcoin)) {
+			int goldcoinNum = Integer.parseInt(goldcoin);
+			// 娣诲姞閲戝竵鏄庣粏
+			IntegralDetail detail = new IntegralDetail();
+			detail.setTitle("鍗囩骇VIP绂忓埄");
+			detail.setUid(uid);
+			detail.setMoney(Integer.parseInt(goldcoin));
+			detail.setCreateTime(new Date());
+			detail.setUniqueKey("VIP-3-" + uid);
+			integralDetailService.insertSelective(detail);
+			// 娣诲姞閲戝竵
+			userInfoExtraService.addGoldCoinByUid(uid, Integer.parseInt(goldcoin));
+			// 娑堟伅
+			UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
+			userOtherMsgNotificationService.goldCoinSystemGiveMsg(uid, goldcoinNum, userInfoExtra.getGoldCoin());
+		}
+	}
+	
+ 
 	@Override
 	public void remindBoss(Long uid, String rankName, String item, Date time, boolean divorced) {
 		// 鏄惁瀛樺湪涓婄骇
@@ -493,8 +544,7 @@
 	
 	@Override
 	public UserVIPPreInfo selectByUidAndProcess(Long uid, int process) {
-		UserVIPPreInfo info = userVIPPreInfoMapper.selectByUidAndProcess(uid, process);
-		return info;
+		return userVIPPreInfoMapper.selectByUidAndProcess(uid, process);
 	}
 
 }

--
Gitblit v1.8.0