用户下单同步修改台桌状态

This commit is contained in:
2024-10-25 10:27:11 +08:00
parent a8e9924f74
commit 0334d88a4f
8 changed files with 112 additions and 9 deletions

View File

@@ -20,6 +20,7 @@ import com.chaozhanggui.system.cashierservice.entity.dto.ChoseEatModelDTO;
import com.chaozhanggui.system.cashierservice.entity.dto.ShopEatTypeInfoDTO;
import com.chaozhanggui.system.cashierservice.exception.MsgException;
import com.chaozhanggui.system.cashierservice.mapper.*;
import com.chaozhanggui.system.cashierservice.mpservice.MpShopTableService;
import com.chaozhanggui.system.cashierservice.netty.PushToAppChannelHandlerAdapter;
import com.chaozhanggui.system.cashierservice.rabbit.RabbitProducer;
import com.chaozhanggui.system.cashierservice.redis.RedisCst;
@@ -124,10 +125,12 @@ public class CartService {
private MpOrderDetailMapper mpOrderDetailMapper;
@Autowired
private MpShopTableMapper mpShopTableMapper;
private final MpShopTableService mpShopTableService;
@Autowired
private MQUtils mQUtils;
public CartService(TbUserShopMsgMapper tbUserShopMsgMapper, WechatUtil wechatUtil, WxAccountUtil wxAccountUtil, TbShopOpenIdMapper shopOpenIdMapper, ProductService productService, TbProductMapper tbProductMapper, RedisTemplate<String, Object> redisTemplate, StringRedisTemplate stringRedisTemplate, ShopUtils shopUtils) {
public CartService(TbUserShopMsgMapper tbUserShopMsgMapper, WechatUtil wechatUtil, WxAccountUtil wxAccountUtil, TbShopOpenIdMapper shopOpenIdMapper, ProductService productService, TbProductMapper tbProductMapper, RedisTemplate<String, Object> redisTemplate, StringRedisTemplate stringRedisTemplate, ShopUtils shopUtils, MpShopTableService mpShopTableService) {
this.tbUserShopMsgMapper = tbUserShopMsgMapper;
this.wechatUtil = wechatUtil;
this.wxAccountUtil = wxAccountUtil;
@@ -137,6 +140,7 @@ public class CartService {
this.redisTemplate = redisTemplate;
this.stringRedisTemplate = stringRedisTemplate;
this.shopUtils = shopUtils;
this.mpShopTableService = mpShopTableService;
}
@@ -1162,6 +1166,11 @@ public class CartService {
}
}
// 修改台桌状态
if (!shopEatTypeInfoDTO.isTakeout() && StrUtil.isNotBlank(tableId)) {
mpShopTableService.updateStateByQrcode(tableId, TableConstant.ShopTable.State.USING);
}
// 发送mq消息
JSONObject jsonObject2 = new JSONObject();
jsonObject2.put("orderId", orderInfo.getId());

View File

@@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.chaozhanggui.system.cashierservice.constant.TableConstant;
import com.chaozhanggui.system.cashierservice.dao.*;
import com.chaozhanggui.system.cashierservice.entity.Enum.OrderUseTypeEnum;
import com.chaozhanggui.system.cashierservice.entity.*;
@@ -19,6 +20,7 @@ import com.chaozhanggui.system.cashierservice.mapper.MpOrderDetailMapper;
import com.chaozhanggui.system.cashierservice.mapper.MpOrderInfoMapper;
import com.chaozhanggui.system.cashierservice.model.PayReq;
import com.chaozhanggui.system.cashierservice.model.TradeQueryReq;
import com.chaozhanggui.system.cashierservice.mpservice.MpShopTableService;
import com.chaozhanggui.system.cashierservice.netty.PushToClientChannelHandlerAdapter;
import com.chaozhanggui.system.cashierservice.rabbit.RabbitProducer;
import com.chaozhanggui.system.cashierservice.redis.RedisCst;
@@ -178,8 +180,11 @@ public class PayService {
@Autowired
private MpCashierCartMapper mpCashierCartMapper;
public PayService(@Qualifier("tbShopSongOrderServiceImpl") TbShopSongOrderService shopSongOrderService) {
private final MpShopTableService mpShopTableService;
public PayService(@Qualifier("tbShopSongOrderServiceImpl") TbShopSongOrderService shopSongOrderService, MpShopTableService mpShopTableService) {
this.shopSongOrderService = shopSongOrderService;
this.mpShopTableService = mpShopTableService;
}
@Transactional(rollbackFor = Exception.class)
@@ -520,6 +525,15 @@ public class PayService {
stringRedisTemplate.delete(currentOrderKey);
}
// 重置台桌状态
if (StrUtil.isNotBlank(orderInfo.getTableId())) {
TbShopTable shopTable = mpShopTableService.selectByQrcode(orderInfo.getTableId());
if (shopTable.getAutoClear() != null && shopTable.getAutoClear() == 1) {
mpShopTableService.updateStateByQrcode(orderInfo.getTableId(), TableConstant.ShopTable.State.IDLE);
}else {
mpShopTableService.updateStateByQrcode(orderInfo.getTableId(), TableConstant.ShopTable.State.CLEANING);
}
}
return Result.success(CodeEnum.SUCCESS, "1");
}
@@ -1137,6 +1151,16 @@ public class PayService {
data.put("orderId", orderInfo.getId());
data.put("plat", "miniApp");
mQUtils.sendStockSaleMsg(data);
// 重置台桌状态
if (StrUtil.isNotBlank(orderInfo.getTableId())) {
TbShopTable shopTable = mpShopTableService.selectByQrcode(orderInfo.getTableId());
if (shopTable.getAutoClear() != null && shopTable.getAutoClear() == 1) {
mpShopTableService.updateStateByQrcode(orderInfo.getTableId(), TableConstant.ShopTable.State.IDLE);
}else {
mpShopTableService.updateStateByQrcode(orderInfo.getTableId(), TableConstant.ShopTable.State.CLEANING);
}
}
return "SUCCESS";
}