spc-sms/xml/pos-sql.xml

2706 lines
93 KiB
XML
Raw Permalink Normal View History

<?xml version="1.0" encoding="utf-8"?>
<sql-resource key="pos-sql">
<query name="SEL_POSSETT_INFO">
<![CDATA[
SELECT A.SETT_ITM_VAL AS VAN_ID -- VAN ID
, B.SETT_ITM_VAL AS VAN_TID -- VAN TID
, C.SETT_ITM_VAL AS TM_FCSTR_ID -- 티머니가맹점번호
, D.SETT_ITM_VAL AS TM_TID -- 티머니TID
FROM ST_POSSETT_MGR A
, ST_POSSETT_MGR B
, ST_POSSETT_MGR C
, ST_POSSETT_MGR D
WHERE 1 = 1
AND D.ORG_CD = C.ORG_CD
AND C.ORG_CD = B.ORG_CD
AND B.ORG_CD = A.ORG_CD
AND A.ORG_CD = ?
AND D.POS_NO = C.POS_NO
AND C.POS_NO = B.POS_NO
AND B.POS_NO = A.POS_NO
AND A.POS_NO = ?
AND A.SETT_ITM_CLSS_TP = '14'
AND B.SETT_ITM_CLSS_TP = '14'
AND C.SETT_ITM_CLSS_TP = '30'
AND D.SETT_ITM_CLSS_TP = '30'
AND A.SETT_ITM_CD = '0001'
AND B.SETT_ITM_CD = '0004'
AND C.SETT_ITM_CD = '0020'
AND D.SETT_ITM_CD = '0021'
AND D.CO_CD = C.CO_CD
AND C.CO_CD = B.CO_CD
AND B.CO_CD = A.CO_CD
AND A.CO_CD = ?
]]>
</query>
<query name="UPD_PDAEMERGTRN_HDR">
<![CDATA[
UPDATE HQ_PDAEMGTRN_HDR
SET PROC_ID = '1'
WHERE 1 = 1
AND TRAN_DT = ?
AND BIZLOC_ORG_CD = ?
AND PDA_NO = ?
AND TRAN_NO = ?
AND CO_CD = ?
]]>
</query>
<query name="SEL_PDAEMERGTRN_HDR">
<![CDATA[
SELECT SUBSTR(HD.BIZLOC_ORG_CD, 4, 5) AS STORE_CD
, HD.TRAN_DT AS TRAN_DT
, HD.PDA_NO AS PDA_NO
, HD.TRAN_NO AS TRAN_NO
, HD.TOT_SALE_AMT AS TOT_SALE_AMT
FROM HQ_PDAEMGTRN_HDR HD
WHERE 1 = 1
AND HD.TRAN_DT BETWEEN TO_CHAR(SYSDATE - 15, 'YYYYMMDD') AND TO_CHAR(SYSDATE, 'YYYYMMDD')
AND HD.BIZLOC_ORG_CD = ?
AND HD.CO_CD = ?
AND HD.PROC_ID = '0'
]]>
</query>
<query name="SEL_STRSTOCKNOW_ITEM">
<![CDATA[
SELECT NVL(NSTCK_QTY, 0) AS NSTCK_QTY1
FROM ST_STRSTCKNOW_MGR SH
WHERE 1 = 1
AND SH.ORG_CD = ?
AND SH.CO_CD = ?
AND SH.ITEM_CD = TRIM(?)
]]>
</query>
<query name="SEL_STRSTOCKNOW_CIGAR">
<![CDATA[
SELECT SH1.DOME_TBC AS NSTCK_QTY1
, SH2.FOR_TBC AS NSTCK_QTY2
FROM (
SELECT NVL(SUM(NSTCK_QTY), 0) AS DOME_TBC
FROM ST_STRSTCKNOW_MGR SH
INNER JOIN
HQ_GDS_MST GM
ON GM.ITEM_CD = SH.ITEM_CD
AND GM.CO_CD = SH.CO_CD
WHERE 1 = 1
AND SH.ORG_CD = ?
AND SH.CO_CD = ?
AND GM.CATE_CD LIKE '113143%'
) SH1
,
(
SELECT NVL(SUM(NSTCK_QTY), 0) AS FOR_TBC
FROM ST_STRSTCKNOW_MGR SH
INNER JOIN
HQ_GDS_MST GM
ON GM.ITEM_CD = SH.ITEM_CD
AND GM.CO_CD = SH.CO_CD
WHERE 1 = 1
AND SH.ORG_CD = ?
AND SH.CO_CD = ?
AND GM.CATE_CD LIKE '113151%'
) SH2
]]>
</query>
<!-- 임시 SELECT 문 sql문에 종결 문자 있음 에러남 -->
<query name="SEL_SURVEY_INFO">
<![CDATA[
SELECT SUM(CASE WHEN MONTH_DIV ='P' THEN SCORE ELSE 0 END) LASTMONSCORE,
SUM(CASE WHEN MONTH_DIV ='T' THEN SCORE ELSE 0 END) THISMONSCORE
FROM (
SELECT 'P' AS MONTH_DIV
, NVL(ROUND(AVG(SCORE * 20 ), 1), 0) AS SCORE
FROM POS_HPC_RESEARCH_TR RT
WHERE RT.RESEARCH_DT BETWEEN TO_CHAR( SYSDATE, 'YYYYMM' ) || '01000000' AND TO_CHAR( SYSDATE, 'YYYYMM' ) || '31235959'
AND RT.STOR_CD = LPAD( ?, 10, '0' )
UNION ALL
SELECT 'T' AS MONTH_DIV
, NVL(ROUND(AVG(SCORE * 20 ), 1), 0) AS SCORE
FROM POS_HPC_RESEARCH_TR RT
WHERE RT.RESEARCH_DT BETWEEN TO_CHAR( ADD_MONTHS(SYSDATE, -1), 'YYYYMM' ) || '01000000' AND TO_CHAR( ADD_MONTHS(SYSDATE, -1), 'YYYYMM' ) || '31235959'
AND RT.STOR_CD = LPAD( ?, 10, '0' )
)A
]]>
</query>
<!-- 선불고객 조회 쿼리 -->
<query name="SEL_SALEONCREDIT_CUST_NAME">
<![CDATA[
SELECT CUST_ID ,
CUST_MNG_DIV ,
TEL_NO CARD_NO,
CUST_NM ,
NVL(PP_PAY_DPST_AMT,0) - NVL(PP_PAY_OCCUR_AMT,0) PP_PAY_DPST_AMT
FROM STR_STOR_CUST_INFO
WHERE CMP_CD = ?
AND STOR_CD = ?
AND PP_PAY_YN ='1'
AND USE_YN = '1'
--AND S_SUPPLY_VEND_DIV='3'
AND ( TEL_NO LIKE '%' || TRIM(?) || '%'
OR UPPER(CUST_NM) LIKE '%' || UPPER(TRIM(?)) || '%'
OR CUST_ID LIKE '%' || TRIM(?) || '%' )
]]>
</query>
<!-- 선불고객 코드값으로 조회 시 -->
<query name="SEL_SALEONCREDIT_CUST_CODE">
<![CDATA[
SELECT CUST_ID ,
CUST_MNG_DIV ,
TEL_NO CARD_NO ,
CUST_NM ,
NVL(PP_PAY_DPST_AMT,0) -NVL(PP_PAY_OCCUR_AMT,0) PP_PAY_DPST_AMT
FROM STR_STOR_CUST_INFO
WHERE CMP_CD = ?
AND STOR_CD = ?
AND PP_PAY_YN ='1'
--AND S_SUPPLY_VEND_DIV='3'
AND CARD_NO = TRIM(?) --AND CUST_ID = TRIM()
AND USE_YN = '1'
]]>
</query>
<!-- 선불고객 전화번호 값으로 조회 시 -->
<query name="SEL_SALEONCREDIT_CUST_TEL">
<![CDATA[
SELECT CUST_ID ,
CUST_MNG_DIV ,
TEL_NO CARD_NO ,
CUST_NM ,
NVL(PP_PAY_DPST_AMT,0) -NVL(PP_PAY_OCCUR_AMT,0) PP_PAY_DPST_AMT
FROM STR_STOR_CUST_INFO
WHERE CMP_CD = ?
AND STOR_CD = ?
AND PP_PAY_YN ='1'
--AND S_SUPPLY_VEND_DIV='3'
AND USE_YN = '1'
AND TEL_NO LIKE '%' || TRIM(?) || '%'
]]>
</query>
<!-- 외상 고객 조회 쿼리 -->
<query name="SEL_CREDITCUSTINFO_NAME">
<![CDATA[
SELECT CUST_ID ,
CUST_MNG_DIV ,
TEL_NO CARD_NO,
CUST_NM ,
NVL(CRDT_SALE_REMAIN_AMT,0) CRDT_SALE_REMAIN_AMT,
NVL(AUTO_DC_RATE,0) AUTO_DC_RATE
FROM STR_STOR_CUST_INFO
WHERE CMP_CD = ?
AND STOR_CD = ?
AND S_SUPPLY_VEND_DIV LIKE '%' || TRIM(?) || '%'
--AND S_SUPPLY_VEND_DIV <>'3'
AND USE_YN = '1'
AND CRDT_USE_YN ='1'
AND ( TEL_NO LIKE '%' || TRIM(?) || '%'
OR UPPER(CUST_NM) LIKE '%' || UPPER(TRIM(?)) || '%'
OR CUST_ID LIKE '%' || TRIM(?) || '%' )
]]>
</query>
<!-- 외상고객 코드 조회시에도 LIKE 검색가능하게 -->
<!-- CUST_ID = TRIM(?) -->
<query name="SEL_CREDITCUSTINFO_CODE">
<![CDATA[
SELECT CUST_ID ,
CUST_MNG_DIV ,
TEL_NO CARD_NO ,
CUST_NM ,
NVL(CRDT_SALE_REMAIN_AMT,0) CRDT_SALE_REMAIN_AMT,
NVL(AUTO_DC_RATE,0) AUTO_DC_RATE
FROM STR_STOR_CUST_INFO
WHERE CMP_CD = ?
AND STOR_CD = ?
AND S_SUPPLY_VEND_DIV LIKE '%' || TRIM(?) || '%'
--AND S_SUPPLY_VEND_DIV <>'3'
AND CRDT_USE_YN ='1'
AND USE_YN = '1'
AND CUST_ID LIKE TRIM(?) || '%'
]]>
</query>
<!-- 외상 고객 전화 번호 조회 -->
<query name="SEL_CREDITCUSTINFO_TEL">
<![CDATA[
SELECT CUST_ID ,
CUST_MNG_DIV ,
TEL_NO CARD_NO ,
CUST_NM ,
NVL(CRDT_SALE_REMAIN_AMT,0) CRDT_SALE_REMAIN_AMT,
NVL(AUTO_DC_RATE,0) AUTO_DC_RATE
FROM STR_STOR_CUST_INFO
WHERE CMP_CD = ?
AND STOR_CD = ?
AND S_SUPPLY_VEND_DIV LIKE '%' || TRIM(?) || '%'
--AND S_SUPPLY_VEND_DIV <>'3'
AND CRDT_USE_YN ='1'
AND USE_YN = '1'
AND TEL_NO LIKE '%' || TRIM(?) || '%'
]]>
</query>
<query name="SEL_GIFT_SEARCH">
<![CDATA[
SELECT A.GIF_NO AS GIF_NO
,A.GIF_STATUS AS GIF_STATUS
,A.GIF_VRTY AS GIF_VRTY
,NVL(B.GIF_FACE_AMT,0) AS GIF_AMT
,TO_CHAR(SYSDATE,'YYYYMMDD') AS APPROVE_DATE
,TO_CHAR(SYSDATE,'hh24miss') AS APPROVE_NO
FROM GIF_MST A
JOIN GIF_VRTY B
ON A.CMP_CD = B.CMP_CD
AND A.GIF_TYPE = B.GIF_TYPE
AND A.GIF_KIND = B.GIF_KIND
AND A.GIF_VRTY = B.GIF_VRTY
WHERE
A.CMP_CD = ?
AND A.GIF_NO = ?
AND A.GIF_TYPE = '10'
]]>
</query>
<!-- 상태값 상품권 최종상태 =>공통(00185) G0004 [0:대기, 1:입고, 2:출고, 3:판매, 4:반품, 5:판매승인, 6:회수, 7:사고등록, 9:폐기] -->
<query name="UPDATE_GIFTDATA">
<![CDATA[
UPDATE GIF_MST
SET GIF_STATUS = ?
WHERE
GIF_NO = ?
]]>
</query>
<query name="SEL_TICKET_SEARCH">
<![CDATA[
SELECT TICKET_STATUS AS TICKET_STATUS
,TICKET_NO AS TICKET_NO
,NVL(TICKET_AMT,0) AS TICKET_AMT
FROM TR_EXCHANGE_TICKET
WHERE
CMP_CD =?
AND STOR_CD =?
AND TICKET_NO =?
]]>
</query>
<!-- 잔액교환권 등록 SQL -->
<query name="INS_EXCHANGE_TICKET">
<![CDATA[
INSERT INTO TR_EXCHANGE_TICKET(
CMP_CD
, STOR_CD
, SALE_DT
, TICKET_NO
, TICKET_AMT
, TICKET_STATUS
, USER_ID
, SYS_YMDHMS
)
VALUES (
?
,?
,?
,?
,?
,?
,?
,TO_CHAR(SYSDATE,'YYYYMMDDhh24miss')
)
]]>
</query>
<!-- 잔액 교환권 취소 및 승인 SQL -->
<query name="UPD_EXCHANGE_TICKET">
<![CDATA[
UPDATE TR_EXCHANGE_TICKET
SET TICKET_STATUS = ?
WHERE 1 = 1
AND CMP_CD = ?
AND STOR_CD = ?
AND TICKET_NO = ?
]]>
</query>
<query name="SEL_TR_MAX_TRADE_NO">
<![CDATA[
SELECT MAX(A.TRADE_NO) AS TRADE_NO , MAX(A.REG_NO) REG_NO
FROM (
SELECT
NVL(MAX(TRADE_NO),'00000') AS TRADE_NO , '00000' AS REG_NO
FROM TR_SALE_LOG
WHERE 1=1
AND CMP_CD = ?
AND SALE_DT = ?
AND STOR_CD = ?
AND POS_NO = ?
UNION ALL
SELECT
'00000' AS TRADE_NO, NVL(MAX(REG_NO),'00000') AS TRADE_NO
FROM ETC_SALE_LOG
WHERE 1=1
AND CMP_CD = ?
AND SALE_DT = ?
AND STOR_CD = ?
AND POS_NO = ?
) A
]]>
</query>
<!-- 매장별 PVC 상자 재고 입력 -->
<query name="MER_PVC_DTPER_STOCK">
<![CDATA[
MERGE INTO SPL_P_BOX_DTPER_STOCK T
USING ( SELECT ? AS CMP_CD,
? AS STOCK_DT,
? AS STOR_CD,
? AS P_BOX_L_QTY,
? AS P_BOX_M_QTY,
? AS P_BOX_S_QTY,
? AS REG_USER_ID ,
TO_DATE(?,'YYYYMMDDhh24miss') AS REG_DATE
FROM DUAL
) R
ON ( T.CMP_CD = R.CMP_CD
AND T.STOCK_DT = R.STOCK_DT
AND T.STOR_CD = R.STOR_CD
)
WHEN MATCHED THEN
UPDATE SET T.P_BOX_L_QTY = R.P_BOX_L_QTY
,T.P_BOX_M_QTY = R.P_BOX_M_QTY
,T.P_BOX_S_QTY = R.P_BOX_S_QTY
,T.REG_USER_ID = R.REG_USER_ID
,T.REG_DATE = R.REG_DATE
WHEN NOT MATCHED THEN
INSERT (
CMP_CD ,STOCK_DT ,STOR_CD,P_BOX_L_QTY,P_BOX_M_QTY,P_BOX_S_QTY,REG_USER_ID,REG_DATE , UPD_USER_ID, UPD_DATE
)
VALUES (
R.CMP_CD, R.STOCK_DT, R.STOR_CD, R.P_BOX_L_QTY, R.P_BOX_M_QTY, R.P_BOX_S_QTY, R.REG_USER_ID, R.REG_DATE, R.REG_USER_ID, R.REG_DATE
)
]]>
</query>
<!-- 매장별 방문 이력 등록 -->
<query name="MER_STORE_VISIT">
<![CDATA[
MERGE INTO STR_STOR_VISIT T
USING ( SELECT ? AS CMP_CD,
? AS STOR_CD,
? AS VISIT_DT,
? AS POS_NO,
? AS MNG_CARD_NO,
TO_DATE(?,'YYYYMMDDhh24miss') AS VISIT_START_HOUR,
TO_DATE(?,'YYYYMMDDhh24miss') AS VISIT_FNSH_HOUR,
? AS VISIT_USER_ID,
? AS JOB_TYPE ,
? AS PCSMM_SEND_YN,
? AS MSR_DIV,
? AS ORG_BAR_CD_NO,
sysdate AS REG_DATE
FROM DUAL
) R
ON ( T.CMP_CD = R.CMP_CD
AND T.STOR_CD = R.STOR_CD
AND T.VISIT_DT = R.VISIT_DT
AND T.POS_NO = R.POS_NO
AND T.MNG_CARD_NO = R.MNG_CARD_NO
AND T.VISIT_START_DATE = R.VISIT_START_HOUR
)
WHEN MATCHED THEN
UPDATE SET T.VISIT_FNSH_DATE = R.VISIT_FNSH_HOUR
,T.PCSMM_SEND_YN = '0'
,T.UPD_DATE = R.REG_DATE
WHEN NOT MATCHED THEN
INSERT ( CMP_CD ,STOR_CD ,VISIT_DT ,POS_NO ,MNG_CARD_NO
,VISIT_START_DATE ,VISIT_FNSH_DATE ,VISIT_USER_ID ,JOB_TYPE
,PCSMM_SEND_YN ,MSR_DIV ,ORG_BAR_CD_NO , REG_DATE
)
VALUES (
R.CMP_CD ,R.STOR_CD ,R.VISIT_DT ,R.POS_NO ,R.MNG_CARD_NO
,R.VISIT_START_HOUR ,R.VISIT_FNSH_HOUR ,R.VISIT_USER_ID ,R.JOB_TYPE
,R.PCSMM_SEND_YN ,R.MSR_DIV ,R.ORG_BAR_CD_NO ,R.REG_DATE
)
]]>
</query>
<!-- 매장별 방문 이력 등록 -->
<query name="MER_STORE_VISIT_1">
<![CDATA[
MERGE INTO STR_STOR_VISIT T
USING ( SELECT ? AS CMP_CD,
? AS STOR_CD,
? AS VISIT_DT,
? AS POS_NO,
? AS MNG_CARD_NO,
TO_DATE(?,'YYYYMMDDhh24miss') AS VISIT_START_HOUR,
? AS VISIT_USER_ID,
? AS JOB_TYPE ,
? AS PCSMM_SEND_YN,
? AS MSR_DIV,
? AS ORG_BAR_CD_NO,
sysdate AS REG_DATE
FROM DUAL
) R
ON ( T.CMP_CD = R.CMP_CD
AND T.STOR_CD = R.STOR_CD
AND T.VISIT_DT = R.VISIT_DT
AND T.POS_NO = R.POS_NO
AND T.MNG_CARD_NO = R.MNG_CARD_NO
AND T.VISIT_START_DATE = R.VISIT_START_HOUR
)
WHEN MATCHED THEN
UPDATE SET T.UPD_DATE = R.REG_DATE
,T.PCSMM_SEND_YN = '0'
WHEN NOT MATCHED THEN
INSERT ( CMP_CD ,STOR_CD ,VISIT_DT ,POS_NO ,MNG_CARD_NO
,VISIT_START_DATE ,VISIT_USER_ID ,JOB_TYPE
,PCSMM_SEND_YN ,MSR_DIV ,ORG_BAR_CD_NO , REG_DATE
)
VALUES (
R.CMP_CD ,R.STOR_CD ,R.VISIT_DT ,R.POS_NO ,R.MNG_CARD_NO
,R.VISIT_START_HOUR ,R.VISIT_USER_ID ,R.JOB_TYPE
,R.PCSMM_SEND_YN ,R.MSR_DIV ,R.ORG_BAR_CD_NO ,R.REG_DATE
)
]]>
</query>
<!-- 매장별 고객 클레임 등록 -->
<query name="MER_STORE_CLAIM">
<![CDATA[
MERGE INTO ORD_STOR_CLAIM T
USING ( SELECT ? AS SALES_DT,
? AS CMP_CD,
? AS STOR_CD,
? AS POS_NO,
? AS DOC_SEQ,
? AS CUST_NM,
? AS GNDR_TYPE,
? AS CUST_COCT_PNT,
? AS PROD_DT_LOT,
? AS RPST_ITEM_NM,
? AS ACTUAL_PURCH_DT,
? AS CLAIM_PRC_TYPE,
? AS CLAIM_PRC_EXPNS,
? AS CLAIM_PRC_CTNTS,
TO_DATE(? ,'YYYYMMDDHH24MISS') AS REG_DATE,
? AS UPD_USER_ID
FROM DUAL
) R
ON (
T.SALES_DT= R.SALES_DT
AND T.CMP_CD = R.CMP_CD
AND T.STOR_CD = R.STOR_CD
AND T.POS_NO = R.POS_NO
AND T.DOC_SEQ = R.DOC_SEQ
)
WHEN MATCHED THEN
UPDATE SET T.CUST_NM =R.CUST_NM
,T.GNDR_TYPE =R.GNDR_TYPE
,T.CUST_COCT_PNT =R.CUST_COCT_PNT
,T.PROD_DT_LOT =R.PROD_DT_LOT
,T.RPST_ITEM_NM =R.RPST_ITEM_NM
,T.ACTUAL_PURCH_DT =R.ACTUAL_PURCH_DT
,T.CLAIM_PRC_TYPE =R.CLAIM_PRC_TYPE
,T.CLAIM_PRC_EXPNS =R.CLAIM_PRC_EXPNS
,T.CLAIM_PRC_CTNTS =R.CLAIM_PRC_CTNTS
,T.UPD_DATE =R.REG_DATE
,T.UPD_USER_ID =R.UPD_USER_ID
WHEN NOT MATCHED THEN
INSERT ( CMP_CD ,SALES_DT ,STOR_CD ,POS_NO ,DOC_SEQ ,
CUST_NM ,GNDR_TYPE ,CUST_COCT_PNT ,PROD_DT_LOT ,RPST_ITEM_NM ,
ACTUAL_PURCH_DT ,CLAIM_PRC_TYPE ,CLAIM_PRC_EXPNS ,CLAIM_PRC_CTNTS ,
REG_DATE ,REG_USER_ID )
VALUES ( R.CMP_CD ,R.SALES_DT ,R.STOR_CD ,R.POS_NO ,R.DOC_SEQ ,
R.CUST_NM ,R.GNDR_TYPE ,R.CUST_COCT_PNT ,R.PROD_DT_LOT ,R.RPST_ITEM_NM ,
R.ACTUAL_PURCH_DT ,R.CLAIM_PRC_TYPE ,R.CLAIM_PRC_EXPNS ,R.CLAIM_PRC_CTNTS ,
R.REG_DATE ,R.UPD_USER_ID )
]]>
</query>
<!-- 외상 고객 금액 등록 SQL -->
<query name="UPD_CREDIT_USE">
<![CDATA[
UPDATE STR_STOR_CUST_INFO
SET CRDT_SALE_REMAIN_AMT = NVL(CRDT_SALE_REMAIN_AMT,0)+ ?
,CRDT_SALE_OCCUR_AMT = NVL(CRDT_SALE_OCCUR_AMT,0) + ?
,FIRST_TRADE_DT = CASE WHEN FIRST_TRADE_DT IS NULL OR FIRST_TRADE_DT >= ?
THEN ?
ELSE FIRST_TRADE_DT END
,FIRST_TRADE_STOR_CD = CASE WHEN FIRST_TRADE_DT IS NULL OR FIRST_TRADE_DT >= ?
THEN FIRST_TRADE_STOR_CD
ELSE FIRST_TRADE_STOR_CD END
,LAST_TRADE_DT = CASE WHEN LAST_TRADE_DT IS NULL OR LAST_TRADE_DT <= ?
THEN ?
ELSE LAST_TRADE_DT END
,LAST_TRADE_STOR_CD = CASE WHEN LAST_TRADE_DT IS NULL OR LAST_TRADE_DT <= ?
THEN LAST_TRADE_STOR_CD
ELSE LAST_TRADE_STOR_CD END
,UPD_DATE = SYSDATE
WHERE 1 = 1
AND CMP_CD = ?
AND STOR_CD = ?
AND CUST_ID = ?
]]>
</query>
<!-- 외상 고객 입금 로그 -->
<query name="MER_INS_CREDIT_USE_LOG">
<![CDATA[
MERGE INTO ADM_CUST_TRADE_DESC T
USING ( SELECT ? AS CMP_CD,
? AS STOR_CD,
? AS SALE_DT,
? AS CUST_ID,
? AS AF_PAY_OCCUR_AMT,
0 AS AF_PAY_DPST_AMT,
0 AS PP_OCCUR_AMT ,
0 AS PP_DPST_AMT ,
SYSDATE AS REG_DATE,
SYSDATE AS UPD_DATE
FROM DUAL
) R
ON ( T.CMP_CD = R.CMP_CD
AND T.STOR_CD = R.STOR_CD
AND T.SALE_DT = R.SALE_DT
AND T.CUST_ID = R.CUST_ID
)
WHEN MATCHED THEN
UPDATE SET T.AF_PAY_OCCUR_AMT = T.AF_PAY_OCCUR_AMT + R.AF_PAY_OCCUR_AMT
,T.UPD_DATE = R.UPD_DATE
WHEN NOT MATCHED THEN
INSERT (
CMP_CD, STOR_CD, SALE_DT, CUST_ID, AF_PAY_OCCUR_AMT, AF_PAY_DPST_AMT, PP_OCCUR_AMT, PP_DPST_AMT, REG_USER_ID, REG_DATE, UPD_USER_ID, UPD_DATE
)
VALUES (
R.CMP_CD, R.STOR_CD, R.SALE_DT, R.CUST_ID, R.AF_PAY_OCCUR_AMT, R.AF_PAY_DPST_AMT, R.PP_OCCUR_AMT, R.PP_DPST_AMT, 'POSDEAMON', R.REG_DATE, 'POSDEAMON', R.UPD_DATE
)
]]>
</query>
<!-- 선불 고객 금액 등록 SQL -->
<query name="UPD_PREPAY_USE">
<![CDATA[
UPDATE STR_STOR_CUST_INFO
SET PP_PAY_OCCUR_AMT = NVL(PP_PAY_OCCUR_AMT,0) + ? ,
LAST_TRADE_DT = ?,
LAST_TRADE_STOR_CD = ?,
UPD_DATE = SYSDATE
WHERE 1 = 1
AND CMP_CD = ?
AND STOR_CD = ?
AND CUST_ID = ?
]]>
</query>
<!-- 선불 고객 금액 등록 SQL -->
<query name="SEL_PREPAY_USECHK">
<![CDATA[
SELECT NVL(PP_PAY_OCCUR_AMT,0) AS PP_PAY_OCCUR_AMT ,
NVL(PP_PAY_DPST_AMT,0) AS PP_PAY_DPST_AMT
FROM STR_STOR_CUST_INFO
WHERE 1 = 1
AND CMP_CD = ?
AND STOR_CD = ?
AND CUST_ID = ?
AND USE_YN = '1'
]]>
</query>
<!-- 선불 고객 반품가능여부 체크 SQL -->
<query name="SEL_PREPAY_RETCHK">
<![CDATA[
SELECT NVL(APPR_NO,'') AS APPR_NO
FROM PREPAY_SVR_LOG
WHERE APPR_NO = ?
AND TRADE_DIV = '0'
AND INQ_TYPE = '32'
]]>
</query>
<!-- 선불 고객 기 반품여부 체크 SQL -->
<query name="SEL_PREPAY_ORGRETCHK">
<![CDATA[
SELECT NVL(ORG_APPR_NO,'') AS APPR_NO
FROM PREPAY_SVR_LOG
WHERE ORG_APPR_NO = ?
AND TRADE_DIV = '1'
AND INQ_TYPE = '32'
]]>
</query>
<query name="SEL_APPROVE_NUM">
<![CDATA[
SELECT LPAD(SQ_PREPAY_APPR_NO.NEXTVAL, 12 , '0' ) AS APPR_NO , TO_CHAR(SYSDATE,'YYYYMMDDHH24MISS') APPR_DT FROM DUAL
]]>
</query>
<!-- 선불 고객 LOG 등록 SQL -->
<query name="INS_PREPAY_LOG">
<![CDATA[
INSERT INTO PREPAY_SVR_LOG
( APPR_NO , TRADE_DIV , INQ_TYPE, CMP_CD , STOR_CD , SALE_DT
, POS_NO , REG_NO , WCC , APPR_TM , APPR_AMT , ORG_APPR_NO, CUST_ID )
VALUES
( ?, ?, ? , ? , ?, ?
, ? , ?, 'A', TO_CHAR(SYSDATE, 'HH24MISS'), ? , ?, ?)
]]>
</query>
<!-- 선불 고객 입금 로그 20161212-->
<query name="MER_INS_CREDIT_PPUSE_LOG">
<![CDATA[
MERGE INTO ADM_CUST_TRADE_DESC T
USING ( SELECT ? AS CMP_CD,
? AS STOR_CD,
? AS SALE_DT,
? AS CUST_ID,
0 AS AF_PAY_OCCUR_AMT,
0 AS AF_PAY_DPST_AMT,
? AS PP_OCCUR_AMT ,
0 AS PP_DPST_AMT ,
SYSDATE AS REG_DATE,
SYSDATE AS UPD_DATE
FROM DUAL
) R
ON ( T.CMP_CD = R.CMP_CD
AND T.STOR_CD = R.STOR_CD
AND T.SALE_DT = R.SALE_DT
AND T.CUST_ID = R.CUST_ID
)
WHEN MATCHED THEN
UPDATE SET T.PP_OCCUR_AMT = T.PP_OCCUR_AMT + R.PP_OCCUR_AMT
,T.UPD_DATE = R.UPD_DATE
WHEN NOT MATCHED THEN
INSERT (
CMP_CD, STOR_CD, SALE_DT, CUST_ID, AF_PAY_OCCUR_AMT, AF_PAY_DPST_AMT, PP_OCCUR_AMT, PP_DPST_AMT, REG_USER_ID, REG_DATE, UPD_USER_ID, UPD_DATE
)
VALUES (
R.CMP_CD, R.STOR_CD, R.SALE_DT, R.CUST_ID, R.AF_PAY_OCCUR_AMT, R.AF_PAY_DPST_AMT, R.PP_OCCUR_AMT, R.PP_DPST_AMT, 'POSDEAMON', R.REG_DATE, 'POSDEAMON', R.UPD_DATE
)
]]>
</query>
<!-- 프린트 로그 SQL -->
<query name="SET_FOOD_STORE_CHECK">
<![CDATA[
INSERT INTO PRT_CONF_STORE
( PRT_DT ,PRT_HMS ,CMP_CD ,STOR_CD ,PRT_DIV ,REMARKS
, USE_YN ,INST_DT ,INST_USER ,UPD_DT ,UPD_USER ,POS_NO)
VALUES (TO_CHAR(SYSDATE,'YYYYMMDD'), TO_CHAR(SYSDATE,'HH24MISS'), ?, ? ,?, '',
'Y' , SYSDATE , ? , SYSDATE ,? ,?)
]]>
</query>
<!-- LOG 파일 요청 있는지 여부 조회 배신테이블 -->
<query name="SEL_STOR_LOG">
<![CDATA[
SELECT *
FROM POS_DEPLOY_MNG
WHERE 1 = 1
AND CMP_CD = ?
AND STOR_CD = ?
AND DEPLOY_DT = ?
AND POS_NO = ?
AND DEPLOY_DIV = 'LOG'
AND DEPLOY_WORK_DIV ='04'
]]>
</query>
<!-- 점포 체크 리스트 등록 되어있는지 조회 -->
<query name="SEL_STOR_CHECKLIST_COUNT">
<![CDATA[
SELECT NVL(SUM(CNT),0) AS CHECK_LIST_CNT
FROM
MST_STOR_INSPCT_GRP A ,
( SELECT A.CMP_CD, A.INSPCT_ENTRY_GRP_CD , COUNT(*) AS CNT
FROM MST_STOR_INSPCT_GRP_STOR A,
STR_STOR_INSPCT_ANSWR_STOR B
WHERE A.CMP_CD = B.CMP_CD(+)
AND A.INSPCT_ENTRY_GRP_CD = B.INSPCT_ENTRY_GRP_CD(+)
AND A.STOR_CD = B.STOR_CD(+)
AND A.STOR_CD =?
AND A.CMP_CD =?
GROUP BY A.CMP_CD, A.INSPCT_ENTRY_GRP_CD) B
WHERE A.CMP_CD = B.CMP_CD(+)
AND A.INSPCT_ENTRY_GRP_CD = B.INSPCT_ENTRY_GRP_CD(+)
--AND A.WEB_POS_TYPE ='2'
]]>
</query>
<!-- 점포 배송 데이터 조회 AS와 동일하게 쿼리 BRK 조회 -->
<query name="SEL_DELIVERY_DATA">
<![CDATA[
SELECT A.ITEM_GB , A.EARRV_DATE AS ELEAV_DATE
FROM (
SELECT DECODE(CNTR_CD,'D001','20','D003','20', '10' ) AS ITEM_GB -- '10' 제품 , '20' 상품
, TO_CHAR(D1.ARRV_EXPT_DATE, 'yyyy-mm-dd AM hh:mi') AS EARRV_DATE
, '2' div
FROM ORD_IF_DLV_ARRV D1
WHERE D1.DLV_DT = ?
AND ( D1.STOR_CD = '20000' || ? -- '20000'은 FIX
OR D1.STOR_CD = '10000' || ? -- '10000'은 FIX
OR D1.STOR_CD = '00000' || ? -- '00000'은 FIX
OR D1.STOR_CD = ? )
AND D1.ARRV_REAL_DATE IS NULL
AND D1.ARRV_EXPT_DATE IS NOT NULL -- 2014.07.16 물류팀 김지수대리 요청에 의해 배송기사 등록 배송정보는 제외.
ORDER BY ARRV_EXPT_DATE ASC
) A
WHERE ROWNUM = 1
]]>
</query>
<!-- 기념일배송(해피이샵) 조회 조건 변경 가능할 수도 있음 -->
<query name="SEL_ORDER_ESHOP_DATA">
<![CDATA[
SELECT NVL(AMTDAY_CNT,0) AS ORDQTY
FROM ORD_ESHOP
WHERE CMP_CD = ?
AND STOR_CD = ?
]]>
</query>
<!-- STORE CATID SEARCH -->
<query name="SEL_STOR_CATID">
<![CDATA[
SELECT * FROM (
SELECT DISTINCT CMP_CD, STOR_CD
FROM MST_STOR_APPRVEND_MNG
WHERE APPR_ID =?
AND USE_YN ='1'
--ORDER BY UPD_DATE DESC
) A
WHERE ROWNUM = 1 -- Must be Multi Shop Return list type
]]>
</query>
<!-- 배포 파일 명 반환 -->
<query name="SEL_WAT_FILENM">
<![CDATA[
SELECT ? || LPAD(NVL(MAX(SEQ_NO+1),1), 5,'0') AS FILE_NM
FROM WAT_DEPLOY_MNG
WHERE 1 = 1
AND CMP_CD =?
AND DEPLOY_DT =?
AND DEPLOY_DIV ='10'
AND FILE_DIV = ?
]]>
</query>
<!-- 배포 파일 명으로 update -->
<query name="SET_WAT_UPDATE_FILENM">
<![CDATA[
UPDATE WAT_DEPLOY_MNG
SET USE_YN ='0' --파일삭제 후 사용구분 '0'
,UPD_USER_ID ='POSDAEMON'
,UPD_DATE = SYSDATE
WHERE 1 = 1
AND CMP_CD =?
AND FILE_NM =?
AND DEPLOY_DIV =?
AND FILE_DIV = ?
]]>
</query>
<!-- CPI LINE ORDER COUNT SQL -->
<query name="SEL_CPI_LINEORDER_COUNT">
<![CDATA[
SELECT NVL(SUM(DC_QTY * CASE WHEN TRADE_DIV = '0' THEN 1 ELSE -1 END),0) AS CPI_CNT
FROM TR_SALE_CPI_RSLT A , TR_SALE_HEADER B
WHERE A.SALE_DT BETWEEN ? AND ?
AND A.CMP_CD = ?
AND A.STOR_CD = ?
AND A.CPI_CD = ?
AND A.SALE_DT = B.SALE_DT
AND A.STOR_CD = B.STOR_CD
AND A.POS_NO = B.POS_NO
AND A.TRADE_NO = B.TRADE_NO
]]>
</query>
<!-- CPI Issued COUNT SQL -->
<query name="SEL_CPI_ISSUED_COUNT">
<![CDATA[
SELECT NVL(SUM(CNT),0) AS CPI_CNT FROM (
SELECT
C.CMP_CD,
C.SALE_DT,
C.STOR_CD,
C.POS_NO ,
NVL(SUM(CASE WHEN C.TRADE_DIV ='0' THEN 1 ELSE -1 END),0) AS CNT
FROM TR_SALE_CPI_RSLT A , TR_SALE_HEADER C
WHERE A.SALE_DT BETWEEN ? AND ?
AND A.CMP_CD = ?
AND A.STOR_CD = ?
AND A.CPI_CD = ?
AND A.CMP_CD = C.CMP_CD
AND A.SALE_DT = C.SALE_DT
AND A.STOR_CD = C.STOR_CD
AND A.POS_NO = C.POS_NO
AND A.TRADE_NO = C.TRADE_NO
AND A.SLACK_FIELD =?
GROUP BY C.CMP_CD,C.SALE_DT,C.STOR_CD,C.POS_NO
) A
]]>
</query>
<!-- 매장별 PVC 상자 재고 입력 -->
<query name="MER_INS_POS_TESTMODE">
<![CDATA[
MERGE INTO TR_CASHIER_TEST T
USING ( SELECT ? AS CMP_CD,
? AS STOR_CD,
? AS CASHIER_NO,
? AS TEST_ENTRY_ID,
? AS TEST_PASS_YN,
? AS TEST_DATE,
'' AS REPSPSN_NO ,
'' AS SEND_DIV ,
TO_CHAR(SYSDATE,'YYYYMMDDhh24miss') AS REG_DATE,
TO_CHAR(SYSDATE,'YYYYMMDDhh24miss') AS UPD_DATE
FROM DUAL
) R
ON ( T.CMP_CD = R.CMP_CD
AND T.STOR_CD = R.STOR_CD
AND T.CASHIER_NO = R.CASHIER_NO
AND T.TEST_ENTRY_ID = R.TEST_ENTRY_ID
)
WHEN MATCHED THEN
UPDATE SET T.TEST_PASS_YN = R.TEST_PASS_YN
,T.REG_DATE = R.REG_DATE
,T.UPD_DATE = R.UPD_DATE
WHEN NOT MATCHED THEN
INSERT (
CMP_CD, STOR_CD, CASHIER_NO, TEST_ENTRY_ID, TEST_PASS_YN, TEST_DATE, REPSPSN_NO, SEND_DIV, REG_DATE, UPD_DATE
)
VALUES (
R.CMP_CD, R.STOR_CD, R.CASHIER_NO, R.TEST_ENTRY_ID, R.TEST_PASS_YN, R.TEST_DATE, R.REPSPSN_NO, R.SEND_DIV, R.REG_DATE, R.UPD_DATE
)
]]>
</query>
<!-- 조회 조건 변경 가능할 수도 있음 -->
<!-- 동적으로 where in 절에 binding 안되어서 pivot 테이블 이용해서 처리 -->
<query name="SEL_POSTEST_SEARCH">
<![CDATA[
SELECT TEST_ENTRY_ID, TEST_PASS_YN FROM TR_CASHIER_TEST WHERE TEST_ENTRY_ID IN (
SELECT
TRIM(
SUBSTR
(
','||COL1||',' ,
INSTR(','||COL1||',',',',1, NO)+1 ,
(INSTR(','||COL1||',',',', 1,NO+1)-INSTR(','||COL1||',',',', 1,NO))-1
)
) AS COL2
FROM (
SELECT A.LEN, A.COL1, B.NO FROM (
SELECT LENGTH(A.COL1)-LENGTH(REPLACE(A.COL1,',',''))+1 AS LEN ,
A.COL1
FROM (SELECT ? AS COL1 FROM DUAL) A
) A CROSS JOIN TR_PIVOT B WHERE B.NO <= A.LEN
)
) AND CMP_CD = ?
AND STOR_CD = ?
AND CASHIER_NO = ?
]]>
</query>
<!-- 통합 공지 사항 조회 -->
<query name="SEL_TOTAL_NOTICE">
<![CDATA[
WITH S_WORK AS
(
SELECT ROWNUM AS SEQ
, A.CMP_CD
, A.STOR_CD
, A.EMP_DIV
, A.WORK_DT
, A.WORK_DT || A.WORK_HOUR AS WORK_DATE
FROM SBP.STR_EMP_WORK A
INNER JOIN SBP.MST_STOR B
ON A.CMP_CD = B.CMP_CD
AND A.STOR_CD = B.STOR_CD
WHERE 1 = 1
AND A.CMP_CD = ?
AND B.SALES_ORG_CD = ? -- ORG_CD
AND A.STOR_CD = ?
AND A.WORK_DT BETWEEN TO_CHAR( ADD_MONTHS(SYSDATE, -1), 'YYYYMM' ) || '01' AND TO_CHAR( SYSDATE, 'YYYYMM' ) || '31'
ORDER BY A.STOR_CD
, A.WORK_DT || A.WORK_HOUR
)
, S_WORK_CAL AS
(
SELECT A.CMP_CD
, A.STOR_CD
, A.WORK_DT
, A.SEQ
, B.SEQ AS NEXT_SEQ
, A.EMP_DIV
, B.EMP_DIV NEXT_EMP_DIV
, A.WORK_DATE
, B.WORK_DATE AS WORK_FNSH_DATE
FROM S_WORK A
, S_WORK B
WHERE A.CMP_CD = B.CMP_CD(+)
AND A.STOR_CD = B.STOR_CD(+)
AND A.WORK_DT = B.WORK_DT(+)
AND A.SEQ + 1 = B.SEQ(+)
)
, S_WORK_DT AS
(
SELECT A.CMP_CD
, A.STOR_CD
, A.WORK_DT
, A.EMP_DIV
, A.WORK_DATE
, DECODE (A.WORK_FNSH_DATE, NULL, A.WORK_DT || '999999', A.WORK_FNSH_DATE) AS WORK_FNSH_DATE
FROM S_WORK_CAL A
ORDER BY WORK_DATE
)
SELECT
'01' AS DIV
, NVL( MAX( CASE WHEN MON_FLAG = 'PM' THEN AGV ELSE 0 END ), 0 ) AS VALUE1
, NVL( MAX( CASE WHEN MON_FLAG = 'CM' THEN AGV ELSE 0 END ), 0 ) AS VALUE2
,'' AS VALUE3
,'' AS VALUE4
FROM (
SELECT CMP_CD
, STOR_CD
, SURVY_DATE
, ROUND( SUM( Q1 ) / COUNT(1), 0 ) AS Q_1
, ROUND( SUM( Q2 ) / COUNT(1), 0 ) AS Q_2
, ROUND( SUM( Q3 ) / COUNT(1), 0 ) AS Q_3
, ROUND( ( ROUND( SUM( Q1 ) / COUNT(1), 0 )
+ ROUND( SUM( Q2 ) / COUNT(1), 0 )
+ ROUND( SUM( Q3 ) / COUNT(1), 0 )
) / 3, 0 ) AS AGV
, COUNT(1) AS ANSWRCNT
, CASE WHEN SUBSTR(TO_CHAR( ADD_MONTHS(SYSDATE, -1), 'YYYYMM' ), 1,6) = SURVY_DATE THEN 'PM' ELSE 'CM' END AS MON_FLAG
FROM (
SELECT A.CMP_CD
, A.STOR_CD
, SUBSTR (A.SURVY_DATE, 1, 6) AS SURVY_DATE
, SUM( CASE WHEN ENTRY_CD = '1' THEN (6 - SCORE) * 20 ELSE 0 END ) AS Q1
, SUM( CASE WHEN ENTRY_CD = '2' THEN (6 - SCORE) * 20 ELSE 0 END ) AS Q2
, SUM( CASE WHEN ENTRY_CD = '3' THEN (6 - SCORE) * 20 ELSE 0 END ) AS Q3
FROM SBP.STR_HPC_SURVY_RSLT A
, S_WORK_DT C
WHERE 1=1
AND A.CMP_CD = C.CMP_CD
AND A.STOR_CD = C.STOR_CD
AND A.SURVY_DATE BETWEEN C.WORK_DATE AND C.WORK_FNSH_DATE
AND A.SURVY_DT BETWEEN TO_CHAR( ADD_MONTHS(SYSDATE, -1), 'YYYYMM' ) || '01' AND TO_CHAR( SYSDATE, 'YYYYMM' ) || '31'
GROUP BY A.CMP_CD, A.STOR_CD, A.SURVY_DATE
)
GROUP BY CMP_CD, STOR_CD, SURVY_DATE
) T
UNION
SELECT '02' as div , count(*) AS VALUE1 , 0 AS VALUE2 , '' AS VALUE3 , '' AS VALUE4
FROM ( --위해상품 조회
SELECT ISPCTN_ORGAN_CD
, DOC_NO
, SEQ
, ITEM_NM
, UPD_DATE
FROM MST_DNGR_ITEM
WHERE ? BETWEEN START_DT AND FNSH_DT -- 영업일 3
AND CMP_CD = ? --회사코드 4
AND SALES_ORG_CD =? --BRAND CD 5
MINUS
SELECT
A.ISPCTN_ORGAN_CD
, A.DOC_NO
, A.SEQ
, A.ITEM_NM
, A.UPD_DATE
FROM MST_DNGR_ITEM A , MST_DNGR_ITEM_CONFRM_RSLT B
WHERE ? BETWEEN A.START_DT AND A.FNSH_DT --영업일 6
AND A.CMP_CD = ? --회사코드 7
AND A.SALES_ORG_CD =? --BRAND CD 8
AND A.ISPCTN_ORGAN_CD = B.ISPCTN_ORGAN_CD
AND A.DOC_NO = B.DOC_NO
AND A.SEQ = B.SEQ
AND A.CMP_CD = B.CMP_CD
AND A.SALES_ORG_CD = B.SALES_ORG_CD
AND B.STOR_CD = ? --점코드 9
AND B.AGREE_YN = 'Y'
) A
UNION
SELECT '04' as div , 0 AS VALUE1, 0 AS VALUE2, ITEM_GB AS VALUE3, EARRV_DATE AS VALUE4 -- 배송 정보 brk만 있음
FROM (
SELECT DECODE(CNTR_CD,'D001','20','D003','20', '10' ) AS ITEM_GB -- '10' 제품 , '20' 상품
, TO_CHAR(D1.ARRV_EXPT_DATE, 'yyyy-mm-dd AM hh:mi') AS EARRV_DATE
, '2' div
FROM ORD_IF_DLV_ARRV D1
WHERE D1.DLV_DT = ? -- 영업일 10
AND ( D1.STOR_CD = '20000' || ? -- '2000'은 FIX --점코드 11
OR D1.STOR_CD = '10000' || ? -- '1000'은 FIX --점코드12
OR D1.STOR_CD = '00000' || ? -- '0000'은 FIX --점코드13
OR D1.STOR_CD = ? ) --점코드 14
AND D1.ARRV_REAL_DATE IS NULL
AND D1.ARRV_EXPT_DATE IS NOT NULL -- 2014.07.16 물류팀 김지수대리 요청에 의해 배송기사 등록 배송정보는 제외.
ORDER BY ARRV_EXPT_DATE ASC
) A
WHERE ROWNUM = 1
UNION
SELECT '05' as div , NVL(ORD_QTY,0) AS VALUE1, 0 AS VALUE2, '' AS VALUE3, '' AS VALUE4
FROM ORDER_ESHOP
WHERE BRAND_CD = ? --회사코드15 회사코드 안쓰고 브랜드코드 사용함.
AND STOR_CD = ? --점16
]]>
</query>
<!-- 통합 공지 사항 조회 pari-->
<query name="SEL_TOTAL_NOTICE1">
<![CDATA[
SELECT '01' AS DIV , SUM(CASE WHEN MONTH_DIV ='P' THEN SCORE ELSE 0 END) AS VALUE1 ,
SUM(CASE WHEN MONTH_DIV ='T' THEN SCORE ELSE 0 END) AS VALUE2,
'' AS VALUE3,
'' AS VALUE4
FROM (
SELECT 'P' AS MONTH_DIV
, NVL(ROUND(AVG(SCORE * 20 ), 1), 0) AS SCORE
FROM POS_HPC_RESEARCH_TR RT
WHERE RT.RESEARCH_DT BETWEEN TO_CHAR( SYSDATE, 'YYYYMM' ) || '01000000' AND TO_CHAR( SYSDATE, 'YYYYMM' ) || '31235959'
AND RT.STOR_CD = LPAD( ?, 10, '0' ) -- 1 점
UNION ALL
SELECT 'T' AS MONTH_DIV
, NVL(ROUND(AVG(SCORE * 20 ), 1), 0) AS SCORE
FROM POS_HPC_RESEARCH_TR RT
WHERE RT.RESEARCH_DT BETWEEN TO_CHAR( ADD_MONTHS(SYSDATE, -1), 'YYYYMM' ) || '01000000' AND TO_CHAR( ADD_MONTHS(SYSDATE, -1), 'YYYYMM' ) || '31235959'
AND RT.STOR_CD = LPAD( ?, 10, '0' ) -- 2 점
)A
UNION
SELECT '02' as div , count(*) AS VALUE1 , 0 AS VALUE2 , '' AS VALUE3 , '' AS VALUE4
FROM ( --위해상품 조회
SELECT ISPCTN_ORGAN_CD
, DOC_NO
, SEQ
, ITEM_NM
, UPD_DATE
FROM MST_DNGR_ITEM
WHERE ? BETWEEN START_DT AND FNSH_DT -- 영업일 3
AND CMP_CD = ? --회사코드 4
AND SALES_ORG_CD =? --BRAND CD 5
MINUS
SELECT
A.ISPCTN_ORGAN_CD
, A.DOC_NO
, A.SEQ
, A.ITEM_NM
, A.UPD_DATE
FROM MST_DNGR_ITEM A , MST_DNGR_ITEM_CONFRM_RSLT B
WHERE ? BETWEEN A.START_DT AND A.FNSH_DT --영업일 6
AND A.CMP_CD = ? --회사코드 7
AND A.SALES_ORG_CD =? --BRAND CD 8
AND A.ISPCTN_ORGAN_CD = B.ISPCTN_ORGAN_CD
AND A.DOC_NO = B.DOC_NO
AND A.SEQ = B.SEQ
AND A.CMP_CD = B.CMP_CD
AND A.SALES_ORG_CD = B.SALES_ORG_CD
AND B.STOR_CD = ? --점코드 9
AND B.AGREE_YN = 'Y'
) A
UNION
SELECT '05' as div , NVL(ORD_QTY,0) AS VALUE1, 0 AS VALUE2, '' AS VALUE3, '' AS VALUE4
FROM ORDER_ESHOP
WHERE BRAND_CD = ? --회사코드15
AND STOR_CD = ?
]]>
</query>
<!-- 선불 고객 LOG 등록 SQL -->
<query name="INS_INFRA_DATA">
<![CDATA[
INSERT INTO TR_INFRA_SETUPDATA
( INS_YMDHMS,BRAND_CD,STOR_CD,POS_NO,SETUP_STATUS )
VALUES
( TO_CHAR(SYSDATE,'YYYYMMDDhh24miss'),?,?,?,?)
]]>
</query>
<!-- 선불 고객 LOG 등록 SQL -->
<query name="TR_ROS_STOR_EMP_TIME_STAMP">
<![CDATA[
INSERT INTO TR_ROS_STOR_EMP_TIME_STAMP
( CMP_CD , STOR_CD , EMP_NO , WORK_DT , ROS_CD
,SEQ , HOUR_STAMP , ROS_HOUR , REG_USER_ID , REG_DATE
,REG_DIV)
VALUES
( ? ,? ,? ,? ,?
,? ,TO_DATE(? ,'YYYYMMDDHH24MISS') ,? ,? ,sysdate
,'0')
]]>
</query>
<!-- SET WORK MODE SQL -->
<query name="INS_SET_STOR_WORKDATA">
<![CDATA[
INSERT INTO STR_EMP_WORK
( CMP_CD , STOR_CD , WORK_DT , WORK_HOUR , EMP_DIV
, POS_NO ,REG_USER_ID , REG_DATE , UPD_USER_ID , UPD_DATE )
VALUES
( ? ,? ,? ,? ,?
,? ,'POS' ,SYSDATE ,'POS' ,SYSDATE)
]]>
</query>
<!-- CPI LINE ORDER COUNT SQL -->
<query name="SEL_STR_STOR_INSPCT_ANSWR_STOR">
<![CDATA[
SELECT *
FROM STR_STOR_INSPCT_ANSWR_STOR
WHERE 1 = 1
AND CMP_CD = ?
AND STOR_CD = ?
AND INSPCT_ENTRY_GRP_CD = ?
AND START_DT = ?
AND ANSWR_YN = '1'
]]>
</query>
<!-- 임시 SELECT 문 공통코드 테이블에서 조회로 변경해야함. -->
<query name="SEL_POSSYSTEM_DATE">
<![CDATA[
SELECT TO_CHAR(FN_GET_SYSDATE(?)- ?,'YYYYMMDDHH24MISS') AS SYS_DATE FROM DUAL
]]>
</query>
<!--store TBL DATA DELETE SQL -->
<query name="DEL_POSFLOOR_DATA">
<![CDATA[
DELETE POS_MST_FLOOR
WHERE CMP_CD =?
AND STOR_CD =?
]]>
</query>
<!--store TBL DATA DELETE SQL -->
<query name="DEL_POSTBL_DATA">
<![CDATA[
DELETE POS_MST_TBL
WHERE CMP_CD =?
AND STOR_CD =?
]]>
</query>
<!--store TBL DATA insert SQL -->
<query name="INS_POSFLOOR_DATASAVE">
<![CDATA[
INSERT INTO POS_MST_FLOOR
( CMP_CD ,STOR_CD ,FLOOR_CD ,FLOOR_NM ,FILLER_1
,FILLER_2 ,FILLER_3 ,FILLER_4 ,FILLER_5 ,USE_YN
,REG_USER_ID ,REG_DATE ,UPD_USER_ID ,UPD_DATE )
VALUES
( ? ,? ,? ,? ,?
,? ,? ,? ,? ,?
,? ,TO_DATE(? ,'YYYYMMDDHH24MISS') ,? ,TO_DATE(? ,'YYYYMMDDHH24MISS'))
]]>
</query>
<!--store TBL DATA insert SQL -->
<query name="INS_POSTBL_DATASAVE">
<![CDATA[
INSERT INTO POS_MST_TBL
( CMP_CD ,STOR_CD ,FLOOR_CD ,TBL_NO ,TBL_NM
,TBL_TYPE ,TBL_SHAPE ,BACKGR_COLOR ,BACKGR_IMG ,FONT_COLOR
,FONT_NM ,FONT_SIZE ,LOC_X ,LOC_Y ,WIDTH
,HGT ,DISP_DIV ,SEAT_CNT ,SEAT_CNT_DISP_DIV ,OPERATE_DIV
,OPERATE_FLOOR_CD ,OPERATE_TBL_NO ,ORD_CMPT_COLOR ,PAY_CMPT_COLOR ,FILLER_1
,FILLER_2 ,FILLER_3 ,FILLER_4 ,FILLER_5 ,USE_YN
,REG_USER_ID ,REG_DATE ,UPD_USER_ID ,UPD_DATE)
VALUES
( ? ,? ,? ,? ,?
,? ,? ,? ,? ,?
,? ,? ,? ,? ,?
,? ,? ,? ,? ,?
,? ,? ,? ,? ,?
,? ,? ,? ,? ,?
,? ,TO_DATE(? ,'YYYYMMDDHH24MISS') ,? ,TO_DATE(? ,'YYYYMMDDHH24MISS'))
]]>
</query>
<!--store TBL DATA DELETE SQL -->
<query name="SEL_POSFLOOR_DATA">
<![CDATA[
SELECT CMP_CD ,STOR_CD ,FLOOR_CD ,FLOOR_NM ,FILLER_1
,FILLER_2 ,FILLER_3 ,FILLER_4 ,FILLER_5 ,USE_YN
,REG_USER_ID ,TO_CHAR(NVL(REG_DATE,SYSDATE),'YYYYMMDDHH24MISS') REG_DATE ,UPD_USER_ID ,TO_CHAR(NVL(UPD_DATE,SYSDATE),'YYYYMMDDHH24MISS') UPD_DATE
FROM POS_MST_FLOOR
WHERE CMP_CD =?
AND STOR_CD =?
]]>
</query>
<!--store TBL DATA DELETE SQL -->
<query name="SEL_POSTBL_DATA">
<![CDATA[
SELECT CMP_CD ,STOR_CD ,FLOOR_CD ,TBL_NO ,TBL_NM
,TBL_TYPE ,TBL_SHAPE ,BACKGR_COLOR ,BACKGR_IMG ,FONT_COLOR
,FONT_NM ,FONT_SIZE ,LOC_X ,LOC_Y ,WIDTH
,HGT ,DISP_DIV ,SEAT_CNT ,SEAT_CNT_DISP_DIV ,OPERATE_DIV
,OPERATE_FLOOR_CD ,OPERATE_TBL_NO ,ORD_CMPT_COLOR ,PAY_CMPT_COLOR ,FILLER_1
,FILLER_2 ,FILLER_3 ,FILLER_4 ,FILLER_5 ,USE_YN
,REG_USER_ID ,TO_CHAR(NVL(REG_DATE,SYSDATE),'YYYYMMDDHH24MISS') REG_DATE ,UPD_USER_ID ,TO_CHAR(NVL(UPD_DATE,SYSDATE),'YYYYMMDDHH24MISS') UPD_DATE
FROM POS_MST_TBL
WHERE CMP_CD =?
AND STOR_CD =?
]]>
</query>
<!-- 점포 점검 리스트 추가 -->
<query name="MER_STR_STOR_INSPCT_ANSWR_STOR">
<![CDATA[
MERGE INTO STR_STOR_INSPCT_ANSWR_STOR I
USING ( SELECT ? AS CMP_CD,
? AS INSPCT_ENTRY_GRP_CD,
? AS STOR_CD,
? AS START_DT,
? AS ANSWR_YN,
? AS ETC_CTNTS_1,
? AS ETC_CTNTS_2,
? AS ETC_CTNTS_3,
? AS REG_USER_ID,
TO_DATE(? ,'YYYYMMDDHH24MISS') AS RET_DATE,
? AS UPD_USER_ID,
TO_DATE(? ,'YYYYMMDDHH24MISS') AS UPD_DATE
FROM DUAL
) U
ON ( I.CMP_CD = U.CMP_CD
AND I.INSPCT_ENTRY_GRP_CD = U.INSPCT_ENTRY_GRP_CD
AND I.STOR_CD = U.STOR_CD
AND I.START_DT = U.START_DT
)
WHEN MATCHED THEN
UPDATE SET I.ANSWR_YN = U.ANSWR_YN
,I.ETC_CTNTS_1 = U.ETC_CTNTS_1
,I.ETC_CTNTS_2 = U.ETC_CTNTS_2
,I.ETC_CTNTS_3 = U.ETC_CTNTS_3
,I.UPD_DATE = U.UPD_DATE
WHEN NOT MATCHED THEN
INSERT (
CMP_CD ,INSPCT_ENTRY_GRP_CD ,STOR_CD ,START_DT ,ANSWR_YN
,ETC_CTNTS_1 ,ETC_CTNTS_2 ,ETC_CTNTS_3 , REG_USER_ID , REG_DATE
,UPD_USER_ID ,UPD_DATE
)
VALUES (
U.CMP_CD ,U.INSPCT_ENTRY_GRP_CD ,U.STOR_CD ,U.START_DT ,U.ANSWR_YN
, U.ETC_CTNTS_1 ,U.ETC_CTNTS_2 ,U.ETC_CTNTS_3 ,U.REG_USER_ID ,U.RET_DATE
, U.UPD_USER_ID ,U.UPD_DATE
)
]]>
</query>
<!-- 점포 점검 응답 dtl 추가 -->
<query name="MER_STR_STOR_INSPCT_ANSWR_DTL">
<![CDATA[
MERGE INTO STR_STOR_INSPCT_ANSWR I
USING ( SELECT ? AS CMP_CD,
? AS SALES_ORG_CD,
? AS INSPCT_ENTRY_GRP_CD,
? AS STOR_CD,
? AS START_DT,
? AS INSPCT_ENTRY_L_CLSS_CD,
? AS INSPCT_ENTRY,
? AS SEL_ENTRY_1_YN,
? AS SEL_ENTRY_2_YN,
? AS SEL_ENTRY_3_YN,
? AS SEL_ENTRY_4_YN,
? AS SEL_ENTRY_5_YN,
? AS SCORE_1,
? AS SCORE_2,
? AS SCORE_3,
? AS SCORE_4,
? AS SCORE_5,
? AS SEL_ENTRY_1_CTNTS,
? AS SEL_ENTRY_2_CTNTS,
? AS SEL_ENTRY_3_CTNTS,
? AS SEL_ENTRY_4_CTNTS,
? AS SEL_ENTRY_5_CTNTS,
? AS NOTE ,
? AS REG_USER_ID,
TO_DATE(? ,'YYYYMMDDHH24MISS') AS RET_DATE,
? AS UPD_USER_ID,
TO_DATE(? ,'YYYYMMDDHH24MISS') AS UPD_DATE
FROM DUAL
) U
ON ( I.CMP_CD = U.CMP_CD
AND I.SALES_ORG_CD = U.SALES_ORG_CD
AND I.INSPCT_ENTRY_GRP_CD = U.INSPCT_ENTRY_GRP_CD
AND I.STOR_CD = U.STOR_CD
AND I.START_DT = U.START_DT
AND I.INSPCT_ENTRY_L_CLSS_CD = U.INSPCT_ENTRY_L_CLSS_CD
AND I.INSPCT_ENTRY = U.INSPCT_ENTRY
)
WHEN MATCHED THEN
UPDATE SET I.SEL_ENTRY_1_YN = U.SEL_ENTRY_1_YN
,I.SEL_ENTRY_2_YN = U.SEL_ENTRY_2_YN
,I.SEL_ENTRY_3_YN = U.SEL_ENTRY_3_YN
,I.SEL_ENTRY_4_YN = U.SEL_ENTRY_4_YN
,I.SEL_ENTRY_5_YN = U.SEL_ENTRY_5_YN
,I.SCORE_1 = U.SCORE_1
,I.SCORE_2 = U.SCORE_2
,I.SCORE_3 = U.SCORE_3
,I.SCORE_4 = U.SCORE_4
,I.SCORE_5 = U.SCORE_5
,I.SEL_ENTRY_1_CTNTS =U.SEL_ENTRY_1_CTNTS
,I.SEL_ENTRY_2_CTNTS =U.SEL_ENTRY_2_CTNTS
,I.SEL_ENTRY_3_CTNTS =U.SEL_ENTRY_3_CTNTS
,I.SEL_ENTRY_4_CTNTS =U.SEL_ENTRY_4_CTNTS
,I.SEL_ENTRY_5_CTNTS =U.SEL_ENTRY_5_CTNTS
,I.NOTE =U.NOTE
,I.UPD_USER_ID = U.UPD_USER_ID
,I.UPD_DATE = U.UPD_DATE
WHEN NOT MATCHED THEN
INSERT (
CMP_CD ,SALES_ORG_CD ,INSPCT_ENTRY_GRP_CD ,STOR_CD ,START_DT ,INSPCT_ENTRY_L_CLSS_CD ,INSPCT_ENTRY
,SEL_ENTRY_1_YN ,SEL_ENTRY_2_YN ,SEL_ENTRY_3_YN ,SEL_ENTRY_4_YN ,SEL_ENTRY_5_YN
,SCORE_1 ,SCORE_2 ,SCORE_3 ,SCORE_4 ,SCORE_5
,SEL_ENTRY_1_CTNTS ,SEL_ENTRY_2_CTNTS ,SEL_ENTRY_3_CTNTS ,SEL_ENTRY_4_CTNTS ,SEL_ENTRY_5_CTNTS
,NOTE , REG_USER_ID , REG_DATE ,UPD_USER_ID ,UPD_DATE
)
VALUES (
U.CMP_CD ,U.SALES_ORG_CD ,U.INSPCT_ENTRY_GRP_CD ,U.STOR_CD ,U.START_DT ,U.INSPCT_ENTRY_L_CLSS_CD ,U.INSPCT_ENTRY
,U.SEL_ENTRY_1_YN ,U.SEL_ENTRY_2_YN ,U.SEL_ENTRY_3_YN ,U.SEL_ENTRY_4_YN ,U.SEL_ENTRY_5_YN
,U.SCORE_1 ,U.SCORE_2 ,U.SCORE_3 ,U.SCORE_4 ,U.SCORE_5
,U.SEL_ENTRY_1_CTNTS ,U.SEL_ENTRY_2_CTNTS ,U.SEL_ENTRY_3_CTNTS ,U.SEL_ENTRY_4_CTNTS ,U.SEL_ENTRY_5_CTNTS
,U.NOTE ,U.REG_USER_ID ,U.RET_DATE ,U.UPD_USER_ID ,U.UPD_DATE
)
]]>
</query>
<query name="SEL_POS_INSTALL_SCHEDULE">
<![CDATA[
SELECT *
FROM POS_INSTALL_SCHEDULE
WHERE 1 = 1
AND CMP_CD = ?
AND STOR_CD = ?
AND USE_FLAG ='1'
]]>
</query>
<query name="UPD_POS_INSTALL_SCHEDULE">
<![CDATA[
UPDATE POS_INSTALL_SCHEDULE
SET POS_COMPLETE = TO_CHAR(SYSDATE,'YYYYMMDD')
,POS_COMPLETE_TM = TO_CHAR(SYSDATE,'HH24MISS')
,UP_TYPE = '3'
,UPD_DATE = SYSDATE
,UPD_USER_ID = 'POS DAEMON'
WHERE 1 = 1
AND CMP_CD = ?
AND STOR_CD = ?
AND POS_COMPLETE IS NULL
]]>
</query>
<query name="MER_POS_INSTALL_STATUS">
<![CDATA[
MERGE INTO POS_INSTALL_STATUS T
USING ( SELECT ? AS CMP_CD,
? AS STOR_CD,
? AS POS_NO,
? AS INS_STATUS,
? AS INS_RESULT,
? AS REMARKS,
'DAEMON' AS REG_USER_ID,
SYSDATE AS REG_DATE,
'DAEMON' AS UPD_USER_ID,
SYSDATE AS UPD_DATE
FROM DUAL
) R
ON ( T.CMP_CD = R.CMP_CD
AND T.STOR_CD = R.STOR_CD
AND T.POS_NO = R.POS_NO
AND T.INS_STATUS = R.INS_STATUS
)
WHEN MATCHED THEN
UPDATE SET T.INS_RESULT = R.INS_RESULT
,T.REMARKS = R.REMARKS
,T.UPD_DATE = R.UPD_DATE
WHEN NOT MATCHED THEN
INSERT (
CMP_CD, STOR_CD, POS_NO, INS_STATUS, INS_RESULT,
REMARKS, REG_USER_ID, REG_DATE, UPD_USER_ID, UPD_DATE
)
VALUES (
R.CMP_CD, R.STOR_CD, R.POS_NO, R.INS_STATUS, R.INS_RESULT,
R.REMARKS, R.REG_USER_ID , R.REG_DATE, R.UPD_USER_ID , R.UPD_DATE
)
]]>
</query>
<query name="MER_POS_INSTALL_LOG">
<![CDATA[
MERGE INTO POS_INSTALL_LOG T
USING ( SELECT ? AS CMP_CD,
? AS STOR_CD,
? AS POS_NO,
? AS LOG_TIME,
? AS LOG_TYPE,
? AS DATA,
'DAEMON' AS REG_USER_ID,
SYSDATE AS REG_DATE,
'DAEMON' AS UPD_USER_ID,
SYSDATE AS UPD_DATE
FROM DUAL
) R
ON ( T.CMP_CD = R.CMP_CD
AND T.STOR_CD = R.STOR_CD
AND T.POS_NO = R.POS_NO
AND T.LOG_TIME = R.LOG_TIME
)
WHEN MATCHED THEN
UPDATE SET T.LOG_TYPE = R.LOG_TYPE
,T.DATA = R.DATA
,T.UPD_DATE = R.UPD_DATE
WHEN NOT MATCHED THEN
INSERT (
CMP_CD, STOR_CD, POS_NO, LOG_TIME, LOG_TYPE,
DATA, REG_USER_ID, REG_DATE, UPD_USER_ID, UPD_DATE
)
VALUES (
R.CMP_CD, R.STOR_CD, R.POS_NO, R.LOG_TIME, R.LOG_TYPE,
R.DATA, R.REG_USER_ID , R.REG_DATE, R.UPD_USER_ID , R.UPD_DATE
)
]]>
</query>
<!-- XMAS 예약 -->
<query name="MER_XMAX_RESERV">
<![CDATA[
MERGE INTO SAL_RESERV_NO T
USING ( SELECT ? AS SALE_DT,
? AS STOR_CD,
? AS POS_NO,
? AS BILL_NO,
? AS RESERV_NO,
SYSDATE AS REG_DATE,
SYSDATE AS UPD_DATE
FROM DUAL
) R
ON ( T.SALE_DT = R.SALE_DT
AND T.STOR_CD = R.STOR_CD
AND T.BILL_NO = R.BILL_NO
AND T.POS_NO = R.POS_NO
)
WHEN MATCHED THEN
UPDATE SET T.RESERV_NO = R.RESERV_NO
,T.UPD_DATE = R.UPD_DATE
WHEN NOT MATCHED THEN
INSERT ( SALE_DT ,STOR_CD ,BILL_NO ,POS_NO ,RESERV_NO
,REG_DATE ,UPD_DATE
)
VALUES (
R.SALE_DT ,R.STOR_CD ,R.BILL_NO ,R.POS_NO ,R.RESERV_NO
,R.REG_DATE ,R.UPD_DATE
)
]]>
</query>
<!-- 임시 SELECT 문 공통코드 테이블에서 조회로 변경해야함. -->
<query name="SEL_DEL_IMG_LST">
<![CDATA[
SELECT IMG_FILE_NM
FROM MST_ITEM_INTRO_HIST A , SYS_ATTCH_FILE_MNG B
WHERE 1= 1
AND A.CMP_CD = ?
AND A.HIST_DT = ?
AND A.IMG_FILE_ID = B.FILE_NO
]]>
</query>
<!-- 임시 SELECT 문 공통코드 테이블에서 조회로 변경해야함. -->
<query name="SEL_SALESORG_LST">
<![CDATA[
SELECT SALES_ORG_CD FROM MST_SALESORG
WHERE 1= 1
AND CMP_CD = ?
AND USE_YN ='1'
ORDER BY SALES_ORG_CD
]]>
</query>
<!-- 임시 SELECT 문 공통코드 테이블에서 조회로 변경해야함. -->
<query name="SEL_CUSTOMER_FILE_LST">
<![CDATA[
SELECT
A.SALES_ORG_CD
,A.FILE_NM AS FILE_NM --없음
FROM POS_MST_CUST_SCRN A --LEFT JOIN SYS_ATTCH_FILE_MNG B
--ON A.FILE_ID = B.FILE_NO
WHERE 1=1
AND A.CMP_CD= ?
AND A.USE_YN ='1'
AND TO_CHAR(SYSDATE,'YYYYMMDD') BETWEEN USE_STARTDAY AND USE_FNSHDAY
]]>
</query>
<!-- 임시 SELECT 문 공통코드 테이블에서 조회로 변경해야함. -->
<query name="SEL_WAT_FILE_LIST">
<![CDATA[
SELECT DISTINCT
CASE WHEN FILE_DIV ='04' AND FILE_SUB_DIV ='1' THEN FILE_NM || '_FULL' ELSE FILE_NM END AS FILE_NM
FROM MST_SALESORG_ITEM ITEM ,
WAT_POS_MST_FILE_LIST LST
WHERE 1 = 1
AND ITEM.ITEM_CD = LST.FILE_NM
AND ITEM.CMP_CD = ?
AND ITEM.SALES_ORG_CD= ?
AND LST.FILE_DIV = ?
AND LST.FILE_SUB_DIV = ?
AND LST.MDF_DATE >= TO_CHAR(SYSDATE-30,'yyyyMMdd')
]]>
</query>
<!-- 임시 SELECT 문 공통코드 테이블에서 조회로 변경해야함. -->
<query name="SEL_WAT_CPI_IMG_LIST">
<![CDATA[
SELECT W.FILE_NM FROM WAT_POS_MST_FILE_LIST W,
(
SELECT
B.FILE_SAVE_NM AS FILE_NM
FROM CPI_MST A ,
SYS_ATTCH_FILE_MNG B
WHERE A.CMP_CD = B.CMP_CD
AND A.CMP_CD = ?
AND A.SALES_ORG_CD =?
AND A.CUST_FACE_RSCE_FILE_ID =B.FILE_NO
AND A.FNSH_DT <= TO_CHAR(SYSDATE,'yyyyMMdd')
UNION
SELECT
B.FILE_SAVE_NM AS FILE_NM
FROM CPI_MST A ,
SYS_ATTCH_FILE_MNG B
WHERE A.CMP_CD = B.CMP_CD
AND A.CMP_CD = ?
AND A.SALES_ORG_CD =?
AND A.SOUND_FILE_ID =B.FILE_NO
AND A.FNSH_DT <= TO_CHAR(SYSDATE,'yyyyMMdd')
) A
WHERE W.FILE_NM = A.FILE_NM
AND W.MDF_DATE >= TO_CHAR(SYSDATE-3,'yyyyMMdd')
AND W.FILE_DIV ='05'
]]>
</query>
<!-- 임시 SELECT 문 공통코드 테이블에서 조회로 변경해야함. -->
<query name="SEL_WAT_TEST_IMG_LIST">
<![CDATA[
SELECT W.FILE_NM FROM WAT_POS_MST_FILE_LIST W,
(
SELECT
DISTINCT C.FILE_SAVE_NM AS FILE_NM
FROM POS_MST_EXAM_MODE_DTL_LOC A
INNER JOIN POS_MST_EXAM_MODE B
ON A.CMP_CD = B.CMP_CD
AND A.SALES_ORG_CD= B.SALES_ORG_CD
AND A.EXAM_ENTRY_ID = B.EXAM_ENTRY_ID
AND B.USE_YN='1'
LEFT JOIN SYS_ATTCH_FILE_MNG C
ON A.FILE_ID = C.FILE_NO
WHERE A.CMP_CD = ?
AND A.SALES_ORG_CD = ?
) A
WHERE W.FILE_NM = A.FILE_NM
AND W.MDF_DATE >= TO_CHAR(SYSDATE-3,'yyyyMMdd')
AND W.FILE_DIV ='06'
]]>
</query>
<query name="MER_POS_WAT_FILE_LIST">
<![CDATA[
MERGE INTO WAT_POS_MST_FILE_LIST T
USING ( SELECT ? AS FILE_DIV,
? AS FILE_NM,
? AS FILE_SUB_DIV,
? AS MDF_DATE ,
SYSDATE AS REG_DATE
FROM DUAL
) R
ON ( T.FILE_DIV = R.FILE_DIV
AND T.FILE_NM = R.FILE_NM
AND T.FILE_SUB_DIV = R.FILE_SUB_DIV
)
WHEN MATCHED THEN
UPDATE SET T.MDF_DATE = R.MDF_DATE
,T.REG_DATE = R.REG_DATE
WHEN NOT MATCHED THEN
INSERT (
FILE_DIV, FILE_NM, FILE_SUB_DIV ,MDF_DATE, REG_DATE
)
VALUES (
R.FILE_DIV, R.FILE_NM, R.FILE_SUB_DIV ,R.MDF_DATE, R.REG_DATE
)
]]>
</query>
<!-- 임시 SELECT 문 공통코드 테이블에서 조회로 변경해야함. -->
<query name="SEL_CDP_COM_FILE_LST">
<![CDATA[
SELECT * FROM (
SELECT SALES_ORG_CD, TRIM(FILE_SAVE_NM) AS FILE_NM
FROM POS_MST_SCRN_COMPNT A LEFT JOIN SYS_ATTCH_FILE_MNG B
ON A.LOGIN_IMG_FILE_ID = B.FILE_NO
AND B.FILE_QUE_NO = '1'
WHERE A.CMP_CD = ?
UNION
SELECT SALES_ORG_CD,TRIM(FILE_SAVE_NM) AS FILE_NM
FROM POS_MST_SCRN_COMPNT A LEFT JOIN SYS_ATTCH_FILE_MNG B
ON A.BRAND_CI_IMG_FILE_ID = B.FILE_NO
AND B.FILE_QUE_NO = '1'
WHERE A.CMP_CD = ?
UNION
SELECT SALES_ORG_CD,TRIM(FILE_SAVE_NM) AS FILE_NM
FROM POS_MST_SCRN_COMPNT A LEFT JOIN SYS_ATTCH_FILE_MNG B
ON A.MAIN_IMG_FILE_ID = B.FILE_NO
AND B.FILE_QUE_NO = '1'
WHERE A.CMP_CD = ?
UNION
SELECT SALES_ORG_CD,TRIM(FILE_SAVE_NM) AS FILE_NM
FROM POS_MST_SCRN_COMPNT A LEFT JOIN SYS_ATTCH_FILE_MNG B
ON A.WAIT_IMG_FILE_ID = B.FILE_NO
WHERE A.CMP_CD = ?
UNION
SELECT
A.SALES_ORG_CD
,TRIM(B.FILE_SAVE_NM) AS FILE_NM
FROM POS_MST_MOT_MSG A LEFT JOIN SYS_ATTCH_FILE_MNG B
ON A.FILE_ID = B.FILE_NO
WHERE A.CMP_CD = ?
UNION
SELECT
A.SALES_ORG_CD
,TRIM(B.FILE_SAVE_NM) AS FILE_NM
FROM POS_MST_MOT_MSG A LEFT JOIN SYS_ATTCH_FILE_MNG B
ON A.SOUND_FILE_ID = B.FILE_NO
WHERE A.CMP_CD = ?
) A
WHERE LENGTH(FILE_NM)> 0
]]>
</query>
<query name="SEL_CDPCOM_BRAND_FILE_LST">
<![CDATA[
SELECT W.FILE_NM FROM WAT_POS_MST_FILE_LIST W,
(
SELECT TRIM(FILE_SAVE_NM) AS FILE_NM
FROM POS_MST_SCRN_COMPNT A LEFT JOIN SYS_ATTCH_FILE_MNG B
ON A.LOGIN_IMG_FILE_ID = B.FILE_NO
AND B.FILE_QUE_NO = '1'
WHERE A.CMP_CD = ?
AND A.SALES_ORG_CD = ?
AND A.USE_YN ='1'
AND B.FILE_SAVE_NM IS NOT NULL
UNION
SELECT TRIM(FILE_SAVE_NM) AS FILE_NM
FROM POS_MST_SCRN_COMPNT A LEFT JOIN SYS_ATTCH_FILE_MNG B
ON A.BRAND_CI_IMG_FILE_ID = B.FILE_NO
AND B.FILE_QUE_NO = '1'
WHERE A.CMP_CD = ?
AND A.SALES_ORG_CD = ?
AND A.USE_YN ='1'
AND B.FILE_SAVE_NM IS NOT NULL
UNION
SELECT TRIM(FILE_SAVE_NM) AS FILE_NM
FROM POS_MST_SCRN_COMPNT A LEFT JOIN SYS_ATTCH_FILE_MNG B
ON A.MAIN_IMG_FILE_ID = B.FILE_NO
AND B.FILE_QUE_NO = '1'
WHERE A.CMP_CD = ?
AND A.SALES_ORG_CD = ?
AND A.USE_YN ='1'
AND B.FILE_SAVE_NM IS NOT NULL
UNION
SELECT TRIM(FILE_SAVE_NM) AS FILE_NM
FROM POS_MST_SCRN_COMPNT A LEFT JOIN SYS_ATTCH_FILE_MNG B
ON A.WAIT_IMG_FILE_ID = B.FILE_NO
AND B.FILE_QUE_NO = '1'
WHERE A.CMP_CD = ?
AND A.SALES_ORG_CD = ?
AND A.USE_YN ='1'
AND B.FILE_SAVE_NM IS NOT NULL
UNION
SELECT TRIM(B.FILE_SAVE_NM) AS FILE_NM
FROM POS_MST_MOT_MSG A LEFT JOIN SYS_ATTCH_FILE_MNG B
ON A.FILE_ID = B.FILE_NO
AND B.FILE_QUE_NO = '1'
WHERE A.CMP_CD = ?
AND A.SALES_ORG_CD = ?
AND A.USE_YN ='1'
AND B.FILE_SAVE_NM IS NOT NULL
UNION
SELECT
TRIM(B.FILE_SAVE_NM) AS FILE_NM
FROM POS_MST_MOT_MSG A LEFT JOIN SYS_ATTCH_FILE_MNG B
ON A.SOUND_FILE_ID = B.FILE_NO
AND B.FILE_QUE_NO = '1'
WHERE A.CMP_CD = ?
AND A.SALES_ORG_CD =?
AND A.USE_YN ='1'
AND B.FILE_SAVE_NM IS NOT NULL
) A
WHERE W.FILE_NM = A.FILE_NM
AND W.MDF_DATE >= TO_CHAR(SYSDATE-3,'yyyyMMdd')
AND W.FILE_DIV ='07'
]]>
</query>
<!-- 임시 SELECT 문 공통코드 테이블에서 조회로 변경해야함. -->
<query name="DEL_POS_MST_TOUCHKEY">
<![CDATA[
DELETE POS_INSTALL_MST_TOUCHKEY
WHERE 1= 1
AND CMP_CD = ?
AND STOR_CD = ?
AND POS_NO = ?
]]>
</query>
<!--POS_INSTALL_MST_TOUCHKEY insert SQL -->
<query name="INS_POS_MST_TOUCHKEY">
<![CDATA[
INSERT INTO POS_INSTALL_MST_TOUCHKEY
( CMP_CD ,STOR_CD ,POS_NO ,KEY_DIV ,KEY_TYPE
,KEY_CLASS ,KEY_ITEM ,KEY_NM ,KEY_POS ,MST_IF_DIV ,MST_IF_DATE
,REG_USER_ID ,REG_DATE )
VALUES
( ? ,? ,? ,? ,?
,? ,? ,? ,? ,'0' ,SYSDATE
,'POSDAEMON' ,SYSDATE)
]]>
</query>
<!-- 임시 SELECT 문 공통코드 테이블에서 조회로 변경해야함. -->
<query name="DEL_POS_MST_FLAVOR">
<![CDATA[
DELETE POS_INSTALL_MST_FLAVOR
WHERE 1= 1
AND CMP_CD = ?
AND STOR_CD = ?
AND POS_NO = ?
]]>
</query>
<!--store TBL DATA insert SQL -->
<query name="INS_POS_MST_FLAVOR">
<![CDATA[
INSERT INTO POS_INSTALL_MST_FLAVOR
( CMP_CD ,STOR_CD ,POS_NO ,ITEM_POS ,ITEM_CD
,MST_IF_DIV ,MST_IF_DATE ,REG_USER_ID ,REG_DATE )
VALUES
( ? ,? ,? ,? ,?
,'0' ,SYSDATE ,'POSDAEMON' ,SYSDATE)
]]>
</query>
<!-- 임시 SELECT 문 공통코드 테이블에서 조회로 변경해야함. -->
<query name="DEL_POS_MST_POSTOPT">
<![CDATA[
DELETE POS_INSTALL_MST_POSTOPT
WHERE 1= 1
AND CMP_CD = ?
AND STOR_CD = ?
AND POS_NO = ?
]]>
</query>
<!--store TBL DATA insert SQL -->
<query name="INS_POS_INSTALL_MST_POSTOPT">
<![CDATA[
INSERT INTO POS_INSTALL_MST_POSTOPT
( CMP_CD ,STOR_CD ,POS_NO ,OPTN_CD ,OPTN_VAL
,MST_IF_DIV ,MST_IF_DATE ,REG_USER_ID ,REG_DATE )
VALUES
( ? ,? ,? ,? ,?
,'0' ,SYSDATE ,'POSDAEMON' ,SYSDATE)
]]>
</query>
<!-- 임시 SELECT 문 공통코드 테이블에서 조회로 변경해야함. -->
<query name="DEL_POS_MST_KPS">
<![CDATA[
DELETE POS_INSTALL_MST_KPS
WHERE 1= 1
AND CMP_CD = ?
AND STOR_CD = ?
AND POS_NO = ?
]]>
</query>
<!--POS_INSTALL_POS_MST_KPS insert SQL -->
<query name="INS_POS_MST_KPS">
<![CDATA[
INSERT INTO POS_INSTALL_MST_KPS
( CMP_CD ,STOR_CD ,POS_NO ,KPS_SYS_CD ,KPS_SYS_NM
,KPS_USE_DIV ,KPS_COM_PORT ,KPS_COM_BAUD ,KPS_NET_IP ,KPS_NET_PORT
,MST_IF_DIV ,MST_IF_DATE ,REG_USER_ID ,REG_DATE )
VALUES
( ? ,? ,? ,? ,?
,? ,? ,? ,? ,?
,'0' ,SYSDATE ,'POSDAEMON' ,SYSDATE)
]]>
</query>
<!--POS_INSTALL_POS_MST_KPS insert SQL -->
<query name="INS_POS_MST_KPS_1">
<![CDATA[
INSERT INTO POS_INSTALL_MST_KPS
( CMP_CD ,STOR_CD ,POS_NO ,KPS_SYS_CD ,KPS_SYS_NM
,KPS_USE_DIV ,KPS_COM_PORT ,KPS_COM_BAUD ,KPS_NET_IP ,KPS_NET_PORT
,MST_IF_DIV ,MST_IF_DATE ,REG_USER_ID ,REG_DATE ,KTCH_SYS_DIV)
VALUES
( ? ,? ,? ,? ,?
,? ,? ,? ,? ,?
,'0' ,SYSDATE ,'POSDAEMON' ,SYSDATE ,?)
]]>
</query>
<!-- 임시 SELECT 문 공통코드 테이블에서 조회로 변경해야함. -->
<query name="DEL_POS_MST_POSTRMNL">
<![CDATA[
DELETE POS_INSTALL_MST_POSTRMNL
WHERE 1= 1
AND CMP_CD = ?
AND STOR_CD = ?
AND POS_NO = ?
]]>
</query>
<!--POS_INSTALL_MST_POSTRMNL insert SQL -->
<query name="INS_POS_INSTALL_MST_POSTRMNL">
<![CDATA[
INSERT INTO POS_INSTALL_MST_POSTRMNL
( CMP_CD ,STOR_CD ,POS_NO ,POS_IP ,POS_DIV
,MAIN_YN ,SCR_SIZE ,CARD_READER ,CAT_TRMNL ,MST_IF_DIV
,MST_IF_DATE ,REG_USER_ID ,REG_DATE )
VALUES
( ? ,? ,? ,? ,?
,? ,? ,? ,? ,'0'
,SYSDATE ,'POSDAEMON' ,SYSDATE)
]]>
</query>
<!-- china prepaycard list -->
<query name="SEL_CHN_PREPAYCARD_ALLLIST">
<![CDATA[
SELECT
A.GIF_VRTY , A.GIF_NO , NVL(B.GIF_FACE_AMT,0) AS GIF_FACE_AMT
FROM GIF_PPCARD_SHPMNT_DESC A
INNER JOIN GIF_VRTY B
ON A.GIF_VRTY = B.GIF_VRTY
AND B.GIF_TYPE ='20'
WHERE 1 = 1
AND A.CMP_CD = ?
AND A.STOR_CD = ?
AND A.GIF_VRTY = ?
AND A.CARD_DIV ='01'
AND A.SALE_YN ='0'
AND A.RTN_YN <>'1'
AND A.CANCEL_YN <> '1'
ORDER BY A.GIF_NO,B.GIF_FACE_AMT
]]>
</query>
<query name="SEL_CHN_PREPAYCARD_LIST">
<![CDATA[
SELECT
A.GIF_VRTY , A.GIF_NO , NVL(B.GIF_FACE_AMT,0) AS GIF_FACE_AMT
FROM GIF_PPCARD_SHPMNT_DESC A
INNER JOIN GIF_VRTY B
ON A.GIF_VRTY = B.GIF_VRTY
AND B.GIF_TYPE ='20'
WHERE 1 = 1
AND A.CMP_CD = ?
AND A.STOR_CD = ?
AND A.GIF_NO = ?
AND A.CARD_DIV ='01'
AND A.SALE_YN ='0'
AND A.RTN_YN <>'1'
AND A.CANCEL_YN <> '1'
ORDER BY A.GIF_NO,B.GIF_FACE_AMT
]]>
</query>
<query name="SEL_STR_EQ_HEADER_LIST">
<![CDATA[
SELECT A.DT || '|' || NVL(CHECK_STATE,'0') AS DATA
FROM MST_CLNDR A
LEFT JOIN STR_STOR_EQU_CHECK_LIST B
ON A.DT = B.SALE_DT
AND B.STOR_CD = ?
WHERE 1 = 1
AND A.CMP_CD = ?
AND A.DT BETWEEN ? AND ?
ORDER BY A.DT
]]>
</query>
<query name="SEL_STR_EQ_DETAIL_LIST">
<![CDATA[
SELECT
CHECK_DIV_CD || '|' || B.ENTRY_NM || '|' ||
CHECK_EQU_CD || '|' || C.ENTRY_NM || '|' ||
NVL(AS_RESULT,0) || '|' || NVL(STOR_RESULT,0) || '|' || C. EXPLN AS DATA
FROM STR_STOR_EQU_CHECK_DETAIL A LEFT JOIN V_MST_CMM_DTL B
ON B.LANG_TYPE ='ko-KR' AND B.CMM_GRP_CD ='D0030'
AND A.CHECK_DIV_CD = B.CMM_CD
LEFT JOIN V_MST_CMM_DTL C
ON C.LANG_TYPE ='ko-KR' AND C.CMM_GRP_CD ='D0031'
AND A.CHECK_EQU_CD = C.CMM_CD
AND B.CMM_CD = C.CHAR_VAL_TITLE_VAL_01
WHERE 1= 1
AND A.STOR_CD = ?
AND A.CMP_CD = ?
AND A.SALE_DT BETWEEN ? AND ?
AND A.CHECK_RESULT ='2' --불량만 조회
]]>
</query>
<query name="SEL_POS_INSTALL_CONFIG">
<![CDATA[
SELECT *
FROM POS_INSTALL_MST_CONFIG
WHERE 1 = 1
AND CMP_CD = ?
AND STOR_CD = ?
AND POS_NO = ?
]]>
</query>
<query name="SEL_POS_INSTALL_CONFIG_FILE">
<![CDATA[
SELECT *
FROM POS_INSTALL_MST_CONFIG
WHERE 1 = 1
AND CMP_CD = ?
AND STOR_CD = ?
AND POS_NO = ?
AND FILE_NM = ?
]]>
</query>
<query name="MER_POS_INSTALL_CONFIG">
<![CDATA[
MERGE INTO POS_INSTALL_MST_CONFIG T
USING ( SELECT ? AS CMP_CD,
? AS STOR_CD,
? AS POS_NO,
? AS FILE_NM,
? AS MAIN_TAG,
? AS SECTION_TAG,
? AS SECTION_VALUE,
'' AS FILLER1,
'' AS FILLER2,
'' AS FILLER3,
'' AS FILLER4,
'' AS FILLER5,
? AS REG_USER_ID,
SYSDATE AS REG_DATE,
? AS UPD_USER_ID,
SYSDATE AS UPD_DATE
FROM DUAL
) R
ON ( T.CMP_CD = R.CMP_CD
AND T.STOR_CD = R.STOR_CD
AND T.POS_NO = R.POS_NO
AND T.FILE_NM = R.FILE_NM
AND T.MAIN_TAG = R.MAIN_TAG
AND T.SECTION_TAG = R.SECTION_TAG
)
WHEN MATCHED THEN
UPDATE SET T.SECTION_VALUE = R.SECTION_VALUE
,T.UPD_USER_ID = R.UPD_USER_ID
,T.UPD_DATE = R.UPD_DATE
WHEN NOT MATCHED THEN
INSERT (
CMP_CD, STOR_CD, POS_NO, FILE_NM, MAIN_TAG, SECTION_TAG, SECTION_VALUE,
FILLER1, FILLER2, FILLER3, FILLER4, FILLER5,
REG_USER_ID, REG_DATE, UPD_USER_ID, UPD_DATE
)
VALUES (
R.CMP_CD, R.STOR_CD, R.POS_NO, R.FILE_NM, R.MAIN_TAG, R.SECTION_TAG, R.SECTION_VALUE,
R.FILLER1, R.FILLER2, R.FILLER3, R.FILLER4, R.FILLER5,
R.REG_USER_ID, R.REG_DATE, R.UPD_USER_ID, R.UPD_DATE
)
]]>
</query>
<query name="MER_STR_EQ_CHK_HEADER">
<![CDATA[
MERGE INTO STR_STOR_EQU_CHECK_LIST T
USING ( SELECT ? AS CMP_CD,
? AS STOR_CD,
? AS SALE_DT,
? AS CHECK_STATE,
? AS REG_USER_ID,
TO_DATE(?,'YYYYMMDDHH24MISS') AS REG_DATE,
? AS UPD_USER_ID,
TO_DATE(?,'YYYYMMDDHH24MISS') AS UPD_DATE
FROM DUAL
) R
ON ( T.CMP_CD = R.CMP_CD
AND T.STOR_CD = R.STOR_CD
AND T.SALE_DT = R.SALE_DT
)
WHEN MATCHED THEN
UPDATE SET T.CHECK_STATE = R.CHECK_STATE
,T.UPD_USER_ID = R.UPD_USER_ID
,T.UPD_DATE = R.UPD_DATE
WHEN NOT MATCHED THEN
INSERT (
CMP_CD, STOR_CD, SALE_DT, CHECK_STATE,
REG_USER_ID, REG_DATE, UPD_USER_ID, UPD_DATE
)
VALUES (
R.CMP_CD, R.STOR_CD, R.SALE_DT, R.CHECK_STATE,
R.REG_USER_ID , R.REG_DATE, R.UPD_USER_ID , R.UPD_DATE
)
]]>
</query>
<query name="MER_STR_EQ_CHK_DETAIL">
<![CDATA[
MERGE INTO STR_STOR_EQU_CHECK_DETAIL T
USING ( SELECT ? AS CMP_CD,
? AS STOR_CD,
? AS SALE_DT,
? AS CHECK_DIV_CD,
? AS CHECK_EQU_CD,
? AS CHECK_RESULT,
? AS AS_RESULT,
? AS STOR_RESULT,
? AS REG_USER_ID,
TO_DATE(?,'YYYYMMDDHH24MISS') AS REG_DATE,
? AS UPD_USER_ID,
TO_DATE(?,'YYYYMMDDHH24MISS') AS UPD_DATE
FROM DUAL
) R
ON ( T.CMP_CD = R.CMP_CD
AND T.STOR_CD = R.STOR_CD
AND T.SALE_DT = R.SALE_DT
AND T.CHECK_DIV_CD = R.CHECK_DIV_CD
AND T.CHECK_EQU_CD = R.CHECK_EQU_CD
)
WHEN MATCHED THEN
UPDATE SET T.CHECK_RESULT = R.CHECK_RESULT
,T.AS_RESULT = R.AS_RESULT
,T.STOR_RESULT = R.STOR_RESULT
,T.UPD_USER_ID = R.UPD_USER_ID
,T.UPD_DATE = R.UPD_DATE
WHEN NOT MATCHED THEN
INSERT (
CMP_CD, STOR_CD, SALE_DT, CHECK_DIV_CD, CHECK_EQU_CD, CHECK_RESULT, AS_RESULT, STOR_RESULT,
REG_USER_ID, REG_DATE, UPD_USER_ID, UPD_DATE
)
VALUES (
R.CMP_CD, R.STOR_CD, R.SALE_DT, R.CHECK_DIV_CD, R.CHECK_EQU_CD, R.CHECK_RESULT, R.AS_RESULT, R.STOR_RESULT,
R.REG_USER_ID , R.REG_DATE, R.UPD_USER_ID , R.UPD_DATE
)
]]>
</query>
<query name="SEL_GIFT_DATACHECK">
<![CDATA[
SELECT *
FROM GIF_MST
WHERE 1 = 1
AND CMP_CD = ?
AND GIF_NO = ?
]]>
</query>
<query name="SEL_STOR_SPPR_LIST">
<![CDATA[
SELECT NVL(SPPLR_CD,'') ||'|'|| NVL(SPPLR_NM,'') ||'|'|| NVL(TEL_NO,'') ||'|'|| NVL(BIZ_PSN_NO ,'') AS DATA
FROM MST_STOR_SPPLR
WHERE 1 = 1
AND CMP_CD = ?
AND STOR_CD = ?
AND USE_YN ='1'
AND (BIZ_PSN_NO LIKE '%' || TRIM(?) || '%'
OR TEL_NO LIKE '%' || TRIM(?) || '%'
OR SPPLR_NM LIKE '%' || TRIM(?) || '%' )
]]>
</query>
<query name="UPD_CHN_PREPAYCARD_DATA">
<![CDATA[
UPDATE GIF_PPCARD_SHPMNT_DESC
SET SALE_YN = ?
, UPD_USER_ID = 'POSDAEMON'
, UPD_DATE = SYSDATE
WHERE 1 = 1
AND CMP_CD = ?
AND STOR_CD = ?
AND GIF_NO = ?
]]>
</query>
<query name="SEL_POS_LOGFILE">
<![CDATA[
SELECT *
FROM WAT_POS_LOG_REQ
WHERE 1 = 1
AND CMP_CD = ?
AND STOR_CD = ?
AND POS_NO = ?
AND REQ_DIV IN ( '1','5')
AND ROWNUM = 1
]]>
</query>
<query name="SET_POS_LOGFILE">
<![CDATA[
UPDATE WAT_POS_LOG_REQ
SET REQ_DIV = ?
, UPD_USER_ID = 'POSDAEMON'
, UPD_DATE = SYSDATE
WHERE 1 = 1
AND CMP_CD = ?
AND STOR_CD = ?
AND POS_NO = ?
AND LOG_DT = ?
]]>
</query>
<!-- POS 마스터 조회 19 -->
<query name="SEL_HAPPY_ORDER_ITEM">
<![CDATA[
SELECT
CMP_CD || '|' ||
STOR_CD || '|' ||
? || '|' ||
ITEM_CD || '|' ||
L_CLSS || '|' ||
M_CLSS || '|' ||
S_CLSS || '|' ||
FLAVOUR_DIV || '|' ||
TO_CHAR(FLAVOUR_QTY) || '|' ||
FLAVOUR_STOCK || '|' ||
SHTCUT_ITEMNM || '|' ||
ITEM_NM || '|' ||
TO_CHAR(TAKE_IN_SALE_AMT) || '|' ||
TO_CHAR(TAKE_OUT_SALE_AMT) || '|' ||
IF_MENU1 || '|' ||
IF_MENU2 || '|' ||
OPEN_ITEM_DIV || '|' ||
DISPO_ITEM_DIV || '|' ||
SUB_SET_MNG_TYPE || '|' ||
ITEM_TAX_AMT_DIV || '|' ||
TAKE_IN_VAT_CD || '|' ||
TAKE_OUT_VAT_CD || '|' ||
TO_CHAR(ITEM_COST) || '|' ||
SALE_PRMT_YN || '|' ||
SALE_NOQ || '|' ||
FREE_GIFT_YN || '|' ||
DC_PRMT_YN || '|' ||
ACCUM_PRMT_YN || '|' ||
SVC_FEE_TRGT_YN || '|' ||
BTN_ITEM_IMG || '|' ||
NEW_ITEM_START_DT || '|' ||
NEW_ITEM_FNSH_DT || '|' ||
ITEM_TYPE || '|' ||
TIME_BAR_CD_YN || '|' ||
DISTBT_EXPIRE_NOD || '|' ||
ALCOHOL_ITEM_TYPE || '|' ||
SALE_START_DT || '|' ||
SALE_FNSH_DT || '|' ||
COOP_CARD_DC_NOADM_YN || '|' ||
CAKE_EXCHNG_CPN_USE_POSS_YN || '|' ||
ITEM_INFO || '|' ||
CALORY_INFO || '|' ||
SALE_IMG_FILE_NM || '|' ||
FILLER1 || '|' ||
FILLER2 || '|' ||
FILLER3 || '|' ||
FILLER4 || '|' ||
FILLER5 || '|' ||
USE_YN || '|' ||
UPD_DT || '#~' AS DATA
FROM
(
SELECT
ROWNUM AS RNUM
, STOR.CMP_CD AS CMP_CD -- 회사 코드
, STOR.STOR_CD AS STOR_CD -- 점포 코드
, ITEM.ITEM_CD AS ITEM_CD -- 상품 코드
, MCLSS.H_RANK_ITEM_CLASS_CD AS L_CLSS -- 대분류
, SCLSS.H_RANK_ITEM_CLASS_CD AS M_CLSS -- 중분류
, ITEM.ITEM_CLASS_CD AS S_CLSS -- 소분류
, NVL(ITEM.FLAVOUR_TYPE,'0') AS FLAVOUR_DIV -- 플레이버 구분
, NVL(ITEM.FLAVOUR_SEL_CNT,0) AS FLAVOUR_QTY -- 플레이버 수량
, NVL(ITEM.FLAVOUR_WEIGHT ,0) AS FLAVOUR_STOCK -- 플레이버 중량
, REPLACE(REPLACE(SUBSTR(ITEM.SALE_POS_ITEM_NM, 1, 20), '''', ' ') , '|', '-') AS SHTCUT_ITEMNM -- 단축 상품명 ( 판매 POS 상품 명 )
, REPLACE(REPLACE(SUBSTR(ITEM.ITEM_NM, 1, 40), '''', ' '), '|', '-') AS ITEM_NM
, NVL(
CASE
WHEN ITEM.SALE_PRC_CTRL_DIV = 'H' THEN NVL(ORGPRC.TAKE_IN_SALE_PRC, ITEM.TAKE_IN_SALE_PRC)
ELSE NVL(STOPRC.TAKE_IN_SALE_PRC, NVL(
CASE
WHEN STOR.DRT_FRCS_TYPE = '10' THEN TCHPRC.TAKE_IN_SALE_PRC
ELSE NULL
END, NVL(ORGPRC.TAKE_IN_SALE_PRC, ITEM.TAKE_IN_SALE_PRC)))
END, 0) AS TAKE_IN_SALE_AMT
, NVL(
CASE
WHEN ITEM.SALE_PRC_CTRL_DIV = 'H' THEN NVL(ORGPRC.TAKE_OUT_SALE_PRC, ITEM.TAKE_OUT_SALE_PRC)
ELSE NVL(STOPRC.TAKE_OUT_SALE_PRC,
NVL(CASE WHEN STOR.DRT_FRCS_TYPE = '10' THEN TCHPRC.TAKE_OUT_SALE_PRC ELSE NULL END,
NVL(ORGPRC.TAKE_OUT_SALE_PRC, ITEM.TAKE_OUT_SALE_PRC)))
END, 0) AS TAKE_OUT_SALE_AMT
, '' AS IF_MENU1 -- 인터페이스 메뉴1 (판매 POS 미사용)
, '' AS IF_MENU2 -- 인터페이스 메뉴2 (판매 POS 미사용)
, ITEM.PRC_STOR_OPEN_YN AS OPEN_ITEM_DIV -- 가격 점포 오픈 여부
, ITEM.DISPO_ITEM_YN AS DISPO_ITEM_DIV -- 일회 용품 여부
, ITEM.SUB_SET_MNG_TYPE AS SUB_SET_MNG_TYPE -- 부가 세트 관리 유형(구]상품 종류)
, ITEM.SALE_TAX_TYPE AS ITEM_TAX_AMT_DIV -- 상품 세금구분
, '' AS TAX_AMT_INCLUDE_YN -- 세금포함 구분
, DECODE( CMP.TAX_AMT_APPLY_DIV, '1', NVL( EXPTAX.TAKE_IN_TAXRATE_CD, TAXRATE.TAKE_IN_TAXRATE_CD ), ITEM.TAKE_IN_TAXRATE_CD) AS TAKE_IN_VAT_CD -- TAKE IN 부가세 코드 ( 부가세 금액 적용 유형이 '1' 이면 일괄, '2' : 상품별 )
, DECODE( CMP.TAX_AMT_APPLY_DIV, '1', NVL( EXPTAX.TAKE_OUT_TAXRATE_CD, TAXRATE.TAKE_OUT_TAXRATE_CD ), ITEM.TAKE_OUT_TAXRATE_CD) AS TAKE_OUT_VAT_CD -- TAKE OUT 부가세 코드 ( 부가세 금액 적용 유형이 '1' 이면 일괄, '2' : 상품별 )
, NVL(ITEM.SHPMNT_COST, 0) AS ITEM_COST -- 상품 원가 ( 출하 원가 )
, CASE WHEN ITEM.ORD_SALE_TYPE IN ('2', '3') OR ITEM.FLAVOUR_TYPE = '2' AND ITEM.CONFRM_STATUS = '9' THEN '1' ELSE '0' END AS SALE_PRMT_YN -- 판매 허용 여부 (주문/판매, 판매용 상품과 플레이버 투입상품은 판매 가능, 그외에 판매 불가)
, NVL(ITEM.SALE_EXHAUST_FACTOR, 0) AS SALE_NOQ -- 판매 입수
, DECODE( ITEM.ITEM_TYPE, '11', '1', '0') AS FREE_GIFT_YN -- 사은품 여부 (상품유형이 '11'이면 사은품 )
, ITEM.DC_NOADM_YN AS DC_PRMT_YN -- 할인 불가 여부
, ITEM.POINT_ACCUM_YN AS ACCUM_PRMT_YN -- 적립 허용 여부
, ITEM.SVC_FEE_APPLY_YN AS SVC_FEE_TRGT_YN -- 봉사료 대상 여부
, AFILE2.FILE_SAVE_NM AS BTN_ITEM_IMG -- 버튼 상품 이미지
, FLAG.START_DT AS NEW_ITEM_START_DT -- 신상품 시작 일자
, FLAG.FNSH_DT AS NEW_ITEM_FNSH_DT -- 신상품 종료 일자
, ITEM.ITEM_TYPE AS ITEM_TYPE -- 상품 유형
, ITEM.TIME_BAR_CD_YN AS TIME_BAR_CD_YN -- 타임바코드여부
, NVL(BCLSS.DISTBT_EXPIRE_DT, 0) AS DISTBT_EXPIRE_NOD -- 유통기한일수
, ITEM.ALCOHOL_ITEM_TYPE AS ALCOHOL_ITEM_TYPE -- 알콜 상품 유형
, ITEM.SALE_START_DT AS SALE_START_DT -- 판매 시작 일자
, ITEM.SALE_FNSH_DT AS SALE_FNSH_DT -- 판매 종료 일자
, ITEM.COOP_CARD_DC_NOADM_YN AS COOP_CARD_DC_NOADM_YN -- 제휴카드 할인 불가 여부
, ITEM.CAKE_EXCHNG_CPN_USE_POSS_YN AS CAKE_EXCHNG_CPN_USE_POSS_YN -- 케익 교환권 사용 가능 여부
, INTRO.NUTRIENT AS ITEM_INFO -- 영양 정보
, ITEM.CALORY AS CALORY_INFO -- 열량 정보
, AFILE1.FILE_SAVE_NM AS SALE_IMG_FILE_NM -- 버튼 상품 이미지
, '' AS FILLER1 -- 여유필드1
, '' AS FILLER2 -- 여유필드2
, '' AS FILLER3 -- 여유필드3
, '' AS FILLER4 -- 여유필드4
, '' AS FILLER5 -- 여유필드5
, ITEM.USE_YN AS USE_YN -- 사용 여부
, '' AS UPD_DT -- 수정 일시
, '' AS REG_DT -- 등록 일시
FROM MST_STOR STOR INNER JOIN MST_CMP CMP
ON CMP.CMP_CD = STOR.CMP_CD
INNER JOIN MST_SALESORG_ITEM ITEM
ON ITEM.CMP_CD = STOR.CMP_CD
AND ITEM.SALES_ORG_CD = STOR.SALES_ORG_CD
AND ITEM.DRT_FRCS_TYPE = STOR.DRT_FRCS_TYPE
AND (ITEM.ORD_SALE_TYPE IN ('2', '3')
OR ITEM.FLAVOUR_TYPE = '2') --주문/판매, 판매용 상품과 플레이버 투입상품
LEFT OUTER JOIN MST_ITEM_CLASS SCLSS
ON SCLSS.CMP_CD = ITEM.CMP_CD
AND SCLSS.ITEM_CLASS_TYPE_CD = '00'
AND SCLSS.ITEM_CLASS_CD = ITEM.ITEM_CLASS_CD
AND SCLSS.ITEM_CLASS_LVL_TYPE = 'S'
LEFT OUTER JOIN MST_ITEM_CLASS MCLSS
ON MCLSS.CMP_CD = SCLSS.CMP_CD
AND MCLSS.ITEM_CLASS_TYPE_CD = SCLSS.ITEM_CLASS_TYPE_CD
AND MCLSS.ITEM_CLASS_CD = SCLSS.H_RANK_ITEM_CLASS_CD
AND MCLSS.ITEM_CLASS_LVL_TYPE = 'M'
LEFT OUTER JOIN MST_ITEM_INTRO INTRO
ON INTRO.CMP_CD = STOR.CMP_CD
AND INTRO.ITEM_CD = ITEM.ITEM_CD
LEFT OUTER JOIN MST_ITEM_FLAG FLAG
ON FLAG.CMP_CD = STOR.CMP_CD
AND FLAG.ITEM_CD = ITEM.ITEM_CD
AND FLAG.ITEM_FLAG_TYPE = '01' /* 신상품 */
AND FLAG.USE_YN = '1'
LEFT OUTER JOIN (SELECT CMP_CD , STOR_CD , '01' AS STOR_FLAG_TYPE ,
MIN(STOR_FLAG_DTL_TYPE) AS STOR_FLAG_DTL_TYPE , '1' AS USE_YN ,
MAX(REG_DATE) AS REG_DATE ,
MAX(UPD_DATE) AS UPD_DATE
FROM MST_STOR_FLAG
WHERE STOR_FLAG_TYPE = '01'
AND USE_YN = '1'
GROUP BY CMP_CD , STOR_CD ) SFLAG
ON SFLAG.CMP_CD = STOR.CMP_CD
AND SFLAG.STOR_CD = STOR.STOR_CD
AND SFLAG.STOR_FLAG_TYPE = '01' /* 점포 플래그 : 터치키 유형 */
AND SFLAG.USE_YN = '1' LEFT
OUTER JOIN MST_TOUCH_KEY_TYPE_SALE_PRC TCHPRC /* 마스터 터치키 유형 판매가 */
ON TCHPRC.CMP_CD = ITEM.CMP_CD
AND TCHPRC.ITEM_CD = ITEM.ITEM_CD
AND TCHPRC.SALES_ORG_CD = ITEM.SALES_ORG_CD
AND ? BETWEEN TCHPRC.START_DT AND TCHPRC.FNSH_DT --1
AND TCHPRC.CMP_CD = SFLAG.CMP_CD
AND TCHPRC.TOUCH_KEY_MNG_TYPE = SFLAG.STOR_FLAG_DTL_TYPE
LEFT OUTER JOIN MST_SALESORG_SALE_PRC ORGPRC
ON ORGPRC.CMP_CD = STOR.CMP_CD
AND ORGPRC.ITEM_CD = ITEM.ITEM_CD
AND ORGPRC.SALES_ORG_CD = STOR.SALES_ORG_CD
AND ORGPRC.DRT_FRCS_TYPE = STOR.DRT_FRCS_TYPE
AND ? BETWEEN ORGPRC.START_DT AND ORGPRC.FNSH_DT --2
LEFT OUTER JOIN MST_STOR_SALE_PRC STOPRC
ON STOPRC.CMP_CD = STOR.CMP_CD
AND STOPRC.STOR_CD = STOR.STOR_CD
AND STOPRC.ITEM_CD = ITEM.ITEM_CD
AND ? BETWEEN STOPRC.START_DT AND STOPRC.FNSH_DT --3
LEFT OUTER JOIN MST_LOCAL_TAXRATE_DISTRCT EXPDST /* LOCAL 세율 지역 */
ON EXPDST.CMP_CD = CMP.CMP_CD
AND EXPDST.TAXRATE_DISTRCT_CD = STOR.TAXRATE_DISTRCT_CD
AND EXPDST.USE_YN = '1'
LEFT OUTER JOIN MST_LOCAL_TAXRATE TAXRATE /* LOCAL 세율 */
ON TAXRATE.CMP_CD = CMP.CMP_CD
AND TAXRATE.TAXRATE_DISTRCT_CD = EXPDST.TAXRATE_DISTRCT_CD
AND ? BETWEEN TAXRATE.START_DT AND TAXRATE.FNSH_DT --4
LEFT OUTER JOIN MST_LOCAL_EXCEP_TAXRATE_ITEM EXPTAX /* LOCAL 예외 세율 상품 */
ON EXPTAX.CMP_CD = EXPDST.CMP_CD
AND EXPTAX.TAXRATE_DISTRCT_CD = EXPDST.TAXRATE_DISTRCT_CD
AND EXPTAX.ITEM_CD = ITEM.ITEM_CD
AND ? BETWEEN EXPTAX.START_DT AND EXPTAX.FNSH_DT --5
AND EXPTAX.USE_YN = '1'
LEFT OUTER JOIN SPL_EXPRY_DT_ITEM BCITEM /*재고손익 유통기한 상품. BR 상품 유통기한 일수 체크용*/
ON BCITEM.CMP_CD = ITEM.CMP_CD
AND BCITEM.ITEM_CD = ITEM.ITEM_CD
AND BCITEM.USE_YN = '1'
LEFT OUTER JOIN SPL_BR_CLASS BCLSS /*재고손익 BR분류 상품코드 매핑. BR 상품 유통기한 일수 체크용*/
ON BCLSS.CMP_CD = BCITEM.CMP_CD
AND BCLSS.GRP_CD = BCITEM.GRP_CD
AND BCLSS.USE_YN = '1'
LEFT OUTER JOIN SYS_ATTCH_FILE_MNG AFILE1
ON AFILE1.FILE_NO = SALE_IMG_FILE_ID
LEFT OUTER JOIN SYS_ATTCH_FILE_MNG AFILE2
ON AFILE2.FILE_NO = TOUCH_KEY_IMG_FILE_ID
WHERE 1=1
AND STOR.CMP_CD = ?
AND STOR.STOR_CD = ?
AND ITEM.ITEM_CD = ?
) A
]]>
</query>
<query name="SEL_HPAPP_AFTER_SAVE">
<![CDATA[
SELECT SAVE_STATUS
FROM SAL_DAILY_STOR_POS_HPAPP
WHERE CMP_CD = ?
AND SALE_DT = ?
AND STOR_CD = ?
AND POS_NO = ?
AND TRADE_NO = ?
]]>
</query>
<!-- happy pgy add 20170613 -->
<query name="UPD_HPAPP_AFTER_SAVE">
<![CDATA[
UPDATE SAL_DAILY_STOR_POS_HPAPP
SET SAVE_STATUS = ?
, UPD_USER_ID = 'POSDAEMON'
, UPD_DATE = SYSDATE
WHERE CMP_CD = ?
AND SALE_DT = ?
AND STOR_CD = ?
AND POS_NO = ?
AND TRADE_NO = ?
]]>
</query>
<!-- POS Conn Check 2017.07.26 -->
<query name="MER_POS_CONN_STATUS">
<![CDATA[
MERGE INTO TR_POSCONN_INFO T
USING ( SELECT ? AS CMP_CD,
? AS SALE_DT,
? AS STOR_CD,
? AS POS_NO,
? AS SERVER_NO
FROM DUAL
) R
ON ( T.CMP_CD = R.CMP_CD
AND T.SALE_DT = R.SALE_DT
AND T.STOR_CD = R.STOR_CD
AND T.POS_NO = R.POS_NO
)
WHEN MATCHED THEN
UPDATE SET
T.REG_DATE = SYSDATE
WHEN NOT MATCHED THEN
INSERT (
CMP_CD, SALE_DT, STOR_CD, POS_NO, SERVER_NO, REG_USER_ID, REG_DATE
)
VALUES (
R.CMP_CD, R.SALE_DT, R.STOR_CD, R.POS_NO, R.SERVER_NO, 'DAEMON', SYSDATE
)
]]>
</query>
<query name="DLV_SAVE_HEADER">
<![CDATA[
MERGE INTO TR_DLV_HEADER T
USING ( SELECT ? AS CMP_CD,
? AS SALE_DT,
? AS STOR_CD,
? AS POS_NO,
? AS TRADE_NO,
? AS DLV_DT,
? AS TOTSALE_QTY,
? AS ACTUAL_SALE_AMT,
? AS DLV_AMT,
? AS DLV_TYPE,
? AS DLV_STATUS,
TO_DATE(?,'YYYYMMDDHH24MISS') AS REG_DATE,
? AS REG_USER_ID,
TO_DATE(?,'YYYYMMDDHH24MISS') AS UPD_DATE,
? AS UPD_USER_ID
FROM DUAL
) R
ON ( T.CMP_CD = R.CMP_CD
AND T.SALE_DT = R.SALE_DT
AND T.STOR_CD = R.STOR_CD
AND T.POS_NO = R.POS_NO
AND T.TRADE_NO = R.TRADE_NO
)
WHEN MATCHED THEN
UPDATE SET T.DLV_STATUS = R.DLV_STATUS
, T.UPD_USER_ID = R.UPD_USER_ID
, T.UPD_DATE = SYSDATE
WHEN NOT MATCHED THEN
INSERT (
CMP_CD , SALE_DT, STOR_CD , POS_NO, TRADE_NO , DLV_DT, TOTSALE_QTY, ACTUAL_SALE_AMT,
DLV_AMT, DLV_TYPE , DLV_STATUS, REG_DATE, REG_USER_ID, UPD_DATE, UPD_USER_ID
)
VALUES (
R.CMP_CD ,R.SALE_DT , R.STOR_CD , R.POS_NO, R.TRADE_NO , R.DLV_DT, R.TOTSALE_QTY , R.ACTUAL_SALE_AMT,
R.DLV_AMT ,R.DLV_TYPE ,R.DLV_STATUS, R.REG_DATE, R.REG_USER_ID, R.UPD_DATE , R.UPD_USER_ID
)
]]>
</query>
<query name="DLV_SAVE_DETAIL">
<![CDATA[
MERGE INTO TR_DLV_DTL T
USING ( SELECT ? CMP_CD,
? SALE_DT,
? STOR_CD,
? POS_NO,
? TRADE_NO,
? ITEM_SEQ,
? ITEM_CD,
? SALE_QTY,
? BILL_AMT,
TO_DATE(?,'YYYYMMDDHH24MISS') AS REG_DATE,
? REG_USER_ID,
TO_DATE(?,'YYYYMMDDHH24MISS') AS UPD_DATE,
? UPD_USER_ID
FROM DUAL
) R
ON ( T.CMP_CD = R.CMP_CD
AND T.SALE_DT = R.SALE_DT
AND T.STOR_CD = R.STOR_CD
AND T.POS_NO = R.POS_NO
AND T.TRADE_NO = R.TRADE_NO
AND T.ITEM_SEQ = R.ITEM_SEQ
)
WHEN MATCHED THEN
UPDATE SET T.UPD_USER_ID = R.UPD_USER_ID
, T.UPD_DATE = SYSDATE
WHEN NOT MATCHED THEN
INSERT (
CMP_CD, SALE_DT, STOR_CD, POS_NO, TRADE_NO, ITEM_SEQ, ITEM_CD,
SALE_QTY, BILL_AMT, REG_DATE, REG_USER_ID, UPD_DATE, UPD_USER_ID
)
VALUES (
R.CMP_CD, R.SALE_DT, R.STOR_CD, R.POS_NO, R.TRADE_NO, R.ITEM_SEQ, R.ITEM_CD,
R.SALE_QTY, R.BILL_AMT, R.REG_DATE, R.REG_USER_ID, R.UPD_DATE, R.UPD_USER_ID
)
]]>
</query>
<query name="SEL_DLV_HEADER_LIST">
<![CDATA[
SELECT H.CMP_CD || '|' || H.SALE_DT || '|' || H.STOR_CD || '|' || H.POS_NO || '|' || H.TRADE_NO || '|' ||
H.DLV_DT || '|' || H.TOTSALE_QTY || '|' || H.ACTUAL_SALE_AMT || '|' || H.DLV_AMT || '|' || H.DLV_TYPE || '|' ||
H.DLV_STATUS || '|' || to_char(H.REG_DATE, 'YYYYMMDDHH24MISS') || '|' || H.REG_USER_ID || '|' || to_char(H.UPD_DATE, 'YYYYMMDDHH24MISS') || '|' || H.UPD_USER_ID AS DATA
FROM TR_DLV_HEADER H
WHERE 1=1
AND H.CMP_CD = ?
AND H.STOR_CD = ?
AND H.POS_NO = ?
AND H.SALE_DT BETWEEN ? AND ?
]]>
</query>
<query name="SEL_DLV_DETAIL_LIST">
<![CDATA[
SELECT H.CMP_CD || '|' || H.SALE_DT || '|' || H.STOR_CD || '|' || H.POS_NO || '|' ||H.TRADE_NO|| '|' || H.ITEM_SEQ || '|' ||
H.ITEM_CD || '|' || H.SALE_QTY || '|' || H.BILL_AMT|| '|' || to_char(H.REG_DATE, 'YYYYMMDDHH24MISS') || '|' || H.REG_USER_ID || '|' || to_char(H.REG_DATE, 'YYYYMMDDHH24MISS') || '|' ||
H.UPD_USER_ID AS DATA
FROM TR_DLV_DTL H
WHERE 1=1
AND H.CMP_CD = ?
AND H.STOR_CD = ?
AND H.POS_NO = ?
AND H.SALE_DT BETWEEN ? AND ?
]]>
</query>
<!-- pgy 2018.08.17 해피오더 재고 조회 -->
<query name="SEL_HPORD_STOCK_QTY">
<![CDATA[
WITH W_STOR AS (
SELECT
CMP_CD
, SALES_ORG_CD
, DRT_FRCS_TYPE
, STOR_CD
FROM MST_STOR
WHERE CMP_CD = ?
AND STOR_CD = ?
),
W_BASE AS (
SELECT
S.CMP_CD
, S.SALES_ORG_CD
, S.DRT_FRCS_TYPE
, S.STOR_CD
, PI.ITEM_CD /*대표상품코드*/
, PI.ITEM_NM /*대표상품명*/
, PI.ITEM_PROD_TYPE
, PI.TAKE_IN_SALE_PRC
, PI.TAKE_OUT_SALE_PRC
, PI.ITEM_CLASS_CD
, V.L_CLSS_CD AS L_CLASS_CD
, V.L_ITEM_CLASS_NM AS L_CLASS_NM
, V.M_CLSS_CD AS M_CLASS_CD
, V.M_ITEM_CLASS_NM AS M_CLASS_NM
, V.L_DISP_SEQ
FROM W_STOR S, POS_MST_STOR_ITEM_KEY K, MST_SALESORG_ITEM CI, MST_SALESORG_ITEM PI, V_MST_ITEM_CLASS V
, (
SELECT ITEM_CD
FROM SPI_EAI.HP_ORDER_ITEM_IFR
WHERE PR_STATUS = 1
GROUP BY ITEM_CD
) R
WHERE S.CMP_CD = K.CMP_CD
AND S.STOR_CD = K.STOR_CD
AND S.CMP_CD = CI.CMP_CD
AND S.SALES_ORG_CD = CI.SALES_ORG_CD
AND S.DRT_FRCS_TYPE = CI.DRT_FRCS_TYPE
AND K.CMP_CD = CI.CMP_CD
AND K.ITEM_CD = CI.ITEM_CD
AND K.FIX_YN = '0'
AND CI.CMP_CD = PI.CMP_CD
AND CI.SALES_ORG_CD = PI.SALES_ORG_CD
AND CI.DRT_FRCS_TYPE = PI.DRT_FRCS_TYPE
AND CI.RPST_ITEM_CD = PI.ITEM_CD
AND PI.ITEM_CD = R.ITEM_CD
AND PI.CMP_CD = V.CMP_CD(+)
AND PI.ITEM_CD = V.ITEM_CD(+)
AND PI.ITEM_CLASS_CD = V.ITEM_CLASS_CD(+)
AND V.ITEM_CLASS_TYPE_CD(+) = '00'
AND V.USE_YN(+) = '1'
GROUP BY S.CMP_CD
, S.SALES_ORG_CD
, S.DRT_FRCS_TYPE
, S.STOR_CD
, PI.ITEM_CD /*대표상품코드*/
, PI.ITEM_NM /*대표상품명*/
, PI.ITEM_PROD_TYPE
, PI.TAKE_IN_SALE_PRC
, PI.TAKE_OUT_SALE_PRC
, PI.ITEM_CLASS_CD
, V.L_CLSS_CD
, V.L_ITEM_CLASS_NM
, V.M_CLSS_CD
, V.M_ITEM_CLASS_NM
, V.L_DISP_SEQ
)
SELECT M_CLASS_NM || '|' ||
ITEM_CD || '|' ||
ITEM_NM || '|' ||
PROD_QTY || '#~' AS DATA
FROM (
SELECT B.M_CLASS_CD
, NVL(B.M_CLASS_NM,'미등록') AS M_CLASS_NM
, B.ITEM_CD /*대표상품코드*/
, B.ITEM_NM /*대표상품명*/
, CASE WHEN T.ITEM_CD IS NOT NULL AND TO_CHAR(NVL(P.UPD_DATE,NVL(T.UPD_DATE,SYSDATE)),'YYYYMMDDHH24MISS') <= TO_CHAR(NVL(T.UPD_DATE,SYSDATE),'YYYYMMDDHH24MISS')
THEN ( CASE WHEN NVL(T.CHG_QTY,0) <0 THEN '0' ELSE TO_CHAR(NVL(T.CHG_QTY,0)) END )
ELSE ( CASE WHEN NVL(P.BASE_QTY - P.SALE_QTY + P.ORD_QTY + P.MV_QTY ,0) < 0 THEN '0' ELSE TO_CHAR( NVL(P.BASE_QTY - P.SALE_QTY + P.ORD_QTY + P.MV_QTY ,0) ) END)
END AS PROD_QTY
FROM W_BASE B
, SPL_DAY_STOCK_HP P
, SPL_HPYORD_INSPT T
, SPL_HPYORD_ITEMVIEW_YN N
, V_MST_CMM_DTL L /* 아메리카노 2종은 대표 코드 기준 임 */
WHERE B.STOR_CD = P.STOR_CD(+)
AND B.ITEM_CD = P.ITEM_CD(+)
AND B.CMP_CD = T.CMP_CD(+)
AND B.STOR_CD = T.STOR_CD(+)
AND B.ITEM_CD = T.ITEM_CD(+)
AND T.INSPT_DT(+) = TO_CHAR(SYSDATE,'YYYYMMDD')
AND B.CMP_CD = N.CMP_CD(+)
AND B.STOR_CD = N.STOR_CD(+)
AND B.ITEM_CD = N.ITEM_CD(+)
AND B.CMP_CD = L.CMP_CD(+)
AND B.ITEM_CD = L.CHAR_VAL_TITLE_VAL_01(+)
AND L.LANG_TYPE(+) = ?
AND L.CMM_GRP_CD(+) = 'S0103'
AND L.USE_YN(+) = '1'
) B
WHERE PROD_QTY > 0
ORDER BY NVL(B.M_CLASS_CD, '99999'), B.ITEM_CD
]]>
</query>
</sql-resource>