<?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.hzya.frame.seeyon.cbs8.dao.impl.AgentPaymentDaoImpl">
    <resultMap id="get-AgentPaymentEntity-result" type="com.hzya.frame.seeyon.cbs8.entity.AgentPaymentEntity">
        <result property="oaId" column="oaId" />
        <result property="title" column="title" />
        <result property="finishedflag" column="finishedflag" />
        <result property="referenceNum" column="referenceNum" />
        <result property="busType" column="busType" />
        <result property="amount" column="amount" />
        <result property="currency" column="currency" />
        <result property="payAccount" column="payAccount" />
        <result property="purpose" column="purpose" />
        <result property="tableName" column="tableName" />
        <result property="billName" column="billName" />
        <result property="applyCode" column="applyCode" />
        <result property="payResult" column="payResult" />
    </resultMap>

    <sql id="AgentPaymentEntity_Base_Column_List">
        oaId,
        tableName,
        finishedflag,
        title,
        billName,
        referenceNum,
        busType,
        amount,
        currency,
        payAccount,
        applyCode,
        payResult,
        purpose
    </sql>


    <!-- 采用==查询 -->
    <select id="entity_list_base" resultMap="get-AgentPaymentEntity-result" parameterType="com.hzya.frame.seeyon.cbs8.entity.AgentPaymentEntity">
        select
        <include refid="AgentPaymentEntity_Base_Column_List"/>
       from (
        SELECT
        formmain_0224.id AS oaId,
        'formmain_0224' as tableName,
        formmain_0224.finishedflag,
        COL_SUMMARY.SUBJECT AS title,
        '工资表' AS billName,
        formmain_0224.field0002 AS referenceNum,
        '203' AS busType,
        formmain_0224.field0020 AS amount,
        '10' AS currency,
        '755915707610112' AS payAccount,
        formmain_0224.field0043 AS applyCode,
        formmain_0224.field0046 AS payResult,
        '工资' AS purpose
        FROM
        formmain_0224
        LEFT JOIN COL_SUMMARY ON COL_SUMMARY.FORM_RECORDID = formmain_0224.id
        )formmain_0224
        <trim prefix="where" prefixOverrides="and">
            <if test="referenceNum != null and referenceNum !='' "> formmain_0224.referenceNum = #{referenceNum} </if>
            <if test="busType != null and busType !='' "> and formmain_0224.busType = #{busType} </if>
            <if test="amount != null and amount !='' ">and formmain_0224.amount = #{amount}  </if>
            <if test="currency != null and currency !='' "> and formmain_0224.currency = #{currency}  </if>
            <if test="payAccount != null and payAccount !='' ">and formmain_0224.payAccount = #{payAccount} </if>
            <if test="applyCode != null and applyCode !='' ">and formmain_0224.applyCode = #{applyCode} </if>
            <if test="payResult != null and payResult !='' ">and formmain_0224.payResult = #{payResult} </if>
            <if test="purpose != null and purpose !='' "> and formmain_0224.purpose = #{purpose}  </if>
            <if test="tableName != null and tableName !='' "> and formmain_0224.tableName = #{tableName}  </if>
            <if test="oaId != null and oaId !='' ">and formmain_0224.oaId = #{oaId} </if>
            <if test="title != null and title !='' "> and  formmain_0224.title = #{title}  </if>
            <if test="billName != null and billName !='' "> and formmain_0224.billName = #{billName} </if>
            <if test="finishedflag != null and finishedflag !='' "> and formmain_0224.finishedflag = #{finishedflag}  </if>
        </trim>
    </select>

    <select id="entity_list_base_unpaid" resultMap="get-AgentPaymentEntity-result" parameterType="com.hzya.frame.seeyon.cbs8.entity.AgentPaymentEntity">
        select
        <include refid="AgentPaymentEntity_Base_Column_List"/>
        from (
        SELECT
        formmain_0224.id AS oaId,
        'formmain_0224' as tableName,
        formmain_0224.finishedflag,
        COL_SUMMARY.SUBJECT AS title,
        '工资表' AS billName,
        formmain_0224.field0002 AS referenceNum,
        '203' AS busType,
        formmain_0224.field0020 AS amount,
        '10' AS currency,
        '755915707610112' AS payAccount,
        formmain_0224.field0043 AS applyCode,
        formmain_0224.field0046 AS payResult,
        '工资' AS purpose
        FROM
        formmain_0224
        LEFT JOIN COL_SUMMARY ON COL_SUMMARY.FORM_RECORDID = formmain_0224.id
        )formmain_0224
        <trim prefix="where" prefixOverrides="and">
            <if test="referenceNum != null and referenceNum !='' "> formmain_0224.referenceNum = #{referenceNum} </if>
            <if test="busType != null and busType !='' "> and formmain_0224.busType = #{busType} </if>
            <if test="amount != null and amount !='' ">and formmain_0224.amount = #{amount}  </if>
            <if test="currency != null and currency !='' "> and formmain_0224.currency = #{currency}  </if>
            <if test="payAccount != null and payAccount !='' ">and formmain_0224.payAccount = #{payAccount} </if>
            <if test="applyCode != null and applyCode !='' ">and formmain_0224.applyCode = #{applyCode} </if>
            <if test="purpose != null and purpose !='' "> and formmain_0224.purpose = #{purpose}  </if>
            <if test="tableName != null and tableName !='' "> and formmain_0224.tableName = #{tableName}  </if>
            <if test="oaId != null and oaId !='' ">and formmain_0224.oaId = #{oaId} </if>
            <if test="title != null and title !='' "> and  formmain_0224.title = #{title}  </if>
            <if test="billName != null and billName !='' "> and formmain_0224.billName = #{billName} </if>
            <if test="finishedflag != null and finishedflag !='' "> and formmain_0224.finishedflag = #{finishedflag}  </if>
        </trim>
        and formmain_0224.applyCode is null
        and formmain_0224.payResult is null
    </select>


    <update id="entity_update" parameterType="com.hzya.frame.seeyon.cbs8.entity.AgentPaymentEntity">
        update formmain_0224 set
        <trim suffix="" suffixOverrides=",">
            <if test="applyCode != null and applyCode !='' ">field0043 =#{applyCode},</if>
            <if test="payResult != null and payResult !='' ">field0046 =#{payResult}</if>
        </trim>
        where id = #{oaId}
    </update>
</mapper>
