using System;
using System.Collections;
using System.Text;

using Cosmos.UserFrame;
using Cosmos.ServiceProvider;
using Cosmos.Common;
using Cosmos.CommonManager;
using System.Data;

/*-----------------------------------------------------------------------------------------------*/
// 설      명 : OKCASHBACK 적립
// 작  성  자 : 
// 변경  이력 : 
/*-----------------------------------------------------------------------------------------------*/
namespace Cosmos.Service
{
    class PointOcbSave : PaymentBase, IPaymentUs, IPaymentExpUs
    {
        /// <summary>
        /// 현재 등록중인 기타 정보
        /// </summary>
        protected Column.TR_ETC.DATA m_cEtcItem = null;
        private IOCBDirect m_OCBDirect = null ;

        public PointOcbSave()
        {
            m_OCBDirect = (IOCBDirect)sManager.InitServiceInstance(ServiceLists.AGENT_OLEDEVICE.DLL, ServiceLists.AGENT_OLEDEVICE.OCB_DIRECT);
        }

        #region SearchPayment 결제 조회
        /// <summary>
        /// 결제 조회(OKCASHBACK 조회)
        /// </summary>
        /// <param name="aParam"></param>
        /// <param name="aRet"></param>
        /// <returns></returns>
        public string SearchPayment(string[] aParam, ref string[] aRet)
        {
            string sRet = UserCom.RST_ERR;

            string sInPutType = "", sInPutData = "", sInEncData = "";

            try
            {
                sInPutType = aParam[0];                      // 입력구분
                sInPutData = aParam[1];                      // 입력데이터
                sInEncData = aParam[2];                      // 카드데이터
                m_bErrMsgShow = aParam[3] == "0" ? false : true;    // 메시지 출력여부(0:미출력, 1;출력)
                m_cEtcItem = new Column.TR_ETC.DATA();       // 결과 저장 변수 생성
                m_cEtcItem.ETC_WAY_CD = ItemConst.TR_ITEM_ID.ETC_INFO_ITEM;
                m_cEtcItem.ETC_DTL_CD_01 = ItemConst.TR_ITEM_ID.ETC_INFO.OCB_SAVE;

                if (PosMstManager.GetPosOption(POS_OPTION.OPT326) != "0" && PosMstManager.GetPosOption(POS_OPTION.OPT326) != "" && m_cDevStatus.ICReader.UseYn != true)       // OCB 직통신
                {
                    sRet = ExecutePointOCBDirectIrt(PosConst.CANCEL_DIV.NORMAL, m_cEtcItem.ETC_WAY_CD, m_cEtcItem.ETC_DTL_CD_01, PosConst.POS_OCB_DIRECT.INQ_POINT, sInPutType, sInPutData, sInEncData, "", m_cTrnStatus.Sale.NetSaleAmt, "", "", "");        
                }
                else
                {
                    sRet = ExecutePointHappyPointIrt(PosConst.CANCEL_DIV.NORMAL, PosConst.POS_VAN_MASTER.TRADE_ID.VAN_POT_QRY_A, "OCB", sInPutType, sInPutData, sInEncData, m_cTrnStatus.Sale.NetSaleAmt, 0, "", "", "", "");
                }
                if (sRet != UserCom.RST_OK) return sRet;
            }
            catch (Exception ex)
            {
                if (m_bErrMsgShow) WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                   System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }
            finally
            {
                //여전법 대응!
                //////////////////////////////////////////////////////////////////////////////////
                CmUtil.ZeroFillClear(ref sInPutData);
                CmUtil.ZeroFillClear(ref sInEncData);
                CmUtil.ZeroFillClear(ref aParam);
                //////////////////////////////////////////////////////////////////////////////////
            }
            return sRet;
        }
        #endregion

        #region GetPayment 결제 정보 획득
        /// <summary>
        /// 결제 정보 획득
        /// </summary>
        /// <param name="aParam"></param>
        /// <returns></returns>
        public object GetPayment(string[] aParam)
        {
            return m_cEtcItem;
        }
        #endregion

        #region SetPayment 결제 등록
        /// <summary>
        /// 결제 등록(OKCASHBACK 카드 등록)
        /// </summary>
        /// <param name="aParam"></param>
        /// <returns></returns>
        public string SetPayment(string[] aParam)
        {
            string sRet = UserCom.RST_ERR;
            string sInPutType = "", sInPutData = "", sInEncData = "";

            try
            {
                sInPutType = aParam[0];                         // 입력구분
                sInPutData = aParam[1];                         // 입력데이터(마스킹)
                sInEncData = aParam[2];                         // 카드데이터(암호화)
               
                ArrayList alEtcItem = (ArrayList)StateObject.GetItemObject(Column.TR_ETC.ITEM);     // 기타 내역 받아 오기

                // OKCASHBACK 아이템 설정
                m_cEtcItem.SEQ = alEtcItem.Count + 1;
                alEtcItem.Add(m_cEtcItem);

                m_cDataService.UpdatePluAmount();       // 상품 합계금액 계산(거래해더)
                m_cDataService.UpdatePayAmount();       // 결제 금액 재 계산 처리

                sRet = UserCom.RST_OK;
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                   System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }
            finally
            {
                //여전법 대응!
                //////////////////////////////////////////////////////////////////////////////////
                CmUtil.ZeroFillClear(ref sInPutData);
                CmUtil.ZeroFillClear(ref sInEncData);
                CmUtil.ZeroFillClear(ref aParam);
                //////////////////////////////////////////////////////////////////////////////////
                m_bErrMsgShow = true;
            }
            return sRet;
        }
        #endregion

        #region CancelPayment 결제 취소
        /// <summary>
        /// 결제 취소(OKCASHBACK 카드 등록취소)
        /// </summary>
        /// <param name="aParam"></param>
        /// <returns></returns>
        public string CancelPayment(string[] aParam)
        {
            string sRet = UserCom.RST_ERR;

            try
            {
                if (m_cTrnStatus.Head.TradeDiv != ItemConst.TRAN_DIV.NORMAL) return sRet;

                int nPayRow = CmUtil.IntParse(aParam[0]); // 취소할 행번호

                ArrayList alEtcItem = (ArrayList)StateObject.GetItemObject(Column.TR_ETC.ITEM);     // 기타 내역 받아 오기
                m_cEtcItem = (Column.TR_ETC.DATA)alEtcItem[nPayRow];

                if (m_cEtcItem.OCCUR_ENTRY_08 == ItemConst.PAY_APP_DIV.CAT_TERMINAL)    //단말기승인
                {
                    string[] m_aParam = new string[15];

                    //InParam
                    // 0.전문구분,1.거래유형, 2.할부개월, 3.승인금액 , 4.봉사료, 5.세금, 6.원승인번호, 7.원거래일자, 8.포인트거래구분, 9.상품코드,
                    //10.전표인쇄여부,11.추가항목,12.제휴할인코드,13.제휴할인금액,14.예비1

                    string sAppId = PosConst.POS_CAT_MASTER.TRADE_ID.CAT_POINT_SAVE_CANCEL;

                    m_aParam[0] = PosConst.POS_CAT_MASTER.TRAN_TYPE;
                    m_aParam[1] = sAppId;
                    m_aParam[2] = "00";
                    m_aParam[3] = m_cEtcItem.AMT_ENTRY_08.ToString();
                    m_aParam[4] = "0"; //봉사료
                    m_aParam[5] = "0"; //세금
                    m_aParam[6] = m_cEtcItem.OCCUR_ENTRY_02;
                    m_aParam[7] = m_cEtcItem.OCCUR_ENTRY_03;
                    m_aParam[8] = "02";
                    m_aParam[9] = "";
                    m_aParam[10] = "";
                    m_aParam[11] = "";
                    m_aParam[12] = "";
                    m_aParam[13] = "";
                    m_aParam[14] = "";

                    sRet = CatExecuteIrt(m_aParam[1], m_aParam);
                    if (sRet != UserCom.RST_OK) return sRet;
                }



                m_cEtcItem.CANCEL_DIV = PosConst.CANCEL_DIV.CANCEL;

                m_cDataService.UpdatePluAmount();       // 상품 합계금액 계산(거래해더)
                m_cDataService.UpdatePayAmount();       // 결제 금액 재 계산 처리

                sRet = UserCom.RST_OK;
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                   System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }
            return sRet;
        }
        #endregion

