一周菜谱

This commit is contained in:
sxu 2025-02-07 12:52:41 +08:00
parent b0ac8fdb21
commit d2fe380be0
10 changed files with 403 additions and 524 deletions

View File

@ -0,0 +1,134 @@
package com.bonus.core.allocation.canteen.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.math.BigDecimal;
import java.time.LocalTime;
@ApiModel("配送设置DTO")
public class AllocCanteenDeliveryDTO {
@ApiModelProperty("配送方式")
private Integer deliveryType;
@ApiModelProperty("取餐点名称")
private String foodPlaceNames;
@ApiModelProperty("配送费")
private BigDecimal deliveryAmount;
@ApiModelProperty("起送价")
private BigDecimal basePrice;
@ApiModelProperty("包装费")
private BigDecimal packingFee;
@ApiModelProperty("平均配送时间")
private Integer avgDeliveryMinute;
@ApiModelProperty("配送时间段")
private LocalTime deliveryStartTime;
@ApiModelProperty("配送时间段")
private LocalTime deliveryEndTime;
@ApiModelProperty("超时提醒时间")
private Integer timeoutReminderMinute;
@ApiModelProperty("超时清理时间")
private Integer timeoutCleanMinute;
public boolean validBasePrice(BigDecimal targetBasePrice) {
if (this.basePrice == null) {
return true;
} else if (targetBasePrice == null) {
return false;
} else {
return this.basePrice.compareTo(targetBasePrice) <= 0;
}
}
public boolean needFee() {
return this.deliveryAmount != null || this.packingFee != null;
}
public BigDecimal calcDeliveryAmountForOrder() {
return this.deliveryAmount != null ? this.deliveryAmount : BigDecimal.ZERO;
}
public BigDecimal calcPackingAmountForOrder() {
return this.packingFee != null ? this.packingFee : BigDecimal.ZERO;
}
public Integer getDeliveryType() {
return this.deliveryType;
}
public String getFoodPlaceNames() {
return this.foodPlaceNames;
}
public BigDecimal getDeliveryAmount() {
return this.deliveryAmount;
}
public BigDecimal getBasePrice() {
return this.basePrice;
}
public BigDecimal getPackingFee() {
return this.packingFee;
}
public Integer getAvgDeliveryMinute() {
return this.avgDeliveryMinute;
}
public LocalTime getDeliveryStartTime() {
return this.deliveryStartTime;
}
public LocalTime getDeliveryEndTime() {
return this.deliveryEndTime;
}
public Integer getTimeoutReminderMinute() {
return this.timeoutReminderMinute;
}
public Integer getTimeoutCleanMinute() {
return this.timeoutCleanMinute;
}
public void setDeliveryType(final Integer deliveryType) {
this.deliveryType = deliveryType;
}
public void setFoodPlaceNames(final String foodPlaceNames) {
this.foodPlaceNames = foodPlaceNames;
}
public void setDeliveryAmount(final BigDecimal deliveryAmount) {
this.deliveryAmount = deliveryAmount;
}
public void setBasePrice(final BigDecimal basePrice) {
this.basePrice = basePrice;
}
public void setPackingFee(final BigDecimal packingFee) {
this.packingFee = packingFee;
}
public void setAvgDeliveryMinute(final Integer avgDeliveryMinute) {
this.avgDeliveryMinute = avgDeliveryMinute;
}
public void setDeliveryStartTime(final LocalTime deliveryStartTime) {
this.deliveryStartTime = deliveryStartTime;
}
public void setDeliveryEndTime(final LocalTime deliveryEndTime) {
this.deliveryEndTime = deliveryEndTime;
}
public void setTimeoutReminderMinute(final Integer timeoutReminderMinute) {
this.timeoutReminderMinute = timeoutReminderMinute;
}
public void setTimeoutCleanMinute(final Integer timeoutCleanMinute) {
this.timeoutCleanMinute = timeoutCleanMinute;
}
}

View File

@ -0,0 +1,65 @@
package com.bonus.core.allocation.canteen.model;
import io.swagger.annotations.ApiModelProperty;
import com.bonus.core.allocation.canteen.dto.AllocCanteenDeliveryDTO;
import com.bonus.core.common.enums.DeliveryTypeEnum;
import java.math.BigDecimal;
public class AllocDeliveryCostModel {
@ApiModelProperty("配送方式")
private Integer deliveryType;
@ApiModelProperty("配送名称")
private String deliveryName;
@ApiModelProperty("配送费")
private BigDecimal deliveryAmount;
@ApiModelProperty("包装费")
private BigDecimal packingFee;
public AllocDeliveryCostModel(AllocCanteenDeliveryDTO deliveryDTO) {
this.deliveryType = deliveryDTO.getDeliveryType();
this.deliveryName = DeliveryTypeEnum.getDesc(deliveryDTO.getDeliveryType());
this.deliveryAmount = deliveryDTO.getDeliveryAmount();
this.packingFee = deliveryDTO.getPackingFee();
}
public AllocDeliveryCostModel(Integer deliveryType) {
this.deliveryType = deliveryType;
this.deliveryName = DeliveryTypeEnum.getDesc(deliveryType);
}
public Integer getDeliveryType() {
return this.deliveryType;
}
public String getDeliveryName() {
return this.deliveryName;
}
public BigDecimal getDeliveryAmount() {
return this.deliveryAmount;
}
public BigDecimal getPackingFee() {
return this.packingFee;
}
public void setDeliveryType(final Integer deliveryType) {
this.deliveryType = deliveryType;
}
public void setDeliveryName(final String deliveryName) {
this.deliveryName = deliveryName;
}
public void setDeliveryAmount(final BigDecimal deliveryAmount) {
this.deliveryAmount = deliveryAmount;
}
public void setPackingFee(final BigDecimal packingFee) {
this.packingFee = packingFee;
}
public AllocDeliveryCostModel() {
}
}

