From 8eacbd15374d01296926e87be3125731521000ee Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期五, 12 四月 2019 15:58:23 +0800
Subject: [PATCH] 手机号修改7天内禁止事件添加

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserExtraTaoBaoInfoServiceImpl.java |   93 +++++++++++++++++++++++++++++-----------------
 1 files changed, 58 insertions(+), 35 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserExtraTaoBaoInfoServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserExtraTaoBaoInfoServiceImpl.java
index ff1d4af..1ff0186 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserExtraTaoBaoInfoServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserExtraTaoBaoInfoServiceImpl.java
@@ -11,10 +11,12 @@
 import com.yeshi.fanli.dao.mybatis.user.UserExtraTaoBaoInfoMapper;
 import com.yeshi.fanli.entity.bus.user.ForbiddenUserIdentifyCode;
 import com.yeshi.fanli.entity.bus.user.ForbiddenUserIdentifyCode.ForbiddenUserIdentifyCodeTypeEnum;
+import com.yeshi.fanli.entity.bus.user.UserAccountBindingHistory;
 import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo;
 import com.yeshi.fanli.entity.bus.user.UserInfo;
 import com.yeshi.fanli.exception.user.UserExtraTaoBaoInfoException;
 import com.yeshi.fanli.service.inter.user.ForbiddenUserIdentifyCodeService;
+import com.yeshi.fanli.service.inter.user.UserAccountBindingHistoryService;
 import com.yeshi.fanli.service.inter.user.UserExtraTaoBaoInfoService;
 import com.yeshi.fanli.util.Constant;
 import com.yeshi.fanli.util.StringUtil;
@@ -24,25 +26,27 @@
 
 	@Resource
 	private UserExtraTaoBaoInfoMapper userExtraTaoBaoInfoMapper;
-	
+
 	@Resource
 	private ForbiddenUserIdentifyCodeService forbiddenUserIdentifyCodeService;
 	
+	@Resource
+	private UserAccountBindingHistoryService userAccountBindingHistoryService;
 
 	@Transactional
 	@Override