        #region CompletePayment 결제 확정
        /// <summary>
        /// 결제 확정(OKCASHBACK 카드 적립)
        /// </summary>
        /// <param name="aParam"></param>
        /// <returns></returns>
        public string CompletePayment(string[] aParam)
        {
            string sRet = UserCom.RST_ERR;

            string sInPutType = "", sInPutData = "", sInEncData = "";

            try
            {

                m_cEtcItem = null;
                ArrayList alEtcItem = (ArrayList)StateObject.GetItemObject(Column.TR_ETC.ITEM);     // 기타 내역 받아 오기
                foreach (Column.TR_ETC.DATA cEtcItem in alEtcItem)
                {
                    if (cEtcItem.CANCEL_DIV == ItemConst.PAY_CANCEL_DIV.CANCEL) continue;

                    if (cEtcItem.ETC_WAY_CD == ItemConst.TR_ITEM_ID.ETC_INFO_ITEM && cEtcItem.ETC_DTL_CD_01 == ItemConst.TR_ITEM_ID.ETC_INFO.OCB_SAVE)
                    {
                        m_cEtcItem = cEtcItem;
                        break;
                    }
                }


                if (aParam.Length > 0 && aParam[0] == PosConst.POS_CAT_MASTER.TRAN_TYPE)    //단말기승인
                {
                    bool bNewAddFlag = false;

                    if (m_cEtcItem == null)
                    {
                        bNewAddFlag = true;
                        m_cEtcItem = new Column.TR_ETC.DATA();
                    }

                    m_cEtcItem.ETC_WAY_CD = ItemConst.TR_ITEM_ID.ETC_INFO_ITEM;
                    m_cEtcItem.ETC_DTL_CD_01 = ItemConst.TR_ITEM_ID.ETC_INFO.OCB_SAVE;

                    aParam[3] = m_cDataService.GetPluTagetAmount(PosKey.MENU_KEY.OKCASHBACK_SAVE).ToString();     // 적립 대상 금액
                    if (CmUtil.DoubleParse(aParam[3]) < 1000)
                    {
                        // 적립대상 금액이 1000원 이상 이어야 함.
                        m_cEtcItem.CANCEL_DIV = PosConst.CANCEL_DIV.CANCEL;
                        return sRet;
                    }

                    sRet = CatExecuteIrt(aParam[1], aParam);
                    if (sRet != UserCom.RST_OK) return sRet;

                    if (bNewAddFlag == true)
                    {
                        m_cEtcItem.SEQ = alEtcItem.Count + 1;
                        alEtcItem.Add(m_cEtcItem);
                    }
                }
                else
                {
                    
                    if (m_cEtcItem == null) return sRet;

                    sInPutType = m_cEtcItem.OCCUR_ENTRY_05;          // 입력구분
                    sInPutData = m_cEtcItem.OCCUR_ENTRY_01;          // 입력데이터(마스킹)
                    sInEncData = m_cEtcItem.CanFiller1;              // 카드데이터(암호화)

                    double nNetSaleAmt = m_cTrnStatus.Sale.NetSaleAmt;      // 영수금액
                    double nBasicSaveAmt = m_cDataService.GetPluTagetAmount(PosKey.MENU_KEY.OKCASHBACK_SAVE);     // 적립 대상 금액
                    if (nBasicSaveAmt < 1000)
                    {
                        // 적립대상 금액이 1000원 이상 이어야 함.
                        m_cEtcItem.CANCEL_DIV = PosConst.CANCEL_DIV.CANCEL;
                        return sRet;
                    }

                    while (true)
                    {
                        // OKCASHBACK 적립 승인 처리
                        if (PosMstManager.GetPosOption(POS_OPTION.OPT326) != "0" && PosMstManager.GetPosOption(POS_OPTION.OPT326) != "" && m_cDevStatus.ICReader.UseYn != true)       // OCB 직통신
                        {
                            sRet = ExecutePointOCBDirectIrt(PosConst.CANCEL_DIV.NORMAL, m_cEtcItem.ETC_WAY_CD, m_cEtcItem.ETC_DTL_CD_01, PosConst.POS_OCB_DIRECT.SAVE_POINT, sInPutType, sInPutData, sInEncData, "", nBasicSaveAmt, m_cEtcItem.OCCUR_ENTRY_03, m_cEtcItem.OCCUR_ENTRY_02, m_cEtcItem.OCCUR_ENTRY_17);
                        }
                        else
                        {
                            sRet = ExecutePointHappyPointIrt(PosConst.CANCEL_DIV.NORMAL, PosConst.POS_VAN_MASTER.TRADE_ID.VAN_POT_ACC_A, "OCB", sInPutType, sInPutData, sInEncData
                                , nNetSaleAmt, nBasicSaveAmt, "", "", "", "");
                        }
                        if (sRet != UserCom.RST_OK)
                        {
                            if (WinManager.QuestionMessage(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0490)) == true) continue;

                            m_cEtcItem.CANCEL_DIV = PosConst.CANCEL_DIV.CANCEL;
                            return sRet;
                        }
                        break;
                    }
                }
                sRet = UserCom.RST_OK;
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                   System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }
            finally
            {
                //여전법 대응!
                //////////////////////////////////////////////////////////////////////////////////
                CmUtil.ZeroFillClear(ref sInPutData);
                CmUtil.ZeroFillClear(ref sInEncData);
                CmUtil.ZeroFillClear(ref aParam);
                //////////////////////////////////////////////////////////////////////////////////
            }
            return sRet;
        }
        #endregion

