<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: Icon  
    $Date: 2014-11-6 上午9:26:32  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" xmlns:f="leaf.database.features" alias="t1" baseTable="PRJ_SPECIAL_RETAIL" needAccessControl="false">
    <bm:fields>
        <bm:field name="special_retail_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="SPECIAL_RETAIL_ID" prompt="PRJ_SPECIAL_RETAIL.SPECIAL_RETAIL_ID"/>
        <bm:field name="special_retail_number" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="SPECIAL_RETAIL_NUMBER" prompt="PRJ_SPECIAL_RETAIL.SPECIAL_RETAIL_NUMBER"/>
        <bm:field name="user_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="USER_ID" prompt="PRJ_SPECIAL_RETAIL.USER_ID"/>
        <bm:field name="customer_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CUSTOMER_NAME" prompt="PRJ_SPECIAL_RETAIL.CUSTOMER_NAME"/>
        <bm:field name="years_of_application" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="YEARS_OF_APPLICATION" prompt="PRJ_SPECIAL_RETAIL.YEARS_OF_APPLICATION"/>
        <bm:field name="product_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PRODUCT_NAME" prompt="PRJ_SPECIAL_RETAIL.PRODUCT_NAME"/>
        <bm:field name="brand_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="BRAND_ID" prompt="PRJ_SPECIAL_RETAIL.BRAND_ID"/>
        <bm:field name="series_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="SERIES_ID" prompt="PRJ_SPECIAL_RETAIL.SERIES_ID"/>
        <bm:field name="model_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="MODEL_ID" prompt="PRJ_SPECIAL_RETAIL.MODEL_ID"/>
        <bm:field name="risk_open" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="RISK_OPEN" prompt="PRJ_SPECIAL_RETAIL.RISK_OPEN"/>
        <bm:field name="special_category" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="SPECIAL_CATEGORY" prompt="PRJ_SPECIAL_RETAIL.SPECIAL_CATEGORY"/>
        <bm:field name="status" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="STATUS" prompt="PRJ_SPECIAL_RETAIL.STATUS"/>
        <bm:field name="description" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="DESCRIPTION" prompt="PRJ_SPECIAL_RETAIL.DESCRIPTION"/>
        <bm:field name="special_content" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="SPECIAL_CONTENT" prompt="PRJ_SPECIAL_RETAIL.SPECIAL_CONTENT"/>
        <bm:field name="apply_reason" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="APPLY_REASON" prompt="PRJ_SPECIAL_RETAIL.APPLY_REASON"/>
        <bm:field name="user_name" databaseType="VARCHAR2" datatype="java.lang.String" forInsert="false" forUpdate="false" physicalName="USER_NAME"/>
        <bm:field name="status_des" databaseType="VARCHAR2" datatype="java.lang.String" forInsert="false" forUpdate="false" physicalName="STATUS_DES"/>
        <bm:field name="special_category_des" databaseType="VARCHAR2" datatype="java.lang.String" forInsert="false" forUpdate="false" physicalName="SPECIAL_CATEGORY_DES"/>
        <bm:field name="brand_dis" databaseType="VARCHAR2" datatype="java.lang.String" forInsert="false" forUpdate="false" physicalName="BRAND_DIS"/>
        <bm:field name="model_dis" databaseType="VARCHAR2" datatype="java.lang.String" forInsert="false" forUpdate="false" physicalName="MODEL_DIS"/>
        <bm:field name="series_dis" databaseType="VARCHAR2" datatype="java.lang.String" forInsert="false" forUpdate="false" physicalName="SERIES_DIS"/>
    </bm:fields>
    <bm:features>
        <f:standard-who/>
    </bm:features>
    <bm:primary-key>
        <bm:pk-field name="special_retail_id"/>
    </bm:primary-key>
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
    		SELECT * FROM (
    			SELECT
                    psr.*,
                    (SELECT su.description user_name FROM sys_user su WHERE su.user_id = psr.user_id
                    ) user_name,
                    (select v.description from  hls_car_brands_vl v where v.brand_id=psr.brand_id) brand_dis,
                    (select v.description from  hls_car_model_vl v where v.model_id=psr.model_id) model_dis,
       				(select v.description from  hls_car_series_vl v where v.series_id=psr.series_id) series_dis,
                    (SELECT
                        v.code_value_name
                    FROM
                        sys_code_values_v v
                    WHERE
                        v.code       = 'PRJ801_SPECIAL_RETAIL_STATUS' AND
                        v.code_value = psr.status
                    ) status_des,
                    (SELECT
                        v.code_value_name
                    FROM
                        sys_code_values_v v
                    WHERE
                        v.code       = 'PRJ801_SPECIAL_RETAIL_CATEGORY' AND
                        v.code_value = psr.special_category
                    ) special_category_des
                FROM
                    PRJ_SPECIAL_RETAIL psr) t1 #WHERE_CLAUSE#
    		]]></bm:query-sql>
        </bm:operation>
    </bm:operations>
    <bm:query-fields>
        <bm:query-field name="special_retail_id" queryExpression="t1.special_retail_id = ${@special_retail_id}"/>
    </bm:query-fields>
</bm:model>