View File

@ -0,0 +1,96 @@
package com.bonus.core.common.enums;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
//public enum DeliveryTypeEnum implements LeExcelFieldEnum<DeliveryTypeEnum> {
public enum DeliveryTypeEnum {
SELF_TAKE(1, "自取堂食"),
MERCHANT(2, "商家配送"),
DINING_CABINET(3, "取餐柜配送"),
FRESH_CABINET(4, "生鲜柜配送"),
TAKE_OUT(5, "自取外带"),
FOOD_PLACE(6, "取餐点自取"),
TAKEAWAY(7, "外卖配送"),
TAKEAWAY_STORE(8, "外卖到店"),
NONE(0, "无配送");
private final Integer key;
private final String desc;
private DeliveryTypeEnum(Integer key, String desc) {
this.key = key;
this.desc = desc;
}
public static String getDesc(Integer key) {
DeliveryTypeEnum[] var1 = values();
int var2 = var1.length;
for(int var3 = 0; var3 < var2; ++var3) {
DeliveryTypeEnum temp = var1[var3];
if (temp.getKey().equals(key)) {
return temp.getDesc();
}
}
return "";
}
public static DeliveryTypeEnum getTypeEnum(Integer key) {
DeliveryTypeEnum[] var1 = values();
int var2 = var1.length;
for(int var3 = 0; var3 < var2; ++var3) {
DeliveryTypeEnum typeEnum = var1[var3];
if (typeEnum.getKey().equals(key)) {
return typeEnum;
}
}
return NONE;
}
public static List<Map<String, Object>> getAllEnumsList() {
DeliveryTypeEnum[] enums = values();
List<Map<String, Object>> list = new ArrayList();
DeliveryTypeEnum[] var2 = enums;
int var3 = enums.length;
for(int var4 = 0; var4 < var3; ++var4) {
DeliveryTypeEnum typeEnum = var2[var4];
if (!NONE.getKey().equals(typeEnum.getKey())) {
Map<String, Object> map = new HashMap();
map.put("key", typeEnum.getKey());
map.put("value", typeEnum.getDesc());
list.add(map);
}
}
return list;
}
public static boolean isNeedDeliveryType(Integer key) {
return MERCHANT.getKey().equals(key) || DINING_CABINET.getKey().equals(key) || FRESH_CABINET.getKey().equals(key);
}
public static boolean isValidType(Integer key) {
return getTypeEnum(key) != NONE;
}
public Integer getKey() {
return this.key;
}
public String getDesc() {
return this.desc;
}
// public static class ExcelConvertor extends LeExcelFieldConvertor<DeliveryTypeEnum> {
// public ExcelConvertor() {
// super(DeliveryTypeEnum.class);
// }
// }
}

View File

@ -0,0 +1,12 @@
package com.bonus.core.menu.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.bonus.core.menu.entity.MenuRecipeDishes;
import org.apache.ibatis.annotations.Mapper;
import java.util.Collection;
@Mapper
public interface MenuRecipeDishesMapper extends BaseMapper<MenuRecipeDishes> {
Integer insertValues(Collection<MenuRecipeDishes> list);
}

View File

@ -3,6 +3,7 @@ package com.bonus.core.menu.service;
import com.bonus.core.menu.dto.CheckDishesDto;
import com.bonus.core.menu.dto.OrderRecipeDishesDto;
import com.bonus.core.menu.entity.MenuRecipeDishes;
import com.bonus.core.menu.vo.CheckDishesVo;
import java.time.LocalDate;
import java.util.Collection;
@ -11,15 +12,5 @@ import java.util.Map;
import java.util.Set;
public interface MenuRecipeDishesService {
Boolean deleteByDetailId(Long detailId);
OrderRecipeDishesDto getOrderDishesDetail(Long detailId, Long dishesId);
Map<Long, Integer> getDishesCountByRecipeIds(List<Long> recipeIds);
Map<LocalDate, Set<Integer>> queryDishesByDate(List<LocalDate> dates, Long recipeId, Long dishesId);
List<CheckDishesVo> checkDishes(List<CheckDishesDto> checkDishes, Integer orderType);
boolean saveBatch(Collection<MenuRecipeDishes> entityList);
}

