客座费支持删除清空
This commit is contained in:
@@ -47,6 +47,8 @@ public class RedisCst {
|
|||||||
public static final String TAKEOUT_TABLE_CART = "TAKEOUT_TABLE_CART:";
|
public static final String TAKEOUT_TABLE_CART = "TAKEOUT_TABLE_CART:";
|
||||||
// 店内就餐购物车缓存
|
// 店内就餐购物车缓存
|
||||||
public static final String DINE_IN_TABLE_CART = "DINE_IN_TABLE_CART:";
|
public static final String DINE_IN_TABLE_CART = "DINE_IN_TABLE_CART:";
|
||||||
|
// 当前台桌人数
|
||||||
|
public static final String CURRENT_TABLE_SEAR_COUNT = "CURRENT_TABLE_SEAR_COUNT:";
|
||||||
|
|
||||||
|
|
||||||
public static String getCurrentOrderKey(String tableId, String shopId) {
|
public static String getCurrentOrderKey(String tableId, String shopId) {
|
||||||
@@ -79,4 +81,8 @@ public class RedisCst {
|
|||||||
}
|
}
|
||||||
return getDineInTableCartKey(shopId, tableId);
|
return getDineInTableCartKey(shopId, tableId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getCurrentTableSeatCount(Object shopId, String tableId) {
|
||||||
|
return CURRENT_TABLE_SEAR_COUNT + (shopId + ":" + tableId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -137,7 +137,6 @@ public class CartService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前台桌当前下单次数
|
* 获取当前台桌当前下单次数
|
||||||
*
|
*
|
||||||
@@ -174,6 +173,7 @@ public class CartService {
|
|||||||
JSONArray array = new JSONArray();
|
JSONArray array = new JSONArray();
|
||||||
|
|
||||||
String tableCartKey = RedisCst.getTableCartKey(shopId, tableId, userId);
|
String tableCartKey = RedisCst.getTableCartKey(shopId, tableId, userId);
|
||||||
|
TbCashierCart seatCartInfo = null;
|
||||||
if (redisUtil.exists(tableCartKey)) {
|
if (redisUtil.exists(tableCartKey)) {
|
||||||
array = JSON.parseArray(redisUtil.getMessage(tableCartKey));
|
array = JSON.parseArray(redisUtil.getMessage(tableCartKey));
|
||||||
for (int i = 0; i < array.size(); i++) {
|
for (int i = 0; i < array.size(); i++) {
|
||||||
@@ -182,6 +182,10 @@ public class CartService {
|
|||||||
if (cashierCart.getNumber() > 0) {
|
if (cashierCart.getNumber() > 0) {
|
||||||
amount = amount.add(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee())));
|
amount = amount.add(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ("-999".equals(cashierCart.getProductId())) {
|
||||||
|
seatCartInfo = cashierCart;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 查询购物车所有信息
|
// 查询购物车所有信息
|
||||||
@@ -193,20 +197,27 @@ public class CartService {
|
|||||||
|
|
||||||
if (StrUtil.isNotBlank(tableId)) {
|
if (StrUtil.isNotBlank(tableId)) {
|
||||||
queryWrapper.eq(TbCashierCart::getTableId, tableId);
|
queryWrapper.eq(TbCashierCart::getTableId, tableId);
|
||||||
}else {
|
} else {
|
||||||
queryWrapper.eq(TbCashierCart::getUserId, userId);
|
queryWrapper.eq(TbCashierCart::getUserId, userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<TbCashierCart> tbCashierCarts = mpCashierCartMapper.selectList(queryWrapper);;
|
List<TbCashierCart> tbCashierCarts = mpCashierCartMapper.selectList(queryWrapper);
|
||||||
if (!CollectionUtils.isEmpty(tbCashierCarts)) {
|
if (!CollectionUtils.isEmpty(tbCashierCarts)) {
|
||||||
for (TbCashierCart cashierCart : tbCashierCarts) {
|
for (TbCashierCart cashierCart : tbCashierCarts) {
|
||||||
|
if ("-999".equals(cashierCart.getProductId())) {
|
||||||
|
seatCartInfo = cashierCart;
|
||||||
|
}
|
||||||
array.add(cashierCart);
|
array.add(cashierCart);
|
||||||
if(cashierCart.getIsVip().equals((byte) 1)) continue;
|
if (cashierCart.getIsVip().equals((byte) 1)) continue;
|
||||||
amount = amount.add(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee())));
|
amount = amount.add(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee())));
|
||||||
}
|
}
|
||||||
redisUtil.saveMessage(tableCartKey, array.toString());
|
redisUtil.saveMessage(tableCartKey, array.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ShopEatTypeInfoDTO shopEatTypeInfoDTO = shopUtils.checkEatModel(tableId, shopId);
|
||||||
|
redisUtil.saveMessage(RedisCst.getCurrentTableSeatCount(shopEatTypeInfoDTO.getShopInfo().getId(), tableId), JSONObject.toJSONString(seatCartInfo), 60 * 60 * 12L);
|
||||||
|
|
||||||
JSONObject jsonObject1 = new JSONObject();
|
JSONObject jsonObject1 = new JSONObject();
|
||||||
jsonObject1.put("status", "success");
|
jsonObject1.put("status", "success");
|
||||||
jsonObject1.put("msg", "成功");
|
jsonObject1.put("msg", "成功");
|
||||||
@@ -216,8 +227,74 @@ public class CartService {
|
|||||||
PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), tableCartKey, "", false);
|
PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), tableCartKey, "", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void checkSeatInfo(ShopEatTypeInfoDTO shopEatTypeInfoDTO, String tableId, Integer userId) {
|
||||||
|
TbShopInfo shopInfo = shopEatTypeInfoDTO.getShopInfo();
|
||||||
|
if (shopInfo.getIsTableFee() != null && shopInfo.getIsTableFee() == 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!shopEatTypeInfoDTO.isTakeout()) {
|
||||||
|
String tableCartKey = RedisCst.getTableCartKey(shopEatTypeInfoDTO.getShopInfo().getId().toString(), tableId, userId);
|
||||||
|
String message = redisUtil.getMessage(tableCartKey);
|
||||||
|
|
||||||
|
boolean hasSeatInfo = false;
|
||||||
|
JSONArray array = null;
|
||||||
|
if (StrUtil.isNotBlank(message)) {
|
||||||
|
array = JSON.parseArray(message);
|
||||||
|
long count = array.stream().filter(item -> {
|
||||||
|
TbCashierCart cashierCart = JSONUtil.parseJSONStr2T(((JSONObject) item).toJSONString(), TbCashierCart.class);
|
||||||
|
return "-999".equals(cashierCart.getProductId());
|
||||||
|
}).count();
|
||||||
|
hasSeatInfo = count > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasSeatInfo) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (array == null) {
|
||||||
|
array = new JSONArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
String oldSeatInfo = redisUtil.getMessage(RedisCst.getCurrentTableSeatCount(shopEatTypeInfoDTO.getShopInfo().getId(), tableId));
|
||||||
|
TbCashierCart tbCashierCart = null;
|
||||||
|
if (StrUtil.isNotBlank(oldSeatInfo)) {
|
||||||
|
tbCashierCart = JSONObject.parseObject(oldSeatInfo, TbCashierCart.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tbCashierCart == null) {
|
||||||
|
tbCashierCart = new TbCashierCart();
|
||||||
|
tbCashierCart.setStatus("create");
|
||||||
|
tbCashierCart.setCreatedAt(System.currentTimeMillis());
|
||||||
|
tbCashierCart.setTableId(tableId);
|
||||||
|
tbCashierCart.setName("客座费");
|
||||||
|
tbCashierCart.setSalePrice(shopInfo.getTableFee());
|
||||||
|
tbCashierCart.setShopId(String.valueOf(shopEatTypeInfoDTO.getShopInfo().getId()));
|
||||||
|
tbCashierCart.setTradeDay(DateUtils.getDay());
|
||||||
|
tbCashierCart.setStatus("create");
|
||||||
|
tbCashierCart.setTotalAmount(shopInfo.getTableFee());
|
||||||
|
tbCashierCart.setPlaceNum(1);
|
||||||
|
tbCashierCart.setProductId("-999");
|
||||||
|
tbCashierCart.setSkuId("-999");
|
||||||
|
tbCashierCart.setPackFee(BigDecimal.ZERO);
|
||||||
|
tbCashierCart.setNumber(1);
|
||||||
|
tbCashierCart.setTotalNumber(1);
|
||||||
|
tbCashierCart.setUseType(shopEatTypeInfoDTO.getUseType());
|
||||||
|
tbCashierCart.setPlatformType(PlatformTypeEnum.MINI_APP.getValue());
|
||||||
|
tbCashierCart.setUserId(userId);
|
||||||
|
}
|
||||||
|
tbCashierCart.setId(null);
|
||||||
|
|
||||||
|
mpCashierCartMapper.insert(tbCashierCart);
|
||||||
|
array.add(tbCashierCart);
|
||||||
|
redisUtil.saveMessage(tableCartKey, array.toString());
|
||||||
|
redisUtil.saveMessage(RedisCst.getCurrentTableSeatCount(shopEatTypeInfoDTO.getShopInfo().getId(), tableId), JSONObject.toJSONString(tbCashierCart), 60 * 60 * 12L);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 加入购物车
|
* 加入购物车
|
||||||
|
*
|
||||||
* @param jsonObject 商品信息
|
* @param jsonObject 商品信息
|
||||||
*/
|
*/
|
||||||
public Result createCart(JSONObject jsonObject) {
|
public Result createCart(JSONObject jsonObject) {
|
||||||
@@ -284,23 +361,27 @@ public class CartService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
JSONArray jsonArray = new JSONArray();
|
JSONArray jsonArray = new JSONArray();
|
||||||
ArrayList<TbCashierCart> cashierCartArrayList = new ArrayList<>();
|
ArrayList<TbCashierCart> cashierCartArrayList = new ArrayList<>();
|
||||||
BigDecimal amount = BigDecimal.ZERO;
|
BigDecimal amount = BigDecimal.ZERO;
|
||||||
try{
|
try {
|
||||||
if (redisUtil.exists(tableCartKey)) {
|
if (redisUtil.exists(tableCartKey)) {
|
||||||
JSONArray array = JSON.parseArray(redisUtil.getMessage(tableCartKey));
|
JSONArray array = JSON.parseArray(redisUtil.getMessage(tableCartKey));
|
||||||
if (Objects.isNull(array) || array.isEmpty()) {
|
if (Objects.isNull(array) || array.isEmpty()) {
|
||||||
if (type == 1) {
|
if (type == 1) {
|
||||||
TbCashierCart cashierCart = addCart(productId, skuId,
|
TbCashierCart cashierCart = addCart(productId, skuId,
|
||||||
jsonObject.getInteger("userId"), buyNum, tableId, shopId,isVip, note, shopEatTypeInfoDTO.isTakeout());
|
jsonObject.getInteger("userId"), buyNum, tableId, shopId, isVip, note, shopEatTypeInfoDTO.isTakeout());
|
||||||
jsonArray.add(cashierCart);
|
jsonArray.add(cashierCart);
|
||||||
cashierCart.setPlaceNum(cashierCart.getPlaceNum() == null ? 0 : cashierCart.getPlaceNum());
|
cashierCart.setPlaceNum(cashierCart.getPlaceNum() == null ? 0 : cashierCart.getPlaceNum());
|
||||||
cashierCartArrayList.add(cashierCart);
|
cashierCartArrayList.add(cashierCart);
|
||||||
amount = amount.add(new BigDecimal(cashierCart.getNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee())));
|
amount = amount.add(new BigDecimal(cashierCart.getNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee())));
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
boolean flag = true;
|
boolean flag = true;
|
||||||
|
|
||||||
|
boolean hasSeat = false;
|
||||||
for (int i = 0; i < array.size(); i++) {
|
for (int i = 0; i < array.size(); i++) {
|
||||||
JSONObject object = array.getJSONObject(i);
|
JSONObject object = array.getJSONObject(i);
|
||||||
TbCashierCart cashierCart = JSONUtil.parseJSONStr2T(object.toJSONString(), TbCashierCart.class);
|
TbCashierCart cashierCart = JSONUtil.parseJSONStr2T(object.toJSONString(), TbCashierCart.class);
|
||||||
@@ -351,18 +432,24 @@ public class CartService {
|
|||||||
jsonArray.add(cashierCart);
|
jsonArray.add(cashierCart);
|
||||||
cashierCartArrayList.add(cashierCart);
|
cashierCartArrayList.add(cashierCart);
|
||||||
amount = amount.add(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee())));
|
amount = amount.add(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee())));
|
||||||
|
|
||||||
|
if ("-999".equals(cashierCart.getProductId())) {
|
||||||
|
hasSeat = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flag && type == 1) {
|
if (flag && type == 1) {
|
||||||
TbCashierCart cashierCart = addCart(productId, skuId,
|
TbCashierCart cashierCart = addCart(productId, skuId,
|
||||||
jsonObject.getInteger("userId"), buyNum, tableId, shopId,isVip, note, shopEatTypeInfoDTO.isTakeout());
|
jsonObject.getInteger("userId"), buyNum, tableId, shopId, isVip, note, shopEatTypeInfoDTO.isTakeout());
|
||||||
jsonArray.add(cashierCart);
|
jsonArray.add(cashierCart);
|
||||||
amount = amount.add(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee())));
|
amount = amount.add(new BigDecimal(cashierCart.getTotalNumber()).multiply(cashierCart.getSalePrice().add(cashierCart.getPackFee())));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (type == 1) {
|
if (type == 1) {
|
||||||
TbCashierCart cashierCart = addCart(productId, skuId,
|
TbCashierCart cashierCart = addCart(productId, skuId,
|
||||||
jsonObject.getInteger("userId"), buyNum, tableId, shopId,isVip, note, shopEatTypeInfoDTO.isTakeout());
|
jsonObject.getInteger("userId"), buyNum, tableId, shopId, isVip, note, shopEatTypeInfoDTO.isTakeout());
|
||||||
jsonArray.add(cashierCart);
|
jsonArray.add(cashierCart);
|
||||||
cashierCart.setPlaceNum(cashierCart.getPlaceNum() == null ? 0 : cashierCart.getPlaceNum());
|
cashierCart.setPlaceNum(cashierCart.getPlaceNum() == null ? 0 : cashierCart.getPlaceNum());
|
||||||
cashierCartArrayList.add(cashierCart);
|
cashierCartArrayList.add(cashierCart);
|
||||||
@@ -371,8 +458,8 @@ public class CartService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}catch (MsgException e){
|
} catch (MsgException e) {
|
||||||
if(e.getMessage().equals("商品起售库存不足")){
|
if (e.getMessage().equals("商品起售库存不足")) {
|
||||||
return Result.fail("商品起售库存不足");
|
return Result.fail("商品起售库存不足");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -412,7 +499,7 @@ public class CartService {
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void rmCart(JSONObject jsonObject,String skuId, String redisKey) {
|
private void rmCart(JSONObject jsonObject, String skuId, String redisKey) {
|
||||||
JSONArray jsonArray = new JSONArray();
|
JSONArray jsonArray = new JSONArray();
|
||||||
BigDecimal amount = BigDecimal.ZERO;
|
BigDecimal amount = BigDecimal.ZERO;
|
||||||
if (redisUtil.exists(redisKey)) {
|
if (redisUtil.exists(redisKey)) {
|
||||||
@@ -425,7 +512,7 @@ public class CartService {
|
|||||||
if (cashierCart.getSkuId().equals(skuId)) {
|
if (cashierCart.getSkuId().equals(skuId)) {
|
||||||
if (StrUtil.isNotBlank(cashierCart.getMasterId())) {
|
if (StrUtil.isNotBlank(cashierCart.getMasterId())) {
|
||||||
throw new MsgException("代客下单商品不支持操作");
|
throw new MsgException("代客下单商品不支持操作");
|
||||||
}else {
|
} else {
|
||||||
cashierCartMapper.deleteByPrimaryKey(cashierCart.getId());
|
cashierCartMapper.deleteByPrimaryKey(cashierCart.getId());
|
||||||
flag = true;
|
flag = true;
|
||||||
continue;
|
continue;
|
||||||
@@ -442,7 +529,7 @@ public class CartService {
|
|||||||
jsonObject1.put("data", jsonArray);
|
jsonObject1.put("data", jsonArray);
|
||||||
jsonObject1.put("amount", amount);
|
jsonObject1.put("amount", amount);
|
||||||
jsonObject1.put("reqData", jsonObject);
|
jsonObject1.put("reqData", jsonObject);
|
||||||
if(flag){
|
if (flag) {
|
||||||
PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), redisKey, "", false);
|
PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), redisKey, "", false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -518,7 +605,7 @@ public class CartService {
|
|||||||
product.getIsDistribute() == 1 ? product.getStockNumber() - num : (int) (productSku.getStockNumber() - num)
|
product.getIsDistribute() == 1 ? product.getStockNumber() - num : (int) (productSku.getStockNumber() - num)
|
||||||
, item.getOpenId(), ShopWxMsgTypeEnum.STOCK_MSG, shopInfo.getId());
|
, item.getOpenId(), ShopWxMsgTypeEnum.STOCK_MSG, shopInfo.getId());
|
||||||
redisUtil.saveMessage(RedisCst.SEND_STOCK_WARN_MSG + product.getId() + ":" + item.getOpenId(), product.getId().toString(), 60 * 30L);
|
redisUtil.saveMessage(RedisCst.SEND_STOCK_WARN_MSG + product.getId() + ":" + item.getOpenId(), product.getId().toString(), 60 * 30L);
|
||||||
}else {
|
} else {
|
||||||
log.info("{}已在30分钟内推送过消息,跳过发送", item.getOpenId());
|
log.info("{}已在30分钟内推送过消息,跳过发送", item.getOpenId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -527,7 +614,7 @@ public class CartService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private TbCashierCart addCart(String productId, String skuId, Integer userId, Integer num,
|
private TbCashierCart addCart(String productId, String skuId, Integer userId, Integer num,
|
||||||
String tableId, String shopId,Integer isVip, String note, boolean isTakeout) throws Exception{
|
String tableId, String shopId, Integer isVip, String note, boolean isTakeout) throws Exception {
|
||||||
try {
|
try {
|
||||||
TbProduct product = productMapper.selectById(Integer.valueOf(productId));
|
TbProduct product = productMapper.selectById(Integer.valueOf(productId));
|
||||||
String key = tableId + "-" + shopId;
|
String key = tableId + "-" + shopId;
|
||||||
@@ -540,13 +627,13 @@ public class CartService {
|
|||||||
if (Integer.valueOf(product.getIsDistribute()).equals(1)) {
|
if (Integer.valueOf(product.getIsDistribute()).equals(1)) {
|
||||||
if (num > productSku.getSuit()) {
|
if (num > productSku.getSuit()) {
|
||||||
if (num > product.getStockNumber()) isSale = true;
|
if (num > product.getStockNumber()) isSale = true;
|
||||||
}else {
|
} else {
|
||||||
if (productSku.getSuit() > product.getStockNumber()) isSale = true;
|
if (productSku.getSuit() > product.getStockNumber()) isSale = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (num > productSku.getSuit()) {
|
if (num > productSku.getSuit()) {
|
||||||
if (num > productSku.getStockNumber()) isSale = true;
|
if (num > productSku.getStockNumber()) isSale = true;
|
||||||
}else {
|
} else {
|
||||||
if (productSku.getSuit() > productSku.getStockNumber()) isSale = true;
|
if (productSku.getSuit() > productSku.getStockNumber()) isSale = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -554,10 +641,10 @@ public class CartService {
|
|||||||
throw new MsgException("商品起售库存不足");
|
throw new MsgException("商品起售库存不足");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(num > productSku.getSuit()){
|
if (num > productSku.getSuit()) {
|
||||||
cashierCart.setNumber(num);
|
cashierCart.setNumber(num);
|
||||||
cashierCart.setTotalNumber(num);
|
cashierCart.setTotalNumber(num);
|
||||||
}else {
|
} else {
|
||||||
cashierCart.setNumber(productSku.getSuit());
|
cashierCart.setNumber(productSku.getSuit());
|
||||||
cashierCart.setTotalNumber(productSku.getSuit());
|
cashierCart.setTotalNumber(productSku.getSuit());
|
||||||
}
|
}
|
||||||
@@ -589,11 +676,11 @@ public class CartService {
|
|||||||
if (isTakeout && product.getPackFee() != null) {
|
if (isTakeout && product.getPackFee() != null) {
|
||||||
cashierCart.setPackFee(product.getPackFee().multiply(BigDecimal.valueOf(num)));
|
cashierCart.setPackFee(product.getPackFee().multiply(BigDecimal.valueOf(num)));
|
||||||
}
|
}
|
||||||
if(isVip==1){
|
if (isVip == 1) {
|
||||||
cashierCart.setIsVip(Byte.parseByte("1"));
|
cashierCart.setIsVip(Byte.parseByte("1"));
|
||||||
cashierCart.setTotalAmount(BigDecimal.ZERO);
|
cashierCart.setTotalAmount(BigDecimal.ZERO);
|
||||||
cashierCart.setSalePrice(BigDecimal.ZERO);
|
cashierCart.setSalePrice(BigDecimal.ZERO);
|
||||||
}else {
|
} else {
|
||||||
cashierCart.setIsVip((byte) 0);
|
cashierCart.setIsVip((byte) 0);
|
||||||
cashierCart.setTotalAmount(new BigDecimal(cashierCart.getTotalNumber()).multiply(productSku.getSalePrice().add(cashierCart.getPackFee())));
|
cashierCart.setTotalAmount(new BigDecimal(cashierCart.getTotalNumber()).multiply(productSku.getSalePrice().add(cashierCart.getPackFee())));
|
||||||
}
|
}
|
||||||
@@ -623,7 +710,7 @@ public class CartService {
|
|||||||
String tableId = jsonObject.getString("tableId");
|
String tableId = jsonObject.getString("tableId");
|
||||||
String userId = jsonObject.getString("userId");
|
String userId = jsonObject.getString("userId");
|
||||||
String sendType = jsonObject.getString("sendType");
|
String sendType = jsonObject.getString("sendType");
|
||||||
String remark = StringUtils.isBlank(jsonObject.getString("remark"))?"":jsonObject.getString("remark");
|
String remark = StringUtils.isBlank(jsonObject.getString("remark")) ? "" : jsonObject.getString("remark");
|
||||||
String tableCartKey = RedisCst.getTableCartKey(shopId, tableId, Integer.valueOf(userId));
|
String tableCartKey = RedisCst.getTableCartKey(shopId, tableId, Integer.valueOf(userId));
|
||||||
JSONArray array = JSON.parseArray(redisUtil.getMessage(tableCartKey));
|
JSONArray array = JSON.parseArray(redisUtil.getMessage(tableCartKey));
|
||||||
BigDecimal totalAmount = BigDecimal.ZERO;
|
BigDecimal totalAmount = BigDecimal.ZERO;
|
||||||
@@ -721,7 +808,7 @@ public class CartService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TbShopUser tbShopUser = shopUserMapper.selectByUserIdAndShopId(userId, shopId);
|
TbShopUser tbShopUser = shopUserMapper.selectByUserIdAndShopId(userId, shopId);
|
||||||
boolean isVip= tbShopUser != null && tbShopUser.getIsVip().equals((byte) 1);
|
boolean isVip = tbShopUser != null && tbShopUser.getIsVip().equals((byte) 1);
|
||||||
|
|
||||||
// 查询历史orderDetail
|
// 查询历史orderDetail
|
||||||
Integer finalOrderId = orderId;
|
Integer finalOrderId = orderId;
|
||||||
@@ -754,7 +841,7 @@ public class CartService {
|
|||||||
TbProduct product = productMapper.selectById(Integer.valueOf(cart.getProductId()));
|
TbProduct product = productMapper.selectById(Integer.valueOf(cart.getProductId()));
|
||||||
cart.setPackFee(product.getPackFee() != null ?
|
cart.setPackFee(product.getPackFee() != null ?
|
||||||
product.getPackFee().multiply(BigDecimal.valueOf(cart.getNumber())) : BigDecimal.ZERO);
|
product.getPackFee().multiply(BigDecimal.valueOf(cart.getNumber())) : BigDecimal.ZERO);
|
||||||
}else {
|
} else {
|
||||||
cart.setTableId(tableId);
|
cart.setTableId(tableId);
|
||||||
cart.setPackFee(BigDecimal.ZERO);
|
cart.setPackFee(BigDecimal.ZERO);
|
||||||
}
|
}
|
||||||
@@ -819,7 +906,7 @@ public class CartService {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
saleAmount = saleAmount.add(tbProduct.getSalePrice());
|
saleAmount = saleAmount.add(tbProduct.getSalePrice());
|
||||||
}else {
|
} else {
|
||||||
tbProduct = null;
|
tbProduct = null;
|
||||||
saleAmount = saleAmount.add(shopEatTypeInfoDTO.getShopInfo().getTableFee());
|
saleAmount = saleAmount.add(shopEatTypeInfoDTO.getShopInfo().getTableFee());
|
||||||
|
|
||||||
@@ -1012,7 +1099,7 @@ public class CartService {
|
|||||||
orderDetail.setOrderId(orderInfo.getId());
|
orderDetail.setOrderId(orderInfo.getId());
|
||||||
if (orderDetail.getId() != null) {
|
if (orderDetail.getId() != null) {
|
||||||
mpOrderDetailMapper.updateById(orderDetail);
|
mpOrderDetailMapper.updateById(orderDetail);
|
||||||
}else {
|
} else {
|
||||||
mpOrderDetailMapper.insert(orderDetail);
|
mpOrderDetailMapper.insert(orderDetail);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1049,7 +1136,7 @@ public class CartService {
|
|||||||
mpCashierCartMapper.updateById(cashierCart);
|
mpCashierCartMapper.updateById(cashierCart);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!CollectionUtils.isEmpty(outRecords)) outRecordMapper.insertBatch(outRecords);
|
if (!CollectionUtils.isEmpty(outRecords)) outRecordMapper.insertBatch(outRecords);
|
||||||
|
|
||||||
// 打印票据
|
// 打印票据
|
||||||
if (!addOrderDetail.isEmpty() && shopEatTypeInfoDTO.isDineInAfter()) {
|
if (!addOrderDetail.isEmpty() && shopEatTypeInfoDTO.isDineInAfter()) {
|
||||||
@@ -1155,12 +1242,12 @@ public class CartService {
|
|||||||
Integer userId = TokenUtil.getUserId();
|
Integer userId = TokenUtil.getUserId();
|
||||||
if (StrUtil.isNotBlank(tableId)) {
|
if (StrUtil.isNotBlank(tableId)) {
|
||||||
cashierCartMapper.updateStatusByOrderIdForMini(jsonObject.getString("tableId"), "closed");
|
cashierCartMapper.updateStatusByOrderIdForMini(jsonObject.getString("tableId"), "closed");
|
||||||
}else {
|
} else {
|
||||||
mpCashierCartMapper.update(null, new LambdaUpdateWrapper<TbCashierCart>()
|
mpCashierCartMapper.update(null, new LambdaUpdateWrapper<TbCashierCart>()
|
||||||
.eq(TbCashierCart::getShopId, shopId)
|
.eq(TbCashierCart::getShopId, shopId)
|
||||||
.and(q -> q.isNull(TbCashierCart::getTableId).or().eq(TbCashierCart::getTableId, ""))
|
.and(q -> q.isNull(TbCashierCart::getTableId).or().eq(TbCashierCart::getTableId, ""))
|
||||||
.eq(TbCashierCart::getUserId, userId)
|
.eq(TbCashierCart::getUserId, userId)
|
||||||
.ne(TbCashierCart::getProductId, "-999")
|
// .ne(TbCashierCart::getProductId, "-999")
|
||||||
.gt(TbCashierCart::getCreatedAt, DateUtil.offsetDay(DateUtil.date(), -1).getTime())
|
.gt(TbCashierCart::getCreatedAt, DateUtil.offsetDay(DateUtil.date(), -1).getTime())
|
||||||
.set(TbCashierCart::getStatus, "closed"));
|
.set(TbCashierCart::getStatus, "closed"));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -948,6 +948,9 @@ public class ProductService {
|
|||||||
jsonArray.add(tbCashierCart);
|
jsonArray.add(tbCashierCart);
|
||||||
redisUtil.saveMessage(tableCartKey, jsonArray.toJSONString());
|
redisUtil.saveMessage(tableCartKey, jsonArray.toJSONString());
|
||||||
|
|
||||||
|
// 保存就餐人数信息
|
||||||
|
redisUtil.saveMessage(RedisCst.getCurrentTableSeatCount(choseCountDTO.getShopId(), choseCountDTO.getTableId()),
|
||||||
|
JSONObject.toJSONString(tbCashierCart), 60L * 60 * 12);
|
||||||
return tbCashierCart;
|
return tbCashierCart;
|
||||||
}, stringRedisTemplate, RedisCst.getLockKey(RedisCst.CHOSE_TABLE_COUNT, choseCountDTO.getShopId(), choseCountDTO.getTableId()));
|
}, stringRedisTemplate, RedisCst.getLockKey(RedisCst.CHOSE_TABLE_COUNT, choseCountDTO.getShopId(), choseCountDTO.getTableId()));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user