From 13a3236249d21e1ed1a0f1e8ae20a29d6bf3913a Mon Sep 17 00:00:00 2001 From: xuhy <3313886187@qq.com> Date: 星期五, 26 九月 2025 17:49:11 +0800 Subject: [PATCH] 修改 --- ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TOrderMealController.java | 65 ++++++++++++++++++++------------ 1 files changed, 40 insertions(+), 25 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TOrderMealController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TOrderMealController.java index c86c896..c0c4c77 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TOrderMealController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TOrderMealController.java @@ -4,23 +4,19 @@ import cn.afterturn.easypoi.excel.ExcelExportUtil; import cn.afterturn.easypoi.excel.entity.ExportParams; import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.ruoyi.common.annotation.Log; 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.enums.BusinessType; 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; @@ -59,14 +55,16 @@ 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; } @@ -87,7 +85,11 @@ @PostMapping(value = "/amountSum") public AjaxResult<AmountSumVO> amountSum(@RequestBody TOrderMealQuery query) { query.setShopId(tokenService.getLoginUser().getObjectId()); - return AjaxResult.success(orderMealService.amountSum(query)); + AmountSumVO amountSumVO = orderMealService.amountSum(query); + if(amountSumVO.getObligation().compareTo(BigDecimal.ZERO) < 0){ + amountSumVO.setObligation(BigDecimal.ZERO); + } + return AjaxResult.success(amountSumVO); } @ApiOperation( value = "查询餐饮详情") @@ -107,37 +109,46 @@ orderMealVO.setGoodsList(goodsList); } orderMealVO.setOrderMealGoods(list); + // 查询用餐人数 + TBoard board = boardService.getById(orderMeal.getBoardId()); + orderMealVO.setMaxPerson(board.getMaxPerson()); + orderMealVO.setMinPerson(board.getMinPerson()); + orderMealVO.setBoardName(board.getBoardName()); return AjaxResult.success(orderMealVO); } + @Log(title = "餐饮-修改餐饮信息", businessType = BusinessType.UPDATE) @ApiOperation( value = "修改") @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(); } + @Log(title = "餐饮-列表详情结账", businessType = BusinessType.UPDATE) @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); @@ -146,18 +157,19 @@ } return AjaxResult.success(); } - + @Log(title = "餐饮订单-删除餐饮订单", businessType = BusinessType.DELETE) @ApiOperation( value = "删除餐饮订单") @GetMapping(value = "/deleteById") public AjaxResult<Boolean> deleteById(@RequestParam(value = "id") Long id) { - orderMealGoodsService.remove(Wrappers.lambdaQuery(TOrderMealGoods.class) - .eq(TOrderMealGoods::getOrderId, id)); +// orderMealGoodsService.remove(Wrappers.lambdaQuery(TOrderMealGoods.class) +// .eq(TOrderMealGoods::getOrderId, id)); return AjaxResult.success(orderMealService.removeById(id)); } /** * 添加餐饮管理 */ + @Log(title = "餐饮-开台", businessType = BusinessType.UPDATE) @ApiOperation( value = "开台") @PostMapping(value = "/startMeal") public AjaxResult<Integer> startMeal(@RequestBody TOrderMeal dto) { @@ -169,6 +181,7 @@ /** * 添加餐饮管理 */ + @Log(title = "餐饮-点菜", businessType = BusinessType.UPDATE) @ApiOperation( value = "点菜接口") @PostMapping(value = "/add") public AjaxResult<Integer> add(@RequestBody TOrderMealDTO dto) { @@ -183,6 +196,7 @@ // return AjaxResult.success(); // } + @Log(title = "餐饮-结账", businessType = BusinessType.UPDATE) @ApiOperation( value = "结账接口") @PostMapping(value = "/checkout") public AjaxResult<String> checkout(@Validated @RequestBody CheckoutDTO dto) { @@ -193,6 +207,7 @@ /** * 导出餐饮列表 */ + @Log(title = "餐饮-导出餐饮列表", businessType = BusinessType.UPDATE) @ApiOperation(value = "导出餐饮列表") @PostMapping("/exportOrderMeal") public void exportOrderMeal(@RequestBody TOrderMealQuery query) -- Gitblit v1.7.1