| | |
| | | @Autowired |
| | | private TFoundationConfigService foundationConfigService; |
| | | @Autowired |
| | | private TFoundationPersonService foundationPersonService; |
| | | @Autowired |
| | | private TGoodsService goodsService; |
| | | @Autowired |
| | | private TOrderMealService orderMealService; |
| | |
| | | dataGenerator.setOtherPay(dto.getOtherProportion()); |
| | | this.save(dataGenerator); |
| | | long start = System.currentTimeMillis(); |
| | | // 查询所有的人数用餐标准 |
| | | List<TFoundationConfigVO> foundationConfigs = foundationConfigService.getList(dto.getShopId()); |
| | | TShop shop = shopService.getById(dto.getShopId()); |
| | | List<TFoundationConfigVO> foundationConfigs = foundationConfigService.getList(shop.getMealType()); |
| | | if(CollectionUtils.isEmpty(foundationConfigs)){ |
| | | throw new ServiceException("请先添加该店铺用餐标准"); |
| | | throw new ServiceException("请先添加中餐或火锅用餐标准"); |
| | | } |
| | | // 查询所有桌子 |
| | | List<TBoard> boards = boardService.list(Wrappers.lambdaQuery(TBoard.class) |
| | |
| | | orderMeal.setMealType(1); |
| | | orderMeal.setMealPerson(random); |
| | | orderMeal.setMealTime(orderMealGeneratorCountDTO.getTime()); |
| | | orderMeal.setOrderNum(OrderNumConstants.MEAL + CodeGenerateUtils.generateVolumeSn()); |
| | | String num = OrderNumConstants.MEAL + CodeGenerateUtils.generateVolumeSn(); |
| | | // long count1 = orderMealService.count(Wrappers.lambdaQuery(TOrderMeal.class) |
| | | // .eq(TOrderMeal::getOrderNum, num)); |
| | | // if(count1>0){ |
| | | // num = CodeGenerateUtils.generateVolumeSn(); |
| | | // } |
| | | orderMeal.setOrderNum(num); |
| | | orderMeal.setStatus(2); |
| | | List<TOrderMealGoods> orderMealGoods = new ArrayList<>(); |
| | | // 获取当前桌的菜品 |
| | |
| | | if (good.getGoodsNum().equals(typeGood.getGoodsNum())) { |
| | | count+=1; |
| | | good.setGoodsCount(good.getGoodsCount() + 1); |
| | | good.setGoodsSalePrice(good.getGoodsSalePrice().add(typeGood.getSalePrice())); |
| | | // good.setGoodsSalePrice(good.getGoodsSalePrice().add(typeGood.getSalePrice())); |
| | | break; // 找到后直接跳出循环 |
| | | } |
| | | } |
| | |
| | | tOrderMealGoods.setGoodsName(typeGood.getGoodsName()); |
| | | tOrderMealGoods.setGoodsPicture(typeGood.getGoodsPicture()); |
| | | tOrderMealGoods.setGoodsSalePrice(typeGood.getSalePrice()); |
| | | tOrderMealGoods.setCostPrice(typeGood.getCostPrice()); |
| | | tOrderMealGoods.setGoodsCount(1); |
| | | tOrderMealGoods.setTypeId(typeGood.getTypeId()); |
| | | tOrderMealGoods.setGoodsId(typeGood.getId()); |
| | |
| | | // 查询上一次开始之后的订单数据 |
| | | List<TOrderSale> orderSales1 = orderSaleService.list(new LambdaQueryWrapper<TOrderSale>().gt(TOrderSale::getOrderTime, startTime1)); |
| | | List<Long> saleIds1 = orderSales1.stream().map(TOrderSale::getId).collect(Collectors.toList()); |
| | | // 查询上一次的商品 |
| | | List<TOrderSaleGoods> list = orderSaleGoodsService.list(new LambdaQueryWrapper<TOrderSaleGoods>().in(TOrderSaleGoods::getOrderId, saleIds1)); |
| | | // 结合上次最后一次的数据 |
| | | list.addAll(orderSaleGoodsList); |
| | | List<TOrderSaleGoods> list; |
| | | if(CollectionUtils.isEmpty(saleIds1)){ |
| | | // 查询上一次的商品 |
| | | list = orderSaleGoodsService.list(new LambdaQueryWrapper<TOrderSaleGoods>().in(TOrderSaleGoods::getOrderId, saleIds1)); |
| | | // 结合上次最后一次的数据 |
| | | list.addAll(orderSaleGoodsList); |
| | | }else { |
| | | list = orderSaleGoodsList; |
| | | } |
| | | // 删除上一次的数据生成 新生成一条数据 |
| | | TOrderStock orderStock = new TOrderStock(); |
| | | orderStock.setStockNum(OrderNumConstants.STOCK + CodeGenerateUtils.generateVolumeSn()); |
| | |
| | | for (TOrderSale orderSale : orderSales) { |
| | | orderSale.getOrderSaleGoods().forEach(e->e.setOrderId(orderSale.getId())); |
| | | } |
| | | List<TGoodsType> list = goodsTypeService.list(); |
| | | // 查询店铺下的商品 |
| | | List<TGoods> goodsList = goodsService.list(Wrappers.lambdaQuery(TGoods.class) |
| | | .in(TGoods::getShopId,dto.getShopId())); |
| | | // List<TGoodsType> list = goodsTypeService.list(); |
| | | // orderSaleGoods.forEach(e->e.setTypeName(list.stream().filter(m->m.getId().equals(e.getTypeId())).findFirst().get().getTypeName())); |
| | | orderSaleGoods.forEach(e->{ |
| | | e.setId(null); |
| | |
| | | stock.getOrderStockGoods().forEach(e->e.setOrderId(stock.getId())); |
| | | } |
| | | List<TOrderStockGoods> orderStockGoods = stockList.stream().map(TOrderStock::getOrderStockGoods).flatMap(Collection::stream).collect(Collectors.toList()); |
| | | if(!CollectionUtils.isEmpty(orderStockGoods)){ |
| | | for (TOrderStockGoods orderStockGood : orderStockGoods) { |
| | | goodsList.stream().filter(e->e.getId().equals(orderStockGood.getGoodsId())) |
| | | .findFirst().ifPresent(e->orderStockGood.setThisCostPrice(e.getCostPrice())); |
| | | } |
| | | } |
| | | orderStockGoodsService.saveBatch(orderStockGoods); |
| | | } |
| | | |
| | |
| | | orderMealService.remove(Wrappers.lambdaQuery(TOrderMeal.class) |
| | | .ge(TOrderMeal::getMealTime, dataGenerator.getStartTime()) |
| | | .le(TOrderMeal::getMealTime, dataGenerator.getEndTime()) |
| | | .eq(TOrderMeal::getShopId, dataGenerator.getShopId()) |
| | | .eq(TOrderMeal::getIsCover,1)); |
| | | // 修改覆盖类型为已覆盖 |
| | | orderMealService.update(Wrappers.lambdaUpdate(TOrderMeal.class).set(TOrderMeal::getIsCover, 1).eq(TOrderMeal::getGeneratorId, id)); |
| | |
| | | orderSaleService.remove(Wrappers.lambdaQuery(TOrderSale.class) |
| | | .ge(TOrderSale::getOrderTime, dataGenerator.getStartTime()) |
| | | .le(TOrderSale::getOrderTime, dataGenerator.getEndTime()) |
| | | .eq(TOrderSale::getShopId, dataGenerator.getShopId()) |
| | | .eq(TOrderSale::getIsCover,1)); |
| | | // 修改覆盖类型为已覆盖 |
| | | orderSaleService.update(Wrappers.lambdaUpdate(TOrderSale.class).set(TOrderSale::getIsCover, 1).eq(TOrderSale::getGeneratorId, id)); |
| | |
| | | orderStockService.remove(Wrappers.lambdaQuery(TOrderStock.class) |
| | | .ge(TOrderStock::getStockTime, dataGenerator.getStartTime()) |
| | | .le(TOrderStock::getStockTime, dataGenerator.getEndTime()) |
| | | .eq(TOrderStock::getShopId, dataGenerator.getShopId()) |
| | | .eq(TOrderStock::getIsCover,1)); |
| | | // 修改覆盖类型为已覆盖 |
| | | orderStockService.update(Wrappers.lambdaUpdate(TOrderStock.class).set(TOrderStock::getIsCover, 1).eq(TOrderStock::getGeneratorId, id)); |
| | |
| | | // 统计支付金额 |
| | | Map<String, Object> map = orderStockService.getDataGeneratorStockDetail(query); |
| | | Integer totalStock = Integer.parseInt(map.get("totalStock").toString()); |
| | | BigDecimal stockAmountSum = new BigDecimal(map.get("stockAmountSum").toString()); |
| | | // BigDecimal stockAmountSum = new BigDecimal(map.get("stockAmountSum").toString()); |
| | | data.setTotalStock(totalStock); |
| | | data.setStockAmountSum(stockAmountSum); |
| | | List<TOrderStock> list = orderStockService.list(Wrappers.lambdaQuery(TOrderStock.class) |
| | | .eq(TOrderStock::getGeneratorId, query.getGeneratorId())); |
| | | if(CollectionUtils.isEmpty(list)){ |
| | | data.setStockAmountSum(BigDecimal.ZERO); |
| | | }else { |
| | | data.setStockAmountSum(list.stream().filter(e->Objects.nonNull(e.getStockTotalPrice())).map(TOrderStock::getStockTotalPrice).reduce(BigDecimal.ZERO, BigDecimal::add)); |
| | | } |
| | | return data; |
| | | } |
| | | |
| | |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public void deleteByShopId(Long shopId) { |
| | | this.baseMapper.deleteByShopId(shopId); |
| | | } |
| | | |
| | | private int getRandomPayType(Integer size,BigDecimal count) { |
| | | BigDecimal bigDecimal = new BigDecimal(size).multiply(count.divide(new BigDecimal(100))).setScale(0, BigDecimal.ROUND_FLOOR); |
| | | return Integer.parseInt(bigDecimal.toString()); |