Merge remote-tracking branch 'origin/test' into test

This commit is contained in:
yijiegong 2024-09-23 10:10:40 +08:00
commit 48abe51c47
2 changed files with 56 additions and 0 deletions

View File

@ -324,10 +324,47 @@ public class TbCallServiceImpl implements TbCallService {
case 3:
callQueue.setPassTime(DateUtil.date());
TbShopInfo shopInfo = shopInfoRepository.findById(callQueue.getShopId()).orElse(null);
if (shopInfo == null) {
throw new BadRequestException("店铺信息不存在");
}
if(StrUtil.isBlank(callQueue.getOpenId()) && callQueue.getSubState() != 1) {
break;
}
TbCallTable callTable = callTableService.getById(callQueue.getCallTableId());
Byte isPostpone = callTable.getIsPostpone();
Integer postponeNum = callTable.getPostponeNum();
// 判断是否需要顺延
if (isPostpone != null && isPostpone == 1 && postponeNum != null && postponeNum > 0) {
// 查询当前桌以及顺延桌数
List<TbCallQueue> current = callQueueService.lambdaQuery()
.eq(TbCallQueue::getCallTableId, callQueue.getCallTableId())
.eq(TbCallQueue::getCreateDay, DateUtil.today())
.eq(TbCallQueue::getShopId, callTable.getShopId())
.ge(TbCallQueue::getId, callQueue.getId())
.orderByAsc(TbCallQueue::getCreateTime)
.page(new Page<>(1, postponeNum + 1)) // 获取当前桌和顺延的桌数
.getRecords();
// 确保有足够的桌可以顺延
if (current.size() > 1) {
// 获取当前桌以及顺延桌
TbCallQueue currentTable = BeanUtil.copyProperties(current.get(0), TbCallQueue.class);
// 顺延替换信息将每一张顺延桌向前移动
for (int i = 0; i < current.size() - 1; i++) {
exchangeCallQueueInfo(current.get(i), current.get(i + 1)); // 当前桌替换为顺延桌
}
exchangeCallQueueInfo(current.get(current.size() - 1), currentTable);
callQueue = current.get(current.size() - 1);
// 更新数据库中的桌号信息
callQueueService.updateBatchById(current);
}
}
List<TbCallQueue> current = callQueueService.lambdaQuery()
.eq(TbCallQueue::getCallTableId, callQueue.getCallTableId())
.eq(TbCallQueue::getCreateDay, DateUtil.today())
@ -351,6 +388,23 @@ public class TbCallServiceImpl implements TbCallService {
return callQueueService.updateById(callQueue);
}
private void exchangeCallQueueInfo(TbCallQueue setCallQueue, TbCallQueue copyCallQueue) {
setCallQueue.setOpenId(copyCallQueue.getOpenId());
setCallQueue.setState(copyCallQueue.getState());
setCallQueue.setSubState(copyCallQueue.getSubState());
setCallQueue.setCreateTime(copyCallQueue.getCreateTime());
setCallQueue.setName(copyCallQueue.getName());
setCallQueue.setNote(copyCallQueue.getNote());
setCallQueue.setCallNum(copyCallQueue.getCallNum());
setCallQueue.setCallTime(copyCallQueue.getCallTime());
setCallQueue.setCallCount(copyCallQueue.getCallCount());
setCallQueue.setPassTime(copyCallQueue.getPassTime());
setCallQueue.setCancelTime(copyCallQueue.getCancelTime());
setCallQueue.setUserId(copyCallQueue.getUserId());
setCallQueue.setConfirmTime(copyCallQueue.getConfirmTime());
}
@Override
public Object get(Integer page, Integer size, Integer shopId, Integer callTableId, Integer state) {
LambdaQueryWrapper<TbCallTable> query = new LambdaQueryWrapper<TbCallTable>()

View File

@ -1603,11 +1603,13 @@ public class TbShopTableServiceImpl implements TbShopTableService {
tbCashierCart.setPackFee(BigDecimal.ZERO);
tbCashierCart.setNumber(choseCountDTO.getNum());
tbCashierCart.setTotalNumber(choseCountDTO.getNum());
tbCashierCart.setUseType(choseCountDTO.getUseType());
tbCashierCartMapper.insert(tbCashierCart);
} else {
tbCashierCart.setTotalAmount(new BigDecimal(choseCountDTO.getNum()).multiply(shopInfo.getTableFee()));
tbCashierCart.setNumber(choseCountDTO.getNum());
tbCashierCart.setTotalNumber(choseCountDTO.getNum());
tbCashierCart.setUseType(choseCountDTO.getUseType());
tbCashierCartMapper.updateById(tbCashierCart);
}