File was renamed from fanli-service-user/src/main/java/org/fanli/service/user/service/impl/UserAccountServiceImpl.java |
| | |
| | | package org.fanli.service.user.service.impl;
|
| | | package org.fanli.service.user.service.impl.account;
|
| | |
|
| | | import java.io.File;
|
| | | import java.io.FileWriter;
|
| | |
| | | import javax.servlet.http.HttpServletRequest;
|
| | | import javax.servlet.http.HttpSession;
|
| | |
|
| | | import org.fanli.facade.user.dto.HongBao;
|
| | | import org.fanli.facade.user.dto.account.LoginResult;
|
| | | import org.fanli.facade.user.dto.wx.WeiXinUser;
|
| | | import org.fanli.facade.user.entity.account.BindingAccount;
|
| | | import org.fanli.facade.user.entity.account.ForbiddenUserIdentifyCode;
|
| | | import org.fanli.facade.user.entity.account.ForbiddenUserIdentifyCode.ForbiddenUserIdentifyCodeTypeEnum;
|
| | | import org.fanli.facade.user.entity.account.UserConnectHistory;
|
| | | import org.fanli.facade.user.entity.account.msg.UserAccountMsgNotificationService;
|
| | | import org.fanli.facade.user.entity.invite.ThreeSale;
|
| | | import org.fanli.facade.user.exception.UserAccountException;
|
| | | import org.fanli.facade.user.service.account.ForbiddenUserIdentifyCodeService;
|
| | | import org.fanli.facade.user.service.account.UserAccountService;
|
| | | import org.fanli.facade.user.service.invite.SpreadUserImgService;
|
| | | import org.fanli.facade.user.service.taobao.UserExtraTaoBaoInfoService;
|
| | |
| | | import org.fanli.facade.user.util.wx.WXLoginUtil;
|
| | | import org.fanli.service.user.dao.account.UserInfoMapper;
|
| | | import org.fanli.service.user.dao.invite.ThreeSaleMapper;
|
| | | import org.fanli.service.user.dao.money.BindingAccountMapper;
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | | import org.yeshi.utils.FileUtil;
|
| | |
| | | import org.yeshi.utils.TimeUtil;
|
| | | import org.yeshi.utils.tencentcloud.COSManager;
|
| | |
|
| | | import com.alipay.api.domain.OrderItem;
|
| | | import com.google.gson.Gson;
|
| | | import com.qcloud.cos.model.COSObjectSummary;
|
| | | import com.qcloud.cos.model.ObjectListing;
|
| | |
| | |
|
| | | @Resource
|
| | | private AccountMessageMapper accountMessageMapper;
|
| | |
|
| | | @Resource
|
| | | private MoneyRecordMapper moneyRecordMapper;
|
| | |
|
| | |
| | |
|
| | | @Resource
|
| | | private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService;
|
| | | |
| | | @Resource
|
| | | private ForbiddenUserIdentifyCodeService forbiddenUserIdentifyCodeService;
|
| | |
|
| | | @Transactional
|
| | | @Override
|
| | |
| | | WeiXinUser weiXinUser = null;
|
| | | switch (loginType) {
|
| | | case 1:// 淘宝
|
| | | // 判断淘宝是否被封禁
|
| | | if (!StringUtil.isNullOrEmpty(tbUserInfo.getTaoBaoUid())) {
|
| | | ForbiddenUserIdentifyCode identifyCode = forbiddenUserIdentifyCodeService.listByTypeAndIdentifyCode(
|
| | | ForbiddenUserIdentifyCodeTypeEnum.taobaoUid, tbUserInfo.getTaoBaoUid());
|
| | | 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());
|
| | | // 判断用户是否被删除
|
| | | if (userInfo != null && userInfo.getState() != null
|
| | | && (userInfo.getState() == UserInfo.STATE_DELETE_OUT_OF_DATE
|
| | | || userInfo.getState() == UserInfo.STATE_DELETE))
|
| | | userInfo = null;
|
| | | if (userInfo == null) {// 原先的账号不存在
|
| | | userInfo = new UserInfo();
|
| | | userInfo.setAppId(appId);
|
| | |
| | | if (weiXinUser == null)
|
| | | throw new UserAccountException(1001, "无法获取到微信个人信息");
|
| | | LogHelper.test("微信授权用户信息:" + new Gson().toJson(weiXinUser));
|
| | | // 判断微信unionid是否被封禁
|
| | | ForbiddenUserIdentifyCode identifyCode = forbiddenUserIdentifyCodeService.listByTypeAndIdentifyCode(
|
| | | ForbiddenUserIdentifyCodeTypeEnum.wxUnionId, weiXinUser.getUnionid());
|
| | | 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());
|
| | | // 判断用户是否被删除
|
| | | if (userInfo != null && userInfo.getState() != null
|
| | | && (userInfo.getState() == UserInfo.STATE_DELETE_OUT_OF_DATE
|
| | | || userInfo.getState() == UserInfo.STATE_DELETE))
|
| | | userInfo = null;
|
| | | // 直接用的微信登录
|
| | | if (lastUser == null) {
|
| | | if (userInfo != null) {
|
| | |
| | | }
|
| | | }
|
| | | case 3:// 手机号码
|
| | | // 判断手机号码是否被封禁
|
| | | ForbiddenUserIdentifyCode identifyCode1 = forbiddenUserIdentifyCodeService
|
| | | .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);
|
| | | // 判断用户是否被删除
|
| | | if (userInfo != null && userInfo.getState() != null
|
| | | && (userInfo.getState() == UserInfo.STATE_DELETE_OUT_OF_DATE
|
| | | || userInfo.getState() == UserInfo.STATE_DELETE))
|
| | | userInfo = null;
|
| | |
|
| | | if (userInfo == null) {// 原先的账号不存在
|
| | | userInfo = new UserInfo();
|
| | | userInfo.setAppId(appId);
|
| | |
| | | if (StringUtil.isNullOrEmpty(unionId))
|
| | | throw new UserAccountException(2, "unionId为空");
|
| | |
|
| | | return userInfoMapper.getUserInfoByAppIdAndWXUnionId(appId, unionId);
|
| | | List<UserInfo> list = userInfoMapper.listByAppIdAndWXUnionId(appId, unionId);
|
| | | // 剔除被删除掉的用户
|
| | | for (int i = 0; i < list.size(); i++) {
|
| | | if (list.get(i).getState() == UserInfo.STATE_DELETE
|
| | | || list.get(i).getState() == UserInfo.STATE_DELETE_OUT_OF_DATE) {
|
| | | list.remove(i);
|
| | | i--;
|
| | | }
|
| | | }
|
| | | if (list.size() > 0)
|
| | | return list.get(list.size() - 1);
|
| | | else
|
| | | return null;
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | throw new UserAccountException(1, "appId为空");
|
| | | if (StringUtil.isNullOrEmpty(openId))
|
| | | throw new UserAccountException(2, "openId为空");
|
| | | return userInfoMapper.getUserInfoByAppIdAndTaoBaoOpenId(appId, openId);
|
| | | List<UserInfo> list = userInfoMapper.listByAppIdAndTaoBaoOpenId(appId, openId);
|
| | |
|
| | | // 剔除被删除掉的用户
|
| | | for (int i = 0; i < list.size(); i++) {
|
| | | if (list.get(i).getState() == UserInfo.STATE_DELETE
|
| | | || list.get(i).getState() == UserInfo.STATE_DELETE_OUT_OF_DATE) {
|
| | | list.remove(i);
|
| | | i--;
|
| | | }
|
| | | }
|
| | | if (list.size() > 0)
|
| | | return list.get(list.size() - 1);
|
| | | else
|
| | | return null;
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | throw new UserAccountException(1, "appId为空");
|
| | | if (StringUtil.isNullOrEmpty(phone))
|
| | | throw new UserAccountException(2, "phone为空");
|
| | | return userInfoMapper.getUserInfoByAppIdAndPhone(appId, phone);
|
| | | List<UserInfo> list = userInfoMapper.listByAppIdAndPhone(appId, phone);
|
| | |
|
| | | // 剔除被删除掉的用户
|
| | | for (int i = 0; i < list.size(); i++) {
|
| | | if (list.get(i).getState() == UserInfo.STATE_DELETE
|
| | | || list.get(i).getState() == UserInfo.STATE_DELETE_OUT_OF_DATE) {
|
| | | list.remove(i);
|
| | | i--;
|
| | | }
|
| | | }
|
| | | if (list.size() > 0)
|
| | | return list.get(list.size() - 1);
|
| | | else
|
| | | return null;
|
| | |
|
| | | }
|
| | |
|
| | | private void updateLatestLoginTime(Long uid) {
|