spc-kiosk-pb/Service/BsvPayment/HappyGiftUse.cs
2019-06-16 14:12:09 +09:00

447 lines
24 KiB
C#

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 HappyGiftUse : PaymentBase, IPaymentUs
{
public HappyGiftUse()
{
}
#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;
string sPosMenuKey = "", sInPutType = "", sInPutData = "", sInEncData = "";
try
{
sPosMenuKey = aParam[0]; // 메뉴키
sInPutType = aParam[1]; // 입력구분
sInPutData = aParam[2]; // 입력데이터
sInEncData = aParam[3]; // 카드데이터
double nPayAmt = CmUtil.DoubleParse(aParam[4]); // 금액
string sTrType = PosConst.POS_VAN_MASTER.TRADE_ID.VAN_POT_QRY_A;
string sPointType = GetMenuKeyToPointType(sPosMenuKey);
m_cPayItem = new Column.TR_PAYMENT.DATA(); // 결과 저장 변수 생성
m_cPayItem.PAY_WAY_CD = GetMenuKeyToPayWayCd(sPosMenuKey);
m_cPayItem.PAY_DTL_CD_01 = GetMenuKeyToPayDtlCd(sPosMenuKey);
sRet = ExecuteIrt(PosConst.CANCEL_DIV.NORMAL, sTrType, sPointType, sInPutType, sInPutData, sInEncData, nPayAmt, "", "", "");
}
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 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;
string sPosMenuKey = "", sInPutType = "", sInPutData = "", sInEncData = "";
try
{
sPosMenuKey = aParam[0]; // 메뉴키
sInPutType = aParam[1]; // 입력구분
sInPutData = aParam[2]; // 입력데이터
sInEncData = aParam[3]; // 카드데이터
double nPayAmt = CmUtil.DoubleParse(aParam[4]); // 대상금액
string sPassWord = ""; // 비밀번호
string sTrType = PosConst.POS_VAN_MASTER.TRADE_ID.VAN_POT_USE_A;
string sPointType = GetMenuKeyToPointType(sPosMenuKey);
//m_cPayItem = new Column.TR_PAYMENT.DATA(); // 결과 저장 변수 생성
ArrayList alPayItem = (ArrayList)StateObject.GetItemObject(Column.TR_PAYMENT.ITEM); // 결제 내역 받아 오기
m_cPayItem.PAY_WAY_CD = GetMenuKeyToPayWayCd(sPosMenuKey);
m_cPayItem.PAY_DTL_CD_01 = GetMenuKeyToPayDtlCd(sPosMenuKey);
sRet = ExecuteIrt(PosConst.CANCEL_DIV.NORMAL, sTrType, sPointType, sInPutType, sInPutData, sInEncData, nPayAmt, sPassWord, "", "");
if (sRet != UserCom.RST_OK) return sRet;
// 결제 아이템 추가
m_cPayItem.SEQ = alPayItem.Count + 1;
alPayItem.Add(m_cPayItem);
m_cDataService.UpdatePluAmount(); // 상품 합계금액 계산(거래해더)
m_cDataService.UpdatePayAmount(); // 결제 금액 재 계산 처리
//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);
}
finally
{
//여전법 대응!
//////////////////////////////////////////////////////////////////////////////////
CmUtil.ZeroFillClear(ref sInPutData);
CmUtil.ZeroFillClear(ref sInEncData);
CmUtil.ZeroFillClear(ref aParam);
//////////////////////////////////////////////////////////////////////////////////
}
return sRet;
}
#endregion
#region CancelPayment
/// <summary>
/// 결제 취소
/// </summary>
/// <param name="aParam"></param>
/// <returns></returns>
public string CancelPayment(string[] aParam)
{
string sRet = UserCom.RST_ERR;
string sInPutType = "", sInPutData = "", sInEncData = "";
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];
sInPutType = m_cPayItem.OCCUR_ENTRY_05; // 입력구분
sInPutData = m_cPayItem.OCCUR_ENTRY_01; // 입력데이터
sInEncData = m_cPayItem.CanFiller1; // 카드데이터
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_MASTER.TRADE_ID.VAN_POT_USE_C;
string sPointType = GetPayDtlCdToPointType(m_cPayItem.PAY_WAY_CD, m_cPayItem.PAY_DTL_CD_01);
sRet = ExecuteIrt(PosConst.CANCEL_DIV.CANCEL, sTrType, sPointType, sInPutType, sInPutData, sInEncData, nPayAmt, sPassWord, sApprDate, sApprNo);
if (sRet != UserCom.RST_OK) return sRet;
m_cPayItem.CANCEL_DIV = PosConst.CANCEL_DIV.CANCEL;
m_cDataService.UpdatePluAmount(); // 상품 합계금액 계산(거래해더)
m_cDataService.UpdatePayAmount(); // 결제 금액 재 계산 처리
//WinManager.ConfirmMessage(sPointType + " " + MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0068));
// 여전법 대응 ///////////////////////////////////////////////////////////////////
CmUtil.ZeroFillClear(ref m_cPayItem.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 sInPutData);
CmUtil.ZeroFillClear(ref sInEncData);
CmUtil.ZeroFillClear(ref aParam);
//////////////////////////////////////////////////////////////////////////////////
}
return sRet;
}
#endregion
#region RefundPayment
/// <summary>
/// 결제 반품
/// </summary>
/// <param name="aParam"></param>
/// <returns></returns>
public string RefundPayment(string[] aParam)
{
string sRet = UserCom.RST_ERR;
string sInPutType = "", sInPutData = "", sInEncData = "";
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;
}
else
{
sInPutType = m_cPayItem.OCCUR_ENTRY_05; // 입력구분
sInPutData = m_cPayItem.OCCUR_ENTRY_01; // 입력데이터
sInEncData = m_cPayItem.CanFiller1; // 카드데이터
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_MASTER.TRADE_ID.VAN_POT_USE_C;
string sPointType = GetPayDtlCdToPointType(m_cPayItem.PAY_WAY_CD, m_cPayItem.PAY_DTL_CD_01);
sRet = ExecuteIrt(PosConst.CANCEL_DIV.CANCEL, sTrType, sPointType, sInPutType, sInPutData, sInEncData, nPayAmt, sPassWord, sApprDate, sApprNo);
if (sRet != UserCom.RST_OK) return sRet;
}
// 여전법 대응 ///////////////////////////////////////////////////////////////////
CmUtil.ZeroFillClear(ref m_cPayItem.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 sInPutData);
CmUtil.ZeroFillClear(ref sInEncData);
CmUtil.ZeroFillClear(ref aParam);
//////////////////////////////////////////////////////////////////////////////////
}
return sRet;
}
#endregion
#region SetMenualPayment
public string SetMenualPayment(string[] aParam)
{
throw new NotImplementedException();
}
#endregion
#region
/// <summary>
/// 조회
/// </summary>
public string ExecuteIrt(string sTradeDiv, string sTrType, string sPointType, string sInPutType, string sInPutData, string sCardData, double nPayAmt, string sPassWord, string sApprDate, string sApprNo)
{
string sRecvData = "";
string sRet = UserCom.RST_ERR;
string sAddInfo = "";
try
{
// 연습모드이면 연습 데이터 설정
if (m_cPosStatus.Base.TrainingFlag == "1" || m_cPosStatus.Mst.TestStorYn == "1" ) return SetTrainingData(sTrType, sPointType, sInPutType, sInPutData, sCardData, nPayAmt, sPassWord, sApprDate, sApprNo);
// 승인업체 코드 조회
//string sCMPApprID = PosMstManager.GetMstVan(ItemConst.TR_ITEM_ID.PPCARD_ITEM, ItemConst.TR_ITEM_ID.PPCARD.HP_GIFT, PosMst.MST_VAN.DATA.CMP_APPR_ID);
//string sVanCD = PosMstManager.GetMstPayDc(m_cPayItem.PAY_WAY_CD, m_cPayItem.PAY_DTL_CD_01, PosMst.MST_PAY_DC.DATA.APPR_VEND_CD);
//string sCMPApprID = PosMstManager.GetMstVan(ItemConst.TR_ITEM_ID.PPCARD_ITEM, ItemConst.TR_ITEM_ID.PPCARD.HP_GIFT, PosMst.MST_VAN.DATA.CMP_APPR_ID);
string sVanCD = PosMstManager.GetMstPayDc(m_cPayItem.PAY_WAY_CD, m_cPayItem.PAY_DTL_CD_01, PosMst.MST_PAY_DC.DATA.APPR_VEND_CD);
if (sVanCD == "")
{
WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0563);
return sRet;
}
sAddInfo = "";
sAddInfo += CmUtil.MidH("0003", 0, 4); // 버전
sAddInfo += CmUtil.MidH(m_cPosStatus.Base.StoreNo, 0, 10); // 지점코드
//sAddInfo += CmUtil.MidH(CmUtil.GetDataRowStr(PosMstManager.GetMstStore(), PosMst.MST_STORE.DATA.STORNM), 0, 20); // 지점명칭
sAddInfo += CmUtil.MidH("", 0, 20);
sAddInfo += CmUtil.MidH(sApprNo, 0, 20); // 승인번호
sAddInfo += CmUtil.MidH(m_cPosStatus.Base.PosNo, 0, 10); // POS NO
//sAddInfo += CmUtil.MidH("", 0, 136); // Filler
string sProductCode = PosMstManager.GetMstVan(ItemConst.TR_ITEM_ID.PPCARD_ITEM, ItemConst.TR_ITEM_ID.PPCARD.HP_GIFT, PosMst.MST_VAN.DATA.HOME_PAGE);
if (sProductCode.Trim().Length == 0) sProductCode = "TT0000"; // 브랜드코드
// 포인트 조회,사용,사용취소
string[] aIrtRsp = null;
sRet = ExecutePointIrt(sTradeDiv, m_cPayItem.PAY_WAY_CD, m_cPayItem.PAY_DTL_CD_01, sVanCD, sTrType, sPointType, sInPutType, sInPutData, sCardData, nPayAmt, sApprDate, CmUtil.MidH(sApprNo, 0, 12), sPassWord, sProductCode, "", "", sAddInfo, ref aIrtRsp, "", "");
if (sRet != UserCom.RST_OK) return sRet;
m_cPayItem.OCCUR_ENTRY_01 = sInPutData; // 카드번호
m_cPayItem.PAY_AMT = nPayAmt;
m_cPayItem.PAY_DTL_CD_02 = ""; // 캠페인코드
m_cPayItem.PAY_DTL_CD_03 = "";
m_cPayItem.PAY_DTL_CD_04 = "";
m_cPayItem.PAY_DTL_CD_05 = PosConst.PAY_DC_TYPE.PAY; // 할인적립구분 (1:결제, 2:할인)
m_cPayItem.AMT_ENTRY_01 = nPayAmt; // 사용포인트
m_cPayItem.AMT_ENTRY_02 = 0; // 제휴 할인 금액
m_cPayItem.AMT_ENTRY_03 = 0;
double nAlterPayAmt = CmUtil.DoubleParse(aIrtRsp[Column.POS_RES_POINT.SEQ.ResSavePoint].Trim());
if (sTradeDiv == PosConst.CANCEL_DIV.NORMAL)
{
m_cPayItem.AMT_ENTRY_04 = CmUtil.DoubleAdd(nAlterPayAmt, nPayAmt); // 사용전 잔액
m_cPayItem.AMT_ENTRY_05 = nAlterPayAmt; // 사용후 잔액
}
else
{
m_cPayItem.AMT_ENTRY_04 = CmUtil.DoubleSubtraction(nAlterPayAmt, nPayAmt);
m_cPayItem.AMT_ENTRY_05 = nAlterPayAmt;
}
m_cPayItem.AMT_ENTRY_06 = 0;
m_cPayItem.AMT_ENTRY_07 = 0;
m_cPayItem.AMT_ENTRY_08 = 0;
m_cPayItem.AMT_ENTRY_09 = 0;
m_cPayItem.AMT_ENTRY_10 = 0;
m_cPayItem.OCCUR_ENTRY_02 = CmUtil.MidH(aIrtRsp[Column.POS_RES_POINT.SEQ.ResAddRespon].Trim(), 0, 20); // 승인번호
m_cPayItem.OCCUR_ENTRY_03 = CmUtil.MidH(aIrtRsp[Column.POS_RES_POINT.SEQ.ResTrDate], 0, 6); // 승인일자
m_cPayItem.OCCUR_ENTRY_04 = CmUtil.MidH(aIrtRsp[Column.POS_RES_POINT.SEQ.ResTrDate], 6, 4); // 승인시간
m_cPayItem.OCCUR_ENTRY_05 = sInPutType; // 입력 구분
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 = "";
m_cPayItem.OCCUR_ENTRY_10 = ""; // 가맹점 정보
m_cPayItem.OCCUR_ENTRY_11 = CmUtil.MidH(aIrtRsp[Column.POS_RES_POINT.SEQ.ResAddRespon].Trim(), 20, 8); // 유효기간
m_cPayItem.OCCUR_ENTRY_12 = ""; // 결제 정보
m_cPayItem.OCCUR_ENTRY_13 = "";
m_cPayItem.OCCUR_ENTRY_16 = sVanCD; // VAN 구분
m_cPayItem.OCCUR_ENTRY_20 = GetPayDtlCdToPayDtlName(m_cPayItem.PAY_WAY_CD, m_cPayItem.PAY_DTL_CD_01); // 결제수단명
m_cPayItem.OCCUR_ENTRY_21 = GetPayDtlCdToCashBillYn(m_cPayItem.PAY_WAY_CD, m_cPayItem.PAY_DTL_CD_01); // 현금영수증 발행여부
//m_cPayItem.CanFiller1 = 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);
}
return sRet;
}
/// <summary>
/// 연습 데이터 설정
/// </summary>
public string SetTrainingData(string sTrType, string sPointType, string sInPutType, string sInPutData, string sCardData, double nPayAmt, string sPassWord, string sApprDate, string sApprNo)
{
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_AMT = nPayAmt;
m_cPayItem.PAY_DTL_CD_02 = ""; // 캠페인코드
m_cPayItem.PAY_DTL_CD_03 = "";
m_cPayItem.PAY_DTL_CD_04 = "";
m_cPayItem.PAY_DTL_CD_05 = "1"; // 할인적립구분 (1:결제, 2:할인)
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 = sInPutData; // 카드번호
m_cPayItem.OCCUR_ENTRY_02 = "99999999"; // 승인번호
m_cPayItem.OCCUR_ENTRY_03 = DateTime.Now.ToString("yyMMdd"); // 승인일자
m_cPayItem.OCCUR_ENTRY_04 = DateTime.Now.ToString("HHmmss"); // 승인시간
m_cPayItem.OCCUR_ENTRY_05 = sInPutType; // 입력 구분
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 = "";
m_cPayItem.OCCUR_ENTRY_10 = ""; // 가맹점 정보
m_cPayItem.OCCUR_ENTRY_12 = ""; // 알리페이 결제 정보
m_cPayItem.OCCUR_ENTRY_13 = "";
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_21 = GetPayDtlCdToCashBillYn(m_cPayItem.PAY_WAY_CD, m_cPayItem.PAY_DTL_CD_01); // 현금영수증 발행여부
//m_cPayItem.CanFiller1 = 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);
}
return sRet;
}
#endregion
}
}