From d8fc7a24f8a2be1bc62aa38083a9f3dd3fbb3dc4 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期四, 21 二月 2019 17:40:55 +0800
Subject: [PATCH] 封禁用户相关操作

---
 fanli/src/main/java/com/yeshi/fanli/controller/client/UserAccountController.java |   94 ++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 88 insertions(+), 6 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/UserAccountController.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/UserAccountController.java
index 49ecb5b..b68335b 100644
--- a/fanli/src/main/java/com/yeshi/fanli/controller/client/UserAccountController.java
+++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/UserAccountController.java
@@ -15,6 +15,8 @@
 import com.alipay.api.AlipayApiException;
 import com.yeshi.fanli.entity.accept.AcceptData;
 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.LoginResult;
 import com.yeshi.fanli.entity.bus.user.SMSHistory;
 import com.yeshi.fanli.entity.bus.user.UserInfo;
@@ -44,6 +46,7 @@
 import com.yeshi.fanli.service.inter.user.AccountMessageService;
 import com.yeshi.fanli.service.inter.user.BindingAccountService;
 import com.yeshi.fanli.service.inter.user.ExtractService;
+import com.yeshi.fanli.service.inter.user.ForbiddenUserIdentifyCodeService;
 import com.yeshi.fanli.service.inter.user.ShamUserService;
 import com.yeshi.fanli.service.inter.user.SpreadUserImgService;
 import com.yeshi.fanli.service.inter.user.TBPidService;
@@ -138,6 +141,9 @@
 	@Resource
 	private UserShareGoodsRecordService userShareGoodsRecordService;
 
+	@Resource
+	private ForbiddenUserIdentifyCodeService forbiddenUserIdentifyCodeService;
+
 	private static final String PASSWORD_MAX_ERROR = "password_max_error";
 	private static final String EXTRACT_MIN_MONEY = "extract_min_money";
 	private static final String EXTRACT_MAX_MONEY = "extract_max_money";
@@ -176,6 +182,7 @@
 			redisManager.clearSMSFrequencyLimit(phone, SMSHistory.TYPE_LOGIN);
 		}
 
