修改ws上下文对应的key规则,修改无tableId购物车缓存策略
This commit is contained in:
@@ -34,6 +34,7 @@ public class CartConsumer {
|
||||
JSONObject jsonObject = JSON.parseObject(message);
|
||||
String tableId = jsonObject.getString("tableId");
|
||||
String shopId = jsonObject.getString("shopId");
|
||||
Integer userId = jsonObject.getInteger("userId");
|
||||
if (jsonObject.getString("type").equals("initCart") ) {
|
||||
cartService.initCart(jsonObject);
|
||||
}
|
||||
@@ -46,13 +47,14 @@ public class CartConsumer {
|
||||
else if (jsonObject.getString("type").equals("queryCart") ) {
|
||||
cartService.queryCart(jsonObject);
|
||||
} else if(jsonObject.getString("type").equals("createOrder")){
|
||||
String cartDetail = redisUtil.getMessage(RedisCst.TABLE_CART.concat(tableId).concat("-").concat(shopId));
|
||||
String tableCartKey = RedisCst.getTableCartKey(shopId, tableId, userId);
|
||||
String cartDetail = redisUtil.getMessage(tableCartKey);
|
||||
if (StringUtils.isEmpty(cartDetail)){
|
||||
log.info("createOrder购物车为空");
|
||||
throw new MsgException("购物车为空无法下单");
|
||||
}
|
||||
JSONArray array = JSON.parseArray(cartDetail);
|
||||
if (array.size() > 0){
|
||||
if (!array.isEmpty()){
|
||||
cartService.createOrder(jsonObject);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user