加入会员合并同账号数据
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
package com.czg.service.account.service.impl;
|
package com.czg.service.account.service.impl;
|
||||||
|
|
||||||
|
import cn.dev33.satoken.stp.StpUtil;
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.util.RandomUtil;
|
import cn.hutool.core.util.RandomUtil;
|
||||||
@@ -9,6 +10,10 @@ import com.czg.account.entity.*;
|
|||||||
import com.czg.account.service.*;
|
import com.czg.account.service.*;
|
||||||
import com.czg.config.RedisCst;
|
import com.czg.config.RedisCst;
|
||||||
import com.czg.exception.ApiNotPrintException;
|
import com.czg.exception.ApiNotPrintException;
|
||||||
|
import com.czg.order.entity.OrderDetail;
|
||||||
|
import com.czg.order.entity.OrderInfo;
|
||||||
|
import com.czg.order.service.OrderDetailService;
|
||||||
|
import com.czg.order.service.OrderInfoService;
|
||||||
import com.czg.resp.CzgResult;
|
import com.czg.resp.CzgResult;
|
||||||
import com.czg.sa.StpKit;
|
import com.czg.sa.StpKit;
|
||||||
import com.czg.service.RedisService;
|
import com.czg.service.RedisService;
|
||||||
@@ -42,6 +47,10 @@ import java.util.List;
|
|||||||
public class ShopUserServiceImpl extends ServiceImpl<ShopUserMapper, ShopUser> implements ShopUserService {
|
public class ShopUserServiceImpl extends ServiceImpl<ShopUserMapper, ShopUser> implements ShopUserService {
|
||||||
@DubboReference
|
@DubboReference
|
||||||
private SysParamsService sysParamsService;
|
private SysParamsService sysParamsService;
|
||||||
|
@DubboReference
|
||||||
|
private OrderInfoService orderInfoService;
|
||||||
|
@DubboReference
|
||||||
|
private OrderDetailService orderDetailService;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ShopUserFlowService shopUserFlowService;
|
private ShopUserFlowService shopUserFlowService;
|
||||||
@@ -247,10 +256,33 @@ public class ShopUserServiceImpl extends ServiceImpl<ShopUserMapper, ShopUser> i
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public boolean join(Long shopId, Long userId, ShopUserAddDTO shopUserAddDTO) {
|
public boolean join(Long shopId, Long userId, ShopUserAddDTO shopUserAddDTO) {
|
||||||
|
// 当前用户信息
|
||||||
UserInfo userInfo = userInfoService.getById(userId);
|
UserInfo userInfo = userInfoService.getById(userId);
|
||||||
userInfo.setPhone(shopUserAddDTO.getPhone());
|
|
||||||
|
// 查询系统添加的会员
|
||||||
|
UserInfo oriInfo = userInfoService.getOne(new QueryWrapper().eq(UserInfo::getPhone, shopUserAddDTO.getPhone()));
|
||||||
|
if (oriInfo != null) {
|
||||||
|
BeanUtil.copyProperties(shopUserAddDTO, oriInfo);
|
||||||
|
if (StrUtil.isNotBlank(userInfo.getAlipayOpenId())) {
|
||||||
|
oriInfo.setAlipayOpenId(userInfo.getAlipayOpenId());
|
||||||
|
}
|
||||||
|
if (StrUtil.isNotBlank(userInfo.getWechatOpenId())) {
|
||||||
|
oriInfo.setAlipayOpenId(userInfo.getWechatOpenId());
|
||||||
|
}
|
||||||
|
// 迁移订单
|
||||||
|
orderInfoService.updateChain().eq(OrderInfo::getUserId, userInfo.getId())
|
||||||
|
.set(OrderInfo::getUserId, oriInfo.getId()).update();
|
||||||
|
|
||||||
|
// 删除多余用户信息
|
||||||
|
userInfoService.removeById(userId);
|
||||||
|
userInfo = oriInfo;
|
||||||
|
}else {
|
||||||
|
BeanUtil.copyProperties(shopUserAddDTO, userInfo);
|
||||||
|
}
|
||||||
userInfoService.updateById(userInfo);
|
userInfoService.updateById(userInfo);
|
||||||
|
|
||||||
ShopUser shopUser = getOne(new QueryWrapper().eq(ShopUser::getShopId, shopId).eq(ShopUser::getUserId, userId));
|
ShopUser shopUser = getOne(new QueryWrapper().eq(ShopUser::getShopId, shopId).eq(ShopUser::getUserId, userId));
|
||||||
@@ -268,8 +300,9 @@ public class ShopUserServiceImpl extends ServiceImpl<ShopUserMapper, ShopUser> i
|
|||||||
shopUser.setJoinTime(DateUtil.date().toLocalDateTime());
|
shopUser.setJoinTime(DateUtil.date().toLocalDateTime());
|
||||||
shopUser.setUserId(null);
|
shopUser.setUserId(null);
|
||||||
shopUser.setShopId(null);
|
shopUser.setShopId(null);
|
||||||
|
// 切换id
|
||||||
return updateById(shopUser);
|
StpKit.USER.reLogin(shopUser.getId());
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user