From 4114e871bcb3dce771b6aed64a1027d0bbb95ca6 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期四, 16 五月 2019 15:28:37 +0800
Subject: [PATCH] 增加动态用户

---
 fanli/src/main/java/com/yeshi/fanli/controller/client/UserAccountController.java |  292 ++++++++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 252 insertions(+), 40 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 faf7b2b..03c9e92 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
@@ -9,6 +9,7 @@
 
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
 import org.yeshi.utils.JsonUtil;
 import org.yeshi.utils.encrypt.DESUtil;
 
@@ -32,7 +33,6 @@
 import com.yeshi.fanli.log.LogHelper;
 import com.yeshi.fanli.service.inter.config.BusinessSystemService;
 import com.yeshi.fanli.service.inter.config.ConfigService;
-import com.yeshi.fanli.service.inter.config.InviteGetMoneyService;
 import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
 import com.yeshi.fanli.service.inter.hongbao.HongBaoV2Service;
 import com.yeshi.fanli.service.inter.hongbao.ThreeSaleSerivce;
@@ -40,15 +40,16 @@
 import com.yeshi.fanli.service.inter.order.OrderService;
 import com.yeshi.fanli.service.inter.push.DeviceTokenHWService;
 import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService;
-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;
+import com.yeshi.fanli.service.inter.user.UserAccountBindingHistoryService;
 import com.yeshi.fanli.service.inter.user.UserAccountService;
 import com.yeshi.fanli.service.inter.user.UserInfoService;
+import com.yeshi.fanli.service.inter.user.UserMoneyService;
 import com.yeshi.fanli.service.inter.user.UserShareGoodsRecordService;
 import com.yeshi.fanli.service.inter.user.UserSystemCouponService;
 import com.yeshi.fanli.util.Constant;
@@ -77,7 +78,6 @@
 	@Resource
 	private OrderService orderService;
 
-
 	@Resource
 	private HongBaoV2Service hongBaoV2Service;
 
@@ -103,9 +103,6 @@
 	private LostOrderService lostOrderService;
 
 	@Resource
-	private AccountMessageService accountMessageService;
-
-	@Resource
 	private HongBaoManageService hongBaoManageService;
 
 	@Resource
@@ -113,9 +110,6 @@
 
 	@Resource
 	private RedisManager redisManager;
-
-	@Resource
-	private InviteGetMoneyService inviteGetMoneyService;
 
 	@Resource
 	private TBPidService tbPidService;
@@ -134,9 +128,15 @@
 
 	@Resource
 	private ForbiddenUserIdentifyCodeService forbiddenUserIdentifyCodeService;
-	
+
 	@Resource
 	private UserSystemCouponService userSystemCouponService;
+
+	@Resource
+	private UserMoneyService userMoneyService;
+
+	@Resource
+	private UserAccountBindingHistoryService userAccountBindingHistoryService;
 
 	private static final String PASSWORD_MAX_ERROR = "password_max_error";
 	private static final String EXTRACT_MIN_MONEY = "extract_min_money";
@@ -159,7 +159,8 @@
 	public void login(AcceptData acceptData, String code, String vcode, String phone, boolean wxinstall,
 			String tbOpenid, String tbNickName, String tbPortrait, String tbSession, int loginType, Boolean first,
 			HttpSession session, HttpServletRequest request, PrintWriter out) {
-		BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), acceptData.getPackages());
+		BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
+				acceptData.getPackages());
 		if (system == null) {
 			out.print(JsonUtil.loadFalseResult("绯荤粺涓嶅瓨鍦�"));
 			return;
@@ -220,8 +221,8 @@
 			root.put("type", result.getType());
 			root.put("data", data);
 			out.print(JsonUtil.loadTrueResult(root));
-			
-			final UserInfo uuser =  result.getUser();
+
+			final UserInfo uuser = result.getUser();
 			ThreadUtil.run(new Runnable() {
 				public void run() {
 					try {
@@ -238,7 +239,7 @@
 					}
 				}
 			});
-			
+
 		} catch (UserAccountException e) {
 			try {
 				LogHelper.cookieLog("鐧诲綍鍑洪敊:" + e.getCode() + "-" + e.getMessage());
@@ -247,7 +248,7 @@
 			}
 			out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
 		}
