选择餐位费加入缓存
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.MpCashierCartMapper;
|
||||||
import com.chaozhanggui.system.cashierservice.mapper.MpOrderInfoMapper;
|
import com.chaozhanggui.system.cashierservice.mapper.MpOrderInfoMapper;
|
||||||
import com.chaozhanggui.system.cashierservice.mapper.MpShopTableMapper;
|
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.CodeEnum;
|
||||||
import com.chaozhanggui.system.cashierservice.sign.Result;
|
import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||||
import com.chaozhanggui.system.cashierservice.util.*;
|
import com.chaozhanggui.system.cashierservice.util.*;
|
||||||
@@ -98,6 +100,8 @@ public class ProductService {
|
|||||||
private MpCashierCartMapper mpCashierCartMapper;
|
private MpCashierCartMapper mpCashierCartMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
private MpOrderInfoMapper mpOrderInfoMapper;
|
private MpOrderInfoMapper mpOrderInfoMapper;
|
||||||
|
@Autowired
|
||||||
|
private RedisUtil redisUtil;
|
||||||
|
|
||||||
public ProductService(ShopUtils shopUtils) {
|
public ProductService(ShopUtils shopUtils) {
|
||||||
this.shopUtils = shopUtils;
|
this.shopUtils = shopUtils;
|
||||||
@@ -929,6 +933,18 @@ public class ProductService {
|
|||||||
mpCashierCartMapper.updateById(tbCashierCart);
|
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;
|
return tbCashierCart;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user