<?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.mmc.iuav.user.dao.fdd.ContractDao">
    <insert id="insertUavContractInfo">
        insert into contract_info (union_id, order_no, contract_no, contract_title)
        values (#{unionId}, #{orderNo}, #{contractNo}, #{contractTitle})
    </insert>
    <update id="updateContractInfo">
        update contract_info
        <set>
            <if test="signStatus != null">
                sign_status = #{signStatus},
            </if>
            <if test="singerTime != null">
                singer_time = #{singerTime},
            </if>
            <if test="aRemark != null">
                a_remark = #{aRemark},
            </if>
            <if test="bRemark != null">
                b_remark = #{bRemark},
            </if>
            <if test="aTransactionId != null">
                a_transaction_id = #{aTransactionId},
            </if>
            <if test="bTransactionId != null">
                b_transaction_id = #{bTransactionId},
            </if>
            <if test="archiveDate != null">
                archive_date = #{archiveDate}
            </if>
        </set>
        where contract_no = #{contractNo}
    </update>
    <delete id="deleteContractInfo">
        delete
        from contract_info
        where order_no = #{orderNo}
    </delete>

    <select id="contractInfoByOrderNo" resultType="com.mmc.iuav.user.entity.fdd.ContractInfoDO">
        select id,
        union_id,
        order_no,
        contract_no,
        contract_title,
        sign_status,
        singer_time,
        a_remark,
        b_remark,
        a_transaction_id,
        b_transaction_id,
        create_time,
        update_time,
        archive_date
        from contract_info
        <where>
            <if test="orderNo != null">
                order_no = #{orderNo}
            </if>
            <if test="contractNo != null">
                contract_no = #{contractNo}
            </if>
        </where>
    </select>
    <select id="listContractInfoByOrderNo" resultType="com.mmc.iuav.user.entity.fdd.ContractInfoDO">
        select id,
        union_id,
        order_no,
        contract_no,
        contract_title,
        sign_status,
        singer_time,
        a_remark,
        b_remark,
        a_transaction_id,
        b_transaction_id,
        create_time,
        update_time,
        archive_date
        from contract_info
        <where>
            <if test="orderNo != null">
                <foreach collection="orderNo" item="orderNo" separator=",">
                    order_no = #{orderNo}
                </foreach>
            </if>
        </where>
    </select>
</mapper>