-		
+
 	}
 
 	/**
@@ -265,7 +266,8 @@
 	@RequestMapping(value = "register")
 	public void register(AcceptData acceptData, String tbOpenid, String tbNickName, String tbPortrait, String vcode,
 			String phone, HttpServletRequest request, HttpSession session, PrintWriter out) {
-		BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), acceptData.getPackages());
+		BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
+				acceptData.getPackages());
 		if (system == null) {
 			out.print(JsonUtil.loadFalseResult("绯荤粺涓嶅瓨鍦�"));
 			return;
@@ -325,7 +327,8 @@
 	 */
 	@RequestMapping(value = "connect")
 	public void connect(AcceptData acceptData, long mainUid, long lessUid, HttpSession session, PrintWriter out) {
-		BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), acceptData.getPackages());
+		BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
+				acceptData.getPackages());
 		if (system == null) {
 			out.print(JsonUtil.loadFalseResult("绯荤粺涓嶅瓨鍦�"));
 			return;
@@ -358,7 +361,8 @@
 	 */
 	@RequestMapping(value = "getuid")
 	public void getUid(AcceptData acceptData, String code, String tbOpenid, String phone, PrintWriter out) {
-		BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), acceptData.getPackages());
+		BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
+				acceptData.getPackages());
 		if (system == null) {
 			out.print(JsonUtil.loadFalseResult("绯荤粺涓嶅瓨鍦�"));
 			return;
@@ -422,7 +426,8 @@
 	 */
 	@RequestMapping(value = "bindPhone")
 	public void bindPhone(AcceptData acceptData, Long uid, String vcode, String phone, PrintWriter out) {
-		BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), acceptData.getPackages());
+		BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
+				acceptData.getPackages());
 		if (system == null) {
 			out.print(JsonUtil.loadFalseResult("绯荤粺涓嶅瓨鍦�"));
 			return;
@@ -485,7 +490,8 @@
 	 */
 	@RequestMapping(value = "unBindPhone")
 	public void unBindPhone(AcceptData acceptData, Long uid, String phone, PrintWriter out) {
-		BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), acceptData.getPackages());
+		BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
+				acceptData.getPackages());
 		if (system == null) {
 			out.print(JsonUtil.loadFalseResult("绯荤粺涓嶅瓨鍦�"));
 			return;
@@ -521,7 +527,8 @@
 	@RequestMapping(value = "bindTaoBao")
 	public void bindTaoBao(AcceptData acceptData, Long uid, String tbOpenid, String tbNickName, String tbPortrait,
 			String tbSession, PrintWriter out) {
-		BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), acceptData.getPackages());
+		BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
+				acceptData.getPackages());
 		if (system == null) {
 			out.print(JsonUtil.loadFalseResult("绯荤粺涓嶅瓨鍦�"));
 			return;
@@ -583,7 +590,8 @@
 	 */
 	@RequestMapping(value = "unBindTaoBao")
 	public void unBindTaoBao(AcceptData acceptData, Long uid, PrintWriter out) {
-		BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), acceptData.getPackages());
+		BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
+				acceptData.getPackages());
 		if (system == null) {
 			out.print(JsonUtil.loadFalseResult("绯荤粺涓嶅瓨鍦�"));
 			return;
@@ -607,7 +615,8 @@
 	 */
 	@RequestMapping(value = "changeWX")
 	public void changeWX(AcceptData acceptData, Long uid, String code, PrintWriter out) {
-		BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), acceptData.getPackages());
+		BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
+				acceptData.getPackages());
 		if (system == null) {
 			out.print(JsonUtil.loadFalseResult("绯荤粺涓嶅瓨鍦�"));
 			return;
@@ -654,7 +663,8 @@
 	 */
 	@RequestMapping(value = "getphone")
 	public void getPhone(AcceptData acceptData, Long uid, PrintWriter out) {
-		BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), acceptData.getPackages());
+		BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
+				acceptData.getPackages());
 		if (system == null) {
 			out.print(JsonUtil.loadFalseResult("绯荤粺涓嶅瓨鍦�"));
 			return;
@@ -674,7 +684,8 @@
 
 	@RequestMapping(value = "verifyvcodeforbind")
 	public void verifyVcodeForbind(AcceptData acceptData, Long uid, String vcode, PrintWriter out) {
-		BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), acceptData.getPackages());
+		BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
+				acceptData.getPackages());
 		if (system == null) {
 			out.print(JsonUtil.loadFalseResult("绯荤粺涓嶅瓨鍦�"));
 			return;
@@ -719,7 +730,8 @@
 	 */
 	@RequestMapping(value = "bindalipay")
 	public void bindAlipay(AcceptData acceptData, Long uid, String name, String account, PrintWriter out) {
-		BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), acceptData.getPackages());
+		BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
+				acceptData.getPackages());
 		if (system == null) {
 			out.print(JsonUtil.loadFalseResult("绯荤粺涓嶅瓨鍦�"));
 			return;
@@ -774,7 +786,8 @@
 	@RequestMapping(value = "bindalipaywithverify")
 	public void bindAlipayWithVerify(AcceptData acceptData, Long uid, String name, String account, PrintWriter out) {
 
-		BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), acceptData.getPackages());
+		BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
+				acceptData.getPackages());
 		if (system == null) {
 			out.print(JsonUtil.loadFalseResult("绯荤粺涓嶅瓨鍦�"));
 			return;
@@ -864,7 +877,8 @@
 	@RequestMapping(value = "bindalipaywithverifynew")
 	public void bindAlipayWithVerifyNew(AcceptData acceptData, Long uid, String name, String account, PrintWriter out) {
 
-		BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), acceptData.getPackages());
+		BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
+				acceptData.getPackages());
 		if (system == null) {
 			out.print(JsonUtil.loadFalseResult("绯荤粺涓嶅瓨鍦�"));
 			return;
@@ -900,6 +914,8 @@
 			return;
 		}
 		redisManager.cacheCommonString(key, "1", 120);
