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

253 lines
10 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="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" />
</resultMap>
<sql id="selectOmsPayableTicketDetailVo">
select id, ticket_plan_id, payable_bill_id, payment_time, payment_amount, payment_rate, ticket_bill_code,
create_by, create_time, update_by, update_time, remark
from oms_payable_ticket_detail
</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="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 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="listByPayableBillIdList" resultType="com.ruoyi.sip.domain.OmsPayableTicketDetail">
SELECT
t1.*,t2.actual_ticket_time,t2.ticket_status,t2.id as paymentBillId
FROM
oms_payable_ticket_detail t1
LEFT JOIN oms_ticket_bill t2 ON t1.ticket_bill_code = t2.ticket_bill_code
<where>
<if test="list != null and list.size>0">
and t1.payable_bill_id in
<foreach item="item" collection="list" separator="," open="(" close=")" index="">
#{item}
</foreach>
</if>
</where>
</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="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>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="ticketPlanId != null">
#{ticketPlanId},
</if>
<if test="payableBillId != null">
#{payableBillId},
</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>
</trim>
</insert>
<insert id="insertBatch">
insert into oms_payable_ticket_detail (payable_bill_id, ticket_plan_id, payment_time, payment_amount, payment_rate,
ticket_bill_code, create_by, create_time, update_by, update_time, remark) values
<foreach item="item" collection="list" separator=",">
(#{item.payableBillId}, #{item.ticketPlanId}, #{item.paymentTime}, #{item.paymentAmount}, #{item.paymentRate}, #{item.ticketBillCode},
#{item.createBy}, #{item.createTime}, #{item.updateBy}, #{item.updateTime}, #{item.remark})
</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="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>
</trim>
where id = #{id}
</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>
</mapper>