From c8041ec0544bf122e6819e6bf698997ccbf30aaf Mon Sep 17 00:00:00 2001
From: yujian <yujian@163.com>
Date: 星期二, 10 十二月 2019 15:32:34 +0800
Subject: [PATCH] 小黄条

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/user/vip/UserVIPInfoServiceImpl.java |   39 ++++++++++++++++++++++++++++++---------
 1 files changed, 30 insertions(+), 9 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/vip/UserVIPInfoServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/vip/UserVIPInfoServiceImpl.java
index 86ef0a1..eb0d183 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/vip/UserVIPInfoServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/vip/UserVIPInfoServiceImpl.java
@@ -11,6 +11,7 @@
 
 import javax.annotation.Resource;
 
+import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.yeshi.utils.DateUtil;
@@ -23,6 +24,7 @@
 import com.yeshi.fanli.entity.bus.user.UserInviteSeparate;
 import com.yeshi.fanli.entity.bus.user.UserSystemCoupon;
 import com.yeshi.fanli.entity.bus.user.vip.UserVIPInfo;
+import com.yeshi.fanli.entity.integral.IntegralDetail;
 import com.yeshi.fanli.entity.shop.BanLiShopOrder;
 import com.yeshi.fanli.entity.system.SystemCoupon.CouponTypeEnum;
 import com.yeshi.fanli.exception.user.vip.UserVIPInfoException;
@@ -56,6 +58,7 @@
 	@Resource
 	private UserVipConfigService userVipConfigService;
 	
+	@Lazy
 	@Resource
 	private HongBaoV2CountService hongBaoV2CountService;
 	
@@ -77,12 +80,13 @@
 	@Resource
 	private ConfigService configService;
 	
+	@Lazy
 	@Resource
 	private UserSystemCouponService userSystemCouponService;
 
-	
 
 	@Override
