一周菜谱(详情)api/v2/applet/menurecipe/week/recipe/detail

This commit is contained in:
tqzhang 2025-02-07 15:08:55 +08:00
parent 676001afa3
commit 08c8f1b0a3
11 changed files with 304 additions and 222 deletions

View File

@ -1,6 +1,7 @@
package com.bonus.core.account.v3.app.controller;
import com.bonus.common.core.utils.StringUtils;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.core.account.v3.app.dto.AppTradeDetailListDTO;
import com.bonus.core.account.v3.app.service.AppAccService;
@ -12,29 +13,39 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Resource;
import javax.validation.Valid;
@RestController
@Api(
value = "ly_小程序账户控制器V3",
tags = {"ly_小程序账户控制器V3"}
value = "ly_小程序账户控制器V3",
tags = {"ly_小程序账户控制器V3"}
)
@RequestMapping({"/api/v3/app/accInfo"})
public class AppAccController {
private static final Logger log = LoggerFactory.getLogger(AppAccController.class);
@Resource
private AppAccService appAccService;
private static final Logger log = LoggerFactory.getLogger(AppAccController.class);
@Resource
private AppAccService appAccService;
@ApiOperation("分页查询账户充值记录")
@PostMapping({"/queryTradeAppPage"})
public AjaxResult queryTradeAppPage(@RequestBody @Valid AppTradeDetailListDTO dto) {
try {
return AjaxResult.success(this.appAccService.queryTradeAppPage(dto));
} catch (Exception e) {
@ApiOperation("分页查询账户充值记录")
@PostMapping({"/queryTradeAppPage"})
public AjaxResult queryTradeAppPage(@RequestBody @Valid AppTradeDetailListDTO dto) {
try {
if (StringUtils.isBlank(String.valueOf(dto.getCustId()))) {
return AjaxResult.error("食堂ID不能为空");
}
if (StringUtils.isBlank(String.valueOf(dto.getCurrent()))) {
return AjaxResult.error("当前页不能为空");
}
if (StringUtils.isBlank(String.valueOf(dto.getSize()))) {
return AjaxResult.error("每页显示记录数不能为空");
}
return AjaxResult.success(this.appAccService.queryTradeAppPage(dto));
} catch (Exception e) {
log.error(e.toString(), e);
return AjaxResult.error("查询账户充值记录失败");
}
}
}
}
}

View File

@ -1,5 +1,6 @@
package com.bonus.core.account.v4.app.controller;
import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.core.web.controller.BaseController;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.core.account.v4.app.dto.AppAccInfoV4DTO;
@ -8,6 +9,7 @@ import com.bonus.core.account.v4.app.vo.AppAccInfoV4VO;
import com.bonus.core.account.v4.app.vo.AppWalletBalanceVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -20,29 +22,45 @@ import java.util.Map;
@RestController
@RequestMapping({"/api/v4/app/account"})
@Api(
value = "账户管理/移动端/v4",
tags = {"账户管理/移动端/v4"}
value = "账户管理/移动端/v4",
tags = {"账户管理/移动端/v4"}
)
public class AppAccV4Controller extends BaseController {
private static final Logger log = LoggerFactory.getLogger(AppAccV4Controller.class);
@Resource
private AppAccV4Service appAccV4Service;
private static final Logger log = LoggerFactory.getLogger(AppAccV4Controller.class);
@Resource
private AppAccV4Service appAccV4Service;
@ApiOperation(
value = "查询账户(仅返回钱包余额)",
notes = "移动端查询账户(仅返回钱包余额)"
)
@PostMapping({"/wallet/balance"})
public AjaxResult queryWalletBalance(@RequestBody AppAccInfoV4DTO o) {
return success(this.appAccV4Service.queryWalletBalance(o));
}
@ApiOperation(
value = "查询账户(仅返回钱包余额)",
notes = "移动端查询账户(仅返回钱包余额)"
)
@PostMapping({"/wallet/balance"})
public AjaxResult queryWalletBalance(@RequestBody AppAccInfoV4DTO o) {
try {
if (StringUtils.isBlank(String.valueOf(o.getCustId()))) {
return error("食堂ID不能为空");
}
return success(this.appAccV4Service.queryWalletBalance(o));
} catch (Exception e) {
log.error(e.toString(), e);
return error("查询账户失败");
}
}
@ApiOperation(
value = "查询账户(基础信息+余额)",
notes = "移动端查询账户(基础信息+余额)"
)
@PostMapping({"/info"})
public AjaxResult queryAccInfoForApp(@RequestBody AppAccInfoV4DTO o) {
return success(this.appAccV4Service.queryAccInfoForApp(o));
}
@ApiOperation(
value = "查询账户(基础信息+余额)",
notes = "移动端查询账户(基础信息+余额)"
)
@PostMapping({"/info"})
public AjaxResult queryAccInfoForApp(@RequestBody AppAccInfoV4DTO o) {
try {
if (StringUtils.isBlank(String.valueOf(o.getCustId()))) {
return error("食堂ID不能为空");
}
return success(this.appAccV4Service.queryAccInfoForApp(o));
} catch (Exception e) {
log.error(e.toString(), e);
return error("查询账户失败");
}
}
}