        #region RefundPayment 결제 반품
        /// <summary>
        /// 결제 반품(OKCASHBACK 카드 적립취소)
        /// </summary>
        /// <param name="aParam"></param>
        /// <returns></returns>
        public string RefundPayment(string[] aParam)
        {
            string sRet = UserCom.RST_ERR;
            string sInPutType = "", sInMskData = "", sInEncData = "";

            try
            {
                int nPayRow = CmUtil.IntParse(aParam[0]);       // 취소할 행번호

                ArrayList alEtcItem = (ArrayList)StateObject.GetItemObject(Column.TR_ETC.ITEM);     // 기타 내역 받아 오기
                m_cEtcItem = (Column.TR_ETC.DATA)alEtcItem[nPayRow];

                if (m_cEtcItem.OCCUR_ENTRY_08 == ItemConst.PAY_APP_DIV.CAT_TERMINAL)    //단말기승인
                {
                    string[] m_aParam = new string[15];

                    //InParam
                    // 0.전문구분,1.거래유형, 2.할부개월, 3.승인금액 , 4.봉사료, 5.세금, 6.원승인번호, 7.원거래일자, 8.포인트거래구분, 9.상품코드,
                    //10.전표인쇄여부,11.추가항목,12.제휴할인코드,13.제휴할인금액,14.예비1

                    string sAppId = PosConst.POS_CAT_MASTER.TRADE_ID.CAT_POINT_SAVE_CANCEL;

                    m_aParam[0] = PosConst.POS_CAT_MASTER.TRAN_TYPE;
                    m_aParam[1] = sAppId;
                    m_aParam[2] = "00";
                    m_aParam[3] = m_cEtcItem.AMT_ENTRY_08.ToString();
                    m_aParam[4] = "0"; //봉사료
                    m_aParam[5] = "0"; //세금
                    m_aParam[6] = m_cEtcItem.OCCUR_ENTRY_02;
                    m_aParam[7] = m_cEtcItem.OCCUR_ENTRY_03;
                    m_aParam[8] = "02";
                    m_aParam[9] = "";
                    m_aParam[10] = "";
                    m_aParam[11] = "";
                    m_aParam[12] = "";
                    m_aParam[13] = "";
                    m_aParam[14] = "";

                    sRet = CatExecuteIrt(m_aParam[1], m_aParam);
                    if (sRet != UserCom.RST_OK) return sRet;
                }
                else
                {
                    sInPutType = m_cEtcItem.OCCUR_ENTRY_05;          // 입력구분
                    sInMskData = m_cEtcItem.OCCUR_ENTRY_01;          // 입력데이터(마스킹)
                    sInEncData = m_cEtcItem.CanFiller1;              // 카드데이터(암호화)

                    if (m_cEtcItem.OCCUR_ENTRY_08.ToString() != ItemConst.PAY_APP_DIV.NORMAL)
                    {
                        //WinManager.ConfirmMessage(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0240));
                        m_cEtcItem.OCCUR_ENTRY_06 = m_cEtcItem.OCCUR_ENTRY_02;              // 원승인번호
                        m_cEtcItem.OCCUR_ENTRY_07 = m_cEtcItem.OCCUR_ENTRY_03;              // 원승인일자
                    }
                    else
                    {
                        double nNetSaleAmt = m_cTrnStatus.Sale.NetSaleAmt;      // 영수금액
                        double nBasicSaveAmt = m_cEtcItem.AMT_ENTRY_08;         // 적립대상금액
                        string sApprDate = m_cEtcItem.OCCUR_ENTRY_03;           // 승인일자
                        string sApprNo = m_cEtcItem.OCCUR_ENTRY_02;             // 승인번호

                        if (PosMstManager.GetPosOption(POS_OPTION.OPT326) != "0" && PosMstManager.GetPosOption(POS_OPTION.OPT326) != "" && m_cDevStatus.ICReader.UseYn != true)       // OCB 직통신
                        {
                            sRet = ExecutePointOCBDirectIrt(PosConst.CANCEL_DIV.CANCEL, m_cEtcItem.ETC_WAY_CD, m_cEtcItem.ETC_DTL_CD_01, PosConst.POS_OCB_DIRECT.SAVE_CAN_POINT, sInPutType, sInMskData, sInEncData, "", m_cTrnStatus.Sale.NetSaleAmt, m_cEtcItem.OCCUR_ENTRY_03, m_cEtcItem.OCCUR_ENTRY_02, m_cEtcItem.OCCUR_ENTRY_17);
                        }
                        else
                        {
                            sRet = ExecutePointHappyPointIrt(PosConst.CANCEL_DIV.CANCEL, PosConst.POS_VAN_MASTER.TRADE_ID.VAN_POT_ACC_C, "OCB", sInPutType, sInMskData, sInEncData, nNetSaleAmt, nBasicSaveAmt, "", "", sApprDate, sApprNo);
                        }
                        if (sRet != UserCom.RST_OK) return sRet;
                    }
                }
                // 여전법 대응 ///////////////////////////////////////////////////////////////////
                CmUtil.ZeroFillClear(ref m_cEtcItem.CanFiller1);
                //////////////////////////////////////////////////////////////////////////////////
                sRet = UserCom.RST_OK;
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                   System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }
            finally
            {
                //여전법 대응!
                //////////////////////////////////////////////////////////////////////////////////
                CmUtil.ZeroFillClear(ref sInMskData);
                CmUtil.ZeroFillClear(ref sInEncData);
                CmUtil.ZeroFillClear(ref aParam);
                //////////////////////////////////////////////////////////////////////////////////
            }
            return sRet;
        }
        #endregion

        #region SetMenualPayment
        public string SetMenualPayment(string[] aParam)
        {
            throw new NotImplementedException();
        }
        #endregion

