From 54b0dd1b6f8230799b0b4490f8b39afdd53a4e4c Mon Sep 17 00:00:00 2001
From: yujian <yujian@123.com>
Date: 星期三, 21 八月 2019 09:30:57 +0800
Subject: [PATCH] 积分明细

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/tlj/UserTaoLiJinRecordServiceImpl.java |   67 +++++++++++----------------------
 1 files changed, 23 insertions(+), 44 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/tlj/UserTaoLiJinRecordServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/tlj/UserTaoLiJinRecordServiceImpl.java
index 15abadd..673415e 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/tlj/UserTaoLiJinRecordServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/tlj/UserTaoLiJinRecordServiceImpl.java
@@ -53,7 +53,7 @@
 import com.yeshi.fanli.util.RedisManager;
 import com.yeshi.fanli.util.StringUtil;
 import com.yeshi.fanli.util.TaoBaoConstant;
-import com.yeshi.fanli.util.account.UserUtil;
+import com.yeshi.fanli.util.TokenUtil;
 import com.yeshi.fanli.util.factory.CommonGoodsFactory;
 import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
 import com.yeshi.fanli.util.taobao.TaoLiJinUtil;
@@ -533,53 +533,32 @@
 		if (amount.compareTo(tlj) > 0)
 			throw new UserTaoLiJinRecordException(1, "绾㈠寘浣欓涓嶈冻");
 		
-		Long giveId = null;
 		Date nowDate = new Date();
-		try {
-			// 璧犻�佽褰�
-			UserTaoLiJinGiveRecord giveRecord = new UserTaoLiJinGiveRecord();
-			giveRecord.setAmount(amount);
-			giveRecord.setGiveUid(uid);
-			giveRecord.setState(UserTaoLiJinGiveRecord.STATE_INIT);
-			giveRecord.setGiveTime(nowDate);
-			giveRecord.setEndTime(DateUtil.plusDayDate(Constant.GIVE_DAYS, new Date()));
-			userTaoLiJinGiveRecordService.insertSelective(giveRecord);
-			
-			giveId = giveRecord.getId();
-		} catch (Exception e) {
-			LogHelper.errorDetailInfo(e);
-			throw new UserTaoLiJinRecordException(1, "璧犻�佽褰曞垱寤哄け璐�");
-		}
+		// 璧犻�佽褰�
+		UserTaoLiJinGiveRecord giveRecord = new UserTaoLiJinGiveRecord();
+		giveRecord.setAmount(amount);
+		giveRecord.setGiveUid(uid);
+		giveRecord.setState(UserTaoLiJinGiveRecord.STATE_INIT);
+		giveRecord.setGiveTime(nowDate);
+		giveRecord.setEndTime(DateUtil.plusDayDate(Constant.GIVE_DAYS, new Date()));
+		userTaoLiJinGiveRecordService.insertSelective(giveRecord);
 		
-		String token = null;
-		for (int i = 0; i < 5; i++) {
-			try {
-				// TODO 鍙d护鐢熸垚瑙勫垯寰呭畾
-				long num = 10000 + (long) (Math.random() * 10000);
-				token = UserUtil.getInviteCode(num);
-				
-				TokenRecord tokenRecord = new TokenRecord();
-				tokenRecord.setUid(uid);
-				tokenRecord.setIdentify(giveId + ""); // 璁板綍id
-				tokenRecord.setType(TokenTypeEnum.taoLiJin);
-				tokenRecord.setStartTime(nowDate);
-				tokenRecord.setEndTime(DateUtil.plusDayDate(Constant.TOKEN_DAYS, new Date()));
-				tokenRecord.setToken(token);
-				tokenRecord.setState(0);
-				tokenRecordService.insertSelective(tokenRecord);
-			} catch (Exception e) {
-				LogHelper.errorDetailInfo(e);
-				token = null;
-			}
-			
-			if(!StringUtil.isNullOrEmpty(token)) {
-				break;
-			}
-		}
+		// 鍙d护璁板綍
+		TokenRecord tokenRecord = new TokenRecord();
+		tokenRecord.setUid(uid);
+		tokenRecord.setIdentify(giveRecord.getId() + "");
+		tokenRecord.setType(TokenTypeEnum.taoLiJin);
+		tokenRecord.setStartTime(nowDate);
+		tokenRecord.setEndTime(DateUtil.plusDayDate(Constant.TOKEN_DAYS, new Date()));
+		tokenRecord.setState(0);
+		tokenRecordService.insertSelective(tokenRecord);
 		
-		if(StringUtil.isNullOrEmpty(token))
-			throw new UserTaoLiJinRecordException(1, "鍙d护鐢熸垚澶辫触");
+		// 鍒涘缓鍙d护
+		String token = TokenUtil.createToken(tokenRecord.getId());
+		tokenRecord.setToken(token);
+		tokenRecordService.updateByPrimaryKeySelective(tokenRecord);
 		
+		// 鏇存柊浣欓
 		UserMoneyExtra updateExtra = new UserMoneyExtra();
 		updateExtra.setUid(uid);
 		updateExtra.setTlj(MoneyBigDecimalUtil.sub(tlj, amount));

--
Gitblit v1.8.0