From 972d3bc71115ec977dccf835fbcd148da3bcc86c Mon Sep 17 00:00:00 2001
From: yujian <yujian@123.com>
Date: 星期二, 03 九月 2019 16:41:49 +0800
Subject: [PATCH] 统计可用的免单券数量-countUsableFreeCouponForBuy

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserInfoServiceImpl.java |  110 ++++++++++++++----------------------------------------
 1 files changed, 29 insertions(+), 81 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserInfoServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserInfoServiceImpl.java
index 0f5ba56..04916dd 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserInfoServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserInfoServiceImpl.java
@@ -20,6 +20,7 @@
 import org.hibernate.Query;
 import org.hibernate.SQLQuery;
 import org.hibernate.Session;
+import org.springframework.context.annotation.Lazy;
 import org.springframework.core.task.TaskExecutor;
 import org.springframework.orm.hibernate4.HibernateCallback;
 import org.springframework.stereotype.Service;
@@ -40,15 +41,13 @@
 import com.yeshi.fanli.dao.mybatis.share.ShareMapper;
 import com.yeshi.fanli.dao.user.UserInfoDao;
 import com.yeshi.fanli.entity.bus.user.BindingAccount;
-import com.yeshi.fanli.entity.bus.user.ForbiddenUserIdentifyCode;
-import com.yeshi.fanli.entity.bus.user.ForbiddenUserIdentifyCode.ForbiddenUserIdentifyCodeTypeEnum;
 import com.yeshi.fanli.entity.bus.user.InviteUser;
 import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo;
 import com.yeshi.fanli.entity.bus.user.UserInfo;
+import com.yeshi.fanli.entity.bus.user.UserInfoModifyRecord.ModifyTypeEnum;
 import com.yeshi.fanli.entity.bus.user.WeiXinUser;
 import com.yeshi.fanli.entity.system.BusinessSystem;
-import com.yeshi.fanli.exception.ThreeSaleException;
-import com.yeshi.fanli.exception.user.ForbiddenUserIdentifyCodeException;
+import com.yeshi.fanli.exception.user.ThreeSaleException;
 import com.yeshi.fanli.exception.user.UserInfoException;
 import com.yeshi.fanli.log.LogHelper;
 import com.yeshi.fanli.service.inter.config.ConfigService;
@@ -60,6 +59,7 @@
 import com.yeshi.fanli.service.inter.user.SpreadUserImgService;
 import com.yeshi.fanli.service.inter.user.UserActiveLogService;
 import com.yeshi.fanli.service.inter.user.UserExtraTaoBaoInfoService;
+import com.yeshi.fanli.service.inter.user.UserInfoModifyRecordService;
 import com.yeshi.fanli.service.inter.user.UserInfoService;
 import com.yeshi.fanli.service.inter.user.UserRankService;
 import com.yeshi.fanli.util.Constant;
@@ -132,6 +132,11 @@
 
 	@Resource
 	private BindingAccountService bindingAccountService;
+	
+	@Lazy
+	@Resource
+	private UserInfoModifyRecordService userInfoModifyRecordService;
+	
 
 	public UserInfo getUserByLoginTypeAndOpenId(int loginType, String openid, String appid) {
 		List<UserInfo> list = null;
@@ -726,17 +731,23 @@
 			userInfoVO.setLastLoginTime(null);
 		}
 
-		/*
-		 * 鏄剧ず鐢ㄦ埛寰俊 娣樺疂 鑰佺増鏈瓨鍦� String wxUnionId = userInfoVO.getWxUnionId(); if
-		 * (wxUnionId == null || wxUnionId.trim().length() == 0) {
-		 * userInfoVO.setWxName(null); }
-		 * 
-		 * String taoBaoUid = userInfoVO.getTaoBaoUid(); if (taoBaoUid == null
-		 * || taoBaoUid.trim().length() == 0) { userInfoVO.setTbName(null); }
-		 */
+		
+		 //鏄剧ず鐢ㄦ埛寰俊 娣樺疂 鑰佺増鏈瓨鍦� 
+		 String wxUnionId = userInfoVO.getWxUnionId(); 
+		 if (wxUnionId == null || wxUnionId.trim().length() == 0) {
+			 userInfoVO.setWxName(null); 
+		 }
+		 
+		 // 鏄惁缁戝畾鏀粯瀹濓紙璐拱 +  鍒嗕韩鏉冮檺锛�
+		 String taoBaoUid = userInfoVO.getTaoBaoUid(); 
+		 String tbSpecialId = userInfoVO.getTbSpecialId();
+		 String tbRelationId = userInfoVO.getTbRelationId();
+		 if (StringUtil.isNullOrEmpty(taoBaoUid) || StringUtil.isNullOrEmpty(tbSpecialId) || StringUtil.isNullOrEmpty(tbRelationId)) { 
+		 	userInfoVO.setTbName(null); 
+		 	userInfoVO.setTaoBaoUid(null); 
+		 }
 
 		Long uid = userInfoVO.getId();
