209 lines
9.4 KiB
XML
209 lines
9.4 KiB
XML
<?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.PrcPriceSetVersionSurchargeMapper">
|
|
|
|
<resultMap type="PrcPriceSetVersionSurcharge" id="PrcPriceSetVersionSurchargeResult">
|
|
<id property="psvsId" column="psvs_id" />
|
|
<result property="psvId" column="psv_id" />
|
|
<result property="scId" column="sc_id" />
|
|
<result property="productCode" column="product_code" />
|
|
<result property="psdId" column="psd_id" />
|
|
<result property="scName" column="sc_name" />
|
|
<result property="feeType" column="fee_type" />
|
|
<result property="chargeType" column="charge_type" />
|
|
<result property="chargeValue" column="charge_value" />
|
|
<result property="currency" column="currency" />
|
|
<result property="roundMode" column="round_mode" />
|
|
<result property="countryCode" column="country_code" />
|
|
<result property="scNote" column="sc_note" />
|
|
<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="selectPrcPriceSetVersionSurchargeVo">
|
|
select psvs_id, psv_id, sc_id, product_code, psd_id, sc_name, fee_type, charge_type,
|
|
charge_value, currency, round_mode, country_code, sc_note,
|
|
created_by, create_time, updated_by, update_time
|
|
from prc_price_set_version_surcharge
|
|
</sql>
|
|
|
|
<select id="selectPrcPriceSetVersionSurchargeById" parameterType="Long" resultMap="PrcPriceSetVersionSurchargeResult">
|
|
<include refid="selectPrcPriceSetVersionSurchargeVo"/>
|
|
where psvs_id = #{psvsId}
|
|
</select>
|
|
|
|
<select id="selectPrcPriceSetVersionSurchargeList" parameterType="PrcPriceSetVersionSurcharge" resultMap="PrcPriceSetVersionSurchargeResult">
|
|
<include refid="selectPrcPriceSetVersionSurchargeVo"/>
|
|
<where>
|
|
<if test="psvId != null">
|
|
AND psv_id = #{psvId}
|
|
</if>
|
|
<if test="scId != null">
|
|
AND sc_id = #{scId}
|
|
</if>
|
|
<if test="productCode != null and productCode != ''">
|
|
AND product_code = #{productCode}
|
|
</if>
|
|
<if test="psdId != null">
|
|
AND psd_id = #{psdId}
|
|
</if>
|
|
</where>
|
|
order by psvs_id asc
|
|
</select>
|
|
|
|
<insert id="insertPrcPriceSetVersionSurcharge" parameterType="PrcPriceSetVersionSurcharge" useGeneratedKeys="true" keyProperty="psvsId">
|
|
insert into prc_price_set_version_surcharge (
|
|
<if test="psvId != null">psv_id,</if>
|
|
<if test="psdId != null">psd_id,</if>
|
|
<if test="scId != null">sc_id,</if>
|
|
<if test="productCode != null">product_code,</if>
|
|
<if test="scName != null and scName != ''">sc_name,</if>
|
|
<if test="feeType != null and feeType != ''">fee_type,</if>
|
|
<if test="chargeType != null and chargeType != ''">charge_type,</if>
|
|
<if test="chargeValue != null">charge_value,</if>
|
|
<if test="currency != null and currency != ''">currency,</if>
|
|
<if test="roundMode != null and roundMode != ''">round_mode,</if>
|
|
<if test="countryCode != null">country_code,</if>
|
|
<if test="scNote != null">sc_note,</if>
|
|
<if test="createBy != null and createBy != ''">created_by,</if>
|
|
create_time
|
|
) values (
|
|
<if test="psvId != null">#{psvId},</if>
|
|
<if test="psdId != null">#{psdId},</if>
|
|
<if test="scId != null">#{scId},</if>
|
|
<if test="productCode != null">#{productCode},</if>
|
|
<if test="scName != null and scName != ''">#{scName},</if>
|
|
<if test="feeType != null and feeType != ''">#{feeType},</if>
|
|
<if test="chargeType != null and chargeType != ''">#{chargeType},</if>
|
|
<if test="chargeValue != null">#{chargeValue},</if>
|
|
<if test="currency != null and currency != ''">#{currency},</if>
|
|
<if test="roundMode != null and roundMode != ''">#{roundMode},</if>
|
|
<if test="countryCode != null">#{countryCode},</if>
|
|
<if test="scNote != null">#{scNote},</if>
|
|
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
|
sysdate()
|
|
)
|
|
</insert>
|
|
|
|
<update id="updatePrcPriceSetVersionSurcharge" parameterType="PrcPriceSetVersionSurcharge">
|
|
update prc_price_set_version_surcharge
|
|
<set>
|
|
<if test="psdId != null">psd_id = #{psdId},</if>
|
|
<if test="scId != null">sc_id = #{scId},</if>
|
|
product_code = #{productCode},
|
|
<if test="scName != null and scName != ''">sc_name = #{scName},</if>
|
|
<if test="feeType != null and feeType != ''">fee_type = #{feeType},</if>
|
|
<if test="chargeType != null and chargeType != ''">charge_type = #{chargeType},</if>
|
|
<if test="chargeValue != null">charge_value = #{chargeValue},</if>
|
|
<if test="currency != null and currency != ''">currency = #{currency},</if>
|
|
<if test="roundMode != null and roundMode != ''">round_mode = #{roundMode},</if>
|
|
country_code = #{countryCode},
|
|
sc_note = #{scNote},
|
|
<if test="updateBy != null and updateBy != ''">updated_by = #{updateBy},</if>
|
|
update_time = sysdate()
|
|
</set>
|
|
where psvs_id = #{psvsId}
|
|
</update>
|
|
|
|
<delete id="deletePrcPriceSetVersionSurchargeByIds" parameterType="Long">
|
|
delete from prc_price_set_version_surcharge where psvs_id in
|
|
<foreach item="psvsId" collection="array" open="(" separator="," close=")">
|
|
#{psvsId}
|
|
</foreach>
|
|
</delete>
|
|
|
|
<delete id="deleteByPsvId" parameterType="Long">
|
|
delete from prc_price_set_version_surcharge where psv_id = #{psvId}
|
|
</delete>
|
|
|
|
<delete id="deleteByPsdId" parameterType="Long">
|
|
delete from prc_price_set_version_surcharge where psd_id = #{psdId}
|
|
</delete>
|
|
|
|
<select id="selectByPsdIds" resultMap="PrcPriceSetVersionSurchargeResult">
|
|
<include refid="selectPrcPriceSetVersionSurchargeVo"/>
|
|
where psd_id in
|
|
<foreach item="id" collection="psdIds" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
order by psvs_id asc
|
|
</select>
|
|
|
|
<!-- Join detail x surcharge_rel x surcharge; skip OF fuel; product-level or same detail_id -->
|
|
<insert id="insertFromLibraryRels">
|
|
insert into prc_price_set_version_surcharge (
|
|
psv_id, psd_id, sc_id, product_code, sc_name, fee_type, charge_type,
|
|
charge_value, currency, round_mode, country_code, sc_note,
|
|
created_by, create_time
|
|
)
|
|
select
|
|
d.psv_id,
|
|
d.psd_id,
|
|
r.sc_id,
|
|
d.product_code,
|
|
s.sc_name,
|
|
ifnull(nullif(s.fee_type, ''), 'SURCHARGE'),
|
|
ifnull(nullif(s.charge_type, ''), 'FIXED'),
|
|
s.charge_value,
|
|
ifnull(nullif(s.currency, ''), 'CNY'),
|
|
ifnull(nullif(s.round_mode, ''), 'HALF_UP'),
|
|
s.country_code,
|
|
s.sc_note,
|
|
#{createBy},
|
|
sysdate()
|
|
from prc_price_set_detail d
|
|
inner join prc_surcharge_rel r on r.product_code = d.product_code
|
|
inner join prc_surcharge s on s.sc_id = r.sc_id
|
|
where d.psv_id = #{psvId}
|
|
and ifnull(s.sc_name, '') <> ''
|
|
and s.charge_value is not null
|
|
and lower(ifnull(s.ss_code, '')) not in ('of', 'vd')
|
|
and (r.detail_id is null or r.detail_id = d.product_country_id)
|
|
and (
|
|
s.country_code is null or s.country_code = ''
|
|
or d.country_code is null or d.country_code = ''
|
|
or upper(s.country_code) = upper(d.country_code)
|
|
)
|
|
</insert>
|
|
|
|
<insert id="copySurchargesFromVersion">
|
|
insert into prc_price_set_version_surcharge (
|
|
psv_id, psd_id, sc_id, product_code, sc_name, fee_type, charge_type,
|
|
charge_value, currency, round_mode, country_code, sc_note,
|
|
created_by, create_time
|
|
)
|
|
select
|
|
#{newPsvId},
|
|
nd.psd_id,
|
|
sc.sc_id,
|
|
sc.product_code,
|
|
sc.sc_name,
|
|
sc.fee_type,
|
|
sc.charge_type,
|
|
sc.charge_value,
|
|
sc.currency,
|
|
sc.round_mode,
|
|
sc.country_code,
|
|
sc.sc_note,
|
|
#{createBy},
|
|
sysdate()
|
|
from prc_price_set_version_surcharge sc
|
|
inner join prc_price_set_detail od
|
|
on od.psd_id = sc.psd_id and od.psv_id = #{srcPsvId}
|
|
inner join prc_price_set_detail nd
|
|
on nd.psv_id = #{newPsvId}
|
|
and nd.product_code = od.product_code
|
|
and ifnull(nd.country_code, '') = ifnull(od.country_code, '')
|
|
and ifnull(nd.zone_code, '') = ifnull(od.zone_code, '')
|
|
and ifnull(nd.weight_label, '') = ifnull(od.weight_label, '')
|
|
and ifnull(nd.product_country_id, 0) = ifnull(od.product_country_id, 0)
|
|
and ifnull(nd.discount_value, -1) = ifnull(od.discount_value, -1)
|
|
where sc.psv_id = #{srcPsvId}
|
|
</insert>
|
|
|
|
</mapper>
|