<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" needAccessControl="false">
    <bm:fields>
        <bm:field name="transaction_id"/>
        <bm:field name="transaction_date" databaseType="DATE" datatype="java.util.Date"/>
        <bm:field name="transaction_num"/>
        <bm:field name="credit_card_amount" databaseType="NUMBER" datatype="java.lang.Double"/>
        <bm:field name="handling_fee_amount" databaseType="NUMBER" datatype="java.lang.Double"/>
        <bm:field name="transaction_amount" databaseType="NUMBER" datatype="java.lang.Double"/>
        <bm:field name="contract_number"/>
        <bm:field name="bp_bank_account_num"/>
        <bm:field name="terminal_number"/>
        <bm:field name="import_date" databaseType="DATE" datatype="java.util.Date"/>
        <bm:field name="transaction_type"/>

        <bm:field name="transaction_type_n"/>

        <bm:field name="administrant"/>
        <bm:field name="extra_nam"/>
    </bm:fields>
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
            select * from (
      SELECT t.transaction_id,
       to_date(replace(t.zuonr, 'POS'), 'yyyymmdd') import_date, ---导入日期
       t.transaction_date, ---交易日期
       t.transaction_num, ---现金事务编码
       t.credit_card_amount, ---刷卡金额
       t.handling_fee_amount, ---手续费
       t.transaction_amount, ---到账金额
       cc.contract_number, ---会员号（合同号）
       t.bp_bank_account_num, ---对方银行账号
       t.terminal_number, ---POS机编号
       t.transaction_category,
       t.transaction_type,
       (select v.code_value_name
          from sys_code_values_v v
         where v.code = 'CSH511_TRANSACTION_TYPE'
           and v.code_value = t.transaction_type) transaction_type_n,
       (SELECT m.administrant
          FROM csh_terminal_manager m
         where m.terminal_number = t.terminal_number
           and m.enabled_flag = 'Y'
           and rownum = 1) administrant, ---所属人
       (SELECT n.extra_nam
                 FROM csh_terminal_manager m, hls_bp_master n
                where m.agent_id = n.bp_id
                  and m.terminal_number = t.terminal_number
                  and m.enabled_flag = 'Y'
                  and rownum = 1) extra_nam, ---代理商
       source_doc_id
  FROM csh_transaction t, con_contract cc
 where t.source_doc_id = cc.contract_id(+)
      --  and t.transaction_type = 'RECEIPT'
      --  and cc.data_class = 'NORMAL'
   and t.zuonr like 'POS________'
   and t.transaction_num is not null
   and t.transaction_type = 'RECEIPT'
) t1

                #WHERE_CLAUSE#
                #ORDER_BY_CLAUSE#
                ]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:query-fields>
        <bm:query-field field="transaction_num" queryOperator="like"/>
        <bm:query-field field="contract_number" queryOperator="like"/>
        <bm:query-field field="bp_bank_account_num" queryOperator="like"/>
        <bm:query-field field="terminal_number" queryOperator="like"/>
        <bm:query-field field="administrant" queryOperator="like"/>
        <bm:query-field field="extra_nam" queryOperator="like"/>
        <bm:query-field name="import_date_from" queryExpression="t1.import_date &gt;= to_date(${@import_date_from},&apos;yyyy-mm-dd&apos;)"/>
        <bm:query-field name="import_date_to" queryExpression="t1.import_date &lt;= to_date(${@import_date_to},&apos;yyyy-mm-dd&apos;)"/>
        <bm:query-field name="transaction_date_from" queryExpression="t1.transaction_date &gt;= to_date(${@transaction_date_from},&apos;yyyy-mm-dd&apos;)"/>
        <bm:query-field name="transaction_date_to" queryExpression="t1.transaction_date &lt;= to_date(${@transaction_date_to},&apos;yyyy-mm-dd&apos;)"/>
        <bm:query-field name="credit_card_amount_from" queryExpression="t1.credit_card_amount &gt;= ${@credit_card_amount_from}"/>
        <bm:query-field name="credit_card_amount_to" queryExpression="t1.credit_card_amount &lt;= ${@credit_card_amount_to}"/>

    </bm:query-fields>
</bm:model>
