fix 预约订单时间槽,增加 开业筹备中的店铺逻辑
This commit is contained in:
parent
bb0eb917c1
commit
507b65838c
@ -83,8 +83,8 @@ public class ShopStoreBase implements Serializable {
|
||||
@ApiModelProperty(value = "店铺营业状态:1-营业中;2-已打烊;3-开业(活动)筹备中;")
|
||||
private Integer store_biz_state;
|
||||
|
||||
@ApiModelProperty(value = "开业(活动)筹备具体时间 yyyy-MM-dd HH:mm:ss;")
|
||||
private Date store_biz_opening_dtime;
|
||||
@ApiModelProperty(value = "开业(活动)筹备日期 yyyy-MM-dd")
|
||||
private Date store_biz_opening_date;
|
||||
|
||||
@ApiModelProperty(value = "上级店铺编号:创建店铺决定,所属分销商-不可更改! 佣金公平性考虑")
|
||||
private Integer shop_parent_id;
|
||||
|
||||
@ -616,4 +616,6 @@ public interface ShopOrderBaseService extends IBaseService<ShopOrderBase> {
|
||||
* @return
|
||||
*/
|
||||
Boolean updateOrderTime(String orderId, Date orderTime);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -9366,4 +9366,5 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1017,19 +1017,21 @@ public class ShopOrderInfoServiceImpl extends BaseServiceImpl<ShopOrderInfoMappe
|
||||
@Override
|
||||
public List<BookingArgDTO> genBookingOrderArgList(String storeIds) {
|
||||
// 初始化营业时间对象
|
||||
Pair<String, String> timesPair = null;
|
||||
Pair<String, String> storeBizTimeRange = null;
|
||||
|
||||
// 如果storeId不为空,则尝试获取店铺信息
|
||||
if (StrUtil.isNotBlank(storeIds)) {
|
||||
// 多个店铺的营业时间段集合
|
||||
List<Pair<String, String>> timesMapList = selStoreBizTimeMapList(storeIds);
|
||||
if (!CollUtil.isEmpty(timesMapList)) {
|
||||
// 根据一个或多个店铺id获取有效店铺的有效营业时间段
|
||||
List<Pair<String, String>> storeBizTimeRangesList = selectMulStoreBizTimeRanges(storeIds);
|
||||
if (!CollUtil.isEmpty(storeBizTimeRangesList)) {
|
||||
// 获取多个店铺的营业时间段的一个交集
|
||||
timesPair = DateTimeUtils.findTimeInterSection(timesMapList);
|
||||
storeBizTimeRange = DateTimeUtils.findTimeInterSection(storeBizTimeRangesList);
|
||||
}
|
||||
}
|
||||
|
||||
if (timesPair == null || StrUtil.isBlank(timesPair.getFirst()) || StrUtil.isBlank(timesPair.getSecond())) {
|
||||
if (storeBizTimeRange == null
|
||||
|| StrUtil.isBlank(storeBizTimeRange.getFirst())
|
||||
|| StrUtil.isBlank(storeBizTimeRange.getSecond())) {
|
||||
// 没有具体的营业时间段
|
||||
logger.info("[生成预约参数] 未找到营业时间段");
|
||||
return Collections.emptyList();
|
||||
@ -1037,15 +1039,31 @@ public class ShopOrderInfoServiceImpl extends BaseServiceImpl<ShopOrderInfoMappe
|
||||
|
||||
// 显示几天的时间槽,默认7天
|
||||
int daysCnt = 7;
|
||||
List<BookingArgDTO> result = new ArrayList<>();
|
||||
List<BookingArgDTO> bookingArgList = new ArrayList<>();
|
||||
|
||||
// 判断今天还能不能立即下单和预约下单?能:就有今天的时间槽;不能:就没有今天的时间槽
|
||||
Date startDate = new Date();
|
||||
//-1-在时间段之前 0-时间段内,1-在时间段之后
|
||||
int inRangeVal = DateTimeUtils.isCurrentTimeInRange(timesPair.getFirst(), timesPair.getSecond());
|
||||
int inRangeVal = 0;
|
||||
// 今天是否可预约(在营业时间之前或之中)
|
||||
boolean isTodayAvailable = true;
|
||||
|
||||
// 获取开业(活动)筹备中店铺最晚的日期, 如果存在说明几个店铺中有开业(活动)筹备中的店铺
|
||||
Date latestBizOpeningDate = shopStoreBaseService.getLatestBizOpeningDate(storeIds);
|
||||
if (latestBizOpeningDate != null) {
|
||||
// 有开业筹备中的店铺,预约以这个开业日期为起始日期
|
||||
startDate = latestBizOpeningDate;
|
||||
inRangeVal = 1;
|
||||
isTodayAvailable = false;
|
||||
} else {
|
||||
// 判断今天还能不能立即下单和预约下单?能:就有今天的时间槽;不能:就没有今天的时间槽
|
||||
//-1-在时间段之前 0-时间段内,1-在时间段之后
|
||||
inRangeVal = DateTimeUtils.isCurrentTimeInRange(storeBizTimeRange.getFirst(), storeBizTimeRange.getSecond());
|
||||
|
||||
// 确定起始日期
|
||||
startDate = inRangeVal == 1 ? DateUtil.offsetDay(startDate, 1) : startDate;
|
||||
isTodayAvailable = inRangeVal <= 0; // 今天是否可预约(在营业时间之前或之中)
|
||||
}
|
||||
|
||||
// 确定起始日期
|
||||
Date startDate = inRangeVal == 1 ? DateUtil.offsetDay(new Date(), 1) : new Date();
|
||||
boolean isTodayAvailable = inRangeVal <= 0; // 今天是否可预约(在营业时间之前或之中)
|
||||
|
||||
for (int i = 0; i < daysCnt; i++) {
|
||||
Date currentDate = DateUtil.offsetDay(startDate, i);
|
||||
@ -1065,9 +1083,9 @@ public class ShopOrderInfoServiceImpl extends BaseServiceImpl<ShopOrderInfoMappe
|
||||
|
||||
// 设置date_title
|
||||
String dateTitle;
|
||||
if (i == 0) {
|
||||
if (i == 0 && latestBizOpeningDate == null) {
|
||||
dateTitle = isTodayAvailable ? "今天" : "明天";
|
||||
} else if (i == 1) {
|
||||
} else if (i == 1 && latestBizOpeningDate == null) {
|
||||
dateTitle = isTodayAvailable ? "明天" : "后天";
|
||||
} else {
|
||||
dateTitle = displayDateStr;
|
||||
@ -1077,8 +1095,8 @@ public class ShopOrderInfoServiceImpl extends BaseServiceImpl<ShopOrderInfoMappe
|
||||
bookingArgDTO.setDate_str(displayDateStr);
|
||||
bookingArgDTO.setDate(dateStr);
|
||||
|
||||
String startTimeStr = timesPair.getFirst();
|
||||
String endTimeStr = timesPair.getSecond();
|
||||
String startTimeStr = storeBizTimeRange.getFirst();
|
||||
String endTimeStr = storeBizTimeRange.getSecond();
|
||||
bookingArgDTO.setWorking_hours(String.format("%s-%s", startTimeStr, endTimeStr));
|
||||
|
||||
// 生成时间槽
|
||||
@ -1179,16 +1197,18 @@ public class ShopOrderInfoServiceImpl extends BaseServiceImpl<ShopOrderInfoMappe
|
||||
}
|
||||
|
||||
bookingArgDTO.setItems(items);
|
||||
result.add(bookingArgDTO);
|
||||
bookingArgList.add(bookingArgDTO);
|
||||
}
|
||||
|
||||
logger.debug("[生成预约参数] 成功生成预约参数,storeId: {}, timesMap: {}, 参数数量: {}",
|
||||
storeIds, timesPair, result.size());
|
||||
return result;
|
||||
storeIds, storeBizTimeRange, bookingArgList.size());
|
||||
return bookingArgList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据一个或多个店铺id获取有效店铺的有效营业时间段
|
||||
* <p>
|
||||
* 根据 storeIds(一个或多个 storeid,如 34,23,43,23,),先对id去重,
|
||||
* 再获取多个店铺的营业时间 List<map{startTimeStr, endTimeStr}> 列表list
|
||||
* 启动如果遇到某个店铺是开业(活动)筹备中的,获取他的开始营业的的日期和营业时间段组合出特有营业时间段
|
||||
@ -1196,7 +1216,7 @@ public class ShopOrderInfoServiceImpl extends BaseServiceImpl<ShopOrderInfoMappe
|
||||
* @param storeIds 以逗号分隔的店铺ID字符串
|
||||
* @return 包含店铺营业时间信息的列表,每个元素为包含opening_hours和close_hours的Map
|
||||
*/
|
||||
private List<Pair<String, String>> selStoreBizTimeMapList(String storeIds) {
|
||||
private List<Pair<String, String>> selectMulStoreBizTimeRanges(String storeIds) {
|
||||
// 参数校验
|
||||
if (StrUtil.isBlank(storeIds)) {
|
||||
return Collections.emptyList();
|
||||
@ -1220,7 +1240,6 @@ public class ShopOrderInfoServiceImpl extends BaseServiceImpl<ShopOrderInfoMappe
|
||||
QueryWrapper<ShopStoreInfo> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.select("store_opening_hours", "store_close_hours"); // 只查询必要字段
|
||||
queryWrapper.in("store_id", storeIds);
|
||||
|
||||
List<ShopStoreInfo> shopStoreInfos = shopStoreInfoService.find(queryWrapper);
|
||||
|
||||
// 4. 转换为营业时间映射列表
|
||||
|
||||
@ -17,6 +17,7 @@ import org.springframework.data.util.Pair;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -245,6 +246,15 @@ public interface ShopStoreBaseService extends IBaseService<ShopStoreBase> {
|
||||
*/
|
||||
Pair<Integer, String> getStoreBizState(Integer storeId);
|
||||
|
||||
|
||||
/**
|
||||
* 根据一个或多个店铺Id,获取开业(活动)筹备中店铺的营业日期最晚的那个日期
|
||||
*
|
||||
* @param storeIds 店铺ID列表,多个ID用英文逗号分隔
|
||||
* @return 最晚的营业开始日期,格式为yyyy-MM-dd
|
||||
*/
|
||||
Date getLatestBizOpeningDate(String storeIds);
|
||||
|
||||
// Page<ShopStoreBase> getMobileStoreList(Integer page, Integer rows);
|
||||
|
||||
}
|
||||
|
||||
@ -4336,6 +4336,54 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据一个或多个店铺Id,获取开业(活动)筹备中店铺的营业日期最晚的那个日期
|
||||
*
|
||||
* @param storeIds 店铺ID列表,多个ID用英文逗号分隔
|
||||
* @return 最晚的营业开始日期,格式为yyyy-MM-dd
|
||||
*/
|
||||
@Override
|
||||
public Date getLatestBizOpeningDate(String storeIds) {
|
||||
// 参数校验
|
||||
if (StrUtil.isBlank(storeIds)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
// 1. 解析并去重店铺ID
|
||||
List<Integer> uniqueStoreIds = Arrays.stream(storeIds.split(","))
|
||||
.map(String::trim)
|
||||
.filter(StrUtil::isNotBlank)
|
||||
.map(Integer::valueOf)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 2. 如果没有有效的店铺ID,返回null
|
||||
if (uniqueStoreIds.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 3. 查询开业筹备中店铺的最晚营业开始日期
|
||||
QueryWrapper<ShopStoreBase> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.select("MAX(store_biz_opening_date) AS store_biz_opening_date");
|
||||
queryWrapper.in("store_id", uniqueStoreIds)
|
||||
.eq("store_biz_state", CommonConstant.Store_Biz_State_PreActivity)
|
||||
.eq("store_is_open", CommonConstant.Enable)
|
||||
.gt("store_biz_opening_date", new Date());
|
||||
|
||||
ShopStoreBase shopStoreBase = getOne(queryWrapper);
|
||||
return shopStoreBase != null ? shopStoreBase.getStore_biz_opening_date() : null;
|
||||
|
||||
} catch (NumberFormatException e) {
|
||||
logger.warn("店铺ID解析失败: storeIds={}", storeIds, e);
|
||||
return null;
|
||||
} catch (Exception e) {
|
||||
logger.error("查询店铺最晚营业开始日期异常: storeIds={}", storeIds, e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// @Override
|
||||
// public Page<ShopStoreBase> getMobileStoreList(Integer page, Integer rows) {
|
||||
// QueryWrapper<ShopStoreBase> queryWrapper=new QueryWrapper<>();
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
store_id
|
||||
, user_id, store_name, store_grade_id, store_logo, store_slogan, store_domain, store_area, store_district_id,
|
||||
store_address, store_latitude, store_longitude, store_is_selfsupport, store_type, store_is_open,
|
||||
store_biz_state, store_biz_opening_dtime, ringtone_is_enable, shop_parent_id, store_2nd_category_id,
|
||||
store_biz_state, store_biz_opening_date, ringtone_is_enable, shop_parent_id, store_2nd_category_id,
|
||||
store_category_id, store_state_id, store_time, store_end_time, product_category_ids, store_o2o_tags,
|
||||
store_o2o_flag, store_o2o_merchant_id, store_circle, subsite_id, lkl_merchant_no, lkl_term_no, wx_qrcode,
|
||||
split_ratio, packing_fee, created_at, updated_at
|
||||
|
||||
6
pom.xml
6
pom.xml
@ -308,6 +308,7 @@
|
||||
<docker.host>https://114.132.210.208:2375</docker.host>
|
||||
<docker.registry>10.1.8.3:5000</docker.registry>
|
||||
<docker.ca>/Users/panjunjie/code/docker_registry_ca_dev</docker.ca>
|
||||
<docker.remove_old_image>false</docker.remove_old_image>
|
||||
<!-- nacos配置 -->
|
||||
<nacos.server.address>114.132.210.208:8848</nacos.server.address>
|
||||
<nacos.namespace>public</nacos.namespace>
|
||||
@ -366,6 +367,7 @@
|
||||
<docker.host>https://114.132.210.208:2375</docker.host>
|
||||
<docker.registry>10.1.8.3:5000</docker.registry>
|
||||
<docker.ca>/Users/panjunjie/code/docker_registry_ca_dev</docker.ca>
|
||||
<docker.remove_old_image>false</docker.remove_old_image>
|
||||
<!-- nacos配置 -->
|
||||
<nacos.server.address>114.132.210.208:8848</nacos.server.address>
|
||||
<nacos.namespace>public</nacos.namespace>
|
||||
@ -418,6 +420,7 @@
|
||||
<docker.host>https://114.132.210.208:2375</docker.host>
|
||||
<docker.registry>10.1.8.3:5000</docker.registry>
|
||||
<docker.ca>/Users/panjunjie/code/docker_registry_ca_dev</docker.ca>
|
||||
<docker.remove_old_image>false</docker.remove_old_image>
|
||||
<!-- nacos配置 -->
|
||||
<nacos.server.address>10.1.8.3:8848</nacos.server.address>
|
||||
<nacos.namespace>public</nacos.namespace>
|
||||
@ -470,6 +473,7 @@
|
||||
<docker.host>https://159.75.249.163:2275</docker.host>
|
||||
<docker.registry>172.16.0.11:5000</docker.registry>
|
||||
<docker.ca>/Users/panjunjie/code/docker_registry_ca_prod</docker.ca>
|
||||
<docker.remove_old_image>true</docker.remove_old_image>
|
||||
<!-- nacos配置 -->
|
||||
<nacos.server.address>172.16.0.11:8848</nacos.server.address>
|
||||
<nacos.namespace>public</nacos.namespace>
|
||||
@ -556,6 +560,8 @@
|
||||
<configuration>
|
||||
<imageName>${docker.registry}/mall/${project.artifactId}:${project.version}</imageName>
|
||||
</configuration>
|
||||
<!-- 通过profile属性控制是否执行 -->
|
||||
<inherited>${docker.remove_old_image}</inherited>
|
||||
</execution>
|
||||
|
||||
<execution>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user