代客下单 下单根据店铺配置校验餐位费

This commit is contained in:
SongZhang 2024-09-18 17:51:55 +08:00
parent 1b3158930f
commit 66dc7c8581
1 changed files with 15 additions and 4 deletions

View File

@ -966,6 +966,9 @@ public class TbShopTableServiceImpl implements TbShopTableService {
@Override
public TbOrderInfo createOrder(CreateOrderDTO createOrderDTO, boolean addMaterId, boolean isPrint) {
return Utils.runFunAndCheckKey(() -> {
TbShopInfo shopInfo = shopInfoRepository.findById(createOrderDTO.getShopId()).orElse(null);
if (shopInfo == null) throw new BadRequestException("店铺信息不存在");
TbShopTable tbShopTable = null;
boolean tableFlag = StrUtil.isNotBlank(createOrderDTO.getTableId());
if (tableFlag) {
@ -1075,7 +1078,8 @@ public class TbShopTableServiceImpl implements TbShopTableService {
orderDetail.setPlaceNum(placeNum);
}
if ((OrderUseTypeEnum.DINE_IN_BEFORE.getValue().equals(createOrderDTO.getUseType()) || OrderUseTypeEnum.DINE_IN_AFTER.getValue().equals(createOrderDTO.getUseType()))
if (shopInfo.getIsTableFee() != null && shopInfo.getIsTableFee() == 0
&&(OrderUseTypeEnum.DINE_IN_BEFORE.getValue().equals(createOrderDTO.getUseType()) || OrderUseTypeEnum.DINE_IN_AFTER.getValue().equals(createOrderDTO.getUseType()))
&& mealNum == null) {
throw new BadRequestException("请选择用餐人数");
}
@ -1599,6 +1603,13 @@ public class TbShopTableServiceImpl implements TbShopTableService {
@Override
public Object choseCount(ChoseCountDTO choseCountDTO) {
TbShopInfo shopInfo = shopInfoRepository.findById(choseCountDTO.getShopId()).orElse(null);
if (shopInfo == null) throw new BadRequestException("店铺信息不存在");
if (shopInfo.getIsTableFee() != null && shopInfo.getIsTableFee() == 1) {
throw new BadRequestException("当前店铺无需选择餐位费");
}
TbShopTable shopTable = mpShopTableService.lambdaQuery().eq(TbShopTable::getQrcode, choseCountDTO.getTableId()).one();
if (shopTable == null) {
throw new BadRequestException("台桌不存在");
@ -1624,12 +1635,12 @@ public class TbShopTableServiceImpl implements TbShopTableService {
tbCashierCart.setCreatedAt(System.currentTimeMillis());
tbCashierCart.setTableId(Long.valueOf(choseCountDTO.getTableId()));
tbCashierCart.setName("客座费");
tbCashierCart.setSalePrice(BigDecimal.ONE);
tbCashierCart.setSalePrice(shopInfo.getTableFee());
tbCashierCart.setMasterId(choseCountDTO.getMasterId());
tbCashierCart.setShopId(String.valueOf(choseCountDTO.getShopId()));
tbCashierCart.setTradeDay(DateUtils.getDay());
tbCashierCart.setStatus("create");
tbCashierCart.setTotalAmount(new BigDecimal(choseCountDTO.getNum()).multiply(BigDecimal.ONE));
tbCashierCart.setTotalAmount(new BigDecimal(choseCountDTO.getNum()).multiply(shopInfo.getTableFee()));
tbCashierCart.setPlaceNum(1);
tbCashierCart.setProductId("-999");
tbCashierCart.setSkuId("-999");
@ -1638,7 +1649,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
tbCashierCart.setTotalNumber(choseCountDTO.getNum());
tbCashierCartMapper.insert(tbCashierCart);
} else {
tbCashierCart.setTotalAmount(new BigDecimal(choseCountDTO.getNum()).multiply(BigDecimal.ONE));
tbCashierCart.setTotalAmount(new BigDecimal(choseCountDTO.getNum()).multiply(shopInfo.getTableFee()));
tbCashierCart.setNumber(choseCountDTO.getNum());
tbCashierCart.setTotalNumber(choseCountDTO.getNum());
tbCashierCartMapper.updateById(tbCashierCart);