修改产品价格显示

This commit is contained in:
wuweihua
2026-09-09 17:06:50 +08:00
parent fddd8f0586
commit e265656060
30 changed files with 771 additions and 194 deletions
@@ -6,6 +6,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<resultMap type="BmsProductCountry" id="BmsProductCountryResult">
<id property="detailId" column="detail_id" />
<result property="productId" column="product_id" />
<result property="productCode" column="product_code" />
<result property="countryName" column="country_name" />
<result property="countryCode" column="country_code" />
@@ -18,31 +19,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="leadTime" column="lead_time" />
<result property="effectiveDate" column="effective_date" />
<result property="expireDate" column="expire_date" />
<result property="status" column="status" />
<result property="createdAt" column="created_at" />
<result property="updatedAt" column="updated_at" />
<result property="effectStatus" column="effect_status" />
<result property="effectStatus" column="status" />
</resultMap>
<!-- 派生状态:已失效(过期) > 待生效(未到生效日) > 已生效 -->
<sql id="effectStatusCase">
case
when expire_date is not null and expire_date &lt;= curdate() then 'EXPIRED'
when effective_date is null or effective_date &gt; curdate() then 'PENDING'
else 'ACTIVE'
end
</sql>
<sql id="selectVo">
select detail_id, product_code, country_name, country_code, weight_min, weight_max,
select detail_id, product_id, product_code, country_name, country_code, weight_min, weight_max,
freight_price, registration_fee, size_limit, last_mile, lead_time,
effective_date, expire_date, created_at, updated_at,
<include refid="effectStatusCase"/> as effect_status
effective_date, expire_date, status, created_at, updated_at
from bms_product_country
</sql>
<select id="selectBmsProductCountryList" parameterType="BmsProductCountry" resultMap="BmsProductCountryResult">
<include refid="selectVo"/>
<where>
<if test="productId != null">
AND product_id = #{productId}
</if>
<if test="productCode != null and productCode != ''">
AND product_code = #{productCode}
</if>
@@ -64,8 +59,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="openOnly != null and openOnly">
AND expire_date is null
</if>
<if test="status != null and status != ''">
AND status = #{status}
</if>
<if test="effectStatus != null and effectStatus != ''">
AND (<include refid="effectStatusCase"/>) = #{effectStatus}
AND status = #{effectStatus}
</if>
</where>
order by effective_date desc, country_name asc, weight_min asc, detail_id asc
@@ -73,16 +71,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="insertBmsProductCountry" parameterType="BmsProductCountry" useGeneratedKeys="true" keyProperty="detailId">
insert into bms_product_country (
product_code, country_name, country_code, weight_min, weight_max,
product_id, product_code, country_name, country_code, weight_min, weight_max,
freight_price, registration_fee, size_limit, last_mile, lead_time,
effective_date, expire_date, created_at
effective_date, expire_date, status, created_at
) values (
#{productCode}, #{countryName}, #{countryCode}, #{weightMin}, #{weightMax},
#{productId}, #{productCode}, #{countryName}, #{countryCode}, #{weightMin}, #{weightMax},
#{freightPrice}, #{registrationFee}, #{sizeLimit}, #{lastMile}, #{leadTime},
#{effectiveDate}, #{expireDate}, sysdate()
#{effectiveDate}, #{expireDate}, IFNULL(#{status}, '0'), sysdate()
)
</insert>
<delete id="deleteByProductId" parameterType="Long">
delete from bms_product_country where product_id = #{productId}
</delete>
<delete id="deleteByProductCode" parameterType="String">
delete from bms_product_country where product_code = #{productCode}
</delete>
@@ -94,6 +96,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach>
</delete>
<delete id="deleteByProductCodeAndEffectiveDate">
delete from bms_product_country
where product_code = #{productCode}
and (
(#{effectiveDate} is null and effective_date is null)
or effective_date = #{effectiveDate}
)
</delete>
<select id="selectMaxOpenEffectiveDate" resultType="java.util.Date">
select max(effective_date) from bms_product_country
where product_code = #{productCode}
@@ -109,6 +120,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and (effective_date is null or effective_date &lt; #{newEffectiveDate})
</update>
<update id="refreshStatusByDates">
update bms_product_country
set status = case
when expire_date is not null and expire_date &lt;= curdate() then '2'
when effective_date is null or effective_date &gt; curdate() then '0'
else '1'
end
</update>
<delete id="deleteOpenByProductCodeAndEffectiveDate">
delete from bms_product_country
where product_code = #{productCode}
@@ -14,6 +14,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateNote" column="update_note" />
<result property="taxMode" column="tax_mode" />
<result property="effectiveDate" column="effective_date" />
<result property="expireDate" column="expire_date" />
<result property="status" column="status" />
<result property="sourceSheet" column="source_sheet" />
<result property="remark" column="remark" />
@@ -28,9 +29,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<sql id="selectBmsProductVo">
select p.product_id, p.product_code, p.product_name, p.service_level, p.cargo_attr,
p.dest_region, p.update_note, p.tax_mode, p.effective_date, p.status,
p.dest_region, p.update_note, p.tax_mode, p.effective_date, p.expire_date, p.status,
p.source_sheet, p.remark, p.tms_id, p.created_by, p.created_at, p.updated_by, p.updated_at,
(select count(distinct c.country_name) from bms_product_country c where c.product_code = p.product_code) as country_count,
(select count(distinct c.country_name) from bms_product_country c
where c.product_id = p.product_id
or (c.product_id is null and c.product_code = p.product_code
and (
(p.effective_date is null and c.effective_date is null)
or c.effective_date = p.effective_date
))
) as country_count,
(select count(*) from prc_surcharge_rel r where r.product_id = p.product_id) as surcharge_count
from bms_product p
</sql>
@@ -43,6 +51,31 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectBmsProductByCode" parameterType="String" resultMap="BmsProductResult">
<include refid="selectBmsProductVo"/>
where p.product_code = #{productCode}
order by p.effective_date desc, p.product_id desc
limit 1
</select>
<select id="selectBmsProductByCodeAndDate" resultMap="BmsProductResult">
<include refid="selectBmsProductVo"/>
where p.product_code = #{productCode}
<choose>
<when test="effectiveDate != null">
AND p.effective_date = #{effectiveDate}
</when>
<otherwise>
AND p.effective_date is null
</otherwise>
</choose>
limit 1
</select>
<select id="selectEffectiveBmsProductByCode" resultMap="BmsProductResult">
<include refid="selectBmsProductVo"/>
where p.product_code = #{productCode}
and (p.effective_date is null or #{bizDate} is null or p.effective_date &lt;= #{bizDate})
and (p.expire_date is null or #{bizDate} is null or p.expire_date &gt; #{bizDate})
order by p.effective_date desc, p.product_id desc
limit 1
</select>
<select id="selectBmsProductList" parameterType="BmsProduct" resultMap="BmsProductResult">
@@ -61,20 +94,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
AND p.status = #{status}
</if>
<if test="effectStatus != null and effectStatus != ''">
<choose>
<when test="effectStatus == 'EXPIRED'">
AND p.status = '1'
</when>
<when test="effectStatus == 'PENDING'">
AND p.status = '0'
AND (p.effective_date is null or p.effective_date &gt; curdate())
</when>
<when test="effectStatus == 'ACTIVE'">
AND p.status = '0'
AND p.effective_date is not null
AND p.effective_date &lt;= curdate()
</when>
</choose>
AND p.status = #{effectStatus}
</if>
<if test="cargoAttr != null and cargoAttr != ''">
AND p.cargo_attr like concat('%', #{cargoAttr}, '%')
@@ -84,7 +104,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
OR p.product_name like concat('%', #{params.keyword}, '%'))
</if>
</where>
order by p.product_id desc
order by p.product_code asc, p.effective_date desc, p.product_id desc
</select>
<insert id="insertBmsProduct" parameterType="BmsProduct" useGeneratedKeys="true" keyProperty="productId">
@@ -97,6 +117,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateNote != null">update_note,</if>
<if test="taxMode != null and taxMode != ''">tax_mode,</if>
<if test="effectiveDate != null">effective_date,</if>
<if test="expireDate != null">expire_date,</if>
<if test="status != null and status != ''">status,</if>
<if test="sourceSheet != null">source_sheet,</if>
<if test="remark != null">remark,</if>
@@ -112,6 +133,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateNote != null">#{updateNote},</if>
<if test="taxMode != null and taxMode != ''">#{taxMode},</if>
<if test="effectiveDate != null">#{effectiveDate},</if>
<if test="expireDate != null">#{expireDate},</if>
<if test="status != null and status != ''">#{status},</if>
<if test="sourceSheet != null">#{sourceSheet},</if>
<if test="remark != null">#{remark},</if>
@@ -132,6 +154,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="updateNote != null">update_note = #{updateNote},</if>
<if test="taxMode != null and taxMode != ''">tax_mode = #{taxMode},</if>
<if test="effectiveDate != null">effective_date = #{effectiveDate},</if>
expire_date = #{expireDate},
<if test="status != null and status != ''">status = #{status},</if>
<if test="sourceSheet != null">source_sheet = #{sourceSheet},</if>
<if test="remark != null">remark = #{remark},</if>
@@ -149,4 +172,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach>
</delete>
<update id="expireOpenByProductCode">
update bms_product
set expire_date = #{newEffectiveDate},
updated_at = sysdate()
where product_code = #{productCode}
and expire_date is null
and (effective_date is null or effective_date &lt; #{newEffectiveDate})
<if test="excludeId != null">
and product_id &lt;&gt; #{excludeId}
</if>
</update>
<update id="refreshStatusByDates">
update bms_product
set status = case
when expire_date is not null and expire_date &lt;= curdate() then '2'
when effective_date is null or effective_date &gt; curdate() then '0'
else '1'
end
</update>
</mapper>
@@ -51,6 +51,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select count(1) from prc_customer_price_set where price_set_id = #{priceSetId}
</select>
<select id="countByCustomerId" resultType="int">
select count(1) from prc_customer_price_set
where customer_id = #{customerId}
<if test="excludeId != null">
AND customer_priceset_id &lt;&gt; #{excludeId}
</if>
<if test="excludePriceSetId != null">
AND price_set_id &lt;&gt; #{excludePriceSetId}
</if>
</select>
<select id="countOverlap" resultType="int">
select count(1)
from prc_customer_price_set c