每日统计
This commit is contained in:
@ -73,4 +73,6 @@ public class BusinessRespVO {
|
|||||||
private BigDecimal withdrawal;
|
private BigDecimal withdrawal;
|
||||||
|
|
||||||
private BigDecimal reduce;
|
private BigDecimal reduce;
|
||||||
|
|
||||||
|
private String time;
|
||||||
}
|
}
|
@ -0,0 +1,56 @@
|
|||||||
|
package cn.iocoder.yudao.module.member.controller.app.business;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
|
import cn.iocoder.yudao.module.member.controller.admin.business.vo.BusinessRespVO;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.dataobject.business.BusinessDO;
|
||||||
|
import cn.iocoder.yudao.module.member.service.business.BusinessService;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
|
|
||||||
|
@Tag(name = "管理后台 - 营业统计")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/t/business")
|
||||||
|
@Validated
|
||||||
|
public class AppBusinessController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private BusinessService businessService;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/data")
|
||||||
|
@Operation(summary = "获得营业统计")
|
||||||
|
public CommonResult<List<BusinessRespVO>> getBusinessPage(String time,Long carteenId,Integer type) {
|
||||||
|
List<BusinessRespVO> result = new ArrayList<>();
|
||||||
|
switch (type){
|
||||||
|
case 0:
|
||||||
|
result = businessService.getDay(time, carteenId);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
result = businessService.getWeek(time, carteenId);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
result = businessService.getMonth(time, carteenId);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return success(result);
|
||||||
|
}
|
||||||
|
}
|
@ -2,11 +2,13 @@ package cn.iocoder.yudao.module.member.service.business;
|
|||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.module.member.controller.admin.business.vo.BusinessPageReqVO;
|
import cn.iocoder.yudao.module.member.controller.admin.business.vo.BusinessPageReqVO;
|
||||||
|
import cn.iocoder.yudao.module.member.controller.admin.business.vo.BusinessRespVO;
|
||||||
import cn.iocoder.yudao.module.member.controller.admin.business.vo.BusinessSaveReqVO;
|
import cn.iocoder.yudao.module.member.controller.admin.business.vo.BusinessSaveReqVO;
|
||||||
import cn.iocoder.yudao.module.member.controller.admin.business.vo.StatisticsVo;
|
import cn.iocoder.yudao.module.member.controller.admin.business.vo.StatisticsVo;
|
||||||
import cn.iocoder.yudao.module.member.dal.dataobject.business.BusinessDO;
|
import cn.iocoder.yudao.module.member.dal.dataobject.business.BusinessDO;
|
||||||
|
|
||||||
import javax.validation.*;
|
import javax.validation.*;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 营业统计 Service 接口
|
* 营业统计 Service 接口
|
||||||
@ -56,4 +58,9 @@ public interface BusinessService {
|
|||||||
|
|
||||||
void updateStatistics(StatisticsVo vo);
|
void updateStatistics(StatisticsVo vo);
|
||||||
|
|
||||||
|
List<BusinessRespVO> getDay(String time,Long carteenId);
|
||||||
|
|
||||||
|
List<BusinessRespVO> getWeek(String time,Long carteenId);
|
||||||
|
|
||||||
|
List<BusinessRespVO> getMonth(String time,Long carteenId);
|
||||||
}
|
}
|
@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollectionUtil;
|
|||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.module.member.controller.admin.business.vo.BusinessPageReqVO;
|
import cn.iocoder.yudao.module.member.controller.admin.business.vo.BusinessPageReqVO;
|
||||||
|
import cn.iocoder.yudao.module.member.controller.admin.business.vo.BusinessRespVO;
|
||||||
import cn.iocoder.yudao.module.member.controller.admin.business.vo.BusinessSaveReqVO;
|
import cn.iocoder.yudao.module.member.controller.admin.business.vo.BusinessSaveReqVO;
|
||||||
import cn.iocoder.yudao.module.member.controller.admin.business.vo.StatisticsVo;
|
import cn.iocoder.yudao.module.member.controller.admin.business.vo.StatisticsVo;
|
||||||
import cn.iocoder.yudao.module.member.dal.dataobject.business.BusinessDO;
|
import cn.iocoder.yudao.module.member.dal.dataobject.business.BusinessDO;
|
||||||
@ -15,7 +16,9 @@ import cn.iocoder.yudao.module.member.dal.mysql.orderdetail.OrderDetailMapper;
|
|||||||
import cn.iocoder.yudao.module.member.enums.CostTypeEnum;
|
import cn.iocoder.yudao.module.member.enums.CostTypeEnum;
|
||||||
import cn.iocoder.yudao.module.member.enums.TimePeriodEnum;
|
import cn.iocoder.yudao.module.member.enums.TimePeriodEnum;
|
||||||
import cn.iocoder.yudao.module.member.service.orderdetail.OrderDetailService;
|
import cn.iocoder.yudao.module.member.service.orderdetail.OrderDetailService;
|
||||||
|
import cn.iocoder.yudao.module.member.util.MemberTimeUtils;
|
||||||
import cn.iocoder.yudao.module.system.enums.ErrorCodeConstants;
|
import cn.iocoder.yudao.module.system.enums.ErrorCodeConstants;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@ -26,10 +29,15 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|||||||
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.LocalTime;
|
import java.time.LocalTime;
|
||||||
import java.util.List;
|
import java.time.YearMonth;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.time.temporal.WeekFields;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
|
|
||||||
@ -121,6 +129,12 @@ public class BusinessServiceImpl implements BusinessService {
|
|||||||
if(ObjectUtil.isNotEmpty(vo.getTotalMoney())){
|
if(ObjectUtil.isNotEmpty(vo.getTotalMoney())){
|
||||||
businessDO.setTurnover(businessDO.getTurnover().add(vo.getTotalMoney()));
|
businessDO.setTurnover(businessDO.getTurnover().add(vo.getTotalMoney()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//客单价
|
||||||
|
if(businessDO.getOrderSum() != 0){
|
||||||
|
businessDO.setPriceAvg(businessDO.getTurnover().divide(new BigDecimal(businessDO.getOrderSum()), 2, RoundingMode.HALF_UP));
|
||||||
|
}
|
||||||
|
|
||||||
//减免金额
|
//减免金额
|
||||||
if(ObjectUtil.isNotEmpty(vo.getReduceMoney())){
|
if(ObjectUtil.isNotEmpty(vo.getReduceMoney())){
|
||||||
businessDO.setReduce(businessDO.getReduce().add(vo.getReduceMoney()));
|
businessDO.setReduce(businessDO.getReduce().add(vo.getReduceMoney()));
|
||||||
@ -142,7 +156,164 @@ public class BusinessServiceImpl implements BusinessService {
|
|||||||
businessMapper.updateById(businessDO);
|
businessMapper.updateById(businessDO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<BusinessRespVO> getDay(String time,Long carteenId) {
|
||||||
|
|
||||||
|
LambdaQueryWrapper<BusinessDO> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(BusinessDO::getCarteenId,carteenId);
|
||||||
|
wrapper.orderByAsc(BusinessDO::getCreateTime);
|
||||||
|
wrapper.apply("DATE_FORMAT(create_time, '%Y-%m') = {0}", time);
|
||||||
|
List<BusinessDO> businessDOS = businessMapper.selectList(wrapper);
|
||||||
|
|
||||||
|
Map<String, BusinessDO> map = businessDOS.stream().collect(Collectors.toMap(vo -> vo.getCreateTime().format(DateTimeFormatter.ofPattern("dd"))
|
||||||
|
, vo -> vo, (existing, replacement) -> existing));
|
||||||
|
|
||||||
|
// 创建一个Map来存储每天的数据
|
||||||
|
Map<String, BusinessRespVO> monthData = new LinkedHashMap<>();
|
||||||
|
|
||||||
|
|
||||||
|
// 定义日期格式化器
|
||||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM");
|
||||||
|
|
||||||
|
// 将字符串解析为 YearMonth 对象
|
||||||
|
YearMonth yearMonth = YearMonth.parse(time, formatter);
|
||||||
|
|
||||||
|
// 获取当月的总天数
|
||||||
|
int daysInMonth = yearMonth.lengthOfMonth();
|
||||||
|
|
||||||
|
// 定义一个格式化器,格式为 "dd"(两位数的日期)
|
||||||
|
DateTimeFormatter dayFormatter = DateTimeFormatter.ofPattern("dd");
|
||||||
|
|
||||||
|
// 循环遍历该月的每一天
|
||||||
|
for (int day = 1; day <= daysInMonth; day++) {
|
||||||
|
// 获取当前日期
|
||||||
|
LocalDate date = yearMonth.atDay(day);
|
||||||
|
|
||||||
|
// 格式化日期为两位数的形式
|
||||||
|
String key = date.format(dayFormatter);
|
||||||
|
|
||||||
|
if(map.get(key) == null){
|
||||||
|
BusinessRespVO bean = new BusinessRespVO();
|
||||||
|
bean.setTurnover(BigDecimal.ZERO).setOrderSum(0).setReduce(BigDecimal.ZERO).setWeigh(BigDecimal.ZERO)
|
||||||
|
.setBreakfast(BigDecimal.ZERO).setLunch(BigDecimal.ZERO).setDinner(BigDecimal.ZERO)
|
||||||
|
.setTime(key);
|
||||||
|
monthData.put(key,bean);
|
||||||
|
}else {
|
||||||
|
BusinessRespVO bean = BeanUtils.toBean(map.get(key), BusinessRespVO.class);
|
||||||
|
bean.setTime(key);
|
||||||
|
monthData.put(key,bean);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return new ArrayList<>(monthData.values());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<BusinessRespVO> getWeek(String time,Long carteenId) {
|
||||||
|
|
||||||
|
LambdaQueryWrapper<BusinessDO> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(BusinessDO::getCarteenId,carteenId);
|
||||||
|
wrapper.orderByAsc(BusinessDO::getCreateTime);
|
||||||
|
wrapper.apply("DATE_FORMAT(create_time, '%Y-%m') = {0}", time);
|
||||||
|
List<BusinessDO> businessDOS = businessMapper.selectList(wrapper);
|
||||||
|
|
||||||
|
Map<Integer,BusinessRespVO> map = new HashMap<>();
|
||||||
|
|
||||||
|
int totalWeeksOfMonth = MemberTimeUtils.getTotalWeeksOfMonth(time);
|
||||||
|
for (int i = 1; i <= totalWeeksOfMonth; i++) {
|
||||||
|
BusinessRespVO bean = new BusinessRespVO();
|
||||||
|
bean.setTurnover(BigDecimal.ZERO).setOrderSum(0).setReduce(BigDecimal.ZERO).setWeigh(BigDecimal.ZERO)
|
||||||
|
.setBreakfast(BigDecimal.ZERO).setLunch(BigDecimal.ZERO).setDinner(BigDecimal.ZERO)
|
||||||
|
.setTime(String.valueOf(i));
|
||||||
|
map.put(i,bean);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (BusinessDO businessDO : businessDOS) {
|
||||||
|
|
||||||
|
LocalDate date = businessDO.getCreateTime().toLocalDate();
|
||||||
|
|
||||||
|
// 获取区域的周定义(可以是ISO标准或其他区域标准)
|
||||||
|
WeekFields weekFields = WeekFields.of(Locale.getDefault());
|
||||||
|
|
||||||
|
// 使用weekFields获取当前日期属于当月的第几周
|
||||||
|
int i = date.get(weekFields.weekOfMonth());
|
||||||
|
BusinessRespVO businessRespVO = map.get(i);
|
||||||
|
|
||||||
|
//营业额
|
||||||
|
businessRespVO.setTurnover(businessRespVO.getTurnover().add(businessDO.getTurnover()));
|
||||||
|
//订单数
|
||||||
|
businessRespVO.setOrderSum(businessRespVO.getOrderSum()+businessDO.getOrderSum());
|
||||||
|
//均单价
|
||||||
|
businessRespVO.setPriceAvg(businessDO.getTurnover().divide(new BigDecimal(businessDO.getOrderSum()), 2, RoundingMode.HALF_UP));
|
||||||
|
//减免金额
|
||||||
|
businessRespVO.setReduce(businessRespVO.getReduce().add(businessDO.getReduce()));
|
||||||
|
//重量
|
||||||
|
businessRespVO.setWeigh(businessRespVO.getWeigh().add(businessDO.getWeigh()));
|
||||||
|
//早
|
||||||
|
businessRespVO.setBreakfast(businessRespVO.getBreakfast().add(businessDO.getBreakfast()));
|
||||||
|
//中
|
||||||
|
businessRespVO.setLunch(businessRespVO.getLunch().add(businessDO.getLunch()));
|
||||||
|
//晚
|
||||||
|
businessRespVO.setDinner(businessRespVO.getDinner().add(businessDO.getDinner()));
|
||||||
|
//门店
|
||||||
|
businessRespVO.setCarteenId(businessDO.getCarteenId());
|
||||||
|
}
|
||||||
|
return new ArrayList<>(map.values());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<BusinessRespVO> getMonth(String time,Long carteenId) {
|
||||||
|
|
||||||
|
int year = MemberTimeUtils.getYearFromYearMonthString(time);
|
||||||
|
|
||||||
|
LambdaQueryWrapper<BusinessDO> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(BusinessDO::getCarteenId,carteenId);
|
||||||
|
wrapper.orderByAsc(BusinessDO::getCreateTime);
|
||||||
|
wrapper.apply("DATE_FORMAT(create_time, '%Y') = {0}", year);
|
||||||
|
List<BusinessDO> businessDOS = businessMapper.selectList(wrapper);
|
||||||
|
|
||||||
|
Map<Integer,BusinessRespVO> map = new HashMap<>();
|
||||||
|
|
||||||
|
for (int i = 1; i <= 12; i++) {
|
||||||
|
BusinessRespVO bean = new BusinessRespVO();
|
||||||
|
bean.setTurnover(BigDecimal.ZERO).setOrderSum(0).setReduce(BigDecimal.ZERO).setWeigh(BigDecimal.ZERO)
|
||||||
|
.setBreakfast(BigDecimal.ZERO).setLunch(BigDecimal.ZERO).setDinner(BigDecimal.ZERO)
|
||||||
|
.setTime(String.valueOf(i));
|
||||||
|
map.put(i,bean);
|
||||||
|
}
|
||||||
|
for (BusinessDO businessDO : businessDOS) {
|
||||||
|
|
||||||
|
LocalDate date = businessDO.getCreateTime().toLocalDate();
|
||||||
|
|
||||||
|
// 使用weekFields获取当前日期属于当月的第几周
|
||||||
|
int i = date.getMonthValue();
|
||||||
|
|
||||||
|
BusinessRespVO businessRespVO = map.get(i);
|
||||||
|
|
||||||
|
//营业额
|
||||||
|
businessRespVO.setTurnover(businessRespVO.getTurnover().add(businessDO.getTurnover()));
|
||||||
|
//订单数
|
||||||
|
businessRespVO.setOrderSum(businessRespVO.getOrderSum()+businessDO.getOrderSum());
|
||||||
|
//均单价
|
||||||
|
businessRespVO.setPriceAvg(businessDO.getTurnover().divide(new BigDecimal(businessDO.getOrderSum()), 2, RoundingMode.HALF_UP));
|
||||||
|
//减免金额
|
||||||
|
businessRespVO.setReduce(businessRespVO.getReduce().add(businessDO.getReduce()));
|
||||||
|
//重量
|
||||||
|
businessRespVO.setWeigh(businessRespVO.getWeigh().add(businessDO.getWeigh()));
|
||||||
|
//早
|
||||||
|
businessRespVO.setBreakfast(businessRespVO.getBreakfast().add(businessDO.getBreakfast()));
|
||||||
|
//中
|
||||||
|
businessRespVO.setLunch(businessRespVO.getLunch().add(businessDO.getLunch()));
|
||||||
|
//晚
|
||||||
|
businessRespVO.setDinner(businessRespVO.getDinner().add(businessDO.getDinner()));
|
||||||
|
//门店
|
||||||
|
businessRespVO.setCarteenId(businessDO.getCarteenId());
|
||||||
|
}
|
||||||
|
return new ArrayList<>(map.values());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -0,0 +1,44 @@
|
|||||||
|
package cn.iocoder.yudao.module.member.util;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.YearMonth;
|
||||||
|
import java.time.temporal.WeekFields;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
public class MemberTimeUtils {
|
||||||
|
|
||||||
|
// 获取指定月份总共有几周
|
||||||
|
public static int getTotalWeeksOfMonth(String yearMonthString) {
|
||||||
|
// 获取该月的第一天和最后一天
|
||||||
|
LocalDate firstDayOfMonth = convertToLocalDate(yearMonthString, true);
|
||||||
|
LocalDate lastDayOfMonth = firstDayOfMonth.withDayOfMonth(firstDayOfMonth.lengthOfMonth());
|
||||||
|
|
||||||
|
// 获取区域的周定义(可以是ISO标准或其他区域标准)
|
||||||
|
WeekFields weekFields = WeekFields.of(Locale.getDefault());
|
||||||
|
|
||||||
|
// 获取第一天和最后一天的周数
|
||||||
|
int firstWeek = firstDayOfMonth.get(weekFields.weekOfMonth());
|
||||||
|
int lastWeek = lastDayOfMonth.get(weekFields.weekOfMonth());
|
||||||
|
|
||||||
|
// 计算总周数
|
||||||
|
return lastWeek - firstWeek + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 将"yyyy-MM"字符串转换为LocalDate,并决定是该月的第一天还是最后一天
|
||||||
|
public static LocalDate convertToLocalDate(String yearMonthString, boolean isFirstDay) {
|
||||||
|
// 使用YearMonth类处理"yyyy-MM"格式
|
||||||
|
YearMonth yearMonth = YearMonth.parse(yearMonthString);
|
||||||
|
|
||||||
|
// 如果isFirstDay为true,则返回该月的第一天,否则返回最后一天
|
||||||
|
return isFirstDay ? yearMonth.atDay(1) : yearMonth.atEndOfMonth();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 从"yyyy-MM"字符串中提取年份
|
||||||
|
public static int getYearFromYearMonthString(String yearMonthString) {
|
||||||
|
// 使用YearMonth类解析字符串
|
||||||
|
YearMonth yearMonth = YearMonth.parse(yearMonthString);
|
||||||
|
|
||||||
|
// 返回年份
|
||||||
|
return yearMonth.getYear();
|
||||||
|
}
|
||||||
|
}
|
@ -19,12 +19,10 @@ public class DishImagePageReqVO extends PageParam {
|
|||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@Schema(description = "开始日期")
|
@Schema(description = "开始日期")
|
||||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
private String startDate;
|
||||||
private String[] startDate;
|
|
||||||
|
|
||||||
@Schema(description = "结束日期")
|
@Schema(description = "结束日期")
|
||||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
private String endDate;
|
||||||
private String[] endDate;
|
|
||||||
|
|
||||||
@Schema(description = "地址", example = "https://www.iocoder.cn")
|
@Schema(description = "地址", example = "https://www.iocoder.cn")
|
||||||
private String imageUrl;
|
private String imageUrl;
|
||||||
|
@ -22,4 +22,13 @@ public class AppSaveVO {
|
|||||||
|
|
||||||
@Schema(description = "总价格", example = "1")
|
@Schema(description = "总价格", example = "1")
|
||||||
private BigDecimal dishesSumPrice;
|
private BigDecimal dishesSumPrice;
|
||||||
|
|
||||||
|
@Schema(description = "菜品图片", example = "1")
|
||||||
|
private String dishesImageUrl;
|
||||||
|
|
||||||
|
@Schema(description = "周几", example = "星期一")
|
||||||
|
private String weekTime;
|
||||||
|
|
||||||
|
@Schema(description = "时段", example = "早")
|
||||||
|
private String timeSlot;
|
||||||
}
|
}
|
||||||
|
@ -23,8 +23,8 @@ public interface DishImageMapper extends BaseMapperX<DishImageDO> {
|
|||||||
return selectPage(reqVO, new LambdaQueryWrapperX<DishImageDO>()
|
return selectPage(reqVO, new LambdaQueryWrapperX<DishImageDO>()
|
||||||
.eqIfPresent(DishImageDO::getCarteenId,reqVO.getCarteenId())
|
.eqIfPresent(DishImageDO::getCarteenId,reqVO.getCarteenId())
|
||||||
.likeIfPresent(DishImageDO::getName, reqVO.getName())
|
.likeIfPresent(DishImageDO::getName, reqVO.getName())
|
||||||
.betweenIfPresent(DishImageDO::getStartDate, reqVO.getStartDate())
|
.eqIfPresent(DishImageDO::getStartDate, reqVO.getStartDate())
|
||||||
.betweenIfPresent(DishImageDO::getEndDate, reqVO.getEndDate())
|
.eqIfPresent(DishImageDO::getEndDate, reqVO.getEndDate())
|
||||||
.eqIfPresent(DishImageDO::getImageUrl, reqVO.getImageUrl())
|
.eqIfPresent(DishImageDO::getImageUrl, reqVO.getImageUrl())
|
||||||
.eqIfPresent(DishImageDO::getRemark, reqVO.getRemark())
|
.eqIfPresent(DishImageDO::getRemark, reqVO.getRemark())
|
||||||
.betweenIfPresent(DishImageDO::getCreateTime, reqVO.getCreateTime())
|
.betweenIfPresent(DishImageDO::getCreateTime, reqVO.getCreateTime())
|
||||||
|
@ -69,6 +69,8 @@ public class DishesServiceImpl implements DishesService {
|
|||||||
DishesDO dishes = BeanUtils.toBean(createReqVO, DishesDO.class);
|
DishesDO dishes = BeanUtils.toBean(createReqVO, DishesDO.class);
|
||||||
dishes.setDeleted(Boolean.FALSE);
|
dishes.setDeleted(Boolean.FALSE);
|
||||||
|
|
||||||
|
checkDishes(dishes.getDishesName(),dishes.getCarteenId());
|
||||||
|
|
||||||
LocalDateTime today = LocalDateTime.now();
|
LocalDateTime today = LocalDateTime.now();
|
||||||
int hour = today.getHour();
|
int hour = today.getHour();
|
||||||
String time = dishesMapper.getTime(hour);
|
String time = dishesMapper.getTime(hour);
|
||||||
@ -115,6 +117,8 @@ public class DishesServiceImpl implements DishesService {
|
|||||||
dishes.setCarteenId(carteenId);
|
dishes.setCarteenId(carteenId);
|
||||||
dishes.setDishesNumber(new BigDecimal("50"));
|
dishes.setDishesNumber(new BigDecimal("50"));
|
||||||
|
|
||||||
|
checkDishes(dishes.getDishesName(),dishes.getCarteenId());
|
||||||
|
|
||||||
LocalDateTime today = LocalDateTime.now();
|
LocalDateTime today = LocalDateTime.now();
|
||||||
int hour = today.getHour();
|
int hour = today.getHour();
|
||||||
String time = dishesMapper.getTime(hour);
|
String time = dishesMapper.getTime(hour);
|
||||||
@ -144,6 +148,8 @@ public class DishesServiceImpl implements DishesService {
|
|||||||
// 更新
|
// 更新
|
||||||
DishesDO updateObj = BeanUtils.toBean(updateReqVO, DishesDO.class);
|
DishesDO updateObj = BeanUtils.toBean(updateReqVO, DishesDO.class);
|
||||||
|
|
||||||
|
checkDishes(updateObj.getDishesName(),updateObj.getCarteenId());
|
||||||
|
|
||||||
//计算每g多少钱
|
//计算每g多少钱
|
||||||
BigDecimal dishesSumPrice = updateObj.getDishesSumPrice();
|
BigDecimal dishesSumPrice = updateObj.getDishesSumPrice();
|
||||||
BigDecimal dishesNumber = updateObj.getDishesNumber();
|
BigDecimal dishesNumber = updateObj.getDishesNumber();
|
||||||
@ -169,8 +175,11 @@ public class DishesServiceImpl implements DishesService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateDishesApp(AppUpdateVO vo) {
|
public void updateDishesApp(AppUpdateVO vo) {
|
||||||
|
validateDishesExists(vo.getId());
|
||||||
DishesDO updateObj = BeanUtils.toBean(vo, DishesDO.class);
|
DishesDO updateObj = BeanUtils.toBean(vo, DishesDO.class);
|
||||||
|
|
||||||
|
checkDishes(updateObj.getDishesName(),updateObj.getCarteenId());
|
||||||
|
|
||||||
//计算每g多少钱
|
//计算每g多少钱
|
||||||
BigDecimal dishesSumPrice = updateObj.getDishesSumPrice();
|
BigDecimal dishesSumPrice = updateObj.getDishesSumPrice();
|
||||||
BigDecimal dishesNumber = new BigDecimal("50");
|
BigDecimal dishesNumber = new BigDecimal("50");
|
||||||
@ -292,12 +301,21 @@ public class DishesServiceImpl implements DishesService {
|
|||||||
week.add(dayOfWeekInChinese);
|
week.add(dayOfWeekInChinese);
|
||||||
week.add("整周");
|
week.add("整周");
|
||||||
|
|
||||||
// Long carteenId = deviceInfoService.getCarteen(getHearder());
|
|
||||||
List<DishesDO> dishesDOS = dishesMapper.selectList(Wrappers.<DishesDO>lambdaQuery()
|
List<DishesDO> dishesDOS = dishesMapper.selectList(Wrappers.<DishesDO>lambdaQuery()
|
||||||
// .eq(DishesDO::getCarteenId, carteenId)
|
|
||||||
.in(DishesDO::getWeekTime, week)
|
.in(DishesDO::getWeekTime, week)
|
||||||
.orderByDesc(DishesDO::getCreateTime));
|
.orderByDesc(DishesDO::getCreateTime));
|
||||||
return dishesDOS;
|
return dishesDOS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void checkDishes(String dishName,Long carteenId){
|
||||||
|
List<DishesDO> dishesDOS = dishesMapper.selectList(Wrappers.<DishesDO>lambdaQuery()
|
||||||
|
.eq(DishesDO::getCarteenId, carteenId)
|
||||||
|
.eq(DishesDO::getDishesName, dishName));
|
||||||
|
|
||||||
|
if(!dishesDOS.isEmpty()){
|
||||||
|
throw exception(2000_10_002, "菜品名称已存在");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Reference in New Issue
Block a user