| | |
| | | import cn.afterturn.easypoi.excel.entity.ExportParams; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.ruoyi.common.basic.PageInfo; |
| | | import com.ruoyi.common.constant.OrderNumConstants; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.utils.CodeGenerateUtils; |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | import com.ruoyi.common.utils.WebUtils; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.system.domain.*; |
| | | import com.ruoyi.system.dto.CheckoutDTO; |
| | | import com.ruoyi.system.dto.MealOrderGoodsDTO; |
| | | import com.ruoyi.system.dto.TOrderMealDTO; |
| | | import com.ruoyi.system.export.TOrderMealExportExcel; |
| | | import com.ruoyi.system.query.TOrderMealQuery; |
| | | import com.ruoyi.system.service.TGoodsService; |
| | | import com.ruoyi.system.service.TGoodsTypeService; |
| | | import com.ruoyi.system.service.TOrderMealGoodsService; |
| | | import com.ruoyi.system.service.TOrderMealService; |
| | | import com.ruoyi.system.service.*; |
| | | import com.ruoyi.system.vo.AmountSumVO; |
| | | import com.ruoyi.system.vo.TOrderMealVO; |
| | | import io.swagger.annotations.Api; |
| | |
| | | private final TOrderMealGoodsService orderMealGoodsService; |
| | | private final TGoodsTypeService goodsTypeService; |
| | | private final TGoodsService goodsService; |
| | | private final TBoardService boardService; |
| | | private final TokenService tokenService; |
| | | |
| | | @Autowired |
| | | public TOrderMealController(TOrderMealService orderMealService, TOrderMealGoodsService orderMealGoodsService, TGoodsTypeService goodsTypeService, TGoodsService goodsService, TokenService tokenService) { |
| | | public TOrderMealController(TOrderMealService orderMealService, TOrderMealGoodsService orderMealGoodsService, TGoodsTypeService goodsTypeService, TGoodsService goodsService, TBoardService boardService, TokenService tokenService) { |
| | | this.orderMealService = orderMealService; |
| | | this.orderMealGoodsService = orderMealGoodsService; |
| | | this.goodsTypeService = goodsTypeService; |
| | | this.goodsService = goodsService; |
| | | this.boardService = boardService; |
| | | this.tokenService = tokenService; |
| | | } |
| | | |
| | |
| | | orderMealVO.setGoodsList(goodsList); |
| | | } |
| | | orderMealVO.setOrderMealGoods(list); |
| | | // 查询用餐人数 |
| | | TBoard board = boardService.getById(orderMeal.getBoardId()); |
| | | orderMealVO.setMaxPerson(board.getMaxPerson()); |
| | | orderMealVO.setMinPerson(board.getMinPerson()); |
| | | return AjaxResult.success(orderMealVO); |
| | | } |
| | | |
| | |
| | | @PostMapping(value = "/update") |
| | | public AjaxResult<String> update(@RequestBody TOrderMealDTO dto) { |
| | | // 删除所有菜品 |
| | | orderMealGoodsService.remove(Wrappers.lambdaQuery(TOrderMealGoods.class) |
| | | .eq(TOrderMealGoods::getOrderId, dto.getId())); |
| | | orderMealService.updateById(dto); |
| | | for (TOrderMealGoods mealOrderGood : dto.getMealOrderGoods()) { |
| | | // 设置商品类型和类型id |
| | | TGoodsType goodsType = goodsTypeService.getById(mealOrderGood.getTypeId()); |
| | | mealOrderGood.setId(null); |
| | | mealOrderGood.setOrderId(dto.getId()); |
| | | mealOrderGood.setTypeId(goodsType.getId()); |
| | | mealOrderGood.setTypeName(goodsType.getTypeName()); |
| | | if(!CollectionUtils.isEmpty(dto.getMealOrderGoods())){ |
| | | orderMealGoodsService.remove(Wrappers.lambdaQuery(TOrderMealGoods.class) |
| | | .eq(TOrderMealGoods::getOrderId, dto.getId())); |
| | | for (TOrderMealGoods mealOrderGood : dto.getMealOrderGoods()) { |
| | | // 设置商品类型和类型id |
| | | TGoodsType goodsType = goodsTypeService.getById(mealOrderGood.getTypeId()); |
| | | mealOrderGood.setId(null); |
| | | mealOrderGood.setOrderId(dto.getId()); |
| | | mealOrderGood.setTypeId(goodsType.getId()); |
| | | mealOrderGood.setTypeName(goodsType.getTypeName()); |
| | | } |
| | | orderMealGoodsService.saveBatch(dto.getMealOrderGoods()); |
| | | } |
| | | orderMealGoodsService.saveBatch(dto.getMealOrderGoods()); |
| | | return AjaxResult.success(); |
| | | } |
| | | @ApiOperation( value = "列表详情结账") |
| | | @PostMapping(value = "/detailUpdate") |
| | | public AjaxResult<String> detailUpdate(@RequestBody TOrderMealDTO dto) { |
| | | // 删除所有菜品 |
| | | orderMealGoodsService.remove(Wrappers.lambdaQuery(TOrderMealGoods.class) |
| | | .eq(TOrderMealGoods::getOrderId, dto.getId())); |
| | | orderMealService.updateById(dto); |
| | | // 查询餐桌 |
| | | List<TOrderMealGoods> mealOrderGoods = dto.getMealOrderGoods(); |
| | | if (!CollectionUtils.isEmpty(mealOrderGoods)) { |
| | | // 删除所有菜品 |
| | | orderMealGoodsService.remove(Wrappers.lambdaQuery(TOrderMealGoods.class) |
| | | .eq(TOrderMealGoods::getOrderId, dto.getId())); |
| | | for (TOrderMealGoods mealOrderGood : mealOrderGoods) { |
| | | // 设置商品类型和类型id |
| | | mealOrderGood.setId(null); |