unis_sip/ruoyi-sip/src/main/resources/mapper/sip/OmsPayableTicketDetailMappe...

341 lines
14 KiB
XML
Raw Normal View History

<?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.sip.mapper.OmsPayableTicketDetailMapper">
<resultMap type="com.ruoyi.sip.domain.OmsPayableTicketDetail" id="OmsPayableTicketDetailResult">
<result property="id" column="id" />
<result property="ticketPlanId" column="ticket_plan_id" />
<result property="payableBillId" column="payable_bill_id" />
<result property="payableDetailType" column="payable_detail_type" />
<result property="paymentTime" column="payment_time" />
<result property="paymentAmount" column="payment_amount" />
<result property="paymentRate" column="payment_rate" />
<result property="ticketBillCode" column="ticket_bill_code" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
<result property="actualTicketTime" column="actual_ticket_time" />
<result property="ticketStatus" column="ticket_status" />
<result property="paymentAmountWithoutTax" column="payment_amount_without_tax" />
<result property="writeOffId" column="write_off_id" />
<result property="paymentAmountTax" column="payment_amount_tax" />
</resultMap>
<sql id="selectOmsPayableTicketDetailVo">
select id, ticket_plan_id, payable_bill_id, payable_detail_type, payment_time, payment_amount, payment_rate, ticket_bill_code,
create_by, create_time, update_by, update_time, remark,
payment_amount_without_tax, write_off_id, payment_amount_tax
from oms_payable_ticket_detail t1
</sql>
<select id="selectOmsPayableTicketDetailList" parameterType="com.ruoyi.sip.domain.OmsPayableTicketDetail" resultMap="OmsPayableTicketDetailResult">
<include refid="selectOmsPayableTicketDetailVo"/>
<where>
<if test="ticketPlanId != null">
and ticket_plan_id = #{ticketPlanId}
</if>
<if test="payableBillId != null">
and payable_bill_id = #{payableBillId}
</if>
<if test="payableDetailType != null and payableDetailType != ''">
and payable_detail_type = #{payableDetailType}
</if>
<if test="paymentTime != null">
and payment_time = #{paymentTime}
</if>
<if test="paymentAmount != null">
and payment_amount = #{paymentAmount}
</if>
<if test="paymentRate != null">
and payment_rate = #{paymentRate}
</if>
<if test="ticketBillCode != null and ticketBillCode != ''">
and ticket_bill_code = #{ticketBillCode}
</if>
<if test="createBy != null and createBy != ''">
and create_by = #{createBy}
</if>
<if test="createTime != null">
and create_time = #{createTime}
</if>
<if test="updateBy != null and updateBy != ''">
and update_by = #{updateBy}
</if>
<if test="updateTime != null">
and update_time = #{updateTime}
</if>
<if test="remark != null and remark != ''">
and remark like concat('%', #{remark}, '%')
</if>
</where>
</select>
<select id="selectByTicketPlanIds" resultType="com.ruoyi.sip.domain.OmsPayableTicketDetail">
<include refid="selectOmsPayableTicketDetailVo"/>
<where>
<if test="list != null and list.size > 0">
and ticket_plan_id in
<foreach item="item" collection="list" separator="," open="(" close=")" index="">
#{item}
</foreach>
</if>
</where>
</select>
<select id="selectOmsPayableTicketDetailById" parameterType="Long" resultMap="OmsPayableTicketDetailResult">
<include refid="selectOmsPayableTicketDetailVo"/>
where id = #{id}
</select>
<select id="listByTickerCode" resultType="com.ruoyi.sip.domain.dto.PaymentBillPayableDetailDTO">
select t1.payment_amount, t2.payable_bill_code,t2.product_type, t4.project_name, t4.project_code, t2.total_price_with_tax
from (SELECT sum(payment_amount) payment_amount,
payable_bill_id
FROM oms_payable_ticket_detail
WHERE write_off_id is null and ticket_bill_code in
<foreach item="item" collection="list" separator="," open="(" close=")" index="">
#{item}
</foreach>
group by payable_bill_id) t1
left join oms_payable_bill t2 on t1.payable_bill_id = t2.id
left join project_order_info t3 on t2.order_code = t3.order_code
left join project_info t4 on t3.project_id = t4.id
</select>
<select id="list" resultType="com.ruoyi.sip.domain.OmsPayableTicketDetail">
SELECT
t1.*,t2.actual_ticket_time,t2.vendor_ticket_time,t2.ticket_status,t2.id as ticketBillId
FROM
oms_payable_ticket_detail t1
LEFT JOIN oms_ticket_bill t2 ON t1.ticket_bill_code = t2.ticket_bill_code
<where>
<if test="payableBillIdList != null and payableBillIdList.size>0">
and t1.payable_bill_id in
<foreach item="item" collection="payableBillIdList" separator="," open="(" close=")" index="">
#{item}
</foreach>
</if>
<if test="writeOffIdList != null and writeOffIdList.size>0">
and t1.write_off_id in
<foreach item="item" collection="writeOffIdList" separator="," open="(" close=")" index="">
#{item}
</foreach>
</if>
<if test="payableDetailType != null and payableDetailType != ''">
and t1.payable_detail_type = #{payableDetailType}
</if>
</where>
</select>
<select id="listPayableByWriteOffId" resultType="com.ruoyi.sip.domain.dto.PaymentBillPayableDetailDTO">
select t1.payment_amount, t2.payable_bill_code,t2.product_type,t2.create_time,t5.vendor_name, t4.project_name, t4.project_code, t2.total_price_with_tax
from (SELECT sum(payment_amount) payment_amount,
payable_bill_id
FROM oms_payable_ticket_detail
WHERE write_off_id in
<foreach item="item" collection="list" separator="," open="(" close=")" index="">
#{item}
</foreach>
group by payable_bill_id) t1
left join oms_payable_bill t2 on t1.payable_bill_id = t2.id
left join project_order_info t3 on t2.order_code = t3.order_code
left join project_info t4 on t3.project_id = t4.id
left join oms_vendor_info t5 on t2.vendor_code = t5.vendor_code
</select>
<insert id="insertOmsPayableTicketDetail" parameterType="com.ruoyi.sip.domain.OmsPayableTicketDetail" useGeneratedKeys="true" keyProperty="id">
insert into oms_payable_ticket_detail
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="ticketPlanId != null">
ticket_plan_id,
</if>
<if test="payableBillId != null">
payable_bill_id,
</if>
<if test="payableDetailType != null and payableDetailType != ''">
payable_detail_type,
</if>
<if test="paymentTime != null">
payment_time,
</if>
<if test="paymentAmount != null">
payment_amount,
</if>
<if test="paymentRate != null">
payment_rate,
</if>
<if test="ticketBillCode != null and ticketBillCode != ''">
ticket_bill_code,
</if>
<if test="createBy != null and createBy != ''">
create_by,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateBy != null and updateBy != ''">
update_by,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="remark != null and remark != ''">
remark,
</if>
<if test="paymentAmountWithoutTax != null">
payment_amount_without_tax,
</if>
<if test="writeOffId != null">
write_off_id,
</if>
<if test="paymentAmountTax != null">
payment_amount_tax,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="ticketPlanId != null">
#{ticketPlanId},
</if>
<if test="payableBillId != null">
#{payableBillId},
</if>
<if test="payableDetailType != null and payableDetailType != ''">
#{payableDetailType},
</if>
<if test="paymentTime != null">
#{paymentTime},
</if>
<if test="paymentAmount != null">
#{paymentAmount},
</if>
<if test="paymentRate != null">
#{paymentRate},
</if>
<if test="ticketBillCode != null and ticketBillCode != ''">
#{ticketBillCode},
</if>
<if test="createBy != null and createBy != ''">
#{createBy},
</if>
<if test="createTime != null">
#{createTime},
</if>
<if test="updateBy != null and updateBy != ''">
#{updateBy},
</if>
<if test="updateTime != null">
#{updateTime},
</if>
<if test="remark != null and remark != ''">
#{remark},
</if>
<if test="paymentAmountWithoutTax != null">
#{paymentAmountWithoutTax},
</if>
<if test="writeOffId != null">
#{writeOffId},
</if>
<if test="paymentAmountTax != null">
#{paymentAmountTax},
</if>
</trim>
</insert>
<insert id="insertBatch">
insert into oms_payable_ticket_detail (payable_bill_id, ticket_plan_id, payable_detail_type, payment_time, payment_amount, payment_rate,
ticket_bill_code, create_by, create_time, update_by, update_time, remark,
payment_amount_without_tax, write_off_id, payment_amount_tax) values
<foreach item="item" collection="list" separator=",">
(#{item.payableBillId}, #{item.ticketPlanId}, #{item.payableDetailType}, #{item.paymentTime}, #{item.paymentAmount}, #{item.paymentRate}, #{item.ticketBillCode},
#{item.createBy}, #{item.createTime}, #{item.updateBy}, #{item.updateTime}, #{item.remark},
#{item.paymentAmountWithoutTax}, #{item.writeOffId}, #{item.paymentAmountTax})
</foreach>
</insert>
<update id="updateOmsPayableTicketDetail" parameterType="com.ruoyi.sip.domain.OmsPayableTicketDetail">
update oms_payable_ticket_detail
<trim prefix="SET" suffixOverrides=",">
<if test="ticketPlanId != null">
ticket_plan_id = #{ticketPlanId},
</if>
<if test="payableBillId != null">
payable_bill_id = #{payableBillId},
</if>
<if test="payableDetailType != null and payableDetailType != ''">
payable_detail_type = #{payableDetailType},
</if>
<if test="paymentTime != null">
payment_time = #{paymentTime},
</if>
<if test="paymentAmount != null">
payment_amount = #{paymentAmount},
</if>
<if test="paymentRate != null">
payment_rate = #{paymentRate},
</if>
<if test="ticketBillCode != null and ticketBillCode != ''">
ticket_bill_code = #{ticketBillCode},
</if>
<if test="createBy != null and createBy != ''">
create_by = #{createBy},
</if>
<if test="createTime != null">
create_time = #{createTime},
</if>
<if test="updateBy != null and updateBy != ''">
update_by = #{updateBy},
</if>
<if test="updateTime != null">
update_time = #{updateTime},
</if>
<if test="remark != null and remark != ''">
remark = #{remark},
</if>
<if test="paymentAmountWithoutTax != null">
payment_amount_without_tax = #{paymentAmountWithoutTax},
</if>
<if test="writeOffId != null">
write_off_id = #{writeOffId},
</if>
<if test="paymentAmountTax != null">
payment_amount_tax = #{paymentAmountTax},
</if>
</trim>
where id = #{id}
</update>
<update id="updateBatch">
<foreach item="item" collection="list">
update oms_payable_ticket_detail
<trim prefix="SET" suffixOverrides=",">
<if test="item.writeOffId != null">
write_off_id = #{item.writeOffId},
</if>
</trim>
where id=#{item.id}
</foreach>
</update>
<delete id="deleteOmsPayableTicketDetailById" parameterType="Long">
delete from oms_payable_ticket_detail where id = #{id}
</delete>
<delete id="deleteOmsPayableTicketDetailByIds" parameterType="String">
delete from oms_payable_ticket_detail where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<delete id="clearRelationPayable">
delete from oms_payable_ticket_detail where ticket_bill_code = #{code}
</delete>
<delete id="deleteByWriteOffIds">
DELETE FROM oms_payable_ticket_detail WHERE write_off_id IN
<foreach collection="array" item="item" open="(" separator="," close=")" index="">
#{item}
</foreach>
</delete>
</mapper>