+
+		
 
 		// 鏀粯瀹濈粦瀹�
 		ForbiddenUserIdentifyCode ic = forbiddenUserIdentifyCodeService
@@ -984,16 +1000,16 @@
 			out.print(JsonUtil.loadFalseResult(2, "鐢ㄦ埛涓嶅瓨鍦�"));
 			return;
 		}
-		BigDecimal moneyToday = inviteGetMoneyService.getMoneyToday(uid + "");
+		BigDecimal moneyToday = userMoneyService.getMoneyToday(uid);
 		if (moneyToday == null) {
 			moneyToday = new BigDecimal(0);
 		}
-		BigDecimal moneyMonth = inviteGetMoneyService.getMoneyMonth(uid + "");
+		BigDecimal moneyMonth = userMoneyService.getMoneyMonth(uid);
 		if (moneyMonth == null) {
 			moneyMonth = new BigDecimal(0);
 		}
 
-		BigDecimal moneyLastMonth = inviteGetMoneyService.getMoneyLastMonth(uid + "");
+		BigDecimal moneyLastMonth = userMoneyService.getMoneyLastMonth(uid);
 		BigDecimal unOpenmoney = hongBaoV2Service.getUnRecievedFanLiMoney(uid);
 		BigDecimal totalFanMoney = hongBaoV2Service.getTotalFanLiMoney(uid);
 		JSONObject data = new JSONObject();
@@ -1062,15 +1078,8 @@
 
 			} else {
 
-				tbPid = tbPidService.getTBPid(Long.parseLong(uid), PidUser.TYPE_FANLI_IOS);
-				if (tbPid != null) {
-					String siteId = tbPid.getPid().split("_")[2];
-					String adzoneId = tbPid.getPid().split("_")[3];
-					TaoBaoUnionConfig config = taoBaoUnionConfigService.getConfigByAppIdCache(siteId);
-					clientTBPid = new ClientTBPid(config.getAppKey(), tbPid.getPid(), siteId, adzoneId);
-				} else {
-					clientTBPid = tbPidService.getIOSDefault();
-				}
+				clientTBPid = tbPidService.getIOSDefault();
+
 			}
 
 		} else {
@@ -1102,4 +1111,207 @@
 			deviceTokenHWService.unBindDeviceToken(acceptData.getDevice());
 		out.print(JsonUtil.loadTrueResult(""));
 	}
