170 lines
8.2 KiB
XML
170 lines
8.2 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.PrcCustomerPriceSetMapper">
|
|
|
|
<resultMap type="PrcCustomerPriceSet" id="PrcCustomerPriceSetResult">
|
|
<id property="customerPricesetId" column="customer_priceset_id" />
|
|
<result property="priceSetId" column="price_set_id" />
|
|
<result property="customerId" column="customer_id" />
|
|
<result property="customerCode" column="customer_code" />
|
|
<result property="customerName" column="customer_name" />
|
|
<result property="bindPriority" column="bind_priority" />
|
|
<result property="prBegindate" column="pr_begindate" />
|
|
<result property="prEnddate" column="pr_enddate" />
|
|
<result property="priceSetNote" column="price_set_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="selectPrcCustomerPriceSetVo">
|
|
select customer_priceset_id, price_set_id, customer_id, customer_code, customer_name, bind_priority,
|
|
pr_begindate, pr_enddate, price_set_note,
|
|
created_by, create_time, updated_by, update_time
|
|
from prc_customer_price_set
|
|
</sql>
|
|
|
|
<select id="selectPrcCustomerPriceSetById" parameterType="Long" resultMap="PrcCustomerPriceSetResult">
|
|
<include refid="selectPrcCustomerPriceSetVo"/>
|
|
where customer_priceset_id = #{customerPricesetId}
|
|
</select>
|
|
|
|
<select id="selectPrcCustomerPriceSetList" parameterType="PrcCustomerPriceSet" resultMap="PrcCustomerPriceSetResult">
|
|
<include refid="selectPrcCustomerPriceSetVo"/>
|
|
<where>
|
|
<if test="priceSetId != null">
|
|
AND price_set_id = #{priceSetId}
|
|
</if>
|
|
<if test="customerId != null">
|
|
AND customer_id = #{customerId}
|
|
</if>
|
|
<if test="customerCode != null and customerCode != ''">
|
|
AND customer_code = #{customerCode}
|
|
</if>
|
|
<if test="customerName != null and customerName != ''">
|
|
AND customer_name like concat('%', #{customerName}, '%')
|
|
</if>
|
|
</where>
|
|
order by bind_priority asc, customer_priceset_id asc
|
|
</select>
|
|
|
|
<select id="countByPriceSetId" parameterType="Long" resultType="int">
|
|
select count(1) from prc_customer_price_set where price_set_id = #{priceSetId}
|
|
</select>
|
|
|
|
<select id="countByCustomerId" resultType="int">
|
|
select count(1) from prc_customer_price_set
|
|
where customer_id = #{customerId}
|
|
<if test="excludeId != null">
|
|
AND customer_priceset_id <> #{excludeId}
|
|
</if>
|
|
<if test="excludePriceSetId != null">
|
|
AND price_set_id <> #{excludePriceSetId}
|
|
</if>
|
|
</select>
|
|
|
|
<select id="countByCustomerCode" resultType="int">
|
|
select count(1) from prc_customer_price_set
|
|
where customer_code = #{customerCode}
|
|
<if test="excludeId != null">
|
|
AND customer_priceset_id <> #{excludeId}
|
|
</if>
|
|
<if test="excludePriceSetId != null">
|
|
AND price_set_id <> #{excludePriceSetId}
|
|
</if>
|
|
</select>
|
|
|
|
<select id="countOverlap" resultType="int">
|
|
select count(1)
|
|
from prc_customer_price_set c
|
|
inner join prc_price_set s on s.price_set_id = c.price_set_id
|
|
where c.customer_id = #{customerId}
|
|
and s.status = 'E'
|
|
<if test="priceSetId != null">
|
|
AND c.price_set_id <> #{priceSetId}
|
|
</if>
|
|
and c.pr_begindate <= ifnull(#{endDate}, '9999-12-31')
|
|
and ifnull(c.pr_enddate, '9999-12-31') >= #{beginDate}
|
|
</select>
|
|
|
|
<select id="selectEffectiveByCustomer" resultMap="PrcCustomerPriceSetResult">
|
|
select c.customer_priceset_id, c.price_set_id, c.customer_id, c.customer_code, c.customer_name, c.bind_priority,
|
|
c.pr_begindate, c.pr_enddate, c.price_set_note,
|
|
c.created_by, c.create_time, c.updated_by, c.update_time
|
|
from prc_customer_price_set c
|
|
inner join prc_price_set s on s.price_set_id = c.price_set_id
|
|
where c.customer_id = #{customerId}
|
|
and ifnull(s.status, 'D') <> 'S'
|
|
order by c.bind_priority asc, c.pr_begindate desc, c.customer_priceset_id asc
|
|
</select>
|
|
|
|
<select id="selectEffectiveByCustomerCode" resultMap="PrcCustomerPriceSetResult">
|
|
select c.customer_priceset_id, c.price_set_id, c.customer_id, c.customer_code, c.customer_name, c.bind_priority,
|
|
c.pr_begindate, c.pr_enddate, c.price_set_note,
|
|
c.created_by, c.create_time, c.updated_by, c.update_time
|
|
from prc_customer_price_set c
|
|
inner join prc_price_set s on s.price_set_id = c.price_set_id
|
|
where c.customer_code = #{customerCode}
|
|
and ifnull(s.status, 'D') <> 'S'
|
|
order by c.bind_priority asc, c.pr_begindate desc, c.customer_priceset_id asc
|
|
</select>
|
|
|
|
<insert id="insertPrcCustomerPriceSet" parameterType="PrcCustomerPriceSet" useGeneratedKeys="true" keyProperty="customerPricesetId">
|
|
insert into prc_customer_price_set (
|
|
<if test="priceSetId != null">price_set_id,</if>
|
|
<if test="customerId != null">customer_id,</if>
|
|
<if test="customerCode != null and customerCode != ''">customer_code,</if>
|
|
<if test="customerName != null">customer_name,</if>
|
|
<if test="bindPriority != null">bind_priority,</if>
|
|
<if test="prBegindate != null">pr_begindate,</if>
|
|
<if test="prEnddate != null">pr_enddate,</if>
|
|
<if test="priceSetNote != null">price_set_note,</if>
|
|
<if test="createBy != null and createBy != ''">created_by,</if>
|
|
create_time
|
|
) values (
|
|
<if test="priceSetId != null">#{priceSetId},</if>
|
|
<if test="customerId != null">#{customerId},</if>
|
|
<if test="customerCode != null and customerCode != ''">#{customerCode},</if>
|
|
<if test="customerName != null">#{customerName},</if>
|
|
<if test="bindPriority != null">#{bindPriority},</if>
|
|
<if test="prBegindate != null">#{prBegindate},</if>
|
|
<if test="prEnddate != null">#{prEnddate},</if>
|
|
<if test="priceSetNote != null">#{priceSetNote},</if>
|
|
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
|
sysdate()
|
|
)
|
|
</insert>
|
|
|
|
<update id="updatePrcCustomerPriceSet" parameterType="PrcCustomerPriceSet">
|
|
update prc_customer_price_set
|
|
<set>
|
|
<if test="priceSetId != null">price_set_id = #{priceSetId},</if>
|
|
<if test="customerId != null">customer_id = #{customerId},</if>
|
|
<if test="customerCode != null">customer_code = #{customerCode},</if>
|
|
<if test="customerName != null">customer_name = #{customerName},</if>
|
|
<if test="bindPriority != null">bind_priority = #{bindPriority},</if>
|
|
<if test="prBegindate != null">pr_begindate = #{prBegindate},</if>
|
|
pr_enddate = #{prEnddate},
|
|
<if test="priceSetNote != null">price_set_note = #{priceSetNote},</if>
|
|
<if test="updateBy != null and updateBy != ''">updated_by = #{updateBy},</if>
|
|
update_time = sysdate()
|
|
</set>
|
|
where customer_priceset_id = #{customerPricesetId}
|
|
</update>
|
|
|
|
<delete id="deletePrcCustomerPriceSetByIds" parameterType="Long">
|
|
delete from prc_customer_price_set where customer_priceset_id in
|
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</delete>
|
|
|
|
<delete id="deletePrcCustomerPriceSetByPriceSetId" parameterType="Long">
|
|
delete from prc_customer_price_set where price_set_id = #{priceSetId}
|
|
</delete>
|
|
|
|
</mapper>
|