feat: 1.餐位费允许增减数量 2.选择人数根据店铺配置决定是否操作
This commit is contained in:
@@ -62,6 +62,8 @@ public interface TableConstant {
|
||||
}
|
||||
|
||||
class CashierCart {
|
||||
public static final String ID = "-999";
|
||||
|
||||
@Getter
|
||||
public enum Status {
|
||||
REFUNDING("refunding"), REFUND("refund"), CLOSED("closed"), CREATE("create"),
|
||||
|
||||
@@ -213,6 +213,9 @@ public class OrderController {
|
||||
*/
|
||||
@PutMapping("/choseCount")
|
||||
public Result choseCount(@Validated @RequestBody ChoseCountDTO choseCountDTO) {
|
||||
if (choseCountDTO.getNum() == null) {
|
||||
return Result.success(CodeEnum.SUCCESS);
|
||||
}
|
||||
return Result.success(CodeEnum.SUCCESS, orderService.choseCount(choseCountDTO));
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@ public class ChoseCountDTO {
|
||||
private Integer shopId;
|
||||
@NotEmpty
|
||||
private String tableId;
|
||||
@NotNull
|
||||
@Min(1)
|
||||
private Integer num;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ public class ShopEatTypeInfoDTO {
|
||||
private boolean isMunchies;
|
||||
private boolean isDineInAfter;
|
||||
private boolean isDineInBefore;
|
||||
private boolean needSeatFee;
|
||||
private TbShopInfo shopInfo;
|
||||
private String useType;
|
||||
private String sendType;
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.chaozhanggui.system.cashierservice.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.chaozhanggui.system.cashierservice.bean.constant.TableConstant;
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbCashierCart;
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbShopTable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* (TbShopPermission)表服务接口
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2024-09-14 17:08:48
|
||||
*/
|
||||
public interface MpShopTableService extends IService<TbShopTable> {
|
||||
|
||||
}
|
||||
|
||||
@@ -96,6 +96,7 @@ public class OrderService {
|
||||
private final TbShopOpenIdMapper shopOpenIdMapper;
|
||||
private final MpShopTableMapper mpShopTableMapper;
|
||||
private final MpOrderInfoService mpOrderInfoService;
|
||||
private final MpShopTableService mpShopTableService;
|
||||
|
||||
@Autowired
|
||||
TbConsInfoMapper tbConsInfoMapper;
|
||||
@@ -132,13 +133,14 @@ public class OrderService {
|
||||
|
||||
|
||||
public OrderService(WxAccountUtil wxAccountUtil, MPCashierCartMapper mpCashierCartMapper,
|
||||
TbShopOpenIdMapper shopOpenIdMapper, MpShopTableMapper mpShopTableMapper, MpOrderInfoService mpOrderInfoService,
|
||||
TbShopOpenIdMapper shopOpenIdMapper, MpShopTableMapper mpShopTableMapper, MpOrderInfoService mpOrderInfoService, MpShopTableService mpShopTableService,
|
||||
TbCashierCartMapper tbCashierCartMapper, MpCashierCartService mpCashierCartService) {
|
||||
this.wxAccountUtil = wxAccountUtil;
|
||||
this.mpCashierCartMapper = mpCashierCartMapper;
|
||||
this.shopOpenIdMapper = shopOpenIdMapper;
|
||||
this.mpShopTableMapper = mpShopTableMapper;
|
||||
this.mpOrderInfoService = mpOrderInfoService;
|
||||
this.mpShopTableService = mpShopTableService;
|
||||
this.tbCashierCartMapper = tbCashierCartMapper;
|
||||
this.mpCashierCartService = mpCashierCartService;
|
||||
}
|
||||
@@ -162,8 +164,9 @@ public class OrderService {
|
||||
|
||||
boolean isDineInAfter = !isMunchies && !isTakeout;
|
||||
boolean isDineInBefore = isMunchies && !isTakeout;
|
||||
boolean needSeatFee = shopInfo.getIsTableFee() == null || shopInfo.getIsTableFee() == 0;
|
||||
|
||||
return new ShopEatTypeInfoDTO(isTakeout, isMunchies, isDineInAfter, isDineInBefore, shopInfo, isTakeout ? OrderUseTypeEnum.TAKEOUT.getValue() :
|
||||
return new ShopEatTypeInfoDTO(isTakeout, isMunchies, isDineInAfter, isDineInBefore, needSeatFee, shopInfo, isTakeout ? OrderUseTypeEnum.TAKEOUT.getValue() :
|
||||
isMunchies ? OrderUseTypeEnum.DINE_IN_BEFORE.getValue() : OrderUseTypeEnum.DINE_IN_AFTER.getValue(), isTakeout ? OrderSendTypeEnums.TAKE_SELF.getValue() : OrderSendTypeEnums.TABLE.getValue());
|
||||
}
|
||||
|
||||
@@ -178,26 +181,9 @@ public class OrderService {
|
||||
String eatModel = StrUtil.isBlank(tableId) ? ShopInfoEatModelEnum.TAKE_OUT.getValue() : ShopInfoEatModelEnum.DINE_IN.getValue();
|
||||
ShopEatTypeInfoDTO shopEatTypeInfoDTO = checkEatModel(shopId, eatModel);
|
||||
|
||||
TbProduct product = mpProductMapper.selectOne(new LambdaQueryWrapper<TbProduct>()
|
||||
.eq(TbProduct::getId, productId)
|
||||
.eq(TbProduct::getStatus, 1));
|
||||
if (ObjectUtil.isEmpty(product)) {
|
||||
return Result.fail(CodeEnum.PRODUCTINFOERROR);
|
||||
}
|
||||
|
||||
TbProductSkuWithBLOBs skuWithBLOBs;
|
||||
if ("1".equals(product.getTypeEnum())) {
|
||||
skuWithBLOBs = tbProductSkuMapper.selectByProduct(productId);
|
||||
} else {
|
||||
skuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(skuId);
|
||||
}
|
||||
|
||||
|
||||
if (ObjectUtil.isEmpty(skuWithBLOBs)) {
|
||||
return Result.fail(CodeEnum.PRODUCTSKUERROR);
|
||||
}
|
||||
|
||||
// 台桌点单
|
||||
boolean isSeatCart = TableConstant.CashierCart.ID.equals(productId.toString());
|
||||
if ((StrUtil.isNotBlank(tableId))) {
|
||||
TbShopTable shopTable = mpShopTableMapper.selectOne(new LambdaUpdateWrapper<TbShopTable>()
|
||||
.eq(TbShopTable::getQrcode, tableId)
|
||||
@@ -206,6 +192,9 @@ public class OrderService {
|
||||
if (shopTable == null) {
|
||||
return Result.fail("台桌不处于开台或空闲状态");
|
||||
}
|
||||
if (shopEatTypeInfoDTO.isNeedSeatFee() && number > shopTable.getMaxCapacity() && isSeatCart) {
|
||||
return Result.fail("当前台桌最大人数未: " + shopTable.getMaxCapacity());
|
||||
}
|
||||
}
|
||||
|
||||
LambdaQueryWrapper<TbCashierCart> cartQuery = new LambdaQueryWrapper<TbCashierCart>()
|
||||
@@ -215,16 +204,33 @@ public class OrderService {
|
||||
.in(TbCashierCart::getStatus, "create")
|
||||
.eq(TbCashierCart::getId, cartId);
|
||||
|
||||
// 后付款订单只查询为空的
|
||||
if (shopEatTypeInfoDTO.isDineInAfter()) {
|
||||
cartQuery.isNull(TbCashierCart::getPlaceNum);
|
||||
}
|
||||
TbCashierCart cart = mpCashierCartMapper.selectOne(cartQuery);
|
||||
|
||||
// 校验是否是代客下单往期订单
|
||||
if (shopEatTypeInfoDTO.isDineInAfter() && cart != null && cart.getPlaceNum() != null) {
|
||||
if (shopEatTypeInfoDTO.isDineInAfter() && cart != null && cart.getPlaceNum() != null && !isSeatCart) {
|
||||
return Result.fail("后付费已下单订单仅支持退款");
|
||||
}
|
||||
TbProduct product = null;
|
||||
TbProductSkuWithBLOBs skuWithBLOBs = null;
|
||||
if (!isSeatCart) {
|
||||
product = mpProductMapper.selectOne(new LambdaQueryWrapper<TbProduct>()
|
||||
.eq(TbProduct::getId, productId)
|
||||
.eq(TbProduct::getStatus, 1));
|
||||
if (ObjectUtil.isEmpty(product)) {
|
||||
return Result.fail(CodeEnum.PRODUCTINFOERROR);
|
||||
}
|
||||
|
||||
|
||||
if ("1".equals(product.getTypeEnum())) {
|
||||
skuWithBLOBs = tbProductSkuMapper.selectByProduct(productId);
|
||||
} else {
|
||||
skuWithBLOBs = tbProductSkuMapper.selectByPrimaryKey(skuId);
|
||||
}
|
||||
|
||||
|
||||
if (ObjectUtil.isEmpty(skuWithBLOBs)) {
|
||||
return Result.fail(CodeEnum.PRODUCTSKUERROR);
|
||||
}
|
||||
|
||||
// 首次加入购物车,并且拥有起售数,设置为起售数
|
||||
if (cart == null && skuWithBLOBs.getSuit() != null && skuWithBLOBs.getSuit() != 0) {
|
||||
@@ -253,7 +259,7 @@ public class OrderService {
|
||||
List<TbCashierCart> list = mpCashierCartMapper.selectList(queryWrapper.eq(TbCashierCart::getStatus, "create"));
|
||||
|
||||
if (list.isEmpty()) {
|
||||
tbOrderInfoMapper.deleteByPrimaryKey(Integer.valueOf(finalCart.getOrderId()));
|
||||
tbOrderInfoMapper.deleteByPrimaryKey(Integer.valueOf(cart.getOrderId()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -261,13 +267,14 @@ public class OrderService {
|
||||
return Result.success(CodeEnum.SUCCESS, masterId);
|
||||
}
|
||||
|
||||
|
||||
// 校验库存
|
||||
if ("1".equals(product.getIsStock().toString())) {
|
||||
if (product.getStockNumber() - number < 0) {
|
||||
return Result.fail(CodeEnum.STOCKERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (StringUtils.isEmpty(masterId)) {
|
||||
boolean flag = redisUtil.exists("SHOP:CODE:" + clientType + ":" + shopId);
|
||||
@@ -304,10 +311,18 @@ public class OrderService {
|
||||
if (isPack.equals("false")) {
|
||||
cart.setPackFee(BigDecimal.ZERO);
|
||||
} else {
|
||||
if (!isSeatCart) {
|
||||
cart.setPackFee(new BigDecimal(number).multiply(product.getPackFee()));
|
||||
}else{
|
||||
cart.setPackFee(BigDecimal.ZERO);
|
||||
}
|
||||
}
|
||||
if (isGift.equals("false")) {
|
||||
if (!isSeatCart) {
|
||||
cart.setTotalAmount(new BigDecimal(number).multiply(skuWithBLOBs.getSalePrice()).add(cart.getPackFee()));
|
||||
}else {
|
||||
cart.setTotalAmount(new BigDecimal(number).multiply(cart.getSalePrice()).add(cart.getPackFee()));
|
||||
}
|
||||
} else {
|
||||
cart.setTotalAmount(BigDecimal.ZERO);
|
||||
}
|
||||
@@ -324,31 +339,42 @@ public class OrderService {
|
||||
if (Objects.isNull(cashierCart)) {
|
||||
cashierCart = new TbCashierCart();
|
||||
cashierCart.setUseType(shopEatTypeInfoDTO.getUseType());
|
||||
if (product != null) {
|
||||
cashierCart.setCoverImg(product.getCoverImg());
|
||||
cashierCart.setCreatedAt(System.currentTimeMillis());
|
||||
cashierCart.setIsSku(product.getTypeEnum());
|
||||
cashierCart.setName(product.getName());
|
||||
cashierCart.setCategoryId(product.getCategoryId());
|
||||
}
|
||||
cashierCart.setCreatedAt(System.currentTimeMillis());
|
||||
cashierCart.setMasterId(masterId);
|
||||
cashierCart.setUuid(uuid);
|
||||
cashierCart.setMerchantId(userId);
|
||||
cashierCart.setName(product.getName());
|
||||
cashierCart.setProductId(productId.toString());
|
||||
if (skuWithBLOBs != null) {
|
||||
cashierCart.setSalePrice(skuWithBLOBs.getSalePrice());
|
||||
cashierCart.setSkuId(skuWithBLOBs.getId().toString());
|
||||
cashierCart.setSkuName(skuWithBLOBs.getSpecSnap());
|
||||
}
|
||||
cashierCart.setShopId(shopId.toString());
|
||||
cashierCart.setTradeDay(DateUtils.getDay());
|
||||
cashierCart.setStatus("create");
|
||||
cashierCart.setIsPack(isPack);
|
||||
cashierCart.setIsGift(isGift);
|
||||
cashierCart.setSkuName(skuWithBLOBs.getSpecSnap());
|
||||
if (isGift.equals("false")) {
|
||||
if (isSeatCart) {
|
||||
cashierCart.setTotalAmount(new BigDecimal(number).multiply(cashierCart.getSalePrice()));
|
||||
}else {
|
||||
cashierCart.setTotalAmount(new BigDecimal(number).multiply(skuWithBLOBs.getSalePrice()));
|
||||
}
|
||||
} else {
|
||||
cashierCart.setTotalAmount(BigDecimal.ZERO);
|
||||
}
|
||||
if (isPack.equals("false")) {
|
||||
cashierCart.setPackFee(BigDecimal.ZERO);
|
||||
} else {
|
||||
if (!isSeatCart) {
|
||||
cashierCart.setPackFee(new BigDecimal(number).multiply(product.getPackFee()));
|
||||
}
|
||||
cashierCart.setTotalAmount(cashierCart.getTotalAmount().add(cashierCart.getPackFee()));
|
||||
|
||||
}
|
||||
@@ -356,7 +382,6 @@ public class OrderService {
|
||||
cashierCart.setUserId(Integer.valueOf(userId));
|
||||
cashierCart.setNumber(number);
|
||||
cashierCart.setUuid(uuid);
|
||||
cashierCart.setCategoryId(product.getCategoryId());
|
||||
cashierCart.setTableId(tableId);
|
||||
cashierCart.setPlatformType(OrderPlatformTypeEnum.CASH.getValue());
|
||||
list.add(cashierCart);
|
||||
@@ -370,8 +395,10 @@ public class OrderService {
|
||||
if (isPack.equals("false")) {
|
||||
cashierCart.setPackFee(BigDecimal.ZERO);
|
||||
} else {
|
||||
if (!isSeatCart) {
|
||||
cashierCart.setPackFee(new BigDecimal(number).multiply(product.getPackFee()));
|
||||
}
|
||||
}
|
||||
cashierCart.setTotalAmount(new BigDecimal(cashierCart.getNumber()).multiply(skuWithBLOBs.getSalePrice()).add(cashierCart.getPackFee()));
|
||||
mpCashierCartMapper.updateById(cashierCart);
|
||||
}
|
||||
@@ -380,15 +407,6 @@ public class OrderService {
|
||||
}
|
||||
|
||||
|
||||
// TbCashierCart finalCart1 = cart;
|
||||
// ThreadUtil.execute(() -> {
|
||||
// ThreadUtil.sleep(1, TimeUnit.SECONDS);
|
||||
// if (finalCart1.getOrderId() != null && finalCart1.getTableId() != null) {
|
||||
// log.info("购物车数量改变,开始校验订单是否为空");
|
||||
// printMechineConsumer.printReturnTicket(Integer.valueOf(finalCart1.getOrderId()), tbOrderDetailMapper.selectAllByOrderId(Integer.valueOf(finalCart1.getOrderId())));
|
||||
// }
|
||||
// });
|
||||
|
||||
setRedisTableCartInfo(tableId, shopId, Collections.singletonList(cart), true);
|
||||
|
||||
return Result.success(CodeEnum.SUCCESS, masterId);
|
||||
@@ -1781,7 +1799,7 @@ public class OrderService {
|
||||
if (shopInfo == null) throw new NotPrintException("店铺信息不存在");
|
||||
|
||||
if (shopInfo.getIsTableFee() != null && shopInfo.getIsTableFee() == 1) {
|
||||
throw new NotPrintException("当前店铺无需选择餐位费");
|
||||
return Result.success(CodeEnum.SUCCESS);
|
||||
}
|
||||
|
||||
TbShopTable shopTable = mpShopTableMapper.selectOne(new LambdaQueryWrapper<TbShopTable>()
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.chaozhanggui.system.cashierservice.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.chaozhanggui.system.cashierservice.bean.constant.TableConstant;
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbCashierCart;
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbShopTable;
|
||||
import com.chaozhanggui.system.cashierservice.mybatis.MPCashierCartMapper;
|
||||
import com.chaozhanggui.system.cashierservice.mybatis.MpShopTableMapper;
|
||||
import com.chaozhanggui.system.cashierservice.service.MpCashierCartService;
|
||||
import com.chaozhanggui.system.cashierservice.service.MpShopTableService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* (TbShopPermission)表服务实现类
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2024-09-14 17:08:49
|
||||
*/
|
||||
@Service
|
||||
public class MpShopTableServiceImpl extends ServiceImpl<MpShopTableMapper, TbShopTable> implements MpShopTableService {
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user