就餐模式获取修改

This commit is contained in:
2024-09-29 14:14:38 +08:00
parent 6ddde0e335
commit f06c6cff67

View File

@@ -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购物车为空");