+
+	/**
+	 * 鏂扮増鐧诲綍 V1.5.3
+	 * 
+	 * @param acceptData
+	 * @param vcode
+	 * @param phone
+	 * @param code
+	 * @param loginType
+	 *            鐧诲綍鏂瑰紡锛� 1-鎵嬫満鐧诲綍 2-寰俊鐧诲綍
+	 * @param request
+	 * @param out
+	 */
+	@RequestMapping(value = "loginNew", method = RequestMethod.POST)
+	public void loginNew(AcceptData acceptData, String vcode, String phone, String code, int loginType,
+			HttpServletRequest request, PrintWriter out) {
+
+		try {
+			BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
+					acceptData.getPackages());
+			if (system == null) {
+				out.print(JsonUtil.loadFalseResult("绯荤粺涓嶅瓨鍦�"));
+				return;
+			}
+
+			UserInfo userInfo = null;
+			// 鎵嬫満鐧诲綍
+			if (loginType == 1) {
+				userInfo = userAccountService.loginPhone(request, loginType, vcode, phone, system.getAppid());
+			}
+
+			// 寰俊鐧诲綍
+			if (loginType == 2) {
+				userInfo = userAccountService.loginWinXin(request, loginType, code, system.getAppid());
+			}
+
+			if (userInfo == null) {
+				out.print(JsonUtil.loadFalseResult("鐧诲綍澶辫触"));
+			} else {
+				JSONObject data = new JSONObject();
+				data.put("userInfo", UserUtil.filterForClientUser(userInfo));
+				out.print(JsonUtil.loadTrueResult(data));
+
+				final UserInfo uuser = userInfo;
+				ThreadUtil.run(new Runnable() {
+					public void run() {
+						try {
+							/* 鍚屾鏈櫥褰曚箣鍓嶈澶囨娊濂栨暟鎹� */
+							int platformType = 0;
+							String platform = acceptData.getPlatform();
+							if ("android".equals(platform)) {
+								platformType = 1;
+							} else if ("ios".equals(platform)) {
+								platformType = 2;
+							}
+							userSystemCouponService.copyLotteryPrize(uuser.getId(), platformType,
+									acceptData.getDevice());
+						} catch (Exception e) {
+							e.printStackTrace();
+						}
+					}
+				});
+			}
+
+		} catch (UserAccountException e) {
+			out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
+			try {
+				LogHelper.cookieLog("鐧诲綍鍑洪敊:" + e.getCode() + "-" + e.getMessage());
+			} catch (Exception e1) {
+				e1.printStackTrace();
+			}
+		} catch (Exception e) {
+			out.print(JsonUtil.loadFalseResult("鐧诲綍澶辫触"));
+			try {
+				LogHelper.errorDetailInfo(e);
+			} catch (Exception e1) {
+				e1.printStackTrace();
+			}
+		}
+	}
+
+	/**
+	 * 缁戝畾鐢佃瘽鍙风爜 V1.5.3
+	 * 
+	 * @param acceptData
+	 * @param vcode
+	 * @param phone
+	 * @param out
+	 */
+	@RequestMapping(value = "bindPhoneNew")
+	public void bindPhoneNew(AcceptData acceptData, Long uid, String vcode, String phone, PrintWriter out) {
+
+		BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
+				acceptData.getPackages());
+		if (system == null) {
+			out.print(JsonUtil.loadFalseResult("绯荤粺涓嶅瓨鍦�"));
+			return;
+		}
+
+		if (StringUtil.isNullOrEmpty(vcode)) {
+			out.print(JsonUtil.loadFalseResult("楠岃瘉鐮佷笉鑳戒负绌�"));
+			return;
+		}
+
+		if (StringUtil.isNullOrEmpty(phone)) {
+			out.print(JsonUtil.loadFalseResult("鐢佃瘽鍙风爜涓嶈兘涓虹┖"));
+			return;
+		}
+
+		phone = phone.replaceAll(" ", "");
+
+		String oldVCode = redisManager.getSMSVCode(phone, SMSHistory.TYPE_BIND);
+		if (Constant.IS_OUTNET) {
+			if (!vcode.equalsIgnoreCase(oldVCode)) {
+				out.print(JsonUtil.loadFalseResult(9001, "楠岃瘉鐮侀敊璇紝閲嶆柊杈撳叆"));
+				return;
+			}
+			redisManager.clearSMSFrequencyLimit(phone, SMSHistory.TYPE_BIND);
+		}
+
+		try {
+			// 缁戝畾鐢ㄦ埛
+			userAccountService.bindPhoneNew(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("userInfo", UserUtil.filterForClientUser(user));
+			out.print(JsonUtil.loadTrueResult(data));
+
+		} catch (UserAccountException e) {
+			out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
+		} catch (Exception e) {
+			out.print(JsonUtil.loadFalseResult(1, "缁戝畾澶辫触"));
+		}
+	}
+
+	/**
+	 * 鏇存敼寰俊
+	 * 
+	 * @param acceptData
+	 * @param uid
+	 * @param code
+	 * @param out
+	 */
+	@RequestMapping(value = "bindWeiXin")
+	public void bindWeiXin(AcceptData acceptData, Long uid, String code, PrintWriter out) {
+		BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(),
+				acceptData.getPackages());
+
+		if (system == null) {
+			out.print(JsonUtil.loadFalseResult("绯荤粺涓嶅瓨鍦�"));
+			return;
+		}
+
+		if (StringUtil.isNullOrEmpty(code)) {
+			out.print(JsonUtil.loadFalseResult("璇蜂笂浼燾ode"));
+			return;
+		}
+
+		try {
+			userAccountService.bindWeiXin(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("userInfo", UserUtil.filterForClientUser(user));
+			out.print(JsonUtil.loadTrueResult(data));
+		} catch (UserAccountException e) {
+			out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
+		}
+	}
+
 }

--
Gitblit v1.8.0