下单支持堂食外带, 增加餐位费, 多次下单功能
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
package com.chaozhanggui.system.cashierservice.util;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.chaozhanggui.system.cashierservice.entity.Enum.OrderUseTypeEnum;
|
||||
import com.chaozhanggui.system.cashierservice.entity.Enum.ShopInfoEatModelEnum;
|
||||
import com.chaozhanggui.system.cashierservice.entity.Enum.ShopInfoRegisterlEnum;
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbShopInfo;
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.ShopEatTypeInfoDTO;
|
||||
import com.chaozhanggui.system.cashierservice.exception.MsgException;
|
||||
import com.chaozhanggui.system.cashierservice.mapper.MpShopInfoMapper;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class ShopUtils {
|
||||
|
||||
private final MpShopInfoMapper mpShopInfoMapper;
|
||||
|
||||
public ShopUtils(MpShopInfoMapper mpShopInfoMapper) {
|
||||
this.mpShopInfoMapper = mpShopInfoMapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验就餐模式是否存在并返回就餐类型信息
|
||||
* @param tableId 台桌id
|
||||
* @param shopId 店铺id
|
||||
* @return 就餐类型信息
|
||||
*/
|
||||
public ShopEatTypeInfoDTO checkEatModel(String tableId, Object shopId) {
|
||||
String eatModel = StrUtil.isBlank(tableId) ? ShopInfoEatModelEnum.TAKE_OUT.getValue() : ShopInfoEatModelEnum.DINE_IN.getValue();
|
||||
|
||||
TbShopInfo shopInfo = mpShopInfoMapper.selectOne(new LambdaQueryWrapper<TbShopInfo>()
|
||||
.eq(TbShopInfo::getId, shopId)
|
||||
.eq(TbShopInfo::getStatus, 1));
|
||||
if (shopInfo == null) {
|
||||
throw new MsgException("店铺信息不存在");
|
||||
}
|
||||
|
||||
if (!shopInfo.getEatModel().contains(eatModel)) {
|
||||
throw new MsgException("当前店铺未开启此就餐模式");
|
||||
}
|
||||
boolean isTakeout = ShopInfoEatModelEnum.TAKE_OUT.getValue().equals(eatModel);
|
||||
// 是否是快餐版/先付费
|
||||
boolean isMunchies = StrUtil.isNotBlank(shopInfo.getRegisterType()) &&
|
||||
ShopInfoRegisterlEnum.MUNCHIES.getValue().equals(shopInfo.getRegisterType());
|
||||
|
||||
boolean isDineInAfter = !isMunchies && !isTakeout;
|
||||
boolean isDineInBefore = isMunchies && !isTakeout;
|
||||
|
||||
return new ShopEatTypeInfoDTO(isTakeout, isMunchies, isDineInAfter, isDineInBefore, shopInfo, isTakeout ? OrderUseTypeEnum.TAKEOUT.getValue() :
|
||||
isMunchies ? OrderUseTypeEnum.DINE_IN_BEFORE.getValue() : OrderUseTypeEnum.DINE_IN_AFTER.getValue());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user