修改ws上下文对应的key规则,修改无tableId购物车缓存策略
This commit is contained in:
@@ -1,19 +1,23 @@
|
||||
package com.chaozhanggui.system.cashierservice.redis;
|
||||
|
||||
/** 功能描述:redis前缀
|
||||
* @params:
|
||||
* @return:
|
||||
* @Author: wgc
|
||||
* @Date: 2020-12-19 15:02
|
||||
*/
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
||||
/**
|
||||
* 功能描述:redis前缀
|
||||
*
|
||||
* @params:
|
||||
* @return:
|
||||
* @Author: wgc
|
||||
* @Date: 2020-12-19 15:02
|
||||
*/
|
||||
public class RedisCst {
|
||||
|
||||
//在线用户
|
||||
//在线用户
|
||||
public static final String ONLINE_USER = "ONLINE_USER:";
|
||||
public static final String PHONE_LIMIT = "PHONE_LIMIT:";
|
||||
public static final String ONLINE_APP_USER = "ONLINE_APP_USER:";
|
||||
public static final String LDBL_APP_VERSION = "LDBL_APP_VERSION:";
|
||||
public static final String TABLE_CART = "TABLE:CART:";
|
||||
// public static final String TABLE_CART = "TABLE:CART:";
|
||||
public static final String ORDER_EXPIRED = "ORDER:EXPIRED:";
|
||||
public static final String TABLE_ORDER = "TABLE:ORDER:";
|
||||
public static final String PRODUCT = "PRODUCT:";
|
||||
@@ -21,7 +25,7 @@ public class RedisCst {
|
||||
public static final String INTEGRAL_COIN_KEY = "INTEGRAL:COIN:KEY";
|
||||
public static final String COUPONS_COIN_KEY = "COUPONS:COIN:KEY";
|
||||
|
||||
public static final String OUT_NUMBER="ORDER:NUMBER:";
|
||||
public static final String OUT_NUMBER = "ORDER:NUMBER:";
|
||||
// 创建订单锁
|
||||
public static final String CREATE_ORDER_LOCK = "CREATE_ORDER_LOCK:";
|
||||
public static final String SEND_STOCK_WARN_MSG = "SEND_STOCK_WARN_MSG:";
|
||||
@@ -37,20 +41,40 @@ public class RedisCst {
|
||||
// 全局锁
|
||||
public static final String LOCK_KEY = "LOCK:";
|
||||
|
||||
// 外带购物车缓存
|
||||
public static final String TAKEOUT_TABLE_CART = "TAKEOUT_TABLE_CART:";
|
||||
// 店内就餐购物车缓存
|
||||
public static final String DINE_IN_TABLE_CART = "DINE_IN_TABLE_CART:";
|
||||
|
||||
|
||||
public static String getCurrentOrderKey(String tableId, String shopId) {
|
||||
return CURRENT_TABLE_ORDER + shopId + ":" + tableId;
|
||||
return CURRENT_TABLE_ORDER + shopId + ":" + tableId;
|
||||
}
|
||||
|
||||
public static String getTableCallNumKey(Integer shopId, Integer callTableId) {
|
||||
return TABLE_CALL_NUMBER + shopId + ":" + callTableId;
|
||||
}
|
||||
|
||||
public static String getLockKey(String sign, Object... args) {
|
||||
StringBuilder key = new StringBuilder(LOCK_KEY + ":" + sign + ":");
|
||||
for (Object arg : args) {
|
||||
key.append(":").append(arg.toString());
|
||||
public static String getLockKey(String sign, Object... args) {
|
||||
StringBuilder key = new StringBuilder(LOCK_KEY + ":" + sign + ":");
|
||||
for (Object arg : args) {
|
||||
key.append(":").append(arg.toString());
|
||||
}
|
||||
return key.toString();
|
||||
}
|
||||
|
||||
public static String getTakeoutTableCartKey(String shopId, Object userId) {
|
||||
return TAKEOUT_TABLE_CART + shopId + ":" + userId;
|
||||
}
|
||||
|
||||
public static String getDineInTableCartKey(String shopId, String tableId) {
|
||||
return DINE_IN_TABLE_CART + shopId + ":" + tableId;
|
||||
}
|
||||
|
||||
public static String getTableCartKey(String shopId, String tableId, Object userId) {
|
||||
if (StrUtil.isBlank(tableId)) {
|
||||
return getTakeoutTableCartKey(shopId, userId);
|
||||
}
|
||||
return getDineInTableCartKey(shopId, tableId);
|
||||
}
|
||||
return key.toString();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user