| | |
| | | import com.yeshi.fanli.util.*; |
| | | import com.yeshi.fanli.util.account.UserUtil; |
| | | import com.yeshi.fanli.util.wx.MyWXLoginUtil; |
| | | import com.yeshi.fanli.vo.user.QQUserInfoVO; |
| | | import net.sf.json.JSONObject; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "loginNew", method = RequestMethod.POST) |
| | | public void loginNew(AcceptData acceptData, String vcode, String phone, String code, int loginType, |
| | | public void loginNew(AcceptData acceptData, String vcode, String phone, String code, String aliAccessToken, int loginType, |
| | | HttpServletRequest request, PrintWriter out) { |
| | | |
| | | // 2.0以下版本不允许登录 |
| | |
| | | UserInfo userInfo = null; |
| | | // 手机登录 |
| | | if (loginType == 1) { |
| | | userInfo = userAccountService.loginPhone(new ProxyIP(request.getRemoteHost(), request.getRemotePort()), loginType, vcode, phone, system); |
| | | userInfo = userAccountService.loginPhone(new ProxyIP(request.getRemoteHost(), request.getRemotePort()), loginType, vcode, phone, aliAccessToken, system); |
| | | } |
| | | |
| | | // 微信登录 |
| | |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "bindPhoneNew") |
| | | public void bindPhoneNew(AcceptData acceptData, Long uid, String vcode, String phone, PrintWriter out) { |
| | | public void bindPhoneNew(AcceptData acceptData, Long uid, String vcode, String phone, String aliAccessToken, PrintWriter out) { |
| | | |
| | | BusinessSystem system = getSystem(acceptData); |
| | | if (system == null) { |
| | | out.print(JsonUtil.loadFalseResult("系统不存在")); |
| | | return; |
| | | } |
| | | |
| | | if (StringUtil.isNullOrEmpty(vcode)) { |
| | | out.print(JsonUtil.loadFalseResult("验证码不能为空")); |
| | | String mobile = null; |
| | | try { |
| | | mobile = userAccountService.getMobile(vcode, phone, aliAccessToken, acceptData.getSystem(), SMSHistory.TYPE_BIND); |
| | | } catch (UserAccountException e) { |
| | | out.print(JsonUtil.loadFalseResult(e.getMsg())); |
| | | 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); |
| | | userAccountService.bindPhoneNew(uid, mobile); |
| | | |
| | | UserInfo user = userInfoService.getUserByIdWithMybatis(uid); |
| | | // 判断电话号码是否已经封禁 |
| | | ForbiddenUserIdentifyCode ic = forbiddenUserIdentifyCodeService |
| | | .listByTypeAndIdentifyCode(ForbiddenUserIdentifyCodeTypeEnum.phone, phone); |
| | | .listByTypeAndIdentifyCode(ForbiddenUserIdentifyCodeTypeEnum.phone, mobile); |
| | | if (ic != null && ic.getEffective() != null && ic.getEffective()) { |
| | | out.print(JsonUtil.loadFalseResult(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC)); |
| | | // 封禁用户 |
| | |
| | | } |
| | | |
| | | try { |
| | | userAccountService.bindWeiXin(acceptData, uid, code); |
| | | userAccountService.bindWeiXin(system, uid, code); |
| | | |
| | | UserInfo user = userInfoService.getUserByIdWithMybatis(uid); |
| | | // 判断taoBaoUid是否已经封禁 |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 更改微信 |
| | | * |
| | | * @param acceptData |
| | | * @param uid |
| | | * @param qqUser |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "bindQQ") |
| | | public void bindQQ(AcceptData acceptData, Long uid, String qqUser, PrintWriter out) { |
| | | BusinessSystem system = getSystem(acceptData); |
| | | |
| | | if (system == null) { |
| | | out.print(JsonUtil.loadFalseResult("系统不存在")); |
| | | return; |
| | | } |
| | | |
| | | if (StringUtil.isNullOrEmpty(qqUser)) { |
| | | out.print(JsonUtil.loadFalseResult("请上传qqUser")); |
| | | return; |
| | | } |
| | | |
| | | String qqUserStr = StringUtil.getFromBase64(qqUser); |
| | | QQUserInfoVO qqUserInfo = new Gson().fromJson(qqUserStr, QQUserInfoVO.class); |
| | | try { |
| | | userAccountService.bindQQ(uid, qqUserInfo); |
| | | |
| | | UserInfo user = userInfoService.getUserByIdWithMybatis(uid); |
| | | |
| | | 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())); |
| | | } |
| | | } |
| | | |
| | | } |