1.代客下单 挂单不增加masterId
This commit is contained in:
@@ -290,7 +290,8 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||||||
if (shopTable == null) {
|
if (shopTable == null) {
|
||||||
throw new BadRequestException("桌码不存在,桌码" + tableId);
|
throw new BadRequestException("桌码不存在,桌码" + tableId);
|
||||||
}
|
}
|
||||||
if (!shopTable.getStatus().equals("opening") && !shopTable.getStatus().equals("idle")) {
|
if (!shopTable.getStatus().equals("using") && !shopTable.getStatus().equals("idle")
|
||||||
|
&& !shopTable.getStatus().equals("pending")) {
|
||||||
throw new BadRequestException("当前台桌非开台状态");
|
throw new BadRequestException("当前台桌非开台状态");
|
||||||
}
|
}
|
||||||
return shopTable;
|
return shopTable;
|
||||||
@@ -663,6 +664,16 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||||||
return "DDPL" + date + randomNum;
|
return "DDPL" + date + randomNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public synchronized void addGlobalCode(String day, String clientType, String shopId) {
|
||||||
|
String code = redisTemplate.opsForValue().get("SHOP:CODE:" + clientType + ":" + shopId + ":" + day);
|
||||||
|
if (StrUtil.isBlank(code)) {
|
||||||
|
redisTemplate.opsForValue().set("SHOP:CODE:" + clientType + ":" + shopId + ":" + day, "1");
|
||||||
|
}else {
|
||||||
|
redisTemplate.opsForValue().get("SHOP:CODE:" + clientType + ":" + shopId + ":" + (Integer.parseInt(code) + 1));
|
||||||
|
}
|
||||||
|
redisTemplate.opsForValue().setIfAbsent("SHOP:CODE:SET" + clientType + ":" + shopId + ":" + day, "1");
|
||||||
|
}
|
||||||
|
|
||||||
public synchronized String generateOrderCode(String day, String clientType, String shopId) {
|
public synchronized String generateOrderCode(String day, String clientType, String shopId) {
|
||||||
String code = redisTemplate.opsForValue().get("SHOP:CODE:" + clientType + ":" + shopId + ":" + day);
|
String code = redisTemplate.opsForValue().get("SHOP:CODE:" + clientType + ":" + shopId + ":" + day);
|
||||||
// 使用顺序递增的计数器生成取餐码
|
// 使用顺序递增的计数器生成取餐码
|
||||||
@@ -695,7 +706,8 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||||||
TbMerchantAccount merchantAccount = merchantAccountMapper.selectOne(new LambdaQueryWrapper<TbMerchantAccount>().eq(TbMerchantAccount::getAccount, account));
|
TbMerchantAccount merchantAccount = merchantAccountMapper.selectOne(new LambdaQueryWrapper<TbMerchantAccount>().eq(TbMerchantAccount::getAccount, account));
|
||||||
String day = DateUtils.getDay();
|
String day = DateUtils.getDay();
|
||||||
JSONObject jsonObject = new JSONObject();
|
JSONObject jsonObject = new JSONObject();
|
||||||
String key = "SHOP:CODE:USER:pc" + ":" + shopId + ":" + day + ":" + shopId;
|
// 当前台桌码
|
||||||
|
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)) {
|
||||||
@@ -839,7 +851,9 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||||||
cashierCart.setUpdatedAt(System.currentTimeMillis());
|
cashierCart.setUpdatedAt(System.currentTimeMillis());
|
||||||
cashierCartMapper.updateById(cashierCart);
|
cashierCartMapper.updateById(cashierCart);
|
||||||
}
|
}
|
||||||
|
if (isFirst) {
|
||||||
|
addGlobalCode(day, "pc", String.valueOf(createOrderDTO.getShopId()));
|
||||||
|
}
|
||||||
|
|
||||||
// 推送耗材信息
|
// 推送耗材信息
|
||||||
pushConsMsg(orderInfo, cashierCarts);
|
pushConsMsg(orderInfo, cashierCarts);
|
||||||
@@ -1008,18 +1022,11 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||||||
orderInfo.setPayType("cash");
|
orderInfo.setPayType("cash");
|
||||||
orderInfo.setStatus("closed");
|
orderInfo.setStatus("closed");
|
||||||
orderInfo.setPayOrderNo("cash".concat(SnowFlakeUtil.generateOrderNo()));
|
orderInfo.setPayOrderNo("cash".concat(SnowFlakeUtil.generateOrderNo()));
|
||||||
String masterId = getMasterId(Integer.valueOf(orderInfo.getShopId()), Long.valueOf(orderInfo.getTableId()), null).toString();
|
|
||||||
orderInfo.setMasterId(masterId);
|
|
||||||
orderInfoMapper.updateById(orderInfo);
|
orderInfoMapper.updateById(orderInfo);
|
||||||
String day = DateUtils.getDay();
|
|
||||||
String key = "SHOP:CODE:USER:pc" + ":" + payDTO.getShopId() + ":" + day + ":" + orderInfo.getTableId();
|
|
||||||
|
|
||||||
redisTemplate.delete(key);
|
|
||||||
|
|
||||||
//更新购物车状态
|
//更新购物车状态
|
||||||
TbCashierCart cashierCart = new TbCashierCart();
|
TbCashierCart cashierCart = new TbCashierCart();
|
||||||
cashierCart.setStatus("final");
|
cashierCart.setStatus("final");
|
||||||
cashierCart.setMasterId(masterId);
|
|
||||||
int cartCount = cashierCartMapper.update(cashierCart, new LambdaUpdateWrapper<TbCashierCart>()
|
int cartCount = cashierCartMapper.update(cashierCart, new LambdaUpdateWrapper<TbCashierCart>()
|
||||||
.eq(TbCashierCart::getOrderId, payDTO.getOrderId()));
|
.eq(TbCashierCart::getOrderId, payDTO.getOrderId()));
|
||||||
|
|
||||||
@@ -1051,6 +1058,9 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||||||
.eq(TbShopTable::getQrcode, orderInfo.getTableId())
|
.eq(TbShopTable::getQrcode, orderInfo.getTableId())
|
||||||
.set(TbShopTable::getStatus, TableStateEnum.IDLE.getState()));
|
.set(TbShopTable::getStatus, TableStateEnum.IDLE.getState()));
|
||||||
|
|
||||||
|
String day = DateUtils.getDay();
|
||||||
|
String key = "SHOP:CODE:USER:pc" + ":" + payDTO.getShopId() + ":" + day + ":" + orderInfo.getTableId();
|
||||||
|
redisTemplate.delete(key);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user