+	@Transactional
 	public void addUserVIPInfo(UserVIPInfo info) throws UserVIPInfoException {
 		if (info.getId() == null) {
 			throw new UserVIPInfoException(1, "淇℃伅涓嶅畬鏁�");
@@ -121,14 +125,30 @@
 		// 涓嬬骇鐨勮秴绾т細鍛� 涓嶈劚绂�
 		userInviteSeparateService.updateInvalidByBossId(uid);
 		
-		// 璧犻�佸埜
+		// 棰濆淇℃伅
+		UserInfoExtra userInfoExtra = userInfoExtraService.getByUidForUpdate(uid);
+		if (userInfoExtra == null)
+			throw new UserVIPInfoException(1, "鐢ㄦ埛淇℃伅涓嶅瓨鍦�");
+		
+		// 娣诲姞閲戝竵
+		IntegralDetail detail = new IntegralDetail();
+		detail.setTitle("鍗囩骇VIP绂忓埄");
+		detail.setUid(uid);
+		detail.setMoney(Constant.VIP_COLDCOIN_NUM);
+		detail.setCreateTime(new Date());
+		detail.setUniqueKey("VIP-" + uid);
+		integralDetailService.insertSelective(detail);
+		userInfoExtraService.addGoldCoinByUid(uid, Constant.VIP_COLDCOIN_NUM);
+		
 		try {
+			// 濂栧姳鍒�
 			BigDecimal percent = new BigDecimal(configService.get("exchange_rebate_percent"));
 			for (int i = 0; i < Constant.VIP_COUPON_REWARD_NUM; i++) {
 				userSystemCouponService.insertUserCoupon(uid, CouponTypeEnum.rebatePercentCoupon.name(), 
 						UserSystemCoupon.SOURCE_SYSTEM_PUSH, percent, false);
 			}
 			
+			// 璧犻�佸厤鍗曞埜
 			for (int i = 0; i < Constant.VIP_COUPON_GIVEFREE_NUM; i++) {
 				userSystemCouponService.insertUserCoupon(uid, CouponTypeEnum.freeCouponGive.name(), 
 						UserSystemCoupon.SOURCE_SYSTEM_PUSH, null, false);
@@ -142,7 +162,7 @@
 		msgOther.setContent1("鎭枩浣狅紝宸叉垚涓鸿秴绾т細鍛�");
 		msgOther.setContent2("婊¤冻鍗囩骇鏉′欢");
 		msgOther.setContent3(TimeUtil.formatDateDot(new Date()));
-		userOtherMsgNotificationService.passVIPApplyMsg(uid, "杩斿埄濂栧姳鍒稿拰璧犻�佸厤鍗曞埜璇峰埌鎴戠殑-绂忓埄涓績涓煡鐪�", msgOther);
+		userOtherMsgNotificationService.passVIPApplyMsg(uid, "杩斿埄濂栧姳鍒稿拰銆佽禒閫佸厤鍗曞埜鍜岄噾甯佽鍒版垜鐨�-绂忓埄涓績涓煡鐪�", msgOther);
 		
 		// 閫氱煡涓婄骇
 		callBoss(uid);
@@ -183,7 +203,7 @@
 		MsgOtherVIPDTO msgboss = new MsgOtherVIPDTO();
 		msgboss.setContent1(userInfo.getNickName() +" "+ uid);
 		msgboss.setContent2("浜�" + TimeUtil.formatDateDot(new Date()) + "鎴愬姛鍗囩骇鎴愪负瓒呯骇浼氬憳");
-		msgboss.setContent3("浠婃棩璧�"+limitDays+"澶╁唴锛屼綘鏈兘鎴愪负瓒呯骇浼氬憳灏嗕細涓庡叾浠ュ強鍏剁洿鎺ョ矇涓濊劚绂婚個璇峰叧绯� ");
+		msgboss.setContent3("浠婃棩璧�"+limitDays+"澶╁唴锛屼綘鏈兘鎴愪负瓒呯骇浼氬憳灏嗕細涓庡叾鑴辩閭�璇峰叧绯� ");
 		userOtherMsgNotificationService.teamVIPCallBoss(bossId, "濡傛湁鐤戦棶璇疯仈绯绘垜鐨�-浜哄伐瀹㈡湇", msgboss);
 	}
 	
@@ -216,12 +236,13 @@
 	public void applyVIP(Long uid) throws UserVIPInfoException {
 		UserVIPInfo userInfo = userVIPInfoMapper.selectByPrimaryKeyForUpdate(uid);
 		if (userInfo == null) {
-			throw new UserVIPInfoException(1, "鐢ㄦ埛淇℃伅涓嶅瓨鍦�");
+			userInfo = new UserVIPInfo();
+			userInfo.setId(uid);
+			addUserVIPInfo(userInfo);
 		}
 
-		if (userInfo.getState() != UserVIPInfo.STATE_INVALID) {
+		if (userInfo.getState() != UserVIPInfo.STATE_INVALID)
 			throw new UserVIPInfoException(2, "宸茬粡鐢宠杩�");
-		}
 
 		UserVIPInfo info = new UserVIPInfo();
 		info.setId(userInfo.getId());
@@ -337,7 +358,7 @@
 	
 	
 	@Override
-	public void InviteSeparate(Long workerId, Long bossId) {
+	public void inviteSeparate(Long workerId, Long bossId) {
 		if (workerId == null || bossId == null)
 			return;
 		
@@ -381,7 +402,7 @@
 			MsgOtherVIPDTO msgboss = new MsgOtherVIPDTO();
 			msgboss.setContent1(userInfo.getNickName() + workerId + "浜�" +TimeUtil.formatDateDot(userInviteSeparate.getCreateTime())+"鎴愬姛鍗囩骇鎴愪负瓒呯骇浼氬憳 ");
 			msgboss.setContent2("寰堥仐鎲撅紝浣犳湭鑳藉湪"+limitDays+"澶╁崌绾т负瓒呯骇浼氬憳 ");
-			msgboss.setContent3(" 宸蹭笌鍏朵互鍙婂叾鐩存帴绮変笣鑴辩浜嗛個璇峰叧绯�  ");
+			msgboss.setContent3("宸蹭笌鍏惰劚绂婚個璇峰叧绯�");
 			userOtherMsgNotificationService.teamSplitCallBoss(bossId, "濡傛湁鐤戦棶璇疯仈绯绘垜鐨�-浜哄伐瀹㈡湇", msgboss);
 		}
 	}

--
Gitblit v1.8.0