You've already forked FrameTour-BE
添加景区、删除子类型
This commit is contained in:
@@ -26,61 +26,6 @@ public class PricingConfigController {
|
|||||||
private final IPriceBundleService bundleService;
|
private final IPriceBundleService bundleService;
|
||||||
private final IPricingManagementService managementService;
|
private final IPricingManagementService managementService;
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取所有商品配置
|
|
||||||
*/
|
|
||||||
@GetMapping("/products")
|
|
||||||
public ApiResponse<List<PriceProductConfig>> getProductConfigs() {
|
|
||||||
List<PriceProductConfig> configs = productConfigService.getActiveProductConfigs();
|
|
||||||
return ApiResponse.success(configs);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据商品类型获取阶梯配置
|
|
||||||
*/
|
|
||||||
@GetMapping("/tiers/{productType}")
|
|
||||||
public ApiResponse<List<PriceTierConfig>> getTierConfigs(@PathVariable String productType) {
|
|
||||||
List<PriceTierConfig> configs = productConfigService.getTierConfigs(productType);
|
|
||||||
return ApiResponse.success(configs);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据商品类型和商品ID获取阶梯配置
|
|
||||||
*/
|
|
||||||
@GetMapping("/tiers/{productType}/{productId}")
|
|
||||||
public ApiResponse<List<PriceTierConfig>> getTierConfigs(@PathVariable String productType,
|
|
||||||
@PathVariable String productId) {
|
|
||||||
List<PriceTierConfig> configs = productConfigService.getTierConfigs(productType, productId);
|
|
||||||
return ApiResponse.success(configs);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据商品类型和商品ID获取具体配置
|
|
||||||
*/
|
|
||||||
@GetMapping("/products/{productType}/{productId}")
|
|
||||||
public ApiResponse<PriceProductConfig> getProductConfig(@PathVariable String productType,
|
|
||||||
@PathVariable String productId) {
|
|
||||||
PriceProductConfig config = productConfigService.getProductConfig(productType, productId);
|
|
||||||
return ApiResponse.success(config);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取所有阶梯配置
|
|
||||||
*/
|
|
||||||
@GetMapping("/tiers")
|
|
||||||
public ApiResponse<List<PriceTierConfig>> getAllTierConfigs() {
|
|
||||||
log.info("获取所有阶梯定价配置");
|
|
||||||
return ApiResponse.success(List.of());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取所有一口价配置
|
|
||||||
*/
|
|
||||||
@GetMapping("/bundles")
|
|
||||||
public ApiResponse<List<PriceBundleConfig>> getBundleConfigs() {
|
|
||||||
List<PriceBundleConfig> configs = bundleService.getActiveBundles();
|
|
||||||
return ApiResponse.success(configs);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ==================== 配置管理API(手动处理时间) ====================
|
// ==================== 配置管理API(手动处理时间) ====================
|
||||||
|
|
||||||
@@ -146,4 +91,121 @@ public class PricingConfigController {
|
|||||||
boolean success = managementService.updateBundleConfig(config);
|
boolean success = managementService.updateBundleConfig(config);
|
||||||
return ApiResponse.success(success);
|
return ApiResponse.success(success);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ==================== 启用/禁用API ====================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 启用/禁用商品配置
|
||||||
|
*/
|
||||||
|
@PutMapping("/products/{id}/status")
|
||||||
|
public ApiResponse<Boolean> updateProductConfigStatus(@PathVariable Long id, @RequestParam Boolean isActive) {
|
||||||
|
log.info("修改商品配置状态: id={}, isActive={}", id, isActive);
|
||||||
|
boolean success = managementService.updateProductConfigStatus(id, isActive);
|
||||||
|
return ApiResponse.success(success);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 启用/禁用阶梯配置
|
||||||
|
*/
|
||||||
|
@PutMapping("/tiers/{id}/status")
|
||||||
|
public ApiResponse<Boolean> updateTierConfigStatus(@PathVariable Long id, @RequestParam Boolean isActive) {
|
||||||
|
log.info("修改阶梯配置状态: id={}, isActive={}", id, isActive);
|
||||||
|
boolean success = managementService.updateTierConfigStatus(id, isActive);
|
||||||
|
return ApiResponse.success(success);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 启用/禁用一口价配置
|
||||||
|
*/
|
||||||
|
@PutMapping("/bundles/{id}/status")
|
||||||
|
public ApiResponse<Boolean> updateBundleConfigStatus(@PathVariable Long id, @RequestParam Boolean isActive) {
|
||||||
|
log.info("修改一口价配置状态: id={}, isActive={}", id, isActive);
|
||||||
|
boolean success = managementService.updateBundleConfigStatus(id, isActive);
|
||||||
|
return ApiResponse.success(success);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ==================== 删除API ====================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除商品配置
|
||||||
|
*/
|
||||||
|
@DeleteMapping("/products/{id}")
|
||||||
|
public ApiResponse<Boolean> deleteProductConfig(@PathVariable Long id) {
|
||||||
|
log.info("删除商品配置: id={}", id);
|
||||||
|
boolean success = managementService.deleteProductConfig(id);
|
||||||
|
return ApiResponse.success(success);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除阶梯配置
|
||||||
|
*/
|
||||||
|
@DeleteMapping("/tiers/{id}")
|
||||||
|
public ApiResponse<Boolean> deleteTierConfig(@PathVariable Long id) {
|
||||||
|
log.info("删除阶梯配置: id={}", id);
|
||||||
|
boolean success = managementService.deleteTierConfig(id);
|
||||||
|
return ApiResponse.success(success);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除一口价配置
|
||||||
|
*/
|
||||||
|
@DeleteMapping("/bundles/{id}")
|
||||||
|
public ApiResponse<Boolean> deleteBundleConfig(@PathVariable Long id) {
|
||||||
|
log.info("删除一口价配置: id={}", id);
|
||||||
|
boolean success = managementService.deleteBundleConfig(id);
|
||||||
|
return ApiResponse.success(success);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ==================== 管理端接口(包含禁用的配置) ====================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 管理端:获取所有商品配置(包含禁用的)
|
||||||
|
*/
|
||||||
|
@GetMapping("/admin/products")
|
||||||
|
public ApiResponse<List<PriceProductConfig>> getAllProductConfigsForAdmin() {
|
||||||
|
log.info("管理端获取所有商品配置");
|
||||||
|
List<PriceProductConfig> configs = productConfigService.getAllProductConfigsForAdmin();
|
||||||
|
return ApiResponse.success(configs);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 管理端:获取所有阶梯配置(包含禁用的)
|
||||||
|
*/
|
||||||
|
@GetMapping("/admin/tiers")
|
||||||
|
public ApiResponse<List<PriceTierConfig>> getAllTierConfigsForAdmin() {
|
||||||
|
log.info("管理端获取所有阶梯配置");
|
||||||
|
List<PriceTierConfig> configs = productConfigService.getAllTierConfigsForAdmin();
|
||||||
|
return ApiResponse.success(configs);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 管理端:根据商品类型获取阶梯配置(包含禁用的)
|
||||||
|
*/
|
||||||
|
@GetMapping("/admin/tiers/{productType}")
|
||||||
|
public ApiResponse<List<PriceTierConfig>> getTierConfigsForAdmin(@PathVariable String productType) {
|
||||||
|
log.info("管理端根据商品类型获取阶梯配置: {}", productType);
|
||||||
|
List<PriceTierConfig> configs = productConfigService.getTierConfigsForAdmin(productType);
|
||||||
|
return ApiResponse.success(configs);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 管理端:根据商品类型和商品ID获取阶梯配置(包含禁用的)
|
||||||
|
*/
|
||||||
|
@GetMapping("/admin/tiers/{productType}/{productId}")
|
||||||
|
public ApiResponse<List<PriceTierConfig>> getTierConfigsForAdmin(@PathVariable String productType,
|
||||||
|
@PathVariable String productId) {
|
||||||
|
log.info("管理端根据商品类型和ID获取阶梯配置: {}, {}", productType, productId);
|
||||||
|
List<PriceTierConfig> configs = productConfigService.getTierConfigsForAdmin(productType, productId);
|
||||||
|
return ApiResponse.success(configs);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 管理端:获取所有一口价配置(包含禁用的)
|
||||||
|
*/
|
||||||
|
@GetMapping("/admin/bundles")
|
||||||
|
public ApiResponse<List<PriceBundleConfig>> getAllBundleConfigsForAdmin() {
|
||||||
|
log.info("管理端获取所有一口价配置");
|
||||||
|
List<PriceBundleConfig> configs = bundleService.getAllBundlesForAdmin();
|
||||||
|
return ApiResponse.success(configs);
|
||||||
|
}
|
||||||
}
|
}
|
@@ -19,6 +19,11 @@ public class PriceBundleConfig extends BaseEntity {
|
|||||||
*/
|
*/
|
||||||
private String bundleName;
|
private String bundleName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 景区ID
|
||||||
|
*/
|
||||||
|
private String scenicId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 套餐价格
|
* 套餐价格
|
||||||
*/
|
*/
|
||||||
|
@@ -24,6 +24,11 @@ public class PriceProductConfig extends BaseEntity {
|
|||||||
*/
|
*/
|
||||||
private String productId;
|
private String productId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 景区ID:用于前端搜索和编辑时正确显示景区内容
|
||||||
|
*/
|
||||||
|
private String scenicId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商品名称
|
* 商品名称
|
||||||
*/
|
*/
|
||||||
|
@@ -25,9 +25,9 @@ public class PriceTierConfig extends BaseEntity {
|
|||||||
private String productId;
|
private String productId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商品子类型
|
* 景区ID:用于前端搜索和编辑时正确显示景区内容
|
||||||
*/
|
*/
|
||||||
private String productSubType;
|
private String scenicId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 最小数量
|
* 最小数量
|
||||||
|
@@ -10,11 +10,11 @@ import lombok.Getter;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public enum ProductType {
|
public enum ProductType {
|
||||||
|
|
||||||
VLOG_VIDEO("vlog_video", "Vlog视频"),
|
VLOG_VIDEO("VLOG_VIDEO", "Vlog视频"),
|
||||||
RECORDING_SET("recording_set", "录像集"),
|
RECORDING_SET("RECORDING_SET", "录像集"),
|
||||||
PHOTO_SET("photo_set", "照相集"),
|
PHOTO_SET("PHOTO_SET", "照相集"),
|
||||||
PHOTO_PRINT("photo_print", "照片打印"),
|
PHOTO_PRINT("PHOTO_PRINT", "照片打印"),
|
||||||
MACHINE_PRINT("machine_print", "一体机打印");
|
MACHINE_PRINT("MACHINE_PRINT", "一体机打印");
|
||||||
|
|
||||||
private final String code;
|
private final String code;
|
||||||
private final String description;
|
private final String description;
|
||||||
|
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|||||||
import com.ycwl.basic.pricing.entity.PriceBundleConfig;
|
import com.ycwl.basic.pricing.entity.PriceBundleConfig;
|
||||||
import org.apache.ibatis.annotations.Insert;
|
import org.apache.ibatis.annotations.Insert;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.apache.ibatis.annotations.Select;
|
import org.apache.ibatis.annotations.Select;
|
||||||
import org.apache.ibatis.annotations.Update;
|
import org.apache.ibatis.annotations.Update;
|
||||||
|
|
||||||
@@ -27,20 +28,34 @@ public interface PriceBundleConfigMapper extends BaseMapper<PriceBundleConfig> {
|
|||||||
@Select("SELECT * FROM price_bundle_config WHERE id = #{id} AND is_active = 1")
|
@Select("SELECT * FROM price_bundle_config WHERE id = #{id} AND is_active = 1")
|
||||||
PriceBundleConfig selectActiveBundleById(Long id);
|
PriceBundleConfig selectActiveBundleById(Long id);
|
||||||
|
|
||||||
|
// ==================== 管理端接口(包含禁用的配置) ====================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询所有一口价配置(包含禁用的)- 管理端使用
|
||||||
|
*/
|
||||||
|
@Select("SELECT * FROM price_bundle_config ORDER BY is_active DESC, bundle_name ASC")
|
||||||
|
List<PriceBundleConfig> selectAllBundlesForAdmin();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 插入一口价配置
|
* 插入一口价配置
|
||||||
*/
|
*/
|
||||||
@Insert("INSERT INTO price_bundle_config (bundle_name, bundle_price, included_products, excluded_products, " +
|
@Insert("INSERT INTO price_bundle_config (bundle_name, scenic_id, bundle_price, included_products, excluded_products, " +
|
||||||
"description, is_active, created_time, updated_time) VALUES " +
|
"description, is_active, created_time, updated_time) VALUES " +
|
||||||
"(#{bundleName}, #{bundlePrice}, #{includedProducts}, #{excludedProducts}, " +
|
"(#{bundleName}, #{scenicId}, #{bundlePrice}, #{includedProducts}, #{excludedProducts}, " +
|
||||||
"#{description}, #{isActive}, NOW(), NOW())")
|
"#{description}, #{isActive}, NOW(), NOW())")
|
||||||
int insertBundleConfig(PriceBundleConfig config);
|
int insertBundleConfig(PriceBundleConfig config);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新一口价配置
|
* 更新一口价配置
|
||||||
*/
|
*/
|
||||||
@Update("UPDATE price_bundle_config SET bundle_name = #{bundleName}, bundle_price = #{bundlePrice}, " +
|
@Update("UPDATE price_bundle_config SET bundle_name = #{bundleName}, scenic_id = #{scenicId}, bundle_price = #{bundlePrice}, " +
|
||||||
"included_products = #{includedProducts}, excluded_products = #{excludedProducts}, " +
|
"included_products = #{includedProducts}, excluded_products = #{excludedProducts}, " +
|
||||||
"description = #{description}, is_active = #{isActive}, updated_time = NOW() WHERE id = #{id}")
|
"description = #{description}, is_active = #{isActive}, updated_time = NOW() WHERE id = #{id}")
|
||||||
int updateBundleConfig(PriceBundleConfig config);
|
int updateBundleConfig(PriceBundleConfig config);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新一口价配置状态
|
||||||
|
*/
|
||||||
|
@Update("UPDATE price_bundle_config SET is_active = #{isActive}, updated_time = NOW() WHERE id = #{id}")
|
||||||
|
int updateBundleConfigStatus(@Param("id") Long id, @Param("isActive") Boolean isActive);
|
||||||
}
|
}
|
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|||||||
import com.ycwl.basic.pricing.entity.PriceProductConfig;
|
import com.ycwl.basic.pricing.entity.PriceProductConfig;
|
||||||
import org.apache.ibatis.annotations.Insert;
|
import org.apache.ibatis.annotations.Insert;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.apache.ibatis.annotations.Select;
|
import org.apache.ibatis.annotations.Select;
|
||||||
import org.apache.ibatis.annotations.Update;
|
import org.apache.ibatis.annotations.Update;
|
||||||
|
|
||||||
@@ -33,17 +34,37 @@ public interface PriceProductConfigMapper extends BaseMapper<PriceProductConfig>
|
|||||||
@Select("SELECT * FROM price_product_config WHERE product_type = #{productType} AND product_id = #{productId} AND is_active = 1")
|
@Select("SELECT * FROM price_product_config WHERE product_type = #{productType} AND product_id = #{productId} AND is_active = 1")
|
||||||
PriceProductConfig selectByProductTypeAndId(String productType, String productId);
|
PriceProductConfig selectByProductTypeAndId(String productType, String productId);
|
||||||
|
|
||||||
|
// ==================== 管理端接口(包含禁用的配置) ====================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询所有商品配置(包含禁用的)- 管理端使用
|
||||||
|
*/
|
||||||
|
@Select("SELECT * FROM price_product_config ORDER BY product_type ASC, is_active DESC, product_id ASC")
|
||||||
|
List<PriceProductConfig> selectAllConfigsForAdmin();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据商品类型查询所有配置(包含禁用的)- 管理端使用
|
||||||
|
*/
|
||||||
|
@Select("SELECT * FROM price_product_config WHERE product_type = #{productType} ORDER BY is_active DESC, product_id ASC")
|
||||||
|
List<PriceProductConfig> selectByProductTypeForAdmin(@Param("productType") String productType);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 插入商品价格配置
|
* 插入商品价格配置
|
||||||
*/
|
*/
|
||||||
@Insert("INSERT INTO price_product_config (product_type, product_id, product_name, base_price, original_price, unit, is_active, created_time, updated_time) " +
|
@Insert("INSERT INTO price_product_config (product_type, product_id, scenic_id, product_name, base_price, original_price, unit, is_active, created_time, updated_time) " +
|
||||||
"VALUES (#{productType}, #{productId}, #{productName}, #{basePrice}, #{originalPrice}, #{unit}, #{isActive}, NOW(), NOW())")
|
"VALUES (#{productType}, #{productId}, #{scenicId}, #{productName}, #{basePrice}, #{originalPrice}, #{unit}, #{isActive}, NOW(), NOW())")
|
||||||
int insertProductConfig(PriceProductConfig config);
|
int insertProductConfig(PriceProductConfig config);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新商品价格配置
|
* 更新商品价格配置
|
||||||
*/
|
*/
|
||||||
@Update("UPDATE price_product_config SET product_id = #{productId}, product_name = #{productName}, base_price = #{basePrice}, " +
|
@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}, updated_time = NOW() WHERE id = #{id}")
|
"original_price = #{originalPrice}, unit = #{unit}, is_active = #{isActive}, updated_time = NOW() WHERE id = #{id}")
|
||||||
int updateProductConfig(PriceProductConfig config);
|
int updateProductConfig(PriceProductConfig config);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新商品配置状态
|
||||||
|
*/
|
||||||
|
@Update("UPDATE price_product_config SET is_active = #{isActive}, updated_time = NOW() WHERE id = #{id}")
|
||||||
|
int updateProductConfigStatus(@Param("id") Long id, @Param("isActive") Boolean isActive);
|
||||||
}
|
}
|
@@ -21,12 +21,10 @@ public interface PriceTierConfigMapper extends BaseMapper<PriceTierConfig> {
|
|||||||
*/
|
*/
|
||||||
@Select("SELECT * FROM price_tier_config WHERE product_type = #{productType} " +
|
@Select("SELECT * FROM price_tier_config WHERE product_type = #{productType} " +
|
||||||
"AND product_id = #{productId} " +
|
"AND product_id = #{productId} " +
|
||||||
"AND (product_sub_type = #{productSubType} OR product_sub_type IS NULL) " +
|
|
||||||
"AND #{quantity} >= min_quantity AND #{quantity} <= max_quantity " +
|
"AND #{quantity} >= min_quantity AND #{quantity} <= max_quantity " +
|
||||||
"AND is_active = 1 ORDER BY sort_order ASC LIMIT 1")
|
"AND is_active = 1 ORDER BY sort_order ASC LIMIT 1")
|
||||||
PriceTierConfig selectByProductTypeAndQuantity(@Param("productType") String productType,
|
PriceTierConfig selectByProductTypeAndQuantity(@Param("productType") String productType,
|
||||||
@Param("productId") String productId,
|
@Param("productId") String productId,
|
||||||
@Param("productSubType") String productSubType,
|
|
||||||
@Param("quantity") Integer quantity);
|
@Param("quantity") Integer quantity);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -44,28 +42,56 @@ public interface PriceTierConfigMapper extends BaseMapper<PriceTierConfig> {
|
|||||||
List<PriceTierConfig> selectByProductTypeAndId(@Param("productType") String productType,
|
List<PriceTierConfig> selectByProductTypeAndId(@Param("productType") String productType,
|
||||||
@Param("productId") String productId);
|
@Param("productId") String productId);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据商品类型和子类型查询阶梯配置
|
* 查询所有启用的阶梯配置
|
||||||
|
*/
|
||||||
|
@Select("SELECT * FROM price_tier_config WHERE is_active = 1 ORDER BY product_type ASC, sort_order ASC")
|
||||||
|
List<PriceTierConfig> selectAllActiveConfigs();
|
||||||
|
|
||||||
|
// ==================== 管理端接口(包含禁用的配置) ====================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询所有阶梯配置(包含禁用的)- 管理端使用
|
||||||
|
*/
|
||||||
|
@Select("SELECT * FROM price_tier_config ORDER BY product_type ASC, is_active DESC, sort_order ASC")
|
||||||
|
List<PriceTierConfig> selectAllConfigsForAdmin();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据商品类型查询所有阶梯配置(包含禁用的)- 管理端使用
|
||||||
*/
|
*/
|
||||||
@Select("SELECT * FROM price_tier_config WHERE product_type = #{productType} " +
|
@Select("SELECT * FROM price_tier_config WHERE product_type = #{productType} " +
|
||||||
"AND product_sub_type = #{productSubType} AND is_active = 1 ORDER BY sort_order ASC")
|
"ORDER BY is_active DESC, sort_order ASC")
|
||||||
List<PriceTierConfig> selectByProductTypeAndSubType(@Param("productType") String productType,
|
List<PriceTierConfig> selectByProductTypeForAdmin(@Param("productType") String productType);
|
||||||
@Param("productSubType") String productSubType);
|
|
||||||
|
/**
|
||||||
|
* 根据商品类型和商品ID查询所有阶梯配置(包含禁用的)- 管理端使用
|
||||||
|
*/
|
||||||
|
@Select("SELECT * FROM price_tier_config WHERE product_type = #{productType} " +
|
||||||
|
"AND product_id = #{productId} ORDER BY is_active DESC, sort_order ASC")
|
||||||
|
List<PriceTierConfig> selectByProductTypeAndIdForAdmin(@Param("productType") String productType,
|
||||||
|
@Param("productId") String productId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 插入阶梯定价配置
|
* 插入阶梯定价配置
|
||||||
*/
|
*/
|
||||||
@Insert("INSERT INTO price_tier_config (product_type, product_id, product_sub_type, min_quantity, max_quantity, price, " +
|
@Insert("INSERT INTO price_tier_config (product_type, product_id, scenic_id, min_quantity, max_quantity, price, " +
|
||||||
"original_price, unit, sort_order, is_active, created_time, updated_time) VALUES " +
|
"original_price, unit, sort_order, is_active, created_time, updated_time) VALUES " +
|
||||||
"(#{productType}, #{productId}, #{productSubType}, #{minQuantity}, #{maxQuantity}, #{price}, " +
|
"(#{productType}, #{productId}, #{scenicId}, #{minQuantity}, #{maxQuantity}, #{price}, " +
|
||||||
"#{originalPrice}, #{unit}, #{sortOrder}, #{isActive}, NOW(), NOW())")
|
"#{originalPrice}, #{unit}, #{sortOrder}, #{isActive}, NOW(), NOW())")
|
||||||
int insertTierConfig(PriceTierConfig config);
|
int insertTierConfig(PriceTierConfig config);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新阶梯定价配置
|
* 更新阶梯定价配置
|
||||||
*/
|
*/
|
||||||
@Update("UPDATE price_tier_config SET product_id = #{productId}, product_sub_type = #{productSubType}, min_quantity = #{minQuantity}, " +
|
@Update("UPDATE price_tier_config SET product_id = #{productId}, scenic_id = #{scenicId}, min_quantity = #{minQuantity}, " +
|
||||||
"max_quantity = #{maxQuantity}, price = #{price}, original_price = #{originalPrice}, unit = #{unit}, sort_order = #{sortOrder}, " +
|
"max_quantity = #{maxQuantity}, price = #{price}, original_price = #{originalPrice}, unit = #{unit}, sort_order = #{sortOrder}, " +
|
||||||
"is_active = #{isActive}, updated_time = NOW() WHERE id = #{id}")
|
"is_active = #{isActive}, updated_time = NOW() WHERE id = #{id}")
|
||||||
int updateTierConfig(PriceTierConfig config);
|
int updateTierConfig(PriceTierConfig config);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新阶梯配置状态
|
||||||
|
*/
|
||||||
|
@Update("UPDATE price_tier_config SET is_active = #{isActive}, updated_time = NOW() WHERE id = #{id}")
|
||||||
|
int updateTierConfigStatus(@Param("id") Long id, @Param("isActive") Boolean isActive);
|
||||||
}
|
}
|
@@ -33,4 +33,13 @@ public interface IPriceBundleService {
|
|||||||
* @return 一口价配置列表
|
* @return 一口价配置列表
|
||||||
*/
|
*/
|
||||||
List<PriceBundleConfig> getActiveBundles();
|
List<PriceBundleConfig> getActiveBundles();
|
||||||
|
|
||||||
|
// ==================== 管理端接口(包含禁用的配置) ====================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有一口价配置(包含禁用的)- 管理端使用
|
||||||
|
*
|
||||||
|
* @return 一口价配置列表
|
||||||
|
*/
|
||||||
|
List<PriceBundleConfig> getAllBundlesForAdmin();
|
||||||
}
|
}
|
@@ -56,4 +56,38 @@ public interface IPricingManagementService {
|
|||||||
* 更新一口价配置
|
* 更新一口价配置
|
||||||
*/
|
*/
|
||||||
boolean updateBundleConfig(PriceBundleConfig config);
|
boolean updateBundleConfig(PriceBundleConfig config);
|
||||||
|
|
||||||
|
// ==================== 状态管理 ====================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新商品配置状态
|
||||||
|
*/
|
||||||
|
boolean updateProductConfigStatus(Long id, Boolean isActive);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新阶梯配置状态
|
||||||
|
*/
|
||||||
|
boolean updateTierConfigStatus(Long id, Boolean isActive);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新一口价配置状态
|
||||||
|
*/
|
||||||
|
boolean updateBundleConfigStatus(Long id, Boolean isActive);
|
||||||
|
|
||||||
|
// ==================== 删除操作 ====================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除商品配置
|
||||||
|
*/
|
||||||
|
boolean deleteProductConfig(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除阶梯配置
|
||||||
|
*/
|
||||||
|
boolean deleteTierConfig(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除一口价配置
|
||||||
|
*/
|
||||||
|
boolean deleteBundleConfig(Long id);
|
||||||
}
|
}
|
@@ -32,22 +32,10 @@ public interface IProductConfigService {
|
|||||||
*
|
*
|
||||||
* @param productType 商品类型
|
* @param productType 商品类型
|
||||||
* @param productId 具体商品ID
|
* @param productId 具体商品ID
|
||||||
* @param productSubType 商品子类型
|
|
||||||
* @param quantity 数量
|
* @param quantity 数量
|
||||||
* @return 阶梯价格配置
|
* @return 阶梯价格配置
|
||||||
*/
|
*/
|
||||||
PriceTierConfig getTierConfig(String productType, String productId, String productSubType, Integer quantity);
|
PriceTierConfig getTierConfig(String productType, String productId, Integer quantity);
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据商品类型和数量获取阶梯价格配置(兼容旧接口)
|
|
||||||
*
|
|
||||||
* @param productType 商品类型
|
|
||||||
* @param productSubType 商品子类型
|
|
||||||
* @param quantity 数量
|
|
||||||
* @return 阶梯价格配置
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
PriceTierConfig getTierConfig(String productType, String productSubType, Integer quantity);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取所有启用的商品配置
|
* 获取所有启用的商品配置
|
||||||
@@ -72,4 +60,44 @@ public interface IProductConfigService {
|
|||||||
* @return 阶梯配置列表
|
* @return 阶梯配置列表
|
||||||
*/
|
*/
|
||||||
List<PriceTierConfig> getTierConfigs(String productType, String productId);
|
List<PriceTierConfig> getTierConfigs(String productType, String productId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有启用的阶梯配置
|
||||||
|
*
|
||||||
|
* @return 阶梯配置列表
|
||||||
|
*/
|
||||||
|
List<PriceTierConfig> getAllTierConfigs();
|
||||||
|
|
||||||
|
// ==================== 管理端接口(包含禁用的配置) ====================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有商品配置(包含禁用的)- 管理端使用
|
||||||
|
*
|
||||||
|
* @return 商品配置列表
|
||||||
|
*/
|
||||||
|
List<PriceProductConfig> getAllProductConfigsForAdmin();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有阶梯配置(包含禁用的)- 管理端使用
|
||||||
|
*
|
||||||
|
* @return 阶梯配置列表
|
||||||
|
*/
|
||||||
|
List<PriceTierConfig> getAllTierConfigsForAdmin();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据商品类型获取所有阶梯配置(包含禁用的)- 管理端使用
|
||||||
|
*
|
||||||
|
* @param productType 商品类型
|
||||||
|
* @return 阶梯配置列表
|
||||||
|
*/
|
||||||
|
List<PriceTierConfig> getTierConfigsForAdmin(String productType);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据商品类型和商品ID获取所有阶梯配置(包含禁用的)- 管理端使用
|
||||||
|
*
|
||||||
|
* @param productType 商品类型
|
||||||
|
* @param productId 具体商品ID
|
||||||
|
* @return 阶梯配置列表
|
||||||
|
*/
|
||||||
|
List<PriceTierConfig> getTierConfigsForAdmin(String productType, String productId);
|
||||||
}
|
}
|
@@ -9,7 +9,7 @@ import com.ycwl.basic.pricing.mapper.PriceBundleConfigMapper;
|
|||||||
import com.ycwl.basic.pricing.service.IPriceBundleService;
|
import com.ycwl.basic.pricing.service.IPriceBundleService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.cache.annotation.Cacheable;
|
//import org.springframework.cache.annotation.Cacheable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
@@ -71,11 +71,18 @@ public class PriceBundleServiceImpl implements IPriceBundleService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Cacheable(value = "active-bundles")
|
// @Cacheable(value = "active-bundles")
|
||||||
public List<PriceBundleConfig> getActiveBundles() {
|
public List<PriceBundleConfig> getActiveBundles() {
|
||||||
return bundleConfigMapper.selectActiveBundles();
|
return bundleConfigMapper.selectActiveBundles();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ==================== 管理端接口(包含禁用的配置) ====================
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<PriceBundleConfig> getAllBundlesForAdmin() {
|
||||||
|
return bundleConfigMapper.selectAllBundlesForAdmin();
|
||||||
|
}
|
||||||
|
|
||||||
private boolean isProductsMatchBundle(Set<String> productTypes, PriceBundleConfig bundle) {
|
private boolean isProductsMatchBundle(Set<String> productTypes, PriceBundleConfig bundle) {
|
||||||
try {
|
try {
|
||||||
List<String> includedProducts = objectMapper.readValue(
|
List<String> includedProducts = objectMapper.readValue(
|
||||||
|
@@ -140,7 +140,7 @@ public class PriceCalculationServiceImpl implements IPriceCalculationService {
|
|||||||
|
|
||||||
// 优先使用基于product_id的阶梯定价
|
// 优先使用基于product_id的阶梯定价
|
||||||
PriceTierConfig tierConfig = productConfigService.getTierConfig(
|
PriceTierConfig tierConfig = productConfigService.getTierConfig(
|
||||||
productType.getCode(), productId, product.getProductSubType(), product.getQuantity());
|
productType.getCode(), productId, product.getQuantity());
|
||||||
|
|
||||||
if (tierConfig != null) {
|
if (tierConfig != null) {
|
||||||
log.debug("使用阶梯定价: productType={}, productId={}, quantity={}, price={}",
|
log.debug("使用阶梯定价: productType={}, productId={}, quantity={}, price={}",
|
||||||
@@ -186,7 +186,7 @@ public class PriceCalculationServiceImpl implements IPriceCalculationService {
|
|||||||
|
|
||||||
// 优先使用基于product_id的阶梯定价
|
// 优先使用基于product_id的阶梯定价
|
||||||
PriceTierConfig tierConfig = productConfigService.getTierConfig(
|
PriceTierConfig tierConfig = productConfigService.getTierConfig(
|
||||||
productType.getCode(), productId, product.getProductSubType(), product.getQuantity());
|
productType.getCode(), productId, product.getQuantity());
|
||||||
|
|
||||||
if (tierConfig != null) {
|
if (tierConfig != null) {
|
||||||
actualPrice = tierConfig.getPrice();
|
actualPrice = tierConfig.getPrice();
|
||||||
|
@@ -104,4 +104,50 @@ public class PricingManagementServiceImpl implements IPricingManagementService {
|
|||||||
config.setUpdatedTime(LocalDateTime.now());
|
config.setUpdatedTime(LocalDateTime.now());
|
||||||
return bundleConfigMapper.updateBundleConfig(config) > 0;
|
return bundleConfigMapper.updateBundleConfig(config) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ==================== 状态管理 ====================
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public boolean updateProductConfigStatus(Long id, Boolean isActive) {
|
||||||
|
log.info("更新商品配置状态: id={}, isActive={}", id, isActive);
|
||||||
|
return productConfigMapper.updateProductConfigStatus(id, isActive) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public boolean updateTierConfigStatus(Long id, Boolean isActive) {
|
||||||
|
log.info("更新阶梯配置状态: id={}, isActive={}", id, isActive);
|
||||||
|
return tierConfigMapper.updateTierConfigStatus(id, isActive) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public boolean updateBundleConfigStatus(Long id, Boolean isActive) {
|
||||||
|
log.info("更新一口价配置状态: id={}, isActive={}", id, isActive);
|
||||||
|
return bundleConfigMapper.updateBundleConfigStatus(id, isActive) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ==================== 删除操作 ====================
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public boolean deleteProductConfig(Long id) {
|
||||||
|
log.info("删除商品配置: id={}", id);
|
||||||
|
return productConfigMapper.deleteById(id) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public boolean deleteTierConfig(Long id) {
|
||||||
|
log.info("删除阶梯配置: id={}", id);
|
||||||
|
return tierConfigMapper.deleteById(id) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public boolean deleteBundleConfig(Long id) {
|
||||||
|
log.info("删除一口价配置: id={}", id);
|
||||||
|
return bundleConfigMapper.deleteById(id) > 0;
|
||||||
|
}
|
||||||
}
|
}
|
@@ -8,7 +8,7 @@ import com.ycwl.basic.pricing.mapper.PriceTierConfigMapper;
|
|||||||
import com.ycwl.basic.pricing.service.IProductConfigService;
|
import com.ycwl.basic.pricing.service.IProductConfigService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.cache.annotation.Cacheable;
|
//import org.springframework.cache.annotation.Cacheable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -25,13 +25,13 @@ public class ProductConfigServiceImpl implements IProductConfigService {
|
|||||||
private final PriceTierConfigMapper tierConfigMapper;
|
private final PriceTierConfigMapper tierConfigMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Cacheable(value = "product-config", key = "#productType")
|
// @Cacheable(value = "product-config", key = "#productType")
|
||||||
public List<PriceProductConfig> getProductConfig(String productType) {
|
public List<PriceProductConfig> getProductConfig(String productType) {
|
||||||
return productConfigMapper.selectByProductType(productType);
|
return productConfigMapper.selectByProductType(productType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Cacheable(value = "product-config", key = "#productType + '_' + #productId")
|
// @Cacheable(value = "product-config", key = "#productType + '_' + #productId")
|
||||||
public PriceProductConfig getProductConfig(String productType, String productId) {
|
public PriceProductConfig getProductConfig(String productType, String productId) {
|
||||||
PriceProductConfig config = productConfigMapper.selectByProductTypeAndId(productType, productId);
|
PriceProductConfig config = productConfigMapper.selectByProductTypeAndId(productType, productId);
|
||||||
if (config == null) {
|
if (config == null) {
|
||||||
@@ -41,38 +41,59 @@ public class ProductConfigServiceImpl implements IProductConfigService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Cacheable(value = "tier-config", key = "#productType + '_' + #productId + '_' + (#productSubType ?: 'default') + '_' + #quantity")
|
// @Cacheable(value = "tier-config", key = "#productType + '_' + #productId + '_' + #quantity")
|
||||||
public PriceTierConfig getTierConfig(String productType, String productId, String productSubType, Integer quantity) {
|
public PriceTierConfig getTierConfig(String productType, String productId, Integer quantity) {
|
||||||
PriceTierConfig config = tierConfigMapper.selectByProductTypeAndQuantity(productType, productId, productSubType, quantity);
|
PriceTierConfig config = tierConfigMapper.selectByProductTypeAndQuantity(productType, productId, quantity);
|
||||||
if (config == null) {
|
if (config == null) {
|
||||||
log.warn("阶梯定价配置未找到: productType={}, productId={}, productSubType={}, quantity={}",
|
log.warn("阶梯定价配置未找到: productType={}, productId={}, quantity={}",
|
||||||
productType, productId, productSubType, quantity);
|
productType, productId, quantity);
|
||||||
}
|
}
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Deprecated
|
// @Cacheable(value = "active-product-configs")
|
||||||
public PriceTierConfig getTierConfig(String productType, String productSubType, Integer quantity) {
|
|
||||||
// 兼容旧接口,使用默认productId
|
|
||||||
return getTierConfig(productType, "default", productSubType, quantity);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Cacheable(value = "active-product-configs")
|
|
||||||
public List<PriceProductConfig> getActiveProductConfigs() {
|
public List<PriceProductConfig> getActiveProductConfigs() {
|
||||||
return productConfigMapper.selectActiveConfigs();
|
return productConfigMapper.selectActiveConfigs();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Cacheable(value = "tier-configs", key = "#productType")
|
// @Cacheable(value = "tier-configs", key = "#productType")
|
||||||
public List<PriceTierConfig> getTierConfigs(String productType) {
|
public List<PriceTierConfig> getTierConfigs(String productType) {
|
||||||
return tierConfigMapper.selectByProductType(productType);
|
return tierConfigMapper.selectByProductType(productType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Cacheable(value = "tier-configs", key = "#productType + '_' + #productId")
|
// @Cacheable(value = "tier-configs", key = "#productType + '_' + #productId")
|
||||||
public List<PriceTierConfig> getTierConfigs(String productType, String productId) {
|
public List<PriceTierConfig> getTierConfigs(String productType, String productId) {
|
||||||
return tierConfigMapper.selectByProductTypeAndId(productType, productId);
|
return tierConfigMapper.selectByProductTypeAndId(productType, productId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
// @Cacheable(value = "all-tier-configs")
|
||||||
|
public List<PriceTierConfig> getAllTierConfigs() {
|
||||||
|
return tierConfigMapper.selectAllActiveConfigs();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ==================== 管理端接口(包含禁用的配置) ====================
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<PriceProductConfig> getAllProductConfigsForAdmin() {
|
||||||
|
return productConfigMapper.selectAllConfigsForAdmin();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<PriceTierConfig> getAllTierConfigsForAdmin() {
|
||||||
|
return tierConfigMapper.selectAllConfigsForAdmin();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<PriceTierConfig> getTierConfigsForAdmin(String productType) {
|
||||||
|
return tierConfigMapper.selectByProductTypeForAdmin(productType);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<PriceTierConfig> getTierConfigsForAdmin(String productType, String productId) {
|
||||||
|
return tierConfigMapper.selectByProductTypeAndIdForAdmin(productType, productId);
|
||||||
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user