增加一个打单功能套餐
This commit is contained in:
@@ -6,7 +6,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
|
||||
<select id="selectByChannelAndType" resultType="com.bms.price.domain.ChannelProductMap">
|
||||
select id, channel_id as channelId, channel_code as channelCode, product_id as productId,
|
||||
price_set_id as priceSetId, pay_type as payType, create_by as createBy, create_time as createTime,
|
||||
pay_type as payType, create_by as createBy, create_time as createTime,
|
||||
update_by as updateBy, update_time as updateTime
|
||||
from srv_channel_product_map
|
||||
where channel_id = #{channelId} and pay_type = #{payType}
|
||||
@@ -15,14 +15,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
|
||||
<insert id="upsert">
|
||||
insert into srv_channel_product_map (
|
||||
channel_id, channel_code, product_id, price_set_id, pay_type, create_by, create_time, update_by, update_time
|
||||
channel_id, channel_code, product_id, pay_type, create_by, create_time, update_by, update_time
|
||||
) values (
|
||||
#{channelId}, #{channelCode}, #{productId}, #{priceSetId}, #{payType}, #{createBy}, sysdate(), #{updateBy}, sysdate()
|
||||
#{channelId}, #{channelCode}, #{productId}, #{payType}, #{createBy}, sysdate(), #{updateBy}, sysdate()
|
||||
)
|
||||
on duplicate key update
|
||||
channel_code = values(channel_code),
|
||||
product_id = values(product_id),
|
||||
price_set_id = values(price_set_id),
|
||||
update_by = values(update_by),
|
||||
update_time = sysdate()
|
||||
</insert>
|
||||
|
||||
@@ -49,6 +49,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<where>
|
||||
<if test="templateOnly != null and templateOnly">
|
||||
and (pay_product.channel_id is null or pay_product.channel_id = '')
|
||||
and not (
|
||||
exists (
|
||||
select 1 from pay_product_term t_label
|
||||
where t_label.product_id = pay_product.product_id
|
||||
and t_label.price_set_id is not null
|
||||
)
|
||||
and not exists (
|
||||
select 1 from pay_product_term t_pay
|
||||
where t_pay.product_id = pay_product.product_id
|
||||
and t_pay.price_set_id is null
|
||||
)
|
||||
)
|
||||
</if>
|
||||
<if test="currentOnly != null and currentOnly">
|
||||
and pay_product.origin_id is null
|
||||
@@ -129,7 +141,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
inner join pay_product v on v.product_id = t2.product_id
|
||||
where (v.channel_id is null or v.channel_id = '')
|
||||
and (v.product_id = pay_product.product_id or v.origin_id = pay_product.product_id)
|
||||
order by case when t2.status = '0' then 0 else 1 end, ifnull(v.version_no, 1) desc, t2.term_id desc
|
||||
and t2.price_set_id is null
|
||||
order by case when t2.status = '1' then 0 when t2.status = '0' then 1 else 2 end, ifnull(v.version_no, 1) desc, t2.term_id desc
|
||||
limit 1
|
||||
)
|
||||
left join pay_product cur on cur.product_id = t.product_id
|
||||
@@ -202,15 +215,65 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
where product_id = #{productId}
|
||||
</update>
|
||||
|
||||
<!-- 应付公共模板:排除「仅打单套餐」产品(有 label term、无公共 term) -->
|
||||
<sql id="payPublicTemplateOnly">
|
||||
and not (
|
||||
exists (
|
||||
select 1 from pay_product_term t_label
|
||||
where t_label.product_id = pay_product.product_id
|
||||
and t_label.price_set_id is not null
|
||||
)
|
||||
and not exists (
|
||||
select 1 from pay_product_term t_pay
|
||||
where t_pay.product_id = pay_product.product_id
|
||||
and t_pay.price_set_id is null
|
||||
)
|
||||
)
|
||||
</sql>
|
||||
|
||||
<select id="selectTemplateId" resultType="long">
|
||||
select product_id from pay_product
|
||||
where dict_value = #{dictValue}
|
||||
and (channel_id is null or channel_id = '')
|
||||
and origin_id is null
|
||||
<include refid="payPublicTemplateOnly"/>
|
||||
order by product_id
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<select id="selectTemplateIdByType" resultType="long">
|
||||
select product_id from pay_product
|
||||
where dict_value = #{dictValue}
|
||||
and ifnull(product_type, 'AP') = #{productType}
|
||||
and (channel_id is null or channel_id = '')
|
||||
and origin_id is null
|
||||
<include refid="payPublicTemplateOnly"/>
|
||||
order by product_id
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<!-- 打单套餐专用:只命中已有 label term 的 AR 产品,绝不碰应付公共模板 -->
|
||||
<select id="selectLabelProductIdByDict" resultType="long">
|
||||
select p.product_id
|
||||
from pay_product p
|
||||
where p.dict_value = #{dictValue}
|
||||
and ifnull(p.product_type, 'AP') = 'AR'
|
||||
and (p.channel_id is null or p.channel_id = '')
|
||||
and p.origin_id is null
|
||||
and exists (
|
||||
select 1 from pay_product_term t
|
||||
where t.product_id = p.product_id
|
||||
and t.price_set_id is not null
|
||||
)
|
||||
and not exists (
|
||||
select 1 from pay_product_term t2
|
||||
where t2.product_id = p.product_id
|
||||
and t2.price_set_id is null
|
||||
)
|
||||
order by p.product_id
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<select id="selectTemplateOptions" resultMap="PayProductResult">
|
||||
select p.product_id, p.product_name, p.product_type, p.dict_value, p.sheet_name, p.supplier_name, p.effective_date,
|
||||
p.currency, ifnull(cur.version_no, p.version_no) as version_no
|
||||
@@ -221,13 +284,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
inner join pay_product v on v.product_id = t2.product_id
|
||||
where (v.channel_id is null or v.channel_id = '')
|
||||
and (v.product_id = p.product_id or v.origin_id = p.product_id)
|
||||
order by case when t2.status = '0' then 0 else 1 end, ifnull(v.version_no, 1) desc, t2.term_id desc
|
||||
and t2.price_set_id is null
|
||||
order by case when t2.status = '1' then 0 when t2.status = '0' then 1 else 2 end, ifnull(v.version_no, 1) desc, t2.term_id desc
|
||||
limit 1
|
||||
)
|
||||
left join pay_product cur on cur.product_id = t.product_id
|
||||
where (p.channel_id is null or p.channel_id = '')
|
||||
and p.origin_id is null
|
||||
and ifnull(p.product_type, 'AP') = #{payType}
|
||||
and not (
|
||||
exists (
|
||||
select 1 from pay_product_term t_label
|
||||
where t_label.product_id = p.product_id
|
||||
and t_label.price_set_id is not null
|
||||
)
|
||||
and not exists (
|
||||
select 1 from pay_product_term t_pay
|
||||
where t_pay.product_id = p.product_id
|
||||
and t_pay.price_set_id is null
|
||||
)
|
||||
)
|
||||
order by p.product_name
|
||||
</select>
|
||||
|
||||
@@ -238,11 +314,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
|
||||
<insert id="insertWeightBands">
|
||||
insert into pay_weight_band (
|
||||
product_id, version_no, section_name, country_name, country_code, zone_name, weight_label, weight_min, weight_max,
|
||||
product_id, term_id, version_no, section_name, country_name, country_code, zone_name, weight_label, weight_min, weight_max,
|
||||
volume_text, charge_name, price, price_unit, sort_no
|
||||
) values
|
||||
<foreach collection="list" item="row" separator=",">
|
||||
(#{row.productId}, ifnull(#{row.versionNo}, 1), #{row.sectionName}, #{row.countryName}, #{row.countryCode}, #{row.zoneName},
|
||||
(#{row.productId}, #{row.termId}, ifnull(#{row.versionNo}, 1), #{row.sectionName}, #{row.countryName}, #{row.countryCode}, #{row.zoneName},
|
||||
#{row.weightLabel}, #{row.weightMin}, #{row.weightMax}, #{row.volumeText}, #{row.chargeName}, #{row.price},
|
||||
#{row.priceUnit}, #{row.sortNo})
|
||||
</foreach>
|
||||
@@ -250,11 +326,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
|
||||
<insert id="insertSurcharges">
|
||||
insert into pay_surcharge (
|
||||
product_id, version_no, section_name, fee_name, zone_name, charge_text, amount, currency, price_unit, fee_desc, period_text,
|
||||
product_id, term_id, version_no, section_name, fee_name, zone_name, charge_text, amount, currency, price_unit, fee_desc, period_text,
|
||||
effective_start, effective_end, charge_timing, calc_rule, calc_param, weight_min, weight_max, postcode_param, sort_no
|
||||
) values
|
||||
<foreach collection="list" item="row" separator=",">
|
||||
(#{row.productId}, ifnull(#{row.versionNo}, 1), #{row.sectionName}, #{row.feeName}, #{row.zoneName}, #{row.chargeText}, #{row.amount},
|
||||
(#{row.productId}, #{row.termId}, ifnull(#{row.versionNo}, 1), #{row.sectionName}, #{row.feeName}, #{row.zoneName}, #{row.chargeText}, #{row.amount},
|
||||
#{row.currency}, #{row.priceUnit}, #{row.feeDesc}, #{row.periodText}, #{row.effectiveStart}, #{row.effectiveEnd},
|
||||
#{row.chargeTiming}, ifnull(#{row.calcRule}, 'MANUAL'), #{row.calcParam}, #{row.weightMin}, #{row.weightMax},
|
||||
#{row.postcodeParam}, #{row.sortNo})
|
||||
@@ -262,14 +338,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</insert>
|
||||
|
||||
<insert id="insertExtraLines">
|
||||
insert into pay_extra_line (product_id, line_type, line_text, sort_no) values
|
||||
insert into pay_extra_line (product_id, term_id, line_type, line_text, sort_no) values
|
||||
<foreach collection="list" item="row" separator=",">
|
||||
(#{row.productId}, #{row.lineType}, #{row.lineText}, #{row.sortNo})
|
||||
(#{row.productId}, #{row.termId}, #{row.lineType}, #{row.lineText}, #{row.sortNo})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<select id="selectWeightBands" resultType="com.bms.price.domain.PayWeightBand">
|
||||
select band_id as bandId, product_id as productId, version_no as versionNo, section_name as sectionName, country_name as countryName,
|
||||
select band_id as bandId, product_id as productId, term_id as termId, version_no as versionNo, section_name as sectionName, country_name as countryName,
|
||||
country_code as countryCode, zone_name as zoneName, weight_label as weightLabel, weight_min as weightMin,
|
||||
weight_max as weightMax, volume_text as volumeText, charge_name as chargeName, price, price_unit as priceUnit, sort_no as sortNo
|
||||
from pay_weight_band
|
||||
@@ -278,8 +354,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
order by product_id, sort_no, band_id
|
||||
</select>
|
||||
|
||||
<select id="selectWeightBandsByTerm" resultType="com.bms.price.domain.PayWeightBand">
|
||||
select band_id as bandId, product_id as productId, term_id as termId, version_no as versionNo, section_name as sectionName, country_name as countryName,
|
||||
country_code as countryCode, zone_name as zoneName, weight_label as weightLabel, weight_min as weightMin,
|
||||
weight_max as weightMax, volume_text as volumeText, charge_name as chargeName, price, price_unit as priceUnit, sort_no as sortNo
|
||||
from pay_weight_band
|
||||
where term_id in
|
||||
<foreach collection="termIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
order by product_id, sort_no, band_id
|
||||
</select>
|
||||
|
||||
<select id="selectSurcharges" resultType="com.bms.price.domain.PaySurcharge">
|
||||
select surcharge_id as surchargeId, product_id as productId, version_no as versionNo, section_name as sectionName, fee_name as feeName,
|
||||
select surcharge_id as surchargeId, product_id as productId, term_id as termId, version_no as versionNo, section_name as sectionName, fee_name as feeName,
|
||||
zone_name as zoneName, charge_text as chargeText, amount, currency, price_unit as priceUnit, fee_desc as feeDesc,
|
||||
period_text as periodText, effective_start as effectiveStart, effective_end as effectiveEnd,
|
||||
charge_timing as chargeTiming, calc_rule as calcRule, calc_param as calcParam,
|
||||
@@ -290,14 +376,47 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
order by product_id, sort_no, surcharge_id
|
||||
</select>
|
||||
|
||||
<select id="selectSurchargesByTerm" resultType="com.bms.price.domain.PaySurcharge">
|
||||
select surcharge_id as surchargeId, product_id as productId, term_id as termId, version_no as versionNo, section_name as sectionName, fee_name as feeName,
|
||||
zone_name as zoneName, charge_text as chargeText, amount, currency, price_unit as priceUnit, fee_desc as feeDesc,
|
||||
period_text as periodText, effective_start as effectiveStart, effective_end as effectiveEnd,
|
||||
charge_timing as chargeTiming, calc_rule as calcRule, calc_param as calcParam,
|
||||
weight_min as weightMin, weight_max as weightMax, postcode_param as postcodeParam, sort_no as sortNo
|
||||
from pay_surcharge
|
||||
where term_id in
|
||||
<foreach collection="termIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
order by product_id, sort_no, surcharge_id
|
||||
</select>
|
||||
|
||||
<select id="selectExtraLines" resultType="com.bms.price.domain.PayExtraLine">
|
||||
select line_id as lineId, product_id as productId, line_type as lineType, line_text as lineText, sort_no as sortNo
|
||||
select line_id as lineId, product_id as productId, term_id as termId, line_type as lineType, line_text as lineText, sort_no as sortNo
|
||||
from pay_extra_line
|
||||
where product_id in
|
||||
<foreach collection="productIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
order by product_id, sort_no, line_id
|
||||
</select>
|
||||
|
||||
<select id="selectExtraLinesByTerm" resultType="com.bms.price.domain.PayExtraLine">
|
||||
select line_id as lineId, product_id as productId, term_id as termId, line_type as lineType, line_text as lineText, sort_no as sortNo
|
||||
from pay_extra_line
|
||||
where term_id in
|
||||
<foreach collection="termIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
order by product_id, sort_no, line_id
|
||||
</select>
|
||||
|
||||
<delete id="deleteWeightBandsByTerm">
|
||||
delete from pay_weight_band where term_id in
|
||||
<foreach collection="termIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
</delete>
|
||||
<delete id="deleteSurchargesByTerm">
|
||||
delete from pay_surcharge where term_id in
|
||||
<foreach collection="termIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
</delete>
|
||||
<delete id="deleteExtraLinesByTerm">
|
||||
delete from pay_extra_line where term_id in
|
||||
<foreach collection="termIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
</delete>
|
||||
|
||||
<delete id="deleteWeightBands">
|
||||
delete from pay_weight_band where product_id in
|
||||
<foreach collection="productIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
@@ -323,13 +442,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
where product_id = #{rootId} or origin_id = #{rootId}
|
||||
</select>
|
||||
|
||||
<!-- 取价只看有效期。生效/失效开关不参与,和历史页说明一致。 -->
|
||||
<!-- 取价只看有效期。生效/失效开关不参与,和历史页说明一致。仅应付公共 term。 -->
|
||||
<select id="selectEffectiveVersionId" resultType="long">
|
||||
select v.product_id
|
||||
from pay_product v
|
||||
inner join pay_product_term t on t.product_id = v.product_id
|
||||
where (v.channel_id is null or v.channel_id = '')
|
||||
and (v.product_id = #{stableId} or v.origin_id = #{stableId})
|
||||
and t.price_set_id is null
|
||||
and t.status = '1'
|
||||
and (t.effective_start is null or t.effective_start <= date(#{bizDate}))
|
||||
and (t.effective_end is null or t.effective_end >= date(#{bizDate}))
|
||||
order by ifnull(v.version_no, 1) desc, v.product_id desc
|
||||
|
||||
@@ -5,7 +5,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<mapper namespace="com.bms.price.mapper.PayProductTermMapper">
|
||||
|
||||
<select id="selectByDict" resultType="com.bms.price.domain.PayProductTerm">
|
||||
select t.term_id as termId, t.dict_value as dictValue, t.product_id as productId, t.version_no as versionNo,
|
||||
select t.term_id as termId, t.dict_value as dictValue, t.product_id as productId, t.price_set_id as priceSetId,
|
||||
t.version_no as versionNo,
|
||||
t.effective_start as effectiveStart, t.effective_end as effectiveEnd, t.status,
|
||||
t.created_by as createBy, t.create_time as createTime, t.remark,
|
||||
p.product_name as productName, p.source_file as sourceFile,
|
||||
@@ -15,29 +16,107 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
join pay_product p on p.product_id = t.product_id
|
||||
where t.dict_value = #{dictValue}
|
||||
and (p.channel_id is null or p.channel_id = '')
|
||||
and t.price_set_id is null
|
||||
order by t.version_no desc, t.term_id desc
|
||||
</select>
|
||||
|
||||
<select id="selectById" resultType="com.bms.price.domain.PayProductTerm">
|
||||
select term_id as termId, dict_value as dictValue, product_id as productId, version_no as versionNo,
|
||||
select term_id as termId, dict_value as dictValue, product_id as productId, price_set_id as priceSetId,
|
||||
version_no as versionNo,
|
||||
effective_start as effectiveStart, effective_end as effectiveEnd, status
|
||||
from pay_product_term
|
||||
where term_id = #{termId}
|
||||
</select>
|
||||
|
||||
<!-- 应付侧当前版:只取公共 term;优先生效(1),其次待生效(0) -->
|
||||
<select id="selectByProductId" resultType="com.bms.price.domain.PayProductTerm">
|
||||
select term_id as termId, dict_value as dictValue, product_id as productId, version_no as versionNo,
|
||||
select term_id as termId, dict_value as dictValue, product_id as productId, price_set_id as priceSetId,
|
||||
version_no as versionNo,
|
||||
effective_start as effectiveStart, effective_end as effectiveEnd, status
|
||||
from pay_product_term
|
||||
where product_id = #{productId}
|
||||
and price_set_id is null
|
||||
and status in ('0', '1')
|
||||
order by case when status = '1' then 0 when status = '0' then 1 else 2 end, version_no desc, term_id desc
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<!-- 打单套餐产品列表:待生效+生效 -->
|
||||
<select id="selectByPriceSetId" resultType="com.bms.price.domain.PayProductTerm">
|
||||
select t.term_id as termId, t.dict_value as dictValue, t.product_id as productId, t.price_set_id as priceSetId,
|
||||
t.version_no as versionNo,
|
||||
t.effective_start as effectiveStart, t.effective_end as effectiveEnd, t.status,
|
||||
p.product_name as productName, p.source_file as sourceFile,
|
||||
ifnull(t.file_path, p.file_path) as filePath, p.weight_count as weightCount,
|
||||
p.surcharge_count as surchargeCount, p.currency
|
||||
from pay_product_term t
|
||||
join pay_product p on p.product_id = t.product_id
|
||||
where t.price_set_id = #{priceSetId}
|
||||
and t.status in ('0', '1')
|
||||
order by p.product_name, t.term_id desc
|
||||
</select>
|
||||
|
||||
<select id="selectByPriceSetIdAndVersion" resultType="com.bms.price.domain.PayProductTerm">
|
||||
select t.term_id as termId, t.dict_value as dictValue, t.product_id as productId, t.price_set_id as priceSetId,
|
||||
t.version_no as versionNo,
|
||||
t.effective_start as effectiveStart, t.effective_end as effectiveEnd, t.status,
|
||||
p.product_name as productName, p.source_file as sourceFile,
|
||||
ifnull(t.file_path, p.file_path) as filePath, p.weight_count as weightCount,
|
||||
p.surcharge_count as surchargeCount, p.currency
|
||||
from pay_product_term t
|
||||
join pay_product p on p.product_id = t.product_id
|
||||
where t.price_set_id = #{priceSetId}
|
||||
and t.version_no = #{versionNo}
|
||||
order by case when t.status = '1' then 0 when t.status = '0' then 1 else 2 end, p.product_name, t.term_id desc
|
||||
</select>
|
||||
|
||||
<select id="selectLabelVersionGroups" resultType="com.bms.price.domain.LabelPackageVersion">
|
||||
select #{priceSetId} as priceSetId,
|
||||
t.version_no as versionNo,
|
||||
min(t.effective_start) as effectiveTime,
|
||||
max(t.effective_end) as expireTime,
|
||||
count(distinct t.product_id) as productCount,
|
||||
sum(case when t.status = '1' then 1 else 0 end) as activeCount,
|
||||
sum(case when t.status = '0' then 1 else 0 end) as pendingCount,
|
||||
min(t.create_time) as createTime
|
||||
from pay_product_term t
|
||||
where t.price_set_id = #{priceSetId}
|
||||
group by t.version_no
|
||||
order by t.version_no desc
|
||||
</select>
|
||||
|
||||
<!-- 启动:写入生效日;未到日 status=0,已到/当天 status=1 -->
|
||||
<update id="updateLabelVersionPeriod">
|
||||
update pay_product_term
|
||||
set effective_start = #{effectiveStart},
|
||||
effective_end = #{effectiveEnd},
|
||||
status = #{status},
|
||||
updated_by = #{updateBy},
|
||||
update_time = sysdate()
|
||||
where price_set_id = #{priceSetId}
|
||||
and version_no = #{versionNo}
|
||||
and status in ('0', '1')
|
||||
</update>
|
||||
|
||||
<select id="selectMaxVersionByProduct" resultType="int">
|
||||
select ifnull(max(version_no), 0) from pay_product_term where product_id = #{productId}
|
||||
<if test="priceSetId != null">
|
||||
and price_set_id = #{priceSetId}
|
||||
</if>
|
||||
<if test="priceSetId == null">
|
||||
and price_set_id is null
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="selectMaxVersionByPriceSet" resultType="int">
|
||||
select ifnull(max(version_no), 0) from pay_product_term where price_set_id = #{priceSetId}
|
||||
</select>
|
||||
|
||||
<insert id="insertTerm" parameterType="com.bms.price.domain.PayProductTerm" useGeneratedKeys="true" keyProperty="termId">
|
||||
insert into pay_product_term (
|
||||
dict_value, product_id, version_no, effective_start, effective_end, file_path, status, created_by, create_time, remark
|
||||
dict_value, product_id, price_set_id, version_no, effective_start, effective_end, file_path, status, created_by, create_time, remark
|
||||
) values (
|
||||
#{dictValue}, #{productId}, ifnull(#{versionNo}, 1), #{effectiveStart}, #{effectiveEnd}, #{filePath},
|
||||
#{dictValue}, #{productId}, #{priceSetId}, ifnull(#{versionNo}, 1), #{effectiveStart}, #{effectiveEnd}, #{filePath},
|
||||
ifnull(#{status}, '0'), #{createBy}, sysdate(), #{remark}
|
||||
)
|
||||
</insert>
|
||||
@@ -59,9 +138,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
where term_id = #{termId}
|
||||
</update>
|
||||
|
||||
<!-- 截断旧版:生效/待生效 → 已失效(2) -->
|
||||
<update id="closeOpenTerms">
|
||||
update pay_product_term
|
||||
set status = '1',
|
||||
set status = '2',
|
||||
effective_end = case
|
||||
when effective_end is not null and effective_end < #{endDate} then effective_end
|
||||
when effective_start is not null and effective_start > #{endDate} then effective_start
|
||||
@@ -70,14 +150,90 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
updated_by = #{updateBy},
|
||||
update_time = sysdate()
|
||||
where dict_value = #{dictValue}
|
||||
and status in ('0', '1')
|
||||
and price_set_id is null
|
||||
</update>
|
||||
|
||||
<update id="closeOpenTermsBySetProduct">
|
||||
update pay_product_term
|
||||
set status = '2',
|
||||
effective_end = case
|
||||
when effective_end is not null and effective_end < #{endDate} then effective_end
|
||||
when effective_start is not null and effective_start > #{endDate} then effective_start
|
||||
else #{endDate}
|
||||
end,
|
||||
updated_by = #{updateBy},
|
||||
update_time = sysdate()
|
||||
where product_id = #{productId}
|
||||
and price_set_id = #{priceSetId}
|
||||
and status in ('0', '1')
|
||||
</update>
|
||||
|
||||
<update id="closePendingBySetProduct">
|
||||
update pay_product_term
|
||||
set status = '2',
|
||||
effective_end = case
|
||||
when effective_end is not null and effective_end < #{endDate} then effective_end
|
||||
when effective_start is not null and effective_start > #{endDate} then effective_start
|
||||
else #{endDate}
|
||||
end,
|
||||
updated_by = #{updateBy},
|
||||
update_time = sysdate()
|
||||
where product_id = #{productId}
|
||||
and price_set_id = #{priceSetId}
|
||||
and status = '0'
|
||||
</update>
|
||||
|
||||
<update id="closeEffectExceptVersion">
|
||||
update pay_product_term
|
||||
set status = '2',
|
||||
effective_end = case
|
||||
when effective_end is not null and effective_end < #{endDate} then effective_end
|
||||
when effective_start is not null and effective_start > #{endDate} then effective_start
|
||||
else #{endDate}
|
||||
end,
|
||||
updated_by = #{updateBy},
|
||||
update_time = sysdate()
|
||||
where price_set_id = #{priceSetId}
|
||||
and status = '1'
|
||||
and version_no <> #{versionNo}
|
||||
</update>
|
||||
|
||||
<update id="scheduleEndExceptVersion">
|
||||
update pay_product_term
|
||||
set status = '1',
|
||||
effective_end = #{endDate},
|
||||
updated_by = #{updateBy},
|
||||
update_time = sysdate()
|
||||
where price_set_id = #{priceSetId}
|
||||
and version_no <> #{versionNo}
|
||||
and (
|
||||
status = '1'
|
||||
or (status = '2' and effective_end is not null and effective_end >= #{today})
|
||||
)
|
||||
</update>
|
||||
|
||||
<update id="restorePrematureClosed">
|
||||
update pay_product_term
|
||||
set status = '1',
|
||||
updated_by = #{updateBy},
|
||||
update_time = sysdate()
|
||||
where price_set_id = #{priceSetId}
|
||||
and status = '2'
|
||||
and effective_end is not null
|
||||
and effective_end >= #{today}
|
||||
</update>
|
||||
|
||||
<delete id="deleteByProductIds">
|
||||
delete from pay_product_term where product_id in
|
||||
<foreach collection="productIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
</delete>
|
||||
|
||||
<delete id="deleteByTermIds">
|
||||
delete from pay_product_term where term_id in
|
||||
<foreach collection="termIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
</delete>
|
||||
|
||||
<update id="updateProductEffectiveDate">
|
||||
update pay_product
|
||||
set effective_date = #{effectiveDate},
|
||||
|
||||
@@ -31,11 +31,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
s.default_discount, s.default_type, s.calculate_sign,
|
||||
s.status, s.tms_id,
|
||||
s.created_by, s.create_time, s.updated_by, s.update_time,
|
||||
(select count(distinct p.product_code)
|
||||
from prc_price_set_product p
|
||||
inner join prc_price_set_version v on v.psv_id = p.psv_id
|
||||
where v.price_set_id = s.price_set_id
|
||||
and ifnull(p.is_del, '0') = '0') as product_count,
|
||||
case
|
||||
when ifnull(s.set_category, 'PACKAGE') = 'LABEL' then
|
||||
(select count(distinct t.product_id)
|
||||
from pay_product_term t
|
||||
where t.price_set_id = s.price_set_id
|
||||
and t.status = '0')
|
||||
else
|
||||
(select count(distinct p.product_code)
|
||||
from prc_price_set_product p
|
||||
inner join prc_price_set_version v on v.psv_id = p.psv_id
|
||||
where v.price_set_id = s.price_set_id
|
||||
and ifnull(p.is_del, '0') = '0')
|
||||
end as product_count,
|
||||
(select count(1) from prc_customer_price_set c where c.price_set_id = s.price_set_id) as customer_count,
|
||||
(select group_concat(
|
||||
concat(ifnull(c.customer_code, ''),
|
||||
|
||||
Reference in New Issue
Block a user