|
|
|
|
@@ -187,14 +187,19 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|
|
|
|
boolean isMunchies = StrUtil.isNotBlank(shopInfo.getRegisterType()) &&
|
|
|
|
|
ShopInfoRegisterlEnum.MUNCHIES.getValue().equals(shopInfo.getRegisterType());
|
|
|
|
|
|
|
|
|
|
boolean isDineInAfter = !isMunchies && !isTakeout;
|
|
|
|
|
boolean isDineInBefore = isMunchies && !isTakeout;
|
|
|
|
|
boolean hasTable = StrUtil.isNotBlank(tableId);
|
|
|
|
|
// 是否先付费
|
|
|
|
|
boolean isDineInAfter = hasTable && !isMunchies && !isTakeout;
|
|
|
|
|
// 是否后付费
|
|
|
|
|
boolean isDineInBefore = hasTable && isMunchies && !isTakeout;
|
|
|
|
|
// 是否无台桌
|
|
|
|
|
boolean isNoneTable = !hasTable && !isTakeout;
|
|
|
|
|
|
|
|
|
|
boolean needSeatFee = shopInfo.getIsTableFee() == null || shopInfo.getIsTableFee() == 0;
|
|
|
|
|
boolean isNoneTable = StrUtil.isBlank(tableId) && !isTakeout;
|
|
|
|
|
boolean isIncrMasterId = isTakeout || isNoneTable;
|
|
|
|
|
|
|
|
|
|
return new ShopEatTypeInfoDTO(isTakeout, isMunchies, isDineInAfter, isDineInBefore, needSeatFee, isNoneTable, shopInfo, isTakeout ? OrderUseTypeEnum.TAKEOUT.getValue() :
|
|
|
|
|
isMunchies ? OrderUseTypeEnum.DINE_IN_BEFORE.getValue() : OrderUseTypeEnum.DINE_IN_AFTER.getValue(),
|
|
|
|
|
return new ShopEatTypeInfoDTO(isTakeout, isMunchies, isDineInAfter, isDineInBefore, needSeatFee, isNoneTable, isIncrMasterId, shopInfo, isTakeout ? TableConstant.OrderInfo.UseType.TAKEOUT.getValue() :
|
|
|
|
|
isDineInBefore ? TableConstant.OrderInfo.UseType.DINE_IN_BEFORE.getValue() : isNoneTable ? TableConstant.OrderInfo.UseType.NONE_TABLE.getValue() : TableConstant.OrderInfo.UseType.DINE_IN_AFTER.getValue(),
|
|
|
|
|
shopId, tableId, isTakeout ? OrderSendTypeEnums.TAKE_SELF.getValue() : OrderSendTypeEnums.TABLE.getValue());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -494,7 +499,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|
|
|
|
// 首次加入
|
|
|
|
|
if (tbCashierCart == null) {
|
|
|
|
|
tbCashierCart = new TbCashierCart();
|
|
|
|
|
tbCashierCart.setUseType(addCartDTO.getUseType());
|
|
|
|
|
tbCashierCart.setUseType(shopEatTypeInfoDTO.getUseType());
|
|
|
|
|
tbCashierCart.setCoverImg(product.getCoverImg());
|
|
|
|
|
tbCashierCart.setCreatedAt(System.currentTimeMillis());
|
|
|
|
|
tbCashierCart.setIsSku(product.getTypeEnum());
|
|
|
|
|
@@ -735,30 +740,21 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void clearCart(ClearCartDTO clearCartDTO) {
|
|
|
|
|
Integer orderId;
|
|
|
|
|
ShopEatTypeInfoDTO shopEatTypeInfoDTO = checkEatModel(clearCartDTO.getShopId(), clearCartDTO.getTableId());
|
|
|
|
|
if (clearCartDTO.getTableId() != null) {
|
|
|
|
|
orderId = getCurrentOrderId(shopEatTypeInfoDTO);
|
|
|
|
|
} else {
|
|
|
|
|
orderId = null;
|
|
|
|
|
}
|
|
|
|
|
ShopEatTypeInfoDTO shopEatTypeInfoDTO = checkEatModel(clearCartDTO.getShopId(), clearCartDTO.getTableId(), clearCartDTO.getUseType());
|
|
|
|
|
|
|
|
|
|
LambdaQueryWrapper<TbCashierCart> query = new LambdaQueryWrapper<TbCashierCart>()
|
|
|
|
|
.eq(TbCashierCart::getShopId, clearCartDTO.getShopId())
|
|
|
|
|
.isNull(TbCashierCart::getPlaceNum)
|
|
|
|
|
.eq(TbCashierCart::getUseType, clearCartDTO.getUseType())
|
|
|
|
|
.eq(TbCashierCart::getUseType, shopEatTypeInfoDTO.getUseType())
|
|
|
|
|
.and(q -> q.eq(TbCashierCart::getMasterId, clearCartDTO.getMasterId())
|
|
|
|
|
.or()
|
|
|
|
|
.isNull(TbCashierCart::getMasterId)
|
|
|
|
|
.or()
|
|
|
|
|
.eq(TbCashierCart::getMasterId, ""))
|
|
|
|
|
.and(q -> q.eq(TbCashierCart::getOrderId, orderId)
|
|
|
|
|
.or()
|
|
|
|
|
.isNull(TbCashierCart::getOrderId));
|
|
|
|
|
.isNull(TbCashierCart::getOrderId);
|
|
|
|
|
|
|
|
|
|
if (clearCartDTO.getTableId() != null) {
|
|
|
|
|
if (StrUtil.isNotBlank(clearCartDTO.getTableId())) {
|
|
|
|
|
query.eq(TbCashierCart::getTableId, clearCartDTO.getTableId());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cashierCartMapper.delete(query);
|
|
|
|
|
@@ -779,7 +775,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|
|
|
|
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
|
|
|
|
|
.in(TbCashierCart::getStatus, "create", "return")
|
|
|
|
|
.eq(TbCashierCart::getShopId, shopId)
|
|
|
|
|
.eq(TbCashierCart::getUseType, useType)
|
|
|
|
|
.eq(TbCashierCart::getUseType, shopEatTypeInfoDTO.getUseType())
|
|
|
|
|
.gt(TbCashierCart::getCreatedAt, DateUtil.offsetDay(DateUtil.date(), -1).getTime())
|
|
|
|
|
.and(q -> q.eq(TbCashierCart::getMasterId, masterId).or().isNull(TbCashierCart::getMasterId));
|
|
|
|
|
|
|
|
|
|
@@ -1063,11 +1059,10 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|
|
|
|
if (account == null) {
|
|
|
|
|
throw new BadRequestException("token解析失败");
|
|
|
|
|
}
|
|
|
|
|
TbMerchantAccount merchantAccount = merchantAccountMapper.selectOne(new LambdaQueryWrapper<TbMerchantAccount>().eq(TbMerchantAccount::getAccount, account));
|
|
|
|
|
String day = DateUtils.getDay();
|
|
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
|
|
// 当前台桌码
|
|
|
|
|
String key = "SHOP:CODE:USER:pc" + ":" + shopId + ":" + day + ":" + tableId + useType;
|
|
|
|
|
String key = RedisConstant.getMasterIdKey(shopId, day, tableId);
|
|
|
|
|
String userCode = redisTemplate.opsForValue().get(key);
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(userCode) || "null".equals(userCode) || "#null".equals(userCode)) {
|
|
|
|
|
@@ -1112,7 +1107,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|
|
|
|
|
|
|
|
|
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
|
|
|
|
|
.eq(TbCashierCart::getShopId, createOrderDTO.getShopId())
|
|
|
|
|
.eq(TbCashierCart::getUseType, createOrderDTO.getUseType())
|
|
|
|
|
.eq(TbCashierCart::getUseType, shopEatTypeInfoDTO.getUseType())
|
|
|
|
|
.in(TbCashierCart::getStatus, "create", "return")
|
|
|
|
|
.gt(TbCashierCart::getCreatedAt, DateUtil.offsetDay(DateUtil.date(), -1).getTime())
|
|
|
|
|
.and(q -> q.eq(TbCashierCart::getMasterId, createOrderDTO.getMasterId()).or().isNull(TbCashierCart::getMasterId));
|
|
|
|
|
@@ -1235,7 +1230,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|
|
|
|
orderDetail.setShopId(Integer.valueOf(cashierCart.getShopId()));
|
|
|
|
|
orderDetail.setPackAmount(cashierCart.getPackFee());
|
|
|
|
|
orderDetail.setStatus("unpaid");
|
|
|
|
|
orderDetail.setUseType(createOrderDTO.getUseType());
|
|
|
|
|
orderDetail.setUseType(shopEatTypeInfoDTO.getUseType());
|
|
|
|
|
orderDetail.setProductImg(cashierCart.getCoverImg());
|
|
|
|
|
orderDetail.setCartId(cashierCart.getId());
|
|
|
|
|
if (cashierCart.getOrderId() != null) {
|
|
|
|
|
@@ -1267,7 +1262,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|
|
|
|
orderInfo.setFreightAmount(feeAmount);
|
|
|
|
|
orderInfo.setProductAmount(saleAmount);
|
|
|
|
|
orderInfo.setTradeDay(DateUtils.getDay());
|
|
|
|
|
orderInfo.setUseType(createOrderDTO.getUseType());
|
|
|
|
|
orderInfo.setUseType(shopEatTypeInfoDTO.getUseType());
|
|
|
|
|
orderInfo.setCreatedAt(DateUtil.current());
|
|
|
|
|
if (seatCart != null) {
|
|
|
|
|
orderInfo.setSeatAmount(seatCart.getTotalAmount());
|
|
|
|
|
@@ -1307,7 +1302,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|
|
|
|
orderInfo.setCreatedAt(DateUtil.current());
|
|
|
|
|
orderInfo.setTableName(tbShopTable != null ? tbShopTable.getName() : null);
|
|
|
|
|
orderInfo.setPlaceNum(placeNum);
|
|
|
|
|
orderInfo.setUseType(createOrderDTO.getUseType());
|
|
|
|
|
orderInfo.setUseType(shopEatTypeInfoDTO.getUseType());
|
|
|
|
|
if (StrUtil.isNotBlank(createOrderDTO.getVipUserId())) {
|
|
|
|
|
orderInfo.setUserId(createOrderDTO.getVipUserId());
|
|
|
|
|
}
|
|
|
|
|
@@ -1359,7 +1354,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 先付费模式,结束购物车状态
|
|
|
|
|
if (shopEatTypeInfoDTO.isDineInBefore() || shopEatTypeInfoDTO.isTakeout() || StrUtil.isBlank(createOrderDTO.getTableId())) {
|
|
|
|
|
if (!shopEatTypeInfoDTO.isDineInAfter() || StrUtil.isBlank(createOrderDTO.getTableId())) {
|
|
|
|
|
cashierCart.setStatus("final");
|
|
|
|
|
}
|
|
|
|
|
cashierCartMapper.updateById(cashierCart);
|
|
|
|
|
@@ -1380,12 +1375,12 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|
|
|
|
|
|
|
|
|
if (isFirst) {
|
|
|
|
|
// 后付费,不增加当前台桌取餐号
|
|
|
|
|
if (!shopEatTypeInfoDTO.isTakeout()) {
|
|
|
|
|
if (!shopEatTypeInfoDTO.isIncrMaterId()) {
|
|
|
|
|
addGlobalCode(cn.ysk.cashier.utils.DateUtils.getDay(), "pc", String.valueOf(createOrderDTO.getShopId()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!shopEatTypeInfoDTO.isTakeout() || (addMaterId && "pending".equals(orderInfo.getStatus()))) {
|
|
|
|
|
String key = "SHOP:CODE:USER:pc" + ":" + createOrderDTO.getShopId() + ":" + cn.ysk.cashier.utils.DateUtils.getDay() + ":" + orderInfo.getTableId();
|
|
|
|
|
if (shopEatTypeInfoDTO.isIncrMaterId() && "pending".equals(orderInfo.getStatus())) {
|
|
|
|
|
String key = RedisConstant.getMasterIdKey(createOrderDTO.getShopId(), cn.ysk.cashier.utils.DateUtils.getDay(), orderInfo.getTableId());;
|
|
|
|
|
redisTemplate.delete(key);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|