View File

@ -1,10 +1,17 @@
package com.bonus.core.menu.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.bonus.core.menu.dto.AppletWeekCanteenDTO;
import com.bonus.core.menu.dto.AppletWeekRecipeDTO;
import com.bonus.core.menu.entity.MenuRecipe;
import com.bonus.core.menu.vo.AppletWeekCanteenVO;
import com.bonus.core.menu.vo.AppletWeekRecipeVO;
import java.util.List;
public interface MenuRecipeService {
public interface MenuRecipeService extends IService<MenuRecipe> {
List<AppletWeekCanteenVO> getWeekMealList(AppletWeekCanteenDTO content);
List<AppletWeekRecipeVO> getWeekRecipeDetailList(AppletWeekRecipeDTO content);
}

View File

@ -2,16 +2,12 @@ package com.bonus.core.menu.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
import com.bonus.core.menu.entity.MenuRecipeDishes;
import com.bonus.core.menu.mapper.MenuRecipeDishesMapper;
import com.bonus.core.menu.service.MenuRecipeDishesService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import java.lang.invoke.SerializedLambda;
import java.math.BigDecimal;
@ -24,197 +20,20 @@ import java.util.stream.Collectors;
@Service
public class MenuRecipeDishesServiceImpl implements MenuRecipeDishesService {
private static final Logger log = LoggerFactory.getLogger(MenuRecipeDishesServiceImpl.class);
@Autowired
@Lazy
private MenuDishesService menuDishesService;
@Autowired
@Lazy
private MenuRecipeDetailService menuRecipeDetailService;
@Autowired
private MenuRecipeMapper menuRecipeMapper;
@Autowired
private AllocDeliveryApi allocDeliveryApi;
@Autowired
private AllocMealtimeApi allocMealtimeApi;
@Autowired
private MenuAppRecipeMapper menuAppRecipeMapper;
public Boolean deleteByDetailId(Long detailId) {
return this.remove((Wrapper)Wrappers.lambdaQuery().eq(MenuRecipeDishes::getDetailId, detailId));
}
public OrderRecipeDishesDto getOrderDishesDetail(Long detailId, Long dishesId) {
MenuRecipeDetail menuRecipeDetail = (MenuRecipeDetail)this.menuRecipeDetailService.getOne((Wrapper)Wrappers.lambdaQuery(MenuRecipeDetail.class).select(new SFunction[]{MenuRecipeDetail::getRecipeId}).eq(MenuRecipeDetail::getDetailId, detailId));
if (ObjectUtil.isNull(menuRecipeDetail)) {
throw new LeException("菜谱已更新,请刷新页面重新点餐");
} else {
String redisKey = String.format("yst:%s:recipe:%s:detail:%s:dishes:%s:order:query", TenantContextHolder.getTenantId(), menuRecipeDetail.getRecipeId(), detailId, dishesId);
Object obj = RedisUtil.getObj(redisKey);
if (obj instanceof OrderRecipeDishesDto) {
OrderRecipeDishesDto o = (OrderRecipeDishesDto)obj;
log.info("取redis缓存,详情: {}", JSON.toJSONString(obj));
return o;
} else {
MenuRecipeDishes menuRecipeDishes = (MenuRecipeDishes)this.getOne((Wrapper)((LambdaQueryWrapper)Wrappers.lambdaQuery(MenuRecipeDishes.class).eq(MenuRecipeDishes::getDishesId, dishesId)).eq(MenuRecipeDishes::getDetailId, detailId));
MenuDishes menuDishes = (MenuDishes)this.menuDishesService.getOne((Wrapper)Wrappers.lambdaQuery(MenuDishes.class).eq(MenuDishes::getDishesId, dishesId));
OrderRecipeDishesDto orderRecipeDishesDto = (OrderRecipeDishesDto)BeanUtil.copyProperties(menuRecipeDishes, OrderRecipeDishesDto.class, new String[0]);
orderRecipeDishesDto.setSalesMode(menuDishes.getSalesMode());
orderRecipeDishesDto.setUnitPrice(menuDishes.getUnitPrice());
orderRecipeDishesDto.setImageUrl(menuDishes.getImageUrl());
orderRecipeDishesDto.setDishesName(menuDishes.getDishesName());
log.info("查询数据库信息,详情: {}", JSON.toJSONString(orderRecipeDishesDto));
RedisUtil.setObj(redisKey, orderRecipeDishesDto, 86400L);
return orderRecipeDishesDto;
}
}
}
public Map<Long, Integer> getDishesCountByRecipeIds(List<Long> recipeIds) {
List<RecipeDishesCountDto> dishesCountByRecipeIds = ((MenuRecipeDishesMapper)this.baseMapper).getDishesCountByRecipeIds(recipeIds);
return (Map)dishesCountByRecipeIds.stream().collect(Collectors.toMap(RecipeDishesCountDto::getRecipeId, RecipeDishesCountDto::getNum));
}
public Map<LocalDate, Set<Integer>> queryDishesByDate(List<LocalDate> dates, Long recipeId, Long dishesId) {
List<ExistDateDto> existDateDtos = ((MenuRecipeDishesMapper)this.baseMapper).queryDishesByDate(dates, recipeId, dishesId);
return (Map)existDateDtos.stream().collect(Collectors.groupingBy(ExistDateDto::getApplyDate, Collectors.mapping(ExistDateDto::getMealtimeType, Collectors.toSet())));
}
public List<CheckDishesVo> checkDishes(List<CheckDishesDto> checkDishes, Integer orderType) {
List<Long> dishesIds = (List)checkDishes.stream().map(CheckDishesDto::getGoodsDishesId).collect(Collectors.toList());
Map<Long, MenuDishes> dishesMap = (Map)this.menuDishesService.getMenuDishesList(dishesIds).stream().collect(Collectors.toMap(MenuDishes::getDishesId, Function.identity()));
return (List)checkDishes.stream().map((checkDish) -> {
CheckDishesVo checkDishesVo = this.initCheckDishesVo(dishesMap, checkDish);
MenuRecipeDetail menuRecipeDetail = this.menuRecipeDetailService.getByRecipeIdAndApplyDateAndIntervalId(checkDish.getRecipeId(), checkDish.getOrderDate(), checkDish.getMealtimeType());
if (ObjectUtil.isEmpty(menuRecipeDetail)) {
checkDishesVo.setIfExpired(LeConstants.COMMON_YES);
return checkDishesVo;
} else {
Long detailId = menuRecipeDetail.getDetailId();
Long stallId = this.menuRecipeMapper.selectStallIdByWrappers((Wrapper)((LambdaQueryWrapper)Wrappers.lambdaQuery(MenuRecipe.class).eq(MenuRecipe::getRecipeId, menuRecipeDetail.getRecipeId())).eq(MenuRecipe::getDelFlag, DelFlagEnum.DEL_FALSE.key()));
List<AllocDeliveryCostModel> costModelList = this.allocDeliveryApi.queryDeliveryCostModel(stallId);
checkDishesVo.setCostModelList(costModelList);
List<AllocMealtimeStateModel> mealTimeList = this.allocMealtimeApi.getAllocMealtimeMenuModel(stallId).getMealtimeStateModelList();
if (ObjectUtil.isNotEmpty(mealTimeList)) {
mealTimeList = (List)mealTimeList.stream().filter((mealtime) -> {
return mealtime.getIfUse() == 1;
}).collect(Collectors.toList());
}
if (LocalDate.now().isEqual(menuRecipeDetail.getApplyDate()) && !OrderTypeEnum.isCurrMealType(orderType)) {
mealTimeList = (List)mealTimeList.stream().filter((time) -> {
return LocalTime.now().isBefore(time.getStartTime());
}).collect(Collectors.toList());
} else if (LocalDate.now().isAfter(menuRecipeDetail.getApplyDate())) {
mealTimeList = null;
}
MenuRecipeDishes menuRecipeDishes = (MenuRecipeDishes)((MenuRecipeDishesMapper)this.baseMapper).selectOne((Wrapper)((LambdaQueryWrapper)Wrappers.lambdaQuery(MenuRecipeDishes.class).eq(MenuRecipeDishes::getDetailId, detailId)).eq(MenuRecipeDishes::getDishesId, checkDish.getGoodsDishesId()));
if (ObjectUtil.isEmpty(menuRecipeDishes)) {
checkDishesVo.setIfExpired(LeConstants.COMMON_YES);
return checkDishesVo;
} else {
BeanUtil.copyProperties(menuRecipeDishes, checkDishesVo, new String[0]);
checkDishesVo.setIfExpired(LeConstants.COMMON_NO);
checkDishesVo.setMenuDetailId(detailId);
checkDishesVo.setSalePrice(BigDecimal.valueOf((long)menuRecipeDishes.getPrice()));
checkDishesVo.setPrefPrice(BigDecimal.valueOf((long)menuRecipeDishes.getSalePrice()));
if (ObjectUtil.isEmpty(mealTimeList)) {
checkDishesVo.setIfExpired(LeConstants.COMMON_YES);
return checkDishesVo;
} else {
boolean contains = mealTimeList.stream().map(AllocMealtimeStateModel::getMealtimeType).toList().contains(checkDish.getMealtimeType());
if (contains) {
checkDishesVo.setIfExpired(LeConstants.COMMON_NO);
} else {
checkDishesVo.setIfExpired(LeConstants.COMMON_YES);
}
return checkDishesVo;
}
}
}
}).collect(Collectors.toList());
}
public CheckDishesVo initCheckDishesVo(Map<Long, MenuDishes> dishesMap, CheckDishesDto checkDish) {
CheckDishesVo checkDishesVo = new CheckDishesVo();
checkDishesVo.setIfExpired(LeConstants.COMMON_YES);
checkDishesVo.setRecipeId(checkDish.getRecipeId());
MenuDishes menuDishes = (MenuDishes)dishesMap.get(checkDish.getGoodsDishesId());
if (ObjectUtil.isNotEmpty(menuDishes)) {
checkDishesVo.setGoodsDishesName(menuDishes.getDishesName());
checkDishesVo.setWeightUnit(menuDishes.getUnitPrice());
checkDishesVo.setSalesMode(menuDishes.getSalesMode());
checkDishesVo.setSizeJson(menuDishes.getSizeJson());
checkDishesVo.setSizeType(menuDishes.getSizeType());
checkDishesVo.setImageUrl(menuDishes.getImageUrl());
}
checkDishesVo.setOrderDate(checkDish.getOrderDate());
checkDishesVo.setMealtimeType(checkDish.getMealtimeType());
checkDishesVo.setGoodsDishesId(checkDish.getGoodsDishesId());
return checkDishesVo;
}
private MenuRecipeDishesMapper menuRecipeDishesMapper;
@Override
public boolean saveBatch(Collection<MenuRecipeDishes> entityList) {
Iterator var2 = CollUtil.split(entityList, 500).iterator();
while(var2.hasNext()) {
List<MenuRecipeDishes> menuRecipeDishes = (List)var2.next();
((MenuRecipeDishesMapper)this.baseMapper).insertValues(menuRecipeDishes);
menuRecipeDishesMapper.insertValues(menuRecipeDishes);
}
return true;
}
// $FF: synthetic method
private static Object $deserializeLambda$(SerializedLambda lambda) {
switch (lambda.getImplMethodName()) {
case "getDelFlag":
if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/menu/entity/MenuRecipe") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) {
return MenuRecipe::getDelFlag;
}
break;
case "getDetailId":
if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/menu/entity/MenuRecipeDishes") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
return MenuRecipeDishes::getDetailId;
}
if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/menu/entity/MenuRecipeDetail") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
return MenuRecipeDetail::getDetailId;
}
if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/menu/entity/MenuRecipeDishes") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
return MenuRecipeDishes::getDetailId;
}
if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/menu/entity/MenuRecipeDishes") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
return MenuRecipeDishes::getDetailId;
}
break;
case "getDishesId":
if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/menu/entity/MenuRecipeDishes") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
return MenuRecipeDishes::getDishesId;
}
if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/menu/entity/MenuDishes") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
return MenuDishes::getDishesId;
}
if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/menu/entity/MenuRecipeDishes") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
return MenuRecipeDishes::getDishesId;
}
break;
case "getRecipeId":
if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/menu/entity/MenuRecipeDetail") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
return MenuRecipeDetail::getRecipeId;
}
if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("net/xnzn/core/menu/entity/MenuRecipe") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
return MenuRecipe::getRecipeId;
}
}
throw new IllegalArgumentException("Invalid lambda deserialization");
}
}

