Files
BMS/bms-back/ruoyi-system/src/main/resources/mapper/price/PrcCustomerPriceSetMapper.xml
T
2026-09-07 14:42:27 +08:00

131 lines
6.3 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.ruoyi.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="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="created_at" />
<result property="updateBy" column="updated_by" />
<result property="updateTime" column="updated_at" />
</resultMap>
<sql id="selectPrcCustomerPriceSetVo">
select customer_priceset_id, price_set_id, customer_id, customer_name, bind_priority,
pr_begindate, pr_enddate, price_set_note,
created_by, created_at, updated_by, updated_at
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="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="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 &lt;&gt; #{priceSetId}
</if>
and c.pr_begindate &lt;= ifnull(#{endDate}, '9999-12-31')
and ifnull(c.pr_enddate, '9999-12-31') &gt;= #{beginDate}
</select>
<select id="selectEffectiveByCustomer" resultMap="PrcCustomerPriceSetResult">
select c.customer_priceset_id, c.price_set_id, c.customer_id, c.customer_name, c.bind_priority,
c.pr_begindate, c.pr_enddate, c.price_set_note,
c.created_by, c.created_at, c.updated_by, c.updated_at
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'
and c.pr_begindate &lt;= #{bizDate}
and ifnull(c.pr_enddate, '9999-12-31') &gt;= #{bizDate}
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="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>
created_at
) values (
<if test="priceSetId != null">#{priceSetId},</if>
<if test="customerId != null">#{customerId},</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="customerId != null">customer_id = #{customerId},</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>
updated_at = 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>