增加软删除

This commit is contained in:
wuweihua
2026-10-12 09:52:24 +08:00
parent 5aba8af49d
commit d08485d738
25 changed files with 561 additions and 101 deletions
@@ -12,6 +12,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="detailId" column="detail_id" />
<result property="priceType" column="price_type" />
<result property="countryCode" column="country_code" />
<result property="isDel" column="is_del" />
<result property="scName" column="sc_name" />
<result property="feeType" column="fee_type" />
<result property="chargeType" column="charge_type" />
@@ -31,20 +32,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<sql id="selectPrcSurchargeRelVo">
select r.rel_id, r.sc_id, r.product_id, r.product_code, r.detail_id,
r.price_type, r.country_code,
r.price_type, r.country_code, r.is_del,
r.created_by, r.create_time, r.updated_by, r.update_time,
s.sc_name, s.fee_type, s.charge_type, s.charge_value, s.currency,
s.round_mode, s.ss_code, s.sc_note,
ifnull(c.country_name, rc.country_name) as country_name, ifnull(c.weight_min, rc.weight_min) as weight_min, ifnull(c.weight_max, rc.weight_max) as weight_max
from prc_surcharge_rel r
join prc_surcharge s on s.sc_id = r.sc_id
left join product_country c on c.detail_id = r.detail_id and r.price_type = 'PRODUCT'
left join redline_product_country rc on rc.detail_id = r.detail_id and r.price_type = 'REDLINE'
join prc_surcharge s on s.sc_id = r.sc_id and ifnull(s.is_del, '0') = '0'
left join product_country c on c.detail_id = r.detail_id and r.price_type = 'PRODUCT' and ifnull(c.is_del, '0') = '0'
left join redline_product_country rc on rc.detail_id = r.detail_id and r.price_type = 'REDLINE' and ifnull(rc.is_del, '0') = '0'
</sql>
<select id="selectPrcSurchargeRelList" parameterType="PrcSurchargeRel" resultMap="PrcSurchargeRelResult">
<include refid="selectPrcSurchargeRelVo"/>
<where>
and ifnull(r.is_del, '0') = '0'
<if test="productId != null">
AND r.product_id = #{productId}
</if>
@@ -69,7 +71,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectByDetailIdsAndPriceType" resultMap="PrcSurchargeRelResult">
<include refid="selectPrcSurchargeRelVo"/>
where r.price_type = #{priceType}
where ifnull(r.is_del, '0') = '0'
and r.price_type = #{priceType}
and r.detail_id in
<foreach item="id" collection="detailIds" open="(" separator="," close=")">
#{id}
@@ -79,55 +82,66 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<insert id="insertPrcSurchargeRel" parameterType="PrcSurchargeRel" useGeneratedKeys="true" keyProperty="relId">
insert into prc_surcharge_rel (
sc_id, product_id, product_code, detail_id, price_type, country_code,
sc_id, product_id, product_code, detail_id, price_type, country_code, is_del,
<if test="createBy != null and createBy != ''">created_by,</if>
create_time
) values (
#{scId}, #{productId}, #{productCode}, #{detailId},
#{priceType}, #{countryCode},
#{priceType}, #{countryCode}, ifnull(#{isDel}, '0'),
<if test="createBy != null and createBy != ''">#{createBy},</if>
sysdate()
)
</insert>
<delete id="deletePrcSurchargeRelByIds" parameterType="Long">
delete from prc_surcharge_rel where rel_id in
<update id="deletePrcSurchargeRelByIds" parameterType="Long">
update prc_surcharge_rel
set is_del = '1', update_time = sysdate()
where ifnull(is_del, '0') = '0'
and rel_id in
<foreach item="relId" collection="array" open="(" separator="," close=")">
#{relId}
</foreach>
</delete>
</update>
<delete id="deleteRelByProductCodes">
delete from prc_surcharge_rel where product_code in
<update id="deleteRelByProductCodes">
update prc_surcharge_rel
set is_del = '1', update_time = sysdate()
where ifnull(is_del, '0') = '0'
and price_type = 'PRODUCT'
and product_code in
<foreach item="code" collection="array" open="(" separator="," close=")">
#{code}
</foreach>
and price_type = 'PRODUCT'
</delete>
</update>
<delete id="deleteByDetailIdsAndPriceType">
delete from prc_surcharge_rel
where price_type = #{priceType}
<update id="deleteByDetailIdsAndPriceType">
update prc_surcharge_rel
set is_del = '1', update_time = sysdate()
where ifnull(is_del, '0') = '0'
and price_type = #{priceType}
and detail_id in
<foreach item="id" collection="detailIds" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</update>
<delete id="deleteByProductIdsAndPriceType">
delete from prc_surcharge_rel
where price_type = #{priceType}
<update id="deleteByProductIdsAndPriceType">
update prc_surcharge_rel
set is_del = '1', update_time = sysdate()
where ifnull(is_del, '0') = '0'
and price_type = #{priceType}
and product_id in
<foreach item="id" collection="productIds" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</update>
<!-- 附加费版本化编辑后,产品关联重指向新记录 -->
<update id="rebindRelScId">
update prc_surcharge_rel
set sc_id = #{newScId}, updated_by = #{operator}, update_time = sysdate()
where sc_id = #{oldScId}
where ifnull(is_del, '0') = '0'
and sc_id = #{oldScId}
</update>
</mapper>