<?xml version="1.0" encoding="UTF-8"?>
<queryMap desc=" ">
	<query id="SlmGlAccrued.doQuery" desc="获取数据">
		SELECT
		T.BALANCE_NO,
		T.ORDER_NO,
		T.ORDER_TYP_DESC,
		T.BALANCE_TPYE_CODE,
		T.BALANCE_TPYE_DESC,
		T.COST_TPYE_CODE,
		T.COST_TPYE_DESC,
		DECODE(T.PAY_FLAG,'0','待支付','1','已支付') PAY_FLAG,
		T.BILLS_KEY,
		T.CUSTOMER_NO,
		T.CUSTOMER_NM,
		(SELECT BASENAME FROM COM_BASE_INFO  WHERE VALIDFLAG='1' AND BASECODE = T.SUPPLY_UNIT) SUPPLY_UNIT,
		T.STLMT_UNIT_NO,
		T.STLMT_UNIT_NM,
		TO_CHAR(T.SIGN_DATE, 'YYYY-MM-DD') SIGN_DATE,
		T.ORDER_YEAR,
		T.MEMO,
		DECODE(T.VALIDFLAG,'0','无效','1','有效') VALIDFLAG,
		T.CREATE_NAME,
		T.CREATE_DEPT,
		TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
		T.UPDATE_NAME,
		TO_CHAR(T.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
		T.DELETE_NAME,
		TO_CHAR(T.DELETE_TIME, 'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
		TO_CHAR(T.BALNCE_TOL_PRICE,'FM999,999,999,999,990.00') BALNCE_TOL_PRICE,
		T.BILLS_NOS,
		T.CG_ORDER_NO
		FROM SLM_GL_ORDER_BALANCE T
		WHERE 1=1
		AND T.VALIDFLAG = '1'
	</query>

	<query id="SlmGlAccrued.doQueryOrderHead" desc="获取数据">
		SELECT
		T.ORD_PK,
		T.ORDER_NO,
		T.ORDER_TYP,
		T.ORDER_TYP_DESC,
		T.PROTCL_NO,
		T.CUSTOMER_NO,
		T.CUSTOMER_NM,
		(SELECT BASENAME FROM COM_BASE_INFO  WHERE VALIDFLAG='1' AND BASECODE = T.SUPPLY_UNIT) SUPPLY_UNIT,
		T.MNY_ASK_TYP,
		T.STLMT_UNIT_NO,
		T.STLMT_UNIT_NM,
		T.LEGAL_PSN,
		T.AGENT,
		T.ADDRESS,
		T.ZIP_CODE,
		T.BANK,
		T.ACCOUNT,
		T.TAX_ID,
		T.PHONE,
		T.FAX,
		T.MNY_ASK_DESC,
		T.SIGN_PERSON,
		TO_CHAR(T.SIGN_DATE, 'YYYY-MM-DD HH24:MI:SS') SIGN_DATE,
		T.SIGN_ADDRESS,
		T.ORDER_YEAR,
		T.SALE_ORG,
		T.SALE_ORG_DESC,
		T.MEMO,
		TO_CHAR(T.CLOSE_TIME, 'YYYY-MM-DD HH24:MI:SS') CLOSE_TIME,
		DECODE(T.VALIDFLAG,'00','无效','10','有效','20','生效') VALIDFLAG,
		T.CREATE_NAME,
		T.CREATE_DEPT,
		TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
		T.UPDATE_NAME,
		TO_CHAR(T.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
		T.DELETE_NAME,
		TO_CHAR(T.DELETE_TIME, 'YYYY-MM-DD HH24:MI:SS') DELETE_TIME,
		T.CONTAIN_TAX,
		T.TRADE_TYPE,
		(SELECT BASENAME FROM COM_BASE_INFO  WHERE VALIDFLAG='1' AND BASECODE = T.TRADE_TYPE) TRADE_TYPE_DESC,
		T.ORDER_CLASSIFY,
		TO_CHAR(T.PRINT_TIME, 'YYYY-MM-DD HH24:MI:SS') PRINT_TIME,
		T.PRINT_COUNT,
		T.LOCAL_LAW,
		T.IPMAC,
		T.GL_ORDER_NO,
		DECODE(T.APPROVALFLAG,'00','待审','10','通过','20','退回','30','拒绝') APPROVALFLAG,
		T.LOCAL_ORHER,
		T.LOCAL_ZY,
		T.ORHER_INFO,
		T.DELVRY_ADDR,
		T.DELVRY_TYPE,
		T.TRANSIT_TYPE,
		T.PACK_TYPE,
		T.RECEIV_NO,
		T.RECEIV_NM,
		T.ORDER_SPECIAL_DESC
		FROM SLM_GL_ORDER_HEAD T
		WHERE 1=1
		AND T.APPROVALFLAG = '10'
		AND T.VALIDFLAG = '20'
	</query>

	<query id="SlmGlAccrued.doQueryOrderLine" desc="获取数据">
		SELECT
		T.ORD_PK,
		T.ORD_LN_PK,
		T.ORDER_SEQ,
		T.PSC,
		T.PSC_DESC,
		T.PRD_CLS,
		T.PRODUCCODE,
		T.PRODUCNAME,
		T.STD_CODE,
		T.STD_NAME,
		T.STEELCODE,
		T.STEELNAME,
		T.STD_STYLE,
		T.STD_STYLE_DESC,
		T.ORDER_SPEC_CODE,
		T.ORDER_SPEC_DESC,
		T.SPEC_CODE,
		T.SPEC_NAME,
		T.DIMATER,
		T.HEIGHT,
		T.MODEL_CODE,
		T.MODEL_DESC,
		T.LEN_NO,
		T.LEN_DESC,
		T.LEN_UNIT,
		T.LEN_MIN,
		T.LEN_MAX,
		T.ORDER_COUNT,
		T.ORDER_QTY,
		T.ORDER_UNIT,
		T.ORD_ENSU_TOTL_LEN,
		T.DELVRY_RANGE_TPE,
		T.DELVRY_RANGE_MIN,
		T.DELVRY_RANGE_MAX,
		T.PRODUCER_FL,
		TO_CHAR(T.DELVRY_EDATE, 'YYYY-MM-DD HH24:MI:SS') DELVRY_EDATE,
		T.BALNCE_PRICE,
		T.BALNCE_TOL_PRICE,
		T.PAK_PRICE,
		T.TRANS_PRICE,
		T.ORDER_PRICE,
		T.OUT_PRICE,
		T.MEMO,
		T.VALIDFLAG,
		T.CREATE_NAME,
		TO_CHAR(T.CREATE_TIME, 'YYYY-MM-DD HH24:MI:SS') CREATE_TIME,
		T.UPDATE_NAME,
		TO_CHAR(T.UPDATE_TIME, 'YYYY-MM-DD HH24:MI:SS') UPDATE_TIME,
		T.DELETE_NAME,
		TO_CHAR(T.DELETE_TIME, 'YYYY-MM-DD HH24:MI:SS') DELETE_TIME
		FROM SLM_GL_ORDER_LINE T
		WHERE 1=1
		AND T.ORD_PK=?
	</query>

	<query id="SlmGlAccrued.doDelete" desc="废除">
		UPDATE SLM_GL_ORDER_BALANCE T
		SET
		T.VALIDFLAG = '0',
		T.DELETE_NAME = ?,
		T.DELETE_TIME = SYSDATE
		WHERE
		1=1
		AND T.BALANCE_NO = ?
	</query>

	<query id="SlmGlAccrued.doUpdate" desc="修改">
		UPDATE SLM_GL_ORDER_BALANCE T
		SET
		T.BILLS_KEY = ?,
		T.UPDATE_NAME = ?,
		T.UPDATE_TIME = SYSDATE
		WHERE
		1=1
		AND T.BALANCE_NO = ?
	</query>

	<query id="SlmGlAccrued.addBalance" desc="新增数据">
		INSERT INTO SLM_GL_ORDER_BALANCE(
		BALANCE_NO,
		ORDER_NO,
		ORDER_TYP,
		ORDER_TYP_DESC,
		BALANCE_TPYE_CODE,
		BALANCE_TPYE_DESC,
		COST_TPYE_CODE,
		COST_TPYE_DESC,
		PAY_FLAG,
		CUSTOMER_NO,
		CUSTOMER_NM,
		SUPPLY_UNIT,
		STLMT_UNIT_NO,
		STLMT_UNIT_NM,
		SIGN_DATE,
		ORDER_YEAR,
		MEMO,
		VALIDFLAG,
		CREATE_NAME,
		CREATE_DEPT,
		CREATE_TIME,
		BALNCE_TOL_PRICE)
		VALUES(
		?,
		?,
		?,
		?,
		?,
		?,
		?,
		?,
		?,
		?,
		?,
		?,
		?,
		?,
		to_date(?,'yyyy-mm-dd hh24:mi:ss'),
		?,
		?,
		?,
		?,
		?,
		SYSDATE,
		?)
	</query>

	<query id="SlmGlAccrued.doQueryFreight" desc="获取数据">
		SELECT
		T.ORDER_NO,
		T.COST_TPYE_DESC,
		T.CG_ORDER_NO,
		S.TRADE_TYPE,
		(SELECT BASENAME FROM COM_BASE_INFO  WHERE VALIDFLAG='1' AND BASECODE = S.TRADE_TYPE) TRADE_TYPE_DESC,
		T.ORDER_TYP,
		T.ORDER_TYP_DESC,
		T.ORDER_YEAR,
		S.SIGN_DATE,
		S.SIGN_ADDRESS,
		DECODE(S.VALIDFLAG,'00','无效','10','有效','20','生效') VALIDFLAG,
		DECODE(S.APPROVALFLAG,'00','待审','10','通过','20','退回','30','拒绝') APPROVALFLAG,
		T.SUPPLY_UNIT,
		(SELECT BASENAME FROM COM_BASE_INFO  WHERE VALIDFLAG='1' AND BASECODE = T.SUPPLY_UNIT) SUPPLY_UNIT_DESC,
		T.CUSTOMER_NO,
		T.CUSTOMER_NM,
		T.STLMT_UNIT_NO,
		T.STLMT_UNIT_NM,
		S.RECEIV_NO,
		S.RECEIV_NM,
		S.ORDER_SPECIAL_DESC,
		T.MEMO
		FROM SLM_GL_ORDER_BALANCE T
		LEFT JOIN SLM_GL_ORDER_HEAD S ON T.ORDER_NO = S.ORDER_NO
		WHERE 1=1
		AND S.VALIDFLAG = '20'
		AND S.APPROVALFLAG = '10'
	</query>

	<query id="SlmGlAccrued.doAddFreight" desc="新增运费">
		INSERT INTO SLM_GL_ORDER_BALANCE(
		BALANCE_NO,
		ORDER_NO,
		BALANCE_TPYE_CODE,
		BALANCE_TPYE_DESC,
		COST_TPYE_CODE,
		COST_TPYE_DESC,
		CUSTOMER_NO,
		CUSTOMER_NM,
		SUPPLY_UNIT,
		STLMT_UNIT_NO,
		STLMT_UNIT_NM,
		PAY_FLAG,
		VALIDFLAG,
		CREATE_NAME,
		CREATE_DEPT,
		CREATE_TIME,
		BALNCE_TOL_PRICE,
		CG_ORDER_NO)
		VALUES(
		?,
		?,
		?,
		?,
		?,
		?,
		?,
		?,
		?,
		?,
		?,
		?,
		?,
		?,
		?,
		SYSDATE,
		?,
		?)
	</query>

	<query id="SlmGlAccrued.queryCount" desc="获取数据">
		SELECT
		COUNT(*)
		FROM SLM_GL_ORDER_BALANCE T
		WHERE 1=1 AND TO_CHAR(T.CREATE_TIME, 'yyyyMMdd') = TO_CHAR(SYSDATE, 'yyyyMMdd')
	</query>
</queryMap>