-	public void addRelationId(Long uid, String relationId, String taoBaoUid,String nickName, 
-			boolean valid) throws UserExtraTaoBaoInfoException{
-		
+	public void addRelationId(Long uid, String relationId, String taoBaoUid, String nickName, boolean valid)
+			throws UserExtraTaoBaoInfoException {
+
 		if (uid == null || StringUtil.isNullOrEmpty(relationId) || StringUtil.isNullOrEmpty(taoBaoUid)) {
 			throw new UserExtraTaoBaoInfoException(1, "浼犻�掑弬鏁颁负绌�");
 		}
-		
+
 		// 楠岃瘉taoBaoUid鏄惁琚皝绂�
-		if(validateTaoBaoUidForbidden(taoBaoUid)) {
+		if (validateTaoBaoUidForbidden(taoBaoUid)) {
 			throw new UserExtraTaoBaoInfoException(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC);
 		}
-				
+
 		UserExtraTaoBaoInfo taoBaoInfo = new UserExtraTaoBaoInfo();
 		taoBaoInfo.setUser(new UserInfo(uid));
 		taoBaoInfo.setTaoBaoNickName(nickName);
@@ -50,10 +54,10 @@
 		taoBaoInfo.setRelationId(relationId);
 		taoBaoInfo.setRelationValid(valid);
 		taoBaoInfo.setRelationUpdateTime(new Date());
-		
+
 		List<UserExtraTaoBaoInfo> list = userExtraTaoBaoInfoMapper.listByTaoBaoUid(taoBaoUid);
 		if (list == null || list.size() == 0) {
-			//鏂板
+			// 鏂板
 			taoBaoInfo.setCreateTime(new Date());
 			userExtraTaoBaoInfoMapper.insertSelective(taoBaoInfo);
 		} else {
@@ -61,7 +65,7 @@
 			taoBaoInfo.setId(list.get(0).getId());
 			taoBaoInfo.setUpdateTime(new Date());
 			userExtraTaoBaoInfoMapper.updateByPrimaryKeySelective(taoBaoInfo);
-			
+
 			// 娓呯┖澶氫綑宸茬粦瀹氭暟鎹�
 			if (list.size() > 1) {
 				for (int i = 1; i < list.size(); i++) {
@@ -73,18 +77,18 @@
 
 	@Transactional
 	@Override
-	public void addSpecialId(Long uid, String specialId, String taoBaoUid, String nickName,
-			boolean valid) throws UserExtraTaoBaoInfoException{
-		
+	public void addSpecialId(Long uid, String specialId, String taoBaoUid, String nickName, boolean valid)
+			throws UserExtraTaoBaoInfoException {
+
 		if (uid == null || StringUtil.isNullOrEmpty(specialId) || StringUtil.isNullOrEmpty(taoBaoUid)) {
 			throw new UserExtraTaoBaoInfoException(1, "浼犻�掑弬鏁颁负绌�");
 		}
-		
+
 		// 楠岃瘉taoBaoUid鏄惁琚皝绂�
-		if(validateTaoBaoUidForbidden(taoBaoUid)) {
+		if (validateTaoBaoUidForbidden(taoBaoUid)) {
 			throw new UserExtraTaoBaoInfoException(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC);
 		}
-				
+
 		UserExtraTaoBaoInfo taoBaoInfo = new UserExtraTaoBaoInfo();
 		taoBaoInfo.setUser(new UserInfo(uid));
 		taoBaoInfo.setTaoBaoNickName(nickName);
@@ -92,10 +96,10 @@
 		taoBaoInfo.setSpecialValid(valid);
 		taoBaoInfo.setSpecialId(specialId);
 		taoBaoInfo.setSpecialUpdateTime(new Date());
-		
+
 		List<UserExtraTaoBaoInfo> list = userExtraTaoBaoInfoMapper.listByTaoBaoUid(taoBaoUid);
 		if (list == null || list.size() == 0) {
-			//鏂板
+			// 鏂板
 			taoBaoInfo.setCreateTime(new Date());
 			userExtraTaoBaoInfoMapper.insertSelective(taoBaoInfo);
 		} else {
@@ -103,7 +107,7 @@
 			taoBaoInfo.setId(list.get(0).getId());
 			taoBaoInfo.setUpdateTime(new Date());
 			userExtraTaoBaoInfoMapper.updateByPrimaryKeySelective(taoBaoInfo);
-			
+
 			// 娓呯┖澶氫綑宸茬粦瀹氭暟鎹�
 			if (list.size() > 1) {
 				for (int i = 1; i < list.size(); i++) {
@@ -115,19 +119,19 @@
 
 	@Transactional
 	@Override
-	public void saveUserTaoBaoInfo(Long uid, String relationId, String specialId, String taoBaoUid,
-			String nickName, boolean valid) throws UserExtraTaoBaoInfoException {
-		
+	public void saveUserTaoBaoInfo(Long uid, String relationId, String specialId, String taoBaoUid, String nickName,
+			boolean valid) throws UserExtraTaoBaoInfoException {
+
 		if (uid == null || StringUtil.isNullOrEmpty(relationId) || StringUtil.isNullOrEmpty(specialId)
 				|| StringUtil.isNullOrEmpty(taoBaoUid)) {
 			throw new UserExtraTaoBaoInfoException(1, "浼犻�掑弬鏁伴儴鍒嗕负绌�");
 		}
-		
+
 		// 楠岃瘉taoBaoUid鏄惁琚皝绂�
-		if(validateTaoBaoUidForbidden(taoBaoUid)) {
+		if (validateTaoBaoUidForbidden(taoBaoUid)) {
 			throw new UserExtraTaoBaoInfoException(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC);
 		}
-		
+
 		UserExtraTaoBaoInfo taoBaoInfo = new UserExtraTaoBaoInfo();
 		taoBaoInfo.setTaoBaoUid(taoBaoUid);
 		taoBaoInfo.setTaoBaoNickName(nickName);
@@ -142,8 +146,12 @@
 		taoBaoInfo.setSpecialUpdateTime(new Date());
 
 		List<UserExtraTaoBaoInfo> list = userExtraTaoBaoInfoMapper.listByTaoBaoUid(taoBaoUid);
+
+		// 鍒ゆ柇涔嬪墠鐢ㄦ埛鏄惁缁戝畾杩�
+		UserExtraTaoBaoInfo info = userExtraTaoBaoInfoMapper.selectByUid(uid);
+
 		if (list == null || list.size() == 0) {
-			//鏂板
+			// 鏂板
 			taoBaoInfo.setCreateTime(new Date());
 			userExtraTaoBaoInfoMapper.insertSelective(taoBaoInfo);
 		} else {
@@ -151,7 +159,7 @@
 			taoBaoInfo.setId(list.get(0).getId());
 			taoBaoInfo.setUpdateTime(new Date());
 			userExtraTaoBaoInfoMapper.updateByPrimaryKeySelective(taoBaoInfo);
-			
+
 			// 娓呯┖澶氫綑宸茬粦瀹氭暟鎹�
 			if (list.size() > 1) {
 				for (int i = 1; i < list.size(); i++) {
@@ -159,43 +167,58 @@
 				}
 			}
 		}
+
+		// 鍔犲叆缁戝畾璁板綍
+		UserAccountBindingHistory history = new UserAccountBindingHistory();
+		history.setContent(taoBaoUid);
+		history.setType(UserAccountBindingHistory.TYPE_TB);
+		history.setUid(uid);
+
+		// 涔嬪墠宸茬粡缁戝畾鐢佃瘽鍙风爜
+		if (info!=null)
+			history.setFirst(false);
+		else
+			history.setFirst(true);
+		userAccountBindingHistoryService.addUserAccountBindingHistory(history);
 	}
 
 	/**
-	 * 楠岃瘉taoBaoUid  鏄惁琚皝
+	 * 楠岃瘉taoBaoUid 鏄惁琚皝
+	 * 
 	 * @param taoBaoUid
 	 * @return
 	 */
 	public boolean validateTaoBaoUidForbidden(String taoBaoUid) {
 		boolean validate = false;
-		ForbiddenUserIdentifyCode identifyCode = forbiddenUserIdentifyCodeService.listByTypeAndIdentifyCode(
-				ForbiddenUserIdentifyCodeTypeEnum.taobaoUid, taoBaoUid);
+		ForbiddenUserIdentifyCode identifyCode = forbiddenUserIdentifyCodeService
+				.listByTypeAndIdentifyCode(ForbiddenUserIdentifyCodeTypeEnum.taobaoUid, taoBaoUid);
 		// 璐﹀彿琚皝
 		if (identifyCode != null && identifyCode.getEffective() != null && identifyCode.getEffective()) {
 			validate = true;
 		}
 		return validate;
 	}
-	
+
 	/**
 	 * 娓呯┖澶氫綑缁戝畾娣樺疂璐﹀彿淇℃伅
+	 * 
 	 * @param otherInfo
 	 */
-	public void clearTaoBaoInfo(UserExtraTaoBaoInfo otherInfo ) {
+	public void clearTaoBaoInfo(UserExtraTaoBaoInfo otherInfo) {
 		otherInfo.setUser(null);
 		otherInfo.setTaoBaoUid(null);
 		otherInfo.setTaoBaoNickName(null);
-		
+
 		otherInfo.setRelationValid(null);
 		otherInfo.setRelationId(null);
 		otherInfo.setRelationUpdateTime(null);
-		
+
 		otherInfo.setSpecialValid(null);
 		otherInfo.setSpecialId(null);
 		otherInfo.setSpecialUpdateTime(new Date());
 		userExtraTaoBaoInfoMapper.updateByPrimaryKey(otherInfo);
 	}
-	
+
 	@Override
 	public UserExtraTaoBaoInfo getByUid(Long uid) {
 		return userExtraTaoBaoInfoMapper.selectByUid(uid);

--
Gitblit v1.8.0