+		UserInfo tbUserInfo = new UserInfo();
 		if (!StringUtil.isNullOrEmpty(tbSession)) {
 			try {
 				tbSession = DESUtil.decode(tbSession.replace("\n", ""), StringUtil.getBase64String("YeShiFANLI889*+"),
@@ -187,12 +194,14 @@
 			tbOpenid = tbs.optString("openId");
 			tbNickName = tbs.optString("nick");
 			tbPortrait = tbs.optString("avatarUrl");
+			// 娣樺疂ID
+			tbUserInfo.setTaoBaoUid(tbs.optString("taobao_user_id"));
 		}
 
-		UserInfo tbUserInfo = new UserInfo();
 		tbUserInfo.setOpenid(tbOpenid);
 		tbUserInfo.setTbName(tbNickName);
 		tbUserInfo.setTbPic(tbPortrait);
+
 		try {
 			LoginResult result = userAccountService.login(request, first, system.getAppid(), code, phone, tbUserInfo,
 					wxinstall, loginType);
@@ -412,15 +421,32 @@
 
 		String oldVCode = redisManager.getSMSVCode(phone, SMSHistory.TYPE_LOGIN);
 
-		if (!vcode.equalsIgnoreCase(oldVCode)) {
-			out.print(JsonUtil.loadFalseResult(90001, "楠岃瘉鐮侀敊璇�"));
-			return;
+		if (Constant.IS_OUTNET) {
+			if (!vcode.equalsIgnoreCase(oldVCode)) {
+				out.print(JsonUtil.loadFalseResult(90001, "楠岃瘉鐮侀敊璇�"));
+				return;
+			}
+			redisManager.clearSMSFrequencyLimit(phone, SMSHistory.TYPE_LOGIN);
 		}
-		redisManager.clearSMSFrequencyLimit(phone, SMSHistory.TYPE_LOGIN);
-
 		try {
 			userAccountService.bindPhone(uid, phone);
 			UserInfo user = userInfoService.getUserByIdWithMybatis(uid);
+			// 鍒ゆ柇鐢佃瘽鍙风爜鏄惁宸茬粡灏佺
+			ForbiddenUserIdentifyCode ic = forbiddenUserIdentifyCodeService
+					.listByTypeAndIdentifyCode(ForbiddenUserIdentifyCodeTypeEnum.phone, phone);
+			if (ic != null && ic.getEffective() != null && ic.getEffective()) {
+				out.print(JsonUtil.loadFalseResult(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC));
+				// 灏佺鐢ㄦ埛
+				// 灏佺缁戝畾鐨勬甯哥敤鎴�
+				if (user != null && user.getState() != null && user.getState() == UserInfo.STATE_NORMAL) {
+					UserInfo update = new UserInfo(uid);
+					update.setState(UserInfo.STATE_FORBIDDEN);
+					update.setStateDesc("缁戝畾琚皝绂佺殑鐢佃瘽鍙风爜琚皝绂�");
+					userInfoService.updateByPrimaryKeySelective(update);
+				}
+				return;
+			}
+
 			JSONObject data = new JSONObject();
 			data.put("user", UserUtil.filterForClientUser(user));
 			out.print(JsonUtil.loadTrueResult(data));
@@ -482,6 +508,8 @@
 			return;
 		}
 
+		String taoBaoUid = "";
+
 		if (!StringUtil.isNullOrEmpty(tbSession)) {
 			try {
 				tbSession = DESUtil.decode(tbSession.replace("\n", ""), StringUtil.getBase64String("YeShiFANLI889*+"),
@@ -493,11 +521,32 @@
 			tbOpenid = session.optString("openId");
 			tbNickName = session.optString("nick");
 			tbPortrait = session.optString("avatarUrl");
+			taoBaoUid = session.optString("taobao_user_id");
 		}
 
 		try {
 			userAccountService.bindTaoBao(uid, tbOpenid, tbNickName, tbPortrait);
 			UserInfo user = userInfoService.getUserByIdWithMybatis(uid);
+
+			// 鍒ゆ柇taoBaoUid鏄惁宸茬粡灏佺
+			if (!StringUtil.isNullOrEmpty(taoBaoUid)) {
+				ForbiddenUserIdentifyCode ic = forbiddenUserIdentifyCodeService
+						.listByTypeAndIdentifyCode(ForbiddenUserIdentifyCodeTypeEnum.taobaoUid, taoBaoUid);
+				if (ic != null && ic.getEffective() != null && ic.getEffective()) {
+					out.print(JsonUtil.loadFalseResult(Constant.CODE_FORBIDDEN_USER,
+							Constant.FORBIDDEN_USER_REASON_DESC));
+					// 灏佺鐢ㄦ埛
+					// 灏佺缁戝畾鐨勬甯哥敤鎴�
+					if (user != null && user.getState() != null && user.getState() == UserInfo.STATE_NORMAL) {
+						UserInfo update = new UserInfo(uid);
+						update.setState(UserInfo.STATE_FORBIDDEN);
+						update.setStateDesc("缁戝畾琚皝绂佺殑娣樺疂鍙疯灏佺");
+						userInfoService.updateByPrimaryKeySelective(update);
+					}
+					return;
+				}
+			}
+
 			JSONObject data = new JSONObject();
 			data.put("user", UserUtil.filterForClientUser(user));
 			out.print(JsonUtil.loadTrueResult(data));
@@ -553,6 +602,22 @@
 		try {
 			userAccountService.changeWXBind(uid, code);
 			UserInfo user = userInfoService.getUserByIdWithMybatis(uid);
+			// 鍒ゆ柇taoBaoUid鏄惁宸茬粡灏佺
+			ForbiddenUserIdentifyCode ic = forbiddenUserIdentifyCodeService
+					.listByTypeAndIdentifyCode(ForbiddenUserIdentifyCodeTypeEnum.wxUnionId, user.getWxUnionId());
+			if (ic != null && ic.getEffective() != null && ic.getEffective()) {
+				out.print(JsonUtil.loadFalseResult(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC));
+				// 灏佺鐢ㄦ埛
+				// 灏佺缁戝畾鐨勬甯哥敤鎴�
+				if (user != null && user.getState() != null && user.getState() == UserInfo.STATE_NORMAL) {
+					UserInfo update = new UserInfo(uid);
+					update.setState(UserInfo.STATE_FORBIDDEN);
+					update.setStateDesc("缁戝畾琚皝绂佺殑寰俊鍙疯灏佺");
+					userInfoService.updateByPrimaryKeySelective(update);
+				}
+				return;
+			}
+
 			JSONObject data = new JSONObject();
 			data.put("user", UserUtil.filterForClientUser(user));
 			out.print(JsonUtil.loadTrueResult(data));
@@ -816,6 +881,23 @@
 			return;
 		}
 		redisManager.cacheCommonString(key, "1", 120);
+
+		// 鏀粯瀹濈粦瀹�
+		ForbiddenUserIdentifyCode ic = forbiddenUserIdentifyCodeService
+				.listByTypeAndIdentifyCode(ForbiddenUserIdentifyCodeTypeEnum.alipayAccount, account);
+		if (ic != null && ic.getEffective() != null && ic.getEffective()) {
+			out.print(JsonUtil.loadFalseResult(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC));
+			// 灏佺鐢ㄦ埛
+			// 灏佺缁戝畾鐨勬甯哥敤鎴�
+			if (user != null && user.getState() != null && user.getState() == UserInfo.STATE_NORMAL) {
+				UserInfo update = new UserInfo(uid);
+				update.setState(UserInfo.STATE_FORBIDDEN);
+				update.setStateDesc("缁戝畾琚皝绂佺殑鏀粯瀹濊灏佺");
+				userInfoService.updateByPrimaryKeySelective(update);
+			}
+			return;
+		}
+
 		// 鍙互灞曠ず缁欑敤鎴风湅鐨勯敊璇爜
 		String[] ALIPAY_CODES = new String[] { "SYSTEM_ERROR", "PERMIT_CHECK_PERM_LIMITED", "PERM_AML_NOT_REALNAME_REV",
 				"PERM_AML_NOT_REALNAME_REV", "PAYEE_USER_INFO_ERROR", "PAYEE_ACC_OCUPIED",

--
Gitblit v1.8.0