<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc="权限功能表查询">
	<query id="CoreOrderBuyer.QUERYTYPE" desc="用途类型(订货单位/结算单位/最终用户/收货单位)">
		<![CDATA[
				 SELECT C.CUSTOMER_NO, C.SALE_ORG, C.CUSTM_USE
					    FROM SLM_BASE_CUSTOMER A, SLM_BASE_CUSTM_RIGHT B, SLM_BASE_CUSTM_USE C
					 	WHERE A.CUSTOMER_NO IN (SELECT CUSTOMER_NO
					                           FROM SLM_BASE_CUSTM_USE
					                          WHERE SALE_ORG = ?  AND CUSTM_USE = ?)
					   AND A.CUSTOMER_NO = B.CUSTOMER_NO
					   AND B.SALE_ORG = ?
					   AND A.CUSTOMER_NO = C.CUSTOMER_NO
					   AND C.CUSTM_USE = ?
					   AND C.SALE_ORG = B.SALE_ORG
		]]>
	</query>
	<query id="CoreOrderBuyer.doQueryCustomer" desc="查询(订货单位/结算单位/最终用户/收货单位)">
		<![CDATA[
				 SELECT  A.CUSTOMER_NO,A.CUSTOMER_NM, C.SALE_ORG, C.CUSTM_USE
					    FROM SLM_BASE_CUSTOMER A, SLM_BASE_CUSTM_RIGHT B, SLM_BASE_CUSTM_USE C
					 	WHERE A.CUSTOMER_NO IN (SELECT CUSTOMER_NO
					                           FROM SLM_BASE_CUSTM_USE
					                          WHERE SALE_ORG = ?  AND CUSTM_USE = ?)
					   AND A.CUSTOMER_NO = B.CUSTOMER_NO
					   AND B.SALE_ORG = ?
					   AND A.CUSTOMER_NO = C.CUSTOMER_NO
					   AND C.CUSTM_USE = ?
					   AND C.SALE_ORG = B.SALE_ORG
		]]>
	</query>
	<query id="CoreOrderBuyer.doQueryBuyer" desc="用途类型(最终用户/收货单位)">
		<![CDATA[ 
				 
 SELECT DISTINCT A.CUSTOMER_NO, A.CUSTOMER_NM

  FROM SLM_BASE_CUSTOMER    A,
       SLM_BASE_CUSTM_RIGHT B,
       SLM_BASE_CUSTM_USE   C,
       SLM_BASE_RECEIV_UNIT D

 WHERE A.CUSTOMER_NO = B.CUSTOMER_NO
   AND A.CUSTOMER_NO = C.CUSTOMER_NO
   AND A.CUSTOMER_NO = D.CUSTOMER_NO
   AND C.CUSTM_USE = ?
   AND A.VALIDFLAG = '1'
   AND B.VALIDFLAG = '1'
   AND C.VALIDFLAG = '1'
   AND D.VALIDFLAG = '1'
				 
		]]>
	</query>

	<query id="CoreOrderBuyer.doQueryUserInfo" desc="用户信息">
		<![CDATA[
			SELECT D.DEPARTNAME DEPTNAME,T.*
			FROM CORE_APP_USER T
			LEFT JOIN CORE_APP_DEPARTMENT D ON T.DEPTID = D.DEPARTID
			WHERE 1 = 1
			AND T.DEPTID LIKE '002001042%' OR T.DEPTID LIKE '002023001%'
		]]>
	</query>
		<query id="CoreOrderBuyer.doQueryBuyers" desc="用途类型(订货单位/结算单位)">
		<![CDATA[
	 
        SELECT DISTINCT A.CUSTOMER_NO,
                A.CUSTOMER_NM,
                A.BIGAREA,
                A.MARKET_SYS,
                (SELECT BASENAME
                      FROM COM_BASE_INFO
                     WHERE BASECODE = A.BIGAREA)  BIGAREANO,
                 (SELECT BASENAME
                      FROM COM_BASE_INFO
                     WHERE BASECODE = A.MARKET_SYS)  MARKET_SYS_DESC,
                A.ABRVITION,
                A.ORG,
                A.PY,
                D.CHN_FL,
                D.CUSTM_CTGRY,
                (SELECT BASENAME
                      FROM COM_BASE_INFO
                     WHERE BASECODE = D.CUSTM_CTGRY)  CUSTM_CTGRYNAME,
                D.CUSTM_PRPTY,
               (SELECT BASENAME
                      FROM COM_BASE_INFO
                     WHERE BASECODE = D.CUSTM_PRPTY)  CUSTM_PRPTYNAME,
                D.LEGAL_PSN,
                D.AGENT,
                D.ADDRESS,
                D.BIGAREA,
                D.REGION_NO,
                D.ZIP_CODE,
                D.BANK,
                D.ACCOUNT,
                D.TAX_ID,
                D.PHONE,
                D.FAX,
                D.MEMO

  FROM SLM_BASE_CUSTOMER    A,
       SLM_BASE_CUSTM_RIGHT B,
       SLM_BASE_CUSTM_USE   C,
       SLM_BASE_ORDER_UNIT  D

 WHERE A.CUSTOMER_NO = B.CUSTOMER_NO
   AND A.CUSTOMER_NO = C.CUSTOMER_NO
   AND A.CUSTOMER_NO = D.CUSTOMER_NO
   AND C.CUSTM_USE = ?
   AND A.VALIDFLAG = '1'
   AND B.VALIDFLAG = '1'
   AND C.VALIDFLAG = '1'
   AND D.VALIDFLAG = '1'
	 

		]]>
	</query>
	
	<query id="CoreOrderBuyer.doQueryBuyer100204" desc="用途类型(订货单位/结算单位)">
		<![CDATA[ 
			 SELECT DISTINCT A.CUSTOMER_NO,
                A.CUSTOMER_NM,
                A.BIGAREA,
                A.REGION_NO,
                A.MARKET_SYS,
                A.ABRVITION,
                A.ORG,
                A.PY

  FROM SLM_BASE_CUSTOMER A, SLM_BASE_CUSTM_USE B, SLM_BASE_CUSTM_RIGHT C
 WHERE A.CUSTOMER_NO = B.CUSTOMER_NO
   AND A.CUSTOMER_NO = C.CUSTOMER_NO
   AND B.CUSTM_USE = ?
   AND A.VALIDFLAG = '1'
   AND B.VALIDFLAG = '1'
   AND C.VALIDFLAG = '1'
			 
			 
		]]>
	</query>
	<query id="CoreOrderBuyer.doQueryBuyer100105" desc="用途类型(订货单位/结算单位)">
		<![CDATA[
			 SELECT DISTINCT A.CUSTOMER_NO,
                A.CUSTOMER_NM,
                A.BIGAREA,
                A.REGION_NO,
                A.MARKET_SYS,
                A.ABRVITION,
                A.ORG,
                A.PY

  FROM SLM_BASE_CUSTOMER A, SLM_BASE_CUSTM_USE B, SLM_BASE_CUSTM_RIGHT C
 WHERE A.CUSTOMER_NO = B.CUSTOMER_NO
   AND A.CUSTOMER_NO = C.CUSTOMER_NO
   AND A.VALIDFLAG = '1'
   AND B.VALIDFLAG = '1'
   AND C.VALIDFLAG = '1'


		]]>
	</query>
</queryMap>