View File

@ -2,6 +2,11 @@ package com.bonus.core.menu.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bonus.common.core.exception.ServiceException;
import com.bonus.constant.DelFlagEnum;
import com.bonus.core.marketing.constants.MktEffTypeEnum;
@ -29,14 +34,13 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDate;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
@Service
public class MenuRecipeServiceImpl implements MenuRecipeService {
public class MenuRecipeServiceImpl extends ServiceImpl<MenuRecipeMapper, MenuRecipe> implements MenuRecipeService {
private static final Logger log = LoggerFactory.getLogger(MenuRecipeServiceImpl.class);
@Autowired
@ -126,7 +130,7 @@ public class MenuRecipeServiceImpl implements MenuRecipeService {
public synchronized void generateRecipe(List<Long> recipeIdList0, LocalDate applyDate) {
if (!ObjectUtil.isEmpty(recipeIdList0) && !ObjectUtil.isEmpty(applyDate)) {
List<Long> recipeIdList = new ArrayList(recipeIdList0);
Map<Long, Long> recipeDetailContMap = (Map)this.menuRecipeDetailService.list((Wrapper)((LambdaQueryWrapper)Wrappers.lambdaQuery(MenuRecipeDetail.class).select(new SFunction[]{MenuRecipeDetail::getRecipeId}).eq(MenuRecipeDetail::getApplyDate, applyDate)).in(MenuRecipeDetail::getRecipeId, recipeIdList)).stream().collect(Collectors.groupingBy(MenuRecipeDetail::getRecipeId, Collectors.counting()));
Map<Long, Long> recipeDetailContMap = (Map)this.menuRecipeDetailService.list((Wrapper)((LambdaQueryWrapper) Wrappers.lambdaQuery(MenuRecipeDetail.class).select(new SFunction[]{MenuRecipeDetail::getRecipeId}).eq(MenuRecipeDetail::getApplyDate, applyDate)).in(MenuRecipeDetail::getRecipeId, recipeIdList)).stream().collect(Collectors.groupingBy(MenuRecipeDetail::getRecipeId, Collectors.counting()));
recipeIdList.removeAll(recipeDetailContMap.keySet());
if (!ObjectUtil.isEmpty(recipeIdList)) {
List<MenuRecipe> menuRecipes = this.list((Wrapper)((LambdaQueryWrapper)Wrappers.lambdaQuery(MenuRecipe.class).in(MenuRecipe::getRecipeType, new Object[]{2, 3})).in(MenuRecipe::getRecipeId, recipeIdList));

View File

@ -1,7 +1,7 @@
package com.bonus.core.menu.vo;
import io.swagger.annotations.ApiModelProperty;
import net.xnzn.core.allocation.canteen.model.AllocDeliveryCostModel;
import com.bonus.core.allocation.canteen.model.AllocDeliveryCostModel;
import java.math.BigDecimal;
import java.time.LocalDate;
@ -210,325 +210,4 @@ public class CheckDishesVo {
this.costModelList = costModelList;
}
public boolean equals(final Object o) {
if (o == this) {
return true;
} else if (!(o instanceof CheckDishesVo)) {
return false;
} else {
CheckDishesVo other = (CheckDishesVo)o;
if (!other.canEqual(this)) {
return false;
} else {
label263: {
Object this$recipeId = this.getRecipeId();
Object other$recipeId = other.getRecipeId();
if (this$recipeId == null) {
if (other$recipeId == null) {
break label263;
}
} else if (this$recipeId.equals(other$recipeId)) {
break label263;
}
return false;
}
Object this$ifExpired = this.getIfExpired();
Object other$ifExpired = other.getIfExpired();
if (this$ifExpired == null) {
if (other$ifExpired != null) {
return false;
}
} else if (!this$ifExpired.equals(other$ifExpired)) {
return false;
}
label249: {
Object this$menuDetailId = this.getMenuDetailId();
Object other$menuDetailId = other.getMenuDetailId();
if (this$menuDetailId == null) {
if (other$menuDetailId == null) {
break label249;
}
} else if (this$menuDetailId.equals(other$menuDetailId)) {
break label249;
}
return false;
}
Object this$weightUnit = this.getWeightUnit();
Object other$weightUnit = other.getWeightUnit();
if (this$weightUnit == null) {
if (other$weightUnit != null) {
return false;
}
} else if (!this$weightUnit.equals(other$weightUnit)) {
return false;
}
label235: {
Object this$salesMode = this.getSalesMode();
Object other$salesMode = other.getSalesMode();
if (this$salesMode == null) {
if (other$salesMode == null) {
break label235;
}
} else if (this$salesMode.equals(other$salesMode)) {
break label235;
}
return false;
}
Object this$mealtimeType = this.getMealtimeType();
Object other$mealtimeType = other.getMealtimeType();
if (this$mealtimeType == null) {
if (other$mealtimeType != null) {
return false;
}
} else if (!this$mealtimeType.equals(other$mealtimeType)) {
return false;
}
label221: {
Object this$goodsDishesId = this.getGoodsDishesId();
Object other$goodsDishesId = other.getGoodsDishesId();
if (this$goodsDishesId == null) {
if (other$goodsDishesId == null) {
break label221;
}
} else if (this$goodsDishesId.equals(other$goodsDishesId)) {
break label221;
}
return false;
}
label214: {
Object this$supplyNum = this.getSupplyNum();
Object other$supplyNum = other.getSupplyNum();
if (this$supplyNum == null) {
if (other$supplyNum == null) {
break label214;
}
} else if (this$supplyNum.equals(other$supplyNum)) {
break label214;
}
return false;
}
Object this$saleNum = this.getSaleNum();
Object other$saleNum = other.getSaleNum();
if (this$saleNum == null) {
if (other$saleNum != null) {
return false;
}
} else if (!this$saleNum.equals(other$saleNum)) {
return false;
}
label200: {
Object this$surplusNum = this.getSurplusNum();
Object other$surplusNum = other.getSurplusNum();
if (this$surplusNum == null) {
if (other$surplusNum == null) {
break label200;
}
} else if (this$surplusNum.equals(other$surplusNum)) {
break label200;
}
return false;
}
label193: {
Object this$restrictNum = this.getRestrictNum();
Object other$restrictNum = other.getRestrictNum();
if (this$restrictNum == null) {
if (other$restrictNum == null) {
break label193;
}
} else if (this$restrictNum.equals(other$restrictNum)) {
break label193;
}
return false;
}
Object this$sizeType = this.getSizeType();
Object other$sizeType = other.getSizeType();
if (this$sizeType == null) {
if (other$sizeType != null) {
return false;
}
} else if (!this$sizeType.equals(other$sizeType)) {
return false;
}
Object this$goodsDishesName = this.getGoodsDishesName();
Object other$goodsDishesName = other.getGoodsDishesName();
if (this$goodsDishesName == null) {
if (other$goodsDishesName != null) {
return false;
}
} else if (!this$goodsDishesName.equals(other$goodsDishesName)) {
return false;
}
label172: {
Object this$salePrice = this.getSalePrice();
Object other$salePrice = other.getSalePrice();
if (this$salePrice == null) {
if (other$salePrice == null) {
break label172;
}
} else if (this$salePrice.equals(other$salePrice)) {
break label172;
}
return false;
}
Object this$prefPrice = this.getPrefPrice();
Object other$prefPrice = other.getPrefPrice();
if (this$prefPrice == null) {
if (other$prefPrice != null) {
return false;
}
} else if (!this$prefPrice.equals(other$prefPrice)) {
return false;
}
Object this$unitName = this.getUnitName();
Object other$unitName = other.getUnitName();
if (this$unitName == null) {
if (other$unitName != null) {
return false;
}
} else if (!this$unitName.equals(other$unitName)) {
return false;
}
label151: {
Object this$tasteName = this.getTasteName();
Object other$tasteName = other.getTasteName();
if (this$tasteName == null) {
if (other$tasteName == null) {
break label151;
}
} else if (this$tasteName.equals(other$tasteName)) {
break label151;
}
return false;
}
Object this$orderDate = this.getOrderDate();
Object other$orderDate = other.getOrderDate();
if (this$orderDate == null) {
if (other$orderDate != null) {
return false;
}
} else if (!this$orderDate.equals(other$orderDate)) {
return false;
}
label137: {
Object this$imageUrl = this.getImageUrl();
Object other$imageUrl = other.getImageUrl();
if (this$imageUrl == null) {
if (other$imageUrl == null) {
break label137;
}
} else if (this$imageUrl.equals(other$imageUrl)) {
break label137;
}
return false;
}
Object this$sizeJson = this.getSizeJson();
Object other$sizeJson = other.getSizeJson();
if (this$sizeJson == null) {
if (other$sizeJson != null) {
return false;
}
} else if (!this$sizeJson.equals(other$sizeJson)) {
return false;
}
Object this$costModelList = this.getCostModelList();
Object other$costModelList = other.getCostModelList();
if (this$costModelList == null) {
if (other$costModelList == null) {
return true;
}
} else if (this$costModelList.equals(other$costModelList)) {
return true;
}
return false;
}
}
}
protected boolean canEqual(final Object other) {
return other instanceof CheckDishesVo;
}
public int hashCode() {
int PRIME = true;
int result = 1;
Object $recipeId = this.getRecipeId();
result = result * 59 + ($recipeId == null ? 43 : $recipeId.hashCode());
Object $ifExpired = this.getIfExpired();
result = result * 59 + ($ifExpired == null ? 43 : $ifExpired.hashCode());
Object $menuDetailId = this.getMenuDetailId();
result = result * 59 + ($menuDetailId == null ? 43 : $menuDetailId.hashCode());
Object $weightUnit = this.getWeightUnit();
result = result * 59 + ($weightUnit == null ? 43 : $weightUnit.hashCode());
Object $salesMode = this.getSalesMode();
result = result * 59 + ($salesMode == null ? 43 : $salesMode.hashCode());
Object $mealtimeType = this.getMealtimeType();
result = result * 59 + ($mealtimeType == null ? 43 : $mealtimeType.hashCode());
Object $goodsDishesId = this.getGoodsDishesId();
result = result * 59 + ($goodsDishesId == null ? 43 : $goodsDishesId.hashCode());
Object $supplyNum = this.getSupplyNum();
result = result * 59 + ($supplyNum == null ? 43 : $supplyNum.hashCode());
Object $saleNum = this.getSaleNum();
result = result * 59 + ($saleNum == null ? 43 : $saleNum.hashCode());
Object $surplusNum = this.getSurplusNum();
result = result * 59 + ($surplusNum == null ? 43 : $surplusNum.hashCode());
Object $restrictNum = this.getRestrictNum();
result = result * 59 + ($restrictNum == null ? 43 : $restrictNum.hashCode());
Object $sizeType = this.getSizeType();
result = result * 59 + ($sizeType == null ? 43 : $sizeType.hashCode());
Object $goodsDishesName = this.getGoodsDishesName();
result = result * 59 + ($goodsDishesName == null ? 43 : $goodsDishesName.hashCode());
Object $salePrice = this.getSalePrice();
result = result * 59 + ($salePrice == null ? 43 : $salePrice.hashCode());
Object $prefPrice = this.getPrefPrice();
result = result * 59 + ($prefPrice == null ? 43 : $prefPrice.hashCode());
Object $unitName = this.getUnitName();
result = result * 59 + ($unitName == null ? 43 : $unitName.hashCode());
Object $tasteName = this.getTasteName();
result = result * 59 + ($tasteName == null ? 43 : $tasteName.hashCode());
Object $orderDate = this.getOrderDate();
result = result * 59 + ($orderDate == null ? 43 : $orderDate.hashCode());
Object $imageUrl = this.getImageUrl();
result = result * 59 + ($imageUrl == null ? 43 : $imageUrl.hashCode());
Object $sizeJson = this.getSizeJson();
result = result * 59 + ($sizeJson == null ? 43 : $sizeJson.hashCode());
Object $costModelList = this.getCostModelList();
result = result * 59 + ($costModelList == null ? 43 : $costModelList.hashCode());
return result;
}
public String toString() {
Long var10000 = this.getRecipeId();
return "CheckDishesVo(recipeId=" + var10000 + ", ifExpired=" + this.getIfExpired() + ", goodsDishesName=" + this.getGoodsDishesName() + ", menuDetailId=" + this.getMenuDetailId() + ", salePrice=" + String.valueOf(this.getSalePrice()) + ", prefPrice=" + String.valueOf(this.getPrefPrice()) + ", weightUnit=" + this.getWeightUnit() + ", unitName=" + this.getUnitName() + ", salesMode=" + this.getSalesMode() + ", tasteName=" + this.getTasteName() + ", mealtimeType=" + this.getMealtimeType() + ", orderDate=" + String.valueOf(this.getOrderDate()) + ", goodsDishesId=" + this.getGoodsDishesId() + ", imageUrl=" + this.getImageUrl() + ", supplyNum=" + this.getSupplyNum() + ", saleNum=" + this.getSaleNum() + ", surplusNum=" + this.getSurplusNum() + ", restrictNum=" + this.getRestrictNum() + ", sizeType=" + this.getSizeType() + ", sizeJson=" + this.getSizeJson() + ", costModelList=" + String.valueOf(this.getCostModelList()) + ")";
}
}

View File

@ -0,0 +1,72 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.bonus.core.menu.mapper.MenuRecipeDishesMapper">
<insert id="insertValues">
INSERT INTO menu_recipe_dishes
(detail_id, dishes_id, price, size_type, supply_num, sale_num, surplus_num,
restrict_num, sale_price, recommend_flag, crby, crtime, upby, uptime, sort_num)
VALUES
<foreach collection="list" item="item" separator="," open="" close="">
( #{item.detailId}, #{item.dishesId},#{item.price},#{item.sizeType},#{item.supplyNum},#{item.saleNum},#{item.surplusNum},
#{item.restrictNum},#{item.salePrice},#{item.recommendFlag}
,#{item.crby},#{item.crtime},#{item.upby},#{item.uptime},#{item.sortNum})
</foreach>
</insert>
<!-- 获取指定菜品的历史销量 -->
<select id="selectHistoricalSalesByDishesId" resultType="java.lang.Integer">
select sum(sale_num)
from menu_recipe_dishes mrd
left join menu_recipe_detail mrdd on mrdd.detail_id = mrd.detail_id
where dishes_id = #{dishesId}
and #{lastDay} >= mrdd.apply_date
and mrdd.apply_date >= #{firstDay}
</select>
<select id="selectExistLeftJoinByDishesId" resultType="java.lang.Integer">
select
1
from
menu_recipe_detail mrd
left join menu_recipe_dishes mrdd on mrd.detail_id = mrdd.detail_id
where
mrd.apply_date >= curdate()
and mrdd.dishes_id in
<foreach collection="dishesIdList" item="dishesId" open="(" separator="," close=")">
#{dishesId}
</foreach>
limit 1
</select>
<!-- <select id="getDishesCountByRecipeIds" resultType="net.xnzn.core.menu.dto.RecipeDishesCountDto">-->
<!-- SELECT-->
<!-- mrd.recipe_id,count(DISTINCT(md.base_dishes_id)) as num-->
<!-- FROM-->
<!-- menu_recipe_detail mrd-->
<!-- LEFT JOIN menu_recipe_dishes mrdd ON mrd.detail_id = mrdd.detail_id-->
<!-- LEFT JOIN menu_dishes md ON md.dishes_id = mrdd.dishes_id-->
<!-- where-->
<!-- mrd.apply_date >= curdate()-->
<!-- <if test="recipeIds !=null and recipeIds.size()>0">-->
<!-- AND mrd.recipe_id in-->
<!-- <foreach collection="recipeIds" separator="," open="(" close=")" item="item">-->
<!-- #{item}-->
<!-- </foreach>-->
<!-- </if>-->
<!-- GROUP BY mrd.recipe_id;-->
<!-- </select>-->
<!-- <select id="queryDishesByDate" resultType="net.xnzn.core.menu.dto.ExistDateDto">-->
<!-- SELECT t2.apply_date,-->
<!-- t2.mealtime_type-->
<!-- FROM menu_recipe_dishes t1-->
<!-- JOIN menu_recipe_detail t2 ON t1.detail_id = t2.detail_id-->
<!-- WHERE t2.detail_type = 2-->
<!-- AND t2.recipe_id = #{recipeId}-->
<!-- AND t1.dishes_id = #{dishesId}-->
<!-- AND t2.apply_date IN-->
<!-- <foreach collection="dates" item="date" open="(" close=")" separator=",">-->
<!-- #{date}-->
<!-- </foreach>-->
<!-- </select>-->
</mapper>