using System;
using System.Collections;
using System.Text;
using Cosmos.UserFrame;
using Cosmos.ServiceProvider;
using Cosmos.Common;
using Cosmos.CommonManager;
using System.Data;
/*-----------------------------------------------------------------------------------------------*/
// 설 명 : 세브란스병원 임직원 할인
// 작 성 자 :
// 변경 이력 :
/*-----------------------------------------------------------------------------------------------*/
namespace Cosmos.Service
{
class SeveranceDC : PaymentBase, IPaymentUs
{
private int iRecvTimeOut = 10000;
public SeveranceDC()
{
}
#region SearchPayment 결제 조회
///
/// 결제 조회
///
///
///
///
public string SearchPayment(string[] aParam, ref string[] aRet)
{
string sRet = UserCom.RST_ERR;
string sInPutData = "", sCardData = "";
try
{
sInPutData = aParam[2]; // 입력데이터
sCardData = aParam[3]; // 카드데이터
string sPosMenuKey = aParam[0]; // 메뉴키
string sWCC = aParam[1]; // 입력구분
double nPayAmt = CmUtil.DoubleParse(aParam[4]); // 대상금액
string sApprDate = aParam[5]; // 승인일자
string sApprNo = aParam[6]; // 승인번호
double niTemQty1 = CmUtil.DoubleParse(aParam[7]); // 상품수량1
double nSaleAmount1 = CmUtil.DoubleParse(aParam[8]); // 판매금액1
double niTemQty2 = CmUtil.DoubleParse(aParam[9]); // 상품수량2
double nSaleAmount2 = CmUtil.DoubleParse(aParam[10]); // 판매금액2
string siTemCD = aParam[11]; // 대표상품코드
string siTemNM = aParam[12]; // 대표상품명
double niTemQty3 = CmUtil.DoubleParse(aParam[13]); // 상품수량3
string sPassword = aParam[14]; // 비밀번호
m_cPayItem = new Column.TR_PAYMENT.DATA(); // 결과 저장 변수 생성
if (sPosMenuKey == PosKey.MENU_KEY.SEVERANCE_DC)
{
// 할인
m_cPayItem.PAY_WAY_CD = ItemConst.TR_ITEM_ID.EMP_DC_ITEM; // 결제수단
m_cPayItem.PAY_DTL_CD_01 = ItemConst.TR_ITEM_ID.EMP_DC.SEVERANCE; // 상세코드
}
else
{
// 결제
m_cPayItem.PAY_WAY_CD = ItemConst.TR_ITEM_ID.EMP_PAY_ITEM; // 결제수단
m_cPayItem.PAY_DTL_CD_01 = ItemConst.TR_ITEM_ID.EMP_PAY.SEVERANCE; // 상세코드
}
string sTrType = PosConst.POS_VAN_MSG_TYPE.NORMAL;
string siNqType = PosConst.POS_VAN_INQ_TYPE.SEARCH;
string sSaleType = "";
if (sPosMenuKey == PosKey.MENU_KEY.SEVERANCE_DC)
sSaleType = PosConst.POS_VAN_SALE_TYPE.EMPLOYEE_DC; // 판매구분 (10:직원식, 20:직원할인)
else
sSaleType = PosConst.POS_VAN_SALE_TYPE.EMPLOYEE; // 판매구분 (10:직원식, 20:직원할인)
sRet = ExecuteIrt(PosConst.CANCEL_DIV.NORMAL, sTrType, siNqType, sSaleType, sWCC, sInPutData, sCardData, nPayAmt, sApprDate, sApprNo, niTemQty1, nSaleAmount1, niTemQty2, nSaleAmount2, siTemCD, siTemNM, niTemQty3, sPassword);
}
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 sCardData);
CmUtil.ZeroFillClear(ref aParam);
//////////////////////////////////////////////////////////////////////////////////
}
return sRet;
}
#endregion
#region GetPayment 결제 정보 획득
///
/// 결제 정보 획득
///
///
///
public object GetPayment(string[] aParam)
{
return m_cPayItem;
}
#endregion
#region SetPayment 결제 등록
///
/// 결제 등록
///
///
///
public string SetPayment(string[] aParam)
{
string sRet = UserCom.RST_ERR;
string sInPutData = "", sCardData = "";
try
{
sInPutData = aParam[2]; // 입력데이터
sCardData = aParam[3]; // 카드데이터
string sPosMenuKey = aParam[0]; // 메뉴키
string sWCC = aParam[1]; // 입력구분
double nPayAmt = CmUtil.DoubleParse(aParam[4]); // 대상금액
string sApprDate = aParam[5]; // 승인일자
string sApprNo = aParam[6]; // 승인번호
double niTemQty1 = CmUtil.DoubleParse(aParam[7]); // 상품수량1
double nSaleAmount1 = CmUtil.DoubleParse(aParam[8]); // 판매금액1
double niTemQty2 = CmUtil.DoubleParse(aParam[9]); // 상품수량2
double nSaleAmount2 = CmUtil.DoubleParse(aParam[10]); // 판매금액2
string siTemCD = aParam[11]; // 대표상품코드
string siTemNM = aParam[12]; // 대표상품명
double niTemQty3 = CmUtil.DoubleParse(aParam[13]); // 상품수량3
string sPassword = aParam[14]; // 비밀번호
if (sApprDate.Length == 8) sApprDate.Substring(2, 6); // 승인일자(YYMMDD)
m_cPayItem = new Column.TR_PAYMENT.DATA(); // 결과 저장 변수 생성
if (sPosMenuKey == PosKey.MENU_KEY.SEVERANCE_DC)
{
// 할인
m_cPayItem.PAY_WAY_CD = ItemConst.TR_ITEM_ID.EMP_DC_ITEM; // 결제수단
m_cPayItem.PAY_DTL_CD_01 = ItemConst.TR_ITEM_ID.EMP_DC.SEVERANCE; // 상세코드
}
else
{
// 결제
m_cPayItem.PAY_WAY_CD = ItemConst.TR_ITEM_ID.EMP_PAY_ITEM; // 결제수단
m_cPayItem.PAY_DTL_CD_01 = ItemConst.TR_ITEM_ID.EMP_PAY.SEVERANCE; // 상세코드
}
string sTrType = "";
if (m_cTrnStatus.Head.TradeDiv == ItemConst.TRAN_DIV.NORMAL)
sTrType = PosConst.POS_VAN_MSG_TYPE.NORMAL; // 정상
else
sTrType = PosConst.POS_VAN_MSG_TYPE.REFUND; // 반품
string siNqType = PosConst.POS_VAN_INQ_TYPE.APPROVAL; // 요청구분 (10:조회, 20:승인)
string sSaleType = "";
if (sPosMenuKey == PosKey.MENU_KEY.SEVERANCE_DC)
{
sSaleType = PosConst.POS_VAN_SALE_TYPE.EMPLOYEE_DC; // 판매구분 (10:직원식, 20:직원할인)
}
else
{
sSaleType = PosConst.POS_VAN_SALE_TYPE.EMPLOYEE; // 판매구분 (10:직원식, 20:직원할인)
}
// 승인요청
sRet = ExecuteIrt(PosConst.CANCEL_DIV.NORMAL, sTrType, siNqType, sSaleType, sWCC, sInPutData, sCardData, nPayAmt, sApprDate, sApprNo, niTemQty1, nSaleAmount1, niTemQty2, nSaleAmount2, siTemCD, siTemNM, niTemQty3, sPassword);
if (sRet != UserCom.RST_OK) return sRet;
// 결제 아이템 추가
ArrayList alPayItem = (ArrayList)StateObject.GetItemObject(Column.TR_PAYMENT.ITEM); // 결제 내역 받아 오기
m_cPayItem.SEQ = alPayItem.Count + 1;
alPayItem.Add(m_cPayItem);
//#20180126 세브란스 직원 할인시 DETAIL의 할인코드 2자리만 들어가는 증상 수정 start
//기존
/*
if (m_cPayItem.PAY_WAY_CD == ItemConst.TR_ITEM_ID.EMP_DC_ITEM)
SetPluCoopDcAmount(m_cPayItem.PAY_DTL_CD_01, m_cPayItem.PAY_AMT, nPayAmt); // 상품아이템에 할인금액 설정
*/
//변경
if (m_cPayItem.PAY_WAY_CD == ItemConst.TR_ITEM_ID.EMP_DC_ITEM)
SetPluCoopDcAmount(m_cPayItem.PAY_WAY_CD + m_cPayItem.PAY_DTL_CD_01, m_cPayItem.PAY_AMT, nPayAmt); // 상품아이템에 할인금액 설정
//#20180126 세브란스 직원 할인시 DETAIL의 할인코드 2자리만 들어가는 증상 수정 end
m_cDataService.UpdatePluAmount(); // 상품 합계금액 계산(거래해더)
m_cDataService.UpdatePayAmount(); // 결제 금액 재 계산 처리
}
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 sCardData);
CmUtil.ZeroFillClear(ref aParam);
//////////////////////////////////////////////////////////////////////////////////
}
return sRet;
}
#endregion
#region CancelPayment 결제 취소
///
/// 결제 취소
///
///
///
public string CancelPayment(string[] aParam)
{
string sRet = UserCom.RST_ERR;
string sInPutData = "", sCardData = "";
try
{
if (m_cTrnStatus.Head.TradeDiv != ItemConst.TRAN_DIV.NORMAL) return sRet;
int nPayRow = CmUtil.IntParse(aParam[0]); // 취소할 행번호
// 결제 내역 받아 오기
ArrayList alPayItem = (ArrayList)StateObject.GetItemObject(Column.TR_PAYMENT.ITEM);
m_cPayItem = (Column.TR_PAYMENT.DATA)alPayItem[nPayRow];
sInPutData = m_cPayItem.OCCUR_ENTRY_01; // 입력데이터
sCardData = m_cPayItem.OCCUR_ENTRY_22; // 카드데이터
string sWCC = m_cPayItem.OCCUR_ENTRY_05; // 입력구분
double nPayAmt = m_cPayItem.AMT_ENTRY_01; // 대상금액
string sApprDate = m_cPayItem.OCCUR_ENTRY_03; // 승인일자
string sApprNo = m_cPayItem.OCCUR_ENTRY_02; // 승인번호
string sPassword = ""; // 비밀번호
string sTrType = PosConst.POS_VAN_MSG_TYPE.REFUND; // 반품
string siNqType = PosConst.POS_VAN_INQ_TYPE.APPROVAL; // 요청구분 (10:조회, 20:승인)
double nSaleAmount1 = 0;
string sSaleType = "";
if (m_cPayItem.PAY_WAY_CD == ItemConst.TR_ITEM_ID.EMP_DC_ITEM)
{
sSaleType = PosConst.POS_VAN_SALE_TYPE.EMPLOYEE_DC; // 판매구분 (10:직원식, 20:직원할인)
nSaleAmount1 = CmUtil.DoubleAdd(m_cPayItem.AMT_ENTRY_01, m_cPayItem.AMT_ENTRY_04);
}
else
{
sSaleType = PosConst.POS_VAN_SALE_TYPE.EMPLOYEE; // 판매구분 (10:직원식, 20:직원할인)
}
sRet = ExecuteIrt(PosConst.CANCEL_DIV.CANCEL, sTrType, siNqType, sSaleType, sWCC, sInPutData, sCardData, nPayAmt, sApprDate, sApprNo, 0, nSaleAmount1, 0, 0, "", "", 0, sPassword);
if (sRet != UserCom.RST_OK) return sRet;
if (m_cPayItem.PAY_WAY_CD == ItemConst.TR_ITEM_ID.EMP_DC_ITEM)
ClearPluCoopDcAmount(); // 할인금액 삭제
m_cPayItem.CANCEL_DIV = PosConst.CANCEL_DIV.CANCEL;
m_cDataService.UpdatePluAmount(); // 상품 합계금액 계산(거래해더)
m_cDataService.UpdatePayAmount(); // 결제 금액 재 계산 처리
//WinManager.ConfirmMessage(sPointType + " " + MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0068));
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 sCardData);
CmUtil.ZeroFillClear(ref aParam);
//////////////////////////////////////////////////////////////////////////////////
}
return sRet;
}
#endregion
#region RefundPayment 결제 반품
///
/// 결제 반품
///
///
///
public string RefundPayment(string[] aParam)
{
string sRet = UserCom.RST_ERR;
string sInPutData = "", sCardData = "";
try
{
int nPayRow = CmUtil.IntParse(aParam[0]); // 취소할 행번호
// 결제 내역 받아 오기
ArrayList alPayItem = (ArrayList)StateObject.GetItemObject(Column.TR_PAYMENT.ITEM);
m_cPayItem = (Column.TR_PAYMENT.DATA)alPayItem[nPayRow];
if (m_cPayItem.OCCUR_ENTRY_08.ToString() != ItemConst.PAY_APP_DIV.NORMAL)
{
//임의 등록 이면 승인 없이 데이터 처리
//WinManager.ConfirmMessage(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0240));
m_cPayItem.OCCUR_ENTRY_06 = m_cPayItem.OCCUR_ENTRY_02;
m_cPayItem.OCCUR_ENTRY_07 = m_cPayItem.OCCUR_ENTRY_03;
sRet = UserCom.RST_OK;
}
else
{
sInPutData = m_cPayItem.OCCUR_ENTRY_01; // 입력데이터
sCardData = m_cPayItem.OCCUR_ENTRY_22; // 카드데이터
string sWCC = m_cPayItem.OCCUR_ENTRY_05; // 입력구분
double nPayAmt = m_cPayItem.AMT_ENTRY_01; // 대상금액
string sApprDate = m_cPayItem.OCCUR_ENTRY_03; // 승인일자
string sApprNo = m_cPayItem.OCCUR_ENTRY_02; // 승인번호
string sPassword = ""; // 비밀번호
string sTrType = PosConst.POS_VAN_MSG_TYPE.REFUND; // 반품
string siNqType = PosConst.POS_VAN_INQ_TYPE.APPROVAL; // 요청구분 (10:조회, 20:승인)
double nSaleAmount1 = 0;
string sSaleType = "";
if (m_cPayItem.PAY_WAY_CD == ItemConst.TR_ITEM_ID.EMP_DC_ITEM)
{
sSaleType = PosConst.POS_VAN_SALE_TYPE.EMPLOYEE_DC; // 판매구분 (10:직원식, 20:직원할인)
nSaleAmount1 = CmUtil.DoubleAdd(m_cPayItem.AMT_ENTRY_01, m_cPayItem.AMT_ENTRY_04);
}
else
{
sSaleType = PosConst.POS_VAN_SALE_TYPE.EMPLOYEE; // 판매구분 (10:직원식, 20:직원할인)
}
sRet = ExecuteIrt(PosConst.CANCEL_DIV.CANCEL, sTrType, siNqType, sSaleType, sWCC, sInPutData, sCardData, nPayAmt, sApprDate, sApprNo, 0, nSaleAmount1, 0, 0, "", "", 0, sPassword);
if (sRet != UserCom.RST_OK) return sRet;
//if (m_cPayItem.PAY_WAY_CD == ItemConst.TR_ITEM_ID.EMP_DC_ITEM)
// ClearPluCoopDcAmount(); // 할인금액 삭제
}
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 sCardData);
CmUtil.ZeroFillClear(ref aParam);
//////////////////////////////////////////////////////////////////////////////////
}
return sRet;
}
#endregion
#region SetMenualPayment
public string SetMenualPayment(string[] aParam)
{
throw new NotImplementedException();
}
#endregion
#region 조회 실행
///
/// 조회 실행
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
public string ExecuteIrt(string sTradeDiv, string sTrType, string siNqType, string sSaleType, string sWCC, string sInPutData, string sCardData, double nPayAmt, string sApprDate, string sApprNo
, double iTemQty1, double nSaleAmount1, double iTemQty2, double nSaleAmount2, string iTemCD, string iTemNM, double iTemQty3, string Password)
{
string sRet = UserCom.RST_ERR;
try
{
// 연습모드이면 연습 데이터 설정
if (m_cPosStatus.Base.TrainingFlag == "1" || m_cPosStatus.Mst.TestStorYn == "1" ) return SetTrainingData(sTrType, siNqType, sSaleType, sWCC, sCardData, nPayAmt, sApprDate, sApprNo, iTemQty1, nSaleAmount1, iTemQty2, nSaleAmount2, iTemCD, iTemNM, iTemQty3, Password);
string[] aIrtRsp = null;
// 조회
sRet = ExecuteSendRecv(sTradeDiv, sTrType, siNqType, sSaleType, sWCC, sCardData, nPayAmt, sApprDate, sApprNo, iTemQty1, nSaleAmount1, iTemQty2, nSaleAmount2, iTemCD, iTemNM, iTemQty3, Password, ref aIrtRsp);
if (sRet != UserCom.RST_OK) return sRet;
if (sTradeDiv == PosConst.CANCEL_DIV.NORMAL)
{
// 결제구분 (1:결제, 2:할인)
DataRow dr = PosMstManager.GetMstPayDc(new string[] { m_cPosStatus.Base.CmpCd, m_cPosStatus.Base.StoreNo, m_cPayItem.PAY_WAY_CD, m_cPayItem.PAY_DTL_CD_01 });
if (m_cPayItem.PAY_WAY_CD == ItemConst.TR_ITEM_ID.EMP_DC_ITEM && m_cPayItem.PAY_DTL_CD_01 == ItemConst.TR_ITEM_ID.EMP_DC.SEVERANCE)
{
m_cPayItem.PAY_AMT = CmUtil.DoubleParse(aIrtRsp[Column.POS_RES_SEVERANCEDC.SEQ.DCAmount]); // 결제금액
m_cPayItem.PAY_DTL_CD_05 = PosConst.PAY_DC_TYPE.DC; // 할인결제구분 (1:결제, 2:할인)
m_cPayItem.AMT_ENTRY_01 = CmUtil.DoubleParse(aIrtRsp[Column.POS_RES_SEVERANCEDC.SEQ.DCAmount]); // 사용포인트
}
else
{
m_cPayItem.PAY_AMT = nPayAmt; // 결제금액
m_cPayItem.PAY_DTL_CD_05 = PosConst.PAY_DC_TYPE.PAY; // 할인결제구분 (1:결제, 2:할인)
m_cPayItem.AMT_ENTRY_01 = nPayAmt; // 받은금액
}
if (sTrType == PosConst.POS_VAN_MSG_TYPE.NORMAL && siNqType == PosConst.POS_VAN_INQ_TYPE.APPROVAL)
{
if (m_cPayItem.PAY_AMT <= 0) return UserCom.RST_ERR;
}
m_cPayItem.PAY_DTL_CD_02 = ""; // 캠페인코드
m_cPayItem.PAY_DTL_CD_03 = "0"; // 할인금액 아이템 적용여부
m_cPayItem.QTY_ENTRY_01 = CmUtil.GetValueToLong(aIrtRsp[Column.POS_RES_SEVERANCEDC.SEQ.UseFreeQty]); // 무료횟수
m_cPayItem.QTY_ENTRY_02 = CmUtil.GetValueToLong(aIrtRsp[Column.POS_RES_SEVERANCEDC.SEQ.ToTalQty]); // 총사용횟수
m_cPayItem.AMT_ENTRY_02 = 0; // 제휴 할인 금액
m_cPayItem.AMT_ENTRY_03 = 0; // 총포인트
m_cPayItem.AMT_ENTRY_04 = CmUtil.DoubleParse(aIrtRsp[Column.POS_RES_SEVERANCEDC.SEQ.DCAmountAfter]); // 가용포인트(할인후결제금액)
m_cPayItem.AMT_ENTRY_05 = CmUtil.DoubleParse(aIrtRsp[Column.POS_RES_SEVERANCEDC.SEQ.UseAmount]); // 직원식 결제금액
m_cPayItem.OCCUR_ENTRY_01 = sCardData; // 카드번호
m_cPayItem.OCCUR_ENTRY_02 = aIrtRsp[Column.POS_RES_SEVERANCEDC.SEQ.AppNo].Trim(); // 승인번호
m_cPayItem.OCCUR_ENTRY_03 = aIrtRsp[Column.POS_RES_SEVERANCEDC.SEQ.AppDate]; // 승인일자
m_cPayItem.OCCUR_ENTRY_04 = CmUtil.MidH(aIrtRsp[Column.POS_RES_SEVERANCEDC.SEQ.AppDate], 8, 4); // 승인시간
m_cPayItem.OCCUR_ENTRY_05 = sWCC; // 입력 구분
m_cPayItem.OCCUR_ENTRY_06 = sApprNo; // 원승인번호
m_cPayItem.OCCUR_ENTRY_07 = sApprDate; // 원승인일자
m_cPayItem.OCCUR_ENTRY_08 = ItemConst.PAY_APP_DIV.NORMAL; // 승인구분
m_cPayItem.OCCUR_ENTRY_09 = aIrtRsp[Column.POS_RES_SEVERANCEDC.SEQ.EmpCardNo].Trim(); // 직원카드번호
m_cPayItem.OCCUR_ENTRY_10 = aIrtRsp[Column.POS_RES_SEVERANCEDC.SEQ.Message1].Trim(); // 직원명
m_cPayItem.OCCUR_ENTRY_11 = aIrtRsp[Column.POS_RES_SEVERANCEDC.SEQ.Employee_Type].Trim(); // 직원구분 (24:전공의, 25:수련직, 그외 임직원)
m_cPayItem.OCCUR_ENTRY_12 = aIrtRsp[Column.POS_RES_SEVERANCEDC.SEQ.SaleFlag].Trim(); // 결제구분 (00:가능, 20:직원식메뉴 일반 결제 가능) * 중요
m_cPayItem.OCCUR_ENTRY_16 = CmUtil.GetDataRowStr(dr, PosMst.MST_PAY_DC.DATA.APPR_VEND_CD); // VAN 구분
m_cPayItem.OCCUR_ENTRY_20 = GetPayDtlCdToPayDtlName(m_cPayItem.PAY_WAY_CD, m_cPayItem.PAY_DTL_CD_01); // 결제수단명
m_cPayItem.OCCUR_ENTRY_22 = sCardData;
m_cPayItem.CANCEL_DIV = ItemConst.PAY_CANCEL_DIV.NORMAL;
m_cPayItem.BILLSPR_NO = m_cTrnStatus.Sale.BillSplitNo; // 빌분리 번호
// 직원식 상품이 있지만 일반결제 가능 (응답값)
m_cTrnStatus.Sale.SetSeveranceNormalPay = (m_cPayItem.OCCUR_ENTRY_12 == "20") ? true : false;
}
else
{
m_cPayItem.OCCUR_ENTRY_01 = sCardData; // 카드번호
m_cPayItem.OCCUR_ENTRY_02 = aIrtRsp[Column.POS_RES_SEVERANCEDC.SEQ.AppNo].Trim(); // 승인번호
m_cPayItem.OCCUR_ENTRY_03 = aIrtRsp[Column.POS_RES_SEVERANCEDC.SEQ.AppDate]; // 승인일자
m_cPayItem.OCCUR_ENTRY_04 = CmUtil.MidH(aIrtRsp[Column.POS_RES_SEVERANCEDC.SEQ.AppDate], 8, 4); // 승인시간
m_cPayItem.OCCUR_ENTRY_05 = sWCC; // 입력 구분
m_cPayItem.OCCUR_ENTRY_06 = sApprNo; // 원승인번호
m_cPayItem.OCCUR_ENTRY_07 = sApprDate; // 원승인일자
}
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 sCardData);
//////////////////////////////////////////////////////////////////////////////////
}
return sRet;
}
///
/// 연습 데이터 설정
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
public string SetTrainingData(string sTrType, string siNqType, string sSaleType, string sWCC, string sCardData, double nPayAmt, string sApprDate, string sApprNo,
double iTemQty1, double nSaleAmount1, double iTemQty2, double nSaleAmount2, string iTemCD, string iTemNM, double iTemQty3, string sPassword)
{
string sRet = UserCom.RST_ERR;
try
{
// 결제구분 (1:결제, 2:할인)
DataRow dr = PosMstManager.GetMstPayDc(new string[] { m_cPosStatus.Base.CmpCd, m_cPosStatus.Base.StoreNo, m_cPayItem.PAY_WAY_CD, m_cPayItem.PAY_DTL_CD_01 });
// 연습모드이면 연습 데이터 설정
m_cPayItem.PAY_DTL_CD_02 = ""; // 캠페인코드
m_cPayItem.PAY_DTL_CD_03 = "0"; // 할인금액 아이템 적용여부
if (m_cPayItem.PAY_WAY_CD == ItemConst.TR_ITEM_ID.EMP_DC_ITEM && m_cPayItem.PAY_DTL_CD_01 == ItemConst.TR_ITEM_ID.EMP_DC.SEVERANCE)
{
m_cPayItem.PAY_AMT = nPayAmt; // 결제금액
m_cPayItem.PAY_DTL_CD_05 = PosConst.PAY_DC_TYPE.DC; // 할인결제구분 (1:결제, 2:할인)
m_cPayItem.AMT_ENTRY_01 = nPayAmt; // 사용포인트
}
else
{
m_cPayItem.PAY_AMT = nPayAmt; // 결제금액
m_cPayItem.PAY_DTL_CD_05 = PosConst.PAY_DC_TYPE.PAY; // 할인결제구분 (1:결제, 2:할인)
m_cPayItem.AMT_ENTRY_01 = nPayAmt; // 받은금액
}
m_cPayItem.QTY_ENTRY_01 = 0; // 무료횟수
m_cPayItem.QTY_ENTRY_02 = 0; // 총사용횟수
m_cPayItem.AMT_ENTRY_01 = nPayAmt; // 사용포인트
m_cPayItem.AMT_ENTRY_02 = 0; // 제휴 할인 금액
m_cPayItem.AMT_ENTRY_03 = 0; // 총포인트
m_cPayItem.AMT_ENTRY_04 = 0; // 가용포인트
m_cPayItem.AMT_ENTRY_05 = 0; // 잔여포인트
m_cPayItem.AMT_ENTRY_08 = 0;
m_cPayItem.OCCUR_ENTRY_01 = sCardData; // 카드번호
m_cPayItem.OCCUR_ENTRY_02 = "99999999"; // 승인번호
m_cPayItem.OCCUR_ENTRY_03 = DateTime.Now.ToString("yyMMdd"); // 승인일자
m_cPayItem.OCCUR_ENTRY_04 = DateTime.Now.ToString("HHmm"); // 승인시간
m_cPayItem.OCCUR_ENTRY_05 = sWCC; // 입력 구분
m_cPayItem.OCCUR_ENTRY_06 = sApprNo; // 원승인번호
m_cPayItem.OCCUR_ENTRY_07 = sApprDate; // 원승인일자
m_cPayItem.OCCUR_ENTRY_08 = ItemConst.PAY_APP_DIV.COMPULSION; // 승인구분
m_cPayItem.OCCUR_ENTRY_09 = sCardData; // 직원카드번호
m_cPayItem.OCCUR_ENTRY_10 = "TRAINEE"; // 직원명
m_cPayItem.OCCUR_ENTRY_11 = "24"; // 직원구분 (24:전공의, 25:수련직, 그외 임직원)
m_cPayItem.OCCUR_ENTRY_12 = "00"; // 결제구분 (00:가능, 20:직원식메뉴 일반 결제 가능) * 중요
m_cPayItem.OCCUR_ENTRY_16 = CmUtil.GetDataRowStr(dr, PosMst.MST_PAY_DC.DATA.APPR_VEND_CD); // VAN 구분
m_cPayItem.OCCUR_ENTRY_20 = GetPayDtlCdToPayDtlName(m_cPayItem.PAY_WAY_CD, m_cPayItem.PAY_DTL_CD_01); // 결제수단명
m_cPayItem.OCCUR_ENTRY_22 = sCardData;
m_cPayItem.CANCEL_DIV = ItemConst.PAY_CANCEL_DIV.NORMAL;
m_cPayItem.BILLSPR_NO = m_cTrnStatus.Sale.BillSplitNo; // 빌분리 번호
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 sCardData);
//////////////////////////////////////////////////////////////////////////////////
}
return sRet;
}
#endregion
#region 할인 금액 설정
///
/// 할인 금액 설정
///
///
///
///
///
public double SetPluCoopDcAmount(string sCoopDcDiv, double nTotDcAmt, double nTotSaleAmt)
{
double nApplyAmt = 0, nDisAmt = 0, nMaxAmt = 0;
int nMaxRow = 0;
try
{
ArrayList alSaleItem = (ArrayList)StateObject.GetItemObject(Column.TR_PLU.ITEM);
for (int i = 0; i < alSaleItem.Count; i++)
{
Column.TR_PLU.DATA cPluItem = (Column.TR_PLU.DATA)alSaleItem[i];
if (cPluItem.CANCEL_DIV == PosConst.CANCEL_DIV.CANCEL || cPluItem.CANCEL_DIV_MAIN == PosConst.CANCEL_DIV.CANCEL) continue; // 지정취소
if (cPluItem.DC_PRMT_YN == "1") continue;
nTotDcAmt = CmUtil.MathRounds(nTotDcAmt, m_cPosStatus.Mst.DcRudDwLocMethd, CmUtil.IntParse(m_cPosStatus.Mst.DcRudDwLoc));
nDisAmt = CmUtil.DoubleMultiplication(nTotDcAmt, CmUtil.DoubleDivision(cPluItem.BILL_AMT, nTotSaleAmt));
nDisAmt = CmUtil.MathRounds(nDisAmt, m_cPosStatus.Mst.ItemRudDwLocMethd, CmUtil.IntParse(m_cPosStatus.Mst.ItemRudDwLoc));
cPluItem.EMP_DC_DIV = sCoopDcDiv;
cPluItem.EMP_DC_AMT = nDisAmt;
m_cDataService.UpdatePluItemAmount(cPluItem);
nApplyAmt = CmUtil.DoubleAdd(nApplyAmt, nDisAmt);
if (nMaxAmt == 0 || nMaxAmt < cPluItem.BILL_AMT)
{
nMaxAmt = cPluItem.BILL_AMT;
nMaxRow = i;
}
}
// 자투리 금액
if (nTotDcAmt != nApplyAmt)
{
Column.TR_PLU.DATA cPluItem = (Column.TR_PLU.DATA)alSaleItem[nMaxRow];
cPluItem.EMP_DC_AMT = CmUtil.DoubleAdd(cPluItem.EMP_DC_AMT, CmUtil.DoubleSubtraction(nTotDcAmt, nApplyAmt));
m_cDataService.UpdatePluItemAmount(cPluItem);
}
}
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 nTotDcAmt;
}
///
/// 할인 금액 삭제
///
///
public double ClearPluCoopDcAmount()
{
try
{
ArrayList alSaleItem = (ArrayList)StateObject.GetItemObject(Column.TR_PLU.ITEM);
for (int i = 0; i < alSaleItem.Count; i++)
{
Column.TR_PLU.DATA cPluItem = (Column.TR_PLU.DATA)alSaleItem[i];
if (cPluItem.CANCEL_DIV == PosConst.CANCEL_DIV.CANCEL || cPluItem.CANCEL_DIV_MAIN == PosConst.CANCEL_DIV.CANCEL) continue;// 지정취소
if (cPluItem.EMP_DC_AMT > 0)
{
cPluItem.EMP_DC_DIV = "0000";
cPluItem.EMP_DC_AMT = 0;
m_cDataService.UpdatePluItemAmount(cPluItem);
}
}
}
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 0;
}
#endregion
#region 승인 요청/응답
///
/// 승인 요청/응답
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
protected string ExecuteSendRecv(string sTradeDiv, string sTrType, string siNqType, string sSaleType, string sWCC, string sCardData, double nPayAmt, string sApprDate, string sApprNo,
double iTemQty1, double nSaleAmount1, double iTemQty2, double nSaleAmount2, string iTemCD, string iTemNM, double iTemQty3, string sPassword,
ref string[] aIrtRsp)
{
string sSendData = "", sRecvData = ""; // 송수신 전문
string sAckData = "";
int nNowPos = 0;
string sRet = UserCom.RST_ERR;
string sServerIP = "";
string sServerPort = "";
string sCMPApprID = "";
string sApprID = "";
int iRecvTimeOut = 10000;
try
{
// VAN 정보 조회
if (m_cPayItem.OCCUR_ENTRY_16.Trim().Length != 0)
{
// VAN_ID가 있는 경우 VAN_ID로 VAN 정보 조회
sServerIP = PosMstManager.GetMstVan(m_cPayItem.OCCUR_ENTRY_16.Trim(), PosMst.MST_VAN.DATA.IP);
sServerPort = PosMstManager.GetMstVan(m_cPayItem.OCCUR_ENTRY_16.Trim(), PosMst.MST_VAN.DATA.PORT);
sCMPApprID = PosMstManager.GetMstVan(m_cPayItem.OCCUR_ENTRY_16.Trim(), PosMst.MST_VAN.DATA.CMP_APPR_ID);
sApprID = PosMstManager.GetMstVan(m_cPayItem.OCCUR_ENTRY_16.Trim(), PosMst.MST_VAN.DATA.APPR_ID);
}
else
{
// VAN_ID가 미정인 경우 결제수단으로 VAN 정보 조회
sServerIP = PosMstManager.GetMstVan(m_cPayItem.PAY_WAY_CD, m_cPayItem.PAY_DTL_CD_01, PosMst.MST_VAN.DATA.IP);
sServerPort = PosMstManager.GetMstVan(m_cPayItem.PAY_WAY_CD, m_cPayItem.PAY_DTL_CD_01, PosMst.MST_VAN.DATA.PORT);
sCMPApprID = PosMstManager.GetMstVan(m_cPayItem.PAY_WAY_CD, m_cPayItem.PAY_DTL_CD_01, PosMst.MST_VAN.DATA.CMP_APPR_ID);
sApprID = PosMstManager.GetMstVan(m_cPayItem.PAY_WAY_CD, m_cPayItem.PAY_DTL_CD_01, PosMst.MST_VAN.DATA.APPR_ID);
}
if (sServerIP.Trim() == "")
{
WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0565);
return sRet;
}
// 전문 생성
sSendData = GetMakeiNQData(sTrType, siNqType, sSaleType, sWCC, sCardData, nPayAmt, sApprDate, sApprNo, iTemQty1, nSaleAmount1, iTemQty2, nSaleAmount2, iTemCD, iTemNM, iTemQty3, sPassword);
// aCK 데이터
sAckData = PosConst.VAN_HEXA.STX + PosConst.VAN_HEXA.ACK + PosConst.VAN_HEXA.ETX;
// 수신 데이터 길이
int iRecvDataLen = 245;
// 요청 - 승인로그 저장 (판매구분, [0]결제수단, [1]결제상세코드, [2]전문구분, [3]요청구분, [4]카드번호, [5]결제금액, [6]승인번호, [7]승인일자, [8]승인시간, [9]응답상태값, [10]응답메시지, [11]전문)
m_cDataCommon.SetSaleApprLog(sTradeDiv, new string[] { m_cPayItem.PAY_WAY_CD, m_cPayItem.PAY_DTL_CD_01, sTrType, "S", sCardData, nPayAmt.ToString(), "", "", "", "", "", sSendData });
// 전문 송수신
sRet = m_cDataCommon.ExecuteExIrt(sServerIP, CmUtil.IntParse(sServerPort), iRecvTimeOut, sSendData, ref sRecvData, iRecvDataLen, sAckData);
if (sRet != UserCom.RST_OK)
{
WinManager.ErrorMessage(sRet);
return sRet;
}
byte[] bytes = Encoding.Default.GetBytes(sRecvData.Substring(1));
aIrtRsp = new string[Column.POS_RES_SEVERANCEDC.LEN.Length];
ItemColumn.ParseMessage(Column.POS_RES_SEVERANCEDC.LEN, Column.POS_RES_SEVERANCEDC.TYPE, bytes, ref nNowPos, ref aIrtRsp);
// 응답 - 승인로그 저장 (판매구분, [0]결제수단, [1]결제상세코드, [2]전문구분, [3]요청구분, [4]카드번호, [5]결제금액, [6]승인번호, [7]승인일자, [8]승인시간, [9]응답상태값, [10]응답메시지, [11]전문)
m_cDataCommon.SetSaleApprLog(sTradeDiv, new string[] { m_cPayItem.PAY_WAY_CD, m_cPayItem.PAY_DTL_CD_01, sTrType, "R"
, sCardData, nPayAmt.ToString()
, aIrtRsp[Column.POS_RES_SEVERANCEDC.SEQ.AppNo].Trim(), CmUtil.MidH(aIrtRsp[Column.POS_RES_SEVERANCEDC.SEQ.AppDate].Trim(), 0, 8), CmUtil.MidH(aIrtRsp[Column.POS_RES_SEVERANCEDC.SEQ.AppDate].Trim(), 8, 6)
, aIrtRsp[Column.POS_RES_SEVERANCEDC.SEQ.ResStatus].Trim()
, aIrtRsp[Column.POS_RES_SEVERANCEDC.SEQ.Message1].Trim() + " " + aIrtRsp[Column.POS_RES_SEVERANCEDC.SEQ.Message1].Trim()
, sRecvData });
// - 'O000' : 승인 그외 : 거절
if (aIrtRsp[Column.POS_RES_SEVERANCEDC.SEQ.ResStatus].Trim() != "0000")
{
sRet = aIrtRsp[Column.POS_RES_SEVERANCEDC.SEQ.ResStatus].Trim() + " " + aIrtRsp[Column.POS_RES_SEVERANCEDC.SEQ.Message1].Trim() + "\n" + aIrtRsp[Column.POS_RES_SEVERANCEDC.SEQ.Message2].Trim();
WinManager.ErrorMessage(sRet);
return sRet;
}
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 sCardData);
//////////////////////////////////////////////////////////////////////////////////
}
return sRet;
}
#endregion
#region 전문 생성
///
/// 전문 생성
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
///
protected string GetMakeiNQData(string sTrType, string siNqType, string sSaleType, string sWCC, string sCardData, double nPayAmt, string sApprDate, string sApprNo,
double iTemQty1, double nSaleAmount1, double iTemQty2, double nSaleAmount2, string iTemCD, string iTemNM, double iTemQty3, string sPassword)
{
string sSendData = string.Empty;
try
{
string[] aIrtBody = new string[Column.POS_REQ_SEVERANCEDC.LEN.Length];
aIrtBody[Column.POS_REQ_SEVERANCEDC.SEQ.Len] = "200";
aIrtBody[Column.POS_REQ_SEVERANCEDC.SEQ.WorkType] = "001";
aIrtBody[Column.POS_REQ_SEVERANCEDC.SEQ.MsgType] = sTrType;
aIrtBody[Column.POS_REQ_SEVERANCEDC.SEQ.iNqType] = siNqType;
aIrtBody[Column.POS_REQ_SEVERANCEDC.SEQ.SaleTyep] = sSaleType ;
aIrtBody[Column.POS_REQ_SEVERANCEDC.SEQ.SaleTime] = DateTime.Now.ToString("yyyyMMdd") + DateTime.Now.ToString("HHmmss");
aIrtBody[Column.POS_REQ_SEVERANCEDC.SEQ.BrandCD] = m_cPosStatus.Base.BrandCd;
aIrtBody[Column.POS_REQ_SEVERANCEDC.SEQ.StoreCD] = m_cPosStatus.Base.StoreNo;
aIrtBody[Column.POS_REQ_SEVERANCEDC.SEQ.SaleDate] = m_cPosStatus.Base.SaleDate;
aIrtBody[Column.POS_REQ_SEVERANCEDC.SEQ.POSNo] = m_cPosStatus.Base.PosNo;
aIrtBody[Column.POS_REQ_SEVERANCEDC.SEQ.TranNo] = m_cPosStatus.Base.TradeNo;
aIrtBody[Column.POS_REQ_SEVERANCEDC.SEQ.CashierNo] = m_cPosStatus.Base.CashierNo;
aIrtBody[Column.POS_REQ_SEVERANCEDC.SEQ.WCC] = sWCC;
aIrtBody[Column.POS_REQ_SEVERANCEDC.SEQ.CardNo] = sCardData;
aIrtBody[Column.POS_REQ_SEVERANCEDC.SEQ.iTemQty1] = iTemQty1.ToString();
aIrtBody[Column.POS_REQ_SEVERANCEDC.SEQ.iSaleAmount1] = nSaleAmount1.ToString();
aIrtBody[Column.POS_REQ_SEVERANCEDC.SEQ.iTemQty2] = iTemQty2.ToString();
aIrtBody[Column.POS_REQ_SEVERANCEDC.SEQ.iSaleAmount2] = nSaleAmount2.ToString();
aIrtBody[Column.POS_REQ_SEVERANCEDC.SEQ.iTemCD] = iTemCD;
aIrtBody[Column.POS_REQ_SEVERANCEDC.SEQ.iTemNM] = iTemNM;
aIrtBody[Column.POS_REQ_SEVERANCEDC.SEQ.iTemQty3] = iTemQty3.ToString();
aIrtBody[Column.POS_REQ_SEVERANCEDC.SEQ.Password] = sPassword;
aIrtBody[Column.POS_REQ_SEVERANCEDC.SEQ.OrgSaleTime] = sApprDate;
aIrtBody[Column.POS_REQ_SEVERANCEDC.SEQ.OrgAppNo] = sApprNo;
// 요청 전문 생성
sSendData = ItemColumn.MakeMessage(aIrtBody, Column.POS_REQ_SEVERANCEDC.LEN, Column.POS_REQ_SEVERANCEDC.TYPE);
sSendData = PosConst.VAN_HEXA.STX + sSendData + PosConst.VAN_HEXA.ETX;
}
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 sCardData);
//////////////////////////////////////////////////////////////////////////////////
}
return sSendData;
}
#endregion
}
}