-
 		/* 缁戝畾鏀舵璐﹀彿淇℃伅 */
 		List<BindingAccount> account = bindingAccountMapper.selectByUid(uid);
 		if (account != null && account.size() > 0) {
@@ -890,8 +901,8 @@
 			throw new UserInfoException(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC);
 		}
 
-		if (userInfo.getState() != UserInfo.STATE_NORMAL) {
-			throw new UserInfoException(1, "鐢ㄦ埛涓嶅瓨鍦�");
+		if (userInfo.getState() == UserInfo.STATE_DELETE || userInfo.getState() == UserInfo.STATE_DELETE_OUT_OF_DATE) {
+			throw new UserInfoException(Constant.CODE_FORBIDDEN_USER, "甯愭埛宸茶鍒犻櫎锛岃閲嶆柊鐧诲綍");
 		}
 
 		// 娣樺疂鏄电О 缁勭粐
@@ -965,7 +976,9 @@
 		if (!StringUtil.isNullOrEmpty(portrait) && portrait.contains("/img/user/")) {
 			COSManager.getInstance().deleteFile(portrait);
 		}
-
+		
+		userInfoModifyRecordService.addModifyRecord(uid, ModifyTypeEnum.portrait, fileLink);
+		
 		executor.execute(new Runnable() {
 			@Override
 			public void run() {
@@ -994,69 +1007,4 @@
 		userInfoMapper.updateByPrimaryKeySelective(userInfo);
 	}
 
-	@Override
-	public void forbiddenUser(Long uid, String reason) {
-		UserInfo currentInfo = userInfoService.selectByPKey(uid);
-		if (currentInfo == null) {
-			return;
-		}
-		if (currentInfo.getState() != UserInfo.STATE_NORMAL) {
-			return;
-		}
-
-		currentInfo.setState(UserInfo.STATE_FORBIDDEN);
-		currentInfo.setStateDesc(reason);
-		userInfoService.updateByPrimaryKeySelective(currentInfo);
-
-		// 鍔犲叆灏佺鐨勮处鍙峰垪琛�
-		ForbiddenUserIdentifyCode forbiddenUserIdentifyCode = new ForbiddenUserIdentifyCode();
-		forbiddenUserIdentifyCode.setType(ForbiddenUserIdentifyCodeTypeEnum.wxUnionId);
-		forbiddenUserIdentifyCode.setIdentifyCode(currentInfo.getWxUnionId());
-		forbiddenUserIdentifyCode.setBeiZhu(currentInfo.getWxName());
-		try {
-			forbiddenUserIdentifyCodeService.forbiddenIdentifyCode(forbiddenUserIdentifyCode);
-		} catch (ForbiddenUserIdentifyCodeException e) {
-			e.printStackTrace();
-		}
-
-		// 鐢佃瘽鍙风爜
-		forbiddenUserIdentifyCode = new ForbiddenUserIdentifyCode();
-		forbiddenUserIdentifyCode.setType(ForbiddenUserIdentifyCodeTypeEnum.phone);
-		forbiddenUserIdentifyCode.setIdentifyCode(currentInfo.getPhone());
-		try {
-			forbiddenUserIdentifyCodeService.forbiddenIdentifyCode(forbiddenUserIdentifyCode);
-		} catch (ForbiddenUserIdentifyCodeException e) {
-			e.printStackTrace();
-		}
-
-		// 娣樺疂
-		UserExtraTaoBaoInfo taoBao = userExtraTaoBaoInfoService.getByUid(uid);
-		if (taoBao != null && !StringUtil.isNullOrEmpty(taoBao.getTaoBaoUid())) {
-			forbiddenUserIdentifyCode = new ForbiddenUserIdentifyCode();
-			forbiddenUserIdentifyCode.setType(ForbiddenUserIdentifyCodeTypeEnum.taobaoUid);
-			forbiddenUserIdentifyCode.setIdentifyCode(taoBao.getTaoBaoUid());
-			try {
-				forbiddenUserIdentifyCodeService.forbiddenIdentifyCode(forbiddenUserIdentifyCode);
-			} catch (ForbiddenUserIdentifyCodeException e) {
-				e.printStackTrace();
-			}
-		}
-
-		// 鏌ヨ鏀粯瀹濈粦瀹�
-		List<BindingAccount> list = bindingAccountService.getBindingAccountByUid(uid);
-		if (list != null) {
-			for (BindingAccount ba : list) {
-				forbiddenUserIdentifyCode = new ForbiddenUserIdentifyCode();
-				forbiddenUserIdentifyCode.setType(ForbiddenUserIdentifyCodeTypeEnum.alipayAccount);
-				forbiddenUserIdentifyCode.setIdentifyCode(ba.getAccount());
-				forbiddenUserIdentifyCode.setBeiZhu(ba.getName());
-				try {
-					forbiddenUserIdentifyCodeService.forbiddenIdentifyCode(forbiddenUserIdentifyCode);
-				} catch (ForbiddenUserIdentifyCodeException e) {
-					e.printStackTrace();
-				}
-			}
-		}
-
-	}
 }

--
Gitblit v1.8.0