1.代客下单 取单sql fix
This commit is contained in:
@@ -284,6 +284,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 台桌状态校验
|
* 台桌状态校验
|
||||||
|
*
|
||||||
* @param tableId 桌码
|
* @param tableId 桌码
|
||||||
* @return z
|
* @return z
|
||||||
*/
|
*/
|
||||||
@@ -323,15 +324,13 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||||||
.eq(TbCashierCart::getTableId, addCartDTO.getTableId())
|
.eq(TbCashierCart::getTableId, addCartDTO.getTableId())
|
||||||
.and(query2 -> {
|
.and(query2 -> {
|
||||||
query2.and(query3 -> {
|
query2.and(query3 -> {
|
||||||
query3.eq(TbCashierCart::getTradeDay, DateUtils.getDay())
|
query3.eq(TbCashierCart::getTradeDay, DateUtils.getDay())
|
||||||
.eq(TbCashierCart::getMasterId, addCartDTO.getMasterId());
|
.eq(TbCashierCart::getMasterId, addCartDTO.getMasterId());
|
||||||
})
|
})
|
||||||
.or()
|
.or((query4 -> {
|
||||||
.and(query4 -> {
|
|
||||||
query4.isNull(TbCashierCart::getTradeDay)
|
query4.isNull(TbCashierCart::getTradeDay)
|
||||||
.eq(TbCashierCart::getMasterId, "");
|
.eq(TbCashierCart::getMasterId, "");
|
||||||
})
|
}));
|
||||||
;
|
|
||||||
});
|
});
|
||||||
TbCashierCart tbCashierCart = cashierCartMapper.selectOne(query);
|
TbCashierCart tbCashierCart = cashierCartMapper.selectOne(query);
|
||||||
// 首次加入
|
// 首次加入
|
||||||
@@ -441,16 +440,14 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||||||
.in(TbCashierCart::getStatus, "create")
|
.in(TbCashierCart::getStatus, "create")
|
||||||
.eq(TbCashierCart::getShopId, shopId)
|
.eq(TbCashierCart::getShopId, shopId)
|
||||||
.and(query2 -> {
|
.and(query2 -> {
|
||||||
query2.and(query3 -> {
|
query2.or(query3 -> {
|
||||||
query3.eq(TbCashierCart::getTradeDay, DateUtils.getDay())
|
query3.eq(TbCashierCart::getTradeDay, DateUtils.getDay())
|
||||||
.eq(TbCashierCart::getMasterId, masterId);
|
.eq(TbCashierCart::getMasterId, masterId);
|
||||||
})
|
})
|
||||||
.or()
|
.or((query4 -> {
|
||||||
.and(query4 -> {
|
|
||||||
query4.isNull(TbCashierCart::getTradeDay)
|
query4.isNull(TbCashierCart::getTradeDay)
|
||||||
.eq(TbCashierCart::getMasterId, "");
|
.eq(TbCashierCart::getMasterId, "");
|
||||||
})
|
}));
|
||||||
;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// if (vipUserId != null) {
|
// if (vipUserId != null) {
|
||||||
@@ -523,24 +520,26 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 增加库存
|
* 增加库存
|
||||||
|
*
|
||||||
* @param productId 商品id
|
* @param productId 商品id
|
||||||
* @param skuId sku
|
* @param skuId sku
|
||||||
* @param addNum 增加的库存数量
|
* @param addNum 增加的库存数量
|
||||||
*/
|
*/
|
||||||
public void incrStock(Integer productId, Integer skuId, Integer addNum) {
|
public void incrStock(Integer productId, Integer skuId, Integer addNum) {
|
||||||
TbProduct product = productMapper.selectById(productId);
|
TbProduct product = productMapper.selectById(productId);
|
||||||
if (product.getIsDistribute() == 1) {
|
if (product.getIsDistribute() == 1) {
|
||||||
productMapper.incrStock(product.getId(), addNum);
|
productMapper.incrStock(product.getId(), addNum);
|
||||||
}else {
|
} else {
|
||||||
producSkutMapper.incrStock(skuId, addNum);
|
producSkutMapper.incrStock(skuId, addNum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 减少库存
|
* 减少库存
|
||||||
|
*
|
||||||
* @param productId 商品数据
|
* @param productId 商品数据
|
||||||
* @param skuId sku
|
* @param skuId sku
|
||||||
* @param decrNum 减少的数量
|
* @param decrNum 减少的数量
|
||||||
*/
|
*/
|
||||||
public void decrStock(Integer productId, String skuId, int decrNum) {
|
public void decrStock(Integer productId, String skuId, int decrNum) {
|
||||||
TbProduct product = productMapper.selectById(productId);
|
TbProduct product = productMapper.selectById(productId);
|
||||||
@@ -549,15 +548,15 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||||||
if (productMapper.decrStock(productId, decrNum) < 1) {
|
if (productMapper.decrStock(productId, decrNum) < 1) {
|
||||||
throw new BadRequestException("库存不足,下单失败");
|
throw new BadRequestException("库存不足,下单失败");
|
||||||
}
|
}
|
||||||
}else {
|
} else {
|
||||||
productMapper.decrStockUnCheck(productId, decrNum);
|
productMapper.decrStockUnCheck(productId, decrNum);
|
||||||
}
|
}
|
||||||
}else {
|
} else {
|
||||||
if (product.getIsStock() == 1) {
|
if (product.getIsStock() == 1) {
|
||||||
if (producSkutMapper.decrStock(String.valueOf(skuId), decrNum) < 1) {
|
if (producSkutMapper.decrStock(String.valueOf(skuId), decrNum) < 1) {
|
||||||
throw new BadRequestException("库存不足,下单失败");
|
throw new BadRequestException("库存不足,下单失败");
|
||||||
}
|
}
|
||||||
}else {
|
} else {
|
||||||
producSkutMapper.decrStockUnCheck(String.valueOf(skuId), decrNum);
|
producSkutMapper.decrStockUnCheck(String.valueOf(skuId), decrNum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -589,6 +588,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新库存
|
* 更新库存
|
||||||
|
*
|
||||||
* @param cashierCart 购物车
|
* @param cashierCart 购物车
|
||||||
* @return 是否是第一次添加的商品
|
* @return 是否是第一次添加的商品
|
||||||
*/
|
*/
|
||||||
@@ -618,6 +618,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新取餐号
|
* 更新取餐号
|
||||||
|
*
|
||||||
* @param shopId 店铺id
|
* @param shopId 店铺id
|
||||||
* @return 当前取餐号
|
* @return 当前取餐号
|
||||||
*/
|
*/
|
||||||
@@ -679,7 +680,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||||||
);
|
);
|
||||||
|
|
||||||
wxMsgUtils.aboardStockMsg(shopInfo.getShopName(), shopId, product.getName(),
|
wxMsgUtils.aboardStockMsg(shopInfo.getShopName(), shopId, product.getName(),
|
||||||
product.getIsDistribute() == 1 ? product.getStockNumber()-num : (int) (productSku.getStockNumber() - num));
|
product.getIsDistribute() == 1 ? product.getStockNumber() - num : (int) (productSku.getStockNumber() - num));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -694,7 +695,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||||||
String code = redisTemplate.opsForValue().get("SHOP:CODE:" + clientType + ":" + shopId + ":" + day);
|
String code = redisTemplate.opsForValue().get("SHOP:CODE:" + clientType + ":" + shopId + ":" + day);
|
||||||
if (StrUtil.isBlank(code)) {
|
if (StrUtil.isBlank(code)) {
|
||||||
redisTemplate.opsForValue().set("SHOP:CODE:" + clientType + ":" + shopId + ":" + day, "1");
|
redisTemplate.opsForValue().set("SHOP:CODE:" + clientType + ":" + shopId + ":" + day, "1");
|
||||||
}else {
|
} else {
|
||||||
redisTemplate.opsForValue().get("SHOP:CODE:" + clientType + ":" + shopId + ":" + (Integer.parseInt(code) + 1));
|
redisTemplate.opsForValue().get("SHOP:CODE:" + clientType + ":" + shopId + ":" + (Integer.parseInt(code) + 1));
|
||||||
}
|
}
|
||||||
redisTemplate.opsForValue().setIfAbsent("SHOP:CODE:SET" + clientType + ":" + shopId + ":" + day, "1");
|
redisTemplate.opsForValue().setIfAbsent("SHOP:CODE:SET" + clientType + ":" + shopId + ":" + day, "1");
|
||||||
@@ -734,7 +735,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||||||
JSONObject jsonObject = new JSONObject();
|
JSONObject jsonObject = new JSONObject();
|
||||||
// 当前台桌码
|
// 当前台桌码
|
||||||
String key = "SHOP:CODE:USER:pc" + ":" + shopId + ":" + day + ":" + tableId;
|
String key = "SHOP:CODE:USER:pc" + ":" + shopId + ":" + day + ":" + tableId;
|
||||||
String userCode = redisTemplate.opsForValue().get(key);
|
String userCode = redisTemplate.opsForValue().get(key);
|
||||||
|
|
||||||
if (StringUtils.isEmpty(userCode) || "null".equals(userCode) || "#null".equals(userCode)) {
|
if (StringUtils.isEmpty(userCode) || "null".equals(userCode) || "#null".equals(userCode)) {
|
||||||
String code = "#" + generateOrderCode(day, "pc", String.valueOf(shopId));
|
String code = "#" + generateOrderCode(day, "pc", String.valueOf(shopId));
|
||||||
@@ -830,7 +831,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||||||
orderInfo.setTradeDay(DateUtils.getDay());
|
orderInfo.setTradeDay(DateUtils.getDay());
|
||||||
orderInfo.setUserId(String.valueOf(createOrderDTO.getVipUserId()));
|
orderInfo.setUserId(String.valueOf(createOrderDTO.getVipUserId()));
|
||||||
orderInfoMapper.updateById(orderInfo);
|
orderInfoMapper.updateById(orderInfo);
|
||||||
}else {
|
} else {
|
||||||
String orderNo = generateOrderNumber();
|
String orderNo = generateOrderNumber();
|
||||||
orderInfo = new TbOrderInfo();
|
orderInfo = new TbOrderInfo();
|
||||||
orderInfo.setOrderNo(orderNo);
|
orderInfo.setOrderNo(orderNo);
|
||||||
@@ -890,7 +891,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||||||
// 后付费,不增加当前台桌取餐号
|
// 后付费,不增加当前台桌取餐号
|
||||||
if (createOrderDTO.isPostPay()) {
|
if (createOrderDTO.isPostPay()) {
|
||||||
addGlobalCode(day, "pc", String.valueOf(createOrderDTO.getShopId()));
|
addGlobalCode(day, "pc", String.valueOf(createOrderDTO.getShopId()));
|
||||||
}else {
|
} else {
|
||||||
String key = "SHOP:CODE:USER:pc" + ":" + createOrderDTO.getShopId() + ":" + day + ":" + orderInfo.getTableId();
|
String key = "SHOP:CODE:USER:pc" + ":" + createOrderDTO.getShopId() + ":" + day + ":" + orderInfo.getTableId();
|
||||||
redisTemplate.delete(key);
|
redisTemplate.delete(key);
|
||||||
}
|
}
|
||||||
@@ -911,8 +912,6 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object pending(PendingDTO pendingDTO) {
|
public Object pending(PendingDTO pendingDTO) {
|
||||||
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
|
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
|
||||||
@@ -924,7 +923,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||||||
}
|
}
|
||||||
queryWrapper.eq(TbCashierCart::getOrderId, pendingDTO.getOrderId());
|
queryWrapper.eq(TbCashierCart::getOrderId, pendingDTO.getOrderId());
|
||||||
|
|
||||||
}else {
|
} else {
|
||||||
queryWrapper.eq(TbCashierCart::getTableId, pendingDTO.getTableId())
|
queryWrapper.eq(TbCashierCart::getTableId, pendingDTO.getTableId())
|
||||||
.eq(TbCashierCart::getStatus, "create")
|
.eq(TbCashierCart::getStatus, "create")
|
||||||
.eq(TbCashierCart::getTableId, pendingDTO.getTableId())
|
.eq(TbCashierCart::getTableId, pendingDTO.getTableId())
|
||||||
@@ -1110,7 +1109,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||||||
if (updateVipDTO.getType().equals(0)) {
|
if (updateVipDTO.getType().equals(0)) {
|
||||||
queryWrapper.set(TbCashierCart::getUserId, null);
|
queryWrapper.set(TbCashierCart::getUserId, null);
|
||||||
queryWrapper.eq(TbCashierCart::getUserId, updateVipDTO.getVipUserId());
|
queryWrapper.eq(TbCashierCart::getUserId, updateVipDTO.getVipUserId());
|
||||||
}else {
|
} else {
|
||||||
queryWrapper.set(TbCashierCart::getUserId, updateVipDTO.getVipUserId());
|
queryWrapper.set(TbCashierCart::getUserId, updateVipDTO.getVipUserId());
|
||||||
}
|
}
|
||||||
return cashierCartMapper.update(null, queryWrapper);
|
return cashierCartMapper.update(null, queryWrapper);
|
||||||
|
|||||||
Reference in New Issue
Block a user