You've already forked FrameTour-BE
71 lines
3.4 KiB
Java
71 lines
3.4 KiB
Java
package com.ycwl.basic.pricing.mapper;
|
|
|
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
import com.ycwl.basic.pricing.entity.PriceTierConfig;
|
|
import org.apache.ibatis.annotations.Insert;
|
|
import org.apache.ibatis.annotations.Mapper;
|
|
import org.apache.ibatis.annotations.Param;
|
|
import org.apache.ibatis.annotations.Select;
|
|
import org.apache.ibatis.annotations.Update;
|
|
|
|
import java.util.List;
|
|
|
|
/**
|
|
* 阶梯定价配置Mapper
|
|
*/
|
|
@Mapper
|
|
public interface PriceTierConfigMapper extends BaseMapper<PriceTierConfig> {
|
|
|
|
/**
|
|
* 根据商品类型、商品ID和数量查询匹配的阶梯价格
|
|
*/
|
|
@Select("SELECT * FROM price_tier_config WHERE product_type = #{productType} " +
|
|
"AND product_id = #{productId} " +
|
|
"AND (product_sub_type = #{productSubType} OR product_sub_type IS NULL) " +
|
|
"AND #{quantity} >= min_quantity AND #{quantity} <= max_quantity " +
|
|
"AND is_active = 1 ORDER BY sort_order ASC LIMIT 1")
|
|
PriceTierConfig selectByProductTypeAndQuantity(@Param("productType") String productType,
|
|
@Param("productId") String productId,
|
|
@Param("productSubType") String productSubType,
|
|
@Param("quantity") Integer quantity);
|
|
|
|
/**
|
|
* 根据商品类型查询所有阶梯配置
|
|
*/
|
|
@Select("SELECT * FROM price_tier_config WHERE product_type = #{productType} " +
|
|
"AND is_active = 1 ORDER BY sort_order ASC")
|
|
List<PriceTierConfig> selectByProductType(String productType);
|
|
|
|
/**
|
|
* 根据商品类型和商品ID查询所有阶梯配置
|
|
*/
|
|
@Select("SELECT * FROM price_tier_config WHERE product_type = #{productType} " +
|
|
"AND product_id = #{productId} AND is_active = 1 ORDER BY sort_order ASC")
|
|
List<PriceTierConfig> selectByProductTypeAndId(@Param("productType") String productType,
|
|
@Param("productId") String productId);
|
|
|
|
/**
|
|
* 根据商品类型和子类型查询阶梯配置
|
|
*/
|
|
@Select("SELECT * FROM price_tier_config WHERE product_type = #{productType} " +
|
|
"AND product_sub_type = #{productSubType} AND is_active = 1 ORDER BY sort_order ASC")
|
|
List<PriceTierConfig> selectByProductTypeAndSubType(@Param("productType") String productType,
|
|
@Param("productSubType") String productSubType);
|
|
|
|
/**
|
|
* 插入阶梯定价配置
|
|
*/
|
|
@Insert("INSERT INTO price_tier_config (product_type, product_id, product_sub_type, min_quantity, max_quantity, price, " +
|
|
"original_price, unit, sort_order, is_active, created_time, updated_time) VALUES " +
|
|
"(#{productType}, #{productId}, #{productSubType}, #{minQuantity}, #{maxQuantity}, #{price}, " +
|
|
"#{originalPrice}, #{unit}, #{sortOrder}, #{isActive}, NOW(), NOW())")
|
|
int insertTierConfig(PriceTierConfig config);
|
|
|
|
/**
|
|
* 更新阶梯定价配置
|
|
*/
|
|
@Update("UPDATE price_tier_config SET product_id = #{productId}, product_sub_type = #{productSubType}, min_quantity = #{minQuantity}, " +
|
|
"max_quantity = #{maxQuantity}, price = #{price}, original_price = #{originalPrice}, unit = #{unit}, sort_order = #{sortOrder}, " +
|
|
"is_active = #{isActive}, updated_time = NOW() WHERE id = #{id}")
|
|
int updateTierConfig(PriceTierConfig config);
|
|
} |