| | |
| | | long start = System.currentTimeMillis(); |
| | | // 查询所有的人数用餐标准 |
| | | List<TFoundationConfigVO> foundationConfigs = foundationConfigService.getList(dto.getShopId()); |
| | | if(CollectionUtils.isEmpty(foundationConfigs)){ |
| | | throw new ServiceException("请先添加该店铺用餐标准"); |
| | | } |
| | | // 查询所有桌子 |
| | | List<TBoard> boards = boardService.list(Wrappers.lambdaQuery(TBoard.class) |
| | | .eq(TBoard::getShopId,dto.getShopId())); |
| | | if(CollectionUtils.isEmpty(boards)){ |
| | | throw new ServiceException("请先添加桌台信息"); |
| | | throw new ServiceException("请先添加该店铺桌台信息"); |
| | | } |
| | | // 查询所有菜品 |
| | | List<TGoods> goods = goodsService.list(Wrappers.lambdaQuery(TGoods.class) |
| | | .eq(TGoods::getShopId,dto.getShopId())); |
| | | if(CollectionUtils.isEmpty(goods)){ |
| | | throw new ServiceException("请先添加菜品信息"); |
| | | throw new ServiceException("请先添加该店铺菜品信息"); |
| | | } |
| | | // 循环待生成订单列表,添加到集合中,批量插入 |
| | | List<OrderMealGeneratorCountDTO> orderMealGeneratorCountDTOS = dto.getOrderMealGeneratorCountDTOS(); |
| | |
| | | }); |
| | | if(!CollectionUtils.isEmpty(orderMealGoods)){ |
| | | orderMeal.setMealOrderGoods(orderMealGoods); |
| | | orderMeal.setOrderMoney(orderMealGoods.stream().map(TOrderMealGoods::getGoodsSalePrice).reduce(BigDecimal::add).get()); |
| | | orderMeal.setPayMoney(orderMealGoods.stream().map(TOrderMealGoods::getGoodsSalePrice).reduce(BigDecimal::add).get()); |
| | | orderMeal.setOrderMoney(orderMealGoods.stream().map(good->good.getGoodsSalePrice().multiply(new BigDecimal(good.getGoodsCount()))).reduce(BigDecimal::add).get()); |
| | | orderMeal.setPayMoney(orderMealGoods.stream().map(good->good.getGoodsSalePrice().multiply(new BigDecimal(good.getGoodsCount()))).reduce(BigDecimal::add).get()); |
| | | orderMeals.add(orderMeal); |
| | | } |
| | | } |
| | |
| | | if(dataGenerator.getOrderType() == 1){ |
| | | // 删除时间段的数据 |
| | | orderMealService.remove(Wrappers.lambdaQuery(TOrderMeal.class) |
| | | .gt(TOrderMeal::getCreateTime, dataGenerator.getStartTime()) |
| | | .lt(TOrderMeal::getCreateTime, dataGenerator.getEndTime())); |
| | | .gt(TOrderMeal::getMealTime, dataGenerator.getStartTime()) |
| | | .lt(TOrderMeal::getMealTime, dataGenerator.getEndTime())); |
| | | // 修改覆盖类型为已覆盖 |
| | | orderMealService.update(Wrappers.lambdaUpdate(TOrderMeal.class).set(TOrderMeal::getIsCover, 1).eq(TOrderMeal::getGeneratorId, id)); |
| | | }else { |
| | | // 删除时间段的数据 |
| | | orderStockService.remove(Wrappers.lambdaQuery(TOrderStock.class) |
| | | .gt(TOrderStock::getCreateTime, dataGenerator.getStartTime()) |
| | | .lt(TOrderStock::getCreateTime, dataGenerator.getEndTime())); |
| | | .gt(TOrderStock::getStockTime, dataGenerator.getStartTime()) |
| | | .lt(TOrderStock::getStockTime, dataGenerator.getEndTime())); |
| | | // 修改覆盖类型为已覆盖 |
| | | orderStockService.update(Wrappers.lambdaUpdate(TOrderStock.class).set(TOrderStock::getIsCover, 1).eq(TOrderStock::getGeneratorId, id)); |
| | | } |