spc-kiosk-pb/Service/BsvPayment/ExchangeTicket.cs

720 lines
45 KiB
C#
Raw Normal View History

2019-06-16 05:12:09 +00:00
using Cosmos.Common;
using Cosmos.CommonManager;
using Cosmos.UserFrame;
using Newtonsoft.Json;
using System;
using System.Collections;
using System.Data;
/*-----------------------------------------------------------------------------------------------*/
// 설 명 : 잔액교환권
// 작 성 자 :
// 변경 이력 :
/*-----------------------------------------------------------------------------------------------*/
namespace Cosmos.Service
{
class ExchangeTicket : PaymentBase, IPaymentUs
{
public ExchangeTicket()
{
}
#region SearchPayment
/// <summary>
/// 결제 조회
/// </summary>
/// <param name="aParam"></param>
/// <param name="aRet"></param>
/// <returns></returns>
public string SearchPayment(string[] aParam, ref string[] aRet)
{
string sRet = UserCom.RST_ERR;
Hashtable htRecvData = new Hashtable();
try
{
m_cPayItem = new Column.TR_PAYMENT.DATA(); // 결과 저장 변수 생성
string sPosMenuKey = aParam[0]; // 전문구분
m_cPayItem.PAY_WAY_CD = aParam[1]; // 결제 그룹코드
m_cPayItem.PAY_DTL_CD_01 = aParam[2]; // 결제 상세코드
string sTicketType = aParam[3]; // 처리구분
string sTicketNo = aParam[4]; // 번호
double nSaleAmt = CmUtil.DoubleParse(aParam[5]); // 금액
// 잔액 교환권 조회
sRet = ExecuteHostIrt(PosConst.CANCEL_DIV.NORMAL, "10", new string[] { sPosMenuKey, m_cPayItem.PAY_WAY_CD, m_cPayItem.PAY_DTL_CD_01, sTicketType, sTicketNo, nSaleAmt.ToString() }, ref htRecvData);
if (sRet != UserCom.RST_OK) return sRet;
m_cPayItem.PAY_AMT = CmUtil.DoubleParse(aParam[5]);
m_cPayItem.PAY_DTL_CD_02 = ""; // 캠페인코드
m_cPayItem.PAY_DTL_CD_03 = "0"; // 할인금액 아이템 적용 여부 (0:미적용, 1:적용)
m_cPayItem.PAY_DTL_CD_04 = ""; // 상품코드
m_cPayItem.PAY_DTL_CD_05 = PosConst.PAY_DC_TYPE.PAY; // 할인결제구분 (1:결제, 2:할인)
m_cPayItem.QTY_ENTRY_01 = 0; // 수량
m_cPayItem.QTY_ENTRY_02 = 0;
m_cPayItem.QTY_ENTRY_03 = 0;
m_cPayItem.QTY_ENTRY_04 = 0;
m_cPayItem.QTY_ENTRY_05 = 0;
m_cPayItem.AMT_ENTRY_01 = m_cPayItem.PAY_AMT; // 받은돈
m_cPayItem.AMT_ENTRY_02 = 0; // 거스름
m_cPayItem.AMT_ENTRY_03 = CmUtil.DoubleParse(htRecvData[Column.IQ_EXCHAGE_TICKET_RSP.DATA.TICKET_AMT].ToString()); // 잔액교환권 금액
m_cPayItem.AMT_ENTRY_04 = 0;
m_cPayItem.AMT_ENTRY_05 = 0;
m_cPayItem.AMT_ENTRY_08 = 0;
m_cPayItem.AMT_ENTRY_09 = 0;
m_cPayItem.AMT_ENTRY_10 = 0;
m_cPayItem.OCCUR_ENTRY_01 = sTicketNo; // 카드번호
m_cPayItem.OCCUR_ENTRY_02 = ""; // 승인번호
m_cPayItem.OCCUR_ENTRY_03 = ""; // 승인일자
m_cPayItem.OCCUR_ENTRY_04 = ""; // 승인시간
m_cPayItem.OCCUR_ENTRY_05 = ""; // 입력 구분
m_cPayItem.OCCUR_ENTRY_06 = ""; // 원승인번호
m_cPayItem.OCCUR_ENTRY_07 = ""; // 원승인일자
m_cPayItem.OCCUR_ENTRY_08 = ItemConst.PAY_APP_DIV.NORMAL; // 승인구분
m_cPayItem.OCCUR_ENTRY_10 = (sTicketNo == "") ? "0" : "1"; // 잔액교환권 발행여부
m_cPayItem.OCCUR_ENTRY_11 = sTicketType; // 잔액교환권 발생구분
m_cPayItem.OCCUR_ENTRY_12 = sTicketNo; // 잔액교환권 번호
m_cPayItem.OCCUR_ENTRY_13 = ""; // 상품권 승인서버 ID
m_cPayItem.OCCUR_ENTRY_20 = GetPayDtlCdToPayDtlName(m_cPayItem.PAY_WAY_CD, m_cPayItem.PAY_DTL_CD_01); // 결제수단명
m_cPayItem.OCCUR_ENTRY_22 = "";
m_cPayItem.BILLSPR_NO = m_cTrnStatus.Sale.BillSplitNo; // 빌분리 번호
}
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 GetPayment
/// <summary>
/// 결제 정보 획득
/// </summary>
/// <param name="aParam"></param>
/// <returns></returns>
public object GetPayment(string[] aParam)
{
return m_cPayItem;
}
#endregion
#region SetPayment
/// <summary>
/// 결제 등록
/// </summary>
/// <param name="aParam"></param>
/// <returns></returns>
public string SetPayment(string[] aParam)
{
string sRet = UserCom.RST_ERR;
try
{
m_cPayItem = new Column.TR_PAYMENT.DATA(); // 결과 저장 변수 생성
string sPosMenuKey = aParam[0]; // 메뉴키
m_cPayItem.PAY_WAY_CD = aParam[1]; // 결제 그룹코드
m_cPayItem.PAY_DTL_CD_01 = aParam[2]; // 결제 상세코드
m_cPayItem.CANCEL_DIV = ItemConst.PAY_CANCEL_DIV.NORMAL; // 취소여부
string sInqType = aParam[3]; // 전문구분
string sWcc = aParam[4]; // 입력구분
string sGiftNo = aParam[5]; // 번호
double nQty = CmUtil.DoubleParse(aParam[6]); // 수량
double nSaleAmt = CmUtil.DoubleParse(aParam[7]); // 금액
string sTicketType = aParam[8]; // 티켓발행구분
string sTicketNo = aParam[9]; // 티켓번호
double nTicketAmt = CmUtil.DoubleParse(aParam[10]); // 티켓금액
string sMakeType = aParam[11]; // 티켓발생구분
string sAppNo = aParam[12]; // 승인번호
string sAppDate = aParam[13]; // 승인일자
double nChangeMoney = CmUtil.DoubleParse(aParam[14]); // 거스름
// 승인요청
sRet = ExecuteIrt(PosConst.CANCEL_DIV.NORMAL, ItemConst.EXCHANGE_TICKET_ISSUE_TYPE.USE, new string[] { sPosMenuKey, m_cPayItem.PAY_WAY_CD, m_cPayItem.PAY_DTL_CD_01, sInqType, sWcc, sGiftNo, nQty.ToString()
, nSaleAmt.ToString(), sTicketType, sTicketNo, nTicketAmt.ToString(), sMakeType, sAppNo, sAppDate, nChangeMoney.ToString(), "", "" });
if (sRet != UserCom.RST_OK) return sRet;
if (nChangeMoney > 0)
m_cPosStatus.Sale.ChangeCashAmt = nChangeMoney; // 거스름
// 결제 아이템 추가
ArrayList alPayItem = (ArrayList)StateObject.GetItemObject(Column.TR_PAYMENT.ITEM); // 결제 내역 받아 오기
m_cPayItem.SEQ = alPayItem.Count + 1;
alPayItem.Add(m_cPayItem);
m_cDataService.UpdatePluAmount(); // 상품 합계금액 계산(거래해더)
m_cDataService.UpdatePayAmount(); // 결제 금액 재 계산 처리
sRet = UserCom.RST_OK;
//WinManager.ConfirmMessage(sPointType + " " + MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0067));
}
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
/// <summary>
/// 결제 취소
/// </summary>
/// <returns></returns>
public string CancelPayment(string[] aParam)
{
string sRet = UserCom.RST_ERR;
try
{
// ---------------------------------------------------------------------------------------------------------------------------------------
// 결제 수단 취소
// ---------------------------------------------------------------------------------------------------------------------------------------
ArrayList alPayItem = (ArrayList)StateObject.GetItemObject(Column.TR_PAYMENT.ITEM);
for (int iRow = 0; iRow < alPayItem.Count; iRow++)
{
Column.TR_PAYMENT.DATA clPayItem = (Column.TR_PAYMENT.DATA)alPayItem[iRow];
// 취소구분
if (clPayItem.CANCEL_DIV == ItemConst.PAY_CANCEL_DIV.CANCEL) continue;
// 잔액교환권
if (clPayItem.PAY_WAY_CD != ItemConst.TR_ITEM_ID.PAYETC_ITEM && clPayItem.PAY_DTL_CD_01 != ItemConst.TR_ITEM_ID.PAYETC.BALANCE_VOUCHER) continue;
// 결제 수단 취소
sRet = CancelPaymentSub(new string[] { iRow.ToString() });
if (sRet != UserCom.RST_OK) return sRet;
}
// ---------------------------------------------------------------------------------------------------------------------------------------
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
/// <summary>
/// 결제 반품
/// </summary>
/// <returns></returns>
public string RefundPayment(string[] aParam)
{
string sRet = UserCom.RST_ERR;
try
{
//// ---------------------------------------------------------------------------------------------------------------------------------------
//// 결제 수단 반품
//// ---------------------------------------------------------------------------------------------------------------------------------------
//ArrayList alPayItem = (ArrayList)StateObject.GetItemObject(Column.TR_PAYMENT.ITEM);
//for (int iRow = 0; iRow < alPayItem.Count; iRow++)
//{
// Column.TR_PAYMENT.DATA clPayItem = (Column.TR_PAYMENT.DATA)alPayItem[iRow];
// // 취소구분
// if (clPayItem.CANCEL_DIV == ItemConst.PAY_CANCEL_DIV.CANCEL) continue;
// // 잔액교환권
// if (clPayItem.PAY_WAY_CD != ItemConst.TR_ITEM_ID.PAYETC_ITEM && clPayItem.PAY_DTL_CD_01 != ItemConst.TR_ITEM_ID.PAYETC.BALANCE_VOUCHER) continue;
// 결제 수단 반품
sRet = RefundPaymentSub(new string[] { aParam[0].ToString() });
if (sRet != UserCom.RST_OK) 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);
}
return sRet;
}
#endregion
#region RefundPaymentSub
/// <summary>
/// 결제 반품
/// </summary>
/// <param name="aParam"></param>
/// <returns></returns>
public string RefundPaymentSub(string[] aParam)
{
string sRet = UserCom.RST_ERR;
Hashtable htRecvData = new Hashtable();
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];
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;
}
else
{
string sPosMenuKey = "";
string sInqFlag = ItemConst.EXCHANGE_TICKET_ISSUE_TYPE.USE_CANCEL; // 승인구분
string sWcc = m_cPayItem.OCCUR_ENTRY_05; // 입력구분
string sGiftNo = m_cPayItem.OCCUR_ENTRY_01; // 번호
double nQty = CmUtil.DoubleParse(m_cPayItem.QTY_ENTRY_01.ToString()); // 수량
double nSaleAmt = CmUtil.DoubleParse(m_cPayItem.AMT_ENTRY_01.ToString()); // 금액
string sTicketType = m_cPayItem.OCCUR_ENTRY_10; // 티켓발행구분
string sTicketNo = m_cPayItem.OCCUR_ENTRY_12; // 티켓번호
double nTicketAmt = CmUtil.DoubleParse(m_cPayItem.AMT_ENTRY_03.ToString()); // 티켓금액
string sMakeType = m_cPayItem.OCCUR_ENTRY_11; // 티켓발생구분
string sAppNo = m_cPayItem.OCCUR_ENTRY_02; // 승인번호
string sAppDate = m_cPayItem.OCCUR_ENTRY_03; // 승인일자
double nChangeMoney = CmUtil.DoubleParse(m_cPayItem.AMT_ENTRY_02.ToString()); // 거스름
string sOrgAppNo = m_cPayItem.OCCUR_ENTRY_02; // 승인번호
string sOrgAppDate = m_cPayItem.OCCUR_ENTRY_03; // 승인일자
// 잔액교환권 번호가 있을 경우 발행취소 요청
if (m_cPayItem.OCCUR_ENTRY_12.Trim().Length > 0)
{
sRet = ExecuteHostIrt(PosConst.CANCEL_DIV.CANCEL, "", new string[] { ItemConst.IRT_INQ_TYPE.EXCHANGE_TICKET_INQ, m_cPayItem.PAY_WAY_CD, m_cPayItem.PAY_DTL_CD_01, ItemConst.EXCHANGE_TICKET_ISSUE_TYPE.MAKE_CANCEL, sTicketNo, nTicketAmt.ToString() }, ref htRecvData);
if (sRet != UserCom.RST_OK) return sRet;
}
// 취소
sRet = ExecuteIrt(PosConst.CANCEL_DIV.CANCEL, ItemConst.EXCHANGE_TICKET_ISSUE_TYPE.USE_CANCEL, new string[] { ItemConst.IRT_INQ_TYPE.EXCHANGE_TICKET_INQ, m_cPayItem.PAY_WAY_CD, m_cPayItem.PAY_DTL_CD_01, sInqFlag, sWcc, sGiftNo, nQty.ToString()
, nSaleAmt.ToString(), sTicketType, sTicketNo, nTicketAmt.ToString(), sMakeType, sAppNo, sAppDate, nChangeMoney.ToString(), sOrgAppNo, sOrgAppDate });
if (sRet != UserCom.RST_OK) return sRet;
//m_cPayItem.CANCEL_DIV = PosConst.CANCEL_DIV.CANCEL;
}
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 SetMenualPayment
public string SetMenualPayment(string[] aParam)
{
throw new NotImplementedException();
}
#endregion
#region CancelPaymentSub
/// <summary>
/// 결제 취소
/// </summary>
/// <param name="aParam"></param>
/// <returns></returns>
public string CancelPaymentSub(string[] aParam)
{
string sRet = UserCom.RST_ERR;
Hashtable htRecvData = new Hashtable();
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];
string sPosMenuKey = "";
string sInqFlag = ItemConst.EXCHANGE_TICKET_ISSUE_TYPE.USE_CANCEL; // 승인구분
string sWcc = m_cPayItem.OCCUR_ENTRY_05; // 입력구분
string sGiftNo = m_cPayItem.OCCUR_ENTRY_01; // 번호
double nQty = CmUtil.DoubleParse(m_cPayItem.QTY_ENTRY_01.ToString()); // 수량
double nSaleAmt = CmUtil.DoubleParse(m_cPayItem.AMT_ENTRY_01.ToString()); // 금액
string sTicketType = m_cPayItem.OCCUR_ENTRY_10; // 티켓발행구분
string sTicketNo = m_cPayItem.OCCUR_ENTRY_12; // 티켓번호
double nTicketAmt = CmUtil.DoubleParse(m_cPayItem.AMT_ENTRY_03.ToString()); // 티켓금액
string sMakeType = m_cPayItem.OCCUR_ENTRY_11; // 티켓발생구분
string sAppNo = m_cPayItem.OCCUR_ENTRY_02; // 승인번호
string sAppDate = m_cPayItem.OCCUR_ENTRY_03; // 승인일자
double nChangeMoney = CmUtil.DoubleParse(m_cPayItem.AMT_ENTRY_02.ToString()); // 거스름
string sOrgAppNo = m_cPayItem.OCCUR_ENTRY_02; // 승인번호
string sOrgAppDate = m_cPayItem.OCCUR_ENTRY_03; // 승인일자
// 잔액교환권 번호가 있을 경우 발행취소 요청
if (m_cPayItem.OCCUR_ENTRY_12.Trim().Length > 0)
{
sRet = ExecuteHostIrt(PosConst.CANCEL_DIV.CANCEL, "", new string[] { ItemConst.IRT_INQ_TYPE.EXCHANGE_TICKET_INQ, m_cPayItem.PAY_WAY_CD, m_cPayItem.PAY_DTL_CD_01, ItemConst.EXCHANGE_TICKET_ISSUE_TYPE.MAKE_CANCEL, sTicketNo, nTicketAmt.ToString() }, ref htRecvData);
if (sRet != UserCom.RST_OK) return sRet;
}
// 취소
sRet = ExecuteIrt(PosConst.CANCEL_DIV.CANCEL, ItemConst.EXCHANGE_TICKET_ISSUE_TYPE.USE_CANCEL, new string[] { ItemConst.IRT_INQ_TYPE.EXCHANGE_TICKET_INQ, m_cPayItem.PAY_WAY_CD, m_cPayItem.PAY_DTL_CD_01, sInqFlag, sWcc, sGiftNo, nQty.ToString()
, nSaleAmt.ToString(), sTicketType, sTicketNo, nTicketAmt.ToString(), sMakeType, sAppNo, sAppDate, nChangeMoney.ToString(), sOrgAppNo, sOrgAppDate });
if (sRet != UserCom.RST_OK) return sRet;
m_cPayItem.CANCEL_DIV = PosConst.CANCEL_DIV.CANCEL;
//#20170830 거스름돈 발생시 결제취소 해도 거스름돈(AMT_ENTRY_02)이 취소가 안되어 계산함 start
//현금, 잔액교환권, 외화, 상품권, 식권
m_cPosStatus.Sale.ChangeCashAmt = CmUtil.DoubleSubtraction(m_cPosStatus.Sale.ChangeCashAmt, m_cPayItem.AMT_ENTRY_02);
//m_cPayItem.AMT_ENTRY_01 = 0;
//m_cPayItem.AMT_ENTRY_02 = 0;
//#20170830 거스름돈 발생시 결제취소 해도 거스름돈(AMT_ENTRY_02)이 취소가 안되어 계산함 end
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
/// <summary>
/// 조회 실행
/// </summary>
public string ExecuteIrt(string sTradeDiv, string sDealType, string[] aParam)
{
string sRet = UserCom.RST_ERR;
Hashtable htRecvData = new Hashtable();
try
{
string sPosMenuKey = aParam[0]; // 메뉴키
m_cPayItem.PAY_WAY_CD = aParam[1]; // 결제 그룹코드
m_cPayItem.PAY_DTL_CD_01 = aParam[2]; // 결제 상세코드
m_cPayItem.CANCEL_DIV = ItemConst.PAY_CANCEL_DIV.NORMAL; // 취소여부
string sInqFlag = aParam[3]; // 승인서버id
string sWcc = aParam[4]; // 입력구분
string sGiftNo = aParam[5]; // 번호
double nQty = CmUtil.DoubleParse(aParam[6]); // 수량
double nSaleAmt = CmUtil.DoubleParse(aParam[7]); // 금액
string sTicketType = aParam[8]; // 티켓발행구분
string sTicketNo = aParam[9]; // 티켓번호
double nTicketAmt = CmUtil.DoubleParse(aParam[10]); // 티켓금액
string sMakeType = aParam[11]; // 티켓발생구분
string sAppNo = aParam[12]; // 승인번호
string sAppDate = aParam[13]; // 승인일자
double nChangeMoney = CmUtil.DoubleParse(aParam[14]); // 거스름
string sOrgAppNo = aParam[15]; // 원승인번호
string sOrgAppDate = aParam[16]; // 원승인일자
// 연습모드이면 연습 데이터 설정
if (m_cPosStatus.Base.TrainingFlag == "1" || m_cPosStatus.Mst.TestStorYn == "1" ) return SetTrainingData(new string[] { sPosMenuKey, m_cPayItem.PAY_WAY_CD, m_cPayItem.PAY_DTL_CD_01, sInqFlag, sWcc, sGiftNo, nQty.ToString()
, nSaleAmt.ToString(), sTicketType, sTicketNo, nTicketAmt.ToString(), sMakeType, sAppNo, sAppDate, nChangeMoney.ToString(), "", "" });
// 승인 처리
sRet = ExecuteHostIrt(sTradeDiv, sDealType, new string[] { sPosMenuKey, m_cPayItem.PAY_WAY_CD, m_cPayItem.PAY_DTL_CD_01, sInqFlag, sGiftNo, nSaleAmt.ToString() }, ref htRecvData);
if (sRet != UserCom.RST_OK) return sRet;
// 결제구분 (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_AMT = nSaleAmt;
m_cPayItem.PAY_AMT = CmUtil.DoubleSubtraction(m_cPayItem.PAY_AMT, nChangeMoney); // 받은돈
m_cPayItem.PAY_AMT = CmUtil.DoubleSubtraction(m_cPayItem.PAY_AMT, nTicketAmt);
m_cPayItem.PAY_DTL_CD_02 = ""; // 캠페인코드
m_cPayItem.PAY_DTL_CD_03 = "0"; // 할인금액 아이템 적용 여부 (0:미적용, 1:적용)
m_cPayItem.PAY_DTL_CD_04 = ""; // 상품코드
m_cPayItem.PAY_DTL_CD_05 = PosConst.PAY_DC_TYPE.PAY; // 할인결제구분 (1:결제, 2:할인)
m_cPayItem.QTY_ENTRY_01 = 0; // 수량
m_cPayItem.QTY_ENTRY_02 = 0;
m_cPayItem.QTY_ENTRY_03 = 0;
m_cPayItem.QTY_ENTRY_04 = 0;
m_cPayItem.QTY_ENTRY_05 = 0;
m_cPayItem.AMT_ENTRY_01 = nSaleAmt; // 받은돈
m_cPayItem.AMT_ENTRY_02 = nChangeMoney; // 거스름
m_cPayItem.AMT_ENTRY_03 = nTicketAmt; // 잔액교환권 금액
m_cPayItem.AMT_ENTRY_04 = 0;
m_cPayItem.AMT_ENTRY_05 = 0;
m_cPayItem.AMT_ENTRY_08 = 0;
m_cPayItem.AMT_ENTRY_09 = 0;
m_cPayItem.AMT_ENTRY_10 = 0;
m_cPayItem.OCCUR_ENTRY_01 = sGiftNo; // 카드번호
m_cPayItem.OCCUR_ENTRY_02 = ""; // 승인번호
m_cPayItem.OCCUR_ENTRY_03 = ""; // 승인일자
m_cPayItem.OCCUR_ENTRY_04 = ""; // 승인시간
m_cPayItem.OCCUR_ENTRY_05 = sWcc; // 입력 구분
m_cPayItem.OCCUR_ENTRY_06 = ""; // 원승인번호
m_cPayItem.OCCUR_ENTRY_07 = ""; // 원승인일자
m_cPayItem.OCCUR_ENTRY_08 = ItemConst.PAY_APP_DIV.NORMAL; // 승인구분
m_cPayItem.OCCUR_ENTRY_10 = (sTicketNo == "") ? "0" : "1"; // 잔액교환권 발행여부
m_cPayItem.OCCUR_ENTRY_11 = sTicketType; // 잔액교환권 발생구분
m_cPayItem.OCCUR_ENTRY_12 = sTicketNo; // 잔액교환권 번호
m_cPayItem.OCCUR_ENTRY_13 = ""; // 상품권 승인서버 ID
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); // 결제수단명
if (CmUtil.RightH(sGiftNo.Trim(), 1) == ItemConst.EXCHANGE_TICKET_MAKE_TYPE.GIFT)
// 잔액교환권 사용시 발생구분이 상품권인 경우 현금영수증 발행 대상으로 선정
m_cPayItem.OCCUR_ENTRY_21 = ItemConst.PAY_CASHBILL_DIV.YES; // 현금영수증 발행여부
else
m_cPayItem.OCCUR_ENTRY_21 = ItemConst.PAY_CASHBILL_DIV.NO; // 현금영수증 발행여부
m_cPayItem.OCCUR_ENTRY_22 = "";
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);
}
return sRet;
}
/// <summary>
/// 연습 데이터 설정
/// </summary>
public string SetTrainingData(string[] aParam)
{
string sRet = UserCom.RST_ERR;
try
{
// 연습모드이면 연습 데이터 설정
string sPosMenuKey = aParam[0]; // 메뉴키
m_cPayItem.PAY_WAY_CD = aParam[1]; // 결제 그룹코드
m_cPayItem.PAY_DTL_CD_01 = aParam[2]; // 결제 상세코드
m_cPayItem.CANCEL_DIV = ItemConst.PAY_CANCEL_DIV.NORMAL; // 취소여부
string sInqFlag = aParam[3]; // 승인서버id
string sWcc = aParam[4]; // 입력구분
string sGiftNo = aParam[5]; // 번호
double nQty = CmUtil.DoubleParse(aParam[6]); // 수량
double nSaleAmt = CmUtil.DoubleParse(aParam[7]); // 금액
string sTicketType = aParam[8]; // 티켓발행구분
string sTicketNo = aParam[9]; // 티켓번호
double nTicketAmt = CmUtil.DoubleParse(aParam[10]); // 티켓금액
string sMakeType = aParam[11]; // 티켓발생구분
string sAppNo = aParam[12]; // 승인번호
string sAppDate = aParam[13]; // 승인일자
double nChangeMoney = CmUtil.DoubleParse(aParam[14]); // 거스름
string sOrgAppNo = aParam[15]; // 원승인번호
string sOrgAppDate = aParam[16]; // 원승인일자
// 결제구분 (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_AMT = CmUtil.DoubleParse(aParam[5]);
m_cPayItem.PAY_AMT = CmUtil.DoubleSubtraction(m_cPayItem.PAY_AMT, nChangeMoney);
m_cPayItem.PAY_AMT = CmUtil.DoubleSubtraction(m_cPayItem.PAY_AMT, nTicketAmt);
m_cPayItem.PAY_DTL_CD_02 = ""; // 캠페인코드
m_cPayItem.PAY_DTL_CD_03 = "0"; // 할인금액 아이템 적용 여부 (0:미적용, 1:적용)
m_cPayItem.PAY_DTL_CD_04 = ""; // 상품코드
m_cPayItem.PAY_DTL_CD_05 = PosConst.PAY_DC_TYPE.PAY; // 할인결제구분 (1:결제, 2:할인)
m_cPayItem.QTY_ENTRY_01 = 0; // 수량
m_cPayItem.QTY_ENTRY_02 = 0;
m_cPayItem.QTY_ENTRY_03 = 0;
m_cPayItem.QTY_ENTRY_04 = 0;
m_cPayItem.QTY_ENTRY_05 = 0;
m_cPayItem.AMT_ENTRY_01 = m_cPayItem.PAY_AMT; // 받은돈
m_cPayItem.AMT_ENTRY_02 = nChangeMoney; // 거스름
m_cPayItem.AMT_ENTRY_03 = nTicketAmt; // 잔액교환권 금액
m_cPayItem.AMT_ENTRY_04 = 0;
m_cPayItem.AMT_ENTRY_05 = 0;
m_cPayItem.AMT_ENTRY_08 = 0;
m_cPayItem.AMT_ENTRY_09 = 0;
m_cPayItem.AMT_ENTRY_10 = 0;
m_cPayItem.OCCUR_ENTRY_01 = sGiftNo; // 카드번호
m_cPayItem.OCCUR_ENTRY_02 = ""; // 승인번호
m_cPayItem.OCCUR_ENTRY_03 = ""; // 승인일자
m_cPayItem.OCCUR_ENTRY_04 = ""; // 승인시간
m_cPayItem.OCCUR_ENTRY_05 = sWcc; // 입력 구분
m_cPayItem.OCCUR_ENTRY_06 = ""; // 원승인번호
m_cPayItem.OCCUR_ENTRY_07 = ""; // 원승인일자
m_cPayItem.OCCUR_ENTRY_08 = ItemConst.PAY_APP_DIV.COMPULSION; // 승인구분
m_cPayItem.OCCUR_ENTRY_10 = "0"; // 잔액교환권 발행여부
m_cPayItem.OCCUR_ENTRY_11 = ""; // 잔액교환권 발생구분
m_cPayItem.OCCUR_ENTRY_12 = ""; // 잔액교환권 번호
m_cPayItem.OCCUR_ENTRY_13 = ""; // 상품권 승인서버 ID
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); // 결제수단명
if (CmUtil.RightH(sGiftNo.Trim(), 1) == ItemConst.EXCHANGE_TICKET_MAKE_TYPE.GIFT)
// 잔액교환권 사용시 발생구분이 상품권인 경우 현금영수증 발행 대상으로 선정
m_cPayItem.OCCUR_ENTRY_21 = ItemConst.PAY_CASHBILL_DIV.YES; // 현금영수증 발행여부
else
m_cPayItem.OCCUR_ENTRY_21 = ItemConst.PAY_CASHBILL_DIV.NO; // 현금영수증 발행여부
m_cPayItem.OCCUR_ENTRY_22 = "";
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);
}
return sRet;
}
#endregion
#region Host
/// <summary>
/// Host 소켓 통신
/// </summary>
private string ExecuteHostIrt(string sTradeDiv, string sDealType, string[] aParam, ref Hashtable htRecvData)
{
string sRet = UserCom.RST_ERR;
int iRecvTimeOut = 10000;
Hashtable htSendData = new Hashtable();
try
{
// Body 생성
sRet = GetMakeSendDataBody(sDealType, aParam, ref htSendData);
if (sRet != UserCom.RST_OK) return sRet;
switch (aParam[0])
{
// ----------------------------------------------------------------------------------------------------------------------------------------------------------------
// 잔액교환권
// ----------------------------------------------------------------------------------------------------------------------------------------------------------------
case ItemConst.IRT_INQ_TYPE.EXCHANGE_TICKET_INQ:
{
// 요청 - 승인로그 저장 (판매구분, [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, sDealType, "S", aParam[4], CmUtil.DoubleParse(aParam[5]).ToString(), "", "", "", "", "", JsonConvert.SerializeObject(htSendData) });
// 전송
sRet = m_cDataCommon.ExecutePosIrt(ItemConst.COMM_MSG_TYPE.POSIRT, m_cPosStatus.Base.CommSvrIp, (int)m_cPosStatus.Base.PayInqPort, iRecvTimeOut, htSendData, ref htRecvData);
if (sRet != UserCom.RST_OK)
{
WinManager.ErrorMessage(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0005));
sRet = UserCom.RST_ERR;
return sRet;
}
// 응답 - 승인로그 저장 (판매구분, [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, sDealType, "R"
, aParam[4], CmUtil.DoubleParse(aParam[5]).ToString()
, "", "", ""
, htRecvData[Column.IQ_EXCHAGE_TICKET_RSP.DATA.RES_CD].ToString()
, htRecvData[Column.IQ_EXCHAGE_TICKET_RSP.DATA.RES_MSG].ToString()
, JsonConvert.SerializeObject(htRecvData) });
// 응답 체크
if (htRecvData[Column.IQ_EXCHAGE_TICKET_RSP.DATA.RES_CD].ToString() != "00")
{
//WinManager.ErrorMessage(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0187) + "\n\r" + "(" + htRecvData[Column.IQ_EXCHAGE_TICKET_RSP.DATA.RES_CD].ToString() + ")" + htRecvData[Column.IQ_LOTTERY_NUMBERINQ_RSP.DATA.RES_MSG]);
WinManager.ErrorMessage("(" + htRecvData[Column.IQ_EXCHAGE_TICKET_RSP.DATA.RES_CD].ToString() + ")" + htRecvData[Column.IQ_LOTTERY_NUMBERINQ_RSP.DATA.RES_MSG]);
sRet = UserCom.RST_ERR;
return sRet;
}
break;
}
// ----------------------------------------------------------------------------------------------------------------------------------------------------------------
}
}
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 Host Body
/// <summary>
/// Host Body 생성
/// </summary>
private string GetMakeSendDataBody(string sDealType, string[] aParam, ref Hashtable htSendData)
{
string sRet = UserCom.RST_ERR;
try
{
string sPosMenuKey = aParam[0]; // 전문구분
m_cPayItem.PAY_WAY_CD = aParam[1]; // 결제 그룹코드
m_cPayItem.PAY_DTL_CD_01 = aParam[2]; // 결제 상세코드
switch (sPosMenuKey)
{
case ItemConst.IRT_INQ_TYPE.EXCHANGE_TICKET_INQ:
{
string sTicketType = aParam[3]; // 처리구분
string sTicketNo = aParam[4]; // 번호
double nSaleAmt = CmUtil.DoubleParse(aParam[5]); // 금액
// 잔액교환권
htSendData.Add(Column.IQ_EXCHAGE_TICKET_REQ.DATA.INQ_TYPE, sPosMenuKey);
htSendData.Add(Column.IQ_EXCHAGE_TICKET_REQ.DATA.STOR_CD, m_cPosStatus.Base.StoreNo);
htSendData.Add(Column.IQ_EXCHAGE_TICKET_REQ.DATA.SALE_DT, m_cPosStatus.Base.SaleDate);
htSendData.Add(Column.IQ_EXCHAGE_TICKET_REQ.DATA.POS_NO, m_cPosStatus.Base.PosNo);
htSendData.Add(Column.IQ_EXCHAGE_TICKET_REQ.DATA.ISSUE_TYPE, sTicketType);
htSendData.Add(Column.IQ_EXCHAGE_TICKET_REQ.DATA.TICKET_NO, sTicketNo);
htSendData.Add(Column.IQ_EXCHAGE_TICKET_REQ.DATA.TICKET_AMT, nSaleAmt);
htSendData.Add(Column.IQ_EXCHAGE_TICKET_REQ.DATA.USER_ID, m_cPosStatus.Base.CashierNo);
htSendData.Add(Column.IQ_EXCHAGE_TICKET_REQ.DATA.RES_CD, "");
htSendData.Add(Column.IQ_EXCHAGE_TICKET_REQ.DATA.RES_MSG, "");
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);
}
return sRet;
}
#endregion
}
}