You've already forked FrameTour-BE
- 修改 DiscountType 枚举,将 FLASH_SALE 改为 LIMITED_TIME - 优化 OrderServiceImpl 中的商品信息设置逻辑,增加空值判断 - 更新 IDiscountProvider 接口和 FlashSaleDiscountProvider 类中的提供者类型标识- 优化 ScenicServiceImpl 中的字符串判空逻辑,使用 Strings.isNotBlank 方法 - 重构 PriceCacheService 中的商品列表哈希值计算逻辑,仅基于必传字段生成哈希
61 lines
1.9 KiB
Java
61 lines
1.9 KiB
Java
package com.ycwl.basic.pricing.service;
|
|
|
|
import com.ycwl.basic.pricing.dto.DiscountDetectionContext;
|
|
import com.ycwl.basic.pricing.dto.DiscountInfo;
|
|
import com.ycwl.basic.pricing.dto.DiscountResult;
|
|
|
|
import java.util.List;
|
|
|
|
/**
|
|
* 优惠提供者接口
|
|
* 所有优惠类型(coupon、voucher、促销活动等)都需要实现此接口
|
|
*/
|
|
public interface IDiscountProvider {
|
|
|
|
/**
|
|
* 获取提供者类型
|
|
* @return 提供者类型标识,如 "COUPON", "VOUCHER", "LIMITED_TIME" 等
|
|
*/
|
|
String getProviderType();
|
|
|
|
/**
|
|
* 获取优先级
|
|
* @return 优先级,数字越大优先级越高
|
|
*/
|
|
int getPriority();
|
|
|
|
/**
|
|
* 检测可用的优惠
|
|
* @param context 优惠检测上下文
|
|
* @return 可用的优惠列表
|
|
*/
|
|
List<DiscountInfo> detectAvailableDiscounts(DiscountDetectionContext context);
|
|
|
|
/**
|
|
* 应用优惠
|
|
* @param discountInfo 要应用的优惠信息
|
|
* @param context 优惠检测上下文
|
|
* @return 优惠应用结果
|
|
*/
|
|
DiscountResult applyDiscount(DiscountInfo discountInfo, DiscountDetectionContext context);
|
|
|
|
/**
|
|
* 验证优惠是否可以应用
|
|
* @param discountInfo 优惠信息
|
|
* @param context 优惠检测上下文
|
|
* @return 是否可以应用
|
|
*/
|
|
default boolean canApply(DiscountInfo discountInfo, DiscountDetectionContext context) {
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* 获取优惠的最大可能折扣金额(用于排序)
|
|
* @param discountInfo 优惠信息
|
|
* @param context 优惠检测上下文
|
|
* @return 最大可能折扣金额
|
|
*/
|
|
default java.math.BigDecimal getMaxPossibleDiscount(DiscountInfo discountInfo, DiscountDetectionContext context) {
|
|
return discountInfo.getDiscountAmount() != null ? discountInfo.getDiscountAmount() : java.math.BigDecimal.ZERO;
|
|
}
|
|
} |