选择餐位费加入缓存
This commit is contained in:
@@ -20,6 +20,8 @@ import com.chaozhanggui.system.cashierservice.exception.MsgException;
|
||||
import com.chaozhanggui.system.cashierservice.mapper.MpCashierCartMapper;
|
||||
import com.chaozhanggui.system.cashierservice.mapper.MpOrderInfoMapper;
|
||||
import com.chaozhanggui.system.cashierservice.mapper.MpShopTableMapper;
|
||||
import com.chaozhanggui.system.cashierservice.redis.RedisCst;
|
||||
import com.chaozhanggui.system.cashierservice.redis.RedisUtil;
|
||||
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
|
||||
import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||
import com.chaozhanggui.system.cashierservice.util.*;
|
||||
@@ -98,6 +100,8 @@ public class ProductService {
|
||||
private MpCashierCartMapper mpCashierCartMapper;
|
||||
@Autowired
|
||||
private MpOrderInfoMapper mpOrderInfoMapper;
|
||||
@Autowired
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
public ProductService(ShopUtils shopUtils) {
|
||||
this.shopUtils = shopUtils;
|
||||
@@ -929,6 +933,18 @@ public class ProductService {
|
||||
mpCashierCartMapper.updateById(tbCashierCart);
|
||||
}
|
||||
|
||||
// 将数据加入缓存
|
||||
String tableCartKey = RedisCst.getTableCartKey(String.valueOf(choseCountDTO.getShopId()), choseCountDTO.getTableId(), userId);
|
||||
String message = redisUtil.getMessage(tableCartKey);
|
||||
JSONArray jsonArray;
|
||||
if (StrUtil.isNotBlank(message)) {
|
||||
jsonArray = JSONObject.parseArray(message);
|
||||
}else {
|
||||
jsonArray = new JSONArray();
|
||||
}
|
||||
jsonArray.add(tbCashierCart);
|
||||
redisUtil.saveMessage(tableCartKey, jsonArray.toJSONString());
|
||||
|
||||
return tbCashierCart;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user