From 382ab2c3b04f6e584fa8254b4508f83da3aadb74 Mon Sep 17 00:00:00 2001 From: seesaw Date: Sun, 13 Oct 2024 17:31:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/dishes/vo/DishesPageReqVO.java | 4 +++ .../dishestype/vo/DishesTypePageReqVO.java | 2 ++ .../app/dishes/DishesAppController.java | 2 +- .../dishestype/DishesTypeAppController.java | 2 +- .../system/dal/mysql/dishes/DishesMapper.java | 1 + .../mysql/dishestype/DishesTypeMapper.java | 1 + .../system/service/dishes/DishesService.java | 2 ++ .../service/dishes/DishesServiceImpl.java | 25 +++++++++++++++++++ .../service/dishestype/DishesTypeService.java | 3 +++ .../dishestype/DishesTypeServiceImpl.java | 15 ++++++++++- 10 files changed, 54 insertions(+), 3 deletions(-) diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dishes/vo/DishesPageReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dishes/vo/DishesPageReqVO.java index cd70f087..e3bbb8db 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dishes/vo/DishesPageReqVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dishes/vo/DishesPageReqVO.java @@ -9,6 +9,7 @@ import org.springframework.format.annotation.DateTimeFormat; import java.math.BigDecimal; import java.time.LocalDateTime; +import java.util.List; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; @@ -56,4 +57,7 @@ public class DishesPageReqVO extends PageParam { private String weekTime; private String timeSlot; + + private List weekTimes; + } \ No newline at end of file diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dishestype/vo/DishesTypePageReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dishestype/vo/DishesTypePageReqVO.java index e9fbec09..5e3dd0b1 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dishestype/vo/DishesTypePageReqVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dishestype/vo/DishesTypePageReqVO.java @@ -23,4 +23,6 @@ public class DishesTypePageReqVO extends PageParam { @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) private LocalDateTime[] createTime; + private List ids; + } \ No newline at end of file diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/app/dishes/DishesAppController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/app/dishes/DishesAppController.java index bd813510..3ca88b8e 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/app/dishes/DishesAppController.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/app/dishes/DishesAppController.java @@ -76,7 +76,7 @@ public class DishesAppController { @Operation(summary = "获得菜品管理分页") // @PreAuthorize("@ss.hasPermission('t:dishes:query')") public CommonResult> getDishesPage(@Valid DishesPageReqVO pageReqVO) { - PageResult pageResult = dishesService.getDishesPage(pageReqVO); + PageResult pageResult = dishesService.getDishesPageApp(pageReqVO); PageResult bean = BeanUtils.toBean(pageResult, DishesRespVO.class); bean.getList().forEach(f-> f.setKcal(dishesNutritionService.getDishesNutritionKcal(f.getId()))); return success(bean); diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/app/dishestype/DishesTypeAppController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/app/dishestype/DishesTypeAppController.java index b40fa2fc..8922fbeb 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/app/dishestype/DishesTypeAppController.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/app/dishestype/DishesTypeAppController.java @@ -75,7 +75,7 @@ public class DishesTypeAppController { // @PreAuthorize("@ss.hasPermission('t:dishes-type:query')") public CommonResult> getDishesTypePage(@Valid DishesTypePageReqVO pageReqVO) { pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - PageResult pageResult = dishesTypeService.getDishesTypePage(pageReqVO); + PageResult pageResult = dishesTypeService.getDishesTypePageApp(pageReqVO); return success(BeanUtils.toBean(pageResult, DishesTypeRespVO.class)); } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/dishes/DishesMapper.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/dishes/DishesMapper.java index 7a3f6edd..f9547092 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/dishes/DishesMapper.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/dishes/DishesMapper.java @@ -30,6 +30,7 @@ public interface DishesMapper extends BaseMapperX { .eqIfPresent(DishesDO::getDishesVipWeighPrice, reqVO.getDishesVipWeighPrice()) .eqIfPresent(DishesDO::getDishecCook, reqVO.getDishecCook()) .eqIfPresent(DishesDO::getDishecType, reqVO.getDishecType()) + .inIfPresent(DishesDO::getWeekTime, reqVO.getWeekTimes()) .betweenIfPresent(DishesDO::getCreateTime, reqVO.getCreateTime()) .orderByDesc(DishesDO::getId)); } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/dishestype/DishesTypeMapper.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/dishestype/DishesTypeMapper.java index e8fa20cb..95255534 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/dishestype/DishesTypeMapper.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/dishestype/DishesTypeMapper.java @@ -24,6 +24,7 @@ public interface DishesTypeMapper extends BaseMapperX { default PageResult selectPage(DishesTypePageReqVO reqVO) { return selectPage(reqVO, new LambdaQueryWrapperX() + .inIfPresent(DishesTypeDO::getId, reqVO.getIds()) .likeIfPresent(DishesTypeDO::getDishesTypeName, reqVO.getDishesTypeName()) .eqIfPresent(DishesTypeDO::getCarteenId,reqVO.getCarteenId()) .betweenIfPresent(DishesTypeDO::getCreateTime, reqVO.getCreateTime()) diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/dishes/DishesService.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/dishes/DishesService.java index 13b453d0..02b7c343 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/dishes/DishesService.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/dishes/DishesService.java @@ -63,6 +63,8 @@ public interface DishesService { */ PageResult getDishesPage(DishesPageReqVO pageReqVO); + PageResult getDishesPageApp(DishesPageReqVO pageReqVO); + Map getDishName(List ids); List getTodayDishes(); diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/dishes/DishesServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/dishes/DishesServiceImpl.java index 08bac649..d45bbc8d 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/dishes/DishesServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/dishes/DishesServiceImpl.java @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.system.service.dishes; import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.ObjUtil; +import cn.hutool.core.util.StrUtil; import cn.iocoder.yudao.framework.common.pojo.PageParam; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; @@ -67,6 +68,18 @@ public class DishesServiceImpl implements DishesService { // 插入 DishesDO dishes = BeanUtils.toBean(createReqVO, DishesDO.class); dishes.setDeleted(Boolean.FALSE); + + LocalDateTime today = LocalDateTime.now(); + int hour = today.getHour(); + String time = dishesMapper.getTime(hour); + String dayOfWeekInChinese = today.getDayOfWeek().getDisplayName(TextStyle.FULL, Locale.CHINESE); + if(StrUtil.isBlank(createReqVO.getWeekTime())){ + dishes.setWeekTime(dayOfWeekInChinese); + } + if(StrUtil.isBlank(createReqVO.getTimeSlot())){ + dishes.setTimeSlot(time); + } + //计算每g多少钱 BigDecimal dishesSumPrice = createReqVO.getDishesSumPrice(); BigDecimal dishesNumber = createReqVO.getDishesNumber(); @@ -220,6 +233,18 @@ public class DishesServiceImpl implements DishesService { return dishesMapper.selectPage(pageReqVO); } + @Override + public PageResult getDishesPageApp(DishesPageReqVO pageReqVO) { + LocalDateTime today = LocalDateTime.now(); + String dayOfWeekInChinese = today.getDayOfWeek().getDisplayName(TextStyle.FULL, Locale.CHINESE); + + ArrayList week = new ArrayList<>(); + week.add(dayOfWeekInChinese); + week.add("整周"); + pageReqVO.setWeekTimes(week); + return dishesMapper.selectPage(pageReqVO); + } + @Override public Map getDishName(List ids) { List dishesDOS = dishesMapper.selectList(Wrappers.lambdaQuery().in(DishesDO::getId, ids)); diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/dishestype/DishesTypeService.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/dishestype/DishesTypeService.java index 04851394..fa3f8ff9 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/dishestype/DishesTypeService.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/dishestype/DishesTypeService.java @@ -54,6 +54,9 @@ public interface DishesTypeService { * @return 菜品分类分页 */ PageResult getDishesTypePage(DishesTypePageReqVO pageReqVO); + + PageResult getDishesTypePageApp(DishesTypePageReqVO pageReqVO); + /** * @Description: 通过门店编号 获得菜品分类以及菜品名称 * @Author: qjq diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/dishestype/DishesTypeServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/dishestype/DishesTypeServiceImpl.java index 9bf8c343..b809a502 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/dishestype/DishesTypeServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/dishestype/DishesTypeServiceImpl.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.system.service.dishestype; +import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.map.MapUtil; import cn.hutool.core.util.ObjUtil; import cn.hutool.core.util.StrUtil; @@ -8,12 +9,14 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.module.system.controller.admin.dishestype.vo.DishesTypeListRespVO; import cn.iocoder.yudao.module.system.controller.admin.dishestype.vo.DishesTypePageReqVO; import cn.iocoder.yudao.module.system.controller.admin.dishestype.vo.DishesTypeSaveReqVO; +import cn.iocoder.yudao.module.system.dal.dataobject.dishes.DishesDO; import cn.iocoder.yudao.module.system.dal.dataobject.dishestype.DishesTypeDO; import cn.iocoder.yudao.module.system.dal.dataobject.orderdetail.OrderDetail; import cn.iocoder.yudao.module.system.dal.mysql.dishes.DishesMapper; import cn.iocoder.yudao.module.system.dal.mysql.dishestype.DishesTypeMapper; import cn.iocoder.yudao.module.system.enums.ErrorCodeConstants; import cn.iocoder.yudao.module.system.enums.TimePeriodEnum; +import cn.iocoder.yudao.module.system.service.dishes.DishesService; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; @@ -41,7 +44,7 @@ public class DishesTypeServiceImpl implements DishesTypeService { @Resource private DishesTypeMapper dishesTypeMapper; @Resource - private DishesMapper dishesMapper; + private DishesService dishesService; @Override public Long createDishesType(DishesTypeSaveReqVO createReqVO) { // 插入 @@ -85,6 +88,16 @@ public class DishesTypeServiceImpl implements DishesTypeService { return dishesTypeMapper.selectPage(pageReqVO); } + @Override + public PageResult getDishesTypePageApp(DishesTypePageReqVO pageReqVO) { + List todayDishes = dishesService.getTodayDishes(); + if(CollectionUtil.isNotEmpty(todayDishes)){ + List ids = todayDishes.stream().map(DishesDO::getDishecType).collect(Collectors.toList()); + pageReqVO.setIds(ids); + } + return dishesTypeMapper.selectPage(pageReqVO); + } + /** * @param carteenId * @param startTime