<?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.paybill.dao.impl.PayBillDaoImpl">
    <resultMap id="get-PayBillEntity-result" type="com.hzya.frame.seeyon.paybill.entity.PayBillEntity" >
        <result property="id" column="id" jdbcType="VARCHAR"/>
        <result property="pkOrg" column="pk_org" jdbcType="VARCHAR"/>
        <result property="billDate" column="bill_date" jdbcType="VARCHAR"/>
        <result property="primalMoney" column="primal_money" jdbcType="VARCHAR"/>
        <result property="pkOppaccount" column="pk_oppaccount" jdbcType="VARCHAR"/>
        <result property="pkSupplier" column="pk_supplier" jdbcType="VARCHAR"/>
        <result property="tableName" column="table_name" jdbcType="VARCHAR"/>
        <result property="fieldName" column="field_name" jdbcType="VARCHAR"/>

    </resultMap>

    <!--工程项目查询-->
    <select id="PayBillEntity_list_base" resultMap="get-PayBillEntity-result" parameterType="com.hzya.frame.seeyon.paybill.entity.PayBillEntity">
       SELECT
        body.id as id,
        field0070 AS bill_date,
        field0057 AS primal_money,
        field0019 AS pk_oppaccount,
        field0082 AS pk_supplier,
        'formson_0222' as table_name,
        'field0084' as field_name
        FROM formmain_0093 main
        LEFT JOIN formson_0222 body ON main.id = body.formmain_id
        WHERE field0070 IS NOT null and field0084 is null
        union all
        SELECT
        body.id as id,
        field0073 AS bill_date,
        field0031 AS primal_money,
        field0042 AS pk_oppaccount,
        field0077 AS pk_supplier,
        'formson_0210' as table_name,
        'field0078' as field_name
        FROM formmain_0209 main
        LEFT JOIN formson_0210 body ON main.id = body.formmain_id
        WHERE field0073 IS NOT null and field0078 is null
        union all
        SELECT
        body.id as id,
        field0053 AS bill_date,
        field0041 AS primal_money,
        field0024 AS pk_oppaccount,
        field0057 AS pk_supplier,
        'formson_0223' as table_name,
        'field0058' as field_name
        FROM formmain_0094 main
        LEFT JOIN formson_0223 body ON main.id = body.formmain_id
        WHERE field0053 IS NOT NULL and field0058 is null
    </select>

    <!--通过主键修改方法-->
    <update id="PayBillEntity_update" parameterType = "java.util.Map" >
        update ${tableName} set ${fieldName} = #{state} where id = #{id}
    </update>


</mapper>

