unis_sip/ruoyi-sip/src/main/resources/mapper/OmsPayableWriteOffMapper.xml

146 lines
8.4 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.sip.mapper.OmsPayableWriteOffMapper">
<resultMap type="com.ruoyi.sip.domain.OmsPayableWriteOff" id="OmsPayableWriteOffResult">
<result property="id" column="id" />
<result property="writeOffCode" column="write_off_code" />
<result property="writeOffType" column="write_off_type" />
<result property="paymentBillCode" column="payment_bill_code" />
<result property="vendorCode" column="vendor_code" />
<result property="writeOffAmount" column="write_off_amount" />
<result property="writeOffAmountWithoutTax" column="write_off_amount_without_tax" />
<result property="writeOffTaxAmount" column="write_off_tax_amount" />
<result property="writeOffTime" column="write_off_time" />
<result property="remark" column="remark" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectOmsPayableWriteOffVo">
select t1.id, t1.write_off_code, t1.write_off_type, t1.payment_bill_code, t1.vendor_code,
t1.write_off_amount, t1.write_off_amount_without_tax, t1.write_off_tax_amount, t1.write_off_time,
t1.remark, t1.create_by, t1.create_time, t1.update_by, t1.update_time,
t2.vendor_name,t3.user_name as create_by_name
from oms_payable_write_off t1
left join oms_vendor_info t2 on t1.vendor_code=t2.vendor_code
left join sys_user t3 on t1.create_by=t3.user_id
</sql>
<select id="selectOmsPayableWriteOffById" parameterType="Long" resultMap="OmsPayableWriteOffResult">
<include refid="selectOmsPayableWriteOffVo"/>
where t1.id = #{id}
</select>
<select id="selectOmsPayableWriteOffList" parameterType="com.ruoyi.sip.domain.OmsPayableWriteOff" resultMap="OmsPayableWriteOffResult">
<include refid="selectOmsPayableWriteOffVo"/>
<where>
<if test="writeOffCode != null and writeOffCode != ''"> and t1.write_off_code = #{writeOffCode}</if>
<if test="writeOffType != null and writeOffType != ''"> and t1.write_off_type = #{writeOffType}</if>
<if test="paymentBillCode != null and paymentBillCode != ''"> and t1.payment_bill_code = #{paymentBillCode}</if>
<if test="paymentBillCodeList != null and paymentBillCodeList.size>0"> and t1.payment_bill_code in
<foreach index="index" collection="paymentBillCodeList" item="paymentBillCode" separator="," open="(" close=")">
#{paymentBillCode}
</foreach>
</if>
<if test="vendorCode != null and vendorCode != ''"> and t1.vendor_code = #{vendorCode}</if>
<if test="payableBillCode != null and payableBillCode != ''"> and t1.id in (
select write_off_id from oms_payable_payment_detail t1 left join oms_payable_bill t2 on t1.payable_bill_id=t2.id where t2.payable_bill_code=#{payableBillCode}
) </if>
<if test="vendorName != null and vendorName != ''"> and t2.vendor_name = #{vendorName}</if>
<if test="(params.beginTime != null and params.beginTime != '') or (params.endTime != null and params.endTime!='')">
<choose>
<when test="(params.beginTime != null and params.beginTime != '') and (params.endTime != null and params.endTime!='')">
and t1.create_time between #{params.beginTime} and #{params.endTime}
</when>
<when test="(params.beginTime != null and params.beginTime != '')">
and t1.create_time <![CDATA[ >= ]]> #{params.beginTime}
</when>
<when test="(params.endTime != null and params.endTime!='')">
and t1.create_time <![CDATA[ <= ]]> #{params.endTime}
</when>
</choose>
</if>
</where>
</select>
<select id="selectMaxCodeByPrefix" resultType="java.lang.Integer">
select ifnull(max(SUBSTR(write_off_code FROM LENGTH(#{prefix}) + 1 FOR 4)), 0)
from oms_payable_write_off
where write_off_code like concat(#{prefix}, '%')
</select>
<select id="listByIds" resultType="com.ruoyi.sip.domain.OmsPayableWriteOff">
<include refid="selectOmsPayableWriteOffVo"/>
where t1.id in
<foreach item="item" index="index" collection="array" open="(" separator="," close=")" >
#{item}
</foreach>
</select>
<insert id="insertOmsPayableWriteOff" parameterType="com.ruoyi.sip.domain.OmsPayableWriteOff" useGeneratedKeys="true" keyProperty="id">
insert into oms_payable_write_off
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="writeOffCode != null">write_off_code,</if>
<if test="writeOffType != null">write_off_type,</if>
<if test="paymentBillCode != null">payment_bill_code,</if>
<if test="vendorCode != null">vendor_code,</if>
<if test="writeOffAmount != null">write_off_amount,</if>
<if test="writeOffAmountWithoutTax != null">write_off_amount_without_tax,</if>
<if test="writeOffTaxAmount != null">write_off_tax_amount,</if>
<if test="writeOffTime != null">write_off_time,</if>
<if test="remark != null">remark,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="writeOffCode != null">#{writeOffCode},</if>
<if test="writeOffType != null">#{writeOffType},</if>
<if test="paymentBillCode != null">#{paymentBillCode},</if>
<if test="vendorCode != null">#{vendorCode},</if>
<if test="writeOffAmount != null">#{writeOffAmount},</if>
<if test="writeOffAmountWithoutTax != null">#{writeOffAmountWithoutTax},</if>
<if test="writeOffTaxAmount != null">#{writeOffTaxAmount},</if>
<if test="writeOffTime != null">#{writeOffTime},</if>
<if test="remark != null">#{remark},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateOmsPayableWriteOff" parameterType="com.ruoyi.sip.domain.OmsPayableWriteOff">
update oms_payable_write_off
<trim prefix="SET" suffixOverrides=",">
<if test="writeOffCode != null">write_off_code = #{writeOffCode},</if>
<if test="writeOffType != null">write_off_type = #{writeOffType},</if>
<if test="paymentBillCode != null">payment_bill_code = #{paymentBillCode},</if>
<if test="vendorCode != null">vendor_code = #{vendorCode},</if>
<if test="writeOffAmount != null">write_off_amount = #{writeOffAmount},</if>
<if test="writeOffAmountWithoutTax != null">write_off_amount_without_tax = #{writeOffAmountWithoutTax},</if>
<if test="writeOffTaxAmount != null">write_off_tax_amount = #{writeOffTaxAmount},</if>
<if test="writeOffTime != null">write_off_time = #{writeOffTime},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteOmsPayableWriteOffById" parameterType="Long">
delete from oms_payable_write_off where id = #{id}
</delete>
<delete id="deleteOmsPayableWriteOffByIds" parameterType="String">
delete from oms_payable_write_off where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>