预约订单参数加入下单流程。
This commit is contained in:
parent
a65fb441cb
commit
6398635707
@ -121,4 +121,8 @@ public class CommonConstant {
|
||||
public static final Integer Agent_Level_2nd = 2;
|
||||
|
||||
|
||||
// 订单配送预约状态:1-立即配送;2-预约配送
|
||||
public static final Integer Order_Booking_State_LJ = 1;
|
||||
public static final Integer Order_Booking_State_YY = 2;
|
||||
|
||||
}
|
||||
|
||||
@ -207,11 +207,11 @@ public class ShopOrderInfo implements Serializable {
|
||||
@ApiModelProperty(value = "订单配送预约状态:1-立即配送;2-预约配送")
|
||||
private Integer booking_state;
|
||||
|
||||
@ApiModelProperty(value = "预约送达起始时间,格式如:10:15")
|
||||
private String booking_begin_time;
|
||||
@ApiModelProperty(value = "预约送达起始时间,格式如:yyyy-MM-dd HH:mm:ss")
|
||||
private Date booking_begin_time;
|
||||
|
||||
@ApiModelProperty(value = "预约送达截止时间,格式如:10:45")
|
||||
private String booking_end_time;
|
||||
@ApiModelProperty(value = "预约送达截止时间,格式如:yyyy-MM-dd HH:mm:ss")
|
||||
private Date booking_end_time;
|
||||
|
||||
@ApiModelProperty(value = "新建时间")
|
||||
private Date created_at;
|
||||
|
||||
@ -8,6 +8,7 @@ import java.text.SimpleDateFormat;
|
||||
import java.time.*;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.DateTimeFormatterBuilder;
|
||||
import java.time.format.DateTimeParseException;
|
||||
import java.time.temporal.ChronoField;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
@ -62,6 +63,121 @@ public class DateTimeUtils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证日期时间字符串是否符合支持的日期时间格式
|
||||
* 支持的格式包括:
|
||||
* - yyyy-MM-dd HH:mm (如 2023-12-01 09:30)
|
||||
* - yyyy-MM-dd HH:mm:ss (如 2023-12-01 09:30:45)
|
||||
* - yyyy-MM-dd HH:mm:ss.SSS (如 2023-12-01 09:30:45.123)
|
||||
* - yyyy-MM-dd HH:mm:ss.SSSSSS (如 2023-12-01 09:30:45.123456)
|
||||
* - yyyy-MM-dd HH:mm:ss.SSSSSSSSS (如 2023-12-01 09:30:45.123456789)
|
||||
* - yyyy/MM/dd HH:mm:ss (如 2023/12/01 09:30:45)
|
||||
* - yyyy.MM.dd HH:mm:ss (如 2023.12.01 09:30:45)
|
||||
*
|
||||
* @param dateTimeStr 待验证的日期时间字符串
|
||||
* @return true表示符合日期时间格式,false表示不符合
|
||||
*/
|
||||
public static LocalDateTime tryParseDateTime(String dateTimeStr) {
|
||||
// 空值检查
|
||||
if (dateTimeStr == null || dateTimeStr.trim().isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
dateTimeStr = dateTimeStr.trim();
|
||||
|
||||
// 使用正则表达式验证日期时间格式
|
||||
// 支持多种日期分隔符和从分钟到纳秒的各种时间格式
|
||||
String dateTimePattern = "^\\d{4}[-/.]\\d{1,2}[-/.]\\d{1,2}\\s+([01]?[0-9]|2[0-3]):[0-5][0-9](:[0-5][0-9])?(\\.\\d{1,9})?$";
|
||||
|
||||
if (!dateTimeStr.matches(dateTimePattern)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
// 尝试解析日期时间,确保日期时间值有效
|
||||
// 支持三种常见分隔符:-, /, .
|
||||
if (dateTimeStr.contains("-")) {
|
||||
return parseDateTime(dateTimeStr, "yyyy-MM-dd HH:mm", "yyyy-MM-dd HH:mm:ss",
|
||||
"yyyy-MM-dd HH:mm:ss.SSS", "yyyy-MM-dd HH:mm:ss.SSSSSS",
|
||||
"yyyy-MM-dd HH:mm:ss.SSSSSSSSS");
|
||||
} else if (dateTimeStr.contains("/")) {
|
||||
return parseDateTime(dateTimeStr, "yyyy/MM/dd HH:mm", "yyyy/MM/dd HH:mm:ss",
|
||||
"yyyy/MM/dd HH:mm:ss.SSS", "yyyy/MM/dd HH:mm:ss.SSSSSS",
|
||||
"yyyy/MM/dd HH:mm:ss.SSSSSSSSS");
|
||||
} else if (dateTimeStr.contains(".")) {
|
||||
return parseDateTime(dateTimeStr, "yyyy.MM.dd HH:mm", "yyyy.MM.dd HH:mm:ss",
|
||||
"yyyy.MM.dd HH:mm:ss.SSS", "yyyy.MM.dd HH:mm:ss.SSSSSS",
|
||||
"yyyy.MM.dd HH:mm:ss.SSSSSSSSS");
|
||||
}
|
||||
return null;
|
||||
} catch (Exception e) {
|
||||
// 解析失败说明日期时间值无效
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证并解析日期时间字符串为Date对象
|
||||
* 支持的格式包括:
|
||||
* - yyyy-MM-dd HH:mm (如 2023-12-01 09:30)
|
||||
* - yyyy-MM-dd HH:mm:ss (如 2023-12-01 09:30:45)
|
||||
* - yyyy-MM-dd HH:mm:ss.SSS (如 2023-12-01 09:30:45.123)
|
||||
* - yyyy-MM-dd HH:mm:ss.SSSSSS (如 2023-12-01 09:30:45.123456)
|
||||
* - yyyy-MM-dd HH:mm:ss.SSSSSSSSS (如 2023-12-01 09:30:45.123456789)
|
||||
* - yyyy/MM/dd HH:mm:ss (如 2023/12/01 09:30:45)
|
||||
* - yyyy.MM.dd HH:mm:ss (如 2023.12.01 09:30:45)
|
||||
*
|
||||
* @param dateTimeStr 待解析的日期时间字符串
|
||||
* @return 解析后的Date对象,解析失败返回null
|
||||
*/
|
||||
public static Date tryParseDateTimeToDate(String dateTimeStr) {
|
||||
LocalDateTime localDateTime = tryParseDateTime(dateTimeStr);
|
||||
if (localDateTime != null) {
|
||||
return Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析日期时间字符串
|
||||
*
|
||||
* @param dateTimeStr 日期时间字符串
|
||||
* @param patterns 可能的日期时间格式模式
|
||||
* @return 解析后的 LocalDateTime 对象
|
||||
*/
|
||||
private static LocalDateTime parseDateTime(String dateTimeStr, String... patterns) {
|
||||
for (String pattern : patterns) {
|
||||
try {
|
||||
// 检查模式和字符串长度是否匹配
|
||||
if (isMatchingDateTimePattern(dateTimeStr, pattern)) {
|
||||
return LocalDateTime.parse(dateTimeStr, DateTimeFormatter.ofPattern(pattern));
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
// 继续尝试下一个格式
|
||||
}
|
||||
}
|
||||
|
||||
// 如果所有格式都失败,则抛出异常
|
||||
throw new DateTimeParseException("无法解析日期时间字符串: " + dateTimeStr, dateTimeStr, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断日期时间字符串是否与格式模式匹配
|
||||
*
|
||||
* @param dateTimeStr 日期时间字符串
|
||||
* @param pattern 格式模式字符串
|
||||
* @return 是否匹配
|
||||
*/
|
||||
private static boolean isMatchingDateTimePattern(String dateTimeStr, String pattern) {
|
||||
try {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern);
|
||||
LocalDateTime.parse(dateTimeStr, formatter);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 将多种日期格式转换为 yyyy-MM-dd
|
||||
@ -233,8 +349,8 @@ public class DateTimeUtils {
|
||||
/**
|
||||
* 判断指定时间是否在两个时间点之间(包含边界)
|
||||
*
|
||||
* @param startTimeStr 开始时间字符串,格式为 HH:mm
|
||||
* @param endTimeStr 结束时间字符串,格式为 HH:mm
|
||||
* @param startTimeStr 开始时间字符串,支持格式如 HH:mm, HH:mm:ss, HH:mm:ss.SSS 等
|
||||
* @param endTimeStr 结束时间字符串,支持格式如 HH:mm, HH:mm:ss, HH:mm:ss.SSS 等
|
||||
* @param currentTime 要判断的时间点
|
||||
* @return 如果在时间段内返回true,否则返回false。出现异常时返回false,不影响主流程
|
||||
*/
|
||||
@ -247,11 +363,11 @@ public class DateTimeUtils {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 解析开始时间
|
||||
LocalTime startTime = LocalTime.parse(startTimeStr, DateTimeFormatter.ofPattern("HH:mm"));
|
||||
// 解析开始时间 - 支持多种时间格式
|
||||
LocalTime startTime = parseTime(startTimeStr);
|
||||
|
||||
// 解析结束时间
|
||||
LocalTime endTime = LocalTime.parse(endTimeStr, DateTimeFormatter.ofPattern("HH:mm"));
|
||||
// 解析结束时间 - 支持多种时间格式
|
||||
LocalTime endTime = parseTime(endTimeStr);
|
||||
|
||||
// 获取当前时间的时间部分
|
||||
LocalTime nowTime = currentTime.toLocalTime();
|
||||
@ -273,18 +389,114 @@ public class DateTimeUtils {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 判断指定时间是否在两个时间点之间(包含边界)
|
||||
*
|
||||
* @param startTimeStr 开始时间字符串,支持格式如 HH:mm, HH:mm:ss, HH:mm:ss.SSS 等
|
||||
* @param endTimeStr 结束时间字符串,支持格式如 HH:mm, HH:mm:ss, HH:mm:ss.SSS 等
|
||||
* @param currentTime 要判断的时间点
|
||||
* @return 如果在时间段内返回true,否则返回false。出现异常时返回false,不影响主流程
|
||||
*/
|
||||
public static boolean isTimeInRange(String startTimeStr, String endTimeStr, Date currentTime) {
|
||||
if (currentTime == null) {
|
||||
log.warn("时间参数不能为空,startTimeStr: {}, endTimeStr: {}, currentTime: null",
|
||||
startTimeStr, endTimeStr);
|
||||
return false;
|
||||
}
|
||||
// 将Date转换为LocalDateTime并调用已有的方法
|
||||
LocalDateTime localDateTime = currentTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
|
||||
return isTimeInRange(startTimeStr, endTimeStr, localDateTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断当前时间是否在两个时间点之间(包含边界)
|
||||
*
|
||||
* @param startTimeStr 开始时间字符串,格式为 HH:mm
|
||||
* @param endTimeStr 结束时间字符串,格式为 HH:mm
|
||||
* @param startTimeStr 开始时间字符串,支持格式如 HH:mm, HH:mm:ss, HH:mm:ss.SSS 等
|
||||
* @param endTimeStr 结束时间字符串,支持格式如 HH:mm, HH:mm:ss, HH:mm:ss.SSS 等
|
||||
* @return 如果在时间段内返回true,否则返回false
|
||||
* @throws IllegalArgumentException 当时间字符串格式不正确时抛出异常
|
||||
*/
|
||||
public static boolean isCurrentTimeInRange(String startTimeStr, String endTimeStr) {
|
||||
return isTimeInRange(startTimeStr, endTimeStr, LocalDateTime.now());
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析时间字符串,支持多种时间格式
|
||||
*
|
||||
* @param timeStr 时间字符串,支持格式如 HH:mm, HH:mm:ss, HH:mm:ss.SSS 等
|
||||
* @return 解析后的 LocalTime 对象
|
||||
*/
|
||||
private static LocalTime parseTime(String timeStr) {
|
||||
if (timeStr == null || timeStr.isEmpty()) {
|
||||
throw new IllegalArgumentException("时间字符串不能为空");
|
||||
}
|
||||
|
||||
try {
|
||||
// 尝试使用不同的格式解析时间字符串
|
||||
// 按照精度从高到低排序,避免精度损失
|
||||
DateTimeFormatter[] formatters = {
|
||||
DateTimeFormatter.ofPattern("HH:mm:ss.SSSSSSSSS"), // 纳秒(9位)
|
||||
DateTimeFormatter.ofPattern("HH:mm:ss.SSSSSS"), // 微秒(6位)
|
||||
DateTimeFormatter.ofPattern("HH:mm:ss.SSS"), // 毫秒(3位)
|
||||
DateTimeFormatter.ofPattern("HH:mm:ss"), // 秒
|
||||
DateTimeFormatter.ofPattern("HH:mm") // 分钟
|
||||
};
|
||||
|
||||
// 先尝试精确匹配长度的格式
|
||||
for (DateTimeFormatter formatter : formatters) {
|
||||
try {
|
||||
// 根据格式长度进行预筛选
|
||||
String pattern = formatter.toString();
|
||||
if (isMatchingTimePattern(timeStr, pattern)) {
|
||||
return LocalTime.parse(timeStr, formatter);
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
// 继续尝试下一个格式
|
||||
}
|
||||
}
|
||||
|
||||
// 如果精确匹配失败,按原有方式尝试所有格式
|
||||
for (DateTimeFormatter formatter : formatters) {
|
||||
try {
|
||||
return LocalTime.parse(timeStr, formatter);
|
||||
} catch (Exception ignored) {
|
||||
// 继续尝试下一个格式
|
||||
}
|
||||
}
|
||||
|
||||
// 如果所有格式都失败,则抛出异常
|
||||
throw new DateTimeParseException("无法解析时间字符串: " + timeStr, timeStr, 0);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.warn("时间解析失败,timeStr: {}", timeStr, e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断时间字符串是否与格式模式匹配
|
||||
*
|
||||
* @param timeStr 时间字符串
|
||||
* @param pattern 格式模式字符串
|
||||
* @return 是否匹配
|
||||
*/
|
||||
private static boolean isMatchingTimePattern(String timeStr, String pattern) {
|
||||
// 简单的长度匹配检查
|
||||
switch (pattern) {
|
||||
case "HH:mm":
|
||||
return timeStr.length() == 5 && timeStr.charAt(2) == ':';
|
||||
case "HH:mm:ss":
|
||||
return timeStr.length() == 8 && timeStr.charAt(2) == ':' && timeStr.charAt(5) == ':';
|
||||
case "HH:mm:ss.SSS":
|
||||
return timeStr.length() == 12 && timeStr.charAt(2) == ':' && timeStr.charAt(5) == ':' && timeStr.charAt(8) == '.';
|
||||
case "HH:mm:ss.SSSSSS":
|
||||
return timeStr.length() == 15 && timeStr.charAt(2) == ':' && timeStr.charAt(5) == ':' && timeStr.charAt(8) == '.';
|
||||
case "HH:mm:ss.SSSSSSSSS":
|
||||
return timeStr.length() == 18 && timeStr.charAt(2) == ':' && timeStr.charAt(5) == ':' && timeStr.charAt(8) == '.';
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
// System.out.println(convertLklDate("2021-02-19")); // 2025-01-02
|
||||
@ -310,8 +522,9 @@ public class DateTimeUtils {
|
||||
boolean isWorkTime = isCurrentTimeInRange("09:00", "22:36");
|
||||
|
||||
// 判断特定时间是否在夜间时间(22:00-06:00)内
|
||||
LocalDateTime testTime = LocalDateTime.of(2025, 1, 1, 23, 30);
|
||||
boolean isNight = isTimeInRange("22:00", "06:00", testTime);
|
||||
// LocalDateTime testTime = LocalDateTime.of(2025, 1, 1, 23, 30);
|
||||
Date testTime = Date.from(LocalDateTime.of(2025, 10, 23, 21, 30).atZone(ZoneId.systemDefault()).toInstant());
|
||||
boolean isNight = isTimeInRange("08:30", "22:20", testTime);
|
||||
|
||||
System.out.println("当前时间是否在工作时间内:" + isWorkTime);
|
||||
System.out.println("特定时间是否在夜间时间段内:" + isNight);
|
||||
|
||||
@ -113,7 +113,7 @@ public class UserOrderController extends BaseControllerImpl {
|
||||
return CommonResult.success(shopOrderBaseService.detail(order_id));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "添加订单详细信息", notes = "添加订单详细信息")
|
||||
@ApiOperation(value = "添加订单详细信息", notes = "添加订单详细信息(提交订单)")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "ud_id", value = "收货地址编号", paramType = "query", required = true, dataType = "int"),
|
||||
@ApiImplicitParam(name = "is_edu", value = "是教育", paramType = "query", required = false, dataType = "int"),
|
||||
|
||||
@ -3,6 +3,7 @@ package com.suisung.mall.shop.order.service;
|
||||
import com.suisung.mall.common.api.CommonResult;
|
||||
import com.suisung.mall.common.modules.order.ShopOrderInfo;
|
||||
import com.suisung.mall.core.web.service.IBaseService;
|
||||
import org.springframework.data.util.Pair;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -91,6 +92,7 @@ public interface ShopOrderInfoService extends IBaseService<ShopOrderInfo> {
|
||||
|
||||
/**
|
||||
* 分页查询取消订单
|
||||
*
|
||||
* @param pageNum
|
||||
* @param pageSize
|
||||
* @return
|
||||
@ -99,7 +101,19 @@ public interface ShopOrderInfoService extends IBaseService<ShopOrderInfo> {
|
||||
|
||||
/**
|
||||
* 查询取消订单总数
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
long countgetAutoCancelOrderId();
|
||||
|
||||
/**
|
||||
* 检查订单预约参数是否合法
|
||||
*
|
||||
* @param storeId 店铺ID
|
||||
* @param bookingState 预约配送状态
|
||||
* @param bookingBeginTime 预约开始时间
|
||||
* @param bookingEndTime 预约截止时间
|
||||
* @return
|
||||
*/
|
||||
Pair<Boolean, String> checkBookingOrderArgs(Integer storeId, Integer bookingState, String bookingBeginTime, String bookingEndTime);
|
||||
}
|
||||
|
||||
@ -1606,6 +1606,21 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
|
||||
}
|
||||
}
|
||||
|
||||
// 预约订单检测
|
||||
Integer bookingState = Convert.toInt(getParameter("booking_state"));
|
||||
if (CheckUtil.isNotEmpty(bookingState) && CommonConstant.Order_Booking_State_YY.equals(bookingState)) {
|
||||
String bookingBeginTime = getParameter("booking_begin_time");
|
||||
String bookingEndTime = getParameter("booking_end_time");
|
||||
Pair<Boolean, String> pair = shopOrderInfoService.checkBookingOrderArgs(checkedStore, bookingState, bookingBeginTime, bookingEndTime);
|
||||
if (!pair.getFirst()) {
|
||||
throw new ApiException(I18nUtil._(pair.getSecond()));
|
||||
}
|
||||
|
||||
cartData.put("booking_state", bookingState);
|
||||
cartData.put("booking_begin_time", bookingBeginTime);
|
||||
cartData.put("booking_end_time", bookingEndTime);
|
||||
}
|
||||
|
||||
// 添加保存订单(关键方法)
|
||||
List<String> orderIdRow = addOrder(cartData, true, false, null);
|
||||
|
||||
@ -6617,13 +6632,21 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
|
||||
info_row.setCoupon_type_id(shopProductIndex.getCoupon_type_id());
|
||||
}
|
||||
|
||||
// 预约订单关键字段保存处理
|
||||
Integer bookingState = Convert.toInt(cart_data.get("booking_state"));
|
||||
Date bookingBeginTime = DateTimeUtils.tryParseDateTimeToDate(Convert.toStr(cart_data.get("booking_begin_time")));
|
||||
Date bookingEndTime = DateTimeUtils.tryParseDateTimeToDate(Convert.toStr(cart_data.get("booking_end_time")));
|
||||
if (CommonConstant.Order_Booking_State_YY.equals(bookingState) && bookingBeginTime != null && bookingEndTime != null) {
|
||||
info_row.setBooking_state(bookingState);
|
||||
info_row.setBooking_begin_time(bookingBeginTime);
|
||||
info_row.setBooking_end_time(bookingEndTime);
|
||||
}
|
||||
|
||||
info_row.setActivity_json(JSONUtil.toJsonStr(store_item.get("discount_detail_rows")));
|
||||
|
||||
info_row.setPayment_form_id(payment_form_id);
|
||||
|
||||
UserDto user = getCurrentUser();
|
||||
|
||||
|
||||
if (ObjectUtil.isNotEmpty(user) && user.isChain()) {
|
||||
info_row.setChain_id(Convert.toInt(user.getChain_id()));
|
||||
}
|
||||
|
||||
@ -25,9 +25,11 @@ import com.suisung.mall.common.modules.order.ShopOrderStateLog;
|
||||
import com.suisung.mall.common.modules.pay.PayPlantformResource;
|
||||
import com.suisung.mall.common.modules.plantform.ShopPlantformFeedback;
|
||||
import com.suisung.mall.common.modules.product.ShopProductComment;
|
||||
import com.suisung.mall.common.modules.store.ShopStoreInfo;
|
||||
import com.suisung.mall.common.pojo.res.ThirdApiRes;
|
||||
import com.suisung.mall.common.utils.CheckUtil;
|
||||
import com.suisung.mall.common.utils.CommonUtil;
|
||||
import com.suisung.mall.common.utils.DateTimeUtils;
|
||||
import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
|
||||
import com.suisung.mall.shop.base.service.AccountBaseConfigService;
|
||||
import com.suisung.mall.shop.base.service.ShopBaseStateCodeService;
|
||||
@ -41,12 +43,14 @@ import com.suisung.mall.shop.product.service.ShopProductBaseService;
|
||||
import com.suisung.mall.shop.product.service.ShopProductCommentService;
|
||||
import com.suisung.mall.shop.sfexpress.service.SFExpressApiService;
|
||||
import com.suisung.mall.shop.store.service.ShopStoreBaseService;
|
||||
import com.suisung.mall.shop.store.service.ShopStoreInfoService;
|
||||
import com.suisung.mall.shop.store.service.ShopStorePrinterService;
|
||||
import com.suisung.mall.shop.store.service.ShopStoreSfOrderService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.data.util.Pair;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
@ -84,6 +88,8 @@ public class ShopOrderInfoServiceImpl extends BaseServiceImpl<ShopOrderInfoMappe
|
||||
@Autowired
|
||||
private ShopStoreBaseService shopStoreBaseService;
|
||||
@Autowired
|
||||
private ShopStoreInfoService shopStoreInfoService;
|
||||
@Autowired
|
||||
private ShopDistributionUserCommissionService shopDistributionUserCommissionService;
|
||||
@Autowired
|
||||
private AccountBaseConfigService accountBaseConfigService;
|
||||
@ -182,8 +188,6 @@ public class ShopOrderInfoServiceImpl extends BaseServiceImpl<ShopOrderInfoMappe
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取能自动确认收货的订单号
|
||||
*
|
||||
@ -789,7 +793,7 @@ public class ShopOrderInfoServiceImpl extends BaseServiceImpl<ShopOrderInfoMappe
|
||||
@Override
|
||||
public List<String> getAutoCancelOrderIdByPage(Integer pageNum, Integer pageSize) {
|
||||
QueryWrapper<ShopOrderInfo> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.select("order_id","order_state_id");
|
||||
queryWrapper.select("order_id", "order_state_id");
|
||||
queryWrapper.eq("order_state_id", StateCode.ORDER_STATE_WAIT_PAY)
|
||||
.eq("order_is_paid", StateCode.ORDER_PAID_STATE_NO)
|
||||
.eq("payment_type_id", StateCode.PAYMENT_TYPE_ONLINE);
|
||||
@ -798,7 +802,7 @@ public class ShopOrderInfoServiceImpl extends BaseServiceImpl<ShopOrderInfoMappe
|
||||
int second = NumberUtil.mul(order_autocancel_time, 60, 60).intValue();
|
||||
long time = DateUtil.offsetSecond(new Date(), -second).getTime();
|
||||
queryWrapper.lt("order_time", time);
|
||||
List<ShopOrderInfo> shopOrderInfos=this.lists(queryWrapper,pageNum,pageSize).getRecords();
|
||||
List<ShopOrderInfo> shopOrderInfos = this.lists(queryWrapper, pageNum, pageSize).getRecords();
|
||||
return shopOrderInfos.stream().map(ShopOrderInfo::getOrder_id).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@ -816,5 +820,56 @@ public class ShopOrderInfoServiceImpl extends BaseServiceImpl<ShopOrderInfoMappe
|
||||
return this.count(queryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查订单预约参数是否合法
|
||||
*
|
||||
* @param storeId 店铺ID
|
||||
* @param bookingState 预约配送状态
|
||||
* @param bookingBeginTimeStr 预约开始时间
|
||||
* @param bookingEndTimeStr 预约截止时间
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Pair<Boolean, String> checkBookingOrderArgs(Integer storeId, Integer bookingState, String bookingBeginTimeStr, String bookingEndTimeStr) {
|
||||
if (CheckUtil.isEmpty(storeId) || CheckUtil.isEmpty(bookingState)) {
|
||||
return Pair.of(false, "[预约订单校验] 缺少必要参数");
|
||||
}
|
||||
|
||||
if (!CommonConstant.Order_Booking_State_YY.equals(bookingState)) {
|
||||
return Pair.of(true, "[预约订单校验] 非预订单,跳过验证");
|
||||
}
|
||||
|
||||
if (StrUtil.hasBlank(bookingBeginTimeStr, bookingEndTimeStr)) {
|
||||
return Pair.of(false, "[预约订单校验] 预约时间不能为空");
|
||||
}
|
||||
|
||||
Date bookingBeginTime = DateTimeUtils.tryParseDateTimeToDate(bookingBeginTimeStr);
|
||||
Date bookingEndTime = DateTimeUtils.tryParseDateTimeToDate(bookingEndTimeStr);
|
||||
if (bookingBeginTime == null || bookingBeginTime == null) {
|
||||
return Pair.of(false, "[预约订单校验] 预约时间格式有误");
|
||||
}
|
||||
|
||||
// 验证开始时间是否早于结束时间
|
||||
if (bookingBeginTime.after(bookingEndTime)) {
|
||||
return Pair.of(false, "[预约订单校验] 开始时间不能晚于截止时间");
|
||||
}
|
||||
|
||||
// 判断预约订单开始时间是否在店铺的营业时间段里?
|
||||
ShopStoreInfo shopStoreInfo = shopStoreInfoService.getShopStoreInfoByStoreId(storeId);
|
||||
if (shopStoreInfo == null) {
|
||||
return Pair.of(false, "[预约订单校验] 店铺信息有误");
|
||||
}
|
||||
|
||||
if (StrUtil.isBlank(shopStoreInfo.getStore_opening_hours()) || StrUtil.isBlank(shopStoreInfo.getStore_close_hours())) {
|
||||
return Pair.of(false, "[预约订单校验] 店铺营业时间未设置");
|
||||
}
|
||||
|
||||
if (!DateTimeUtils.isTimeInRange(shopStoreInfo.getStore_opening_hours(), shopStoreInfo.getStore_close_hours(), bookingBeginTime)) {
|
||||
return Pair.of(false, "[预约订单校验] 预约时间不在店铺营业时间内");
|
||||
}
|
||||
|
||||
return Pair.of(true, "[预约订单校验] 成功");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1517,10 +1517,10 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
|
||||
|
||||
// RMK 第三方数据同步相关:redis 新增返还思迅库存
|
||||
Map<String, Integer> stockDeltaMap = new HashMap<>();
|
||||
String item_src_id= productItem.getItem_src_id();
|
||||
String item_src_id = productItem.getItem_src_id();
|
||||
stockDeltaMap.put(item_src_id + "-" + shopOrderItem.getOrder_id(), returnNum);
|
||||
syncThirdDataService.incrProductStockToRedis(stockDeltaMap);
|
||||
logger.info("退货返回给思迅,存入redis成功,item_src_id:{},订单号:{},数量:{}",item_src_id,shopOrderReturn.getOrder_id(),returnNum);
|
||||
logger.info("退货返回给思迅,存入redis成功,item_src_id:{},订单号:{},数量:{}", item_src_id, shopOrderReturn.getOrder_id(), returnNum);
|
||||
} else {
|
||||
logger.warn("退货数量为空,无法增加库存,订单项ID: {}", orderItemId);
|
||||
}
|
||||
@ -2112,25 +2112,25 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
|
||||
public boolean ifDenyReturn(ShopOrderInfo shopOrderInfo, ShopOrderItem shopOrderItem, ShopProductIndex shopProductIndex) {
|
||||
// 1. 参数校验
|
||||
if (shopOrderItem == null) {
|
||||
log.warn("[是否禁止退货] 订单商品数据为空");
|
||||
log.debug("[是否禁止退货] 订单商品数据为空 true");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (shopOrderInfo == null) {
|
||||
log.warn("[是否禁止退货] 订单信息为空");
|
||||
log.debug("[是否禁止退货] 订单信息为空 true");
|
||||
return true;
|
||||
}
|
||||
|
||||
String orderId = shopOrderInfo.getOrder_id();
|
||||
Integer orderStateId = shopOrderInfo.getOrder_state_id();
|
||||
if (StrUtil.isBlank(orderId) || CheckUtil.isEmpty(orderStateId)) {
|
||||
log.warn("[是否禁止退货] 订单ID或订单状态为空");
|
||||
log.debug("[是否禁止退货] 订单ID或订单状态为空 true");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (orderStateId.intValue() == StateCode.ORDER_STATE_CANCEL ||
|
||||
orderStateId.intValue() == StateCode.ORDER_STATE_WAIT_PAY) {
|
||||
log.debug("[是否禁止退货] 订单已取消或未支付,order_id: {}", orderId);
|
||||
log.debug("[是否禁止退货] 订单已取消或未支付,true order_id: {}", orderId);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -2145,11 +2145,11 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
|
||||
|
||||
// 检查是否超过退货期限
|
||||
if (orderDealTime != null && withdrawTime.compareTo(orderDealTime) > 0) {
|
||||
log.debug("[是否禁止退货] 订单已超过退货期限,order_id: {}", orderId);
|
||||
log.debug("[是否禁止退货] 订单已超过退货期限 true,order_id: {}", orderId);
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("[是否禁止退货] 检查订单退货期限时发生异常,order_id: {}", orderId, e);
|
||||
log.error("[是否禁止退货] 检查订单退货期限时发生异常 true,order_id: {}", orderId, e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2160,7 +2160,7 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
|
||||
boolean isDrawn = lklOrderDrawService.isOrderDrawed(orderId);
|
||||
|
||||
if (isSeparated && isDrawn) {
|
||||
log.debug("[是否禁止退货] 拉卡拉分账订单已提现,不允许退货,order_id: {}", orderId);
|
||||
log.debug("[是否禁止退货] 拉卡拉分账订单已提现,不允许退货 true,order_id: {}", orderId);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -2170,7 +2170,7 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
|
||||
|
||||
Long productId = shopOrderItem.getProduct_id();
|
||||
if (CheckUtil.isEmpty(productId)) {
|
||||
log.warn("[是否禁止退货] 商品ID为空");
|
||||
log.debug("[是否禁止退货] 商品ID为空 true");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -2182,7 +2182,7 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
|
||||
}
|
||||
|
||||
if (productIndex == null) {
|
||||
log.warn("[是否禁止退货] 商品索引信息不存在,product_id: {}", productId);
|
||||
log.debug("[是否禁止退货] 商品索引信息不存在 true,product_id: {}", productId);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -2192,15 +2192,16 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
|
||||
try {
|
||||
List<Integer> contractTypeIds = Convert.toList(Integer.class, contractTypeIdsStr);
|
||||
if (contractTypeIds != null && contractTypeIds.contains(StateCode.CONTRACT_TYPE_DENY_RETURN)) {
|
||||
log.debug("[是否禁止退货] 商品设置了禁止退货标识,order_id: {}, product_id: {}", orderId, productId);
|
||||
log.debug("[是否禁止退货] 商品设置了禁止退货标识 true,order_id: {}, product_id: {}", orderId, productId);
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("[是否禁止退货] 解析商品保障类型失败,order_id: {}, product_id: {}", orderId, productId, e);
|
||||
log.error("[是否禁止退货] 解析商品保障类型失败 true,order_id: {}, product_id: {}", orderId, productId, e);
|
||||
}
|
||||
}
|
||||
|
||||
// 默认允许退货
|
||||
log.debug("[是否禁止退货] false}");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user