Merge remote-tracking branch 'origin/ah-sbd-h5' into ah-sbd-h5

This commit is contained in:
lizhenhua 2025-08-26 16:45:40 +08:00
commit 4ebf60c66e
8 changed files with 168 additions and 32 deletions

View File

@ -3,6 +3,7 @@ package com.bonus.canteen.core.allocation.api;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.bonus.canteen.core.allocation.canteen.mapper.AllocStallMapper;
import com.bonus.common.houqin.constant.LeConstants; import com.bonus.common.houqin.constant.LeConstants;
import com.bonus.canteen.core.allocation.alloc.model.AllocMetadata; import com.bonus.canteen.core.allocation.alloc.model.AllocMetadata;
import com.bonus.canteen.core.allocation.alloc.service.AllocMetadataService; import com.bonus.canteen.core.allocation.alloc.service.AllocMetadataService;
@ -16,6 +17,7 @@ import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
@ -28,6 +30,9 @@ public class GlobalMetadataApi {
@Lazy @Lazy
private AllocMetadataService allocMetadataService; private AllocMetadataService allocMetadataService;
@Resource
private AllocStallMapper allocStallMapper;
@Resource @Resource
@Lazy @Lazy
private AllocStallApi allocStallApi; private AllocStallApi allocStallApi;
@ -116,7 +121,12 @@ public class GlobalMetadataApi {
} }
public <T> T getAvailableModel(MetadataModelTypeEnum modelTypeEnum, T t, Long canteenId, Long stallId) { public <T> T getAvailableModel(MetadataModelTypeEnum modelTypeEnum, T t, Long canteenId, Long stallId) {
List<AllocMetadata> metadataList = this.getAvailableList(modelTypeEnum, canteenId, stallId); List<AllocMetadata> metadataList =new ArrayList<>();
if("order".equals(modelTypeEnum.getKey())){
metadataList=allocStallMapper.queryAvailableOrder(modelTypeEnum.getKey(),canteenId,stallId);
}else{
metadataList = this.getAvailableList(modelTypeEnum, canteenId, stallId);
}
return MetadataUtil.transferToPayModel(metadataList, t); return MetadataUtil.transferToPayModel(metadataList, t);
} }

View File

@ -1,6 +1,7 @@
package com.bonus.canteen.core.allocation.canteen.mapper; package com.bonus.canteen.core.allocation.canteen.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.bonus.canteen.core.allocation.alloc.model.AllocMetadata;
import com.bonus.canteen.core.allocation.canteen.model.AllocStall; import com.bonus.canteen.core.allocation.canteen.model.AllocStall;
import com.bonus.canteen.core.allocation.canteen.vo.AllocCanteenStallVO; import com.bonus.canteen.core.allocation.canteen.vo.AllocCanteenStallVO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
@ -16,4 +17,6 @@ public interface AllocStallMapper extends BaseMapper<AllocStall> {
List<AllocCanteenStallVO.StallVO> listAllCanteenStall(@Param("canteenId") Long canteenId); List<AllocCanteenStallVO.StallVO> listAllCanteenStall(@Param("canteenId") Long canteenId);
String getStallNameByIdSet(@Param("stallIdSet") Set<Long> stallIdSet); String getStallNameByIdSet(@Param("stallIdSet") Set<Long> stallIdSet);
List<AllocMetadata> queryAvailableOrder(@Param("modelType") String modelType,@Param("canteenId") Long canteenId, @Param("stallId") Long stallId);
} }

View File