View File

@ -1,16 +1,12 @@
package com.bonus.core.allocation.canteen.controller;
import cn.hutool.core.lang.tree.Tree;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.core.allocation.canteen.model.AllocCanteen;
import com.bonus.core.allocation.canteen.service.AllocCanteenService;
import com.bonus.core.allocation.canteen.service.AllocStallService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
@ -18,10 +14,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.time.LocalDate;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping({"/api/v2/alloc/canteen"})
@ -37,9 +29,14 @@ public class AllocCanteenController {
@ApiOperation("查询食堂所有开启的支付方式")
@PostMapping({"/list-avail-pay-type"})
public AjaxResult listAvailPayTypeForApp(@RequestBody AllocCanteen bean) {
if (bean.getCanteenId() == null) {
try {
if (bean.getCanteenId() == null) {
return AjaxResult.error("食堂ID不能为空");
}
return AjaxResult.success(this.allocCanteenService.listAvailPayTypeForApp(bean.getCanteenId()));
} catch (Exception e) {
log.error(e.toString(), e);
return AjaxResult.error("查询食堂所有开启的支付方式失败");
}
return AjaxResult.success(this.allocCanteenService.listAvailPayTypeForApp(bean.getCanteenId()));
}
}

View File

@ -0,0 +1,9 @@
package com.bonus.core.menu.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.bonus.core.menu.entity.MenuRecipeDetail;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface MenuRecipeDetailMapper extends BaseMapper<MenuRecipeDetail> {
}

View File

@ -1,6 +1,8 @@
package com.bonus.core.menu.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.bonus.core.marketing.vo.MktEffectiveUserVO;
import com.bonus.core.menu.entity.MenuRecipe;
import com.bonus.core.menu.vo.AppletWeekRecipeVO;
import com.bonus.domain.CustInfo;
import org.apache.ibatis.annotations.Mapper;
@ -9,7 +11,7 @@ import java.time.LocalDate;
import java.util.List;
@Mapper
public interface MenuRecipeMapper {
public interface MenuRecipeMapper extends BaseMapper<MenuRecipe> {
CustInfo selectOrgAndPsnByCustLimitId(CustInfo custInfo);
List<MktEffectiveUserVO> selectAllUserEff(@Param("effType") Integer effType, @Param("delFlag") Integer delFlag);

View File

@ -8,7 +8,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
public interface MenuRecipeDetailService {
public interface MenuRecipeDetailService extends IService<MenuRecipeDetail> {
List<MenuRecipeDetail> getByRecipeIdAndDatesAndIntervalId(Long recipeId, Set<LocalDate> dates, Integer mealtimeType);
MenuRecipeDetail getByRecipeIdAndApplyDateAndIntervalId(Long recipeId, LocalDate applyDate, Integer mealtimeType);

View File

@ -1,5 +1,6 @@
package com.bonus.core.menu.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.bonus.core.menu.dto.CheckDishesDto;
import com.bonus.core.menu.dto.OrderRecipeDishesDto;
import com.bonus.core.menu.entity.MenuRecipeDishes;
@ -11,7 +12,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
public interface MenuRecipeDishesService {
public interface MenuRecipeDishesService extends IService<MenuRecipeDishes> {
@Override
boolean saveBatch(Collection<MenuRecipeDishes> entityList);
}

View File

@ -4,9 +4,12 @@ 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.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bonus.core.menu.entity.MenuRecipeDetail;
import com.bonus.core.menu.mapper.MenuRecipeDetailMapper;
import com.bonus.core.menu.service.MenuRecipeDetailService;
import org.springframework.stereotype.Service;
import java.lang.invoke.SerializedLambda;
import java.time.LocalDate;
import java.util.List;
@ -16,17 +19,29 @@ import java.util.TreeSet;
import java.util.stream.Collectors;
@Service
public class MenuRecipeDetailServiceImpl implements MenuRecipeDetailService {
public List<MenuRecipeDetail> getByRecipeIdAndDatesAndIntervalId(Long recipeId, Set<LocalDate> values, Integer mealtimeType) {
return this.list((Wrapper)((LambdaQueryWrapper)((LambdaQueryWrapper)Wrappers.lambdaQuery().eq(MenuRecipeDetail::getMealtimeType, mealtimeType)).eq(MenuRecipeDetail::getRecipeId, recipeId)).in(MenuRecipeDetail::getApplyDate, values));
}
public class MenuRecipeDetailServiceImpl extends ServiceImpl<MenuRecipeDetailMapper, MenuRecipeDetail> implements MenuRecipeDetailService {
@Override
public List<MenuRecipeDetail> getByRecipeIdAndDatesAndIntervalId(Long recipeId, Set<LocalDate> values, Integer mealtimeType) {
return this.list(Wrappers.<MenuRecipeDetail>lambdaQuery()
.eq(MenuRecipeDetail::getMealtimeType, mealtimeType)
.eq(MenuRecipeDetail::getRecipeId, recipeId).in(MenuRecipeDetail::getApplyDate, values));
}
public MenuRecipeDetail getByRecipeIdAndApplyDateAndIntervalId(Long recipeId, LocalDate applyDate, Integer mealtimeType) {
return (MenuRecipeDetail)this.getOne((Wrapper)((LambdaQueryWrapper)((LambdaQueryWrapper)Wrappers.lambdaQuery().eq(MenuRecipeDetail::getMealtimeType, mealtimeType)).eq(MenuRecipeDetail::getRecipeId, recipeId)).eq(MenuRecipeDetail::getApplyDate, applyDate));
}
@Override
public MenuRecipeDetail getByRecipeIdAndApplyDateAndIntervalId(Long recipeId, LocalDate applyDate, Integer mealtimeType) {
return (MenuRecipeDetail) this.getOne(Wrappers.<MenuRecipeDetail>lambdaQuery()
.eq(MenuRecipeDetail::getMealtimeType, mealtimeType)
.eq(MenuRecipeDetail::getRecipeId, recipeId)
.eq(MenuRecipeDetail::getApplyDate, applyDate));
}
public Map<Long, Set<LocalDate>> selectApplyDateListByRecipeId(List<Long> recipeIds) {
return (Map)this.list((Wrapper)((LambdaQueryWrapper)Wrappers.lambdaQuery(MenuRecipeDetail.class).select(new SFunction[]{MenuRecipeDetail::getRecipeId, MenuRecipeDetail::getApplyDate}).ge(MenuRecipeDetail::getApplyDate, LocalDate.now())).in(MenuRecipeDetail::getRecipeId, recipeIds)).stream().collect(Collectors.groupingBy(MenuRecipeDetail::getRecipeId, Collectors.mapping(MenuRecipeDetail::getApplyDate, Collectors.toCollection(TreeSet::new))));
}
@Override
public Map<Long, Set<LocalDate>> selectApplyDateListByRecipeId(List<Long> recipeIds) {
return this.list(Wrappers.<MenuRecipeDetail>lambdaQuery()
.select(MenuRecipeDetail::getRecipeId, MenuRecipeDetail::getApplyDate)
.ge(MenuRecipeDetail::getApplyDate, LocalDate.now())
.in(MenuRecipeDetail::getRecipeId, recipeIds)).stream()
.collect(Collectors.groupingBy(MenuRecipeDetail::getRecipeId, Collectors.mapping(MenuRecipeDetail::getApplyDate, Collectors.toCollection(TreeSet::new))));
}
}

View File

@ -2,6 +2,7 @@ package com.bonus.core.menu.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bonus.core.menu.entity.MenuRecipeDishes;
import com.bonus.core.menu.mapper.MenuRecipeDishesMapper;
import com.bonus.core.menu.service.MenuRecipeDishesService;
@ -9,6 +10,8 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.lang.invoke.SerializedLambda;
import java.math.BigDecimal;
import java.time.LocalDate;
@ -18,10 +21,10 @@ import java.util.function.Function;
import java.util.stream.Collectors;
@Service
public class MenuRecipeDishesServiceImpl implements MenuRecipeDishesService {
public class MenuRecipeDishesServiceImpl extends ServiceImpl<MenuRecipeDishesMapper, MenuRecipeDishes> implements MenuRecipeDishesService {
private static final Logger log = LoggerFactory.getLogger(MenuRecipeDishesServiceImpl.class);
@Autowired
@Resource
private MenuRecipeDishesMapper menuRecipeDishesMapper;
@Override

View File

@ -5,8 +5,6 @@ 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.core.toolkit.support.SFunction;
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;
@ -35,6 +33,7 @@ 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;
@ -42,174 +41,196 @@ import java.util.stream.Collectors;
@Service
public class MenuRecipeServiceImpl extends ServiceImpl<MenuRecipeMapper, MenuRecipe> implements MenuRecipeService {
private static final Logger log = LoggerFactory.getLogger(MenuRecipeServiceImpl.class);
private static final Logger log = LoggerFactory.getLogger(MenuRecipeServiceImpl.class);
@Autowired
private MenuRecipeDetailService menuRecipeDetailService;
@Autowired
private MenuRecipeDetailService menuRecipeDetailService;
@Autowired
private MenuRecipeDishesService menuRecipeDishesService;
@Autowired
private MenuRecipeDishesService menuRecipeDishesService;
@Autowired
private MenuAppRecipeMapper menuAppRecipeMapper;
@Autowired
private MenuAppRecipeMapper menuAppRecipeMapper;
@Autowired
private MenuRecipeMapper menuRecipeMapper;
@Autowired
private MenuRecipeMapper menuRecipeMapper;
public List<AppletWeekCanteenVO> getWeekMealList(AppletWeekCanteenDTO content) {
Set<Long> effIdSet = this.getShopstallIdListByCustId(content.getCustId(), false);
if (ObjectUtil.isEmpty(effIdSet)) {
effIdSet = Sets.newTreeSet();
((Set)effIdSet).add(-1L);
}
return this.menuAppRecipeMapper.selectWeekCanteenList((Set)effIdSet);
}
public Set<Long> getShopstallIdListByCustId(Long custId, boolean checkCustInfo) {
Set<Long> effIdSet = Sets.newTreeSet();
CustInfo custInfoQuery = new CustInfo();
custInfoQuery.setCustId(custId);
custInfoQuery.setCustState(1);
CustInfo custInfo = menuRecipeMapper.selectOrgAndPsnByCustLimitId(custInfoQuery);
if (ObjectUtil.isNull(custInfo)) {
if (checkCustInfo) {
throw new ServiceException("菜单绑定错误");
} else {
log.info("***[获取全档口菜谱信息]_未查询到人员信息,直接返回********************");
return (Set)effIdSet;
}
} else {
List<MktEffectiveUserVO> effectiveUserVOList = menuRecipeMapper.selectAllUserEff(MktEffTypeEnum.USER_SORT.key(), DelFlagEnum.DEL_FALSE.key());
Long orgId = custInfo.getOrgId();
Integer psnType = custInfo.getPsnType();
if (ObjectUtil.isNotEmpty(effectiveUserVOList)) {
List<MktEffectiveUserVO> collect = (List)effectiveUserVOList.stream().filter((u) -> {
boolean containsOrg = ObjectUtil.isNotEmpty(u.getOrgIdList()) && u.getOrgIdList().contains(orgId);
boolean containsPsn = ObjectUtil.isNotEmpty(u.getPsnTypeList()) && u.getPsnTypeList().contains(psnType);
return MktUserTypeEnum.INTERSECTION.key().equals(u.getUserType()) && containsOrg && containsPsn || MktUserTypeEnum.UNION_SET.key().equals(u.getUserType()) && (containsOrg || containsPsn);
}).collect(Collectors.toList());
if (ObjectUtil.isNotEmpty(collect)) {
effIdSet = (Set)collect.stream().map(MktEffectiveUserVO::getEffId).collect(Collectors.toSet());
((Set)effIdSet).add(-1L);
}
}
log.info("***[获取指定人员折扣比例]_指定人员的生效范围effIdSet: {}", effIdSet);
return (Set)effIdSet;
}
}
public List<AppletWeekRecipeVO> getWeekRecipeDetailList(AppletWeekRecipeDTO content) {
List<Long> recipeIdList = Lists.newArrayList();
if (ObjectUtil.isNull(content.getRecipeId())) {
Set<Long> effIdSet = this.getShopstallIdListByCustId(content.getCustId(), false);
if (ObjectUtil.isEmpty(effIdSet)) {
@Override
public List<AppletWeekCanteenVO> getWeekMealList(AppletWeekCanteenDTO content) {
Set<Long> effIdSet = this.getShopstallIdListByCustId(content.getCustId(), false);
if (ObjectUtil.isEmpty(effIdSet)) {
effIdSet = Sets.newTreeSet();
((Set)effIdSet).add(-1L);
}
((Set) effIdSet).add(-1L);
}
recipeIdList = this.menuAppRecipeMapper.selectWeekRecipeId(content.getRecipeId(), (Set)effIdSet);
if (ObjectUtil.isEmpty(recipeIdList)) {
return Lists.newArrayList();
}
} else {
((List)recipeIdList).add(content.getRecipeId());
}
return this.menuAppRecipeMapper.selectWeekCanteenList((Set) effIdSet);
}
this.generateRecipe((List)recipeIdList, content.getApplyDate());
List<AppletWeekRecipeVO> resultList = menuRecipeMapper.selectWeekRecipe(content.getApplyDate(), content.getRecipeId(), (List)recipeIdList);
resultList.sort(Collections.reverseOrder((s1, s2) -> {
return s2.getMealtimeType() - s1.getMealtimeType();
}));
return resultList;
}
@Transactional(
rollbackFor = {Exception.class}
)
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()));
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));
if (!ObjectUtil.isEmpty(menuRecipes)) {
Map<Long, MenuRecipe> recipeMap = (Map)menuRecipes.stream().collect(Collectors.toMap(MenuRecipe::getRecipeId, Function.identity()));
List<MenuRecipeDetail> menuRecipeDetails = this.menuRecipeDetailService.list((Wrapper)((LambdaQueryWrapper)Wrappers.lambdaQuery(MenuRecipeDetail.class).eq(MenuRecipeDetail::getDetailType, 1)).in(MenuRecipeDetail::getRecipeId, recipeIdList));
Map<Long, Integer> recipeTypeMap = (Map)menuRecipes.stream().collect(Collectors.toMap(MenuRecipe::getRecipeId, MenuRecipe::getRecipeType));
menuRecipeDetails = this.filterMenuRecipeDetails(recipeTypeMap, menuRecipeDetails, applyDate);
if (!ObjectUtil.isEmpty(menuRecipeDetails)) {
Map<Long, List<MenuRecipeDetail>> detailMap = (Map)menuRecipeDetails.stream().collect(Collectors.groupingBy(MenuRecipeDetail::getRecipeId));
List<Long> detailIds = (List)menuRecipeDetails.stream().map(MenuRecipeDetail::getDetailId).collect(Collectors.toList());
Map<Long, List<MenuRecipeDishes>> recipeDishes = (Map)this.menuRecipeDishesService.list((Wrapper)Wrappers.lambdaQuery(MenuRecipeDishes.class).in(MenuRecipeDishes::getDetailId, detailIds)).stream().collect(Collectors.groupingBy(MenuRecipeDishes::getDetailId));
List<MenuRecipeDetail> recipeDetailV2List = Lists.newArrayList();
List<MenuRecipeDishes> recipeDishesV2List = Lists.newArrayList();
Iterator var13 = recipeMap.keySet().iterator();
label59:
while(true) {
Long recipeId;
Integer type;
List menuRecipeDetail;
do {
if (!var13.hasNext()) {
this.menuRecipeDetailService.saveBatch(recipeDetailV2List);
if (ObjectUtil.isNotEmpty(recipeDishesV2List)) {
this.menuRecipeDishesService.saveBatch(recipeDishesV2List);
}
return;
}
recipeId = (Long)var13.next();
type = (Integer)recipeTypeMap.get(recipeId);
menuRecipeDetail = (List)detailMap.get(recipeId);
} while(!ObjectUtil.isNotEmpty(menuRecipeDetail));
Iterator var17 = menuRecipeDetail.iterator();
while(true) {
Long detailId;
List dishes;
do {
if (!var17.hasNext()) {
continue label59;
}
MenuRecipeDetail recipeDetail = (MenuRecipeDetail)var17.next();
MenuRecipeDetail detailItem = new MenuRecipeDetail();
detailId = Id.next();
detailItem.setDetailId(detailId);
detailItem.setRecipeId(recipeId);
if (ObjectUtil.equal(type, 3)) {
detailItem.setApplyWeek(applyDate.getDayOfWeek().getValue());
}
detailItem.setApplyDate(applyDate);
detailItem.setMealtimeType(recipeDetail.getMealtimeType());
detailItem.setCrby("");
detailItem.setDetailType(2);
recipeDetailV2List.add(detailItem);
dishes = (List)recipeDishes.get(recipeDetail.getDetailId());
} while(!ObjectUtil.isNotEmpty(dishes));
Iterator var22 = dishes.iterator();
while(var22.hasNext()) {
MenuRecipeDishes dish = (MenuRecipeDishes)var22.next();
MenuRecipeDishes dishesItem = (MenuRecipeDishes) BeanUtil.copyProperties(dish, MenuRecipeDishes.class, new String[0]);
dishesItem.setDetailId(detailId);
dishesItem.setId((Long)null);
recipeDishesV2List.add(dishesItem);
}
}
}
}
public Set<Long> getShopstallIdListByCustId(Long custId, boolean checkCustInfo) {
Set<Long> effIdSet = Sets.newTreeSet();
CustInfo custInfoQuery = new CustInfo();
custInfoQuery.setCustId(custId);
custInfoQuery.setCustState(1);
CustInfo custInfo = menuRecipeMapper.selectOrgAndPsnByCustLimitId(custInfoQuery);
if (ObjectUtil.isNull(custInfo)) {
if (checkCustInfo) {
throw new ServiceException("菜单绑定错误");
} else {
log.info("***[获取全档口菜谱信息]_未查询到人员信息,直接返回********************");
return (Set) effIdSet;
}
}
}
}
} else {
List<MktEffectiveUserVO> effectiveUserVOList = menuRecipeMapper.selectAllUserEff(MktEffTypeEnum.USER_SORT.key(), DelFlagEnum.DEL_FALSE.key());
Long orgId = custInfo.getOrgId();
Integer psnType = custInfo.getPsnType();
if (ObjectUtil.isNotEmpty(effectiveUserVOList)) {
List<MktEffectiveUserVO> collect = (List) effectiveUserVOList.stream().filter((u) -> {
boolean containsOrg = ObjectUtil.isNotEmpty(u.getOrgIdList()) && u.getOrgIdList().contains(orgId);
boolean containsPsn = ObjectUtil.isNotEmpty(u.getPsnTypeList()) && u.getPsnTypeList().contains(psnType);
return MktUserTypeEnum.INTERSECTION.key().equals(u.getUserType()) && containsOrg && containsPsn || MktUserTypeEnum.UNION_SET.key().equals(u.getUserType()) && (containsOrg || containsPsn);
}).collect(Collectors.toList());
if (ObjectUtil.isNotEmpty(collect)) {
effIdSet = (Set) collect.stream().map(MktEffectiveUserVO::getEffId).collect(Collectors.toSet());
((Set) effIdSet).add(-1L);
}
}
log.info("***[获取指定人员折扣比例]_指定人员的生效范围effIdSet: {}", effIdSet);
return (Set) effIdSet;
}
}
@Override
public List<AppletWeekRecipeVO> getWeekRecipeDetailList(AppletWeekRecipeDTO content) {
List<Long> recipeIdList = Lists.newArrayList();
if (ObjectUtil.isNull(content.getRecipeId())) {
Set<Long> effIdSet = this.getShopstallIdListByCustId(content.getCustId(), false);
if (ObjectUtil.isEmpty(effIdSet)) {
effIdSet = Sets.newTreeSet();
((Set) effIdSet).add(-1L);
}
recipeIdList = this.menuAppRecipeMapper.selectWeekRecipeId(content.getRecipeId(), (Set) effIdSet);
if (ObjectUtil.isEmpty(recipeIdList)) {
return Lists.newArrayList();
}
} else {
((List) recipeIdList).add(content.getRecipeId());
}
this.generateRecipe((List) recipeIdList, content.getApplyDate());
List<AppletWeekRecipeVO> resultList = menuRecipeMapper.selectWeekRecipe(content.getApplyDate(), content.getRecipeId(), (List) recipeIdList);
resultList.sort(Collections.reverseOrder((s1, s2) -> {
return s2.getMealtimeType() - s1.getMealtimeType();
}));
return resultList;
}
@Transactional(rollbackFor = {Exception.class})
public synchronized void generateRecipe(List<Long> recipeIdList, LocalDate applyDate) {
if (!ObjectUtil.isEmpty(recipeIdList) && !ObjectUtil.isEmpty(applyDate)) {
// List<Long> recipeIdList = new ArrayList(recipeIdList);
Map<Long, Long> recipeDetailContMap = this.menuRecipeDetailService.list(Wrappers.lambdaQuery(MenuRecipeDetail.class)
.select(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(Wrappers.<MenuRecipe>lambdaQuery()
.in(MenuRecipe::getRecipeType, Arrays.asList(2, 3))
.in(MenuRecipe::getRecipeId, recipeIdList));
if (!ObjectUtil.isEmpty(menuRecipes)) {
Map<Long, MenuRecipe> recipeMap = (Map) menuRecipes.stream().collect(Collectors.toMap(MenuRecipe::getRecipeId, Function.identity()));
List<MenuRecipeDetail> menuRecipeDetails =
this.menuRecipeDetailService.list(Wrappers.<MenuRecipeDetail>lambdaQuery()
.eq(MenuRecipeDetail::getDetailType, 1).in(MenuRecipeDetail::getRecipeId, recipeIdList));
Map<Long, Integer> recipeTypeMap = (Map) menuRecipes.stream().collect(Collectors.toMap(MenuRecipe::getRecipeId, MenuRecipe::getRecipeType));
menuRecipeDetails = this.filterMenuRecipeDetails(recipeTypeMap, menuRecipeDetails, applyDate);
if (!ObjectUtil.isEmpty(menuRecipeDetails)) {
Map<Long, List<MenuRecipeDetail>> detailMap = (Map) menuRecipeDetails.stream().collect(Collectors.groupingBy(MenuRecipeDetail::getRecipeId));
List<Long> detailIds = (List) menuRecipeDetails.stream().map(MenuRecipeDetail::getDetailId).collect(Collectors.toList());
Map<Long, List<MenuRecipeDishes>> recipeDishes = (Map) this.menuRecipeDishesService.list((Wrapper) Wrappers.lambdaQuery(MenuRecipeDishes.class)
.in(MenuRecipeDishes::getDetailId, detailIds)).stream().collect(Collectors.groupingBy(MenuRecipeDishes::getDetailId));
List<MenuRecipeDetail> recipeDetailV2List = Lists.newArrayList();
List<MenuRecipeDishes> recipeDishesV2List = Lists.newArrayList();
Iterator var13 = recipeMap.keySet().iterator();
label59:
while (true) {
Long recipeId;
Integer type;
List menuRecipeDetail;
do {
if (!var13.hasNext()) {
this.menuRecipeDetailService.saveBatch(recipeDetailV2List);
if (ObjectUtil.isNotEmpty(recipeDishesV2List)) {
this.menuRecipeDishesService.saveBatch(recipeDishesV2List);
}
return;
}
recipeId = (Long) var13.next();
type = (Integer) recipeTypeMap.get(recipeId);
menuRecipeDetail = (List) detailMap.get(recipeId);
} while (!ObjectUtil.isNotEmpty(menuRecipeDetail));
Iterator var17 = menuRecipeDetail.iterator();
while (true) {
Long detailId;
List dishes;
do {
if (!var17.hasNext()) {
continue label59;
}
MenuRecipeDetail recipeDetail = (MenuRecipeDetail) var17.next();
MenuRecipeDetail detailItem = new MenuRecipeDetail();
detailId = Id.next();
detailItem.setDetailId(detailId);
detailItem.setRecipeId(recipeId);
if (ObjectUtil.equal(type, 3)) {
detailItem.setApplyWeek(applyDate.getDayOfWeek().getValue());
}
detailItem.setApplyDate(applyDate);
detailItem.setMealtimeType(recipeDetail.getMealtimeType());
detailItem.setCrby("");
detailItem.setDetailType(2);
recipeDetailV2List.add(detailItem);
dishes = (List) recipeDishes.get(recipeDetail.getDetailId());
} while (!ObjectUtil.isNotEmpty(dishes));
Iterator var22 = dishes.iterator();
while (var22.hasNext()) {
MenuRecipeDishes dish = (MenuRecipeDishes) var22.next();
MenuRecipeDishes dishesItem = (MenuRecipeDishes) BeanUtil.copyProperties(dish, MenuRecipeDishes.class, new String[0]);
dishesItem.setDetailId(detailId);
dishesItem.setId((Long) null);
recipeDishesV2List.add(dishesItem);
}
}
}
}
}
}
}
}
public List<MenuRecipeDetail> filterMenuRecipeDetails(Map<Long, Integer> recipeTypeMap, List<MenuRecipeDetail> menuRecipeDetails, LocalDate applyDate) {
return (List)menuRecipeDetails.stream().filter((item) -> {
Long recipeId = item.getRecipeId();
Integer type = (Integer)recipeTypeMap.get(recipeId);
if (type == 3) {
return ObjectUtil.equal(item.getApplyWeek(), applyDate.getDayOfWeek().getValue());
} else {
return type == 2;
}
}).collect(Collectors.toList());
}
}

View File

@ -0,0 +1,5 @@
<?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.MenuRecipeDetailMapper">
</mapper>