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/tlj/UserTaoLiJinRecordServiceImpl.java |   37 ++++++++++++++++++++++++++-----------
 1 files changed, 26 insertions(+), 11 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 a14a0d0..ce6ae73 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
@@ -533,16 +533,27 @@
 		if (amount.compareTo(tlj) > 0)
 			throw new UserTaoLiJinRecordException(1, "绾㈠寘浣欓涓嶈冻");
 		
-		
+		Long giveId = null;
 		Date nowDate = new Date();
-		
-		// 璧犻�佽褰�
-		UserTaoLiJinGiveRecord giveRecord = new UserTaoLiJinGiveRecord();
-		giveRecord.setAmount(amount);
-		giveRecord.setGiveUid(uid);
-		giveRecord.setState(UserTaoLiJinGiveRecord.STATE_INIT);
-		giveRecord.setGiveTime(nowDate);
-		userTaoLiJinGiveRecordService.insertSelective(giveRecord);
+		try {
+			String endDay = DateUtil.plusDay(Constant.GIVE_DAYS - 1, nowDate);
+			SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
+			Date endTime = format.parse(endDay);
+			
+			// 璧犻�佽褰�
+			UserTaoLiJinGiveRecord giveRecord = new UserTaoLiJinGiveRecord();
+			giveRecord.setAmount(amount);
+			giveRecord.setGiveUid(uid);
+			giveRecord.setState(UserTaoLiJinGiveRecord.STATE_INIT);
+			giveRecord.setGiveTime(nowDate);
+			giveRecord.setEndTime(endTime);
+			userTaoLiJinGiveRecordService.insertSelective(giveRecord);
+			
+			giveId = giveRecord.getId();
+		} catch (Exception e) {
+			LogHelper.errorDetailInfo(e);
+			throw new UserTaoLiJinRecordException(1, "璧犻�佽褰曞垱寤哄け璐�");
+		}
 		
 		String token = null;
 		for (int i = 0; i < 5; i++) {
@@ -551,12 +562,16 @@
 				long num = 10000 + (long) (Math.random() * 10000);
 				token = UserUtil.getInviteCode(num);
 				
+				String endDay = DateUtil.plusDay(Constant.TOKEN_DAYS - 1,nowDate);
+				SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
+				Date endTime = format.parse(endDay);
+				
 				TokenRecord tokenRecord = new TokenRecord();
 				tokenRecord.setUid(uid);
-				tokenRecord.setIdentify(giveRecord.getId()+""); // 璁板綍id
+				tokenRecord.setIdentify(giveId + ""); // 璁板綍id
 				tokenRecord.setType(TokenTypeEnum.taoLiJin);
 				tokenRecord.setStartTime(nowDate);
-				tokenRecord.setEndTime(DateUtil.plusDayDate(3, nowDate));
+				tokenRecord.setEndTime(endTime);
 				tokenRecord.setToken(token);
 				tokenRecord.setState(0);
 				tokenRecordService.insertSelective(tokenRecord);

--
Gitblit v1.8.0