        #region OKCASHBACK 조회 실행
        /// <summary>
        /// OKCASHBACK 조회 실행
        /// </summary>
        public string ExecutePointHappyPointIrt(string sTradeDiv, string sTrType, string sPointType, string sInPutType, string sInPutData, string sInEncData
            , double nNetSaleAmt, double nBasicSaveAmt, string sAddSaveInfo, string sCampaingInfo
            , string sApprDate, string sApprNo)
        {
            string sRet = UserCom.RST_ERR;
            try
            {
                if (sInPutData.Length >= 6) sInPutData = sInPutData.Substring(0, 6).PadRight(sInPutData.Length, '*');

                // 연습모드이면 연습 데이터 설정
                if (m_cPosStatus.Base.TrainingFlag == "1" || m_cPosStatus.Mst.TestStorYn == "1" ) return SetTrainingData(sTrType, sPointType, sInPutType, sInPutData, sInEncData, nNetSaleAmt, nBasicSaveAmt, sApprDate, sApprNo, "");

                string sAddInfo = "";
                if (sTrType == PosConst.POS_VAN_MASTER.TRADE_ID.VAN_POT_ACC_A || sTrType == PosConst.POS_VAN_MASTER.TRADE_ID.VAN_POT_ACC_C)
                {
                    // 적립,적립취소
                    sAddInfo += CmUtil.RPadH("", 10);                           // 요청 사용자 ID
                    sAddInfo += CmUtil.RPadH(m_cPosStatus.Base.SaleDate, 8);    // POS 영업일자 - POS 매출일자 8자리
                    sAddInfo += "1001";                                         // 거래사유코드 - 1001:대금결제, 1002:포인트고객적립, 1003:운영사이벤트, 1004:제휴사 이벤트
                    sAddInfo += CmUtil.RPadH(m_cPosStatus.Base.SaleDate, 10);   // SAP 코드 - POS 매출일자 10자리
                    sAddInfo += CmUtil.RPadH(m_cPosStatus.Base.PosNo, 2);       // POS 번호
                    sAddInfo += "10";                                           // 요청구분 - 10:일반적립, 20:캐시포인트적립
                    sAddInfo += "10";                                           // 적립방식구분코드 - 10:즉시적립, 20:영수증추후적립                    
                    sAddInfo += string.Format("{0:D10}", (long)nBasicSaveAmt);  // 총적립대상금액
                    sAddInfo += "0000000";                                      // 캐시포인트 - 고객이 현금을 캐쉬로 적립 요청한 경우 적립할 캐시포인트
                    sAddInfo += CmUtil.RPadH("", 20);                           // 결제카드번호 - 신용 결제한 카드번호
                    sAddInfo += CmUtil.RPadH("", 125); ;                        // VReserved
                }

                string sVanCD = GetPayDtlCdToVanCode(m_cEtcItem.ETC_WAY_CD, m_cEtcItem.ETC_DTL_CD_01);    // 승인업체 코드 조회
                if (sVanCD == "")
                {
                    if(m_bErrMsgShow) WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0563);
                    return sRet;
                }

                // 포인트 조회
                string[] aIrtRsp = null;
                sRet = ExecutePointIrt(sTradeDiv, m_cEtcItem.ETC_WAY_CD, m_cEtcItem.ETC_DTL_CD_01, sVanCD, sTrType, sPointType, sInPutType, sInPutData, sInEncData, nNetSaleAmt, sApprDate, sApprNo, "", "", sAddSaveInfo, sCampaingInfo, sAddInfo, ref aIrtRsp, "", "","", m_bErrMsgShow);
                if (sRet != UserCom.RST_OK) return sRet;

                if (sTradeDiv == PosConst.CANCEL_DIV.NORMAL)
                {
                    m_cEtcItem.ETC_DTL_CD_05 = PosConst.PAY_DC_TYPE.NORMAL;                                         // 할인결제구분 (1:결제, 2:할인)

                    m_cEtcItem.ETC_AMT = CmUtil.DoubleParse(aIrtRsp[Column.POS_RES_POINT.SEQ.ResTrPoint]);          // 적립포인트
                    m_cEtcItem.AMT_ENTRY_01 = CmUtil.DoubleParse(aIrtRsp[Column.POS_RES_POINT.SEQ.ResTrPoint]);     // 적립포인트     
                    m_cEtcItem.AMT_ENTRY_03 = CmUtil.DoubleParse(aIrtRsp[Column.POS_RES_POINT.SEQ.ResSavePoint]);   // 총포인트(누적포인트)
                    if (sTrType == PosConst.POS_VAN_MASTER.TRADE_ID.VAN_POT_QRY_A)
                        m_cEtcItem.AMT_ENTRY_04 = CmUtil.DoubleParse(aIrtRsp[Column.POS_RES_POINT.SEQ.ResUsesPoint]);   // 가용포인트
                    m_cEtcItem.AMT_ENTRY_05 = CmUtil.DoubleParse(aIrtRsp[Column.POS_RES_POINT.SEQ.ResSavePoint]);   // 누적포인트
                    m_cEtcItem.AMT_ENTRY_08 = nBasicSaveAmt;            // 적립대상금액1(기본적립)

                    m_cEtcItem.OCCUR_ENTRY_01 = sInPutData.Length > 16 ? sInPutData.Substring(0, 16) : sInPutData;  // 카드번호
                    m_cEtcItem.OCCUR_ENTRY_02 = aIrtRsp[Column.POS_RES_POINT.SEQ.ResApprNo].Trim();                 // 승인번호
                    m_cEtcItem.OCCUR_ENTRY_03 = CmUtil.MidH(aIrtRsp[Column.POS_RES_POINT.SEQ.ResTrDate], 0, 6);     // 승인일자
                    m_cEtcItem.OCCUR_ENTRY_04 = CmUtil.MidH(aIrtRsp[Column.POS_RES_POINT.SEQ.ResTrDate], 6, 4);     // 승인시간
                    m_cEtcItem.OCCUR_ENTRY_05 = sInPutType;             // 입력 구분
                    m_cEtcItem.OCCUR_ENTRY_06 = sApprNo;                // 원승인번호
                    m_cEtcItem.OCCUR_ENTRY_07 = sApprDate;              // 원승인일자
                    m_cEtcItem.OCCUR_ENTRY_08 = ItemConst.PAY_APP_DIV.NORMAL;   //승인구분
                    m_cEtcItem.OCCUR_ENTRY_09 = "0";                    // 거래후 적립 구분(0:일반, 1:사후)
                    m_cEtcItem.OCCUR_ENTRY_16 = sVanCD;                 // VAN 구분 
                    m_cEtcItem.OCCUR_ENTRY_18 = aIrtRsp[Column.POS_RES_POINT.SEQ.ResStoreNo];                       // 가맹점번호
                    m_cEtcItem.OCCUR_ENTRY_20 = GetPayDtlCdToPayDtlName(m_cEtcItem.ETC_WAY_CD, m_cEtcItem.ETC_DTL_CD_01);   // 결제수단명
                    m_cEtcItem.OCCUR_ENTRY_21 = GetPayDtlCdToCashBillYn(m_cEtcItem.ETC_WAY_CD, m_cEtcItem.ETC_DTL_CD_01);   // 현금영수증 발행여부

                    m_cEtcItem.CANCEL_DIV = ItemConst.PAY_CANCEL_DIV.NORMAL;
                    m_cEtcItem.BILLSPR_NO = m_cTrnStatus.Sale.BillSplitNo;      // 빌분리 번호

                    m_cEtcItem.CanFiller1 = sInEncData;
                    m_cEtcItem.HP_RESERVED = aIrtRsp[Column.POS_RES_POINT.SEQ.ResReserved].Trim();      // 예약필드
                    m_cEtcItem.HP_CAMPAIGN_INFO = aIrtRsp[Column.POS_RES_POINT.SEQ.ResCampaign].Trim(); // 캠페인정보

                    if (sTrType == PosConst.POS_VAN_MASTER.TRADE_ID.VAN_POT_QRY_A)
                        m_cEtcItem.HP_ADD_INFO_SCH = aIrtRsp[Column.POS_RES_POINT.SEQ.ResAddRespon].Trim();     // 추가응답정보
                    else
                        m_cEtcItem.HP_ADD_INFO_SAVE = aIrtRsp[Column.POS_RES_POINT.SEQ.ResAddRespon].Trim();    // 추가응답정보
                }
                else
                {
                    m_cEtcItem.AMT_ENTRY_03 = CmUtil.DoubleParse(aIrtRsp[Column.POS_RES_POINT.SEQ.ResSavePoint]);   // 총포인트(누적포인트)
                    m_cEtcItem.AMT_ENTRY_05 = CmUtil.DoubleParse(aIrtRsp[Column.POS_RES_POINT.SEQ.ResSavePoint]);   // 누적포인트

                    m_cEtcItem.OCCUR_ENTRY_01 = sInPutData.Length > 16 ? sInPutData.Substring(0, 16) : sInPutData;  // 카드번호
                    m_cEtcItem.OCCUR_ENTRY_02 = aIrtRsp[Column.POS_RES_POINT.SEQ.ResApprNo].Trim();                 // 승인번호
                    m_cEtcItem.OCCUR_ENTRY_03 = CmUtil.MidH(aIrtRsp[Column.POS_RES_POINT.SEQ.ResTrDate], 0, 6);     // 승인일자
                    m_cEtcItem.OCCUR_ENTRY_04 = CmUtil.MidH(aIrtRsp[Column.POS_RES_POINT.SEQ.ResTrDate], 6, 4);     // 승인시간
                    m_cEtcItem.OCCUR_ENTRY_05 = sInPutType;             // 입력 구분
                    m_cEtcItem.OCCUR_ENTRY_06 = sApprNo;                // 원승인번호
                    m_cEtcItem.OCCUR_ENTRY_07 = sApprDate;              // 원승인일자
                }
                sRet = UserCom.RST_OK;
            }
            catch (Exception ex)
            {
                if (m_bErrMsgShow) WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }
            finally
            {
                //여전법 대응!
                //////////////////////////////////////////////////////////////////////////////////
                CmUtil.ZeroFillClear(ref sInPutData);
                CmUtil.ZeroFillClear(ref sInEncData);
                //////////////////////////////////////////////////////////////////////////////////
            }
            return sRet;
        }

        /// <summary>
        /// 연습 데이터 설정
        /// </summary>
        public string SetTrainingData(string sTrType, string sPointType, string sInPutType, string sInPutData, string sInEncData
            , double nNetSaleAmt, double nBasicSaveAmt, string sApprDate, string sApprNo, string sUniqueID)
        {
            string sRet = UserCom.RST_ERR;
            try
            {
                // 연습모드이면 연습 데이터 설정
                string sVanCD = GetPayDtlCdToVanCode(m_cEtcItem.ETC_WAY_CD, m_cEtcItem.ETC_DTL_CD_01);    // 승인업체 코드 조회
                if (sVanCD == "")
                {
                    if (m_bErrMsgShow) WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0563);
                    return sRet;
                }

                double nSavePnt = 0;
                if (sTrType != PosConst.POS_VAN_MASTER.TRADE_ID.VAN_POT_QRY_A)
                {
                    nSavePnt = m_cDataCommon.ExecTermCoopCmpPayDc(m_cEtcItem.ETC_WAY_CD, m_cEtcItem.ETC_DTL_CD_01, "", nBasicSaveAmt);     // 제휴사 결제 할인 금액 계산
                }

                m_cEtcItem.ETC_DTL_CD_05 = PosConst.PAY_DC_TYPE.NORMAL;             // 할인결제구분 (1:결제, 2:할인)

                m_cEtcItem.ETC_AMT = nSavePnt;
                m_cEtcItem.AMT_ENTRY_01 = nSavePnt;         // 적립포인트
                m_cEtcItem.AMT_ENTRY_03 = 99990;            // 총포인트
                m_cEtcItem.AMT_ENTRY_04 = 99990;            // 가용포인트
                m_cEtcItem.AMT_ENTRY_05 = 0;
                m_cEtcItem.AMT_ENTRY_08 = nNetSaleAmt;      // 적립대상금액

                m_cEtcItem.OCCUR_ENTRY_01 = sInPutData.Length > 16 ? sInPutData.Substring(0, 16) : sInPutData;  // 카드번호
                m_cEtcItem.OCCUR_ENTRY_02 = "99999999";                         // 승인번호
                m_cEtcItem.OCCUR_ENTRY_03 = DateTime.Now.ToString("yyMMdd");    // 승인일자
                m_cEtcItem.OCCUR_ENTRY_04 = DateTime.Now.ToString("HHmm");      // 승인시간
                m_cEtcItem.OCCUR_ENTRY_05 = sInPutType;     // 입력구분
                m_cEtcItem.OCCUR_ENTRY_06 = sApprNo;        // 원승인번호
                m_cEtcItem.OCCUR_ENTRY_07 = sApprDate;      // 원승인일자
                m_cEtcItem.OCCUR_ENTRY_08 = ItemConst.PAY_APP_DIV.COMPULSION;                                           // 승인구분
                m_cEtcItem.OCCUR_ENTRY_09 = "0";            // 거래후 적립 구분(0:일반, 1:사후)
                m_cEtcItem.OCCUR_ENTRY_16 = sVanCD;         // VAN 구분
                m_cEtcItem.OCCUR_ENTRY_17 = sUniqueID;      // UniqueID
                m_cEtcItem.OCCUR_ENTRY_18 = "";
                m_cEtcItem.OCCUR_ENTRY_20 = GetPayDtlCdToPayDtlName(m_cEtcItem.ETC_WAY_CD, m_cEtcItem.ETC_DTL_CD_01);   // 결제수단명
                m_cEtcItem.OCCUR_ENTRY_21 = GetPayDtlCdToCashBillYn(m_cEtcItem.ETC_WAY_CD, m_cEtcItem.ETC_DTL_CD_01);   // 현금영수증 발행여부
                
                m_cEtcItem.CANCEL_DIV = ItemConst.PAY_CANCEL_DIV.NORMAL;
                m_cEtcItem.BILLSPR_NO = m_cTrnStatus.Sale.BillSplitNo;              // 빌분리 번호

                m_cEtcItem.CanFiller1 = sInEncData;
                sRet = UserCom.RST_OK;
            }
            catch (Exception ex)
            {
                if (m_bErrMsgShow) WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }
            finally
            {
                //여전법 대응!
                //////////////////////////////////////////////////////////////////////////////////
                CmUtil.ZeroFillClear(ref sInPutData);
                CmUtil.ZeroFillClear(ref sInEncData);
                //////////////////////////////////////////////////////////////////////////////////
            }
            return sRet;
        }
        #endregion

        #region OCB 직통신
        /// <summary>
        /// OCB 직통신
        /// </summary>
        /// <param name="sTradeDiv"></param>
        /// <param name="sPayWayCD"></param>
        /// <param name="sPayWayDtlCD"></param>
        /// <param name="sTrType"></param>
        /// <param name="sInPutType"></param>
        /// <param name="sInPutData"></param>
        /// <param name="sInEncData"></param>
        /// <param name="sCardPwd"></param>
        /// <param name="nSaleAmt"></param>
        /// <param name="sApprDate"></param>
        /// <param name="sApprNo"></param>
        /// <param name="sUniqueID"></param>
        /// <returns></returns>
        public string ExecutePointOCBDirectIrt(string sTradeDiv, string sPayWayCD, string sPayWayDtlCD, string sTrType, string sInPutType, string sInPutData, string sInEncData, string sCardPwd, double nSaleAmt, string sApprDate, string sApprNo, string sUniqueID)
        {
            string sRet = UserCom.RST_ERR;
            string sResMsg = ""; 

            try
            {
                if (sInPutData.Length >= 6) sInPutData = sInPutData.Substring(0, 6).PadRight(sInPutData.Length, '*');

                // 연습모드이면 연습 데이터 설정
                if (m_cPosStatus.Base.TrainingFlag == "1" || m_cPosStatus.Mst.TestStorYn == "1") return SetTrainingData(sTrType, "OCB", sInPutType, sInPutData, sInEncData, nSaleAmt, 0, sApprDate, sApprNo, sUniqueID);

                // 포인트 조회
                string[] aIrtRsp = null;
                sRet = m_OCBDirect.OCB_Direct_Point(sTradeDiv, sPayWayCD, sPayWayDtlCD, sTrType, sInEncData, sCardPwd, nSaleAmt.ToString(), sApprDate, sApprNo, sUniqueID, ref sResMsg, ref aIrtRsp);
                if (sRet != UserCom.RST_OK)
                {
                    if (sResMsg.Trim() != "")
                        if (m_bErrMsgShow) WinManager.ErrorMessage(sResMsg);
                    return sRet;
                }

                // 가맹점번호
                string sCMPApprID = PosMstManager.GetMstVan(PosMstManager.GetPosOption(POS_OPTION.OPT326), PosMst.MST_VAN.DATA.CMP_APPR_ID);

                if (sTradeDiv == PosConst.CANCEL_DIV.NORMAL)
                {
                    if (sTrType == PosConst.POS_OCB_DIRECT.INQ_POINT)
                    {
                        // 포인트 조회
                        m_cEtcItem.AMT_ENTRY_03 = CmUtil.DoubleParse(aIrtRsp[Column.POS_REQ_OCB_INQPOINT.SEQ.ACC_POINT1]);      // 총포인트(누적포인트)
                        m_cEtcItem.AMT_ENTRY_04 = CmUtil.DoubleParse(aIrtRsp[Column.POS_REQ_OCB_INQPOINT.SEQ.REM_POINT1]);      // 가용포인트
                        m_cEtcItem.AMT_ENTRY_05 = CmUtil.DoubleParse(aIrtRsp[Column.POS_REQ_OCB_INQPOINT.SEQ.ACC_POINT1]);      // 누적포인트
                        m_cEtcItem.OCCUR_ENTRY_13 = CmUtil.MidH(aIrtRsp[Column.POS_REQ_OCB_INQPOINT.SEQ.SAVEPOINT_YN], 0, 1);   // 적립가능여부 
                        m_cEtcItem.OCCUR_ENTRY_14 = CmUtil.MidH(aIrtRsp[Column.POS_REQ_OCB_INQPOINT.SEQ.USEPOINT_YN], 0, 1);    // 사용가능여부
                    }
                    else
                    {
                        // 포인트 적립
                        m_cEtcItem.ETC_AMT = CmUtil.DoubleParse(aIrtRsp[Column.POS_REQ_OCB_POINT.SEQ.CUR_POINT1 ]);             // 적립포인트
                        m_cEtcItem.AMT_ENTRY_01 = CmUtil.DoubleParse(aIrtRsp[Column.POS_REQ_OCB_POINT.SEQ.CUR_POINT1]);         // 적립포인트     
                        m_cEtcItem.AMT_ENTRY_03 = CmUtil.DoubleParse(aIrtRsp[Column.POS_REQ_OCB_POINT.SEQ.ACC_POINT1]);         // 총포인트(누적포인트)
                        m_cEtcItem.AMT_ENTRY_04 = CmUtil.DoubleParse(aIrtRsp[Column.POS_REQ_OCB_POINT.SEQ.REM_POINT1]);         // 가용포인트
                        m_cEtcItem.AMT_ENTRY_05 = CmUtil.DoubleParse(aIrtRsp[Column.POS_REQ_OCB_POINT.SEQ.ACC_POINT1]);         // 누적포인트
                        m_cEtcItem.AMT_ENTRY_06 = CmUtil.DoubleParse(aIrtRsp[Column.POS_REQ_OCB_POINT.SEQ.FEE_AMT1]);           // 가맹점수수료
                        m_cEtcItem.OCCUR_ENTRY_02 = aIrtRsp[Column.POS_REQ_OCB_POINT.SEQ.APPR_NO].Trim();                       // 승인번호
                        m_cEtcItem.OCCUR_ENTRY_03 = CmUtil.MidH(aIrtRsp[Column.POS_REQ_OCB_POINT.SEQ.APPR_DATE], 0, 8);         // 승인일자
                        m_cEtcItem.OCCUR_ENTRY_04 = CmUtil.MidH(aIrtRsp[Column.POS_REQ_OCB_POINT.SEQ.APPR_TIME], 0, 6);         // 승인시간
                    }

                    m_cEtcItem.ETC_DTL_CD_05 = PosConst.PAY_DC_TYPE.NORMAL;                                                     // 할인결제구분 (1:결제, 2:할인)
                    m_cEtcItem.AMT_ENTRY_08 = 0;                                                                                // 적립대상금액1(기본적립)
                    m_cEtcItem.OCCUR_ENTRY_01 = sInPutData.Length > 16 ? sInPutData.Substring(0, 16) : sInPutData;              // 카드번호
                    m_cEtcItem.OCCUR_ENTRY_05 = sInPutType;                                                                     // 입력 구분
                    m_cEtcItem.OCCUR_ENTRY_06 = sApprNo;                                                                        // 원승인번호
                    m_cEtcItem.OCCUR_ENTRY_07 = sApprDate;                                                                      // 원승인일자
                    m_cEtcItem.OCCUR_ENTRY_08 = ItemConst.PAY_APP_DIV.NORMAL;                                                   // 승인구분
                    m_cEtcItem.OCCUR_ENTRY_09 = "0";                                                                            // 거래후 적립 구분(0:일반, 1:사후)
                    m_cEtcItem.OCCUR_ENTRY_16 = PosMstManager.GetPosOption(POS_OPTION.OPT326);                                  // VAN 구분
                    m_cEtcItem.OCCUR_ENTRY_17 = sUniqueID;                                                                      // UniqueID
                    m_cEtcItem.OCCUR_ENTRY_18 = sCMPApprID;                                                                     // 가맹점번호
                    m_cEtcItem.OCCUR_ENTRY_20 = GetPayDtlCdToPayDtlName(m_cEtcItem.ETC_WAY_CD, m_cEtcItem.ETC_DTL_CD_01);       // 결제수단명
                    m_cEtcItem.OCCUR_ENTRY_21 = GetPayDtlCdToCashBillYn(m_cEtcItem.ETC_WAY_CD, m_cEtcItem.ETC_DTL_CD_01);       // 현금영수증 발행여부

                    m_cEtcItem.CANCEL_DIV = ItemConst.PAY_CANCEL_DIV.NORMAL;
                    m_cEtcItem.BILLSPR_NO = m_cTrnStatus.Sale.BillSplitNo;                                                      // 빌분리 번호

                    m_cEtcItem.CanFiller1 = sInEncData;
                }
                else
                {
                    m_cEtcItem.AMT_ENTRY_03 = CmUtil.DoubleParse(aIrtRsp[Column.POS_REQ_OCB_CANPOINT.SEQ.ACC_POINT1]);          // 총포인트(누적포인트)
                    m_cEtcItem.AMT_ENTRY_04 = CmUtil.DoubleParse(aIrtRsp[Column.POS_REQ_OCB_CANPOINT.SEQ.REM_POINT1]);          // 가용포인트
                    m_cEtcItem.AMT_ENTRY_05 = CmUtil.DoubleParse(aIrtRsp[Column.POS_REQ_OCB_CANPOINT.SEQ.ACC_POINT1]);          // 누적포인트
                    m_cEtcItem.AMT_ENTRY_06 = CmUtil.DoubleParse(aIrtRsp[Column.POS_REQ_OCB_CANPOINT.SEQ.CAN_POINT1]);          // 실차감포인트

                    m_cEtcItem.OCCUR_ENTRY_01 = sInPutData.Length > 16 ? sInPutData.Substring(0, 16) : sInPutData;              // 카드번호
                    m_cEtcItem.OCCUR_ENTRY_02 = aIrtRsp[Column.POS_REQ_OCB_CANPOINT.SEQ.APPR_NO].Trim();                        // 승인번호
                    m_cEtcItem.OCCUR_ENTRY_03 = CmUtil.MidH(aIrtRsp[Column.POS_REQ_OCB_CANPOINT.SEQ.APPR_DATE], 0, 8);          // 승인일자
                    m_cEtcItem.OCCUR_ENTRY_04 = CmUtil.MidH(aIrtRsp[Column.POS_REQ_OCB_CANPOINT.SEQ.APPR_TIME], 0, 6);          // 승인시간
                    m_cEtcItem.OCCUR_ENTRY_05 = sInPutType;                                                                     // 입력 구분
                    m_cEtcItem.OCCUR_ENTRY_06 = sApprNo;                                                                        // 원승인번호
                    m_cEtcItem.OCCUR_ENTRY_07 = sApprDate;                                                                      // 원승인일자
                }
                                 
                sRet = UserCom.RST_OK;
            }
            catch (Exception ex)
            {
                if (m_bErrMsgShow) WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }
            finally
            {
                //여전법 대응!
                //////////////////////////////////////////////////////////////////////////////////
                CmUtil.ZeroFillClear(ref sInPutData);
                CmUtil.ZeroFillClear(ref sInEncData);                
                //////////////////////////////////////////////////////////////////////////////////
            }
            return sRet;
        }
        #endregion

        #region Cat단말기 승인 처리
        /// <summary>
        /// Cat단말기 승인 처리
        /// </summary>
        /// <param name="sAppType"></param>
        /// <param name="aParam"></param>
        /// <returns></returns>
        public string CatExecuteIrt(string sAppType, string[] aParam)
        {

            string sRet = UserCom.RST_ERR;

            try
            {
                // 연습모드이면 연습 데이터 설정
                if (m_cPosStatus.Base.TrainingFlag == "1" || m_cPosStatus.Mst.TestStorYn == "1") return SetTrainingData(sAppType, "", "K", "999999*********", "", CmUtil.DoubleParse(aParam[3]), m_cTrnStatus.Head.AftSavePoint, DateTime.Now.ToString("yyyyMMdd"), "99999999", "");


                string sAddInfo = "";
                if (sAppType == PosConst.POS_CAT_MASTER.TRADE_ID.CAT_POINT_SEARCH)
                {
                    // 조회
                    sAddInfo += CmUtil.RPadH("", 10);                           // 요청 사용자 ID                               
                    sAddInfo += CmUtil.RPadH(m_cPosStatus.Base.StoreNo, 10);    // 점포코드
                    sAddInfo += CmUtil.RPadH(m_cPosStatus.Base.PosNo, 2);       // 포스번호
                    sAddInfo += CmUtil.RPadH("", 178);                          // VReserved
                }
                else
                {
                    // 적립,적립취소
                    sAddInfo += CmUtil.RPadH("", 10);                           // 요청 사용자 ID
                    sAddInfo += CmUtil.RPadH(m_cPosStatus.Base.SaleDate, 8);    // POS 영업일자 - POS 매출일자 8자리
                    sAddInfo += "1001";                                         // 거래사유코드 - 1001:대금결제, 1002:포인트고객적립, 1003:운영사이벤트, 1004:제휴사 이벤트
                    sAddInfo += CmUtil.RPadH(m_cPosStatus.Base.SaleDate, 10);   // SAP 코드 - POS 매출일자 10자리
                    sAddInfo += CmUtil.RPadH(m_cPosStatus.Base.PosNo, 2);       // POS 번호
                    sAddInfo += "10";                                           // 요청구분 - 10:일반적립, 20:캐시포인트적립
                    sAddInfo += "10";                                           // 적립방식구분코드 - 10:즉시적립, 20:영수증추후적립                    
                    sAddInfo += string.Format("{0:D10}", (long)m_cTrnStatus.Head.AftSavePoint);  // 총적립대상금액
                    sAddInfo += "0000000";                                      // 캐시포인트 - 고객이 현금을 캐쉬로 적립 요청한 경우 적립할 캐시포인트
                    sAddInfo += CmUtil.RPadH("", 20);                           // 결제카드번호 - 신용 결제한 카드번호
                    sAddInfo += CmUtil.RPadH("", 125);                          // VReserved
                }

                aParam[11] = sAddInfo;

                string sRecvdData = "";
                string sAppLogDiv = "";
                string sInputType = "";

                if (sAppType == PosConst.POS_CAT_MASTER.TRADE_ID.CAT_POINT_SAVE || sAppType == PosConst.POS_CAT_MASTER.TRADE_ID.CAT_POINT_SEARCH)
                {
                    sAppLogDiv = PosConst.CANCEL_DIV.NORMAL;
                }
                else
                {
                    sAppLogDiv = PosConst.CANCEL_DIV.CANCEL;
                }

                string[] aIrtDTLRsp = new string[Column.POS_RES_SPCN_CAT.LEN.Length];

                //전문 송/수신
                if (CatTerminalExecuteIrtCom(sAppType, sAppLogDiv, aParam, m_cEtcItem.ETC_WAY_CD, m_cEtcItem.ETC_DTL_CD_01, ref aIrtDTLRsp, ref sRecvdData, ref sInputType) == false)
                {
                    //WinManager.ErrorMessage(sRecvdData);
                    return sRet;
                }

                if (sAppLogDiv == PosConst.CANCEL_DIV.NORMAL)
                {
                    m_cEtcItem.ETC_DTL_CD_05 = PosConst.PAY_DC_TYPE.NORMAL;                                                             // 할인결제구분 (1:결제, 2:할인)

                    m_cEtcItem.ETC_AMT = CmUtil.DoubleParse(CmUtil.MidH(aIrtDTLRsp[Column.POS_RES_SPCN_CAT.SEQ.AddItem], 0, 9));         // 적립포인트
                    m_cEtcItem.AMT_ENTRY_01 = CmUtil.DoubleParse(CmUtil.MidH(aIrtDTLRsp[Column.POS_RES_SPCN_CAT.SEQ.AddItem], 0, 9));    // 적립포인트     
                    m_cEtcItem.AMT_ENTRY_03 = CmUtil.DoubleParse(CmUtil.MidH(aIrtDTLRsp[Column.POS_RES_SPCN_CAT.SEQ.AddItem], 18, 9));   // 총포인트(누적포인트)

                    //if (sAppType == PosConst.POS_CAT_MASTER.TRADE_ID.CAT_POINT_SEARCH)
                    m_cEtcItem.AMT_ENTRY_04 = CmUtil.DoubleParse(CmUtil.MidH(aIrtDTLRsp[Column.POS_RES_SPCN_CAT.SEQ.AddItem], 9, 9));   // 가용포인트

                    m_cEtcItem.AMT_ENTRY_05 = CmUtil.DoubleParse(CmUtil.MidH(aIrtDTLRsp[Column.POS_RES_SPCN_CAT.SEQ.AddItem], 18, 9));      // 누적포인트
                    m_cEtcItem.AMT_ENTRY_08 = CmUtil.DoubleParse(aIrtDTLRsp[Column.POS_RES_SPCN_CAT.SEQ.TotAmt]);            // 적립대상금액1(기본적립)

                    m_cEtcItem.OCCUR_ENTRY_01 = aIrtDTLRsp[Column.POS_RES_SPCN_CAT.SEQ.CardBinData].Trim().Length == 6 ? aIrtDTLRsp[Column.POS_RES_SPCN_CAT.SEQ.CardBinData].Trim() + "*********" : aIrtDTLRsp[Column.POS_RES_SPCN_CAT.SEQ.CardBinData].Trim();  // 카드번호
                    m_cEtcItem.OCCUR_ENTRY_02 = aIrtDTLRsp[Column.POS_RES_SPCN_CAT.SEQ.AppNo].Trim();                    // 승인번호
                    m_cEtcItem.OCCUR_ENTRY_03 = CmUtil.MidH(aIrtDTLRsp[Column.POS_RES_SPCN_CAT.SEQ.AppDatatime], 0, 6);  // 승인일자
                    m_cEtcItem.OCCUR_ENTRY_04 = CmUtil.MidH(aIrtDTLRsp[Column.POS_RES_SPCN_CAT.SEQ.AppDatatime], 6, 4);  // 승인시간
                    m_cEtcItem.OCCUR_ENTRY_05 = sInputType;                     // 입력 구분
                    m_cEtcItem.OCCUR_ENTRY_06 = "";                             // 원승인번호
                    m_cEtcItem.OCCUR_ENTRY_07 = "";                             // 원승인일자
                    m_cEtcItem.OCCUR_ENTRY_08 = ItemConst.PAY_APP_DIV.CAT_TERMINAL;   //승인구분
                    m_cEtcItem.OCCUR_ENTRY_09 = "0";                            // 거래후 적립 구분(0:일반, 1:사후)
                    m_cEtcItem.OCCUR_ENTRY_16 = GetPayDtlCdToVanCode(m_cEtcItem.ETC_WAY_CD, m_cEtcItem.ETC_DTL_CD_01);      // VAN 구분
                    m_cEtcItem.OCCUR_ENTRY_18 = aIrtDTLRsp[Column.POS_RES_SPCN_CAT.SEQ.FranchiseNo];                     // 가맹점번호
                    m_cEtcItem.OCCUR_ENTRY_20 = GetPayDtlCdToPayDtlName(m_cEtcItem.ETC_WAY_CD, m_cEtcItem.ETC_DTL_CD_01);   // 결제수단명
                    m_cEtcItem.OCCUR_ENTRY_21 = GetPayDtlCdToCashBillYn(m_cEtcItem.ETC_WAY_CD, m_cEtcItem.ETC_DTL_CD_01);   // 현금영수증 발행여부

                    m_cEtcItem.CANCEL_DIV = ItemConst.PAY_CANCEL_DIV.NORMAL;
                    m_cEtcItem.BILLSPR_NO = m_cTrnStatus.Sale.BillSplitNo;      // 빌분리 번호

                    m_cEtcItem.HP_RESERVED = "";        // 예약필드
                    m_cEtcItem.HP_CAMPAIGN_INFO = "";   // 캠페인정보
                    m_cEtcItem.HP_ADD_INFO_SCH = "";    // 추가응답정보
                    m_cEtcItem.HP_ADD_INFO_SAVE = "";   // 추가응답정보

                }
                else
                {
                    m_cEtcItem.AMT_ENTRY_03 = CmUtil.DoubleParse(CmUtil.MidH(aIrtDTLRsp[Column.POS_RES_SPCN_CAT.SEQ.AddItem], 18, 9));   // 총포인트(누적포인트)
                    m_cEtcItem.AMT_ENTRY_05 = CmUtil.DoubleParse(CmUtil.MidH(aIrtDTLRsp[Column.POS_RES_SPCN_CAT.SEQ.AddItem], 18, 9));   // 누적포인트

                    m_cEtcItem.OCCUR_ENTRY_01 = aIrtDTLRsp[Column.POS_RES_SPCN_CAT.SEQ.CardBinData].Trim().Length == 6 ? aIrtDTLRsp[Column.POS_RES_SPCN_CAT.SEQ.CardBinData].Trim() + "*********" : aIrtDTLRsp[Column.POS_RES_SPCN_CAT.SEQ.CardBinData].Trim();  // 카드번호

                    m_cEtcItem.OCCUR_ENTRY_06 = m_cEtcItem.OCCUR_ENTRY_02;              // 원승인번호
                    m_cEtcItem.OCCUR_ENTRY_07 = m_cEtcItem.OCCUR_ENTRY_03;              // 원승인일자

                    m_cEtcItem.OCCUR_ENTRY_02 = aIrtDTLRsp[Column.POS_RES_SPCN_CAT.SEQ.AppNo].Trim();                       // 승인번호
                    m_cEtcItem.OCCUR_ENTRY_03 = CmUtil.MidH(aIrtDTLRsp[Column.POS_RES_SPCN_CAT.SEQ.AppDatatime], 0, 6);     // 승인일자
                    m_cEtcItem.OCCUR_ENTRY_04 = CmUtil.MidH(aIrtDTLRsp[Column.POS_RES_SPCN_CAT.SEQ.AppDatatime], 6, 4);     // 승인시간
                    m_cEtcItem.OCCUR_ENTRY_05 = sInputType;             // 입력 구분

                    m_cEtcItem.HP_ADD_INFO_SAVE = "";    // 추가응답정보

                }
                sRet = UserCom.RST_OK;
            }
            catch (Exception ex)
            {
                if (m_bErrMsgShow) WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                   System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }
            return sRet;
        }
        #endregion


        #region IPaymentExpUs 멤버


        public string SetCoopPayment(string[] aParam)
        {
            throw new NotImplementedException();
        }
        public string SetSmilePayment(string[] aParam)
        {
            throw new NotImplementedException();
        }
        public string SetCoopPaymentIC(string[] aParam)
        {
            throw new NotImplementedException();
        }
        //#20180329, 해피기프트(신) 자동적립 수정 Start, lsr
        public string SetHPGiftPayment()
        {
            throw new NotImplementedException();
        }
        //#20180329, 해피기프트(신) 자동적립 수정 End, lsr

        #endregion
    }
}
