From f06c6cff67487377e7771b8df1a695ba8915e257 Mon Sep 17 00:00:00 2001 From: SongZhang <2064194730@qq.com> Date: Sun, 29 Sep 2024 14:14:38 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=B1=E9=A4=90=E6=A8=A1=E5=BC=8F=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/cashierservice/rabbit/CartConsumer.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/CartConsumer.java b/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/CartConsumer.java index cd5a82d..d1f0c64 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/CartConsumer.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/rabbit/CartConsumer.java @@ -3,10 +3,12 @@ package com.chaozhanggui.system.cashierservice.rabbit; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import com.chaozhanggui.system.cashierservice.entity.dto.ShopEatTypeInfoDTO; import com.chaozhanggui.system.cashierservice.exception.MsgException; import com.chaozhanggui.system.cashierservice.redis.RedisCst; import com.chaozhanggui.system.cashierservice.redis.RedisUtil; import com.chaozhanggui.system.cashierservice.service.CartService; +import com.chaozhanggui.system.cashierservice.util.ShopUtils; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.amqp.rabbit.annotation.RabbitHandler; @@ -26,6 +28,9 @@ public class CartConsumer { private RedisUtil redisUtil; @Autowired private CartService cartService; + @Autowired + private ShopUtils shopUtils; + @RabbitHandler @RabbitListener(queues = {"${queue}"}) public void listener(String message) { @@ -47,7 +52,8 @@ public class CartConsumer { else if (jsonObject.getString("type").equals("queryCart") ) { cartService.queryCart(jsonObject); } else if(jsonObject.getString("type").equals("createOrder")){ - String tableCartKey = RedisCst.getTableCartKey(shopId, tableId, userId); + ShopEatTypeInfoDTO eatModel = shopUtils.getEatModel(tableId, shopId); + String tableCartKey = RedisCst.getTableCartKey(shopId, eatModel.isOpenDineIn() ? tableId : null, userId); String cartDetail = redisUtil.getMessage(tableCartKey); if (StringUtils.isEmpty(cartDetail)){ log.info("createOrder购物车为空");