用户合并修改
This commit is contained in:
@@ -44,6 +44,12 @@ public class UserManageServiceImpl implements UserManageService {
|
||||
private TransactionDetailsDao detailsDao;
|
||||
@Autowired
|
||||
private JfTransactionDetailsDao jfDetailsDao;
|
||||
@Autowired
|
||||
private UserCourseStudyingDao userCourseStudyingDao;
|
||||
@Autowired
|
||||
private UserCourseVideoPositionDao userCourseVideoPositionDao;
|
||||
@Autowired
|
||||
private UserToCourseDao userToCourseDao;
|
||||
|
||||
@Override
|
||||
public R userMerge(Map<String, Object> params) {
|
||||
@@ -51,6 +57,41 @@ public class UserManageServiceImpl implements UserManageService {
|
||||
MyUserEntity secondUser = userDao.selectById(params.get("secondAccountId").toString());
|
||||
if (mainUser != null){
|
||||
if (secondUser!=null){
|
||||
//币、积分、权限
|
||||
updateCoinJf(mainUser,secondUser);
|
||||
//vip vip记录
|
||||
//考虑到一个账号可能是医学vip,另一个是国学vip,到期时间不同,手动修改
|
||||
//币、积分详情
|
||||
updateTransactionDetails(mainUser,secondUser);
|
||||
//电子书、打卡、收货地址
|
||||
updateOthers(mainUser,secondUser);
|
||||
//湖分、湖分剩余
|
||||
updateContribution(mainUser,secondUser);
|
||||
//课、播放记录、浏览记录、收藏(正在学习)
|
||||
updateCourse(mainUser,secondUser);
|
||||
//订单、支付宝订单、微信订单、paypaymentorder充值订单表
|
||||
updateOrder(mainUser,secondUser);
|
||||
//删除次用户
|
||||
userDao.deleteById(secondUser.getId());
|
||||
}else {
|
||||
return R.error("次账号未找到");
|
||||
}
|
||||
}else {
|
||||
return R.error("主账号未找到");
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@Override
|
||||
public R addUserCourseBuy(UserCourseBuyEntity userCourseBuyEntity) {
|
||||
if (courseBuyDao.insert(userCourseBuyEntity)>0){
|
||||
return R.ok();
|
||||
}else {
|
||||
return R.error("开课失败");
|
||||
}
|
||||
}
|
||||
|
||||
private void updateCoinJf(MyUserEntity mainUser,MyUserEntity secondUser){
|
||||
//币、积分、权限
|
||||
mainUser.setPeanutCoin(mainUser.getPeanutCoin().add(secondUser.getPeanutCoin()));
|
||||
mainUser.setJf(mainUser.getJf().add(secondUser.getJf()));
|
||||
@@ -70,40 +111,8 @@ public class UserManageServiceImpl implements UserManageService {
|
||||
mainUser.setPrescriptBPower(secondUser.getPrescriptBPower());
|
||||
}
|
||||
userDao.updateById(mainUser);
|
||||
//删除次用户
|
||||
userDao.deleteById(secondUser.getId());
|
||||
//vip
|
||||
//...
|
||||
//vip记录
|
||||
LambdaQueryWrapper<UserVip> userVipWrapper = new LambdaQueryWrapper<>();
|
||||
// userVipWrapper.eq(UserVip::getUserId,secondUser.getId());
|
||||
// List<UserVip> userVips = userVipDao.selectList(userVipWrapper);
|
||||
// if (userVips != null&&userVips.size()>0) {
|
||||
// for (UserVip userVip : userVips) {
|
||||
// userVip.setUserId(mainUser.getId());
|
||||
// userVipDao.updateById(userVip);
|
||||
// }
|
||||
// }
|
||||
//币详情
|
||||
LambdaQueryWrapper<TransactionDetailsEntity> detailsWrapper = new LambdaQueryWrapper<>();
|
||||
detailsWrapper.eq(TransactionDetailsEntity::getUserId,secondUser.getId());
|
||||
List<TransactionDetailsEntity> details = detailsDao.selectList(detailsWrapper);
|
||||
if (details != null&&details.size()>0) {
|
||||
for (TransactionDetailsEntity detail : details) {
|
||||
detail.setUserId(mainUser.getId());
|
||||
detailsDao.updateById(detail);
|
||||
}
|
||||
}
|
||||
//积分详情
|
||||
LambdaQueryWrapper<JfTransactionDetails> jfDetailsWrapper = new LambdaQueryWrapper<>();
|
||||
jfDetailsWrapper.eq(JfTransactionDetails::getUserId,secondUser.getId());
|
||||
List<JfTransactionDetails> jfdetails = jfDetailsDao.selectList(jfDetailsWrapper);
|
||||
if (jfdetails != null&&jfdetails.size()>0) {
|
||||
for (JfTransactionDetails jfdetail : jfdetails) {
|
||||
jfdetail.setUserId(mainUser.getId());
|
||||
jfDetailsDao.updateById(jfdetail);
|
||||
}
|
||||
}
|
||||
private void updateOthers(MyUserEntity mainUser,MyUserEntity secondUser){
|
||||
//电子书
|
||||
LambdaQueryWrapper<UserEbookBuyEntity> ebookWrapper = new LambdaQueryWrapper<>();
|
||||
ebookWrapper.eq(UserEbookBuyEntity :: getUserId,secondUser.getId());
|
||||
@@ -153,6 +162,30 @@ public class UserManageServiceImpl implements UserManageService {
|
||||
addressDao.updateById(addr);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void updateTransactionDetails(MyUserEntity mainUser,MyUserEntity secondUser){
|
||||
//币详情
|
||||
LambdaQueryWrapper<TransactionDetailsEntity> detailsWrapper = new LambdaQueryWrapper<>();
|
||||
detailsWrapper.eq(TransactionDetailsEntity::getUserId,secondUser.getId());
|
||||
List<TransactionDetailsEntity> details = detailsDao.selectList(detailsWrapper);
|
||||
if (details != null&&details.size()>0) {
|
||||
for (TransactionDetailsEntity detail : details) {
|
||||
detail.setUserId(mainUser.getId());
|
||||
detailsDao.updateById(detail);
|
||||
}
|
||||
}
|
||||
//积分详情
|
||||
LambdaQueryWrapper<JfTransactionDetails> jfDetailsWrapper = new LambdaQueryWrapper<>();
|
||||
jfDetailsWrapper.eq(JfTransactionDetails::getUserId,secondUser.getId());
|
||||
List<JfTransactionDetails> jfdetails = jfDetailsDao.selectList(jfDetailsWrapper);
|
||||
if (jfdetails != null&&jfdetails.size()>0) {
|
||||
for (JfTransactionDetails jfdetail : jfdetails) {
|
||||
jfdetail.setUserId(mainUser.getId());
|
||||
jfDetailsDao.updateById(jfdetail);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void updateContribution(MyUserEntity mainUser,MyUserEntity secondUser){
|
||||
//湖分
|
||||
LambdaQueryWrapper<UserContribution> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(UserContribution :: getUserId,secondUser.getId());
|
||||
@@ -179,6 +212,8 @@ public class UserManageServiceImpl implements UserManageService {
|
||||
exchangeDao.updateById(exchange);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void updateCourse(MyUserEntity mainUser,MyUserEntity secondUser){
|
||||
//课
|
||||
LambdaQueryWrapper<UserCourseBuyEntity> courseWrapper = new LambdaQueryWrapper<>();
|
||||
courseWrapper.eq(UserCourseBuyEntity :: getUserId,secondUser.getId());
|
||||
@@ -189,6 +224,38 @@ public class UserManageServiceImpl implements UserManageService {
|
||||
courseBuyDao.updateById(c);
|
||||
}
|
||||
}
|
||||
//播放记录
|
||||
LambdaQueryWrapper<UserCourseVideoPositionEntity> videoPositionWrapper = new LambdaQueryWrapper<>();
|
||||
videoPositionWrapper.eq(UserCourseVideoPositionEntity::getUserId,secondUser.getId());
|
||||
List<UserCourseVideoPositionEntity> videoPositionList = userCourseVideoPositionDao.selectList(videoPositionWrapper);
|
||||
if (videoPositionList != null&&videoPositionList.size()>0) {
|
||||
for (UserCourseVideoPositionEntity videoPosition : videoPositionList) {
|
||||
videoPosition.setUserId(mainUser.getId());
|
||||
userCourseVideoPositionDao.updateById(videoPosition);
|
||||
}
|
||||
}
|
||||
//浏览记录
|
||||
LambdaQueryWrapper<UserToCourseEntity> userToCourseWrapper = new LambdaQueryWrapper<>();
|
||||
userToCourseWrapper.eq(UserToCourseEntity::getUserId,secondUser.getId());
|
||||
List<UserToCourseEntity> userToCourseList = userToCourseDao.selectList(userToCourseWrapper);
|
||||
if (userToCourseList != null&&userToCourseList.size()>0) {
|
||||
for (UserToCourseEntity userToCourse : userToCourseList) {
|
||||
userToCourse.setUserId(mainUser.getId());
|
||||
userToCourseDao.updateById(userToCourse);
|
||||
}
|
||||
}
|
||||
//收藏(正在学习)
|
||||
LambdaQueryWrapper<UserCourseStudying> studyingWrapper = new LambdaQueryWrapper<>();
|
||||
studyingWrapper.eq(UserCourseStudying::getUserId,secondUser.getId());
|
||||
List<UserCourseStudying> sList = userCourseStudyingDao.selectList(studyingWrapper);
|
||||
if (sList != null&&sList.size()>0) {
|
||||
for (UserCourseStudying s : sList) {
|
||||
s.setUserId(mainUser.getId());
|
||||
userCourseStudyingDao.updateById(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void updateOrder(MyUserEntity mainUser,MyUserEntity secondUser){
|
||||
//订单
|
||||
LambdaQueryWrapper<BuyOrder> orderWrapper = new LambdaQueryWrapper<>();
|
||||
orderWrapper.eq(BuyOrder::getUserId,secondUser.getId());
|
||||
@@ -196,6 +263,7 @@ public class UserManageServiceImpl implements UserManageService {
|
||||
if (orders != null&&orders.size()>0) {
|
||||
for (BuyOrder order : orders) {
|
||||
order.setUserId(mainUser.getId());
|
||||
order.setUserPhone(mainUser.getTel());
|
||||
orderDao.updateById(order);
|
||||
}
|
||||
}
|
||||
@@ -229,22 +297,8 @@ public class UserManageServiceImpl implements UserManageService {
|
||||
paymentOrderDao.updateById(paymentOrder);
|
||||
}
|
||||
}
|
||||
}else {
|
||||
return R.error("次账号未找到");
|
||||
}
|
||||
}else {
|
||||
return R.error("主账号未找到");
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@Override
|
||||
public R addUserCourseBuy(UserCourseBuyEntity userCourseBuyEntity) {
|
||||
if (courseBuyDao.insert(userCourseBuyEntity)>0){
|
||||
return R.ok();
|
||||
}else {
|
||||
return R.error("开课失败");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user