|
|
@ -26,7 +26,6 @@ import com.ccsens.util.wx.WxGzhUtil; |
|
|
|
import com.ccsens.util.wx.WxXcxUtil; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.lang3.RandomStringUtils; |
|
|
|
import org.springframework.cache.annotation.Cacheable; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Propagation; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
@ -49,41 +48,25 @@ public class UserService implements IUserService { |
|
|
|
private SysUserDao userDao; |
|
|
|
@Resource |
|
|
|
private SysAuthDao authDao; |
|
|
|
// @Resource
|
|
|
|
// private ProMemberDao memberDao;
|
|
|
|
// @Resource
|
|
|
|
// private ProRoleDao proRoleDao;
|
|
|
|
// @Resource
|
|
|
|
// private ProMemberRoleDao memberRoleDao;
|
|
|
|
// @Resource
|
|
|
|
// private SysBalanceLogDao sysBalanceLogDao;
|
|
|
|
@Resource |
|
|
|
private Snowflake snowflake; |
|
|
|
@Resource |
|
|
|
private RedisUtil redisUtil; |
|
|
|
// @Resource
|
|
|
|
// private SysProjectDao sysProjectDao;
|
|
|
|
// @Resource
|
|
|
|
// private UserAttentionDao userAttentionDao;
|
|
|
|
@Resource |
|
|
|
private HealthFeignClient healthFeignClient; |
|
|
|
@Resource |
|
|
|
private IRelevanceUserService relevanceUserService; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 登录 |
|
|
|
*/ |
|
|
|
// @Cacheable(cacheNames = "signin", key = "#clientType+'-'+#identifyType+'-'+#identifier+'-'+#credential")
|
|
|
|
// @Cacheable(cacheNames = "signin", key = "login")
|
|
|
|
@Override |
|
|
|
public UserVo.UserSign signin(WebConstant.CLIENT_TYPE clientType, WebConstant.IDENTIFY_TYPE identifyType, |
|
|
|
String identifier, String credential, String clientIp, String redirect) throws Exception { |
|
|
|
UserVo.UserSign userSignVo; |
|
|
|
//1.登陆
|
|
|
|
userSignVo = __signin(identifyType, identifier, credential, redirect); |
|
|
|
// if (ObjectUtil.isNotNull(userSignVo) && ObjectUtil.isNotNull(userSignVo.getAuthId())) {
|
|
|
|
// //2.添加登陆记录
|
|
|
|
// __addSigninRecord(clientType, clientIp, userSignVo.getAuthId());
|
|
|
|
// }
|
|
|
|
return userSignVo; |
|
|
|
} |
|
|
|
|
|
|
@ -100,12 +83,10 @@ public class UserService implements IUserService { |
|
|
|
case Wx_H5: |
|
|
|
return wxH5Login(identifyType, identifier); |
|
|
|
case OAUTH2_WeiBo: |
|
|
|
//Fix Me.
|
|
|
|
break; |
|
|
|
case Phone: |
|
|
|
return phoneLogin(identifier, credential); |
|
|
|
case Email: |
|
|
|
// return emailLogin(identifier, credential);
|
|
|
|
case Account: |
|
|
|
return accountLogin(identifier, credential); |
|
|
|
default: |
|
|
@ -143,30 +124,10 @@ public class UserService implements IUserService { |
|
|
|
private UserVo.UserSign wxH5Login(WebConstant.IDENTIFY_TYPE identifyType, String code) { |
|
|
|
UserVo.UserSign userSignVo; |
|
|
|
//获取微信信息
|
|
|
|
|
|
|
|
// WxGzhUtil wxGzhUtil = new WxGzhUtil();
|
|
|
|
// WxOauth2UserInfo wxOauth2UserInfo = wxGzhUtil.getOauth2UserInfo(identifyType, code);
|
|
|
|
WxOauth2UserInfo wxOauth2UserInfo = WxGzhUtil.getOauth2UserInfo(identifyType, code); |
|
|
|
|
|
|
|
SysAuth theAuth; |
|
|
|
if (ObjectUtil.isNotNull(wxOauth2UserInfo)) { |
|
|
|
// //查找有无保存的信息
|
|
|
|
// SysWxExample sysWxExample = new SysWxExample();
|
|
|
|
// sysWxExample.createCriteria().andUnionIdEqualTo(wxOauth2UserInfo.getUnionId());
|
|
|
|
// List<SysWx> sysWxList = sysWxDao.selectByExample(sysWxExample);
|
|
|
|
// SysWx sysWx = null;
|
|
|
|
// if (CollUtil.isNotEmpty(sysWxList)) {
|
|
|
|
// //如果有信息,则更新
|
|
|
|
// sysWx = sysWxList.get(0);
|
|
|
|
// BeanUtil.copyProperties(wxOauth2UserInfo, sysWx);
|
|
|
|
// sysWxDao.updateByPrimaryKeySelective(sysWx);
|
|
|
|
// } else {
|
|
|
|
// //没有则保存微信信息
|
|
|
|
// sysWx = new SysWx();
|
|
|
|
// BeanUtil.copyProperties(wxOauth2UserInfo, sysWx);
|
|
|
|
// sysWx.setId(snowflake.nextId());
|
|
|
|
// sysWxDao.insertSelective(sysWx);
|
|
|
|
// }
|
|
|
|
//查找认证信息
|
|
|
|
SysAuthExample authExample = new SysAuthExample(); |
|
|
|
authExample.createCriteria().andIdentifyTypeEqualTo((byte) WebConstant.IDENTIFY_TYPE.Wx_H5.value) |
|
|
@ -339,8 +300,8 @@ public class UserService implements IUserService { |
|
|
|
userSignVo.setUserId(theAuth.getUserId()); |
|
|
|
userSignVo.setAuthId(theAuth.getId()); |
|
|
|
|
|
|
|
// //给所有手机号一样的角色添加userId
|
|
|
|
// memberHandler(theAuth.getUserId(), phone);
|
|
|
|
//给所有手机号一样的角色添加userId
|
|
|
|
relevanceUserService.relevancePhone(phone, theAuth.getUserId()); |
|
|
|
} else { |
|
|
|
throw new BaseException(CodeEnum.SMS_CODE_CORRECT); |
|
|
|
} |
|
|
@ -606,13 +567,6 @@ public class UserService implements IUserService { |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public UserVo.SmsCode getSignInSmsCode(String phone,String verificationCodeId, String verificationCodeValue) { |
|
|
|
//获取登陆客户端类型
|
|
|
|
// WebConstant.CLIENT_TYPE client_type = null;
|
|
|
|
// if (ObjectUtil.isNotNull(client)) {
|
|
|
|
// client_type = WebConstant.CLIENT_TYPE.valueOf(client);
|
|
|
|
// } else {
|
|
|
|
// client_type = WebConstant.CLIENT_TYPE.valueOf(1);
|
|
|
|
// }
|
|
|
|
//检查图形验证码是否正确
|
|
|
|
String codeKey = WebConstant.IMAGE_CODE + verificationCodeId; |
|
|
|
if (!redisUtil.hasKey(codeKey)) { |
|
|
@ -738,35 +692,11 @@ public class UserService implements IUserService { |
|
|
|
userSignVo.setUserId(user.getId()); |
|
|
|
userSignVo.setAuthId(phoneAuth.getId()); |
|
|
|
|
|
|
|
// //给所有手机号一样的角色添加userId
|
|
|
|
// memberHandler(user.getId(), userSignup.getPhone());
|
|
|
|
//给所有手机号一样的角色添加userId
|
|
|
|
relevanceUserService.relevancePhone(userSignup.getPhone(), user.getId()); |
|
|
|
return userSignVo; |
|
|
|
} |
|
|
|
|
|
|
|
// /**
|
|
|
|
// * 给所有手机号相同的角色添加userId
|
|
|
|
// */
|
|
|
|
// private void memberHandler(Long userId, String phone) {
|
|
|
|
// ProMemberExample memberExample = new ProMemberExample();
|
|
|
|
// memberExample.createCriteria().andPhoneEqualTo(phone);
|
|
|
|
// List<ProMember> proMemberList = memberDao.selectByExample(memberExample);
|
|
|
|
// if (CollectionUtil.isNotEmpty(proMemberList)) {
|
|
|
|
// SysUser user = userDao.selectByPrimaryKey(userId);
|
|
|
|
// if (ObjectUtil.isNotNull(user)) {
|
|
|
|
// for (ProMember member : proMemberList) {
|
|
|
|
// if (ObjectUtil.isNull(member.getUserId()) || member.getUserId() == 0) {
|
|
|
|
// member.setUserId(userId);
|
|
|
|
// //将用户的昵称和头像复制到成员信息内
|
|
|
|
// member.setAvatarUrl(user.getAvatarUrl());
|
|
|
|
// member.setNickname(user.getNickname());
|
|
|
|
//
|
|
|
|
// memberDao.updateByPrimaryKeySelective(member);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
/** |
|
|
|
* 查找账号 |
|
|
|
*/ |
|
|
@ -862,8 +792,8 @@ public class UserService implements IUserService { |
|
|
|
auth.setIdentifier(wxPhone.getPhone()); |
|
|
|
authDao.insertSelective(auth); |
|
|
|
|
|
|
|
// //给手机号一样的所有项目内的成员添加userId
|
|
|
|
// memberHandler(currentUserId, wxPhone.getPhone());
|
|
|
|
//给所有手机号一样的角色添加userId
|
|
|
|
relevanceUserService.relevancePhone(wxPhone.getPhone(), currentUserId); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
@ -1056,82 +986,6 @@ public class UserService implements IUserService { |
|
|
|
return account; |
|
|
|
} |
|
|
|
|
|
|
|
// /**
|
|
|
|
// * 查找角色下的所有人的userId
|
|
|
|
// */
|
|
|
|
// @Override
|
|
|
|
// public List<Long> selectUserIdByRoleId(Long roleId) {
|
|
|
|
// ProRole role = proRoleDao.selectByPrimaryKey(roleId);
|
|
|
|
// if(ObjectUtil.isNull(role)){
|
|
|
|
// return null;
|
|
|
|
// }
|
|
|
|
// List<Long> userIdList;
|
|
|
|
// if(role.getName().equalsIgnoreCase(WebConstant.ROLE_NAME.AllMember.phase)){
|
|
|
|
// userIdList = memberRoleDao.selectUserIdByProjectId(role.getProjectId());
|
|
|
|
// }else {
|
|
|
|
// userIdList = memberRoleDao.selectUserIdByRoleId(roleId);
|
|
|
|
// }
|
|
|
|
// return userIdList;
|
|
|
|
// }
|
|
|
|
|
|
|
|
// /**
|
|
|
|
// * 查询用户是否关注此项目
|
|
|
|
// *
|
|
|
|
// * @param currentUserId userId
|
|
|
|
// * @param projectId 项目id
|
|
|
|
// * @return 是否关注此项目
|
|
|
|
// */
|
|
|
|
// @Override
|
|
|
|
// public Boolean getIsAttention(Long currentUserId, Long projectId) {
|
|
|
|
// boolean isAttention = false;
|
|
|
|
// if (ObjectUtil.isNotNull(sysProjectDao.selectByPrimaryKey(projectId))) {
|
|
|
|
// UserAttentionExample attentionExample = new UserAttentionExample();
|
|
|
|
// attentionExample.createCriteria().andProjectIdEqualTo(projectId).andUserIdEqualTo(currentUserId);
|
|
|
|
// List<UserAttention> attentionList = userAttentionDao.selectByExample(attentionExample);
|
|
|
|
// if (CollectionUtil.isNotEmpty(attentionList)) {
|
|
|
|
// isAttention = true;
|
|
|
|
// }
|
|
|
|
// } else {
|
|
|
|
// throw new BaseException(CodeEnum.NOT_PROJECT);
|
|
|
|
// }
|
|
|
|
// return isAttention;
|
|
|
|
// }
|
|
|
|
|
|
|
|
// /**
|
|
|
|
// * 用户关注某个项目
|
|
|
|
// *
|
|
|
|
// * @param currentUserId userId
|
|
|
|
// * @param projectIdDto 项目id
|
|
|
|
// */
|
|
|
|
// @Override
|
|
|
|
// public void userAttentionProject(Long currentUserId, ProjectDto.ProjectIdDto projectIdDto) {
|
|
|
|
// //查找项目
|
|
|
|
// SysProject project = sysProjectDao.selectByPrimaryKey(projectIdDto.getProjectId());
|
|
|
|
// if (ObjectUtil.isNotNull(project)) {
|
|
|
|
// UserAttentionExample attentionExample = new UserAttentionExample();
|
|
|
|
// attentionExample.createCriteria().andProjectIdEqualTo(projectIdDto.getProjectId()).andUserIdEqualTo(currentUserId);
|
|
|
|
// List<UserAttention> attentionList = userAttentionDao.selectByExample(attentionExample);
|
|
|
|
// if (CollectionUtil.isNotEmpty(attentionList)) {
|
|
|
|
// throw new BaseException(CodeEnum.ALREADY_ATTENTION);
|
|
|
|
// }
|
|
|
|
// UserAttention attention = new UserAttention();
|
|
|
|
// attention.setId(snowflake.nextId());
|
|
|
|
// attention.setUserId(currentUserId);
|
|
|
|
// attention.setProjectId(projectIdDto.getProjectId());
|
|
|
|
// userAttentionDao.insertSelective(attention);
|
|
|
|
// } else {
|
|
|
|
// throw new BaseException(CodeEnum.NOT_PROJECT);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
// @Override
|
|
|
|
// public UserVo.TokenBean userManageSignin(UserDto.UserSginin dto){
|
|
|
|
// UserVo.TokenBean tokenBean = null;
|
|
|
|
// JsonResponse<UserVo.TokenBean> tokenBeanJsonResponse = userManageFeign.userSignin(dto);
|
|
|
|
// tokenBean = tokenBeanJsonResponse.getData();
|
|
|
|
// return tokenBean;
|
|
|
|
// }
|
|
|
|
|
|
|
|
@Override |
|
|
|
public long defaultRegisterUser(com.ccsens.cloudutil.bean.tall.dto.UserDto.DefaultUserSingup signup) { |
|
|
|
log.info("默认注册信息:{}", signup); |
|
|
@ -1173,55 +1027,21 @@ public class UserService implements IUserService { |
|
|
|
return tokenBean; |
|
|
|
} |
|
|
|
|
|
|
|
// /**
|
|
|
|
// * 通过userId查找账号
|
|
|
|
// * @param userId userId
|
|
|
|
// * @return 账号
|
|
|
|
// */
|
|
|
|
// private String selectAccountByUserId(Long userId) {
|
|
|
|
// String account = null;
|
|
|
|
// SysAuthExample sysAuthExample = new SysAuthExample();
|
|
|
|
// sysAuthExample.createCriteria().andUserIdEqualTo(userId).andIdentifyTypeEqualTo((byte) WebConstant.IDENTIFY_TYPE.Account.value);
|
|
|
|
// List<SysAuth> authList = authDao.selectByExample(sysAuthExample);
|
|
|
|
// if(CollectionUtil.isNotEmpty(authList)){
|
|
|
|
// account = authList.get(0).getIdentifier();
|
|
|
|
// }
|
|
|
|
// return account;
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// private String getPhoneByRegisterType(Long userId, WebConstant.IDENTIFY_TYPE identifyType) {
|
|
|
|
// SysAuthExample authExample = new SysAuthExample();
|
|
|
|
// authExample.createCriteria().andUserIdEqualTo(userId).andIdentifyTypeEqualTo((byte) WebConstant.IDENTIFY_TYPE.Phone.value);
|
|
|
|
// List<SysAuth> sysAuthList = authDao.selectByExample(authExample);
|
|
|
|
// if (CollectionUtil.isNotEmpty(sysAuthList)) {
|
|
|
|
// return sysAuthList.get(0).getIdentifier();
|
|
|
|
// } else {
|
|
|
|
// SysAuthExample authExampleType = new SysAuthExample();
|
|
|
|
// authExampleType.createCriteria().andUserIdEqualTo(userId).andIdentifyTypeEqualTo((byte) identifyType.value);
|
|
|
|
// List<SysAuth> sysAuthList1 = authDao.selectByExample(authExampleType);
|
|
|
|
// if (CollectionUtil.isNotEmpty(sysAuthList1)){
|
|
|
|
// if(sysAuthList1.get(0).getRegisterType() == 1){
|
|
|
|
// return "1";
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// return null;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
/** |
|
|
|
* 合并账号 |
|
|
|
* @param currentUserId userId |
|
|
|
* @param wxPhone 手机号和合并方式 |
|
|
|
* @param mergePhone 手机号和合并方式 |
|
|
|
* @return 用户id |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public UserVo.UserSign mergeByPhone(Long currentUserId, UserDto.WxMergePhone wxPhone) { |
|
|
|
if (wxPhone.getIsMerge() == 0) { |
|
|
|
public UserVo.UserSign mergeByPhone(Long currentUserId, UserDto.MergePhone mergePhone) { |
|
|
|
if (mergePhone.getIsMerge() == 0) { |
|
|
|
//直接合并
|
|
|
|
//1.查找手机号原来的userId
|
|
|
|
Long userId = selectUserIdByPhone(wxPhone.getPhone()); |
|
|
|
Long userId = selectUserIdByPhone(mergePhone.getPhone()); |
|
|
|
if (ObjectUtil.isNotNull(userId)) { |
|
|
|
//处理账号认证信息,保留手机号的账号,删除现在的账号
|
|
|
|
//处理账号认证信息,保留手机号的账号,删除现在的账号登录方式
|
|
|
|
SysAuthExample authExample = new SysAuthExample(); |
|
|
|
authExample.createCriteria().andIdentifyTypeEqualTo((byte) WebConstant.IDENTIFY_TYPE.Account.value) |
|
|
|
.andUserIdEqualTo(currentUserId); |
|
|
@ -1232,27 +1052,16 @@ public class UserService implements IUserService { |
|
|
|
authDao.updateByPrimaryKeySelective(auth); |
|
|
|
} |
|
|
|
} |
|
|
|
userDao.replaceAuth(userId, currentUserId); |
|
|
|
//查询所有关联userId的数据库表 auth表 attention表 balance表 project表 member表 DeliverPostLog表 proLog表
|
|
|
|
//依次将查出的数据的旧userId 替换成新的userId
|
|
|
|
userDao.replaceProject(userId, currentUserId); |
|
|
|
userDao.replaceAttention(userId, currentUserId); |
|
|
|
userDao.replaceBalance(userId, currentUserId); |
|
|
|
userDao.replaceMember(userId, currentUserId); |
|
|
|
userDao.replaceDeliverPostLog(userId, currentUserId); |
|
|
|
userDao.replaceProLog(userId, currentUserId); |
|
|
|
userDao.replaceComment(userId, currentUserId); |
|
|
|
//将以前的余额添加至此账号
|
|
|
|
SysUser newUser = userDao.selectByPrimaryKey(currentUserId); |
|
|
|
SysUser oldUser = userDao.selectByPrimaryKey(userId); |
|
|
|
// if(ObjectUtil.isNotNull(oldUser) && ObjectUtil.isNotNull(newUser)) {
|
|
|
|
// updateBalance(oldUser, newUser);
|
|
|
|
// }
|
|
|
|
//将以前的user删除
|
|
|
|
oldUser.setRecStatus((byte) 2); |
|
|
|
userDao.updateByPrimaryKeySelective(oldUser); |
|
|
|
|
|
|
|
|
|
|
|
//将其他登录方式的userId替换为新userId
|
|
|
|
userDao.replaceAuth(userId,currentUserId); |
|
|
|
//将用户项目关联表里的userId替换为新的
|
|
|
|
userDao.replaceUserProject(userId,currentUserId); |
|
|
|
//TODO 调用业务系统替换所有的userId
|
|
|
|
relevanceUserService.mergeUserByPhone(userId,currentUserId); |
|
|
|
//原user改为已禁用
|
|
|
|
SysUser sysUser = userDao.selectByPrimaryKey(currentUserId); |
|
|
|
sysUser.setRecStatus((byte) 1); |
|
|
|
userDao.updateByPrimaryKeySelective(sysUser); |
|
|
|
} else { |
|
|
|
throw new BaseException(CodeEnum.PARAM_ERROR); |
|
|
|
} |
|
|
@ -1260,15 +1069,17 @@ public class UserService implements IUserService { |
|
|
|
//不要以前的信息
|
|
|
|
SysAuthExample authExample = new SysAuthExample(); |
|
|
|
authExample.createCriteria().andIdentifyTypeEqualTo((byte) WebConstant.IDENTIFY_TYPE.Phone.value) |
|
|
|
.andIdentifierEqualTo(wxPhone.getPhone()); |
|
|
|
.andIdentifierEqualTo(mergePhone.getPhone()); |
|
|
|
List<SysAuth> authList = authDao.selectByExample(authExample); |
|
|
|
if (CollectionUtil.isNotEmpty(authList)) { |
|
|
|
SysAuth auth = authList.get(0); |
|
|
|
//查找这个手机号以前的用户,并删除
|
|
|
|
SysUser user = userDao.selectByPrimaryKey(auth.getUserId()); |
|
|
|
user.setRecStatus((byte) 2); |
|
|
|
userDao.updateByPrimaryKeySelective(user); |
|
|
|
//删除这个手机号的认证方式
|
|
|
|
if(ObjectUtil.isNotNull(user)){ |
|
|
|
user.setRecStatus((byte) 2); |
|
|
|
userDao.updateByPrimaryKeySelective(user); |
|
|
|
} |
|
|
|
//删除原来认证方式
|
|
|
|
auth.setRecStatus((byte) 2); |
|
|
|
authDao.updateByPrimaryKeySelective(auth); |
|
|
|
//将当前的用户手机号改为新的手机号
|
|
|
@ -1278,18 +1089,16 @@ public class UserService implements IUserService { |
|
|
|
List<SysAuth> sysAuthList = authDao.selectByExample(authExample); |
|
|
|
if (CollectionUtil.isNotEmpty(sysAuthList)) { |
|
|
|
SysAuth sysAuth = sysAuthList.get(0); |
|
|
|
sysAuth.setIdentifier(wxPhone.getPhone()); |
|
|
|
sysAuth.setIdentifier(mergePhone.getPhone()); |
|
|
|
authDao.updateByPrimaryKeySelective(sysAuth); |
|
|
|
} |
|
|
|
// auth.setUserId(currentUserId);
|
|
|
|
// authDao.updateByPrimaryKeySelective(auth);
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
UserVo.UserSign userSignVo = null; |
|
|
|
SysAuthExample authExample = new SysAuthExample(); |
|
|
|
authExample.createCriteria().andIdentifyTypeEqualTo((byte) WebConstant.IDENTIFY_TYPE.Phone.value) |
|
|
|
.andIdentifierEqualTo(wxPhone.getPhone()); |
|
|
|
.andIdentifierEqualTo(mergePhone.getPhone()); |
|
|
|
List<SysAuth> authList = authDao.selectByExample(authExample); |
|
|
|
if (CollectionUtil.isNotEmpty(authList)) { |
|
|
|
userSignVo = new UserVo.UserSign(); |
|
|
@ -1300,47 +1109,35 @@ public class UserService implements IUserService { |
|
|
|
return userSignVo; |
|
|
|
} |
|
|
|
|
|
|
|
// private void updateBalance(SysUser oldUser, SysUser newUser) {
|
|
|
|
// newUser.setBalance(newUser.getBalance() + oldUser.getBalance());
|
|
|
|
// userDao.updateByPrimaryKeySelective(newUser);
|
|
|
|
// //添加一条余额变更记录
|
|
|
|
// SysBalanceLog balanceLog = new SysBalanceLog();
|
|
|
|
// balanceLog.setId(snowflake.nextId());
|
|
|
|
// balanceLog.setUserId(newUser.getId());
|
|
|
|
// balanceLog.setBalance(newUser.getBalance());
|
|
|
|
// balanceLog.setOffset(oldUser.getBalance());
|
|
|
|
// balanceLog.setDescription("合并账号");
|
|
|
|
// sysBalanceLogDao.insertSelective(balanceLog);
|
|
|
|
// }
|
|
|
|
|
|
|
|
/** |
|
|
|
* 输入两个userid合并账号 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public void mergeUserId(Long userId, Long uselessId) { |
|
|
|
SysUser user = userDao.selectByPrimaryKey(userId); |
|
|
|
SysUser uselessUser = userDao.selectByPrimaryKey(userId); |
|
|
|
if(ObjectUtil.isNull(user) || ObjectUtil.isNull(uselessUser)){ |
|
|
|
throw new BaseException(CodeEnum.NOT_MEMBER); |
|
|
|
} |
|
|
|
userDao.replaceAuth(uselessId,userId); |
|
|
|
//查询所有关联userId的数据库表 auth表 attention表 balance表 project表 member表 DeliverPostLog表 proLog表
|
|
|
|
//依次将查出的数据的旧userId 替换成新的userId
|
|
|
|
userDao.replaceAttention(uselessId,userId); |
|
|
|
userDao.replaceBalance(uselessId,userId); |
|
|
|
userDao.replaceProject(uselessId,userId); |
|
|
|
userDao.replaceMember(uselessId,userId); |
|
|
|
userDao.replaceDeliverPostLog(uselessId,userId); |
|
|
|
userDao.replaceProLog(uselessId,userId); |
|
|
|
//将以前的余额添加至此账号
|
|
|
|
SysUser oldUser = userDao.selectByPrimaryKey(uselessId); |
|
|
|
SysUser newUser = userDao.selectByPrimaryKey(userId); |
|
|
|
// if(ObjectUtil.isNotNull(oldUser) && ObjectUtil.isNotNull(newUser)) {
|
|
|
|
// updateBalance(oldUser, newUser);
|
|
|
|
// SysUser user = userDao.selectByPrimaryKey(userId);
|
|
|
|
// SysUser uselessUser = userDao.selectByPrimaryKey(userId);
|
|
|
|
// if(ObjectUtil.isNull(user) || ObjectUtil.isNull(uselessUser)){
|
|
|
|
// throw new BaseException(CodeEnum.NOT_MEMBER);
|
|
|
|
// }
|
|
|
|
//将以前的user删除
|
|
|
|
oldUser.setRecStatus((byte) 2); |
|
|
|
userDao.updateByPrimaryKeySelective(oldUser); |
|
|
|
// userDao.replaceAuth(uselessId,userId);
|
|
|
|
// //查询所有关联userId的数据库表 auth表 attention表 balance表 project表 member表 DeliverPostLog表 proLog表
|
|
|
|
// //依次将查出的数据的旧userId 替换成新的userId
|
|
|
|
// userDao.replaceAttention(uselessId,userId);
|
|
|
|
// userDao.replaceBalance(uselessId,userId);
|
|
|
|
// userDao.replaceProject(uselessId,userId);
|
|
|
|
// userDao.replaceMember(uselessId,userId);
|
|
|
|
// userDao.replaceDeliverPostLog(uselessId,userId);
|
|
|
|
// userDao.replaceProLog(uselessId,userId);
|
|
|
|
// //将以前的余额添加至此账号
|
|
|
|
// SysUser oldUser = userDao.selectByPrimaryKey(uselessId);
|
|
|
|
// SysUser newUser = userDao.selectByPrimaryKey(userId);
|
|
|
|
//// if(ObjectUtil.isNotNull(oldUser) && ObjectUtil.isNotNull(newUser)) {
|
|
|
|
//// updateBalance(oldUser, newUser);
|
|
|
|
//// }
|
|
|
|
// //将以前的user删除
|
|
|
|
// oldUser.setRecStatus((byte) 2);
|
|
|
|
// userDao.updateByPrimaryKeySelective(oldUser);
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|