| | |
| | | // 查询已存在的菜品 |
| | | List<TOrderMealGoods> list2 = orderMealGoodsService.list(Wrappers.lambdaQuery(TOrderMealGoods.class) |
| | | .in(TOrderMealGoods::getOrderId, dto.getId())); |
| | | BigDecimal money = BigDecimal.ZERO; |
| | | for (MealOrderGoodsDTO mealOrderGoodsDTO : mealOrderGoodsDTOS) { |
| | | TOrderMealGoods tOrderMealGoods = list2.stream().filter(item1 -> item1.getGoodsId().equals(mealOrderGoodsDTO.getGoodsId())).findFirst().orElse(null); |
| | | if(Objects.nonNull(tOrderMealGoods)){ |
| | | tOrderMealGoods.setGoodsCount(tOrderMealGoods.getGoodsCount()+mealOrderGoodsDTO.getGoodsCount()); |
| | | orderMealGoods.add(tOrderMealGoods); |
| | | money = money.add(tOrderMealGoods.getGoodsSalePrice().multiply(new BigDecimal(mealOrderGoodsDTO.getGoodsCount()))); |
| | | continue; |
| | | } |
| | | for (TGoods goods : list) { |
| | |
| | | orderMealGood.setGoodsId(goods.getId()); |
| | | orderMealGood.setTypeName(list1.stream().filter(item2 -> item2.getId().equals(goods.getTypeId())).findFirst().get().getTypeName()); |
| | | orderMealGoods.add(orderMealGood); |
| | | money = money.add(goods.getSalePrice().multiply(new BigDecimal(mealOrderGoodsDTO.getGoodsCount()))); |
| | | } |
| | | } |
| | | } |
| | | BigDecimal orderMoney = orderMeal.getOrderMoney(); |
| | | // 添加菜品 |
| | | for (TOrderMealGoods orderMealGood : orderMealGoods) { |
| | | orderMealGood.setOrderId(dto.getId()); |
| | | orderMoney = orderMoney.add(orderMealGood.getGoodsSalePrice().multiply(new BigDecimal(orderMealGood.getGoodsCount()))); |
| | | } |
| | | orderMealGoodsService.saveOrUpdateBatch(orderMealGoods); |
| | | BigDecimal orderMoney = orderMeal.getOrderMoney().add(money); |
| | | orderMeal.setOrderMoney(orderMoney); |
| | | this.updateById(orderMeal); |
| | | // 添加备注 |
| | |
| | | } |
| | | PageInfo<TOrderMealVO> pageInfo = new PageInfo<>(query.getPageNum(),query.getPageSize()); |
| | | List<TOrderMealVO> list = this.baseMapper.pageList(query,pageInfo); |
| | | if(CollectionUtils.isEmpty(list)){ |
| | | return new PageInfo<>(); |
| | | } |
| | | List<Long> ids = list.stream().map(TOrderMealVO::getId).collect(Collectors.toList()); |
| | | List<TOrderMealGoods> list1 = orderMealGoodsService.list(Wrappers.lambdaQuery(TOrderMealGoods.class) |
| | | .in(TOrderMealGoods::getOrderId, ids)); |
| | | // 查询商品信息 |
| | | for (TOrderMealVO tOrderMealVO : list) { |
| | | List<TOrderMealGoods> list1 = orderMealGoodsService.list(Wrappers.lambdaQuery(TOrderMealGoods.class) |
| | | .eq(TOrderMealGoods::getOrderId, tOrderMealVO.getId())); |
| | | tOrderMealVO.setOrderMealGoods(list1); |
| | | if(!CollectionUtils.isEmpty(list1)){ |
| | | Map<String, List<TOrderMealGoods>> map = list1.stream().collect(Collectors.groupingBy(TOrderMealGoods::getTypeName)); |
| | | List<TOrderMealGoods> collect = list1.stream().filter(e -> e.getOrderId().equals(tOrderMealVO.getId())).collect(Collectors.toList()); |
| | | tOrderMealVO.setOrderMealGoods(collect); |
| | | if(!CollectionUtils.isEmpty(collect)){ |
| | | Map<String, List<TOrderMealGoods>> map = collect.stream().collect(Collectors.groupingBy(TOrderMealGoods::getTypeName)); |
| | | List<String> goodsList = new ArrayList<>(); |
| | | map.forEach((k,v)->{ |
| | | goodsList.add(k+":"+v.stream().map(item->item.getGoodsName()+" "+(item.getGoodsSalePrice().multiply(new BigDecimal(item.getGoodsCount())))).collect(Collectors.joining(","))); |