From 3672aec5bf6c2c6da4cb7ab4a8b5f314a22c5831 Mon Sep 17 00:00:00 2001
From: yujian <yujian@123.com>
Date: 星期一, 19 八月 2019 17:32:00 +0800
Subject: [PATCH] 退回淘礼金

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/user/TokenRecordServiceImpl.java |   53 +++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 49 insertions(+), 4 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/TokenRecordServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/TokenRecordServiceImpl.java
index bad3925..8370794 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/TokenRecordServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/TokenRecordServiceImpl.java
@@ -72,6 +72,7 @@
 	private UserOtherMsgNotificationService userOtherMsgNotificationService;
 	
 	
+	
 	@Override
 	public void insertSelective(TokenRecord record) {
 		record.setCreateTime(new Date());
@@ -125,7 +126,7 @@
 
 		TokenVO tokenVO = new TokenVO();
 		tokenVO.setToken(token);
-		tokenVO.setNickName(nickName);
+		tokenVO.setNickName(nickName + "璧犻��");
 		tokenVO.setPortrait(portrait);
 
 		String identify = rokenRecord.getIdentify();
@@ -157,6 +158,7 @@
 						throw new TokenRecordException(1001, "娓╅Θ鎻愮ず锛孾鍏嶅崟鍒竇闇�瑕佺櫥褰曞悗棰嗗彇");
 
 					state = true;
+					tokenVO.setAmount(1);
 					UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
 					if (userInfoExtra == null || StringUtil.isNullOrEmpty(userInfoExtra.getInviteCode())) {
 						tips.add("纭棰嗗彇鍚庯紝浣犲皢鎴愪负璧犻�佽�呯殑涓�绾ч槦鍛橈紱");
@@ -191,6 +193,7 @@
 						throw new TokenRecordException(1001, "娓╅Θ鎻愮ず锛孾杩斿埄濂栧姳鍒竇闇�瑕佺櫥褰曞悗棰嗗彇");
 
 					state = true;
+					tokenVO.setAmount(1);
 					UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
 					if (userInfoExtra == null || StringUtil.isNullOrEmpty(userInfoExtra.getInviteCode())) {
 						tips.add("纭棰嗗彇鍚庯紝浣犲皢鎴愪负璧犻�佽�呯殑涓�绾ч槦鍛橈紱");
@@ -216,7 +219,10 @@
 				if (uid == null || uid <= 0)
 					throw new TokenRecordException(1001, "娓╅Θ鎻愮ず锛孾鎺ㄥ箍绾㈠寘]闇�瑕佺櫥褰曞悗棰嗗彇");
 
+				BigDecimal amount = giveRecord.getAmount();
+				
 				state = true;
+				tokenVO.setAmount(Integer.parseInt(amount.setScale(0).toString()));
 				UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
 				if (userInfoExtra == null || StringUtil.isNullOrEmpty(userInfoExtra.getInviteCode())) {
 					tips.add("纭棰嗗彇鍚庯紝浣犲皢鎴愪负璧犻�佽�呯殑涓�绾ч槦鍛橈紱");
@@ -238,7 +244,7 @@
 	}
 
 	@Override
-	public void receiveToken(String token, Long uid) throws TokenRecordException {
+	public String receiveToken(String token, Long uid) throws TokenRecordException {
 		if (uid == null || uid <= 0)
 			throw new TokenRecordException(1, "鐢ㄦ埛鏈櫥褰�");
 
@@ -268,6 +274,8 @@
 		if (userInfoExtra == null) 
 			throw new TokenRecordException(1, "鐢ㄦ埛淇℃伅缂哄け");
 			
+		
+		String msg = "棰嗗彇鎴愬姛";
 		TokenTypeEnum tokenType = rokenRecord.getType();
 		if (tokenType == TokenTypeEnum.freeCoupon) {
 			long couponId = Long.parseLong(identify);
@@ -312,6 +320,7 @@
 				giveRecord.setReceiveTime(new Date());
 				userSystemCouponGiveRecordService.updateByPrimaryKeySelective(giveRecord);
 				
+				msg = "棰嗗彇鎴愬姛[鍏嶅崟鍒竇鎴愬姛锛岃鍒癧鎴戠殑-绂忓埄涓績]涓煡鐪�";
 				// 娑堟伅 + 闃熷憳
 				executor.execute(new Runnable() {
 					@Override
@@ -384,6 +393,7 @@
 				giveRecord.setReceiveTime(new Date());
 				userSystemCouponGiveRecordService.updateByPrimaryKeySelective(giveRecord);
 				
+				msg = "棰嗗彇鎴愬姛[杩斿埄濂栧姳鍒竇鎴愬姛锛岃鍒癧鎴戠殑-绂忓埄涓績]涓煡鐪�";
 				// 娑堟伅 + 闃熷憳
 				executor.execute(new Runnable() {
 					@Override
@@ -394,11 +404,16 @@
 						if (addTeam)
 							beiZhu = "棰嗗彇浜哄凡缁忔垚涓轰綘鐨勪竴绾ч槦鍛�";
 						
+						String userName = "鏃�";
+						UserInfo user = userInfoService.selectByPKey(uid);
+						if (user != null && !StringUtil.isNullOrEmpty(user.getNickName()))
+							userName = user.getNickName();
+						
 						MsgOtherGiveContentDTO msgOther = new MsgOtherGiveContentDTO();
 						msgOther.setType(MsgOtherGiveContentDTO.TYEP_COUPON);
 						msgOther.setTitle("璧犻�佸鍔卞埜");
 						msgOther.setGiveType("浣犺禒閫佺殑濂栧姳鍒歌鎴愬姛棰嗗彇");
-						msgOther.setReceiveInfo("鏄电О:[鏄电О鏄电О鏄电О/鏃燷ID:[854245]");
+						msgOther.setReceiveInfo("鏄电О:  " + userName +" ID:" + uid);
 						msgOther.setGiveTime(sd.format(giveRecord.getGiveTime()));
 						msgOther.setReceiveTime(sd.format(new Date()));
 						userOtherMsgNotificationService.tokenGiveMsg(giveUid, beiZhu, msgOther);
@@ -431,6 +446,35 @@
 					updateRecord.setReceiveUid(uid);
 					updateRecord.setState(UserTaoLiJinGiveRecord.STATE_RECEIVE);
 					userTaoLiJinGiveRecordService.updateByPrimaryKeySelective(updateRecord);
+					
+					msg = "棰嗗彇鎴愬姛[鎺ㄥ箍绾㈠寘]鎴愬姛锛岃鍒癧鎴戠殑-鎺ㄥ箍绾㈠寘]涓煡鐪�";
+					
+					// 娑堟伅 + 闃熷憳
+					executor.execute(new Runnable() {
+						@Override
+						public void run() {
+							SimpleDateFormat sd = new SimpleDateFormat("yyyy.MM.dd HH.mm");
+							boolean addTeam = addInviteTeam(uid, giveUid, userInfoExtra);
+							String beiZhu = "鏃�";
+							if (addTeam)
+								beiZhu = "棰嗗彇浜哄凡缁忔垚涓轰綘鐨勪竴绾ч槦鍛�";
+							
+							String userName = "鏃�";
+							UserInfo user = userInfoService.selectByPKey(uid);
+							if (user != null && !StringUtil.isNullOrEmpty(user.getNickName()))
+								userName = user.getNickName();
+							
+							MsgOtherGiveContentDTO msgOther = new MsgOtherGiveContentDTO();
+							msgOther.setType(MsgOtherGiveContentDTO.TYEP_COUPON);
+							msgOther.setTitle("璧犻�佹帹骞跨孩鍖�");
+							msgOther.setGiveType("浣犺禒閫佺殑鎺ㄥ箍绾㈠寘琚垚鍔熼鍙�");
+							msgOther.setReceiveInfo("鏄电О:  " + userName +" ID:" + uid);
+							msgOther.setGiveTime(sd.format(giveRecord.getGiveTime()));
+							msgOther.setReceiveTime(sd.format(new Date()));
+							userOtherMsgNotificationService.tokenGiveMsg(giveUid, beiZhu, msgOther);
+						}
+					});
+					
 				} catch (UserTaoLiJinOriginException e) {
 					e.printStackTrace();
 				}
@@ -438,7 +482,8 @@
 		} else {
 			throw new TokenRecordException(1, "鏃犲搴旂被鍨�");
 		}
-
+		
+		return msg;
 	}
 	
 	

--
Gitblit v1.8.0