| | |
| | | }
|
| | | userInfo = getUserInfoByTaoBaoOpenId(appId, tbUserInfo.getOpenid());
|
| | | // 判断用户是否被删除
|
| | | if (userInfo != null && userInfo.getState() != null
|
| | | && (userInfo.getState() != UserInfo.STATE_NORMAL))
|
| | | if (userInfo != null && userInfo.getState() != null && (userInfo.getState() != UserInfo.STATE_NORMAL))
|
| | | userInfo = null;
|
| | | if (userInfo == null) {// 原先的账号不存在
|
| | | userInfo = new UserInfo();
|
| | |
| | |
|
| | | userInfo = getUserInfoByWXUnionId(appId, weiXinUser.getUnionid());
|
| | | // 判断用户是否被删除
|
| | | if (userInfo != null && userInfo.getState() != null
|
| | | && (userInfo.getState() != UserInfo.STATE_NORMAL
|
| | | ))
|
| | | if (userInfo != null && userInfo.getState() != null && (userInfo.getState() != UserInfo.STATE_NORMAL))
|
| | | userInfo = null;
|
| | | // 直接用的微信登录
|
| | | if (lastUser == null) {
|
| | |
| | |
|
| | | userInfo = getUserInfoByPhone(appId, phone);
|
| | | // 判断用户是否被删除
|
| | | if (userInfo != null && userInfo.getState() != null
|
| | | && (userInfo.getState() != UserInfo.STATE_NORMAL))
|
| | | if (userInfo != null && userInfo.getState() != null && (userInfo.getState() != UserInfo.STATE_NORMAL))
|
| | | userInfo = null;
|
| | |
|
| | | if (userInfo == null) {// 原先的账号不存在
|
| | |
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | /**
|
| | | * 根据系统与unionid寻找用户
|
| | | *
|
| | |
| | |
|
| | | // 剔除被删除掉的用户
|
| | | for (int i = 0; i < list.size(); i++) {
|
| | | if (list.get(i).getState() !=UserInfo.STATE_NORMAL) {
|
| | | if (list.get(i).getState() != UserInfo.STATE_NORMAL) {
|
| | | list.remove(i);
|
| | | i--;
|
| | | }
|
| | |
| | | String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.SMSLoginCount, phone);
|
| | | redisManager.removeCommonString(key);
|
| | |
|
| | |
|
| | | // 采用redis事务防止一个手机号多次注册问题
|
| | | String watchKey = StringUtil.Md5("REGISTER:" + phone);
|
| | | Jedis jedis = jedisPool.getResource();
|
| | |
| | | InputStream asInputStream = HttpUtil.getAsInputStream(weiXinUser.getHeadimgurl());
|
| | | if (asInputStream != null) {
|
| | | FileUploadResult result = COSManager.getInstance().uploadFile(asInputStream,
|
| | | String.format(FilePathEnum.userWXPortrait.getPath() + "%s_%s.jpg", weiXinUser.getUnionid(),
|
| | | System.currentTimeMillis() + ""));
|
| | | String.format(FilePathEnum.userWXPortrait.getPath() + "%s_%s.jpg",
|
| | | weiXinUser.getUnionid(), System.currentTimeMillis() + ""));
|
| | | if (result != null && !StringUtil.isNullOrEmpty(result.getUrl()))
|
| | | portrait = result.getUrl();
|
| | | } else {
|
| | |
| | |
|
| | | UserInfo userInfo = userInfoMapper.getEffectiveUserInfoByWXUnionId(weiXinUser.getUnionid());
|
| | | if (userInfo == null) {
|
| | | String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.emptyKey, StringUtil.Md5("WXLogin:" + weiXinUser.getUnionid()));
|
| | | String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.emptyKey,
|
| | | StringUtil.Md5("WXLogin:" + weiXinUser.getUnionid()));
|
| | | redisManager.cacheCommonString(key, JsonUtil.getSimpleGson().toJson(weiXinUser), 60 * 20);
|
| | | throw new UserAccountException(101, key);
|
| | | }
|
| | |
| | |
|
| | | }
|
| | |
|
| | | @Transactional(rollbackFor=UserAccountException.class)
|
| | | @Transactional(rollbackFor = UserAccountException.class)
|
| | | @Override
|
| | | public void bindWeiXin(AcceptData acceptData, Long uid, String code) throws UserAccountException {
|
| | | WXAccountInfoDTO wxAccount = Constant.getWXAccount(acceptData.getPlatform(), acceptData.getVersion());
|
| | |
| | | }
|
| | | bindWeiXin(uid, weiXinUser);
|
| | | }
|
| | | |
| | | |
| | | |
| | | |
| | | @Transactional(rollbackFor=UserAccountException.class)
|
| | |
|
| | | @Transactional(rollbackFor = UserAccountException.class)
|
| | | @Override
|
| | | public void bindWeiXin(Long uid,WeiXinUser weiXinUser) throws UserAccountException {
|
| | | public void bindWeiXin(Long uid, WeiXinUser weiXinUser) throws UserAccountException {
|
| | | UserInfo user = userInfoMapper.selectAvailableByPrimaryKey(uid);
|
| | | if (user == null) {
|
| | | throw new UserAccountException(1, "用户不存在");
|
| | | }
|
| | | |
| | |
|
| | | if (weiXinUser == null) {
|
| | | throw new UserAccountException(2, "微信帐号授权失败");
|
| | | }
|
| | |
| | | if (asInputStream == null) {
|
| | | LogHelper.test("微信头像下载失败: " + weiXinUser.getUnionid() + " " + headimgurl);
|
| | | } else {
|
| | | FileUploadResult result = COSManager.getInstance().uploadFile(asInputStream, String
|
| | | .format(FilePathEnum.userWXPortrait.getPath() + "%s_%s.jpg", weiXinUser.getUnionid(), System.currentTimeMillis() + ""));
|
| | | FileUploadResult result = COSManager.getInstance().uploadFile(asInputStream,
|
| | | String.format(FilePathEnum.userWXPortrait.getPath() + "%s_%s.jpg", weiXinUser.getUnionid(),
|
| | | System.currentTimeMillis() + ""));
|
| | | if (result != null && !StringUtil.isNullOrEmpty(result.getUrl())) {
|
| | | headimgurl = result.getUrl();
|
| | | } else {
|
| | |
| | | @Override
|
| | | public UserInfo bindPhoneToLogin(String phone, String key, String appId, HttpServletRequest request)
|
| | | throws UserAccountException {
|
| | | UserInfo phoneUser = userInfoMapper.getEffectiveUserInfoByPhone(phone);
|
| | | if (phoneUser != null)
|
| | | throw new UserAccountException(1, "号码已经被占用");
|
| | |
|
| | | // 判断手机号码是否被封禁
|
| | | ForbiddenUserIdentifyCode identifyCode1 = forbiddenUserIdentifyCodeService
|
| | |
| | | if (!StringUtil.isNullOrEmpty(weiXinUser.getHeadimgurl())) {
|
| | | InputStream asInputStream = HttpUtil.getAsInputStream(weiXinUser.getHeadimgurl());
|
| | | if (asInputStream != null) {
|
| | | FileUploadResult result = COSManager.getInstance().uploadFile(asInputStream, String
|
| | | .format(FilePathEnum.userWXPortrait.getPath() +"%s_%s.jpg", weiXinUser.getUnionid(), System.currentTimeMillis() + ""));
|
| | | FileUploadResult result = COSManager.getInstance().uploadFile(asInputStream,
|
| | | String.format(FilePathEnum.userWXPortrait.getPath() + "%s_%s.jpg", weiXinUser.getUnionid(),
|
| | | System.currentTimeMillis() + ""));
|
| | | if (result != null && !StringUtil.isNullOrEmpty(result.getUrl()))
|
| | | portrait = result.getUrl();
|
| | | } else {
|
| | |
| | | if (StringUtil.isNullOrEmpty(portrait))
|
| | | portrait = Constant.systemCommonConfig.getDefaultPortrait();
|
| | |
|
| | | // 创建新账户
|
| | | userInfo = new UserInfo();
|
| | | userInfo.setPhone(phone);
|
| | | userInfo.setPortrait(portrait);
|
| | | userInfo.setAppId(appId);
|
| | | userInfo.setNickName(weiXinUser.getNickname());
|
| | | userInfo.setWxName(weiXinUser.getNickname());
|
| | | userInfo.setWxOpenId(weiXinUser.getOpenid());
|
| | | userInfo.setWxUnionId(weiXinUser.getUnionid());
|
| | | userInfo.setWxPic(weiXinUser.getHeadimgurl());
|
| | | userInfo.setLastLoginTime(System.currentTimeMillis());
|
| | | userInfo.setLoginType(2);
|
| | | userInfo.setLastLoginIp(request.getRemoteHost());
|
| | | userInfo.setState(UserInfo.STATE_NORMAL);
|
| | | addUser(userInfo);
|
| | | // 是否需要创建新账户
|
| | | UserInfo phoneUser = userInfoMapper.getEffectiveUserInfoByPhone(phone);
|
| | | if (phoneUser != null) {
|
| | | // 绑定微信
|
| | | if (StringUtil.isNullOrEmpty(phoneUser.getWxUnionId())) {
|
| | | try {
|
| | | bindWeiXin(phoneUser.getId(), weiXinUser);
|
| | | } catch (Exception e) {
|
| | | throw new UserAccountException(1, "微信绑定失败");
|
| | | }
|
| | | } else {
|
| | | throw new UserAccountException(1, "该微信已被绑定");
|
| | | }
|
| | | userInfo = userInfoMapper.selectAvailableByPrimaryKey(phoneUser.getId());
|
| | | } else {
|
| | | // 创建新账户
|
| | | userInfo = new UserInfo();
|
| | | userInfo.setPhone(phone);
|
| | | userInfo.setPortrait(portrait);
|
| | | userInfo.setAppId(appId);
|
| | | userInfo.setNickName(weiXinUser.getNickname());
|
| | | userInfo.setWxName(weiXinUser.getNickname());
|
| | | userInfo.setWxOpenId(weiXinUser.getOpenid());
|
| | | userInfo.setWxUnionId(weiXinUser.getUnionid());
|
| | | userInfo.setWxPic(weiXinUser.getHeadimgurl());
|
| | | userInfo.setLastLoginTime(System.currentTimeMillis());
|
| | | userInfo.setLoginType(2);
|
| | | userInfo.setLastLoginIp(request.getRemoteHost());
|
| | | userInfo.setState(UserInfo.STATE_NORMAL);
|
| | | addUser(userInfo);
|
| | | }
|
| | |
|
| | | Long uid = userInfo.getId();
|
| | | ThreadUtil.run(new Runnable() {
|
| | |
| | | // 插入记录
|
| | | userInfoDeleteRecordService.addDeleteRecord(uid, UserInfo.STATE_DELETE_OUT_OF_DATE, reason);
|
| | | }
|
| | |
|
| | |
|
| | | }
|