feat(pricing): 增加商品和打包配置的优惠券及券码使用限制

- 在 PriceBundleConfig 和 PriceProductConfig 中添加是否可使用优惠券和券码的字段
- 修改 CouponDiscountProvider 和 VoucherDiscountProvider,增加对商品和打包配置的检查
- 更新 PriceCalculationServiceImpl 中的优惠计算逻辑,将一口价改为打包购买
- 调整 DiscountDetail 中的描述和排序顺序,以适应新的优惠方式
This commit is contained in:
2025-09-05 11:09:28 +08:00
parent bd077b9252
commit 5210b50adb
11 changed files with 231 additions and 24 deletions

View File

@@ -17,7 +17,7 @@ public interface PriceBundleConfigMapper extends BaseMapper<PriceBundleConfig> {
*/
@Select("SELECT id, bundle_name, scenic_id, bundle_price, " +
"included_products, excluded_products, " +
"description, is_active, create_time, update_time " +
"description, is_active, can_use_coupon, can_use_voucher, create_time, update_time " +
"FROM price_bundle_config WHERE is_active = 1")
@Results({
@Result(column = "included_products", property = "includedProducts",
@@ -32,7 +32,7 @@ public interface PriceBundleConfigMapper extends BaseMapper<PriceBundleConfig> {
*/
@Select("SELECT id, bundle_name, scenic_id, bundle_price, " +
"included_products, excluded_products, " +
"description, is_active, create_time, update_time " +
"description, is_active, can_use_coupon, can_use_voucher, create_time, update_time " +
"FROM price_bundle_config WHERE id = #{id} AND is_active = 1")
@Results({
@Result(column = "included_products", property = "includedProducts",
@@ -49,7 +49,7 @@ public interface PriceBundleConfigMapper extends BaseMapper<PriceBundleConfig> {
*/
@Select("SELECT id, bundle_name, scenic_id, bundle_price, " +
"included_products, excluded_products, " +
"description, is_active, create_time, update_time " +
"description, is_active, can_use_coupon, can_use_voucher, create_time, update_time " +
"FROM price_bundle_config ORDER BY is_active DESC, bundle_name ASC")
@Results({
@Result(column = "included_products", property = "includedProducts",
@@ -63,9 +63,9 @@ public interface PriceBundleConfigMapper extends BaseMapper<PriceBundleConfig> {
* 插入一口价配置
*/
@Insert("INSERT INTO price_bundle_config (bundle_name, scenic_id, bundle_price, included_products, excluded_products, " +
"description, is_active, create_time, update_time) VALUES " +
"description, is_active, can_use_coupon, can_use_voucher, create_time, update_time) VALUES " +
"(#{bundleName}, #{scenicId}, #{bundlePrice}, #{includedProducts,typeHandler=com.ycwl.basic.pricing.handler.BundleProductListTypeHandler}, #{excludedProducts,typeHandler=com.ycwl.basic.pricing.handler.BundleProductListTypeHandler}, " +
"#{description}, #{isActive}, NOW(), NOW())")
"#{description}, #{isActive}, #{canUseCoupon}, #{canUseVoucher}, NOW(), NOW())")
int insertBundleConfig(PriceBundleConfig config);
/**
@@ -73,7 +73,7 @@ public interface PriceBundleConfigMapper extends BaseMapper<PriceBundleConfig> {
*/
@Update("UPDATE price_bundle_config SET bundle_name = #{bundleName}, scenic_id = #{scenicId}, bundle_price = #{bundlePrice}, " +
"included_products = #{includedProducts,typeHandler=com.ycwl.basic.pricing.handler.BundleProductListTypeHandler}, excluded_products = #{excludedProducts,typeHandler=com.ycwl.basic.pricing.handler.BundleProductListTypeHandler}, " +
"description = #{description}, is_active = #{isActive}, update_time = NOW() WHERE id = #{id}")
"description = #{description}, is_active = #{isActive}, can_use_coupon = #{canUseCoupon}, can_use_voucher = #{canUseVoucher}, update_time = NOW() WHERE id = #{id}")
int updateBundleConfig(PriceBundleConfig config);
/**

View File

@@ -57,15 +57,15 @@ public interface PriceProductConfigMapper extends BaseMapper<PriceProductConfig>
/**
* 插入商品价格配置
*/
@Insert("INSERT INTO price_product_config (product_type, product_id, scenic_id, product_name, base_price, original_price, unit, is_active, create_time, update_time) " +
"VALUES (#{productType}, #{productId}, #{scenicId}, #{productName}, #{basePrice}, #{originalPrice}, #{unit}, #{isActive}, NOW(), NOW())")
@Insert("INSERT INTO price_product_config (product_type, product_id, scenic_id, product_name, base_price, original_price, unit, is_active, can_use_coupon, can_use_voucher, create_time, update_time) " +
"VALUES (#{productType}, #{productId}, #{scenicId}, #{productName}, #{basePrice}, #{originalPrice}, #{unit}, #{isActive}, #{canUseCoupon}, #{canUseVoucher}, NOW(), NOW())")
int insertProductConfig(PriceProductConfig config);
/**
* 更新商品价格配置
*/
@Update("UPDATE price_product_config SET product_id = #{productId}, scenic_id = #{scenicId}, product_name = #{productName}, base_price = #{basePrice}, " +
"original_price = #{originalPrice}, unit = #{unit}, is_active = #{isActive}, update_time = NOW() WHERE id = #{id}")
"original_price = #{originalPrice}, unit = #{unit}, is_active = #{isActive}, can_use_coupon = #{canUseCoupon}, can_use_voucher = #{canUseVoucher}, update_time = NOW() WHERE id = #{id}")
int updateProductConfig(PriceProductConfig config);
/**