限制台桌选择人数

This commit is contained in:
2024-09-27 17:12:34 +08:00
parent 8a467a22ec
commit 77a6a525cd
2 changed files with 65 additions and 58 deletions

View File

@@ -32,6 +32,8 @@ public class RedisCst {
public static final String SONG_PAY_LOCK = "song_pay_lock:"; public static final String SONG_PAY_LOCK = "song_pay_lock:";
public static final String ORDER_PRINT_PRO = "ORDER_PRINT_PRODUCT:"; public static final String ORDER_PRINT_PRO = "ORDER_PRINT_PRODUCT:";
public static final String ORDER_PRINT = "ORDER_PRINT:"; public static final String ORDER_PRINT = "ORDER_PRINT:";
// 选择人数锁
public static final String CHOSE_TABLE_COUNT = "CHOSE_TABLE_COUNT";
static final String CURRENT_TABLE_ORDER = "CURRENT_TABLE_ORDER:"; static final String CURRENT_TABLE_ORDER = "CURRENT_TABLE_ORDER:";

View File

@@ -32,6 +32,7 @@ import lombok.Data;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
@@ -102,6 +103,8 @@ public class ProductService {
private MpOrderInfoMapper mpOrderInfoMapper; private MpOrderInfoMapper mpOrderInfoMapper;
@Autowired @Autowired
private RedisUtil redisUtil; private RedisUtil redisUtil;
@Autowired
private StringRedisTemplate stringRedisTemplate;
public ProductService(ShopUtils shopUtils) { public ProductService(ShopUtils shopUtils) {
this.shopUtils = shopUtils; this.shopUtils = shopUtils;
@@ -878,6 +881,7 @@ public class ProductService {
} }
public TbCashierCart choseCount(ChoseCountDTO choseCountDTO) { public TbCashierCart choseCount(ChoseCountDTO choseCountDTO) {
return Utils.runFunAndCheckKey(() -> {
ShopEatTypeInfoDTO shopEatTypeInfoDTO = shopUtils.checkEatModel(choseCountDTO.getTableId(), choseCountDTO.getShopId()); ShopEatTypeInfoDTO shopEatTypeInfoDTO = shopUtils.checkEatModel(choseCountDTO.getTableId(), choseCountDTO.getShopId());
TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(choseCountDTO.getShopId()); TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(choseCountDTO.getShopId());
@@ -945,6 +949,7 @@ public class ProductService {
redisUtil.saveMessage(tableCartKey, jsonArray.toJSONString()); redisUtil.saveMessage(tableCartKey, jsonArray.toJSONString());
return tbCashierCart; return tbCashierCart;
}, stringRedisTemplate, RedisCst.getLockKey(RedisCst.CHOSE_TABLE_COUNT, choseCountDTO.getShopId(), choseCountDTO.getTableId()));
} }
private TbCashierCart getSeatCartInfo(Object shopId, String tableId, Integer userId, ShopEatTypeInfoDTO shopEatTypeInfoDTO) { private TbCashierCart getSeatCartInfo(Object shopId, String tableId, Integer userId, ShopEatTypeInfoDTO shopEatTypeInfoDTO) {