1.代客下单 挂起订单

This commit is contained in:
2024-08-17 10:03:11 +08:00
parent 7c122565fc
commit e938911e4a
5 changed files with 46 additions and 6 deletions

View File

@@ -41,6 +41,7 @@ import cn.ysk.cashier.repository.product.TbProductRepository;
import cn.ysk.cashier.repository.product.TbProductSkuRepository;
import cn.ysk.cashier.repository.shop.TbShopInfoRepository;
import cn.ysk.cashier.utils.*;
import cn.ysk.cashier.vo.PendingCountVO;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
@@ -395,7 +396,8 @@ public class TbShopTableServiceImpl implements TbShopTableService {
}
@Override
public com.baomidou.mybatisplus.extension.plugins.pagination.Page<TbCashierCart> getCart(Long tableId, Integer page, Integer size, Integer shopId, Integer vipUserId) {
public com.baomidou.mybatisplus.extension.plugins.pagination.Page<TbCashierCart> getCart(Long tableId, Integer page,
Integer size, Integer shopId, Integer vipUserId, String masterId) {
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
.eq(TbCashierCart::getTableId, tableId)
.eq(TbCashierCart::getStatus, "create")
@@ -404,6 +406,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
if (vipUserId != null) {
queryWrapper.eq(TbCashierCart::getUserId, vipUserId);
}else {
queryWrapper.eq(TbCashierCart::getMasterId, masterId);
queryWrapper.isNull(TbCashierCart::getUserId);
}
@@ -643,7 +646,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
} else {
orderCode = String.valueOf(Integer.parseInt(code.replace("#", "")) + 1);
}
redisTemplate.opsForValue().set("SHOP:CODE:" + clientType + ":" + shopId + ":" + day, "#" + Integer.parseInt(code.replace("#", "")) + 2);
redisTemplate.opsForValue().set("SHOP:CODE:" + clientType + ":" + shopId + ":" + day, String.valueOf(Integer.parseInt(orderCode) + 1));
boolean flag = Boolean.TRUE.equals(redisTemplate.opsForValue().setIfAbsent("SHOP:CODE:SET" + clientType + ":" + shopId + ":" + day, orderCode));
if (flag) {
return generateOrderCode(day, clientType, shopId);
@@ -872,7 +875,24 @@ public class TbShopTableServiceImpl implements TbShopTableService {
@Override
public Object getCar(Integer shopId) {
return cashierCartMapper.selectCar(shopId);
ArrayList<HashMap<String, Object>> data = new ArrayList<>();
List<PendingCountVO> pendingCountVOS = cashierCartMapper.countPending(shopId);
List<TbCashierCart> tbCashierCarts = cashierCartMapper.selectList(new LambdaQueryWrapper<TbCashierCart>()
.eq(TbCashierCart::getShopId, shopId)
.eq(TbCashierCart::getStatus, "refund"));
HashMap<String, List<TbCashierCart>> cashierMap = new HashMap<>();
for (TbCashierCart tbCashierCart : tbCashierCarts) {
List<TbCashierCart> list = cashierMap.computeIfAbsent(tbCashierCart.getOrderId().toString(), k -> new ArrayList<>());
list.add(tbCashierCart);
}
pendingCountVOS.forEach(item -> {
Map<String, Object> map = BeanUtil.beanToMap(item, false, false);
map.put("carList", cashierMap.get(item.getOrderId().toString()));
});
return data;
}
@Override

View File

@@ -102,7 +102,7 @@ public interface TbShopTableService {
void clearCart(ClearCartDTO clearCartDTO);
Page<TbCashierCart> getCart(Long tableId, Integer page, Integer size, Integer shopId, Integer vipUserId);
Page<TbCashierCart> getCart(Long tableId, Integer page, Integer size, Integer shopId, Integer vipUserId, String masterId);
TbCashierCart updateCart(UpdateCartDTO updateCartDTO);