@ -21,6 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
@ -62,8 +63,23 @@ public class AllocStallServiceImpl extends ServiceImpl<AllocStallMapper, AllocSt
@Override @Override
public List<LocalDate> listReserveDate(AllocMobileCanteenQueryDTO queryDTO) { public List<LocalDate> listReserveDate(AllocMobileCanteenQueryDTO queryDTO) {
AllocCanteenOrderDTO allocCanteenOrderDTO = this.allocOrderMetadataApi.queryAvailableOrder(queryDTO.getCanteenId(), queryDTO.getStallId()); AllocCanteenOrderDTO allocCanteenOrderDTO = this.allocOrderMetadataApi.queryAvailableOrder(queryDTO.getCanteenId(), queryDTO.getStallId());
String ifReserveSkipHoliday = allocCanteenOrderDTO.getIfReserveSkipHoliday(); System.out.println("ifReserveSkipHoliday="+allocCanteenOrderDTO.getIfReserveSkipHoliday()+";reserveLimitDayNum="+allocCanteenOrderDTO.getReserveLimitDay()+"" +
Integer reserveLimitDayNum = Integer.parseInt(allocCanteenOrderDTO.getReserveLimitDay()); ";ifAllowReserveToday="+allocCanteenOrderDTO.getIfAllowReserveToday());
String ifReserveSkipHoliday="1";
if(allocCanteenOrderDTO.getIfReserveSkipHoliday()!=null&&!"".equals(allocCanteenOrderDTO.getIfReserveSkipHoliday())){
ifReserveSkipHoliday= allocCanteenOrderDTO.getIfReserveSkipHoliday();
}else{
ifReserveSkipHoliday="1";
}
Integer reserveLimitDayNum = 7;
try{
reserveLimitDayNum=Integer.parseInt(allocCanteenOrderDTO.getReserveLimitDay());
}catch (Exception e){
reserveLimitDayNum=7;
}
if(allocCanteenOrderDTO.getIfAllowReserveToday()==null||"".equals(allocCanteenOrderDTO.getIfAllowReserveToday())){
allocCanteenOrderDTO.setIfAllowReserveToday("1");
}
return this.listMatchData(ifReserveSkipHoliday, reserveLimitDayNum, allocCanteenOrderDTO.getIfAllowReserveToday()); return this.listMatchData(ifReserveSkipHoliday, reserveLimitDayNum, allocCanteenOrderDTO.getIfAllowReserveToday());
} }
@ -72,42 +88,47 @@ public class AllocStallServiceImpl extends ServiceImpl<AllocStallMapper, AllocSt
return "yst:" + var10000 + ":alloc-stall:" + stallId; return "yst:" + var10000 + ":alloc-stall:" + stallId;
} }
private List<LocalDate> listMatchData(String skipFlagStr, Integer limitNum, String ifAllowReserveToday) { private List<LocalDate> listMatchData(String skipFlagStr, Integer limitNum, String ifAllowReserveToday) {
log.info(String.format("查询日期,是否调过节假日:%s,天数:%d", skipFlagStr, limitNum)); log.info(String.format("查询日期,是否调过节假日:%s,天数:%d", skipFlagStr, limitNum));
List<LocalDate> reserveDateList = new ArrayList(); List<LocalDate> reserveDateList = new ArrayList();
LocalDate startDate; try{
if ("1".equals(ifAllowReserveToday)) { LocalDate startDate;
log.info("允许预定当天"); if ("1".equals(ifAllowReserveToday)) {
startDate = LocalDate.now(); log.info("允许预定当天");
} else { limitNum=limitNum+1;
log.info("不允许预定当天"); startDate = LocalDate.now();
startDate = LocalDate.now().plusDays(1L); } else {
} log.info("不允许预定当天");
startDate = LocalDate.now().plusDays(1L);
if ("2".equals(skipFlagStr)) {
for(int i = 0; i < limitNum; ++i) {
reserveDateList.add(startDate.plusDays((long)i));
} }
} else {
List<LocalDate> holidayList = this.allocHolidayApi.getHolidayList();
for(int i = 0; i < limitNum; ++i) { if ("2".equals(skipFlagStr)) {
LocalDate reserveDate = startDate.plusDays((long)i); for(int i = 0; i < limitNum; ++i) {
boolean skipFlag = false; reserveDateList.add(startDate.plusDays((long)i));
Iterator var10 = holidayList.iterator(); }
} else {
List<LocalDate> holidayList = this.allocHolidayApi.getHolidayList();
while(var10.hasNext()) { for(int i = 0; i < limitNum; ++i) {
LocalDate holiday = (LocalDate)var10.next(); LocalDate reserveDate = startDate.plusDays((long)i);
if (reserveDate.isEqual(holiday)) { boolean skipFlag = false;
skipFlag = true; Iterator var10 = holidayList.iterator();
limitNum = limitNum + 1;
while(var10.hasNext()) {
LocalDate holiday = (LocalDate)var10.next();
if (reserveDate.isEqual(holiday)) {
skipFlag = true;
limitNum = limitNum + 1;
}
}
if (!skipFlag) {
reserveDateList.add(reserveDate);
} }
} }
if (!skipFlag) {
reserveDateList.add(reserveDate);
}
} }
}catch (Exception e){
e.printStackTrace();
} }
return reserveDateList; return reserveDateList;

View File

@ -4,10 +4,12 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bonus.canteen.core.menu.model.AllocMealtimeModel;
import com.bonus.common.core.exception.ServiceException; import com.bonus.common.core.exception.ServiceException;
import com.bonus.common.houqin.constant.DelFlagEnum; import com.bonus.common.houqin.constant.DelFlagEnum;
import com.bonus.canteen.core.allocation.api.AllocCanteenApi; import com.bonus.canteen.core.allocation.api.AllocCanteenApi;
@ -37,6 +39,7 @@ import com.bonus.canteen.core.order.api.OrderMenuApi;
import com.bonus.canteen.core.order.common.vo.OrderGoodsNumVO; import com.bonus.canteen.core.order.common.vo.OrderGoodsNumVO;
import com.bonus.common.houqin.i18n.I18n; import com.bonus.common.houqin.i18n.I18n;
import com.bonus.common.houqin.utils.id.Id; import com.bonus.common.houqin.utils.id.Id;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -285,6 +288,33 @@ public class MenuRecipeServiceImpl extends ServiceImpl<MenuRecipeMapper, MenuRec
if (ObjectUtil.isEmpty(resultList)) { if (ObjectUtil.isEmpty(resultList)) {
return resultList; return resultList;
} else { } else {
for(AppletReserveRecipeVO vo:resultList){
List<AppletReserveRecipeTypeVO> typeList=vo.getTypeList();
if (ObjectUtil.isNotEmpty(typeList)) {
for(AppletReserveRecipeTypeVO vo1:typeList){
List<AppletReserveRecipeDishesVO> dishesList=vo1.getDishesList();
if (ObjectUtil.isNotEmpty(dishesList)) {
for(AppletReserveRecipeDishesVO vo2:dishesList){
String mealtime=vo2.getMealTime();
if(mealtime!=null&&mealtime.contains("\"endTime\":")){
ObjectMapper mapper = new ObjectMapper();
AllocMealtimeModel person =new AllocMealtimeModel();
try{
person = (AllocMealtimeModel) JSONObject.parseObject(mealtime, AllocMealtimeModel.class);
}catch (Exception e){e.printStackTrace();}
if(person!=null){
vo2.setStartTime(person.getReserveStartTime());
}
if(person!=null){
vo2.setEndTime(person.getReserveEndTime());
}
}
}
}
}
}
}
resultList.sort(Collections.reverseOrder((s1, s2) -> { resultList.sort(Collections.reverseOrder((s1, s2) -> {
return s2.getMealtimeType() - s1.getMealtimeType(); return s2.getMealtimeType() - s1.getMealtimeType();
})); }));

View File

@ -7,6 +7,7 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalTime;
import java.util.List; import java.util.List;
@ApiModel("菜品详情") @ApiModel("菜品详情")
@ -45,6 +46,14 @@ public class AppletReserveRecipeDishesVO {
private List<String> tasteNameList; private List<String> tasteNameList;
@ApiModelProperty("预定时间") @ApiModelProperty("预定时间")
private String reserveEndTime; private String reserveEndTime;
@ApiModelProperty("当日预定时间")
private String mealTime;
@ApiModelProperty("当日预定结束时间")
private LocalTime endTime;
@ApiModelProperty("当日预定开始时间")
private LocalTime startTime;
@ApiModelProperty("预定餐最多允许订多少天 默认:7")
private String reserveLimitDay;
public String getDishesImgUrl() { public String getDishesImgUrl() {
return ObjectUtil.isNotEmpty(this.dishesImgUrl) ? SysUtil.getCutFileUrl(this.dishesImgUrl.split(",")[0]) : this.dishesImgUrl; return ObjectUtil.isNotEmpty(this.dishesImgUrl) ? SysUtil.getCutFileUrl(this.dishesImgUrl.split(",")[0]) : this.dishesImgUrl;
@ -181,4 +190,36 @@ public class AppletReserveRecipeDishesVO {
public void setReserveEndTime(String reserveEndTime) { public void setReserveEndTime(String reserveEndTime) {
this.reserveEndTime = reserveEndTime; this.reserveEndTime = reserveEndTime;
} }
public String getMealTime() {
return mealTime;
}
public void setMealTime(String mealTime) {
this.mealTime = mealTime;
}
public LocalTime getEndTime() {
return endTime;
}
public void setEndTime(LocalTime endTime) {
this.endTime = endTime;
}
public LocalTime getStartTime() {
return startTime;
}
public void setStartTime(LocalTime startTime) {
this.startTime = startTime;
}
public String getReserveLimitDay() {
return reserveLimitDay;
}
public void setReserveLimitDay(String reserveLimitDay) {
this.reserveLimitDay = reserveLimitDay;
}
} }

View File

@ -235,9 +235,11 @@ public class OrderPlaceMobileBusinessImplV3 implements OrderPlaceMobileBusiness
, (Long) LeNumUtil.reduceField(reserveMealDTO.getReserveMealList(), OrderReserveMealDTO::getCanteenId , (Long) LeNumUtil.reduceField(reserveMealDTO.getReserveMealList(), OrderReserveMealDTO::getCanteenId
, (Object)null), (Long)LeNumUtil.reduceField(reserveMealDTO.getReserveMealList() , (Object)null), (Long)LeNumUtil.reduceField(reserveMealDTO.getReserveMealList()
, OrderReserveMealDTO::getStallId, (Object)null), headerDTO.getOpenid(), custInfo, reserveMealDTO); , OrderReserveMealDTO::getStallId, (Object)null), headerDTO.getOpenid(), custInfo, reserveMealDTO);
OrderSavePO orderSavePO = this.packageOrderInfo(reserveMealDTO, reserveMealDTO.getReserveMealList(), payDTO); OrderSavePO orderSavePO = this.packageOrderInfo(reserveMealDTO, reserveMealDTO.getReserveMealList(), payDTO);
this.reserveMealOrderPlaceCheck(orderSavePO.getOrderInfoList(), orderSavePO.getOrderDetailList() this.reserveMealOrderPlaceCheck(orderSavePO.getOrderInfoList(), orderSavePO.getOrderDetailList()
, orderSavePO.getOrderDeliveryList()); , orderSavePO.getOrderDeliveryList());
if (LeConstants.COMMON_NO.equals(reserveMealDTO.getIfTrial())) { if (LeConstants.COMMON_NO.equals(reserveMealDTO.getIfTrial())) {
this.orderPlaceBusiness.orderHandlerLock(orderSavePO.getMacOrderId(), OrderCacheConstants.MOBILE_PAY_INTERVAL); this.orderPlaceBusiness.orderHandlerLock(orderSavePO.getMacOrderId(), OrderCacheConstants.MOBILE_PAY_INTERVAL);
} }

View File

@ -13,5 +13,22 @@
#{stallId} #{stallId}
</foreach> </foreach>
</select> </select>
<select id="queryAvailableOrder" resultType="com.bonus.canteen.core.allocation.alloc.model.AllocMetadata">
select metadata_id as metadataId,
area_id as areaId,
canteen_id as canteenId,
stall_id as stallId,
if_active as ifActive,
model_type as modelType,
model_key as modelKey,
model_value as modelValue,
model_key_remark as modelKeyRemark,
crby as crby,
crtime as crtime,
upby as upby,
uptime as uptime,
model_item as modelItem
from alloc_metadata where canteen_id=#{canteenId} and stall_id=#{stallId} and model_type=#{modelType}
</select>
</mapper> </mapper>

View File

@ -147,6 +147,7 @@
<result property="canteenName" column="canteen_name"/> <result property="canteenName" column="canteen_name"/>
<result property="stallId" column="stall_id"/> <result property="stallId" column="stall_id"/>
<result property="reserveEndTime" column="reserveEndTime"/> <result property="reserveEndTime" column="reserveEndTime"/>
<result property="mealTime" column="mealTime"/>
<result property="stallName" column="stall_name"/> <result property="stallName" column="stall_name"/>
<result property="recommendFlag" column="recommend_flag"/> <result property="recommendFlag" column="recommend_flag"/>
<collection property="dishesDetailList" ofType="com.bonus.canteen.core.menu.vo.AppletCurrentDishesDetailVO"> <collection property="dishesDetailList" ofType="com.bonus.canteen.core.menu.vo.AppletCurrentDishesDetailVO">
@ -193,7 +194,7 @@
md.size_json, md.size_json,
mdtt.taste_name, mdtt.taste_name,
mdsr.monthly_sales, mdsr.monthly_sales,
mdsr.good_probability,amd.model_value as reserveEndTime mdsr.good_probability,amd.model_value as reserveEndTime,amd2.model_value as mealTime,amdlimit.model_value as reserveLimitDay
from from
menu_recipe_detail mrd menu_recipe_detail mrd
inner join menu_recipe_dishes m on mrd.detail_id = m.detail_id inner join menu_recipe_dishes m on mrd.detail_id = m.detail_id
@ -211,6 +212,17 @@
left join menu_taste_dishes mtd on md.dishes_id = mtd.dishes_id left join menu_taste_dishes mtd on md.dishes_id = mtd.dishes_id
left join menu_dishes_taste mdtt on mtd.taste_id = mdtt.taste_id left join menu_dishes_taste mdtt on mtd.taste_id = mdtt.taste_id
left join alloc_metadata amd on mr.canteen_id = amd.canteen_id and mr.stall_id = amd.stall_id and amd.model_key='reserveEndTime' left join alloc_metadata amd on mr.canteen_id = amd.canteen_id and mr.stall_id = amd.stall_id and amd.model_key='reserveEndTime'
left join alloc_metadata amdlimit on mr.canteen_id = amdlimit.canteen_id and mr.stall_id = amdlimit.stall_id and amdlimit.model_key='reserveLimitDay'
left join (
select a.*,case when a.model_key='mealtimeBreakfast' then '1'
when a.model_key='mealtimeLunch' then '2'
when a.model_key='mealtimeAfternoonTea' then '3'
when a.model_key='mealtimeDinner' then '4'
when a.model_key='mealtimeMidnightSnack' then '5'
else '0' end as model_keyd
from alloc_metadata a where a.model_type='mealtime'
) amd2
on mrd.mealtime_type=amd2.model_keyd and mr.canteen_id = amd2.canteen_id and mr.stall_id = amd2.stall_id
where where
mrd.apply_date = #{applyDate} mrd.apply_date = #{applyDate}
and mr.recipe_id = #{recipeId} and mr.recipe_id = #{recipeId}