| | |
| | | import javax.servlet.http.HttpServletRequest;
|
| | | import javax.servlet.http.HttpSession;
|
| | |
|
| | | import com.yeshi.fanli.entity.SystemEnum;
|
| | | import com.yeshi.fanli.util.*;
|
| | | import org.springframework.context.annotation.Lazy;
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | | import org.yeshi.utils.HttpUtil;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | | import org.yeshi.utils.SystemUtil;
|
| | | import org.yeshi.utils.entity.FileUploadResult;
|
| | | import org.yeshi.utils.entity.ProxyIP;
|
| | | import org.yeshi.utils.tencentcloud.COSManager;
|
| | |
|
| | | import com.google.gson.Gson;
|
| | |
| | | import com.yeshi.fanli.service.inter.user.invite.ThreeSaleSerivce;
|
| | | 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.RedisKeyEnum;
|
| | | import com.yeshi.fanli.util.RedisManager;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.ThreadUtil;
|
| | | import com.yeshi.fanli.util.factory.msg.MsgAccountDetailFactory;
|
| | | import com.yeshi.fanli.util.wx.WXLoginUtil;
|
| | |
|
| | |
| | | @Resource
|
| | | private RedisManager redisManager;
|
| | |
|
| | | @Resource
|
| | | private UserInfoMapper userInfoMapper;
|
| | | // @Resource
|
| | | // private UserInfoMapper userInfoMapper;
|
| | |
|
| | | @Resource
|
| | | private UserInfoService userInfoService;
|
| | |
| | | throw new UserAccountException(Constant.CODE_FORBIDDEN_USER,
|
| | | Constant.FORBIDDEN_USER_REASON_DESC);
|
| | | }
|
| | | userInfo = getUserInfoByTaoBaoOpenId(appId, tbUserInfo.getOpenid());
|
| | | userInfo = getUserInfoByTaoBaoOpenId(SystemInfoUtil.getSystem(acceptData.getPlatform(), acceptData.getPackages()), tbUserInfo.getOpenid());
|
| | | // 判断用户是否被删除
|
| | | if (userInfo != null && userInfo.getState() != null && (userInfo.getState() != UserInfo.STATE_NORMAL))
|
| | | userInfo = null;
|
| | |
| | | userInfo.setNickName(tbUserInfo.getNickName());
|
| | | userInfo.setPortrait(tbUserInfo.getPortrait());
|
| | | userInfo.setLoginType(loginType);
|
| | | userInfo.setSystem(SystemInfoUtil.getSystem(acceptData));
|
| | | session.setAttribute("LAST_LOGIN_USER", userInfo);
|
| | | // 需要微信登录
|
| | | return new LoginResult(LoginResult.TYPE_WX, userInfo);
|
| | |
| | | if (identifyCode != null && identifyCode.getEffective() != null && identifyCode.getEffective())
|
| | | throw new UserAccountException(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC);
|
| | |
|
| | | userInfo = getUserInfoByWXUnionId(appId, weiXinUser.getUnionid());
|
| | | userInfo = getUserInfoByWXUnionId(SystemInfoUtil.getSystem(acceptData.getPlatform(), acceptData.getPackages()), weiXinUser.getUnionid());
|
| | | // 判断用户是否被删除
|
| | | if (userInfo != null && userInfo.getState() != null && (userInfo.getState() != UserInfo.STATE_NORMAL))
|
| | | userInfo = null;
|
| | |
| | | updateUserInfo.setLastLoginIp(request.getRemoteHost());
|
| | | // 更新openId
|
| | | updateUserInfo.setOpenid(weiXinUser.getOpenid());
|
| | |
|
| | | userInfoMapper.updateByPrimaryKeySelective(updateUserInfo);
|
| | | userInfoService.updateByPrimaryKeySelective(updateUserInfo);
|
| | | // 删除邀请图片
|
| | | spreadUserImgService.deleteImgUrl(userInfo.getId());
|
| | | return new LoginResult(LoginResult.TYPE_NORMAL, userInfo);
|
| | |
| | | userInfo.setLastLoginTime(System.currentTimeMillis());
|
| | | userInfo.setLoginType(loginType);
|
| | | userInfo.setLastLoginIp(request.getRemoteHost());
|
| | | userInfo.setSystem(SystemInfoUtil.getSystem(acceptData));
|
| | | addUser(userInfo);
|
| | |
|
| | | return new LoginResult(LoginResult.TYPE_NORMAL, userInfo);
|
| | |
| | | MsgAccountDetailFactory.TYPE_TB);
|
| | | }
|
| | | updateUserInfo.setLastLoginTime(System.currentTimeMillis());
|
| | | userInfoMapper.updateByPrimaryKeySelective(updateUserInfo);
|
| | | userInfoService.updateByPrimaryKeySelective(updateUserInfo);
|
| | | session.removeAttribute("LAST_LOGIN_USER");
|
| | |
|
| | | // 使分销关系生效
|
| | |
| | | userInfo.setLastLoginTime(System.currentTimeMillis());
|
| | | userInfo.setLoginType(loginType);
|
| | | userInfo.setLastLoginIp(request.getRemoteHost());
|
| | | userInfo.setSystem(SystemInfoUtil.getSystem(acceptData));
|
| | | addUser(userInfo);
|
| | | session.removeAttribute("LAST_LOGIN_USER");
|
| | | return new LoginResult(LoginResult.TYPE_NORMAL, userInfo);
|
| | |
| | | if (identifyCode1 != null && identifyCode1.getEffective() != null && identifyCode1.getEffective())
|
| | | throw new UserAccountException(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC);
|
| | |
|
| | | userInfo = getUserInfoByPhone(appId, phone);
|
| | | userInfo = getUserInfoByPhone(SystemInfoUtil.getSystem(acceptData.getPlatform(), acceptData.getPackages()), phone);
|
| | | // 判断用户是否被删除
|
| | | if (userInfo != null && userInfo.getState() != null && (userInfo.getState() != UserInfo.STATE_NORMAL))
|
| | | userInfo = null;
|
| | |
| | | userInfo.setPortrait(Constant.systemCommonConfig.getDefaultPortrait());
|
| | | userInfo.setPhone(phone);
|
| | | userInfo.setLoginType(loginType);
|
| | | userInfo.setSystem(SystemInfoUtil.getSystem(acceptData));
|
| | | session.setAttribute("LAST_LOGIN_USER", userInfo);
|
| | | // 询问是否绑定微信
|
| | | return new LoginResult(LoginResult.TYPE_WX, userInfo);
|
| | |
| | | if (identifyCode != null && identifyCode.getEffective() != null && identifyCode.getEffective())
|
| | | throw new UserAccountException(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC);
|
| | | }
|
| | | userInfo = getUserInfoByTaoBaoOpenId(appId, tbUserInfo.getOpenid());
|
| | | userInfo = getUserInfoByTaoBaoOpenId(SystemInfoUtil.getSystem(acceptData.getPlatform(), acceptData.getPackages()), tbUserInfo.getOpenid());
|
| | | break;
|
| | | case 2:// 微信
|
| | | // 通过Code换取信息
|
| | |
| | | if (identifyCode != null && identifyCode.getEffective() != null && identifyCode.getEffective())
|
| | | throw new UserAccountException(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC);
|
| | |
|
| | | userInfo = getUserInfoByWXUnionId(appId, weiXinUser.getUnionid());
|
| | | userInfo = getUserInfoByWXUnionId(SystemInfoUtil.getSystem(acceptData.getPlatform(), acceptData.getPackages()), weiXinUser.getUnionid());
|
| | | break;
|
| | | case 3:// 手机号码
|
| | | // 判断是否被封禁
|
| | |
| | | .listByTypeAndIdentifyCode(ForbiddenUserIdentifyCodeTypeEnum.phone, phone);
|
| | | if (identifyCode1 != null && identifyCode1.getEffective() != null && identifyCode1.getEffective())
|
| | | throw new UserAccountException(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC);
|
| | | userInfo = getUserInfoByPhone(appId, phone);
|
| | | userInfo = getUserInfoByPhone(SystemInfoUtil.getSystem(acceptData.getPlatform(), acceptData.getPackages()), phone);
|
| | | break;
|
| | | }
|
| | |
|
| | |
| | | if (userInfo != null) {
|
| | | UserInfo updateUserInfo = new UserInfo(userInfo.getId());
|
| | | updateUserInfo.setLastLoginTime(System.currentTimeMillis());
|
| | | userInfoMapper.updateByPrimaryKeySelective(updateUserInfo);
|
| | | userInfoService.updateByPrimaryKeySelective(updateUserInfo);
|
| | | return new LoginResult(LoginResult.TYPE_NORMAL, userInfo);
|
| | | } else {// 询问是否创建用户
|
| | | userInfo = new UserInfo();
|
| | |
| | | userInfo.setPhone(phone);
|
| | | break;
|
| | | }
|
| | | userInfo.setSystem(SystemInfoUtil.getSystem(acceptData));
|
| | | return new LoginResult(LoginResult.TYPE_CREATE, userInfo);
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | /**
|
| | | * 根据系统与unionid寻找用户
|
| | | * |
| | | * @param appId
|
| | | * @param system
|
| | | * @param unionId
|
| | | * @return
|
| | | * @throws UserAccountException
|
| | | */
|
| | | @Override
|
| | | public UserInfo getUserInfoByWXUnionId(String appId, String unionId) throws UserAccountException {
|
| | | if (StringUtil.isNullOrEmpty(appId))
|
| | | throw new UserAccountException(1, "appId为空");
|
| | | public UserInfo getUserInfoByWXUnionId(SystemEnum system, String unionId) throws UserAccountException {
|
| | | if (system == null)
|
| | | throw new UserAccountException(1, "系统");
|
| | | if (StringUtil.isNullOrEmpty(unionId))
|
| | | throw new UserAccountException(2, "unionId为空");
|
| | |
|
| | | List<UserInfo> list = userInfoMapper.listByAppIdAndWXUnionId(appId, unionId);
|
| | | List<UserInfo> list = userInfoService.listBySystemAndWXUnionId(system, unionId);
|
| | | // 剔除被删除掉的用户
|
| | | for (int i = 0; i < list.size(); i++) {
|
| | | if (list.get(i).getState() == UserInfo.STATE_NORMAL) {
|
| | |
| | | return null;
|
| | | }
|
| | |
|
| | |
|
| | | /**
|
| | | * 根据系统和淘宝的Openid寻找用户
|
| | | * |
| | | * @param appId
|
| | | * @param system
|
| | | * @param openId
|
| | | * @return
|
| | | * @throws UserAccountException
|
| | | */
|
| | | public UserInfo getUserInfoByTaoBaoOpenId(String appId, String openId) throws UserAccountException {
|
| | | if (StringUtil.isNullOrEmpty(appId))
|
| | | throw new UserAccountException(1, "appId为空");
|
| | | public UserInfo getUserInfoByTaoBaoOpenId(SystemEnum system, String openId) throws UserAccountException {
|
| | | if (system == null)
|
| | | throw new UserAccountException(1, "系统为空");
|
| | | if (StringUtil.isNullOrEmpty(openId))
|
| | | throw new UserAccountException(2, "openId为空");
|
| | | List<UserInfo> list = userInfoMapper.listByAppIdAndTaoBaoOpenId(appId, openId);
|
| | | List<UserInfo> list = userInfoService.listBySystemAndTaoBaoOpenId(system, openId);
|
| | |
|
| | | // 剔除被删除掉的用户
|
| | | for (int i = 0; i < list.size(); i++) {
|
| | |
| | |
|
| | | /**
|
| | | * 根据系统和电话号码寻找用户
|
| | | * |
| | | * @param appId
|
| | | * @param system
|
| | | * @param phone
|
| | | * @return
|
| | | * @throws UserAccountException
|
| | | */
|
| | | public UserInfo getUserInfoByPhone(String appId, String phone) throws UserAccountException {
|
| | | if (StringUtil.isNullOrEmpty(appId))
|
| | | throw new UserAccountException(1, "appId为空");
|
| | | public UserInfo getUserInfoByPhone(SystemEnum system, String phone) throws UserAccountException {
|
| | | if (system == null)
|
| | | throw new UserAccountException(1, "系统为空");
|
| | | if (StringUtil.isNullOrEmpty(phone))
|
| | | throw new UserAccountException(2, "phone为空");
|
| | | List<UserInfo> list = userInfoMapper.listByAppIdAndPhone(appId, phone);
|
| | | List<UserInfo> list = userInfoService.listBySystemAndPhone(system, phone);
|
| | |
|
| | | // 剔除被删除掉的用户
|
| | | for (int i = 0; i < list.size(); i++) {
|
| | |
| | | private void updateLatestLoginTime(Long uid) {
|
| | | UserInfo userInfo = new UserInfo(uid);
|
| | | userInfo.setLastLoginTime(System.currentTimeMillis());
|
| | | userInfoMapper.updateByPrimaryKeySelective(userInfo);
|
| | | userInfoService.updateByPrimaryKeySelective(userInfo);
|
| | | }
|
| | |
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | @Override
|
| | | public void register(UserInfo userInfo) throws UserAccountException {
|
| | | if (!StringUtil.isNullOrEmpty(userInfo.getPhone())) {
|
| | | UserInfo user = getUserInfoByPhone(userInfo.getAppId(), userInfo.getPhone());
|
| | | UserInfo user = getUserInfoByPhone(userInfo.getSystem(), userInfo.getPhone());
|
| | | if (user != null)
|
| | | throw new UserAccountException(50001, "电话号码已经被绑定");
|
| | | }
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(userInfo.getOpenid())) {
|
| | | UserInfo user = getUserInfoByTaoBaoOpenId(userInfo.getAppId(), userInfo.getOpenid());
|
| | | UserInfo user = getUserInfoByTaoBaoOpenId(userInfo.getSystem(), userInfo.getOpenid());
|
| | | if (user != null)
|
| | | throw new UserAccountException(50002, "淘宝号已经被绑定");
|
| | | }
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(userInfo.getWxUnionId())) {
|
| | | UserInfo user = getUserInfoByWXUnionId(userInfo.getAppId(), userInfo.getWxUnionId());
|
| | | UserInfo user = getUserInfoByWXUnionId(userInfo.getSystem(), userInfo.getWxUnionId());
|
| | | if (user != null)
|
| | | throw new UserAccountException(50003, "微信号已经被注册");
|
| | | }
|
| | |
| | | @Transactional
|
| | | @Override
|
| | | public void addUser(UserInfo user) {
|
| | |
|
| | | Long maxUid = userInfoMapper.getMaxUid();
|
| | | if (maxUid == null)
|
| | | maxUid = 100000L;
|
| | | long dd = (long) (Math.random() * 100);
|
| | | if (dd == 0) {
|
| | | dd = 1;
|
| | | }
|
| | | long uid = maxUid + dd;
|
| | | user.setId(uid);
|
| | | user.setCreatetime(System.currentTimeMillis());
|
| | | user.setRank(0);
|
| | | if (StringUtil.isNullOrEmpty(user.getPortrait()))
|
| | | user.setPortrait(Constant.systemCommonConfig.getDefaultPortrait());
|
| | | userInfoMapper.insertSelective(user);
|
| | |
|
| | | userInfoService.createUser(user,user.getSystem());
|
| | | // 昵称为空时 默认昵称
|
| | | if (StringUtil.isNullOrEmpty(user.getNickName())) {
|
| | | UserInfo updateUserInfo = new UserInfo(user.getId());
|
| | | updateUserInfo.setNickName(Constant.systemCommonConfig.getDefaultNickName() + user.getId());
|
| | | userInfoMapper.updateByPrimaryKeySelective(updateUserInfo);
|
| | | userInfoService.updateByPrimaryKeySelective(updateUserInfo);
|
| | | }
|
| | |
|
| | | try {
|
| | |
| | |
|
| | | // 添加账号绑定历史
|
| | | if (!StringUtil.isNullOrEmpty(user.getPhone()))
|
| | | userInfoModifyRecordService.addModifyRecord(uid, ModifyTypeEnum.bindPhone, user.getPhone());
|
| | | userInfoModifyRecordService.addModifyRecord(user.getId(), ModifyTypeEnum.bindPhone, user.getPhone());
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(user.getWxUnionId()))
|
| | | userInfoModifyRecordService.addModifyRecord(uid, ModifyTypeEnum.bindWeiXin, user.getWxUnionId());
|
| | | userInfoModifyRecordService.addModifyRecord(user.getId(), ModifyTypeEnum.bindWeiXin, user.getWxUnionId());
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void updateUserSelective(UserInfo user) {
|
| | | userInfoMapper.updateByPrimaryKeySelective(user);
|
| | | userInfoService.updateByPrimaryKeySelective(user);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void bindPhone(Long uid, String phone) throws UserAccountException {
|
| | | UserInfo user = userInfoMapper.selectAvailableByPrimaryKey(uid);
|
| | | UserInfo user = userInfoService.selectAvailableByPrimaryKey(uid);
|
| | | if (user == null)
|
| | | throw new UserAccountException(4, "用户不存在");
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(user.getPhone()))
|
| | | throw new UserAccountException(5, "当前账号已经绑定了手机号,请先解绑");
|
| | |
|
| | | UserInfo phoneUser = getUserInfoByPhone(user.getAppId(), phone);
|
| | | UserInfo phoneUser = getUserInfoByPhone(user.getSystem(), phone);
|
| | | if (phoneUser != null)
|
| | | throw new UserAccountException(6, "当前电话号码已经被绑定");
|
| | |
|
| | | UserInfo update = new UserInfo(user.getId());
|
| | | update.setPhone(phone);
|
| | | userInfoMapper.updateByPrimaryKeySelective(update);
|
| | | userInfoService.updateByPrimaryKeySelective(update);
|
| | | userAccountMsgNotificationService.bindingSuccess(uid, MsgAccountDetailFactory.TYPE_PHONE);
|
| | |
|
| | | userInfoModifyRecordService.addModifyRecord(uid, ModifyTypeEnum.bindPhone, phone);
|
| | |
| | |
|
| | | @Override
|
| | | public void unBindPhone(Long uid, String phone) throws UserAccountException {
|
| | | UserInfo user = userInfoMapper.selectAvailableByPrimaryKey(uid);
|
| | | UserInfo user = userInfoService.selectAvailableByPrimaryKey(uid);
|
| | | if (user == null)
|
| | | throw new UserAccountException(4, "用户不存在");
|
| | |
|
| | |
| | |
|
| | | UserInfo updateUserInfo = new UserInfo(uid);
|
| | | updateUserInfo.setPhone("");
|
| | | userInfoMapper.updateByPrimaryKeySelective(updateUserInfo);
|
| | | userInfoService.updateByPrimaryKeySelective(updateUserInfo);
|
| | | userAccountMsgNotificationService.unBindingSuccess(uid, MsgAccountDetailFactory.TYPE_PHONE);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void bindTaoBao(Long uid, String tbOpenId, String tbNickName, String tbPortrait)
|
| | | throws UserAccountException {
|
| | | UserInfo user = userInfoMapper.selectAvailableByPrimaryKey(uid);
|
| | | UserInfo user = userInfoService.selectAvailableByPrimaryKey(uid);
|
| | | if (user == null)
|
| | | throw new UserAccountException(4, "用户不存在");
|
| | |
|
| | |
| | | if (!StringUtil.isNullOrEmpty(user.getOpenid()) && user.getOpenid().equalsIgnoreCase(tbOpenId))
|
| | | return;
|
| | |
|
| | | UserInfo taoBaoUser = getUserInfoByTaoBaoOpenId(user.getAppId(), tbOpenId);
|
| | | UserInfo taoBaoUser = getUserInfoByTaoBaoOpenId(user.getSystem(), tbOpenId);
|
| | | if (taoBaoUser != null)
|
| | | throw new UserAccountException(6, "当前淘宝号已经被绑定");
|
| | | UserInfo update = new UserInfo(user.getId());
|
| | |
| | | update.setNickName(tbNickName);
|
| | | update.setPortrait(tbPortrait);
|
| | | }
|
| | | userInfoMapper.updateByPrimaryKeySelective(update);
|
| | | userInfoService.updateByPrimaryKeySelective(update);
|
| | |
|
| | | userAccountMsgNotificationService.bindingSuccess(uid, MsgAccountDetailFactory.TYPE_TB);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void unBindTaoBao(Long uid) throws UserAccountException {
|
| | | UserInfo user = userInfoMapper.selectAvailableByPrimaryKey(uid);
|
| | | UserInfo user = userInfoService.selectAvailableByPrimaryKey(uid);
|
| | | if (user == null)
|
| | | throw new UserAccountException(4, "用户不存在");
|
| | | if (StringUtil.isNullOrEmpty(user.getOpenid()))
|
| | |
| | | update.setPortrait(Constant.systemCommonConfig.getDefaultPortrait());
|
| | | }
|
| | |
|
| | | userInfoMapper.updateByPrimaryKeySelective(update);
|
| | | userInfoService.updateByPrimaryKeySelective(update);
|
| | |
|
| | | userExtraTaoBaoInfoService.unBindUid(uid);
|
| | |
|
| | |
| | |
|
| | | @Override
|
| | | public void changeWXBind(AcceptData acceptData, Long uid, String code) throws UserAccountException {
|
| | | UserInfo user = userInfoMapper.selectAvailableByPrimaryKey(uid);
|
| | | UserInfo user = userInfoService.selectAvailableByPrimaryKey(uid);
|
| | | if (user == null)
|
| | | throw new UserAccountException(4, "用户不存在");
|
| | | WXAccountInfoDTO wxAccount = Constant.getWXAccount(acceptData.getPlatform(), acceptData.getVersion());
|
| | |
| | | if (weiXinUser.getUnionid().equalsIgnoreCase(user.getWxUnionId()))
|
| | | throw new UserAccountException(12, "亲,请登录其它微信号进行更换绑定");
|
| | |
|
| | | UserInfo newUser = getUserInfoByWXUnionId(user.getAppId(), weiXinUser.getUnionid());
|
| | | UserInfo newUser = getUserInfoByWXUnionId(user.getSystem(), weiXinUser.getUnionid());
|
| | | if (newUser != null)
|
| | | throw new UserAccountException(13, "该微信号已被其他账号绑定");
|
| | |
|
| | |
| | | updateUserInfo.setPortrait(weiXinUser.getHeadimgurl());
|
| | | }
|
| | |
|
| | | userInfoMapper.updateByPrimaryKeySelective(updateUserInfo);
|
| | | userInfoService.updateByPrimaryKeySelective(updateUserInfo);
|
| | |
|
| | | userAccountMsgNotificationService.changeBindingSuccess(uid, MsgAccountDetailFactory.TYPE_WX);
|
| | |
|
| | |
| | | public void clearUserPortrait(Long uid) {
|
| | | if (uid == null)
|
| | | return;
|
| | | UserInfo user = userInfoMapper.selectAvailableByPrimaryKey(uid);
|
| | | UserInfo user = userInfoService.selectAvailableByPrimaryKey(uid);
|
| | | String prefix = String.format("/portrait/wx/%s_", user.getWxUnionId());
|
| | | ObjectListing list = COSManager.getInstance().getObjectList(prefix, null, 30);
|
| | | if (list != null && list.getObjectSummaries() != null)
|
| | |
| | | public String repairPortrait(Long uid) {
|
| | | if (uid == null)
|
| | | return null;
|
| | | UserInfo user = userInfoMapper.selectAvailableByPrimaryKey(uid);
|
| | | UserInfo user = userInfoService.selectAvailableByPrimaryKey(uid);
|
| | | if (user == null)
|
| | | return null;
|
| | | String prefix = String.format("/portrait/wx/%s_", user.getWxUnionId());
|
| | |
| | | if (!StringUtil.isNullOrEmpty(portrait)) {
|
| | | UserInfo updateUser = new UserInfo(uid);
|
| | | updateUser.setPortrait(portrait);
|
| | | userInfoMapper.updateByPrimaryKeySelective(updateUser);
|
| | | userInfoService.updateByPrimaryKeySelective(updateUser);
|
| | | return portrait;
|
| | | }
|
| | | }
|
| | |
| | |
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | @Override
|
| | | public UserInfo loginPhone(HttpServletRequest request, int loginType, String vcode, String phone, String appId)
|
| | | public UserInfo loginPhone(ProxyIP ipInfo, AcceptData acceptData, int loginType, String vcode, String phone, String appId)
|
| | | throws UserAccountException {
|
| | |
|
| | | // 空额清理
|
| | |
| | | } else {
|
| | |
|
| | | // 查询是否存在该电话历史用户
|
| | | UserInfo userInfo = userInfoMapper.getEffectiveUserInfoByPhone(phone);
|
| | | UserInfo userInfo = userInfoService.getEffectiveUserInfoByPhone(phone, SystemInfoUtil.getSystem(acceptData.getPlatform(), acceptData.getPackages()));
|
| | | if (userInfo != null) {
|
| | | // 更新账户登录信息
|
| | | updateLonginInfo(userInfo, loginType, request);
|
| | | updateLonginInfo(userInfo, loginType, ipInfo);
|
| | | } else {
|
| | | userInfo = new UserInfo();
|
| | | userInfo.setAppId(appId);
|
| | |
| | | userInfo.setPhone(phone);
|
| | | userInfo.setLoginType(loginType);
|
| | | userInfo.setState(UserInfo.STATE_NORMAL);
|
| | | userInfo.setSystem(SystemInfoUtil.getSystem(acceptData));
|
| | | // 创建用户
|
| | | addUser(userInfo);
|
| | |
|
| | |
| | |
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | @Override
|
| | | public UserInfo loginPhoneNew(HttpServletRequest request, int loginType, String vcode, String phone, String appId)
|
| | | public UserInfo loginPhoneNew(ProxyIP ipInfo, AcceptData acceptData, int loginType, String vcode, String phone, String appId)
|
| | | throws UserAccountException {
|
| | | // 空额清理
|
| | | if (phone == null || phone.trim().length() == 0) {
|
| | |
| | | if (exec == null || exec.size() == 0) {
|
| | | throw new UserAccountException(10, "请稍后再试");
|
| | | } else {
|
| | |
|
| | | // 查询是否存在该电话历史用户
|
| | | UserInfo userInfo = userInfoMapper.getEffectiveUserInfoByPhone(phone);
|
| | | UserInfo userInfo = userInfoService.getEffectiveUserInfoByPhone(phone, SystemInfoUtil.getSystem(acceptData.getPlatform(), acceptData.getPackages()));
|
| | | if (userInfo != null) {
|
| | | // 更新账户登录信息
|
| | | updateLonginInfo(userInfo, loginType, request);
|
| | | updateLonginInfo(userInfo, loginType, ipInfo);
|
| | | } else {
|
| | | // 绑定微信
|
| | | String keylogin = RedisKeyEnum.getRedisKey(RedisKeyEnum.emptyKey, StringUtil.Md5("phoneLogin:" + phone));
|
| | |
| | | }
|
| | |
|
| | |
|
| | | |
| | | @Transactional(rollbackFor = Exception.class)
|
| | | @Override
|
| | | public UserInfo loginWinXin(HttpServletRequest request, AcceptData acceptData, int loginType, String code,
|
| | | public UserInfo loginWinXin(ProxyIP ipInfo, AcceptData acceptData, int loginType, String code,
|
| | | String appId) throws UserAccountException {
|
| | | // 日志信息
|
| | | JSONObject logInfo = new JSONObject();
|
| | |
| | | if (exec == null || exec.size() == 0) {
|
| | | throw new UserAccountException(10, "请稍后再试");
|
| | | } else {
|
| | |
|
| | | UserInfo userInfo = userInfoMapper.getEffectiveUserInfoByWXUnionId(weiXinUser.getUnionid());
|
| | | UserInfo userInfo = userInfoService.getEffectiveUserInfoByWXUnionId(weiXinUser.getUnionid(), SystemInfoUtil.getSystem(acceptData.getPlatform(), acceptData.getPackages()));
|
| | | // 直接用的微信登录
|
| | | if (userInfo != null) {
|
| | | LogHelper.test("微信unionID存在:" + weiXinUser.getUnionid());
|
| | | // 更新账户登录信息
|
| | | updateLonginInfo(userInfo, loginType, request);
|
| | | updateLonginInfo(userInfo, loginType,ipInfo );
|
| | | // 删除邀请分享图
|
| | | spreadUserImgService.deleteImgUrl(userInfo.getId());
|
| | | } else {
|
| | |
| | | userInfo.setWxPic(weiXinUser.getHeadimgurl());
|
| | | userInfo.setLastLoginTime(System.currentTimeMillis());
|
| | | userInfo.setLoginType(loginType);
|
| | | userInfo.setLastLoginIp(request.getRemoteHost());
|
| | | userInfo.setLastLoginIp(ipInfo.getIp());
|
| | | userInfo.setState(UserInfo.STATE_NORMAL);
|
| | | userInfo.setSystem(SystemInfoUtil.getSystem(acceptData));
|
| | | addUser(userInfo);
|
| | |
|
| | | try {
|
| | |
| | |
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | @Override
|
| | | public UserInfo loginWeiXinNew(HttpServletRequest request, AcceptData acceptData, int loginType, String wxCode,
|
| | | public UserInfo loginWeiXinNew(ProxyIP ipInfo, AcceptData acceptData, int loginType, String wxCode,
|
| | | String appId) throws UserAccountException {
|
| | | // 日志信息
|
| | | JSONObject logInfo = new JSONObject();
|
| | |
| | | throw new UserAccountException(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC);
|
| | | }
|
| | |
|
| | | UserInfo userInfo = userInfoMapper.getEffectiveUserInfoByWXUnionId(weiXinUser.getUnionid());
|
| | | UserInfo userInfo = userInfoService.getEffectiveUserInfoByWXUnionId(weiXinUser.getUnionid(), SystemInfoUtil.getSystem(acceptData));
|
| | | if (userInfo == null) {
|
| | | String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.emptyKey,
|
| | | StringUtil.Md5("WXLogin:" + weiXinUser.getUnionid()));
|
| | |
| | | throw new UserAccountException(101, key);
|
| | | }
|
| | | // 更新账户登录信息
|
| | | updateLonginInfo(userInfo, loginType, request);
|
| | | updateLonginInfo(userInfo, loginType, ipInfo);
|
| | | Long uid = userInfo.getId();
|
| | | ThreadUtil.run(new Runnable() {
|
| | | public void run() {
|
| | |
| | | *
|
| | | * @param userInfo
|
| | | * @param loginType
|
| | | * @param request
|
| | | * @param ipInfo
|
| | | */
|
| | | public void updateLonginInfo(UserInfo userInfo, int loginType, HttpServletRequest request) {
|
| | | private void updateLonginInfo(UserInfo userInfo, int loginType, ProxyIP ipInfo) {
|
| | | // 设置登录时间与登录类型
|
| | | UserInfo updateUserInfo = new UserInfo(userInfo.getId());
|
| | | updateUserInfo.setLastLoginTime(System.currentTimeMillis());
|
| | | updateUserInfo.setLoginType(loginType);
|
| | | updateUserInfo.setLastLoginIp(request.getRemoteHost());
|
| | | userInfoMapper.updateByPrimaryKeySelective(updateUserInfo);
|
| | | updateUserInfo.setLastLoginIp(ipInfo.getIp());
|
| | | userInfoService.updateByPrimaryKeySelective(updateUserInfo);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void bindPhoneNew(Long uid, String phone) throws UserAccountException {
|
| | | UserInfo user = userInfoMapper.selectAvailableByPrimaryKey(uid);
|
| | | UserInfo user = userInfoService.selectAvailableByPrimaryKey(uid);
|
| | | if (user == null) {
|
| | | throw new UserAccountException(1, "用户不存在");
|
| | | }
|
| | |
| | | throw new UserAccountException(2, "您已经绑定了该电话号码");
|
| | | }
|
| | |
|
| | | UserInfo phoneUser = userInfoMapper.getEffectiveUserInfoByPhone(phone);
|
| | | UserInfo phoneUser = userInfoService.getEffectiveUserInfoByPhone(phone,user.getSystem());
|
| | | if (phoneUser != null) {
|
| | | throw new UserAccountException(2, "号码已经被占用");
|
| | | }
|
| | |
| | | // 更新电话号码
|
| | | UserInfo update = new UserInfo(user.getId());
|
| | | update.setPhone(phone);
|
| | | userInfoMapper.updateByPrimaryKeySelective(update);
|
| | | userInfoService.updateByPrimaryKeySelective(update);
|
| | | // 加入绑定记录
|
| | | UserAccountBindingHistory history = new UserAccountBindingHistory();
|
| | | history.setContent(phone);
|
| | |
| | | @Transactional(rollbackFor = UserAccountException.class)
|
| | | @Override
|
| | | public void bindWeiXin(Long uid, WeiXinUser weiXinUser) throws UserAccountException {
|
| | | UserInfo user = userInfoMapper.selectAvailableByPrimaryKey(uid);
|
| | | UserInfo user = userInfoService.selectAvailableByPrimaryKey(uid);
|
| | | if (user == null) {
|
| | | throw new UserAccountException(1, "用户不存在");
|
| | | }
|
| | |
| | |
|
| | | String wxUnionIdExist = user.getWxUnionId();
|
| | | if (StringUtil.isNullOrEmpty(wxUnionIdExist)) {
|
| | | UserInfo newUser = userInfoMapper.getEffectiveUserInfoByWXUnionId(wxUnionId);
|
| | | UserInfo newUser = userInfoService.getEffectiveUserInfoByWXUnionId(wxUnionId, user.getSystem());
|
| | | if (newUser != null) {
|
| | | throw new UserAccountException(4, "该微信号已被其他帐号绑定");
|
| | | }
|
| | |
| | | }
|
| | | updateUserInfo.setPortrait(headimgurl);
|
| | | }
|
| | | userInfoMapper.updateByPrimaryKeySelective(updateUserInfo);
|
| | | userInfoService.updateByPrimaryKeySelective(updateUserInfo);
|
| | |
|
| | | // 加入绑定记录
|
| | | UserAccountBindingHistory history = new UserAccountBindingHistory();
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public UserInfo bindPhoneToLogin(String phone, String key, String appId, HttpServletRequest request)
|
| | | public UserInfo bindPhoneToLogin(ProxyIP ipinfo, AcceptData acceptData, String phone, String key)
|
| | | throws UserAccountException {
|
| | |
|
| | | // 判断手机号码是否被封禁
|
| | |
| | | if (weiXinUser == null)
|
| | | throw new UserAccountException(1, "微信授权失效,请使用微信重新登录");
|
| | |
|
| | | UserInfo userInfo = userInfoMapper.getEffectiveUserInfoByWXUnionId(weiXinUser.getUnionid());
|
| | | SystemEnum system = SystemInfoUtil.getSystem(acceptData);
|
| | |
|
| | | UserInfo userInfo = userInfoService.getEffectiveUserInfoByWXUnionId(weiXinUser.getUnionid(), system);
|
| | | // 直接用的微信登录
|
| | | if (userInfo != null)
|
| | | throw new UserAccountException(10, "该微信号已被占用");
|
| | |
| | | portrait = Constant.systemCommonConfig.getDefaultPortrait();
|
| | |
|
| | | // 是否需要创建新账户
|
| | | UserInfo phoneUser = userInfoMapper.getEffectiveUserInfoByPhone(phone);
|
| | | UserInfo phoneUser = userInfoService.getEffectiveUserInfoByPhone(phone, system);
|
| | | if (phoneUser != null) {
|
| | | // 绑定微信
|
| | | if (StringUtil.isNullOrEmpty(phoneUser.getWxUnionId())) {
|
| | |
| | | } else {
|
| | | throw new UserAccountException(1, "该微信已被绑定");
|
| | | }
|
| | | userInfo = userInfoMapper.selectAvailableByPrimaryKey(phoneUser.getId());
|
| | | userInfo = userInfoService.selectAvailableByPrimaryKey(phoneUser.getId());
|
| | | } else {
|
| | | // 创建新账户
|
| | | userInfo = new UserInfo();
|
| | | userInfo.setPhone(phone);
|
| | | userInfo.setPortrait(portrait);
|
| | | userInfo.setAppId(appId);
|
| | | userInfo.setAppId(null);
|
| | | userInfo.setNickName(weiXinUser.getNickname());
|
| | | userInfo.setWxName(weiXinUser.getNickname());
|
| | | userInfo.setWxOpenId(weiXinUser.getOpenid());
|
| | |
| | | userInfo.setWxPic(weiXinUser.getHeadimgurl());
|
| | | userInfo.setLastLoginTime(System.currentTimeMillis());
|
| | | userInfo.setLoginType(2);
|
| | | userInfo.setLastLoginIp(request.getRemoteHost());
|
| | | userInfo.setLastLoginIp(ipinfo.getIp());
|
| | | userInfo.setState(UserInfo.STATE_NORMAL);
|
| | | userInfo.setSystem(system);
|
| | | addUser(userInfo);
|
| | | }
|
| | |
|
| | |
| | |
|
| | |
|
| | | @Override
|
| | | public UserInfo bindWXToLogin(HttpServletRequest request, AcceptData acceptData, String code, String appId, String key) throws UserAccountException { |
| | | public UserInfo bindWXToLogin(ProxyIP ipInfo, AcceptData acceptData, String code, String appId, String key) throws UserAccountException {
|
| | | // 日志信息
|
| | | JSONObject logInfo = new JSONObject();
|
| | | logInfo.put("appId", appId);
|
| | | logInfo.put("code", code);
|
| | | logInfo.put("loginType", 2);
|
| | | LogHelper.lgoinInfo(logInfo.toString());
|
| | |
|
| | | SystemEnum system = SystemInfoUtil.getSystem(acceptData);
|
| | |
|
| | | // 通过Code换取信息
|
| | | WXAccountInfoDTO wxAccount = Constant.getWXAccount(acceptData.getPlatform(), acceptData.getVersion());
|
| | |
| | | throw new UserAccountException(10, "请稍后再试");
|
| | | } else {
|
| | |
|
| | | UserInfo userInfo = userInfoMapper.getEffectiveUserInfoByWXUnionId(weiXinUser.getUnionid());
|
| | | UserInfo userInfo = userInfoService.getEffectiveUserInfoByWXUnionId(weiXinUser.getUnionid(), system);
|
| | | // 直接用的微信登录
|
| | | if (userInfo != null) {
|
| | | // 绑定微信
|
| | |
| | | userInfo.setWxPic(weiXinUser.getHeadimgurl());
|
| | | userInfo.setLastLoginTime(System.currentTimeMillis());
|
| | | userInfo.setLoginType(2);
|
| | | userInfo.setLastLoginIp(request.getRemoteHost());
|
| | | userInfo.setLastLoginIp(ipInfo.getIp());
|
| | | userInfo.setState(UserInfo.STATE_NORMAL);
|
| | | userInfo.setSystem(system);
|
| | | addUser(userInfo);
|
| | |
|
| | | Long uid = userInfo.getId();
|