加入会员合并同账号数据

This commit is contained in:
张松 2025-03-14 15:44:28 +08:00
parent a5e3570cde
commit 51e1644624
1 changed files with 6 additions and 4 deletions

View File

@ -274,8 +274,10 @@ public class ShopUserServiceImpl extends ServiceImpl<ShopUserMapper, ShopUser> i
oriInfo.setAlipayOpenId(userInfo.getWechatOpenId());
}
// 迁移订单
orderInfoService.updateChain().eq(OrderInfo::getUserId, userInfo.getId())
.set(OrderInfo::getUserId, oriInfo.getId()).update();
OrderInfo orderInfo = new OrderInfo();
orderInfo.setUserId(oriInfo.getId());
orderInfoService.update(orderInfo, new QueryWrapper().eq(OrderInfo::getUserId, userInfo.getId()));
// 删除多余用户信息
userInfoService.removeById(userId);
@ -285,11 +287,11 @@ public class ShopUserServiceImpl extends ServiceImpl<ShopUserMapper, ShopUser> i
}
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, userInfo.getId()));
if (shopUser == null) {
shopUser = new ShopUser();
shopUser.setShopId(shopId);
shopUser.setUserId(userId);
shopUser.setUserId(userInfo.getId());
save(shopUser);
} else if (shopUser.getIsVip() == 1) {
throw new ApiNotPrintException("您已加入店铺会员");