| | |
| | | import com.yeshi.fanli.service.inter.user.msg.UserAccountMsgNotificationService;
|
| | | import com.yeshi.fanli.service.inter.user.tb.UserExtraTaoBaoInfoService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.FilePathEnum;
|
| | | import com.yeshi.fanli.util.FileUtil;
|
| | | import com.yeshi.fanli.util.RedisKeyEnum;
|
| | | import com.yeshi.fanli.util.RedisManager;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.ThreadUtil;
|
| | |
| | | fw.close();
|
| | |
|
| | | String logUrl = COSManager.getInstance()
|
| | | .uploadFile(new File(logPath), "beifen/" + new File(logPath).getName()).getUrl();
|
| | | .uploadFile(new File(logPath), FilePathEnum.beifen.getPath() + new File(logPath).getName()).getUrl();
|
| | | return logUrl;
|
| | | } catch (IOException e) {
|
| | | e.printStackTrace();
|
| | |
| | | // 清空限制
|
| | | redisManager.clearSMSFrequencyLimit(phone, SMSHistory.TYPE_LOGIN);
|
| | | // 清理次数
|
| | | redisManager.removeCommonString("sendMSNLoginCount" + phone);
|
| | | String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.SMSLoginCount, phone);
|
| | | redisManager.removeCommonString(key);
|
| | |
|
| | |
|
| | | // 采用redis事务防止一个手机号多次注册问题
|
| | | String watchKey = StringUtil.Md5("REGISTER:" + phone);
|
| | |
| | | InputStream asInputStream = HttpUtil.getAsInputStream(weiXinUser.getHeadimgurl());
|
| | | if (asInputStream != null) {
|
| | | FileUploadResult result = COSManager.getInstance().uploadFile(asInputStream,
|
| | | String.format("/portrait/wx/%s_%s.jpg", weiXinUser.getUnionid(),
|
| | | String.format(FilePathEnum.userPortrait.getPath() + "%s_%s.jpg", weiXinUser.getUnionid(),
|
| | | System.currentTimeMillis() + ""));
|
| | | if (result != null && !StringUtil.isNullOrEmpty(result.getUrl()))
|
| | | portrait = result.getUrl();
|
| | |
| | |
|
| | | UserInfo userInfo = userInfoMapper.getEffectiveUserInfoByWXUnionId(weiXinUser.getUnionid());
|
| | | if (userInfo == null) {
|
| | | String longinKey = StringUtil.Md5("WXLogin:" + weiXinUser.getUnionid());
|
| | | redisManager.cacheCommonString(longinKey, JsonUtil.getSimpleGson().toJson(weiXinUser), 60 * 20);
|
| | | throw new UserAccountException(101, longinKey);
|
| | | 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);
|
| | | }
|
| | | // 更新账户登录信息
|
| | | updateLonginInfo(userInfo, loginType, request);
|
| | |
| | |
|
| | | }
|
| | |
|
| | | @Transactional(rollbackFor=UserAccountException.class)
|
| | | @Override
|
| | | public void bindWeiXin(AcceptData acceptData, Long uid, String code) throws UserAccountException {
|
| | | WXAccountInfoDTO wxAccount = Constant.getWXAccount(acceptData.getPlatform(), acceptData.getVersion());
|
| | | WeiXinUser weiXinUser = WXLoginUtil.getWeiXinUser(code, wxAccount.getAppId(), wxAccount.getAppSecret());
|
| | | if (weiXinUser == null) {
|
| | | throw new UserAccountException(2, "微信帐号授权失败");
|
| | | }
|
| | |
|
| | | String wxUnionId = weiXinUser.getUnionid();
|
| | | if (StringUtil.isNullOrEmpty(wxUnionId)) {
|
| | | throw new UserAccountException(2, "微信帐号授权失败");
|
| | | }
|
| | | bindWeiXin(uid, weiXinUser);
|
| | | }
|
| | | |
| | | |
| | | |
| | | |
| | | @Transactional(rollbackFor=UserAccountException.class)
|
| | | @Override
|
| | | public void bindWeiXin(Long uid,WeiXinUser weiXinUser) throws UserAccountException {
|
| | | UserInfo user = userInfoMapper.selectAvailableByPrimaryKey(uid);
|
| | | if (user == null) {
|
| | | throw new UserAccountException(1, "用户不存在");
|
| | | }
|
| | | WXAccountInfoDTO wxAccount = Constant.getWXAccount(acceptData.getPlatform(), acceptData.getVersion());
|
| | | WeiXinUser weiXinUser = WXLoginUtil.getWeiXinUser(code, wxAccount.getAppId(), wxAccount.getAppSecret());
|
| | | |
| | | if (weiXinUser == null) {
|
| | | throw new UserAccountException(2, "微信帐号授权失败");
|
| | | }
|
| | |
| | | LogHelper.test("微信头像下载失败: " + weiXinUser.getUnionid() + " " + headimgurl);
|
| | | } else {
|
| | | FileUploadResult result = COSManager.getInstance().uploadFile(asInputStream, String
|
| | | .format("/portrait/wx/%s_%s.jpg", weiXinUser.getUnionid(), System.currentTimeMillis() + ""));
|
| | | .format(FilePathEnum.userPortrait.getPath() + "%s_%s.jpg", weiXinUser.getUnionid(), System.currentTimeMillis() + ""));
|
| | | if (result != null && !StringUtil.isNullOrEmpty(result.getUrl())) {
|
| | | headimgurl = result.getUrl();
|
| | | } else {
|
| | |
| | | InputStream asInputStream = HttpUtil.getAsInputStream(weiXinUser.getHeadimgurl());
|
| | | if (asInputStream != null) {
|
| | | FileUploadResult result = COSManager.getInstance().uploadFile(asInputStream, String
|
| | | .format("/portrait/wx/%s_%s.jpg", weiXinUser.getUnionid(), System.currentTimeMillis() + ""));
|
| | | .format(FilePathEnum.userPortrait.getPath() +"%s_%s.jpg", weiXinUser.getUnionid(), System.currentTimeMillis() + ""));
|
| | | if (result != null && !StringUtil.isNullOrEmpty(result.getUrl()))
|
| | | portrait = result.getUrl();
|
| | | } else {
|