优化
This commit is contained in:
@ -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<String> weekTimes;
|
||||
|
||||
}
|
@ -23,4 +23,6 @@ public class DishesTypePageReqVO extends PageParam {
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
private List<String> ids;
|
||||
|
||||
}
|
@ -76,7 +76,7 @@ public class DishesAppController {
|
||||
@Operation(summary = "获得菜品管理分页")
|
||||
// @PreAuthorize("@ss.hasPermission('t:dishes:query')")
|
||||
public CommonResult<PageResult<DishesRespVO>> getDishesPage(@Valid DishesPageReqVO pageReqVO) {
|
||||
PageResult<DishesDO> pageResult = dishesService.getDishesPage(pageReqVO);
|
||||
PageResult<DishesDO> pageResult = dishesService.getDishesPageApp(pageReqVO);
|
||||
PageResult<DishesRespVO> bean = BeanUtils.toBean(pageResult, DishesRespVO.class);
|
||||
bean.getList().forEach(f-> f.setKcal(dishesNutritionService.getDishesNutritionKcal(f.getId())));
|
||||
return success(bean);
|
||||
|
@ -75,7 +75,7 @@ public class DishesTypeAppController {
|
||||
// @PreAuthorize("@ss.hasPermission('t:dishes-type:query')")
|
||||
public CommonResult<PageResult<DishesTypeRespVO>> getDishesTypePage(@Valid DishesTypePageReqVO pageReqVO) {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
PageResult<DishesTypeDO> pageResult = dishesTypeService.getDishesTypePage(pageReqVO);
|
||||
PageResult<DishesTypeDO> pageResult = dishesTypeService.getDishesTypePageApp(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, DishesTypeRespVO.class));
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,7 @@ public interface DishesMapper extends BaseMapperX<DishesDO> {
|
||||
.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));
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ public interface DishesTypeMapper extends BaseMapperX<DishesTypeDO> {
|
||||
|
||||
default PageResult<DishesTypeDO> selectPage(DishesTypePageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<DishesTypeDO>()
|
||||
.inIfPresent(DishesTypeDO::getId, reqVO.getIds())
|
||||
.likeIfPresent(DishesTypeDO::getDishesTypeName, reqVO.getDishesTypeName())
|
||||
.eqIfPresent(DishesTypeDO::getCarteenId,reqVO.getCarteenId())
|
||||
.betweenIfPresent(DishesTypeDO::getCreateTime, reqVO.getCreateTime())
|
||||
|
@ -63,6 +63,8 @@ public interface DishesService {
|
||||
*/
|
||||
PageResult<DishesDO> getDishesPage(DishesPageReqVO pageReqVO);
|
||||
|
||||
PageResult<DishesDO> getDishesPageApp(DishesPageReqVO pageReqVO);
|
||||
|
||||
Map<Long,String> getDishName(List<Long> ids);
|
||||
|
||||
List<DishesDO> getTodayDishes();
|
||||
|
@ -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<DishesDO> getDishesPageApp(DishesPageReqVO pageReqVO) {
|
||||
LocalDateTime today = LocalDateTime.now();
|
||||
String dayOfWeekInChinese = today.getDayOfWeek().getDisplayName(TextStyle.FULL, Locale.CHINESE);
|
||||
|
||||
ArrayList<String> week = new ArrayList<>();
|
||||
week.add(dayOfWeekInChinese);
|
||||
week.add("整周");
|
||||
pageReqVO.setWeekTimes(week);
|
||||
return dishesMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Long, String> getDishName(List<Long> ids) {
|
||||
List<DishesDO> dishesDOS = dishesMapper.selectList(Wrappers.<DishesDO>lambdaQuery().in(DishesDO::getId, ids));
|
||||
|
@ -54,6 +54,9 @@ public interface DishesTypeService {
|
||||
* @return 菜品分类分页
|
||||
*/
|
||||
PageResult<DishesTypeDO> getDishesTypePage(DishesTypePageReqVO pageReqVO);
|
||||
|
||||
PageResult<DishesTypeDO> getDishesTypePageApp(DishesTypePageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* @Description: 通过门店编号 获得菜品分类以及菜品名称
|
||||
* @Author: qjq
|
||||
|
@ -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<DishesTypeDO> getDishesTypePageApp(DishesTypePageReqVO pageReqVO) {
|
||||
List<DishesDO> todayDishes = dishesService.getTodayDishes();
|
||||
if(CollectionUtil.isNotEmpty(todayDishes)){
|
||||
List<String> ids = todayDishes.stream().map(DishesDO::getDishecType).collect(Collectors.toList());
|
||||
pageReqVO.setIds(ids);
|
||||
}
|
||||
return dishesTypeMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param carteenId
|
||||
* @param startTime
|
||||
|
Reference in New Issue
Block a user