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

434 lines
20 KiB
C#

using System;
using System.Collections;
using System.Linq;
using System.Text;
using Cosmos.UserFrame;
using Cosmos.ServiceProvider;
using Cosmos.Common;
using Cosmos.CommonManager;
/*-----------------------------------------------------------------------------------------------*/
// 설 명 : 코레일 마일리지
// 작 성 자 : grayber@20180208
// 변경 이력 :
/*-----------------------------------------------------------------------------------------------*/
//grayber@20180208 코레일 마일리지 입력 start - 서비스 구현 추가
namespace Cosmos.Service
{
class KorailMileage : PaymentBase, IPaymentUs
{
#region
private SManager sManager = new SManager();
private StateServer StateObject = (StateServer)StateServer.GetInstance();
private PosStatus m_cPosStatus = new PosStatus();
private TranStatus m_cTrnStatus = new TranStatus();
private IDataProcessUs m_cDataSrv = null;
private IDataCommonUs m_cDataCommon = null;
#endregion
#region
public KorailMileage()
{
m_cPosStatus = (PosStatus)StateObject.POS;
m_cTrnStatus = (TranStatus)StateObject.TRAN;
m_cDataSrv = (IDataProcessUs)sManager.InitServiceInstance(ServiceLists.ASV_DATA_PROCESS.DLL, ServiceLists.ASV_DATA_PROCESS.DATA_SERVICE);
m_cDataCommon = (IDataCommonUs)sManager.InitServiceInstance(ServiceLists.ASV_DATA_PROCESS.DLL, ServiceLists.ASV_DATA_PROCESS.DATA_COMMON);
}
#endregion
#region
/// <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;
return sRet; // grayber@20180208 수기 입력이라 막아둠
string sPosMenuKey = string.Empty, sInputType = string.Empty, sInputData = string.Empty, sCardData = string.Empty;
try
{
sPosMenuKey = aParam[0];
sInputType = aParam[1];
sInputData = aParam[2];
sCardData = aParam[3];
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 = ExecutePointIrt()
}
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
/// <summary>
/// 결제 정보 획득
/// </summary>
/// <param name="aParam"></param>
/// <returns></returns>
public object GetPayment(string[] aParam)
{
try
{
return m_cPayItem;
}
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 null;
}
#endregion
#region
/// <summary>
/// 결제 등록
/// </summary>
/// <param name="aParam"></param>
/// <returns></returns>
public string SetPayment(string[] aParam)
{
// grayber@20180208 코레일 마일리지 입력은 현 시점에서 금액을 키인으로 입력 받아 처리한다
string sRet = UserCom.RST_ERR;
string sPosMenuKey = string.Empty, sInputType = string.Empty, sInputData = string.Empty, sInEncData = string.Empty;
try
{
sPosMenuKey = aParam[0]; // 메뉴키
sInputType = aParam[1]; // 입력구분
sInputData = aParam[2]; // 입력데이터
sInEncData = aParam[3]; // 카드데이터
string sMileageAmt = aParam[4]; // 입력금액
string sPassWord = aParam[5]; // 비밀번호
string sPointType = GetMenuKeyToPointType(sPosMenuKey);
#region
if (m_cTrnStatus.Sale.RemainPayAmt == 0 && CmUtil.DoubleParse(sMileageAmt) > 0)
{
if (WinManager.QuestionMessage(POS_MESSAGE.ERROR.MSG_0516) == false) //받을 금액이 없습니다. 0원으로 결제 하시겠습니까?
{
return sRet;
}
else
{
sMileageAmt = "0";
}
}
if (sMileageAmt.Length > 10)
{
WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0035); // 입력한 금액이 너무 큰 금액 입니다.
return sRet;
}
if (CmUtil.DoubleParse(sMileageAmt) == 0 && m_cTrnStatus.Sale.RemainPayAmt > 0)
{
WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0036); // 입력한 금액은 입력 불가 단위 입니다.
return sRet;
}
if (CmUtil.AmountCut(CmUtil.DoubleParse(sMileageAmt), CmUtil.IntParse(m_cPosStatus.Mst.PayRudDwLoc)) != CmUtil.DoubleParse(sMileageAmt))
{
WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0036); // 입력한 금액은 입력 불가 단위 입니다.
return sRet;
}
#endregion
m_cPayItem = new Column.TR_PAYMENT.DATA();
double nMileageAmt = CmUtil.DoubleParse(sMileageAmt); // 받은금액
double nMileagePayAmt = nMileageAmt; // 결제금액
m_cPayItem.PAY_WAY_CD = GetMenuKeyToPayWayCd(sPosMenuKey); // 결제 그룹 코드
m_cPayItem.PAY_AMT = nMileageAmt; // 결제 금액
m_cPayItem.PAY_DTL_CD_01 = GetMenuKeyToPayDtlCd(sPosMenuKey); // 결제 세부코드
m_cPayItem.PAY_DTL_CD_05 = PosConst.PAY_DC_TYPE.PAY; // 할인 결제 구분
//sRet = ExecutePointIrt()
sRet = SetTrainingData(PosConst.POS_VAN_MASTER.TRADE_ID.VAN_POT_USE_A, sPointType, sInputType, sInputData, sInEncData, nMileagePayAmt, nMileageAmt, sPassWord, "", "", "");
//// 받은금액이 받을금액 보다 큰경우 거스름돈 설정 처리
//if (nCashRecvAmt > m_cTrnStatus.Sale.RemainPayAmt)
//{
// nCashPayAmt = m_cTrnStatus.Sale.RemainPayAmt;
// nChangeAmt = CmUtil.DoubleSubtraction(nCashRecvAmt, m_cTrnStatus.Sale.RemainPayAmt);
//}
// 금액항목
m_cPayItem.AMT_ENTRY_01 = m_cPayItem.PAY_AMT; // 입력 받은 값
m_cPayItem.AMT_ENTRY_03 = 0; // 총 포인트
m_cPayItem.AMT_ENTRY_04 = 0; // 가용 포인트
m_cPayItem.AMT_ENTRY_05 = 0; // 잔여 포인트
// 발생항목
m_cPayItem.OCCUR_ENTRY_01 = string.Empty; // 카드번호
m_cPayItem.OCCUR_ENTRY_02 = string.Empty; // 승인번호
m_cPayItem.OCCUR_ENTRY_08 = ItemConst.PAY_APP_DIV.NORMAL; // 승인구분 ( 0:정상, 1:임의등록, 2:CAT 단말기, 7:XCharge, 8:전화취소, 9:단말기)
// 빌분리 번호
//m_cPayItem.BILLSPR_NO = m_cTrnStatus.Sale.BillSplitNo;
// 결제 아이템 추가
var aPayItem = (ArrayList)StateObject.GetItemObject(Column.TR_PAYMENT.ITEM);
m_cPayItem.SEQ = aPayItem.Count + 1;
m_cPayItem.CANCEL_DIV = PosConst.CANCEL_DIV.NORMAL;
aPayItem.Add(m_cPayItem);
//var alEtcItem = (ArrayList)StateObject.GetItemObject(Column.TR_ETC.ITEM);
// 결제 금액 재 계산 처리
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);
//////////////////////////////////////////////////////////////////////////////////
}
return sRet;
}
#endregion
#region
/// <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);
var cPayItem = (Column.TR_PAYMENT.DATA)alPayItem[nPayRow];
sInputType = m_cPayItem.OCCUR_ENTRY_05; // 입력구분
sInputData = m_cPayItem.OCCUR_ENTRY_01; // 입력데이터
sInEncData = m_cPayItem.CanFiller1; // 카드데이터
m_cPayItem.OCCUR_ENTRY_06 = m_cPayItem.OCCUR_ENTRY_02; // 원승인번호 설정
m_cPayItem.OCCUR_ENTRY_07 = m_cPayItem.OCCUR_ENTRY_03; // 원승인일자 설정
m_cPayItem.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);
}
finally
{
//여전법 대응!
//////////////////////////////////////////////////////////////////////////////////
CmUtil.ZeroFillClear(ref sInputData);
CmUtil.ZeroFillClear(ref sInEncData);
CmUtil.ZeroFillClear(ref aParam);
//////////////////////////////////////////////////////////////////////////////////
}
return sRet;
}
#endregion
#region
/// <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]); // 취소할 행번호
// 결제 내역 받아 오기
var 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; // 카드데이터(암호화)
//if (m_cPayItem.OCCUR_ENTRY_08.ToString().Equals(ItemConst.PAY_APP_DIV.COMPULSION) == true)
//{
m_cPayItem.OCCUR_ENTRY_06 = m_cPayItem.OCCUR_ENTRY_02; // 원승인번호
m_cPayItem.OCCUR_ENTRY_07 = m_cPayItem.OCCUR_ENTRY_03; // 원승인일자
//}
//else
//{
// double nDestAmt = m_cPayItem.AMT_ENTRY_10; // 대상금액
// double nApprAmt = m_cPayItem.PAY_AMT; // 승인금액
// string sApprDate = m_cPayItem.OCCUR_ENTRY_03; // 승인일자
// string sApprNo = m_cPayItem.OCCUR_ENTRY_02; // 승인번호
// string sPointType = GetPayDtlCdToPointType(m_cPayItem.PAY_WAY_CD, m_cPayItem.PAY_DTL_CD_01);
//}
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
public string SetMenualPayment(string[] aParam)
{
string sRet = UserCom.RST_ERR;
try
{
//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 sInEncData, double nDestAmt, double nApprAmt, string sPassWord, string sApprDate, string sApprNo, string sUniqueID)
{
string sRet = UserCom.RST_ERR;
string sVanCD = string.Empty;
try
{
// 연습모드이면 연습 데이터 설정
//sVanCD = GetPayDtlCdToVanCode(m_cPayItem.PAY_WAY_CD, m_cPayItem.PAY_DTL_CD_01); // 승인업체 코드 조회
//if (sVanCD == "")
//{
// WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0563);
// return sRet;
//}
if (sTrType == PosConst.POS_VAN_MASTER.TRADE_ID.VAN_POT_USE_A || sTrType == PosConst.POS_VAN_MASTER.TRADE_ID.VAN_POT_USE_C)
{
m_cPayItem.PAY_AMT = nApprAmt;
}
else
{
m_cPayItem.PAY_AMT = m_cDataCommon.ExecTermCoopCmpPayDc(m_cPayItem.PAY_WAY_CD, m_cPayItem.PAY_DTL_CD_01, "", nDestAmt); // 제휴사 결제 할인 금액 계산
}
//m_cPayItem.PAY_DTL_CD_03 = "0"; // 할인금액아이템적용여부 (0:미적용, 1:적용)
m_cPayItem.PAY_DTL_CD_05 = PosConst.PAY_DC_TYPE.PAY; // 할인결제구분 (1:결제, 2:할인)
if (m_cPayItem.PAY_WAY_CD == ItemConst.TR_ITEM_ID.MOBILE_COM_POINT
&& PosMstManager.GetMstPayDc(m_cPayItem.PAY_WAY_CD, m_cPayItem.PAY_DTL_CD_01, PosMst.MST_PAY_DC.DATA.PAY_DC_TYPE) == PosConst.PAY_DC_TYPE.DC)
{
//m_cPayItem.PAY_DTL_CD_03 = "1"; // 할인금액아이템적용여부 (0:미적용, 1:적용)
m_cPayItem.PAY_DTL_CD_05 = PosConst.PAY_DC_TYPE.DC; // 할인결제구분 (1:결제, 2:할인)
}
m_cPayItem.AMT_ENTRY_01 = m_cPayItem.PAY_AMT; // 사용포인트
m_cPayItem.AMT_ENTRY_03 = 0; // 총포인트
m_cPayItem.AMT_ENTRY_04 = 0; // 가용포인트(할인후결제금액)
m_cPayItem.AMT_ENTRY_05 = 0; // 잔여포인트
//m_cPayItem.AMT_ENTRY_10 = nDestAmt;
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("HHmm"); // 승인시간
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.COMPULSION; //승인구분 (강제)
m_cPayItem.OCCUR_ENTRY_16 = sVanCD; // VAN 구분
m_cPayItem.OCCUR_ENTRY_17 = sUniqueID; // UniqueID
m_cPayItem.OCCUR_ENTRY_18 = ""; // 가맹점번호
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.CANCEL_DIV = ItemConst.PAY_CANCEL_DIV.NORMAL;
m_cPayItem.BILLSPR_NO = m_cTrnStatus.Sale.BillSplitNo; // 빌분리 번호
//m_cPayItem.CanFiller1 = sInEncData;
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);
//////////////////////////////////////////////////////////////////////////////////
}
return sRet;
}
}
}
//grayber@20180208 코레일 마일리지 입력 end