Merge remote-tracking branch 'origin/master'

This commit is contained in:
Tankaikai 2025-03-13 19:15:42 +08:00
commit 639917ed09
2 changed files with 47 additions and 8 deletions

View File

@ -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

View File

@ -228,7 +228,7 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
.eq(CashierCart::getTableCode, param.getTableCode()) .eq(CashierCart::getTableCode, param.getTableCode())
); );
if ("after-pay".equals(orderInfo.getPayMode())) { if ("after-pay".equals(orderInfo.getPayMode())) {
//发送打票信息 //发送打票信息 后付费推送多次 需要处理
rabbitPublisher.sendOrderPrintMsg(orderInfo.getId().toString()); rabbitPublisher.sendOrderPrintMsg(orderInfo.getId().toString());
} else { } else {
redisService.set(RedisCst.classKeyExpired.EXPIRED_ORDER + orderInfo.getId(), "", 60 * 15); redisService.set(RedisCst.classKeyExpired.EXPIRED_ORDER + orderInfo.getId(), "", 60 * 15);
@ -396,6 +396,10 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
addDTO.setVipPrice(false); addDTO.setVipPrice(false);
ShopInfo shopInfo = shopInfoService.getById(sourceOrder.getShopId()); ShopInfo shopInfo = shopInfoService.getById(sourceOrder.getShopId());
targetOrder = initOrderInfo(addDTO, shopInfo, null); targetOrder = initOrderInfo(addDTO, shopInfo, null);
} else {
targetOrder.setPlaceNum(targetOrder.getPlaceNum() + 1);
//下单次数+1
updateChain().set(OrderInfo::getPlaceNum, targetOrder.getPlaceNum() + 1).eq(OrderInfo::getId, targetOrder.getId()).update();
} }
if (CollUtil.isEmpty(param.getDetailIds())) { if (CollUtil.isEmpty(param.getDetailIds())) {
long count = orderDetailService.queryChain().eq(OrderDetail::getOrderId, sourceOrder.getId()).count(); long count = orderDetailService.queryChain().eq(OrderDetail::getOrderId, sourceOrder.getId()).count();
@ -404,12 +408,14 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
} }
orderDetailService.updateChain() orderDetailService.updateChain()
.eq(OrderDetail::getOrderId, sourceOrder.getId()) .eq(OrderDetail::getOrderId, sourceOrder.getId())
.set(OrderDetail::getPlaceNum, targetOrder.getPlaceNum())
.set(OrderDetail::getOrderId, targetOrder.getId()) .set(OrderDetail::getOrderId, targetOrder.getId())
.update(); .update();
} else { } else {
orderDetailService.updateChain() orderDetailService.updateChain()
.eq(OrderDetail::getOrderId, sourceOrder.getId()) .eq(OrderDetail::getOrderId, sourceOrder.getId())
.in(OrderDetail::getId, param.getDetailIds()) .in(OrderDetail::getId, param.getDetailIds())
.set(OrderDetail::getPlaceNum, targetOrder.getPlaceNum())
.set(OrderDetail::getOrderId, targetOrder.getId()) .set(OrderDetail::getOrderId, targetOrder.getId())
.update(); .update();
} }
@ -683,10 +689,10 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
updateChain.set(OrderInfo::getPayType, payType.getValue()); updateChain.set(OrderInfo::getPayType, payType.getValue());
} }
updateChain.update(); updateChain.update();
if (!"after-pay".equals(orderInfo.getPayMode())) { // if (!"after-pay".equals(orderInfo.getPayMode())) {
//发送打票信息 //发送打票信息
rabbitPublisher.sendOrderPrintMsg(orderInfo.getId().toString()); rabbitPublisher.sendOrderPrintMsg(orderInfo.getId().toString());
} // }
} }
/** /**