using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Xml; using System.Data; using Cosmos.Common; using Cosmos.BaseFrame; using Cosmos.UserFrame; using Cosmos.ServiceProvider; //#20180322 휴게소pos매출연동 start,phj using Newtonsoft.Json; using System.Collections; using System.IO; //#20180322 휴게소pos매출연동 end,phj /*-----------------------------------------------------------------------------------------------*/ // 설 명 : 정산자료 I/F (도로공사) // 작 성 자 : // 변경 이력 : /*-----------------------------------------------------------------------------------------------*/ namespace Cosmos.Service { public class CalDataIF : ICalDataIF { protected SManager sManager = new SManager(); // 이 객체를 통해 업무 Service 호출 /// /// StateServer Object (StateServer 객체) /// private StateServer StateObject = (StateServer)StateServer.GetInstance(); /// /// POS Status Value (POS 상태값) /// private PosStatus m_cPosStatus = new PosStatus(); private IMasterUs m_cMstService = null; // 마스터 인터페이스 public CalDataIF() { m_cPosStatus = (PosStatus)StateObject.POS; // POS 기본정보 m_cMstService = (IMasterUs)sManager.InitServiceInstance(ServiceLists.ASV_MASTER.DLL, ServiceLists.ASV_MASTER.POS_MASTER); } public string Execute(string[] aParam) { string sRet = UserCom.RST_ERR; try { if(aParam[0] == "EX") { // 도로공사 정산Data 생성 DataTable dtCalcData = GetCalcDataForEx(m_cPosStatus.Base.CmpCd, aParam[1], m_cPosStatus.Base.StoreNo, m_cPosStatus.Base.PosNo); XmlDocument doc = new XmlDocument(); XmlDeclaration docClaration = doc.CreateXmlDeclaration("1.0", null, null); XmlElement root = doc.DocumentElement; doc.InsertBefore(docClaration, root); XmlElement erestNode = doc.CreateElement("EREST"); doc.AppendChild(erestNode); MakeCalcDataXmlForEx(aParam[1], ref doc, ref erestNode, dtCalcData); // 정산DATA XML 파일 생성 string sFileNm = "H2" + "_" + m_cPosStatus.Base.CmpCd + "_" + m_cPosStatus.Base.StoreNo + "_" + m_cPosStatus.Base.PosNo + "_" + aParam[1] + "_" + "99999" + ".xml"; doc.Save(BaseCom.NxDataPath + "SEND\\EX\\" + sFileNm); sRet = UserCom.RST_OK; } else if(aParam[0] == "KAC") { //string sCmpCd = m_cPosStatus.Base.CmpCd; //string sSaleDt = aParam[1]; //string sStorNo = m_cPosStatus.Base.StoreNo; //string sPosNo = m_cPosStatus.Base.PosNo; //// 한국공항공사 정산Data 생성 //DataTable dtCalc1Data = GetCalcData1ForKac(sCmpCd, sSaleDt, sStorNo, sPosNo); //DataTable dtCalc2Data = GetCalcData2ForKac(sCmpCd, sSaleDt, sStorNo, sPosNo); //Column.KACCalcData data; //data = MakeCalcDataForKac(sCmpCd, sSaleDt, sStorNo, sPosNo, dtCalc1Data, dtCalc2Data); //// 매출 저장 //INetworkTranSend cTranSend = (INetworkTranSend)sManager.InitServiceInstance(ServiceLists.AGENT_NETWORK_TRANSEND.DLL, ServiceLists.AGENT_NETWORK_TRANSEND.NetworkTranSend); //sRet = cTranSend.SaveDataToDb("CALC", sCmpCd, sSaleDt, sStorNo, sPosNo, data.RECEIPT_NO, null, null, data); } //#20180322 휴게소pos매출연동 start,phj else if (aParam[0] == "EX2018") { string sPath = string.Empty; string sFileFullname = string.Empty; string sFilename = string.Empty; // Create CalcData for Ex DataTable dtCalcData = GetCalcDataForEx(m_cPosStatus.Base.CmpCd, aParam[1], m_cPosStatus.Base.StoreNo, m_cPosStatus.Base.PosNo); //Make JsonData var sJsonData = this.MakeCalcDataJsonForEx(aParam[1], dtCalcData); // file name create sFilename = string.Format("{0}{1}{2}{3}{4}{5}.dat" , ItemConst.ROAD_SAVE_TYPE.CLOSING , aParam[1].Substring(2, 6) , m_cPosStatus.RestAreaPos.RestAreaPosGroupCd.PadLeft(3, '0').Trim() //"000" //, m_cPosStatus.Base.StoreNo.PadLeft(7, '0') , m_cPosStatus.RestAreaPos.RestAreaPosCd.PadLeft(7, '0') , m_cPosStatus.RestAreaPos.RestAreaPosPosGroupCd.PadLeft(2, '0').Trim() //"00" //, m_cPosStatus.Base.PosNo.PadLeft(4, '0') , m_cPosStatus.RestAreaPos.RestAreaPosPosNo.PadLeft(4, '0') ); //#20180410 휴게소매출 경로 없을 경우 자동생성 안함 start,phj if (m_cPosStatus.RestAreaPos.RestAreaPosDir == "") { m_cPosStatus.RestAreaPos.RestAreaPosDir = @"C:\eRest_SPC\Sals\"; } //#20180410 휴게소매출 경로 없을 경우 자동생성 안함 end,phj sPath = m_cPosStatus.RestAreaPos.RestAreaPosDir; sFileFullname = sPath + sFilename; //SaveFile //if (CmUtil.WriteTextFile(BaseCom.NxDataPath + m_cPosStatus.Mst.ETC_IF_FTP_PATH + sFilename.ToString(), sJsonData) != true) if (CmUtil.WriteTextFile(sFileFullname, sJsonData) != true) { UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + // Class Name (Class Name (클래스명)) System.Reflection.MethodBase.GetCurrentMethod().Name + "()", // Function Name (Function Name (함수명)) "File Write Error : " + sJsonData); } sRet = UserCom.RST_OK; } //#20180322 휴게소pos매출연동 end,phj } catch (Exception ex) { UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + // Class Name (Class Name (클래스명)) System.Reflection.MethodBase.GetCurrentMethod().Name + "()", // Function Name (Function Name (함수명)) ex.Message); } return sRet; } #region 01 - 도로공사 정산Data 조회 및 생성 private DataTable GetCalcDataForEx(string sCmpCd, string sSaleDt, string sStorCd, string sPosNo) { string sQuery = string.Empty; string sSql = string.Empty; StringBuilder sb = new StringBuilder(); DataTable dtReturn = null; try { //#20180322 휴게소pos매출연동 start,phj //기존 #region 주석처리 /* sQuery = "SELECT A.*, B.*, C.*, D.*, E.*, F.* \n" + " FROM ( \n" + " SELECT ISNULL(SUM(CASE WHEN A.TRADE_DIV = '0' \n" + " THEN 1 \n" + " ELSE (-1) \n" + " END * B.SALE_AMT), 0) AS TOT_SALE_AMT \n" + " , ISNULL(SUM(CASE WHEN A.TRADE_DIV = '0' \n" + " THEN 1 \n" + " ELSE (-1) \n" + " END * (B.ITEM_DC_AMT + B.SUM_DC_AMT + B.CPI_DC_AMT + B.COOP_CARD_DC_AMT + B.POINT_DC_AMT \n" + " + B.CPN_DC_AMT + B.EMP_DC_AMT + B.SET_DC_AMT + B.ETC_DC_AMT + B.EXCEP_DC_AMT)), 0) AS TOT_DC_AMT \n" + " , 0 AS TOT_ETC_AMT \n" + " , 0 AS SVC_TIP_AMT \n" + " , ISNULL(SUM(CASE WHEN A.TRADE_DIV = '0' \n" + " THEN 1 \n" + " ELSE (-1) \n" + " END * B.BILL_AMT), 0) AS DCM_SALE_AMT \n" + " , ISNULL(SUM(CASE WHEN A.TRADE_DIV = '0' \n" + " THEN 1 \n" + " ELSE (-1) \n" + " END * \n" + " CASE WHEN B.ITEM_TAX_DIV = '1' AND B.NOTAX_DIV = '0' \n" + " THEN B.SALE_AMT \n" + " WHEN B.ITEM_TAX_DIV = '1' AND B.NOTAX_DIV = '1' \n" + " THEN 0 \n" + " ELSE 0 \n" + " END), 0) AS VAT_SALE_AMT \n" + " , ISNULL(SUM(CASE WHEN A.TRADE_DIV = '0' \n" + " THEN 1 \n" + " ELSE (-1) \n" + " END * ISNULL(B.APPLY_TAX_AMT, 0)), 0) AS VAT_AMT \n" + " , ISNULL(SUM(CASE WHEN A.TRADE_DIV = '0' \n" + " THEN 1 \n" + " ELSE (-1) \n" + " END * \n" + " CASE WHEN B.ITEM_TAX_DIV = '0' \n" + " THEN B.SALE_AMT \n" + " ELSE 0 \n" + " END), 0) AS NO_VAT_SALE_AMT \n" + " , ISNULL(SUM(CASE WHEN A.TRADE_DIV = '0' \n" + " THEN 1 \n" + " ELSE (-1) \n" + " END * (B.BILL_AMT - B.APPLY_TAX_AMT)), 0) AS NO_TAX_SALE_AMT \n" + " , ISNULL(SUM(CASE WHEN A.TRADE_DIV = '0' \n" + " THEN 0 \n" + " ELSE B.BILL_AMT \n" + " END), 0) AS RET_BILL_AMT \n" + " FROM POSLOG..TR_SALE_HEADER A \n" + " , POSLOG..TR_SALE_DETAIL B \n" + " WHERE A.CMP_CD = '{0}' \n" + " AND A.SALE_DT = '{1}' \n" + " AND A.STOR_CD = '{2}' \n" + " AND A.POS_NO = '{3}' \n" + " AND A.TRAIN_MODE_YN = '0' \n" + " AND A.TRADE_KINDPER = '00' \n" + " AND A.CMP_CD = B.CMP_CD \n" + " AND A.SALE_DT = B.SALE_DT \n" + " AND A.STOR_CD = B.STOR_CD \n" + " AND A.POS_NO = B.POS_NO \n" + " AND A.TRADE_NO = B.TRADE_NO \n" + " AND B.CANCEL_DIV = '0' \n" + " ) A \n" + " , ( \n" + " SELECT ISNULL(SUM(CASE WHEN TRADE_DIV = '0' \n" + " THEN 1 \n" + " ELSE 1 \n" + " END), 0) AS TOT_BILL_CNT \n" + " , ISNULL(SUM(CASE WHEN TRADE_DIV = '0' \n" + " THEN 0 \n" + " ELSE 1 \n" + " END), 0) AS RET_BILL_CNT \n" + " , MAX(TRADE_NO) AS BILL_NO_END \n" + " , ISNULL(SUM(CASE WHEN TRADE_DIV = '0' \n" + " THEN 1 \n" + " ELSE 0 \n" + " END), 0) AS VISIT_CST_CNT \n" + " FROM POSLOG..TR_SALE_HEADER \n" + " WHERE CMP_CD = '{0}' \n" + " AND SALE_DT = '{1}' \n" + " AND STOR_CD = '{2}' \n" + " AND POS_NO = '{3}' \n" + " AND TRAIN_MODE_YN = '0' \n" + " AND TRADE_KINDPER = '00' \n" + " AND NET_SALE_AMT <> 0 \n" + " ) B \n" + " , ( \n" + " SELECT ISNULL(SUM(CASE WHEN ADMT_CD = '7201' \n" + " THEN TSA.AMT \n" + " ELSE 0 \n" + " END), 0) AS POS_READY_AMT \n" + " , ISNULL(SUM(CASE WHEN ADMT_CD = '6210' \n" + " THEN TSA.QTY \n" + " ELSE 0 \n" + " END), 0) AS REM_CHECK_CNT \n" + " , ISNULL(SUM(CASE WHEN ADMT_CD = '6210' \n" + " THEN TSA.AMT \n" + " ELSE 0 \n" + " END), 0) AS REM_CHECK_AMT \n" + " , ISNULL(SUM(CASE WHEN ADMT_CD = '6209' \n" + " THEN TSA.QTY \n" + " ELSE 0 \n" + " END), 0) AS REM_W100000_CNT \n" + " , ISNULL(SUM(CASE WHEN ADMT_CD = '6208' \n" + " THEN TSA.QTY \n" + " ELSE 0 \n" + " END), 0) AS REM_W50000_CNT \n" + " , ISNULL(SUM(CASE WHEN ADMT_CD = '6207' \n" + " THEN TSA.QTY \n" + " ELSE 0 \n" + " END), 0) AS REM_W10000_CNT \n" + " , ISNULL(SUM(CASE WHEN ADMT_CD = '6206' \n" + " THEN TSA.QTY \n" + " ELSE 0 \n" + " END), 0) AS REM_W5000_CNT \n" + " , ISNULL(SUM(CASE WHEN ADMT_CD = '6205' \n" + " THEN TSA.QTY \n" + " ELSE 0 \n" + " END), 0) AS REM_W1000_CNT \n" + " , ISNULL(SUM(CASE WHEN ADMT_CD = '6204' \n" + " THEN TSA.QTY \n" + " ELSE 0 \n" + " END), 0) AS REM_W500_CNT \n" + " , ISNULL(SUM(CASE WHEN ADMT_CD = '6203' \n" + " THEN TSA.QTY \n" + " ELSE 0 \n" + " END), 0) AS REM_W100_CNT \n" + " , ISNULL(SUM(CASE WHEN ADMT_CD = '6202' \n" + " THEN TSA.QTY \n" + " ELSE 0 \n" + " END), 0) AS REM_W50_CNT \n" + " , ISNULL(SUM(CASE WHEN ADMT_CD = '6201' \n" + " THEN TSA.QTY \n" + " ELSE 0 \n" + " END), 0) AS REM_W10_CNT \n" + " , ISNULL(SUM(CASE WHEN ADMT_CD = '7701' \n" + " THEN TSA.AMT \n" + " ELSE 0 \n" + " END), 0) AS LOSS_CASH_AMT \n" + " FROM POSLOG..TR_SALE_HEADER TSH \n" + " LEFT JOIN POSLOG..TR_SALE_ADMT TSA \n" + " ON TSH.CMP_CD = TSA.CMP_CD \n" + " AND TSH.SALE_DT = TSA.SALE_DT \n" + " AND TSH.STOR_CD = TSA.STOR_CD \n" + " AND TSH.POS_NO = TSA.POS_NO \n" + " AND TSH.TRADE_NO = TSA.TRADE_NO \n" + " AND TSA.ADMT_TYPE = '84' \n" + " WHERE TSA.CMP_CD = '{0}' \n" + " AND TSA.SALE_DT = '{1}' \n" + " AND TSA.STOR_CD = '{2}' \n" + " AND TSA.POS_NO = '{3}' \n" + " AND TSH.TRAIN_MODE_YN = '0' \n" + " AND TSH.TRADE_KINDPER = '84' \n" //+ " AND TSA.TRADE_NO = ( \n" //+ " SELECT MAX(TSH.TRADE_NO) \n" //+ " FROM POSLOG..TR_SALE_HEADER TSH \n" //+ " WHERE TSH.CMP_CD = TSA.CMP_CD \n" //+ " AND TSH.SALE_DT = TSA.SALE_DT \n" //+ " AND TSH.STOR_CD = TSA.STOR_CD \n" //+ " AND TSH.POS_NO = TSA.POS_NO \n" //+ " AND TSH.TRAIN_MODE_YN = '0' \n" //+ " AND TSH.TRADE_KINDPER = '84' \n" //+ " ) \n" + " ) C \n" + " , ( \n" + " SELECT ISNULL(SUM(CASE WHEN A.TRADE_DIV = '0' \n" + " THEN 1 \n" + " ELSE (-1) \n" + " END), 0) AS CRD_CARD_CNT \n" + " , ISNULL(SUM(CASE WHEN A.TRADE_DIV = '0' \n" + " THEN 1 \n" + " ELSE (-1) \n" + " END * B.PAY_AMT), 0) AS CRD_CARD_AMT \n" + " FROM POSLOG..TR_SALE_HEADER A \n" + " , POSLOG..TR_SALE_PAY B \n" + " WHERE A.CMP_CD = '{0}' \n" + " AND A.SALE_DT = '{1}' \n" + " AND A.STOR_CD = '{2}' \n" + " AND A.POS_NO = '{3}' \n" + " AND A.TRAIN_MODE_YN = '0' \n" + " AND A.TRADE_KINDPER = '00' \n" + " AND B.PAY_WAY_CD = '02' \n" + " AND B.PAY_DTL_CD_05 = '1' \n" + " AND B.CANCEL_DIV = '0' \n" + " AND A.CMP_CD = B.CMP_CD \n" + " AND A.SALE_DT = B.SALE_DT \n" + " AND A.STOR_CD = B.STOR_CD \n" + " AND A.POS_NO = B.POS_NO \n" + " AND A.TRADE_NO = B.TRADE_NO \n" + " ) D \n" + " , ( \n" + " SELECT ISNULL(SUM(CASE WHEN A.TRADE_DIV = '0' \n" + " THEN 1 \n" + " ELSE (-1) \n" + " END), 0) AS CASH_CNT \n" + " , ISNULL(SUM(CASE WHEN A.TRADE_DIV = '0' \n" + " THEN 1 \n" + " ELSE (-1) \n" + " END * B.PAY_AMT), 0) AS CASH_AMT \n" + " FROM POSLOG..TR_SALE_HEADER A \n" + " , POSLOG..TR_SALE_PAY B \n" + " WHERE A.CMP_CD = '{0}' \n" + " AND A.SALE_DT = '{1}' \n" + " AND A.STOR_CD = '{2}' \n" + " AND A.POS_NO = '{3}' \n" + " AND A.TRAIN_MODE_YN = '0' \n" + " AND A.TRADE_KINDPER = '00' \n" + " AND B.PAY_WAY_CD <> '02' \n" + " AND B.PAY_DTL_CD_05 = '1' \n" + " AND B.CANCEL_DIV = '0' \n" + " AND A.CMP_CD = B.CMP_CD \n" + " AND A.SALE_DT = B.SALE_DT \n" + " AND A.STOR_CD = B.STOR_CD \n" + " AND A.POS_NO = B.POS_NO \n" + " AND A.TRADE_NO = B.TRADE_NO \n" + " ) E \n" + " , ( \n" + " SELECT ISNULL(SUM(CASE WHEN A.TRADE_DIV = '0' \n" + " THEN 1 \n" + " ELSE -1 \n" + " END), 0) AS CASH_BILL_CNT \n" + " , ISNULL(SUM(CASE WHEN A.TRADE_DIV = '0' \n" + " THEN 1 \n" + " ELSE (-1) \n" + " END * B.ETC_AMT), 0) AS CASH_BILL_AMT \n" + " FROM POSLOG..TR_SALE_HEADER A \n" + " , POSLOG..TR_SALE_ETC B \n" + " WHERE A.CMP_CD = '{0}' \n" + " AND A.SALE_DT = '{1}' \n" + " AND A.STOR_CD = '{2}' \n" + " AND A.POS_NO = '{3}' \n" + " AND A.TRAIN_MODE_YN = '0' \n" + " AND A.TRADE_KINDPER = '00' \n" + " AND A.CMP_CD = B.CMP_CD \n" + " AND A.SALE_DT = B.SALE_DT \n" + " AND A.STOR_CD = B.STOR_CD \n" + " AND A.POS_NO = B.POS_NO \n" + " AND A.TRADE_NO = B.TRADE_NO \n" + " AND B.ETC_WAY_CD = '80' \n" + " AND B.ETC_DTL_CD_01 = '00' \n" + " ) F \n"; */ #endregion //변경 if (m_cPosStatus.Mst.ETC_IF_DIV == ItemConst.TranInterfaceOutside.IF_KOR_01) { #region 도로공사 sQuery = "SELECT A.*, B.*, C.*, D.*, E.*, F.* \n" + " FROM ( \n" + " SELECT ISNULL(SUM(CASE WHEN A.TRADE_DIV = '0' \n" + " THEN 1 \n" + " ELSE (-1) \n" + " END * B.SALE_AMT), 0) AS TOT_SALE_AMT \n" + " , ISNULL(SUM(CASE WHEN A.TRADE_DIV = '0' \n" + " THEN 1 \n" + " ELSE (-1) \n" + " END * (B.ITEM_DC_AMT + B.SUM_DC_AMT + B.CPI_DC_AMT + B.COOP_CARD_DC_AMT + B.POINT_DC_AMT \n" + " + B.CPN_DC_AMT + B.EMP_DC_AMT + B.SET_DC_AMT + B.ETC_DC_AMT + B.EXCEP_DC_AMT)), 0) AS TOT_DC_AMT \n" + " , 0 AS TOT_ETC_AMT \n" + " , 0 AS SVC_TIP_AMT \n" + " , ISNULL(SUM(CASE WHEN A.TRADE_DIV = '0' \n" + " THEN 1 \n" + " ELSE (-1) \n" + " END * B.BILL_AMT), 0) AS DCM_SALE_AMT \n" + " , ISNULL(SUM(CASE WHEN A.TRADE_DIV = '0' \n" + " THEN 1 \n" + " ELSE (-1) \n" + " END * \n" + " CASE WHEN B.ITEM_TAX_DIV = '1' AND B.NOTAX_DIV = '0' \n" + " THEN B.SALE_AMT \n" + " WHEN B.ITEM_TAX_DIV = '1' AND B.NOTAX_DIV = '1' \n" + " THEN 0 \n" + " ELSE 0 \n" + " END), 0) AS VAT_SALE_AMT \n" + " , ISNULL(SUM(CASE WHEN A.TRADE_DIV = '0' \n" + " THEN 1 \n" + " ELSE (-1) \n" + " END * ISNULL(B.APPLY_TAX_AMT, 0)), 0) AS VAT_AMT \n" + " , ISNULL(SUM(CASE WHEN A.TRADE_DIV = '0' \n" + " THEN 1 \n" + " ELSE (-1) \n" + " END * \n" + " CASE WHEN B.ITEM_TAX_DIV = '0' \n" + " THEN B.SALE_AMT \n" + " ELSE 0 \n" + " END), 0) AS NO_VAT_SALE_AMT \n" + " , ISNULL(SUM(CASE WHEN A.TRADE_DIV = '0' \n" + " THEN 1 \n" + " ELSE (-1) \n" + " END * (B.BILL_AMT - B.APPLY_TAX_AMT)), 0) AS NO_TAX_SALE_AMT \n" + " , ISNULL(SUM(CASE WHEN A.TRADE_DIV = '0' \n" + " THEN 0 \n" + " ELSE B.BILL_AMT \n" + " END), 0) AS RET_BILL_AMT \n" + " FROM POSLOG..TR_SALE_HEADER A \n" + " , POSLOG..TR_SALE_DETAIL B \n" + " WHERE A.CMP_CD = '{0}' \n" + " AND A.SALE_DT = '{1}' \n" + " AND A.STOR_CD = '{2}' \n" + " AND A.POS_NO = '{3}' \n" + " AND A.TRAIN_MODE_YN = '0' \n" + " AND A.TRADE_KINDPER = '00' \n" + " AND A.CMP_CD = B.CMP_CD \n" + " AND A.SALE_DT = B.SALE_DT \n" + " AND A.STOR_CD = B.STOR_CD \n" + " AND A.POS_NO = B.POS_NO \n" + " AND A.TRADE_NO = B.TRADE_NO \n" + " AND B.CANCEL_DIV = '0' \n" + " ) A \n" + " , ( \n" + " SELECT ISNULL(SUM(CASE WHEN TRADE_DIV = '0' \n" + " THEN 1 \n" + " ELSE 1 \n" + " END), 0) AS TOT_BILL_CNT \n" + " , ISNULL(SUM(CASE WHEN TRADE_DIV = '0' \n" + " THEN 0 \n" + " ELSE 1 \n" + " END), 0) AS RET_BILL_CNT \n" + " , MAX(TRADE_NO) AS BILL_NO_END \n" + " , ISNULL(SUM(CASE WHEN TRADE_DIV = '0' \n" + " THEN 1 \n" + " ELSE 0 \n" + " END), 0) AS VISIT_CST_CNT \n" + " FROM POSLOG..TR_SALE_HEADER \n" + " WHERE CMP_CD = '{0}' \n" + " AND SALE_DT = '{1}' \n" + " AND STOR_CD = '{2}' \n" + " AND POS_NO = '{3}' \n" + " AND TRAIN_MODE_YN = '0' \n" + " AND TRADE_KINDPER = '00' \n" + " AND NET_SALE_AMT <> 0 \n" + " ) B \n" + " , ( \n" + " SELECT ISNULL(SUM(CASE WHEN ADMT_CD = '7201' \n" + " THEN TSA.AMT \n" + " ELSE 0 \n" + " END), 0) AS POS_READY_AMT \n" + " , ISNULL(SUM(CASE WHEN ADMT_CD = '6210' \n" + " THEN TSA.QTY \n" + " ELSE 0 \n" + " END), 0) AS REM_CHECK_CNT \n" + " , ISNULL(SUM(CASE WHEN ADMT_CD = '6210' \n" + " THEN TSA.AMT \n" + " ELSE 0 \n" + " END), 0) AS REM_CHECK_AMT \n" + " , ISNULL(SUM(CASE WHEN ADMT_CD = '6209' \n" + " THEN TSA.QTY \n" + " ELSE 0 \n" + " END), 0) AS REM_W100000_CNT \n" + " , ISNULL(SUM(CASE WHEN ADMT_CD = '6208' \n" + " THEN TSA.QTY \n" + " ELSE 0 \n" + " END), 0) AS REM_W50000_CNT \n" + " , ISNULL(SUM(CASE WHEN ADMT_CD = '6207' \n" + " THEN TSA.QTY \n" + " ELSE 0 \n" + " END), 0) AS REM_W10000_CNT \n" + " , ISNULL(SUM(CASE WHEN ADMT_CD = '6206' \n" + " THEN TSA.QTY \n" + " ELSE 0 \n" + " END), 0) AS REM_W5000_CNT \n" + " , ISNULL(SUM(CASE WHEN ADMT_CD = '6205' \n" + " THEN TSA.QTY \n" + " ELSE 0 \n" + " END), 0) AS REM_W1000_CNT \n" + " , ISNULL(SUM(CASE WHEN ADMT_CD = '6204' \n" + " THEN TSA.QTY \n" + " ELSE 0 \n" + " END), 0) AS REM_W500_CNT \n" + " , ISNULL(SUM(CASE WHEN ADMT_CD = '6203' \n" + " THEN TSA.QTY \n" + " ELSE 0 \n" + " END), 0) AS REM_W100_CNT \n" + " , ISNULL(SUM(CASE WHEN ADMT_CD = '6202' \n" + " THEN TSA.QTY \n" + " ELSE 0 \n" + " END), 0) AS REM_W50_CNT \n" + " , ISNULL(SUM(CASE WHEN ADMT_CD = '6201' \n" + " THEN TSA.QTY \n" + " ELSE 0 \n" + " END), 0) AS REM_W10_CNT \n" + " , ISNULL(SUM(CASE WHEN ADMT_CD = '7701' \n" + " THEN TSA.AMT \n" + " ELSE 0 \n" + " END), 0) AS LOSS_CASH_AMT \n" + " FROM POSLOG..TR_SALE_HEADER TSH \n" + " LEFT JOIN POSLOG..TR_SALE_ADMT TSA \n" + " ON TSH.CMP_CD = TSA.CMP_CD \n" + " AND TSH.SALE_DT = TSA.SALE_DT \n" + " AND TSH.STOR_CD = TSA.STOR_CD \n" + " AND TSH.POS_NO = TSA.POS_NO \n" + " AND TSH.TRADE_NO = TSA.TRADE_NO \n" + " AND TSA.ADMT_TYPE = '84' \n" + " WHERE TSA.CMP_CD = '{0}' \n" + " AND TSA.SALE_DT = '{1}' \n" + " AND TSA.STOR_CD = '{2}' \n" + " AND TSA.POS_NO = '{3}' \n" + " AND TSH.TRAIN_MODE_YN = '0' \n" + " AND TSH.TRADE_KINDPER = '84' \n" //+ " AND TSA.TRADE_NO = ( \n" //+ " SELECT MAX(TSH.TRADE_NO) \n" //+ " FROM POSLOG..TR_SALE_HEADER TSH \n" //+ " WHERE TSH.CMP_CD = TSA.CMP_CD \n" //+ " AND TSH.SALE_DT = TSA.SALE_DT \n" //+ " AND TSH.STOR_CD = TSA.STOR_CD \n" //+ " AND TSH.POS_NO = TSA.POS_NO \n" //+ " AND TSH.TRAIN_MODE_YN = '0' \n" //+ " AND TSH.TRADE_KINDPER = '84' \n" //+ " ) \n" + " ) C \n" + " , ( \n" + " SELECT ISNULL(SUM(CASE WHEN A.TRADE_DIV = '0' \n" + " THEN 1 \n" + " ELSE (-1) \n" + " END), 0) AS CRD_CARD_CNT \n" + " , ISNULL(SUM(CASE WHEN A.TRADE_DIV = '0' \n" + " THEN 1 \n" + " ELSE (-1) \n" + " END * B.PAY_AMT), 0) AS CRD_CARD_AMT \n" + " FROM POSLOG..TR_SALE_HEADER A \n" + " , POSLOG..TR_SALE_PAY B \n" + " WHERE A.CMP_CD = '{0}' \n" + " AND A.SALE_DT = '{1}' \n" + " AND A.STOR_CD = '{2}' \n" + " AND A.POS_NO = '{3}' \n" + " AND A.TRAIN_MODE_YN = '0' \n" + " AND A.TRADE_KINDPER = '00' \n" + " AND B.PAY_WAY_CD = '02' \n" + " AND B.PAY_DTL_CD_05 = '1' \n" + " AND B.CANCEL_DIV = '0' \n" + " AND A.CMP_CD = B.CMP_CD \n" + " AND A.SALE_DT = B.SALE_DT \n" + " AND A.STOR_CD = B.STOR_CD \n" + " AND A.POS_NO = B.POS_NO \n" + " AND A.TRADE_NO = B.TRADE_NO \n" + " ) D \n" + " , ( \n" + " SELECT ISNULL(SUM(CASE WHEN A.TRADE_DIV = '0' \n" + " THEN 1 \n" + " ELSE (-1) \n" + " END), 0) AS CASH_CNT \n" + " , ISNULL(SUM(CASE WHEN A.TRADE_DIV = '0' \n" + " THEN 1 \n" + " ELSE (-1) \n" + " END * B.PAY_AMT), 0) AS CASH_AMT \n" + " FROM POSLOG..TR_SALE_HEADER A \n" + " , POSLOG..TR_SALE_PAY B \n" + " WHERE A.CMP_CD = '{0}' \n" + " AND A.SALE_DT = '{1}' \n" + " AND A.STOR_CD = '{2}' \n" + " AND A.POS_NO = '{3}' \n" + " AND A.TRAIN_MODE_YN = '0' \n" + " AND A.TRADE_KINDPER = '00' \n" + " AND B.PAY_WAY_CD <> '02' \n" + " AND B.PAY_DTL_CD_05 = '1' \n" + " AND B.CANCEL_DIV = '0' \n" + " AND A.CMP_CD = B.CMP_CD \n" + " AND A.SALE_DT = B.SALE_DT \n" + " AND A.STOR_CD = B.STOR_CD \n" + " AND A.POS_NO = B.POS_NO \n" + " AND A.TRADE_NO = B.TRADE_NO \n" + " ) E \n" + " , ( \n" + " SELECT ISNULL(SUM(CASE WHEN A.TRADE_DIV = '0' \n" + " THEN 1 \n" + " ELSE -1 \n" + " END), 0) AS CASH_BILL_CNT \n" + " , ISNULL(SUM(CASE WHEN A.TRADE_DIV = '0' \n" + " THEN 1 \n" + " ELSE (-1) \n" + " END * B.ETC_AMT), 0) AS CASH_BILL_AMT \n" + " FROM POSLOG..TR_SALE_HEADER A \n" + " , POSLOG..TR_SALE_ETC B \n" + " WHERE A.CMP_CD = '{0}' \n" + " AND A.SALE_DT = '{1}' \n" + " AND A.STOR_CD = '{2}' \n" + " AND A.POS_NO = '{3}' \n" + " AND A.TRAIN_MODE_YN = '0' \n" + " AND A.TRADE_KINDPER = '00' \n" + " AND A.CMP_CD = B.CMP_CD \n" + " AND A.SALE_DT = B.SALE_DT \n" + " AND A.STOR_CD = B.STOR_CD \n" + " AND A.POS_NO = B.POS_NO \n" + " AND A.TRADE_NO = B.TRADE_NO \n" + " AND B.ETC_WAY_CD = '80' \n" + " AND B.ETC_DTL_CD_01 = '00' \n" + " ) F \n"; #endregion 도로공사 } else if (m_cPosStatus.Mst.ETC_IF_DIV == ItemConst.TranInterfaceOutside.IF_KOR_03) { #region 도로공사 2018 #region 주석 //sb.Append(" SELECT \n"); //sb.Append(" (SELECT MIN(SYS_DT + PAY_TIME) FROM POSLOG..ETC_SALE_HEADER \n"); //sb.Append(" WHERE CMP_CD = '{0}' \n"); //sb.Append(" AND SALE_DT = '{1}' \n"); //sb.Append(" AND STOR_CD = '{2}' \n"); //sb.Append(" AND POS_NO = '{3}' \n"); //sb.Append(" AND TRADE_KINDPER = '97' \n"); //sb.Append(" ) OPEN_DATETIME \n"); //sb.Append(" ,(SELECT MAX(SYS_DT + PAY_TIME) AS CLOSE_DATETIME FROM POSLOG..TR_SALE_HEADER \n"); //sb.Append(" WHERE CMP_CD = '{0}' \n"); //sb.Append(" AND SALE_DT = '{1}' \n"); //sb.Append(" AND STOR_CD = '{2}' \n"); //sb.Append(" AND POS_NO = '{3}' \n"); //sb.Append(" AND TRADE_DIV = '0' \n"); //sb.Append(" AND TRADE_KINDPER = '84' \n"); //sb.Append(" ) CLOSE_DATETIME \n"); //sb.Append(" ,A.*,B.* \n"); //sb.Append(" FROM \n"); //sb.Append(" (SELECT MIN(TRADE_NO) AS BILL_NO_START, \n"); //sb.Append(" MAX(TRADE_NO) AS BILL_NO_END, \n"); //sb.Append(" COUNT( TRADE_DIV) AS TOT_AMT_CNT, \n"); //sb.Append(" COUNT( CASE WHEN TRADE_DIV = '1' THEN 1 END) AS CANCEL_TOT_CNTT, \n"); //sb.Append(" COUNT( CASE WHEN TRADE_DIV = '0' THEN 1 END) AS SALE_TOT_CNT, \n"); //sb.Append(" COUNT( CASE WHEN TRADE_DIV = '0' THEN 1 END) AS SALE_AMT_CNT, \n"); //sb.Append(" COUNT( CASE WHEN TRADE_DIV = '0' THEN 1 END) AS ETC_1_CNT, \n"); //sb.Append(" COUNT( CASE WHEN TOTDC_AMT > '0' THEN 1 END) AS DC_AMT_CNT, \n"); //sb.Append(" COUNT( CASE WHEN TRADE_DIV = '0' AND TOTDC_AMT > 0 THEN 1 END) AS REGULAR_DC_AMT_CNT, \n"); //sb.Append(" COUNT( CASE WHEN TRADE_DIV = '1' AND TOTDC_AMT > 0 THEN 1 END) AS CANCEL_DC_AMT_CNT, \n"); //sb.Append(" ISNULL(CONVERT(INT,SUM( TOTSALE_AMT ) ),'0') AS TOT_AMT, \n"); //sb.Append(" ISNULL(CONVERT(INT,SUM( CASE WHEN TRADE_DIV = '1' THEN TOTSALE_AMT END )),'0') AS CANCEL_TOT, \n"); //sb.Append(" ISNULL(CONVERT(INT,SUM( CASE WHEN TRADE_DIV = '0' THEN TOTSALE_AMT END )),'0') AS SALE_TOT, \n"); //sb.Append(" ISNULL(CONVERT(INT,SUM( CASE WHEN TRADE_DIV = '0' THEN NET_SALE_AMT - TOT_VAT END )),'0') AS SALE_AMT, \n"); //sb.Append(" ISNULL(CONVERT(INT,SUM( CASE WHEN TRADE_DIV = '0' THEN NET_SALE_AMT END )),'0') AS ETC_1, \n"); //sb.Append(" ISNULL(CONVERT(INT,SUM( CASE WHEN TRADE_DIV = '0' THEN TOT_VAT END )),'0') AS VAT_AMT, \n"); //sb.Append(" ISNULL(CONVERT(INT,SUM( CASE WHEN TOTDC_AMT > '0' THEN TOTDC_AMT END )),'0') AS DC_AMT, \n"); //sb.Append(" ISNULL(CONVERT(INT,SUM( CASE WHEN TRADE_DIV = '0' AND TOTDC_AMT > 0 THEN TOTDC_AMT END )),'0') AS REGULAR_DC_AMT, \n"); //sb.Append(" ISNULL(CONVERT(INT,SUM( CASE WHEN TRADE_DIV = '1' AND TOTDC_AMT > 0 THEN TOTDC_AMT END )),'0') AS CANCEL_DC_AMT \n"); //sb.Append(" FROM POSLOG..TR_SALE_HEADER \n"); //sb.Append(" WHERE CMP_CD = '{0}' \n"); //sb.Append(" AND SALE_DT = '{1}' \n"); //sb.Append(" AND STOR_CD = '{2}' \n"); //sb.Append(" AND POS_NO = '{3}' \n"); //sb.Append(" AND TRAIN_MODE_YN = '0' \n"); //sb.Append(" AND TRADE_KINDPER IN ('00','20','21','42') \n"); //sb.Append(" )A, \n"); //sb.Append(" (SELECT COUNT( CASE WHEN TRADE_DIV = '0' AND PAY_WAY_CD = '02' AND OCCUR_ENTRY_14 = '00' THEN 1 END) AS CARD_AMT1_CNT, \n"); //sb.Append(" COUNT( CASE WHEN TRADE_DIV = '0' AND PAY_WAY_CD = '02' AND OCCUR_ENTRY_14 NOT IN ('00','60','80') THEN 1 END) AS CARD_AMT2_CNT, \n"); //sb.Append(" COUNT( CASE WHEN TRADE_DIV = '1' AND PAY_WAY_CD = '02' AND OCCUR_ENTRY_14 = '00' THEN 1 END) AS CARD_AMT3_CNT, \n"); //sb.Append(" COUNT( CASE WHEN TRADE_DIV = '1' AND PAY_WAY_CD = '02' AND OCCUR_ENTRY_14 NOT IN ('00','60','80') THEN 1 END) AS CARD_AMT4_CNT, \n"); //sb.Append(" COUNT( CASE WHEN TRADE_DIV = '0' AND PAY_WAY_CD <> '02' AND PAY_DTL_CD_05 = '1' OR OCCUR_ENTRY_14 IN ('60','80') THEN 1 END) AS CASH_AMT_CNT, \n"); //sb.Append(" ISNULL(CONVERT(INT,SUM( CASE WHEN TRADE_DIV = '0' AND PAY_WAY_CD = '02' AND OCCUR_ENTRY_14 = '00' THEN PAY_AMT END)),'0') AS CARD_AMT1, \n"); //sb.Append(" ISNULL(CONVERT(INT,SUM( CASE WHEN TRADE_DIV = '0' AND PAY_WAY_CD = '02' AND OCCUR_ENTRY_14 NOT IN ('00','60','80') THEN PAY_AMT END)),'0') AS CARD_AMT2, \n"); //sb.Append(" ISNULL(CONVERT(INT,SUM( CASE WHEN TRADE_DIV = '1' AND PAY_WAY_CD = '02' AND OCCUR_ENTRY_14 = '00' THEN PAY_AMT END)),'0') AS CARD_AMT3, \n"); //sb.Append(" ISNULL(CONVERT(INT,SUM( CASE WHEN TRADE_DIV = '1' AND PAY_WAY_CD = '02' AND OCCUR_ENTRY_14 NOT IN ('00','60','80') THEN PAY_AMT END)),'0') AS CARD_AMT4, \n"); //sb.Append(" ISNULL(CONVERT(INT,SUM( CASE WHEN TRADE_DIV = '0' AND PAY_WAY_CD <> '02' AND PAY_DTL_CD_05 = '1' OR OCCUR_ENTRY_14 IN ('60','80')THEN PAY_AMT END)),'0') AS CASH_AMT \n"); //sb.Append(" FROM POSLOG..TR_SALE_HEADER A, POSLOG..TR_SALE_PAY B \n"); //sb.Append(" WHERE A.CMP_CD = '{0}' \n"); //sb.Append(" AND A.SALE_DT = '{1}' \n"); //sb.Append(" AND A.STOR_CD = '{2}' \n"); //sb.Append(" AND A.POS_NO = '{3}' \n"); //sb.Append(" AND A.TRAIN_MODE_YN = '0' \n"); //sb.Append(" AND A.TRADE_KINDPER IN ('00','20','21','42') \n"); //sb.Append(" AND A.CMP_CD = B.CMP_CD \n"); //sb.Append(" AND A.SALE_DT = B.SALE_DT \n"); //sb.Append(" AND A.STOR_CD = B.STOR_CD \n"); //sb.Append(" AND A.POS_NO = B.POS_NO \n"); //sb.Append(" AND A.TRADE_NO = B.TRADE_NO \n"); //sb.Append(" AND B.CANCEL_DIV = '0' \n"); //sb.Append(" )B \n"); #endregion //주석 //#20180404 도로공사 매출 연동 쿼리 수정_grayber // 변경사항 // - 신용카드 사항 수정 // - 현금 결제 수량 변경 sb.Append(" SELECT TM.*, A.* ,B.* , C.* \n"); sb.Append(" FROM \n"); sb.Append(" (SELECT MIN(TRADE_NO) AS BILL_NO_START, \n"); sb.Append(" MAX(TRADE_NO) AS BILL_NO_END, \n"); sb.Append(" COUNT( TRADE_DIV) AS TOT_AMT_CNT, \n"); sb.Append(" COUNT ( CASE WHEN TRADE_DIV = '1' THEN 1 END ) AS CANCEL_TOT_CNTT, \n"); sb.Append(" COUNT ( CASE WHEN TRADE_DIV = '0' THEN 1 END ) AS SALE_TOT_CNT, \n"); sb.Append(" COUNT ( CASE WHEN TRADE_DIV = '0' THEN 1 END ) AS SALE_AMT_CNT, \n"); sb.Append(" COUNT ( CASE WHEN TRADE_DIV = '0' THEN 1 END ) AS ETC_1_CNT, \n"); sb.Append(" COUNT ( CASE WHEN TOTDC_AMT > '0' THEN 1 END ) AS DC_AMT_CNT, \n"); sb.Append(" COUNT ( CASE WHEN TRADE_DIV = '0' AND TOTDC_AMT > 0 THEN 1 END ) AS REGULAR_DC_AMT_CNT, \n"); sb.Append(" COUNT ( CASE WHEN TRADE_DIV = '1' AND TOTDC_AMT > 0 THEN 1 END ) AS CANCEL_DC_AMT_CNT, \n"); sb.Append(" ISNULL(CONVERT(INT,SUM( TOTSALE_AMT ) ),'0') AS TOT_AMT, \n"); //#20180406 도로공사 수정 start //CANCEL_TOT : 마이너스 금액으로 생성 //기존 //sb.Append(" ISNULL(CONVERT(INT,SUM ( CASE WHEN TRADE_DIV = '1' THEN TOTSALE_AMT END ) ),'0') AS CANCEL_TOT, \n"); //변경 sb.Append(" ISNULL(CONVERT(INT,SUM ( CASE WHEN TRADE_DIV = '1' THEN TOTSALE_AMT END ) ),'0') * -1 AS CANCEL_TOT, \n"); //#20180406 도로공사 수정 end sb.Append(" ISNULL(CONVERT(INT,SUM ( CASE WHEN TRADE_DIV = '0' THEN TOTSALE_AMT END ) ),'0') AS SALE_TOT, \n"); sb.Append(" ISNULL(CONVERT(INT,SUM ( CASE WHEN TRADE_DIV = '0' THEN NET_SALE_AMT - TOT_VAT END ) ),'0') AS SALE_AMT, \n"); sb.Append(" ISNULL(CONVERT(INT,SUM ( CASE WHEN TRADE_DIV = '0' THEN NET_SALE_AMT END ) ),'0') AS ETC_1, \n"); sb.Append(" ISNULL(CONVERT(INT,SUM ( CASE WHEN TRADE_DIV = '0' THEN TOT_VAT END ) ),'0') AS VAT_AMT, \n"); sb.Append(" ISNULL(CONVERT(INT,SUM ( CASE WHEN TOTDC_AMT > '0' THEN TOTDC_AMT END ) ),'0') AS DC_AMT, \n"); sb.Append(" ISNULL(CONVERT(INT,SUM ( CASE WHEN TRADE_DIV = '0' AND TOTDC_AMT > 0 THEN TOTDC_AMT END ) ),'0') AS REGULAR_DC_AMT, \n"); sb.Append(" ISNULL(CONVERT(INT,SUM ( CASE WHEN TRADE_DIV = '1' AND TOTDC_AMT > 0 THEN TOTDC_AMT END ) ),'0') AS CANCEL_DC_AMT \n"); sb.Append(" FROM POSLOG..TR_SALE_HEADER \n"); sb.Append(" WHERE CMP_CD = '{0}' AND SALE_DT = '{1}' AND STOR_CD = '{2}' AND POS_NO = '{3}' AND TRAIN_MODE_YN = '0' AND TRADE_KINDPER IN ('00','20','21','42') \n"); sb.Append(" )A , \n"); sb.Append(" (SELECT COUNT ( CASE WHEN TRADE_DIV = '0' AND ( PAY_WAY_CD + PAY_DTL_CD_01 ) \n"); sb.Append(" IN ( '0200', '0402', '0406', '0407', '0700', '0701', '0702', '0703', '0900', '0901', '1002') \n"); sb.Append(" AND OCCUR_ENTRY_14 = '00' \n"); sb.Append(" THEN 1 END ) AS CARD_AMT1_CNT, \n"); sb.Append(" COUNT ( CASE WHEN TRADE_DIV = '0' AND ( PAY_WAY_CD + PAY_DTL_CD_01 ) \n"); sb.Append(" IN ( '0200', '0402', '0406', '0407', '0700', '0701', '0702', '0703', '0900', '0901', '1002') \n"); //#20180406 도로공사 수정 start //할부개월 없는 결제 수단도 있기 때문에 공백도 조건에 추가 //기존 //sb.Append(" AND OCCUR_ENTRY_14 <> '00' \n"); //변경 sb.Append(" AND OCCUR_ENTRY_14 <> '00' AND OCCUR_ENTRY_14 <> '' \n"); //#20180406 도로공사 수정 end sb.Append(" THEN 1 END ) AS CARD_AMT2_CNT, \n"); sb.Append(" COUNT ( CASE WHEN TRADE_DIV = '1' AND ( PAY_WAY_CD + PAY_DTL_CD_01 ) \n"); sb.Append(" IN ( '0200', '0402', '0406', '0407', '0700', '0701', '0702', '0703', '0900', '0901', '1002') \n"); sb.Append(" AND OCCUR_ENTRY_14 = '00' \n"); sb.Append(" THEN 1 END ) AS CARD_AMT3_CNT, \n"); sb.Append(" COUNT ( CASE WHEN TRADE_DIV = '1' AND ( PAY_WAY_CD + PAY_DTL_CD_01 ) \n"); sb.Append(" IN ( '0200', '0402', '0406', '0407', '0700', '0701', '0702', '0703', '0900', '0901', '1002') \n"); //#20180406 도로공사 수정 start //할부개월 없는 결제 수단도 있기 때문에 공백도 조건에 추가 //기존 //sb.Append(" AND OCCUR_ENTRY_14 <> '00' \n"); //변경 sb.Append(" AND OCCUR_ENTRY_14 <> '00' AND OCCUR_ENTRY_14 <> '' \n"); //#20180406 도로공사 수정 end sb.Append(" THEN 1 END ) AS CARD_AMT4_CNT, \n"); sb.Append(" ISNULL(CONVERT(INT,SUM ( CASE WHEN TRADE_DIV = '0' AND ( PAY_WAY_CD + PAY_DTL_CD_01 ) \n"); sb.Append(" IN ( '0200', '0402', '0406', '0407', '0700', '0701', '0702', '0703', '0900', '0901', '1002') \n"); sb.Append(" AND OCCUR_ENTRY_14 = '00' \n"); sb.Append(" THEN PAY_AMT END ) ),'0') AS CARD_AMT1, \n"); sb.Append(" ISNULL(CONVERT(INT,SUM ( CASE WHEN TRADE_DIV = '0' AND ( PAY_WAY_CD + PAY_DTL_CD_01 ) \n"); sb.Append(" IN ( '0200', '0402', '0406', '0407', '0700', '0701', '0702', '0703', '0900', '0901', '1002') \n"); //#20180406 도로공사 수정 start //할부개월 없는 결제 수단도 있기 때문에 공백도 조건에 추가 //기존 //sb.Append(" AND OCCUR_ENTRY_14 <> '00' \n"); //변경 sb.Append(" AND OCCUR_ENTRY_14 <> '00' AND OCCUR_ENTRY_14 <> '' \n"); //#20180406 도로공사 수정 end sb.Append(" THEN PAY_AMT END ) ),'0') AS CARD_AMT2, \n"); sb.Append(" ISNULL(CONVERT(INT,SUM ( CASE WHEN TRADE_DIV = '1' AND ( PAY_WAY_CD + PAY_DTL_CD_01 ) \n"); sb.Append(" IN ( '0200', '0402', '0406', '0407', '0700', '0701', '0702', '0703', '0900', '0901', '1002') \n"); sb.Append(" AND OCCUR_ENTRY_14 = '00' \n"); sb.Append(" THEN PAY_AMT END ) ),'0') AS CARD_AMT3, \n"); sb.Append(" ISNULL(CONVERT(INT,SUM \n"); sb.Append(" ( CASE WHEN TRADE_DIV = '1' AND ( PAY_WAY_CD + PAY_DTL_CD_01 ) \n"); sb.Append(" IN ( '0200', '0402', '0406', '0407', '0700', '0701', '0702', '0703', '0900', '0901', '1002') \n"); //#20180406 도로공사 수정 start //할부개월 없는 결제 수단도 있기 때문에 공백도 조건에 추가 //기존 //sb.Append(" AND OCCUR_ENTRY_14 <> '00' \n"); //변경 sb.Append(" AND OCCUR_ENTRY_14 <> '00' AND OCCUR_ENTRY_14 <> '' \n"); //#20180406 도로공사 수정 end sb.Append(" THEN PAY_AMT END ) ),'0') AS CARD_AMT4 \n"); sb.Append(" FROM POSLOG..TR_SALE_HEADER A, \n"); sb.Append(" POSLOG..TR_SALE_PAY B \n"); sb.Append(" WHERE A.CMP_CD = '{0}' \n"); sb.Append(" AND A.SALE_DT = '{1}' \n"); sb.Append(" AND A.STOR_CD = '{2}' \n"); sb.Append(" AND A.POS_NO = '{3}' \n"); sb.Append(" AND A.TRAIN_MODE_YN = '0' \n"); sb.Append(" AND A.TRADE_KINDPER IN ('00','20','21','42') \n"); sb.Append(" AND A.CMP_CD = B.CMP_CD \n"); sb.Append(" AND A.SALE_DT = B.SALE_DT \n"); sb.Append(" AND A.STOR_CD = B.STOR_CD \n"); sb.Append(" AND A.POS_NO = B.POS_NO \n"); sb.Append(" AND A.TRADE_NO = B.TRADE_NO \n"); sb.Append(" AND B.CANCEL_DIV = '0' \n"); sb.Append(" ) B , \n"); sb.Append(" (SELECT SUM(TRADE_CNT - B.NOT_BIL_CNT) AS CASH_AMT_CNT, \n"); sb.Append(" CONVERT(INT,SUM(CASH_PAY_AMT)) AS CASH_AMT \n"); sb.Append(" FROM \n"); sb.Append(" (SELECT SUM ( CASE WHEN A.TRADE_NO IS NOT NULL THEN 1 ELSE 0 END ) AS TRADE_CNT , \n"); sb.Append(" SUM (B.PAY_AMT) AS CASH_PAY_AMT \n"); sb.Append(" FROM POSLOG..TR_SALE_HEADER AS A \n"); sb.Append(" LEFT OUTER JOIN POSLOG..TR_SALE_PAY AS B \n"); sb.Append(" ON ( \n"); sb.Append(" A.CMP_CD = B.CMP_CD \n"); sb.Append(" AND A.SALE_DT = B.SALE_DT \n"); sb.Append(" AND A.STOR_CD = B.STOR_CD \n"); sb.Append(" AND A.POS_NO = B.POS_NO \n"); sb.Append(" AND A.TRADE_NO = B.TRADE_NO \n"); sb.Append(" ) \n"); sb.Append(" WHERE A.CMP_CD = '{0}' \n"); sb.Append(" AND A.SALE_DT = '{1}' \n"); sb.Append(" AND A.STOR_CD = '{2}' \n"); sb.Append(" AND A.POS_NO = '{3}' \n"); sb.Append(" AND TRAIN_MODE_YN = '0' \n"); sb.Append(" AND TRADE_KINDPER IN ('00','20','21','42') \n"); sb.Append(" AND B.CANCEL_DIV = '0' \n"); sb.Append(" AND ( B.PAY_WAY_CD + B.PAY_DTL_CD_01 ) \n"); sb.Append(" NOT IN ( '0200', '0402', '0406', '0407', '0700', '0701', '0702', '0703', '0900', '0901', '1002') \n"); sb.Append(" AND B.PAY_DTL_CD_05 = '1' \n"); sb.Append(" GROUP BY A.TRADE_NO \n"); sb.Append(" ) A , \n"); sb.Append(" (SELECT --A.PAY_TRADE_NO, \n"); sb.Append(" --A.PAY_AMT, B.ETC_AMT , \n"); sb.Append(" SUM ( CASE WHEN ( A.PAY_AMT-B.ETC_AMT ) < 1 THEN 0 ELSE 1 END ) AS NOT_BIL_CNT \n"); sb.Append(" FROM \n"); sb.Append(" (SELECT AA.TRADE_NO AS PAY_TRADE_NO, \n"); sb.Append(" SUM(AA.PAY_AMT) AS PAY_AMT \n"); sb.Append(" FROM POSLOG..TR_SALE_PAY AS AA \n"); sb.Append(" WHERE AA.CMP_CD = '{0}' \n"); sb.Append(" AND AA.SALE_DT = '{1}' \n"); sb.Append(" AND AA.STOR_CD = '{2}' \n"); sb.Append(" AND AA.POS_NO = '{3}' \n"); sb.Append(" AND ( AA.PAY_WAY_CD + AA.PAY_DTL_CD_01 ) \n"); sb.Append(" NOT IN ( '0200', '0402', '0406', '0407', '0700', '0701', '0702', '0703', '0900', '0901', '1002') \n"); sb.Append(" GROUP BY AA.TRADE_NO \n"); sb.Append(" ) AS A \n"); sb.Append(" LEFT OUTER JOIN \n"); sb.Append(" (SELECT BB.TRADE_NO AS ETC_TRADE_NO , \n"); sb.Append(" ISNULL( SUM(BB.ETC_AMT),0) AS ETC_AMT \n"); sb.Append(" FROM POSLOG..TR_SALE_ETC AS BB \n"); sb.Append(" WHERE BB.CMP_CD = '{0}' \n"); sb.Append(" AND BB.SALE_DT = '{1}' \n"); sb.Append(" AND BB.STOR_CD = '{2}' \n"); sb.Append(" AND BB.POS_NO = '{3}' \n"); sb.Append(" AND BB.ETC_DTL_CD_01 = '00' \n"); sb.Append(" GROUP BY BB.TRADE_NO \n"); sb.Append(" ) AS B \n"); sb.Append(" ON( A.PAY_TRADE_NO=B.ETC_TRADE_NO ) \n"); sb.Append(" WHERE ETC_AMT IS NOT NULL \n"); sb.Append(" )B \n"); sb.Append(" ) C , \n"); sb.Append(" (SELECT MIN(A.SYS_DT + A.PAY_TIME) AS OPEN_DATETIME, \n"); sb.Append(" MAX(B.SYS_DT + B.PAY_TIME) AS CLOSE_DATETIME \n"); sb.Append(" FROM POSLOG..ETC_SALE_HEADER A \n"); sb.Append(" JOIN POSLOG..TR_SALE_HEADER AS B \n"); sb.Append(" ON( \n"); sb.Append(" A.CMP_CD = B.CMP_CD \n"); sb.Append(" AND A.SALE_DT = B.SALE_DT \n"); sb.Append(" AND A.STOR_CD = B.STOR_CD \n"); sb.Append(" AND A.POS_NO = B.POS_NO \n"); sb.Append(" ) \n"); sb.Append(" WHERE A.CMP_CD = '{0}' \n"); sb.Append(" AND A.SALE_DT = '{1}' \n"); sb.Append(" AND A.STOR_CD = '{2}' \n"); sb.Append(" AND A.POS_NO = '{3}' \n"); sb.Append(" AND A.TRADE_KINDPER = '97' \n"); sb.Append(" AND B.TRADE_KINDPER = '84' \n"); sb.Append(" )TM \n"); #endregion 도로공사 2018 sQuery = sb.ToString(); } //#20180322 휴게소pos매출연동 end,phj sSql = string.Format(sQuery, sCmpCd, sSaleDt, sStorCd, sPosNo); dtReturn = m_cMstService.Select(new string[] { sSql }); } catch (Exception ex) { UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + // Class Name (Class Name (클래스명)) System.Reflection.MethodBase.GetCurrentMethod().Name + "()", // Function Name (Function Name (함수명)) ex.Message); } return dtReturn; } private void MakeCalcDataXmlForEx(string sSaleDt, ref XmlDocument doc, ref XmlElement upperNode, DataTable dtData) { try { DataRow dr = dtData.Rows[0]; //----------------------------------------------------------------------------------------- // TXJM-FD //----------------------------------------------------------------------------------------- XmlElement TXJMNode = doc.CreateElement("TXJM-FD"); TXJMNode.SetAttribute("SRID", "PS010"); // 1.전문ID (5) TXJMNode.SetAttribute("RETCD", "0000"); // 2.전문적합성체크 (4) upperNode.AppendChild(TXJMNode); //----------------------------------------------------------------------------------------- // DATA-HD //----------------------------------------------------------------------------------------- XmlElement DATAHDNode = doc.CreateElement("DATA-HD"); //DATAHDNode.SetAttribute("SHOP_CD", m_cPosStatus.Base.ExStoreCd); // 3.매장코드 (9) //DATAHDNode.SetAttribute("SHOP_CD", m_cPosStatus.Base.OutSDVendConNo); // 3.매장코드 (9) DATAHDNode.SetAttribute("SHOP_CD", m_cPosStatus.Mst.JOIN_STOR_CD); // 3.매장코드 (9) DATAHDNode.SetAttribute("SALE_DATE", sSaleDt); // 4.영업일자 (8) DATAHDNode.SetAttribute("POS_NO", m_cPosStatus.Base.PosNo); // 5.포스번호 (2) DATAHDNode.SetAttribute("REGI_SEQ", "00"); // 6.정산차수 (2) //DATAHDNode.SetAttribute("INDEX_NO", m_cPosStatus.Base.ExStoreCd + ";" + //DATAHDNode.SetAttribute("INDEX_NO", m_cPosStatus.Base.OutSDVendConNo + ";" + sSaleDt + ";" + m_cPosStatus.Base.PosNo + ";" + "00"); // 7.인덱스번호 (20) DATAHDNode.SetAttribute("INDEX_NO", m_cPosStatus.Mst.JOIN_STOR_CD + ";" + sSaleDt + ";" + m_cPosStatus.Base.PosNo + ";" + "00"); // 7.인덱스번호 (20) DATAHDNode.SetAttribute("DT_CNT", "1"); // 8.디테일개수 (2) upperNode.AppendChild(DATAHDNode); XmlElement DATADTNode = doc.CreateElement("DATA-DT"); //DATADTNode.SetAttribute("SHOP_CD", m_cPosStatus.Base.ExStoreCd); // 9.매장코드 (9) //DATADTNode.SetAttribute("SHOP_CD", m_cPosStatus.Base.OutSDVendConNo); // 9.매장코드 (9) DATADTNode.SetAttribute("SHOP_CD", m_cPosStatus.Mst.JOIN_STOR_CD); // 9.매장코드 (9) DATADTNode.SetAttribute("SALE_DATE", sSaleDt); // 10.영업일자 (8) DATADTNode.SetAttribute("POS_NO", m_cPosStatus.Base.PosNo); // 11.포스번호 (2) DATADTNode.SetAttribute("REGI_SEQ", "00"); // 12.정산차수 (2) DATADTNode.SetAttribute("EMP_NO", "0000"); // 13.판매원번호 (4) DATADTNode.SetAttribute("CLOSE_FG", "3"); // 14.포스마감구분 (1) DATADTNode.SetAttribute("OPEN_DT", m_cPosStatus.Base.OpenDateTime); // 15.개점일시 (14) DATADTNode.SetAttribute("CLOSE_DT", m_cPosStatus.Base.CloseDateTime); // 16.마감일시 (14) DATADTNode.SetAttribute("TOT_BILL_CNT", CmUtil.GetDataRowStr(dr, "TOT_BILL_CNT")); // 17.총영수건수 (5) DATADTNode.SetAttribute("TOT_SALE_AMT", CmUtil.GetDataRowStr(dr, "DCM_SALE_AMT")); // 18.총매출액 (12) DATADTNode.SetAttribute("TOT_DC_AMT", CmUtil.GetDataRowStr(dr, "TOT_DC_AMT")); // 19.총할인액 (12) DATADTNode.SetAttribute("SVC_TIP_AMT", CmUtil.GetDataRowStr(dr, "SVC_TIP_AMT"));// 20.봉사료 (12) DATADTNode.SetAttribute("TOT_ETC_AMT", CmUtil.GetDataRowStr(dr, "TOT_ETC_AMT"));// 21.기타에누리액(식권짜투리/에누리-끝전) (12) DATADTNode.SetAttribute("DCM_SALE_AMT", CmUtil.GetDataRowStr(dr, "DCM_SALE_AMT")); // 22.실매출액 (12) DATADTNode.SetAttribute("VAT_SALE_AMT", CmUtil.GetDataRowStr(dr, "VAT_SALE_AMT")); // 23.과세매출액 (12) DATADTNode.SetAttribute("VAT_AMT", CmUtil.GetDataRowStr(dr, "VAT_AMT")); // 24.부가세액 (12) DATADTNode.SetAttribute("NO_VAT_SALE_AMT", CmUtil.GetDataRowStr(dr, "NO_VAT_SALE_AMT")); // 25.면세매출액 (12) DATADTNode.SetAttribute("NO_TAX_SALE_AMT", CmUtil.GetDataRowStr(dr, "NO_TAX_SALE_AMT")); // 26.순매출액 (12) DATADTNode.SetAttribute("RET_BILL_CNT", CmUtil.GetDataRowStr(dr, "RET_BILL_CNT")); // 27.취소매출건수 (5) DATADTNode.SetAttribute("RET_BILL_AMT", CmUtil.GetDataRowStr(dr, "RET_BILL_AMT")); // 28.취소매출액 (12) DATADTNode.SetAttribute("VISIT_CST_CNT", CmUtil.GetDataRowStr(dr, "VISIT_CST_CNT"));// 29.방문손님수 (9) DATADTNode.SetAttribute("POS_READY_AMT", CmUtil.GetDataRowStr(dr, "POS_READY_AMT"));// 30.영업준비금 (12) DATADTNode.SetAttribute("POS_CSH_IN_AMT", "0"); // 31.시재입금액 (12) DATADTNode.SetAttribute("POS_CSH_OUT_AMT", "0"); // 32.시재출금액 (12) DATADTNode.SetAttribute("WEA_IN_CSH_AMT", "0"); // 33.외상입금액-현금 (12) DATADTNode.SetAttribute("WEA_IN_CRD_AMT", "0"); // 34.외상입금액-신용카드 (12) DATADTNode.SetAttribute("TK_GFT_SALE_CSH_AMT", "0"); // 35.상품권판매액-현금 (12) DATADTNode.SetAttribute("TK_GFT_SALE_CRD_AMT", "0"); // 36.상품권판매액-신용카드 (12) DATADTNode.SetAttribute("TK_FOD_SALE_CSH_AMT", "0"); // 37.식권판매액-현금 (12) DATADTNode.SetAttribute("TK_FOD_SALE_CRD_AMT", "0"); // 38.식권판매액-신용카드 (12) DATADTNode.SetAttribute("CASH_CNT", CmUtil.GetDataRowStr(dr, "CASH_CNT")); // 39.결제건수-현금 (9) DATADTNode.SetAttribute("CASH_AMT", CmUtil.GetDataRowStr(dr, "CASH_AMT")); // 40.결제액-현금 (12) DATADTNode.SetAttribute("CASH_BILL_CNT", CmUtil.GetDataRowStr(dr, "CASH_BILL_CNT"));// 41.결제건수-현금영수증 (9) DATADTNode.SetAttribute("CASH_BILL_AMT", CmUtil.GetDataRowStr(dr, "CASH_BILL_AMT"));// 42.결제액-현금영수증 (12) DATADTNode.SetAttribute("CRD_CARD_CNT", CmUtil.GetDataRowStr(dr, "CRD_CARD_CNT")); // 43.결제건수-신용카드 (9) DATADTNode.SetAttribute("CRD_CARD_AMT", CmUtil.GetDataRowStr(dr, "CRD_CARD_AMT")); // 44.결제액-신용카드 (12) DATADTNode.SetAttribute("WES_CNT", "0"); // 45.결제건수-외상 (9) DATADTNode.SetAttribute("WES_AMT", "0"); // 46.결제액-외상 (12) DATADTNode.SetAttribute("TK_GFT_CNT", "0"); // 47.결제건수-상품권 (9) DATADTNode.SetAttribute("TK_GFT_AMT", "0"); // 48.결제액-상품권 (12) DATADTNode.SetAttribute("TK_FOD_CNT", "0"); // 49.결제건수-식권 (9) DATADTNode.SetAttribute("TK_FOD_AMT", "0"); // 50.결제액-식권 (12) DATADTNode.SetAttribute("CST_POINT_CNT", "0"); // 51.결제건수-회원포인트 (9) DATADTNode.SetAttribute("CST_POINT_AMT", "0"); // 52.결제액-회원포인트 (12) DATADTNode.SetAttribute("JCD_CARD_CNT", "0"); // 53.결제건수-제휴카드 (9) DATADTNode.SetAttribute("JCD_CARD_AMT", "0"); // 54.결제액-제휴카드 (12) DATADTNode.SetAttribute("RFC_CNT", "0"); // 55.결제건수-RF (9) DATADTNode.SetAttribute("RFC_AMT", "0"); // 56.결제액-RF (12) DATADTNode.SetAttribute("DC_GEN_CNT", "0"); // 57.할인건수-일반 (9) DATADTNode.SetAttribute("DC_GEN_AMT", "0"); // 58.할인액-일반 (12) DATADTNode.SetAttribute("DC_SVC_CNT", "0"); // 59.할인건수-서비스 (9) DATADTNode.SetAttribute("DC_SVC_AMT", "0"); // 60.할인액-서비스 (12) DATADTNode.SetAttribute("DC_JCD_CNT", "0"); // 61.할인건수-제휴카드 (9) DATADTNode.SetAttribute("DC_JCD_AMT", "0"); // 62.할인액-제휴카드 (12) DATADTNode.SetAttribute("DC_CPN_CNT", "0"); // 63.할인건수-쿠폰 (9) DATADTNode.SetAttribute("DC_CPN_AMT", "0"); // 64.할인액-쿠폰 (12) DATADTNode.SetAttribute("DC_CST_CNT", "0"); // 65.할인건수-회원 (9) DATADTNode.SetAttribute("DC_CST_AMT", "0"); // 66.할인액-회원 (12) DATADTNode.SetAttribute("DC_TFD_CNT", "0"); // 67.할인건수-식권 (9) DATADTNode.SetAttribute("DC_TFD_AMT", "0"); // 68.할인액-식권 (12) DATADTNode.SetAttribute("DC_PRM_CNT", "0"); // 69.할인건수-프로모션 (9) DATADTNode.SetAttribute("DC_PRM_AMT", "0"); // 70.할인액-프로모션 (12) DATADTNode.SetAttribute("DC_CRD_CNT", "0"); // 71.할인건수-신용카드 (9) DATADTNode.SetAttribute("DC_CRD_AMT", "0"); // 72.할인액-신용카드 (12) DATADTNode.SetAttribute("DC_PACK_CNT", "0"); // 73.할인건수-포장할인 (9) DATADTNode.SetAttribute("DC_PACK_AMT", "0"); // 74.할인액-포장할인 (12) DATADTNode.SetAttribute("DC_EMP_CNT", "0"); DATADTNode.SetAttribute("DC_EMP_AMT", "0"); DATADTNode.SetAttribute("REM_CHECK_CNT", CmUtil.GetDataRowStr(dr, "REM_CHECK_CNT"));// 75.수표수량 (9) DATADTNode.SetAttribute("REM_CHECK_AMT", CmUtil.GetDataRowStr(dr, "REM_CHECK_AMT"));// 76.수표금액 (12) DATADTNode.SetAttribute("REM_W100000_CNT", CmUtil.GetDataRowStr(dr, "REM_W100000_CNT")); // 77.십만원권수량 (9) DATADTNode.SetAttribute("REM_W50000_CNT", CmUtil.GetDataRowStr(dr, "REM_W50000_CNT")); // 78.오만원권수량 (9) DATADTNode.SetAttribute("REM_W10000_CNT", CmUtil.GetDataRowStr(dr, "REM_W10000_CNT")); // 79.만원권수량 (9) DATADTNode.SetAttribute("REM_W5000_CNT", CmUtil.GetDataRowStr(dr, "REM_W5000_CNT")); // 80.오천원권수량 (9) DATADTNode.SetAttribute("REM_W1000_CNT", CmUtil.GetDataRowStr(dr, "REM_W1000_CNT")); // 81.천원권수량 (9) DATADTNode.SetAttribute("REM_W500_CNT", CmUtil.GetDataRowStr(dr, "REM_W500_CNT")); // 82.오백원권수량 (9) DATADTNode.SetAttribute("REM_W100_CNT", CmUtil.GetDataRowStr(dr, "REM_W100_CNT")); // 83.백원권수량 (9) DATADTNode.SetAttribute("REM_W50_CNT", CmUtil.GetDataRowStr(dr, "REM_W50_CNT")); // 84.오십원권수량 (9) DATADTNode.SetAttribute("REM_W10_CNT", CmUtil.GetDataRowStr(dr, "REM_W10_CNT")); // 85.십원권수량 (9) DATADTNode.SetAttribute("REM_CASH_AMT", "0"); // 86.마감현금시재액 (12) DATADTNode.SetAttribute("REM_TK_GFT_CNT", "0"); // 87.상품권시재건수 (9) DATADTNode.SetAttribute("REM_TK_GFT_AMT", "0"); // 88.상품권시재금액 (12) DATADTNode.SetAttribute("REM_TK_FOD_CNT", "0"); // 89.식권시재건수 (9) DATADTNode.SetAttribute("REM_TK_FOD_AMT", "0"); // 90.식권시재금액 (12) DATADTNode.SetAttribute("ETC_TK_FOD_AMT", "0"); // 91.식권-짜투리 (12) DATADTNode.SetAttribute("LOSS_CASH_AMT", CmUtil.GetDataRowStr(dr, "LOSS_CASH_AMT")); // 92.현금과부족 (12) DATADTNode.SetAttribute("LOSS_TK_GFT_AMT", "0"); // 93.상품권과부족 (12) DATADTNode.SetAttribute("LOSS_TK_FOD_AMT", "0"); // 94.식권과부족 (12) DATADTNode.SetAttribute("REPAY_CASH_CNT", "0"); // 95.상품권-현금환불건수 (9) DATADTNode.SetAttribute("REPAY_CASH_AMT", "0"); // 96.상품권-현금환불액 (12) DATADTNode.SetAttribute("REPAY_TK_GFT_CNT", "0"); // 97.상품권-환불건수 (9) DATADTNode.SetAttribute("REPAY_TK_GFT_AMT", "0"); // 98.상품권-환불액 (12) DATADTNode.SetAttribute("COM_CNT", "0"); // 99.수수료건수 (9) DATADTNode.SetAttribute("COM_AMT", "0"); // 100.수수료이익금액 (12) DATADTNode.SetAttribute("PREPAY_CNT", "0"); // 101.선수선입금건수 (9) DATADTNode.SetAttribute("PREPAY_AMT", "0"); // 102.선수선입금액 (12) DATADTNode.SetAttribute("INS_DT", m_cPosStatus.Base.CloseDateTime); // 103.등록일시 (14) DATADTNode.SetAttribute("BILL_NO_END", CmUtil.GetDataRowStr(dr, "BILL_NO_END").Substring(1, 4));// 104.마지막영수증번호 (4) DATAHDNode.AppendChild(DATADTNode); } catch(Exception ex) { UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + // Class Name (Class Name (클래스명)) System.Reflection.MethodBase.GetCurrentMethod().Name + "()", // Function Name (Function Name (함수명)) ex.Message); } } #endregion 01 - 도로공사 정산Data 조회 및 생성 #region 02 - 한국공항공사 정산Data 조회 및 생성 private DataTable GetCalcData1ForKac(string sCmpCd, string sSaleDt, string sStorCd, string sPosNo) { string sQuery = string.Empty; StringBuilder sb = new StringBuilder(); DataTable dtReturn = null; try { sb.Append("SELECT COUNT(DISTINCT TSD.TRADE_NO) AS BILL_CNT "); sb.Append(" , MAX(TSD.TRADE_NO) + 1 AS MAX_BILL "); sb.Append(" , SUM(ISNULL(TSD.BILL_AMT, 0)) AS SUM_AMT "); sb.Append(" , SUM(ISNULL(TSD.BILL_AMT, 0) - ISNULL(TSD.APPLY_TAX_AMT, 0)) AS NET_AMT "); sb.Append(" , SUM(ISNULL(TSD.APPLY_TAX_AMT, 0)) AS VAT_AMT "); sb.Append(" FROM POSLOG..TR_SALE_HEADER TSH "); sb.Append(" , POSLOG..TR_SALE_DETAIL TSD "); sb.Append(" WHERE TSH.CMP_CD = '{0}' "); sb.Append(" AND TSH.SALE_DT = '{1}' "); sb.Append(" AND TSH.STOR_CD = '{2}' "); sb.Append(" AND TSH.POS_NO = '{3}' "); sb.Append(" AND TSH.TRAIN_MODE_YN = '" + ItemConst.TRAINING_FLAG.TRAINING_NO + "' "); sb.Append(" AND TSH.TRADE_KINDPER = '" + ItemConst.TRAN_KIND.NORMAL.SALE + "' "); sb.Append(" AND TSH.CMP_CD = TSD.CMP_CD "); sb.Append(" AND TSH.SALE_DT = TSD.SALE_DT "); sb.Append(" AND TSH.STOR_CD = TSD.STOR_CD "); sb.Append(" AND TSH.POS_NO = TSD.POS_NO "); sb.Append(" AND TSH.TRADE_NO = TSD.TRADE_NO "); dtReturn = m_cMstService.Select(new string[] { sb.ToString() }); } catch (Exception ex) { UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + // Class Name (Class Name (클래스명)) System.Reflection.MethodBase.GetCurrentMethod().Name + "()", // Function Name (Function Name (함수명)) ex.Message); } return dtReturn; } private DataTable GetCalcData2ForKac(string sCmpCd, string sSaleDt, string sStorCd, string sPosNo) { string sQuery = string.Empty; StringBuilder sb = new StringBuilder(); DataTable dtReturn = null; try { sb.Append("SELECT (A.CASH_AMT + B.CARD_AMT + C.ETC_AMT) AS TOTLA_AMT "); sb.Append(" , A.CASH_AMT AS CASH_AMT "); sb.Append(" , B.CARD_AMT AS CARD_AMT "); sb.Append(" , C.ETC_AMT AS ETC_AMT "); sb.Append(" FROM ( "); sb.Append(" SELECT SUM(CASE WHEN TSH.TRADE_DIV = '0' "); sb.Append(" THEN 1 "); sb.Append(" ELSE (-1) "); sb.Append(" END * ISNULL(TSP.PAY_AMT, 0)) AS CASH_AMT "); sb.Append(" FROM POSLOG..TR_SALE_HEADER TSH "); sb.Append(" , POSLOG..TR_SALE_PAY TSP "); sb.Append(" WHERE TSH.CMP_CD = '{0}' "); sb.Append(" AND TSH.SALE_DT = '{1}' "); sb.Append(" AND TSH.STOR_CD = '{2}' "); sb.Append(" AND TSH.POS_NO = '{3}' "); sb.Append(" AND TSH.TRAIN_MODE_YN = '" + ItemConst.TRAINING_FLAG.TRAINING_NO + "' "); sb.Append(" AND TSH.TRADE_KINDPER = '" + ItemConst.TRAN_KIND.NORMAL.SALE + "' "); sb.Append(" AND TSH.CMP_CD = TSP.CMP_CD "); sb.Append(" AND TSH.SALE_DT = TSP.SALE_DT "); sb.Append(" AND TSH.STOR_CD = TSP.STOR_CD "); sb.Append(" AND TSH.POS_NO = TSP.POS_NO "); sb.Append(" AND TSH.TRADE_NO = TSP.TRADE_NO "); sb.Append(" AND TSP.PAY_WAY_CD = '" + ItemConst.TR_ITEM_ID.CASH_ITEM + "' "); sb.Append(" ) A "); sb.Append(" , ( "); sb.Append(" SELECT SUM(CASE WHEN TSH.TRADE_DIV = '0' "); sb.Append(" THEN 1 "); sb.Append(" ELSE (-1) "); sb.Append(" END * ISNULL(TSP.PAY_AMT, 0)) AS CARD_AMT "); sb.Append(" FROM POSLOG..TR_SALE_HEADER TSH "); sb.Append(" , POSLOG..TR_SALE_PAY TSP "); sb.Append(" WHERE TSH.CMP_CD = '{0}' "); sb.Append(" AND TSH.SALE_DT = '{1}' "); sb.Append(" AND TSH.STOR_CD = '{2}' "); sb.Append(" AND TSH.POS_NO = '{3}' "); sb.Append(" AND TSH.TRAIN_MODE_YN = '" + ItemConst.TRAINING_FLAG.TRAINING_NO + "' "); sb.Append(" AND TSH.TRADE_KINDPER = '" + ItemConst.TRAN_KIND.NORMAL.SALE + "' "); sb.Append(" AND TSH.SALE_DT = TSP.CMP_CD "); sb.Append(" AND TSH.STOR_CD = TSP.STOR_CD "); sb.Append(" AND TSH.POS_NO = TSP.POS_NO "); sb.Append(" AND TSH.TRADE_NO = TSP.TRADE_NO "); sb.Append(" AND TSP.PAY_WAY_CD = '" + ItemConst.TR_ITEM_ID.CREDITCARD_ITEM + "' "); sb.Append(" ) B "); sb.Append(" , ( "); sb.Append(" SELECT SUM(CASE WHEN TSH.TRADE_DIV = '0' "); sb.Append(" THEN 1 "); sb.Append(" ELSE (-1) "); sb.Append(" END * ISNULL(TSP.PAY_AMT, 0)) AS ETC_AMT "); sb.Append(" FROM POSLOG..TR_SALE_HEADER TSH "); sb.Append(" , POSLOG..TR_SALE_PAY TSP "); sb.Append(" WHERE TSH.CMP_CD = '{0}' "); sb.Append(" AND TSH.SALE_DT = '{1}' "); sb.Append(" AND TSH.STOR_CD = '{2}' "); sb.Append(" AND TSH.POS_NO = '{3}' "); sb.Append(" AND TSH.TRAIN_MODE_YN = '" + ItemConst.TRAINING_FLAG.TRAINING_NO + "' "); sb.Append(" AND TSH.TRADE_KINDPER = '" + ItemConst.TRAN_KIND.NORMAL.SALE + "' "); sb.Append(" AND TSH.SALE_DT = TSP.CMP_CD "); sb.Append(" AND TSH.STOR_CD = TSP.STOR_CD "); sb.Append(" AND TSH.POS_NO = TSP.POS_NO "); sb.Append(" AND TSH.TRADE_NO = TSP.TRADE_NO "); sb.Append(" AND TSP.PAY_WAY_CD <> '" + ItemConst.TR_ITEM_ID.CASH_ITEM + "' "); sb.Append(" AND TSP.PAY_WAY_CD <> '" + ItemConst.TR_ITEM_ID.CREDITCARD_ITEM + "' "); sb.Append(" ) C "); dtReturn = m_cMstService.Select(new string[] { sb.ToString() }); } catch (Exception ex) { UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + // Class Name (Class Name (클래스명)) System.Reflection.MethodBase.GetCurrentMethod().Name + "()", // Function Name (Function Name (함수명)) ex.Message); } return dtReturn; } private Column.KACCalcData MakeCalcDataForKac(string sCmpCd, string sSaleDt, string sStorNo, string sPosNo, DataTable dtCalc1Data, DataTable dtCalc2Data) { Column.KACCalcData cCalcData = new Column.KACCalcData(); try { string sSaleTm = DateTime.Now.ToString("HHmmss"); string sSysDate = DateTime.Now.ToString("yyyyMMddHHmmss"); ////////////////////////////////////////////////////////////// // 마감 정보 (마감정보) - dtCalc1Data // ////////////////////////////////////////////////////////////// cCalcData.TRAN_TYPE = "CALC"; // 정산 //cCalcData.CON_NO = m_cPosStatus.Base.KacConNo; // 계약번호 //cCalcData.CON_NO = m_cPosStatus.Base.OutSDVendConNo; // 계약번호 cCalcData.CON_NO = m_cPosStatus.Mst.JOIN_STOR_CD; // 계약번호 cCalcData.SALE_DT = sSaleDt; // 영업일자 cCalcData.STORE_CD = sStorNo; // 점번호 cCalcData.POS_NO = sPosNo; // POS번호 cCalcData.RECEIPT_SEQ = CmUtil.GetDataRowStr(dtCalc1Data.Rows[0], "MAX_BILL"); // 순차적으로 증가하는 값 cCalcData.RECEIPT_NO = CmUtil.GetDataRowStr(dtCalc1Data.Rows[0], "MAX_BILL"); // 영수증번호 cCalcData.SALE_TM = sSaleTm; // 매출시간 cCalcData.RECEIPT_QTY = CmUtil.GetDataRowStr(dtCalc1Data.Rows[0], "BILL_CNT"); // 매출건수 //cCalcData.TOTAL_AMT = "0"; // 총매출금액 cCalcData.SALE_AMT = CmUtil.GetDataRowStr(dtCalc1Data.Rows[0], "NET_AMT"); // 총공급가액 cCalcData.TAX_AMT = CmUtil.GetDataRowStr(dtCalc1Data.Rows[0], "VAT_AMT"); // 총부가세액 //cCalcData.CASH_AMT = "0"; // 총현금금액 //cCalcData.CARD_AMT = "0"; // 총카드금액 //cCalcData.ETC_AMT = "0"; // 총기타금액 cCalcData.CREATE_DT = sSysDate; // 생성일자 ////////////////////////////////////////////////////////////// // 마감 정보 (마감정보) - dtCalc2Data // ////////////////////////////////////////////////////////////// cCalcData.TOTAL_AMT = CmUtil.GetDataRowStr(dtCalc2Data.Rows[0], "TOTLA_AMT"); // 총매출금액 cCalcData.CASH_AMT = CmUtil.GetDataRowStr(dtCalc2Data.Rows[0], "CASH_AMT"); // 총현금금액 cCalcData.CARD_AMT = CmUtil.GetDataRowStr(dtCalc2Data.Rows[0], "CARD_AMT"); // 총카드금액 cCalcData.ETC_AMT = CmUtil.GetDataRowStr(dtCalc2Data.Rows[0], "ETC_AMT"); // 총기타금액 } catch (Exception ex) { UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + // Class Name (Class Name (클래스명)) System.Reflection.MethodBase.GetCurrentMethod().Name + "()", // Function Name (Function Name (함수명)) ex.Message); } return cCalcData; } #endregion 02 - 한국공항공사 정산Data 조회 및 생성 //#20180322 휴게소pos매출연동 start,phj #region 03 - 도로공사2018 private string MakeCalcDataJsonForEx(string sSaleDt, DataTable dtData) { var sJsonData = string.Empty; try { if (dtData == null || dtData.Rows.Count == 0) return null; DataRow dr = dtData.Rows[0]; Hashtable htData = new Hashtable(); Hashtable htData_Cover = new Hashtable(); var sCloseDate = CmUtil.GetDataRowStr(dr, "CLOSE_DATETIME"); //마감일시 처리 ( 마감쿼리로 못 가져올 경우 현재 이면 지금 시간을 입력함) var sOpenDate = CmUtil.GetDataRowStr(dr, "OPEN_DATETIME"); htData.Add("SALE_DAY", sSaleDt); //기준영업일 //#20180406 도로공사 수정 start //REGI_TYPE : 0 으로 생성 (총정산) //기존 //htData.Add("REGI_TYPE", "1"); //정산종류(0: 총정산, 1:캐셔별 정산) //변경 htData.Add("REGI_TYPE", "0"); //정산종류(0: 총정산, 1:캐셔별 정산) //#20180406 도로공사 수정 end if (sOpenDate.Equals(string.Empty) == true && DateTime.Now.ToString("yyyyMMdd").Equals(sSaleDt)) //개설년월일시분(YYYYMMDDhhmm) htData.Add("OPEN_DATETIME", DateTime.Now.ToString("yyyyMMdd") + "0600"); else htData.Add("OPEN_DATETIME", CmUtil.GetDataRowStr(dr, "OPEN_DATETIME").Substring(0, 12)); if (sCloseDate.Equals(string.Empty) == true && DateTime.Now.ToString("yyyyMMdd").Equals(sSaleDt)) //정산년월일시분(YYYYMMDDhhmm) htData.Add("CLOSE_DATETIME", DateTime.Now.ToString("yyyyMMddHHmm")); else htData.Add("CLOSE_DATETIME", CmUtil.GetDataRowStr(dr, "CLOSE_DATETIME").Substring(0, 12)); htData.Add("CASHIER_ID", "0000"); //캐셔 ID htData.Add("BILL_NO_START", CmUtil.GetDataRowStr(dr, "BILL_NO_START").PadLeft(8, '0')); //시작영수증번호 htData.Add("BILL_NO_END", CmUtil.GetDataRowStr(dr, "BILL_NO_END").PadLeft(8, '0')); //종료영수증번호 htData.Add("TOT_AMT_CNT", CmUtil.GetDataRowStr(dr, "TOT_AMT_CNT")); //총판매 건수 htData.Add("TOT_AMT", CmUtil.GetDataRowStr(dr, "TOT_AMT")); //총판매 총 금액 htData.Add("CANCEL_TOT_CNTT", CmUtil.GetDataRowStr(dr, "CANCEL_TOT_CNTT")); //반품 건수 htData.Add("CANCEL_TOT", CmUtil.GetDataRowStr(dr, "CANCEL_TOT")); //반품총금액 htData.Add("SALE_TOT_CNT", CmUtil.GetDataRowStr(dr, "SALE_TOT_CNT")); //총매출 건수 htData.Add("SALE_TOT", CmUtil.GetDataRowStr(dr, "SALE_TOT")); //총매출 금액 htData.Add("SALE_AMT_CNT", CmUtil.GetDataRowStr(dr, "SALE_AMT_CNT")); //순매출 건수 htData.Add("SALE_AMT", CmUtil.GetDataRowStr(dr, "SALE_AMT")); //순매출 금액 htData.Add("CARD_AMT1_CNT", CmUtil.GetDataRowStr(dr, "CARD_AMT1_CNT")); //신용/선불카드 일시불 건수 htData.Add("CARD_AMT1", CmUtil.GetDataRowStr(dr, "CARD_AMT1")); //신용/선불카드 일시불 금액 htData.Add("CARD_AMT2_CNT", CmUtil.GetDataRowStr(dr, "CARD_AMT2_CNT")); //신용/선불카드 할부 건수 htData.Add("CARD_AMT2", CmUtil.GetDataRowStr(dr, "CARD_AMT2")); //신용/선불카드 할부 금액 htData.Add("CARD_AMT3_CNT", CmUtil.GetDataRowStr(dr, "CARD_AMT3_CNT")); //신용/선불카드 반품일시불 건수 htData.Add("CARD_AMT3", CmUtil.GetDataRowStr(dr, "CARD_AMT3")); //신용/선불카드 반품일시불 금액 htData.Add("CARD_AMT4_CNT", CmUtil.GetDataRowStr(dr, "CARD_AMT4_CNT")); //신용/선불카드 반품할부 건수 htData.Add("CARD_AMT4", CmUtil.GetDataRowStr(dr, "CARD_AMT4")); //신용/선불카드 반품할부 금액 htData.Add("TMP_CARD_AMT2_CNT", "0"); //임의등록 신용/선불 건수 htData.Add("TMP_CARD_AMT2", "0"); //임의등록 신용/선불 금액 htData.Add("CASH_AMT_CNT", CmUtil.GetDataRowStr(dr, "CASH_AMT_CNT")); //현금매출 건수 htData.Add("CASH_AMT", CmUtil.GetDataRowStr(dr, "CASH_AMT")); //현금매출 금액 htData.Add("GIFT_TOT_CNT", "0"); //상품권총판매 건수 htData.Add("GIFT_TOT", "0"); //상품권총판매 금액 htData.Add("GIFT_CANCEL_TOT_CNT", "0"); //상품권총환불 건수 htData.Add("GIFT_CANCEL_TOT", "0"); //상품권총환불 금액 htData.Add("GIFT_SALE_AMT_CNT", "0"); //상품권매출 건수 htData.Add("GIFT_SALE_AMT", "0"); //상품권매출 금액 htData.Add("GIFT_CASH_TOT_CNT", "0"); //총현금매출 건수 htData.Add("GIFT_CASH_TOT", "0"); //총현금매출 금액 htData.Add("INTERIM_CASH2_CNT", "0"); //선수입금 건수 htData.Add("INTERIM_CASH2", "0"); //선구입금 금액 htData.Add("INTERIM_CASH3_CNT", "0"); //수수료이익액 건수 htData.Add("INTERIM_CASH3", "0"); //수수료이익액 금액 htData.Add("ADDED_TAX_CNT", "0"); //미포함 부가세 금액 건수 htData.Add("ADDED_TAX", "0"); //미포함 부가세 금액 금액 htData.Add("ETC_1_CNT", CmUtil.GetDataRowStr(dr, "ETC_1_CNT")); //실매출 건수 htData.Add("ETC_1", CmUtil.GetDataRowStr(dr, "ETC_1")); //실매출 금액 htData.Add("BONUS_PAY_AMT_CNT", "0"); //보너스포인트 사용 건수 htData.Add("BONUS_PAY_AMT", "0"); //보너스포인트 사용 금액 htData.Add("ETC_11_CNT", "0"); //미전송 매출 개수 htData.Add("EMP_ID", "0"); //마감 매니저 ID htData.Add("REST_END_GB", "0"); //POS 마감 구분(0: 미마감, 1: 마감) htData.Add("DC_AMT_CNT", CmUtil.GetDataRowStr(dr, "DC_AMT_CNT")); //할인 건수 htData.Add("DC_AMT", CmUtil.GetDataRowStr(dr, "DC_AMT")); //할인 총 금액 htData.Add("REGULAR_DC_AMT_CNT", CmUtil.GetDataRowStr(dr, "REGULAR_DC_AMT_CNT")); //정상 DC 금액 건수 htData.Add("REGULAR_DC_AMT", CmUtil.GetDataRowStr(dr, "REGULAR_DC_AMT")); //정상 DC 금액 htData.Add("SERVICE_DC_AMT_CNT", "0"); //서비스 DC 금액 건수 htData.Add("SERVICE_DC_AMT", "0"); //서비스 DC 금액 htData.Add("AFCARD_DC_AMT_CNT", "0"); //제휴카드 DC 금액 건수 htData.Add("AFCARD_DC_AMT", "0"); //제휴카드 DC 금액 htData.Add("COUPON_DC_AMT_CNT", "0"); //쿠폰 DC 금액 건수 htData.Add("COUPON_DC_AMT", "0"); //쿠폰 DC 금액 htData.Add("CUSTOM_DC_AMT_CNT", "0"); //고객 혜택 DC 금액 건수 htData.Add("CUSTOM_DC_AMT", "0"); //고객 혜택 DC 금액 htData.Add("CANCEL_DC_AMT", CmUtil.GetDataRowStr(dr, "CANCEL_DC_AMT")); //반품할인 매출 금액 htData.Add("VAT_AMT", CmUtil.GetDataRowStr(dr, "VAT_AMT")); //부가세 매출 금액 htData_Cover.Add("SALE_SUM", htData); sJsonData = JsonConvert.SerializeObject(htData_Cover); } catch (Exception ex) { UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + // Class Name (Class Name (클래스명)) System.Reflection.MethodBase.GetCurrentMethod().Name + "()", // Function Name (Function Name (함수명)) ex.Message); } return sJsonData; } #endregion 03 - 도로공사2018 //#20180322 휴게소pos매출연동 end,phj } }