修改产品功能

This commit is contained in:
wuweihua
2026-09-28 21:43:39 +08:00
parent b247bc2fd2
commit 0ad90f6183
32 changed files with 339 additions and 660 deletions
@@ -7,8 +7,6 @@ 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="ppvId" column="ppv_id" />
<result property="versionNo" column="version_no" />
<result property="productCode" column="product_code" />
<result property="countryName" column="country_name" />
<result property="countryCode" column="country_code" />
@@ -31,13 +29,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectVo">
select c.detail_id, c.product_id, c.ppv_id, v.version_no, c.product_code, c.country_name, c.country_code,
select c.detail_id, c.product_id, c.product_code, c.country_name, c.country_code,
c.zone_id, c.zone_code, c.zone_name,
c.weight_min, c.weight_max,
c.freight_price, c.registration_fee, c.size_limit, c.last_mile, c.lead_time,
c.effective_date, c.expire_date, c.status, c.create_time, c.update_time
from bms_product_country c
left join bms_product_price_version v on v.ppv_id = c.ppv_id
from product_country c
</sql>
<select id="selectBmsProductCountryList" parameterType="BmsProductCountry" resultMap="BmsProductCountryResult">
@@ -46,9 +43,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="productId != null">
AND c.product_id = #{productId}
</if>
<if test="ppvId != null">
AND c.ppv_id = #{ppvId}
</if>
<if test="productCode != null and productCode != ''">
AND c.product_code = #{productCode}
</if>
@@ -87,23 +81,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<insert id="insertBmsProductCountry" parameterType="BmsProductCountry" useGeneratedKeys="true" keyProperty="detailId">
insert into bms_product_country (
product_id, ppv_id, product_code, country_name, country_code, zone_id, zone_code, zone_name,
insert into product_country (
product_id, product_code, country_name, country_code, zone_id, zone_code, zone_name,
weight_min, weight_max,
freight_price, registration_fee, size_limit, last_mile, lead_time,
effective_date, expire_date, status, create_time
) values (
#{productId}, #{ppvId}, #{productCode}, #{countryName}, #{countryCode}, #{zoneId}, #{zoneCode}, #{zoneName},
#{productId}, #{productCode}, #{countryName}, #{countryCode}, #{zoneId}, #{zoneCode}, #{zoneName},
#{weightMin}, #{weightMax},
#{freightPrice}, #{registrationFee}, #{sizeLimit}, #{lastMile}, #{leadTime},
#{effectiveDate}, #{expireDate}, IFNULL(#{status}, '0'), sysdate()
)
</insert>
<!-- 仅服务于明细编辑弹窗:前端每次提交全量可编辑字段,
重量上限/失效日期允许写 null(= 不封顶 / 长期),故不用 <if> 守卫 -->
<!-- Detail edit dialog: frontend submits full editable fields;
weight_max / expire_date may be null (= open-ended) -->
<update id="updateBmsProductCountry" parameterType="BmsProductCountry">
update bms_product_country
update product_country
set weight_min = #{weightMin},
weight_max = #{weightMax},
freight_price = #{freightPrice},
@@ -118,9 +112,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</update>
<update id="updateBmsProductCountryImport" parameterType="BmsProductCountry">
update bms_product_country
update product_country
set product_id = #{productId},
ppv_id = #{ppvId},
country_code = #{countryCode},
zone_id = #{zoneId},
zone_code = #{zoneCode},
@@ -139,30 +132,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where detail_id = #{detailId}
</update>
<update id="updatePpvId">
update bms_product_country
set ppv_id = #{ppvId},
update_time = sysdate()
where detail_id = #{detailId}
</update>
<delete id="deleteByProductId" parameterType="Long">
delete from bms_product_country where product_id = #{productId}
delete from product_country where product_id = #{productId}
</delete>
<delete id="deleteByProductCode" parameterType="String">
delete from bms_product_country where product_code = #{productCode}
delete from product_country where product_code = #{productCode}
</delete>
<delete id="deleteByProductCodes">
delete from bms_product_country where product_code in
delete from product_country where product_code in
<foreach item="code" collection="array" open="(" separator="," close=")">
#{code}
</foreach>
</delete>
<delete id="deleteByProductCodeAndEffectiveDate">
delete from bms_product_country
delete from product_country
where product_code = #{productCode}
and (
(#{effectiveDate} is null and effective_date is null)
@@ -171,13 +157,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete>
<select id="selectMaxOpenEffectiveDate" resultType="java.util.Date">
select max(effective_date) from bms_product_country
select max(effective_date) from product_country
where product_code = #{productCode}
and expire_date is null
</select>
<update id="expireOpenByProductCode">
update bms_product_country
update product_country
set expire_date = #{newEffectiveDate},
update_time = sysdate()
where product_code = #{productCode}
@@ -186,7 +172,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</update>
<update id="refreshStatusByDates">
update bms_product_country
update 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'
@@ -195,7 +181,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</update>
<delete id="deleteOpenByProductCodeAndEffectiveDate">
delete from bms_product_country
delete from product_country
where product_code = #{productCode}
and expire_date is null
and (
@@ -241,7 +227,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="countZonedByProductCountry" resultType="int">
select count(1)
from bms_product_country
from product_country
where product_code = #{productCode}
and zone_code is not null and zone_code &lt;&gt; ''
<choose>
@@ -271,40 +257,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
order by c.country_name asc, c.zone_code asc, c.weight_min asc, c.detail_id asc
</select>
<select id="selectByPpvId" resultMap="BmsProductCountryResult">
<include refid="selectVo"/>
where c.ppv_id = #{ppvId}
order by c.country_name asc, c.zone_code asc, c.weight_min asc, c.detail_id asc
</select>
<insert id="copyCountriesFromVersion">
insert into bms_product_country (
product_id, ppv_id, product_code, country_name, country_code, zone_id, zone_code, zone_name,
<insert id="copyOpenCountries">
insert into product_country (
product_id, product_code, country_name, country_code, zone_id, zone_code, zone_name,
weight_min, weight_max, freight_price, registration_fee, size_limit, last_mile, lead_time,
effective_date, expire_date, status, create_time
)
select
#{productId}, #{newPpvId}, #{productCode}, country_name, country_code, zone_id, zone_code, zone_name,
#{productId}, product_code, country_name, country_code, zone_id, zone_code, zone_name,
weight_min, weight_max, freight_price, registration_fee, size_limit, last_mile, lead_time,
#{effectiveDate}, null, IFNULL(#{status}, '0'), sysdate()
from bms_product_country
where ppv_id = #{srcPpvId}
order by detail_id asc
</insert>
<insert id="copyOpenCountriesToVersion">
insert into bms_product_country (
product_id, ppv_id, product_code, country_name, country_code, zone_id, zone_code, zone_name,
weight_min, weight_max, freight_price, registration_fee, size_limit, last_mile, lead_time,
effective_date, expire_date, status, create_time
)
select
#{productId}, #{newPpvId}, product_code, country_name, country_code, zone_id, zone_code, zone_name,
weight_min, weight_max, freight_price, registration_fee, size_limit, last_mile, lead_time,
#{effectiveDate}, null, IFNULL(#{status}, '0'), sysdate()
from bms_product_country
from product_country
where product_code = #{productCode}
and expire_date is null
and (effective_date is null or effective_date &lt; #{effectiveDate})
order by detail_id asc
</insert>
@@ -31,7 +31,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
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.expire_date, p.status,
p.source_sheet, p.remark, p.tms_id, p.created_by, p.create_time, p.updated_by, p.update_time,
(select count(distinct c.country_name) from bms_product_country c
(select count(distinct c.country_name) from product_country c
where c.product_id = p.product_id
or (c.product_id is null and c.product_code = p.product_code
and (
@@ -40,7 +40,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
))
) as country_count,
(select count(*) from prc_surcharge_rel r where r.product_id = p.product_id) as surcharge_count
from bms_product p
from product p
</sql>
<select id="selectBmsProductById" parameterType="Long" resultMap="BmsProductResult">
@@ -127,7 +127,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<insert id="insertBmsProduct" parameterType="BmsProduct" useGeneratedKeys="true" keyProperty="productId">
insert into bms_product (
insert into product (
<if test="productCode != null and productCode != ''">product_code,</if>
<if test="productName != null and productName != ''">product_name,</if>
<if test="serviceLevel != null">service_level,</if>
@@ -163,7 +163,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</insert>
<update id="updateBmsProduct" parameterType="BmsProduct">
update bms_product
update product
<set>
<if test="productCode != null and productCode != ''">product_code = #{productCode},</if>
<if test="productName != null and productName != ''">product_name = #{productName},</if>
@@ -185,14 +185,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</update>
<delete id="deleteBmsProductByIds" parameterType="Long">
delete from bms_product where product_id in
delete from product where product_id in
<foreach item="productId" collection="array" open="(" separator="," close=")">
#{productId}
</foreach>
</delete>
<update id="expireOpenByProductCode">
update bms_product
update product
set expire_date = #{newEffectiveDate},
update_time = sysdate()
where product_code = #{productCode}
@@ -204,7 +204,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</update>
<update id="refreshStatusByDates">
update bms_product
update 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'
@@ -1,123 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.bms.price.mapper.BmsProductPriceVersionMapper">
<resultMap type="BmsProductPriceVersion" id="BmsProductPriceVersionResult">
<id property="ppvId" column="ppv_id" />
<result property="productCode" column="product_code" />
<result property="productId" column="product_id" />
<result property="versionNo" column="version_no" />
<result property="versionSeq" column="version_seq" />
<result property="effectiveDate" column="effective_date" />
<result property="expireDate" column="expire_date" />
<result property="status" column="status" />
<result property="productCount" column="product_count" />
<result property="createBy" column="created_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="updated_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectVo">
select ppv_id, product_code, product_id, version_no, version_seq,
effective_date, expire_date, status,
created_by, create_time, updated_by, update_time
from bms_product_price_version
</sql>
<select id="selectBmsProductPriceVersionById" parameterType="Long" resultMap="BmsProductPriceVersionResult">
<include refid="selectVo"/>
where ppv_id = #{ppvId}
</select>
<select id="selectOpenByProductCode" resultMap="BmsProductPriceVersionResult">
<include refid="selectVo"/>
where product_code = #{productCode}
and expire_date is null
order by effective_date desc, version_seq desc, ppv_id desc
limit 1
</select>
<select id="selectByProductCodeAndEffectiveDate" resultMap="BmsProductPriceVersionResult">
<include refid="selectVo"/>
where product_code = #{productCode}
and effective_date = #{effectiveDate}
limit 1
</select>
<select id="selectMaxVersionSeq" resultType="java.lang.Integer">
select max(version_seq) from bms_product_price_version where product_code = #{productCode}
</select>
<select id="selectVersionOptions" resultMap="BmsProductPriceVersionResult">
select
min(ppv_id) as ppv_id,
null as product_code,
null as product_id,
version_no,
max(version_seq) as version_seq,
max(effective_date) as effective_date,
max(expire_date) as expire_date,
case
when sum(case when expire_date is null then 1 else 0 end) &gt; 0
and max(effective_date) &lt;= curdate() then '1'
when max(effective_date) &gt; curdate() then '0'
else '2'
end as status,
count(distinct product_code) as product_count,
null as created_by,
null as create_time,
null as updated_by,
null as update_time
from bms_product_price_version
where version_no is not null and version_no &lt;&gt; ''
group by version_no
order by max(version_seq) desc, version_no desc
</select>
<insert id="insertBmsProductPriceVersion" parameterType="BmsProductPriceVersion" useGeneratedKeys="true" keyProperty="ppvId">
insert into bms_product_price_version (
product_code, product_id, version_no, version_seq,
effective_date, expire_date, status, created_by, create_time
) values (
#{productCode}, #{productId}, #{versionNo}, #{versionSeq},
#{effectiveDate}, #{expireDate}, IFNULL(#{status}, '0'), #{createBy}, sysdate()
)
</insert>
<update id="updateBmsProductPriceVersion" parameterType="BmsProductPriceVersion">
update bms_product_price_version
<set>
<if test="productId != null">product_id = #{productId},</if>
<if test="versionNo != null and versionNo != ''">version_no = #{versionNo},</if>
<if test="versionSeq != null">version_seq = #{versionSeq},</if>
<if test="effectiveDate != null">effective_date = #{effectiveDate},</if>
expire_date = #{expireDate},
<if test="status != null and status != ''">status = #{status},</if>
<if test="updateBy != null and updateBy != ''">updated_by = #{updateBy},</if>
update_time = sysdate()
</set>
where ppv_id = #{ppvId}
</update>
<update id="expireOpenByProductCode">
update bms_product_price_version
set expire_date = #{newEffectiveDate},
update_time = sysdate()
where product_code = #{productCode}
and expire_date is null
and (effective_date is null or effective_date &lt; #{newEffectiveDate})
</update>
<update id="refreshStatusByDates">
update bms_product_price_version
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>
@@ -56,7 +56,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
c.registration_fee as base_registration_fee,
d.discount_value, d.round_mode, d.pr_id, d.effective_date, d.expire_date, d.create_time, d.update_time
from prc_price_set_detail d
left join bms_product_country c on c.detail_id = d.product_country_id
left join product_country c on c.detail_id = d.product_country_id
<where>
<if test="priceSetId != null">
AND d.price_set_id = #{priceSetId}
@@ -161,21 +161,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
c.effective_date,
c.expire_date,
sysdate()
from bms_product_country c
inner join bms_product p on p.product_id = c.product_id
from product_country c
inner join product p on p.product_id = c.product_id
<where>
<choose>
<when test="baseVersionNo != null and baseVersionNo != ''">
and exists (
select 1 from bms_product_price_version v
where v.ppv_id = c.ppv_id
and v.version_no = #{baseVersionNo}
)
</when>
<otherwise>
and p.status = '1'
and p.product_id = (
select max(p2.product_id) from bms_product p2
select max(p2.product_id) from product p2
where p2.product_code = p.product_code and p2.status = '1'
)
and ifnull(c.status, '1') &lt;&gt; '2'
@@ -189,9 +180,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and (c.expire_date is null or date(c.expire_date) &gt; date(#{asOf}))
</otherwise>
</choose>
</otherwise>
</choose>
</where>
</where>
order by p.product_code asc, c.country_name asc, c.zone_code asc, c.weight_min asc, c.detail_id asc
</insert>
@@ -206,26 +195,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
p.product_name,
'HALF_UP',
sysdate()
from bms_product p
from product p
<where>
<choose>
<when test="baseVersionNo != null and baseVersionNo != ''">
and exists (
select 1 from bms_product_country c
inner join bms_product_price_version v on v.ppv_id = c.ppv_id
where c.product_id = p.product_id
and v.version_no = #{baseVersionNo}
)
</when>
<otherwise>
and p.status = '1'
and p.product_id = (
select max(p2.product_id) from bms_product p2
select max(p2.product_id) from product p2
where p2.product_code = p.product_code and p2.status = '1'
)
</otherwise>
</choose>
</where>
</where>
order by p.product_code asc
</insert>
@@ -38,6 +38,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="freightAmount" column="freight_amount" />
<result property="surchargeAmount" column="surcharge_amount" />
<result property="payableTotal" column="payable_total" />
<result property="productAmount" column="product_amount" />
<result property="redlineAmount" column="redline_amount" />
<result property="costAmount" column="cost_amount" />
<result property="payTotal" column="pay_total" />
<result property="currency" column="currency" />
<result property="roundMode" column="round_mode" />
<result property="createBy" column="created_by" />
@@ -53,7 +57,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
set_type, bind_priority, customer_priceset_id, product_country_id,
weight_min, weight_max, weight_label, effective_date, charge_weight,
freight_rate, base_freight_rate, discount_percent, registration_fee,
freight_amount, surcharge_amount, payable_total, currency, round_mode,
freight_amount, surcharge_amount, payable_total,
product_amount, redline_amount, cost_amount, pay_total, currency, round_mode,
created_by, create_time, updated_by, update_time
from prc_quote
</sql>
@@ -113,7 +118,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
set_type, bind_priority, customer_priceset_id, product_country_id,
weight_min, weight_max, weight_label, effective_date, charge_weight,
freight_rate, base_freight_rate, discount_percent, registration_fee,
freight_amount, surcharge_amount, payable_total, currency, round_mode,
freight_amount, surcharge_amount, payable_total,
product_amount, redline_amount, cost_amount, pay_total, currency, round_mode,
create_time
) values (
#{quoteId}, #{quoteKey}, #{customerId}, #{customerCode}, #{productCode}, #{productName},
@@ -122,7 +128,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{setType}, #{bindPriority}, #{customerPricesetId}, #{productCountryId},
#{weightMin}, #{weightMax}, #{weightLabel}, #{effectiveDate}, #{chargeWeight},
#{freightRate}, #{baseFreightRate}, #{discountPercent}, #{registrationFee},
#{freightAmount}, #{surchargeAmount}, #{payableTotal}, #{currency}, #{roundMode},
#{freightAmount}, #{surchargeAmount}, #{payableTotal},
#{productAmount}, #{redlineAmount}, #{costAmount}, #{payTotal}, #{currency}, #{roundMode},
sysdate()
)
</insert>
@@ -131,6 +138,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
update prc_quote
set surcharge_amount = #{surchargeAmount},
payable_total = #{payableTotal},
product_amount = #{productAmount},
cost_amount = #{costAmount},
pay_total = #{payTotal},
update_time = sysdate()
where quote_id = #{quoteId}
</update>
@@ -36,7 +36,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
c.country_name, c.weight_min, c.weight_max
from prc_surcharge_rel r
join prc_surcharge s on s.sc_id = r.sc_id
left join bms_product_country c on c.detail_id = r.detail_id
left join product_country c on c.detail_id = r.detail_id
</sql>
<select id="selectPrcSurchargeRelList" parameterType="PrcSurchargeRel" resultMap="PrcSurchargeRelResult">