1.代客下单订单打印
2.批量生成台桌
This commit is contained in:
@@ -30,6 +30,7 @@ import cn.ysk.cashier.exception.BadRequestException;
|
||||
import cn.ysk.cashier.mybatis.entity.TbShopOpenId;
|
||||
import cn.ysk.cashier.mybatis.entity.TbShopUserFlow;
|
||||
import cn.ysk.cashier.mybatis.mapper.*;
|
||||
import cn.ysk.cashier.mybatis.service.MpShopTableService;
|
||||
import cn.ysk.cashier.pojo.TbShopPayType;
|
||||
import cn.ysk.cashier.pojo.order.TbCashierCart;
|
||||
import cn.ysk.cashier.pojo.order.TbOrderDetail;
|
||||
@@ -37,6 +38,7 @@ import cn.ysk.cashier.pojo.order.TbOrderInfo;
|
||||
import cn.ysk.cashier.pojo.product.TbProduct;
|
||||
import cn.ysk.cashier.pojo.product.TbProductSku;
|
||||
import cn.ysk.cashier.pojo.shop.TbMerchantAccount;
|
||||
import cn.ysk.cashier.pojo.shop.TbShopArea;
|
||||
import cn.ysk.cashier.pojo.shop.TbShopInfo;
|
||||
import cn.ysk.cashier.pojo.shop.TbShopTable;
|
||||
import cn.ysk.cashier.repository.TbShopPayTypeRepository;
|
||||
@@ -111,6 +113,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||
private final TbShopPayTypeRepository payTypeRepository;
|
||||
private final MpShopTableMapper mpShopTableMapper;
|
||||
private final TbShopPayTypeMapper tbShopPayTypeMapper;
|
||||
private final MpShopTableService mpShopTableService;
|
||||
|
||||
|
||||
/**
|
||||
@@ -122,6 +125,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||
private final TbCashierCartMapper tbCashierCartMapper;
|
||||
private final TbOrderDetailMapper tbOrderDetailMapper;
|
||||
private final StringRedisTemplate stringRedisTemplate;
|
||||
private final MpShopAreaMapper mpShopAreaMapper;
|
||||
|
||||
@Override
|
||||
public Map<String, Object> queryAll(TbShopTableQueryCriteria criteria, Pageable pageable) {
|
||||
@@ -1567,7 +1571,8 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||
LambdaQueryWrapper<TbCashierCart> query = new LambdaQueryWrapper<TbCashierCart>()
|
||||
.eq(TbCashierCart::getShopId, choseCountDTO.getShopId())
|
||||
.eq(TbCashierCart::getMasterId, choseCountDTO.getMasterId())
|
||||
.eq(TbCashierCart::getProductId, -999)
|
||||
.eq(TbCashierCart::getProductId, "-999")
|
||||
.eq(TbCashierCart::getSkuId, "-999")
|
||||
.eq(TbCashierCart::getTableId, choseCountDTO.getTableId());
|
||||
TbCashierCart tbCashierCart = cashierCartMapper.selectOne(query);
|
||||
|
||||
@@ -1597,4 +1602,65 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||
|
||||
return tbCashierCart;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object printOrder(BaseTableDTO baseTableDTO) {
|
||||
TbShopTable tbShopTable = mpShopTableMapper.selectOne(new LambdaQueryWrapper<TbShopTable>()
|
||||
.eq(TbShopTable::getQrcode, baseTableDTO.getTableId())
|
||||
.in(TbShopTable::getStatus, TableStateEnum.USING.getState(), TableStateEnum.PAYING.getState(), TableStateEnum.CLEANING.getState()));
|
||||
if (tbShopTable == null) {
|
||||
throw new BadRequestException("台桌不存在或当前台桌未开台");
|
||||
}
|
||||
String currentOrderId = getCurrentOrderId(baseTableDTO.getTableId(), baseTableDTO.getShopId().toString());
|
||||
if (StrUtil.isBlank(currentOrderId)) {
|
||||
throw new BadRequestException("当前台桌不存在订单");
|
||||
}
|
||||
TbOrderInfo orderInfo = orderInfoMapper.selectById(currentOrderId);
|
||||
rabbitMsgUtils.printPlaceTicket(orderInfo.getId(), false);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object generate(TableGenerateDTO generateDTO) {
|
||||
TbShopArea shopArea = mpShopAreaMapper.selectOne(new LambdaQueryWrapper<TbShopArea>()
|
||||
.eq(TbShopArea::getShopId, generateDTO.getShopId())
|
||||
.eq(TbShopArea::getId, generateDTO.getAreaId()));
|
||||
if (shopArea == null) {
|
||||
throw new BadRequestException("台桌区域不存在");
|
||||
}
|
||||
|
||||
List<TbShopTable> tbShopTables = mpShopTableMapper.selectList(new LambdaQueryWrapper<TbShopTable>()
|
||||
.eq(TbShopTable::getShopId, generateDTO.getShopId())
|
||||
.select(TbShopTable::getName));
|
||||
|
||||
HashMap<String, Object> tableMap = new HashMap<>();
|
||||
tbShopTables.forEach(item -> {
|
||||
tableMap.put(item.getName(), item);
|
||||
});
|
||||
|
||||
StringBuilder msg = new StringBuilder();
|
||||
ArrayList<TbShopTable> tableArrayList = new ArrayList<>();
|
||||
for (int i = generateDTO.getStart(); i <= generateDTO.getEnd(); i++) {
|
||||
String name = generateDTO.getSign() + i;
|
||||
if (tableMap.get(name) != null) {
|
||||
msg.append(name).append(";");
|
||||
continue;
|
||||
}
|
||||
TbShopTable shopTable = new TbShopTable();
|
||||
shopTable.setShopId(generateDTO.getShopId());
|
||||
shopTable.setName(name);
|
||||
shopTable.setMaxCapacity(generateDTO.getCapacity());
|
||||
shopTable.setAreaId(generateDTO.getAreaId());
|
||||
shopTable.setCreatedAt(DateUtil.current());
|
||||
shopTable.setStatus(TableStateEnum.CLOSED.getState());
|
||||
tableArrayList.add(shopTable);
|
||||
}
|
||||
|
||||
mpShopTableService.saveBatch(tableArrayList);
|
||||
if (StrUtil.isNotBlank(msg.toString())) {
|
||||
msg.append("台桌名已存在,未添加");
|
||||
throw new BadRequestException(msg.toString());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,4 +130,8 @@ public interface TbShopTableService {
|
||||
Object choseTable(ChoseTableDTO choseTableDTO);
|
||||
|
||||
Object choseCount(ChoseCountDTO choseCountDTO);
|
||||
|
||||
Object printOrder(BaseTableDTO baseTableDTO);
|
||||
|
||||
Object generate(TableGenerateDTO generateDTO);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user