<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: Peter Soong  
    $Date: 2014-06-11 10:25:24
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
    <bm:fields>
        <bm:field name="result_id"/>
        <bm:field name="contract_id"/>
        <bm:field name="contract_number"/>
        <bm:field name="contract_name"/>
        <bm:field name="bp_id_tenant_n"/>
        <bm:field name="lease_organization_n"/>
        <bm:field name="division_n"/>
        <bm:field name="lease_channel_n"/>
        <bm:field name="result_state"/>
        <bm:field name="result_state_n"/>
        <bm:field name="time"/>
    </bm:fields>
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
                SELECT
                    *
                FROM
                    (SELECT
                        t2.result_id,
                        t1.contract_id,
                        t1.contract_number,
                        t1.contract_name,
                        t1.bp_id_tenant_n,
                        t1.lease_organization_n,
                        t1.division_n,
                        t1.lease_channel_n,
                        t2.result_state,
                        to_char(t2.creation_date,'yyyy-mm-dd hh24:mi:ss') time,
                        DECODE(t2.result_state, '1', '成功', '2', '失败', '3','程序异常','未知错误') result_state_n
                    FROM
                        con_contract_lv t1,
                        gh_nc_inter_return t2
                    WHERE
                        t2.document_table = 'CON_CONTRACT' AND
                        t1.contract_id    = t2.document_id
                    ORDER BY
                        t2.creation_date desc,
                        t1.contract_id DESC
                    ) t1 #WHERE_CLAUSE#
            ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:query-fields>
        <bm:query-field field="contract_number" queryOperator="like"/>
        <bm:query-field field="contract_name" queryOperator="like"/>
        <bm:query-field field="bp_id_tenant_n" queryOperator="like"/>
        <bm:query-field field="lease_organization_n" queryOperator="like"/>
        <bm:query-field field="division_n" queryOperator="like"/>
        <bm:query-field field="lease_channel_n" queryOperator="like"/>
    </bm:query-fields>
</bm:model>
