| | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | | import com.ks.push.service.BDeviceTokenService; |
| | | import com.yeshi.fanli.entity.SystemEnum; |
| | | import com.yeshi.fanli.entity.SystemFunction; |
| | | import com.yeshi.fanli.exception.user.UserExtraTaoBaoInfoException; |
| | | import com.yeshi.fanli.service.inter.user.tb.UserExtraTaoBaoInfoService; |
| | | import com.yeshi.fanli.util.*; |
| | | import com.yeshi.fanli.vo.taobao.TaoBaoUser; |
| | | import com.yeshi.fanli.vo.user.QQUserInfoVO; |
| | | import org.apache.dubbo.config.annotation.Reference; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestMethod; |
| | |
| | | @Resource |
| | | private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService; |
| | | |
| | | @Reference(version = "1.0", check = false) |
| | | private BDeviceTokenService bDeviceTokenService; |
| | | |
| | | |
| | | /** |
| | | * 新版登录 V1.5.3 |
| | | * |
| | | * @param acceptData |
| | | * @param loginType 登录方式: 1-手机登录 2-微信登录 3-手机 4-qq |
| | | * @param vcode |
| | | * @param phone |
| | | * @param code |
| | | * @param loginType 登录方式: 1-手机登录 2-微信登录 |
| | | * @param aliAccessToken |
| | | * @param qqUser |
| | | * @param request |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "login", method = RequestMethod.POST) |
| | | public void login(AcceptData acceptData, int loginType, String vcode, String phone, String code, |
| | | public void login(AcceptData acceptData, int loginType, String vcode, String phone, String code, String aliAccessToken, String qqUser, |
| | | HttpServletRequest request, PrintWriter out) { |
| | | try { |
| | | BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), |
| | |
| | | } |
| | | |
| | | UserInfo userInfo = null; |
| | | // 手机登录 |
| | | if (loginType == 1) { |
| | | userInfo = userAccountService.loginPhone(new ProxyIP(request.getRemoteHost(), request.getRemotePort()), loginType, vcode, phone, system); |
| | | |
| | | |
| | | switch (loginType) { |
| | | //电话号码登录 |
| | | case 1: { |
| | | if (!StringUtil.isNullOrEmpty(aliAccessToken)) { |
| | | long now = System.currentTimeMillis(); |
| | | String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.oneKeyLoginCount, StringUtil.Md5(StringUtil.isNullOrEmpty(acceptData.getUtdid()) ? acceptData.getDevice() : acceptData.getUtdid())); |
| | | ; |
| | | redisManager.increase(key); |
| | | int expire = (int) ((TimeUtil.convertToTimeTemp(TimeUtil.getGernalTime(now + 1000 * 60 * 60 * 24L, "yyyyMMdd"), "yyyyMMdd") - now) / 1000); |
| | | redisManager.expire(key, expire); |
| | | } |
| | | userInfo = userAccountService.loginPhone(new ProxyIP(request.getRemoteHost(), request.getRemotePort()), loginType, vcode, phone, aliAccessToken, system); |
| | | } |
| | | break; |
| | | //微信登录 |
| | | case 2: { |
| | | //需要绑定电话号码 |
| | | if (SystemInfoUtil.hasFunctions(system.getSystem(), SystemFunction.bindPhone)) |
| | | userInfo = userAccountService.loginWeiXinNew(new ProxyIP(request.getRemoteHost(), request.getRemotePort()), loginType, code, system); |
| | | //不需要绑定电话号码 |
| | | else |
| | | userInfo = userAccountService.loginWeiXin(new ProxyIP(request.getRemoteHost(), request.getRemotePort()), loginType, code, system); |
| | | } |
| | | break; |
| | | case 4: { |
| | | QQUserInfoVO qqUserInfo = UserUtil.parseQQUser(qqUser); |
| | | userInfo = userAccountService.loginQQ(new ProxyIP(request.getRemoteHost(), request.getRemotePort()), loginType, qqUserInfo, system); |
| | | } |
| | | break; |
| | | } |
| | | |
| | | // 微信登录 |
| | | if (loginType == 2) { |
| | | //需要绑定电话号码 |
| | | if (SystemInfoUtil.hasFunctions(system.getSystem(), SystemFunction.bindPhone)) |
| | | userInfo = userAccountService.loginWeiXinNew(new ProxyIP(request.getRemoteHost(), request.getRemotePort()), loginType, code, system); |
| | | //不需要绑定电话号码 |
| | | else |
| | | userInfo = userAccountService.loginWeiXin(new ProxyIP(request.getRemoteHost(), request.getRemotePort()), loginType, code, system); |
| | | } |
| | | |
| | | if (userInfo == null) { |
| | | out.print(JsonUtil.loadFalseResult("登录失败")); |
| | | } else { |
| | | JSONObject data = new JSONObject(); |
| | | data.put("userInfo", UserUtil.filterForClientUser(userInfo)); |
| | | data.put("inviteCode", userInfoExtraService.getInviteCodeByUid(userInfo.getId())); |
| | | if (SystemInfoUtil.hasFunctions(acceptData.getSystem(), SystemFunction.inviteCode)) { |
| | | data.put("inviteCode", userInfoExtraService.getInviteCodeByUid(userInfo.getId())); |
| | | } |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | |
| | | final UserInfo uuser = userInfo; |
| | |
| | | LogHelper.errorDetailInfo(e); |
| | | } |
| | | |
| | | // 绑定oppo,VIVO推送 |
| | | DeviceActive active = deviceActiveService.getFirstActiveInfo(acceptData.getDevice()); |
| | | if (active != null) { |
| | | deviceTokenOPPOService.bindUid(uuser.getId(), active.getId()); |
| | | deviceTokenVIVOService.bindUid(uuser.getId(), active.getId()); |
| | | deviceTokenXMService.bindUid(active.getId(), uuser.getId()); |
| | | if (acceptData.getSystem().isNewPush()) { |
| | | bDeviceTokenService.bindUid(acceptData.getSystem().name(), StringUtil.isNullOrEmpty(acceptData.getUtdid()) ? acceptData.getDevice() : acceptData.getUtdid(), uuser.getId() + ""); |
| | | } else { |
| | | // 绑定oppo,VIVO推送 |
| | | DeviceActive active = deviceActiveService.getFirstActiveInfo(acceptData.getDevice()); |
| | | if (active != null) { |
| | | deviceTokenOPPOService.bindUid(uuser.getId(), active.getId()); |
| | | deviceTokenVIVOService.bindUid(uuser.getId(), active.getId()); |
| | | deviceTokenXMService.bindUid(active.getId(), uuser.getId()); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | }); |
| | | } |
| | | |
| | | } catch (UserAccountException e) { |
| | | int errorCode = e.getCode(); |
| | | if (errorCode == 101) { // 需要绑定手机号 |
| | | if (errorCode == UserAccountException.CODE_NEED_BIND_PHONE) { // 需要绑定手机号 |
| | | JSONObject data = new JSONObject(); |
| | | data.put("key", e.getMsg()); |
| | | JSONObject object = new JSONObject(); |
| | | object.put("code", errorCode); |
| | | object.put("data", data); |
| | | out.print(object.toString()); |
| | | } else if (errorCode == 102) { // 需要绑定微信号 |
| | | } else if (errorCode == UserAccountException.CODE_NEED_BIND_WX) { // 需要绑定微信号 |
| | | JSONObject data = new JSONObject(); |
| | | data.put("key", e.getMsg()); |
| | | JSONObject object = new JSONObject(); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 绑定电话号码 V2.0.1 微信登录 |
| | | * 绑定电话号码 V2.0.1 三方登录 |
| | | * |
| | | * @param acceptData |
| | | * @param vcode |
| | |
| | | */ |
| | | @RequestSerializableByKey(key = "'bindPhoneLogin-'+#phone") |
| | | @RequestMapping(value = "bindPhoneLogin") |
| | | public void bindPhoneLogin(AcceptData acceptData, String vcode, String phone, String key, |
| | | public void bindPhoneLogin(AcceptData acceptData, String vcode, String phone, String key, String aliAccessToken, |
| | | HttpServletRequest request, PrintWriter out) { |
| | | BusinessSystem system = businessSystemService.getBusinessSystemCache(acceptData.getPlatform(), |
| | | acceptData.getPackages(), acceptData.getSystem()); |
| | |
| | | return; |
| | | } |
| | | |
| | | if (StringUtil.isNullOrEmpty(vcode)) { |
| | | out.print(JsonUtil.loadFalseResult("验证码不能为空")); |
| | | return; |
| | | } |
| | | |
| | | if (StringUtil.isNullOrEmpty(phone)) { |
| | | out.print(JsonUtil.loadFalseResult("电话号码不能为空")); |
| | | return; |
| | | } |
| | | |
| | | if (StringUtil.isNullOrEmpty(key)) { |
| | | out.print(JsonUtil.loadFalseResult("key值不能为空")); |
| | | return; |
| | | } |
| | | |
| | | phone = phone.replaceAll(" ", ""); |
| | | if (!StringUtil.isNullOrEmpty(aliAccessToken)) { |
| | | long now = System.currentTimeMillis(); |
| | | String redisKey = RedisKeyEnum.getRedisKey(RedisKeyEnum.oneKeyLoginCount, StringUtil.Md5(StringUtil.isNullOrEmpty(acceptData.getUtdid()) ? acceptData.getDevice() : acceptData.getUtdid())); |
| | | ; |
| | | redisManager.increase(redisKey); |
| | | int expire = (int) ((TimeUtil.convertToTimeTemp(TimeUtil.getGernalTime(now + 1000 * 60 * 60 * 24L, "yyyyMMdd"), "yyyyMMdd") - now) / 1000); |
| | | redisManager.expire(redisKey, expire); |
| | | } |
| | | |
| | | 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); |
| | | 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; |
| | | } |
| | | |
| | | try { |
| | | UserInfo userInfo = userAccountService.bindPhoneToLogin(new ProxyIP(request.getRemoteHost(), request.getRemotePort()), acceptData, phone, key); |
| | | |
| | | UserInfo userInfo = userAccountService.bindPhoneToLogin(new ProxyIP(request.getRemoteHost(), request.getRemotePort()), acceptData, mobile, key); |
| | | JSONObject data = new JSONObject(); |
| | | data.put("userInfo", UserUtil.filterForClientUser(userInfo)); |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | |
| | | out.print(JsonUtil.loadFalseResult("key值不能为空")); |
| | | return; |
| | | } |
| | | |
| | | |
| | | try { |
| | | UserInfo userInfo = userAccountService.bindWXToLogin(new ProxyIP(request.getRemoteHost(), request.getRemotePort()), acceptData, code, system.getAppid(), key); |
| | |
| | | return; |
| | | } |
| | | |
| | | //升高级,防止消息队列无效,没自动申请高级 |
| | | try { |
| | | userVIPPreInfoService.upgradeVipByMyOrder(uid); |
| | | } catch (Exception e) { |
| | | } |
| | | try { |
| | | userVIPPreInfoService.upgradeVipByTeamNum(uid); |
| | | } catch (Exception e) { |
| | | } |
| | | try { |
| | | userVIPInfoService.applyVIP(uid); |
| | | } catch (UserVIPInfoException e) { |
| | |
| | | redisManager.clearSMSVCode(phone, SMSHistory.TYPE_REMVOE); |
| | | } |
| | | |
| | | userAccountService.forbiddenUserAll(uid, "用户主动注销账户"); |
| | | userAccountService.unRegisterUser(uid, "用户主动注销账户"); |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("注销成功")); |
| | | } |
| | | |