统一修改ruoyi->bms

This commit is contained in:
caojia
2026-09-28 10:02:38 +08:00
parent 341afc4111
commit 0408b6c35e
639 changed files with 2776 additions and 2807 deletions
@@ -0,0 +1,362 @@
<?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.PrcPriceSetDetailMapper">
<resultMap type="PrcPriceSetDetail" id="PrcPriceSetDetailResult">
<id property="psdId" column="psd_id" />
<result property="priceSetId" column="price_set_id" />
<result property="psvId" column="psv_id" />
<result property="productCode" column="product_code" />
<result property="productName" column="product_name" />
<result property="countryCode" column="country_code" />
<result property="countryName" column="country_name" />
<result property="zoneId" column="zone_id" />
<result property="zoneCode" column="zone_code" />
<result property="zoneName" column="zone_name" />
<result property="zdId" column="zd_id" />
<result property="wsdId" column="wsd_id" />
<result property="weightLabel" column="weight_label" />
<result property="weightMin" column="weight_min" />
<result property="weightMax" column="weight_max" />
<result property="productCountryId" column="product_country_id" />
<result property="fvValue" column="fv_value" />
<result property="fvRegistrationFee" column="fv_registration_fee" />
<result property="discountValue" column="discount_value" />
<result property="roundMode" column="round_mode" />
<result property="prId" column="pr_id" />
<result property="effectiveDate" column="effective_date" />
<result property="expireDate" column="expire_date" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectPrcPriceSetDetailVo">
select psd_id, price_set_id, psv_id, product_code, product_name, country_code, country_name,
zone_id, zone_code, zone_name,
zd_id, wsd_id, weight_label, weight_min, weight_max, product_country_id, fv_value, fv_registration_fee,
discount_value, round_mode, pr_id, effective_date, expire_date, create_time, update_time
from prc_price_set_detail
</sql>
<select id="selectPrcPriceSetDetailById" parameterType="Long" resultMap="PrcPriceSetDetailResult">
<include refid="selectPrcPriceSetDetailVo"/>
where psd_id = #{psdId}
</select>
<select id="selectPrcPriceSetDetailList" parameterType="PrcPriceSetDetail" resultMap="PrcPriceSetDetailResult">
<include refid="selectPrcPriceSetDetailVo"/>
<where>
<if test="priceSetId != null">
AND price_set_id = #{priceSetId}
</if>
<if test="psvId != null">
AND psv_id = #{psvId}
</if>
<if test="productCode != null and productCode != ''">
AND product_code = #{productCode}
</if>
<if test="countryCode != null and countryCode != ''">
AND country_code = #{countryCode}
</if>
<if test="zoneCode != null and zoneCode != ''">
AND zone_code = #{zoneCode}
</if>
<if test="productKeyword != null and productKeyword != ''">
AND (
product_code like concat('%', #{productKeyword}, '%')
or product_name like concat('%', #{productKeyword}, '%')
)
</if>
<if test="countryKeyword != null and countryKeyword != ''">
AND (
country_code like concat('%', #{countryKeyword}, '%')
or country_name like concat('%', #{countryKeyword}, '%')
)
</if>
<if test="zoneKeyword != null and zoneKeyword != ''">
AND (
zone_code like concat('%', #{zoneKeyword}, '%')
or zone_name like concat('%', #{zoneKeyword}, '%')
)
</if>
<if test="keyword != null and keyword != ''">
AND (
product_code like concat('%', #{keyword}, '%')
or product_name like concat('%', #{keyword}, '%')
or country_code like concat('%', #{keyword}, '%')
or country_name like concat('%', #{keyword}, '%')
or zone_code like concat('%', #{keyword}, '%')
or zone_name like concat('%', #{keyword}, '%')
or weight_label like concat('%', #{keyword}, '%')
)
</if>
</where>
order by psd_id asc
</select>
<select id="countProductByPriceSetId" parameterType="Long" resultType="int">
select count(distinct product_code) from prc_price_set_detail where price_set_id = #{priceSetId}
</select>
<select id="countByPriceSetId" parameterType="Long" resultType="int">
select count(1) from prc_price_set_detail where price_set_id = #{priceSetId}
</select>
<select id="countByPsvId" parameterType="Long" resultType="int">
select count(1) from prc_price_set_detail where psv_id = #{psvId}
</select>
<select id="selectDetailOptionRows" resultMap="PrcPriceSetDetailResult">
select distinct product_code, product_name, country_code, country_name, zone_code, zone_name
from prc_price_set_detail
where psv_id = #{psvId}
order by product_code, country_name, zone_code
</select>
<!-- FIXED: join active products + country by product_id only (avoid OR-join row explosion) -->
<insert id="insertFixedDetailsFromLibrary">
insert ignore into prc_price_set_detail (
price_set_id, psv_id, product_code, product_name,
country_code, country_name, zone_id, zone_code, zone_name,
weight_label, weight_min, weight_max, product_country_id,
fv_value, fv_registration_fee, round_mode,
effective_date, expire_date, create_time
)
select
#{priceSetId},
#{psvId},
p.product_code,
p.product_name,
c.country_code,
c.country_name,
c.zone_id,
c.zone_code,
c.zone_name,
case
when c.weight_min is null and c.weight_max is null then null
else concat(
ifnull(trim(trailing '0' from trim(trailing '.' from cast(c.weight_min as char))), ''),
'&lt;W≤',
ifnull(trim(trailing '0' from trim(trailing '.' from cast(c.weight_max as char))), '')
)
end,
c.weight_min,
c.weight_max,
c.detail_id,
c.freight_price,
c.registration_fee,
'HALF_UP',
c.effective_date,
c.expire_date,
sysdate()
from bms_product p
inner join bms_product_country c on c.product_id = p.product_id
where p.status = '1'
and p.product_id = (
select max(p2.product_id) from bms_product p2
where p2.product_code = p.product_code and p2.status = '1'
)
and ifnull(c.status, '1') &lt;&gt; '2'
<choose>
<when test="openOnly">
and (c.expire_date is null or date(c.expire_date) &gt; curdate())
</when>
<otherwise>
and date(c.effective_date) &lt;= date(#{asOf})
and (c.expire_date is null or date(c.expire_date) &gt; date(#{asOf}))
</otherwise>
</choose>
order by p.product_code asc, c.country_name asc, c.zone_code asc, c.weight_min asc, c.detail_id asc
</insert>
<insert id="insertDiscountDetailsFromLibrary">
insert ignore into prc_price_set_detail (
price_set_id, psv_id, product_code, product_name, round_mode, create_time
)
select
#{priceSetId},
#{psvId},
p.product_code,
p.product_name,
'HALF_UP',
sysdate()
from bms_product p
where p.status = '1'
and p.product_id = (
select max(p2.product_id) from bms_product p2
where p2.product_code = p.product_code and p2.status = '1'
)
order by p.product_code asc
</insert>
<insert id="insertPrcPriceSetDetail" parameterType="PrcPriceSetDetail" useGeneratedKeys="true" keyProperty="psdId">
insert into prc_price_set_detail (
<if test="priceSetId != null">price_set_id,</if>
<if test="psvId != null">psv_id,</if>
<if test="productCode != null and productCode != ''">product_code,</if>
<if test="productName != null">product_name,</if>
<if test="countryCode != null">country_code,</if>
<if test="countryName != null">country_name,</if>
<if test="zoneId != null">zone_id,</if>
<if test="zoneCode != null">zone_code,</if>
<if test="zoneName != null">zone_name,</if>
<if test="zdId != null">zd_id,</if>
<if test="wsdId != null">wsd_id,</if>
<if test="weightLabel != null">weight_label,</if>
<if test="weightMin != null">weight_min,</if>
<if test="weightMax != null">weight_max,</if>
<if test="productCountryId != null">product_country_id,</if>
<if test="fvValue != null">fv_value,</if>
<if test="fvRegistrationFee != null">fv_registration_fee,</if>
<if test="discountValue != null">discount_value,</if>
<if test="roundMode != null and roundMode != ''">round_mode,</if>
<if test="prId != null">pr_id,</if>
<if test="effectiveDate != null">effective_date,</if>
expire_date,
create_time
) values (
<if test="priceSetId != null">#{priceSetId},</if>
<if test="psvId != null">#{psvId},</if>
<if test="productCode != null and productCode != ''">#{productCode},</if>
<if test="productName != null">#{productName},</if>
<if test="countryCode != null">#{countryCode},</if>
<if test="countryName != null">#{countryName},</if>
<if test="zoneId != null">#{zoneId},</if>
<if test="zoneCode != null">#{zoneCode},</if>
<if test="zoneName != null">#{zoneName},</if>
<if test="zdId != null">#{zdId},</if>
<if test="wsdId != null">#{wsdId},</if>
<if test="weightLabel != null">#{weightLabel},</if>
<if test="weightMin != null">#{weightMin},</if>
<if test="weightMax != null">#{weightMax},</if>
<if test="productCountryId != null">#{productCountryId},</if>
<if test="fvValue != null">#{fvValue},</if>
<if test="fvRegistrationFee != null">#{fvRegistrationFee},</if>
<if test="discountValue != null">#{discountValue},</if>
<if test="roundMode != null and roundMode != ''">#{roundMode},</if>
<if test="prId != null">#{prId},</if>
<if test="effectiveDate != null">#{effectiveDate},</if>
#{expireDate},
sysdate()
)
</insert>
<update id="updatePrcPriceSetDetail" parameterType="PrcPriceSetDetail">
update prc_price_set_detail
<set>
<if test="psvId != null">psv_id = #{psvId},</if>
<if test="productCode != null and productCode != ''">product_code = #{productCode},</if>
<if test="productName != null">product_name = #{productName},</if>
country_code = #{countryCode},
country_name = #{countryName},
zone_id = #{zoneId},
zone_code = #{zoneCode},
zone_name = #{zoneName},
zd_id = #{zdId},
wsd_id = #{wsdId},
weight_label = #{weightLabel},
weight_min = #{weightMin},
weight_max = #{weightMax},
product_country_id = #{productCountryId},
fv_value = #{fvValue},
fv_registration_fee = #{fvRegistrationFee},
discount_value = #{discountValue},
<if test="roundMode != null and roundMode != ''">round_mode = #{roundMode},</if>
pr_id = #{prId},
effective_date = #{effectiveDate},
expire_date = #{expireDate},
update_time = sysdate()
</set>
where psd_id = #{psdId}
</update>
<delete id="deletePrcPriceSetDetailByIds" parameterType="Long">
delete from prc_price_set_detail where psd_id in
<foreach item="psdId" collection="array" open="(" separator="," close=")">
#{psdId}
</foreach>
</delete>
<delete id="deletePrcPriceSetDetailByPriceSetId" parameterType="Long">
delete from prc_price_set_detail where price_set_id = #{priceSetId}
</delete>
<delete id="deletePrcPriceSetDetailByPsvId" parameterType="Long">
delete from prc_price_set_detail where psv_id = #{psvId}
</delete>
<delete id="deleteOrphanDetailsByPriceSetId" parameterType="Long">
delete from prc_price_set_detail where price_set_id = #{priceSetId} and psv_id is null
</delete>
<select id="selectFixedMatch" resultMap="PrcPriceSetDetailResult">
<include refid="selectPrcPriceSetDetailVo"/>
where price_set_id = #{priceSetId}
<if test="psvId != null">
and psv_id = #{psvId}
</if>
and product_code = #{productCode}
and (
<if test="productCountryId != null">
product_country_id = #{productCountryId}
or
</if>
(
<choose>
<when test="countryCode != null and countryCode != ''">
upper(ifnull(country_code,'')) = upper(#{countryCode})
</when>
<when test="countryName != null and countryName != ''">
country_name = #{countryName}
</when>
<otherwise>
1 = 0
</otherwise>
</choose>
<if test="zoneCode != null and zoneCode != ''">
and (zone_code is null or upper(zone_code) = upper(#{zoneCode}))
</if>
<if test="weightLabel != null and weightLabel != ''">
and (weight_label is null or weight_label = #{weightLabel} or weight_label like concat('%', #{weightLabel}, '%'))
</if>
)
)
order by
case when #{productCountryId} is not null and product_country_id = #{productCountryId} then 0 else 1 end,
case when #{zoneCode} is not null and upper(ifnull(zone_code,'')) = upper(#{zoneCode}) then 0 else 1 end,
case when zone_code is null then 1 else 0 end,
psd_id asc
limit 1
</select>
<select id="selectDiscountMatch" resultMap="PrcPriceSetDetailResult">
<include refid="selectPrcPriceSetDetailVo"/>
where price_set_id = #{priceSetId}
<if test="psvId != null">
and psv_id = #{psvId}
</if>
and product_code = #{productCode}
order by psd_id asc
limit 1
</select>
<insert id="copyDetailsFromVersion">
insert into prc_price_set_detail (
price_set_id, psv_id, product_code, product_name, country_code, country_name,
zone_id, zone_code, zone_name, zd_id, wsd_id, weight_label, weight_min, weight_max,
product_country_id, fv_value, fv_registration_fee, discount_value, round_mode,
pr_id, effective_date, expire_date, create_time
)
select
price_set_id, #{newPsvId}, product_code, product_name, country_code, country_name,
zone_id, zone_code, zone_name, zd_id, wsd_id, weight_label, weight_min, weight_max,
product_country_id, fv_value, fv_registration_fee, discount_value, round_mode,
pr_id, effective_date, expire_date, sysdate()
from prc_price_set_detail
where psv_id = #{srcPsvId}
order by psd_id asc
</insert>
</mapper>