From d1bcc87e41d8d176ce58ee9e27a17ec93d0d7cb2 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期五, 23 八月 2019 11:59:18 +0800
Subject: [PATCH] Merge branch 'mater-1.6.0' into div

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/user/TokenRecordServiceImpl.java |   32 +++++++++++++++++++++++++-------
 1 files changed, 25 insertions(+), 7 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 927da3c..c9d8e3c 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
@@ -38,6 +38,7 @@
 import com.yeshi.fanli.service.inter.user.UserSystemCouponService;
 import com.yeshi.fanli.util.Constant;
 import com.yeshi.fanli.util.StringUtil;
+import com.yeshi.fanli.util.TokenUtil;
 import com.yeshi.fanli.vo.msg.TokenVO;
 
 @Service
@@ -83,6 +84,12 @@
 		tokenRecordMapper.insertSelective(record);
 	}
 
+	
+	@Override
+	public void updateByPrimaryKeySelective(TokenRecord record) {
+		tokenRecordMapper.updateByPrimaryKeySelective(record);
+	}
+	
 	@Override
 	public TokenRecord getNearByTypeAndIdentify(String type, String identify) {
 		return tokenRecordMapper.getNearByTypeAndIdentify(type, identify);
@@ -90,12 +97,19 @@
 
 	@Override
 	public TokenVO discernToken(String token, Long uid) throws TokenRecordException {
-
-		// TODO token 楠岃瘉
-		TokenRecord rokenRecord = tokenRecordMapper.getByToken(token);
+		// 瑙f瀽鍙d护
+		String parseToken = TokenUtil.parseToken(token);
+		if (StringUtil.isNullOrEmpty(parseToken)) 
+			throw new TokenRecordException(1, "鏈彂鐜板彛浠�");
+		
+		TokenRecord rokenRecord = tokenRecordMapper.getByToken(parseToken);
 		if (rokenRecord == null)
 			throw new TokenRecordException(1, "鍙d护涓嶅瓨鍦�");
 
+		Long uidToken = rokenRecord.getUid();
+		if (uid != null && uidToken != null && uid.longValue() == uidToken.longValue())
+			throw new TokenRecordException(1, "涓嶈兘鑷繁璧犻�佺粰鑷繁");
+		
 		Date now = new Date();
 		Date endTimeToken = rokenRecord.getEndTime();
 		Integer stateTtoken = rokenRecord.getState();
@@ -242,7 +256,7 @@
 		
 		TokenVO tokenVO = new TokenVO();
 		tokenVO.setAmount(num);
-		tokenVO.setToken(token);
+		tokenVO.setToken(parseToken);
 		tokenVO.setNickName(nickName + "璧犻��");
 		tokenVO.setPortrait(portrait);
 		tokenVO.setTips(tips);
@@ -264,7 +278,11 @@
 		TokenRecord rokenRecord = tokenRecordMapper.getByToken(token);
 		if (rokenRecord == null)
 			throw new TokenRecordException(1, "鍙d护宸插け鏁�");
-
+		
+		Long uidToken = rokenRecord.getUid();
+		if (uidToken != null && uid.longValue() == uidToken.longValue())
+			throw new TokenRecordException(1, "涓嶈兘鑷繁璧犻�佺粰鑷繁");
+		
 		Date now = new Date();
 		Date endTimeToken = rokenRecord.getEndTime();
 		if (endTimeToken != null && endTimeToken.getTime() < now.getTime())
@@ -355,7 +373,7 @@
 					msgOther.setType(MsgOtherGiveContentDTO.TYEP_COUPON);
 					msgOther.setTitle("璧犻�佸厤鍗曞埜");
 					msgOther.setGiveType("浣犺禒閫佺殑鍏嶅崟鍒歌鎴愬姛棰嗗彇");
-					msgOther.setReceiveInfo("鏄电О:  " + userName + " ID:" + uid);
+					msgOther.setReceiveInfo("鏄电О: 锛�" + userName + " ID锛�" + uid);
 					msgOther.setGiveTime(sd.format(giveRecord.getGiveTime()));
 					msgOther.setReceiveTime(sd.format(new Date()));
 					userOtherMsgNotificationService.tokenGiveMsg(giveUid, beiZhu, msgOther);
@@ -477,7 +495,7 @@
 							userName = user.getNickName();
 
 						MsgOtherGiveContentDTO msgOther = new MsgOtherGiveContentDTO();
-						msgOther.setType(MsgOtherGiveContentDTO.TYEP_COUPON);
+						msgOther.setType(MsgOtherGiveContentDTO.TYEP_TLJ);
 						msgOther.setTitle("璧犻�佹帹骞跨孩鍖�");
 						msgOther.setGiveType("浣犺禒閫佺殑鎺ㄥ箍绾㈠寘琚垚鍔熼鍙�");
 						msgOther.setReceiveInfo("鏄电О:  " + userName + " ID:" + uid);

--
Gitblit v1.8.0