增加一个渠道绑定
This commit is contained in:
@@ -6,22 +6,37 @@ 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,
|
||||
pay_type as payType, create_by as createBy, create_time as createTime,
|
||||
price_set_id as priceSetId, 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}
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<select id="selectByPriceSetId" resultType="com.bms.price.domain.ChannelProductMap">
|
||||
select m.id, m.channel_id as channelId, m.channel_code as channelCode, m.product_id as productId,
|
||||
m.price_set_id as priceSetId, m.pay_type as payType,
|
||||
c.channel_name as channelName, p.product_name as productName,
|
||||
m.create_by as createBy, m.create_time as createTime,
|
||||
m.update_by as updateBy, m.update_time as updateTime
|
||||
from srv_channel_product_map m
|
||||
left join srv_service_channel c on c.id = m.channel_id
|
||||
left join pay_product p on p.product_id = m.product_id
|
||||
where m.price_set_id = #{priceSetId}
|
||||
and m.pay_type = 'AR'
|
||||
order by m.update_time desc, m.id desc
|
||||
</select>
|
||||
|
||||
<insert id="upsert">
|
||||
insert into srv_channel_product_map (
|
||||
channel_id, channel_code, product_id, pay_type, create_by, create_time, update_by, update_time
|
||||
channel_id, channel_code, product_id, price_set_id, pay_type, create_by, create_time, update_by, update_time
|
||||
) values (
|
||||
#{channelId}, #{channelCode}, #{productId}, #{payType}, #{createBy}, sysdate(), #{updateBy}, sysdate()
|
||||
#{channelId}, #{channelCode}, #{productId}, #{priceSetId}, #{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>
|
||||
@@ -31,6 +46,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
where channel_id = #{channelId} and pay_type = #{payType}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteByChannelTypeAndPriceSet">
|
||||
delete from srv_channel_product_map
|
||||
where channel_id = #{channelId}
|
||||
and pay_type = #{payType}
|
||||
and price_set_id = #{priceSetId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteByProductId">
|
||||
delete from srv_channel_product_map where product_id = #{productId}
|
||||
</delete>
|
||||
|
||||
@@ -274,9 +274,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<!-- 渠道下拉:AP=应付公共模板;AR=pay_product 应收(含打单套餐产品) -->
|
||||
<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
|
||||
p.currency, ifnull(ifnull(t.version_no, cur.version_no), p.version_no) as version_no
|
||||
from pay_product p
|
||||
left join pay_product_term t on t.term_id = (
|
||||
select t2.term_id
|
||||
@@ -284,14 +285,18 @@ 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)
|
||||
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
|
||||
<if test='payType == null or "AP".equals(payType)'>
|
||||
and t2.price_set_id is null
|
||||
</if>
|
||||
order by case when t2.status = '1' then 0 when t2.status = '0' then 1 else 2 end,
|
||||
ifnull(t2.version_no, 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}
|
||||
<if test='payType == null or "AP".equals(payType)'>
|
||||
and not (
|
||||
exists (
|
||||
select 1 from pay_product_term t_label
|
||||
@@ -304,6 +309,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
and t_pay.price_set_id is null
|
||||
)
|
||||
)
|
||||
</if>
|
||||
order by p.product_name
|
||||
</select>
|
||||
|
||||
|
||||
@@ -41,6 +41,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<select id="selectLabelPriceSetIdByProduct" resultType="long">
|
||||
select price_set_id
|
||||
from pay_product_term
|
||||
where product_id = #{productId}
|
||||
and price_set_id is not null
|
||||
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,
|
||||
@@ -76,8 +85,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
where t.price_set_id = #{priceSetId}
|
||||
and t.product_id = #{productId}
|
||||
and t.effective_start is not null
|
||||
and t.effective_start <= date(#{bizDate})
|
||||
and (t.effective_end is null or t.effective_end >= date(#{bizDate}))
|
||||
and t.effective_start <= #{bizDate}
|
||||
and (t.effective_end is null or t.effective_end > #{bizDate})
|
||||
order by ifnull(t.version_no, 1) desc, t.term_id desc
|
||||
limit 1
|
||||
</select>
|
||||
@@ -236,6 +245,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
and effective_end >= #{today}
|
||||
</update>
|
||||
|
||||
<update id="clearScheduledEnd">
|
||||
update pay_product_term
|
||||
set effective_end = null,
|
||||
updated_by = #{updateBy},
|
||||
update_time = sysdate()
|
||||
where price_set_id = #{priceSetId}
|
||||
and status = '1'
|
||||
and effective_end is not null
|
||||
</update>
|
||||
|
||||
<delete id="deleteByProductIds">
|
||||
delete from pay_product_term where product_id in
|
||||
<foreach collection="productIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
|
||||
Reference in New Issue
Block a user