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

818 lines
46 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 PointHappyPointSave_China : PaymentBase, IPaymentUs
{
protected Column.TR_ETC.DATA m_cEtcItem = null;
public PointHappyPointSave_China()
{
}
#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 = "", sWcc = "", siNqType = "", sCardData = "", sTranType = "";
double nPayAmt = 0;
try
{
sPosMenuKey = aParam[0]; // 메뉴키
sWcc = aParam[1]; // 카드번호
sCardData = aParam[2]; // 입력구분
nPayAmt = CmUtil.DoubleParse(aParam[3]); // 금액
m_cEtcItem = new Column.TR_ETC.DATA(); // 결과 저장 변수 생성
m_cEtcItem.ETC_WAY_CD = GetMenuKeyToPayWayCd(sPosMenuKey);
m_cEtcItem.ETC_DTL_CD_01 = GetMenuKeyToPayDtlCd(sPosMenuKey);
// 해피포인트 적립카드로 조회된 내역이 있는지 체크
ArrayList alEtcItem = (ArrayList)StateObject.GetItemObject(Column.TR_ETC.ITEM); // 기타 내역 받아 오기
foreach (Column.TR_ETC.DATA cEtcItem in alEtcItem)
{
if (cEtcItem.CANCEL_DIV == PosConst.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.POINT_SAVE_CHINA)
{
if (cEtcItem.CanFiller1 == sCardData)
{
m_cEtcItem.AMT_ENTRY_03 = cEtcItem.AMT_ENTRY_03; // 총포인트
m_cEtcItem.AMT_ENTRY_04 = cEtcItem.AMT_ENTRY_04; // 가용포인트
m_cEtcItem.AMT_ENTRY_05 = cEtcItem.AMT_ENTRY_05; // 잔여포인트
//m_cEtcItem.HP_ADD_INFO_SCH = cEtcItem.HP_ADD_INFO_SCH; // 추가응답정보
//m_cEtcItem.HP_RESERVED = cEtcItem.HP_RESERVED; // 예약필드
//m_cEtcItem.HP_CAMPAIGN_INFO = cEtcItem.HP_CAMPAIGN_INFO; // 캠페인정보
//m_cEtcItem.HP_EXT_POINT = cEtcItem.HP_EXT_POINT; // 소멸예정포인트
return UserCom.RST_OK;
}
}
}
siNqType = PosConst.POS_POINT_INQ_TYPE_CHINA.SEARCH;
if (sPosMenuKey == PosKey.MENU_KEY.HAPPY_POINT_USE_CHINA)
// 포인트 사용 조회
sTranType = PosConst.POS_POINT_TRAN_TYPE_CHINA.SEARCH_POINT;
else if (sPosMenuKey == PosKey.MENU_KEY.HAPPY_POINT_SAVE_CHINA)
// 포인트 적립 조회
sTranType = PosConst.POS_POINT_TRAN_TYPE_CHINA.SEARCH_POINT;
else if (sPosMenuKey == PosKey.MENU_KEY.PREPAID_CARDS_HPJOY)
// 선불 조회
sTranType = PosConst.POS_POINT_TRAN_TYPE_CHINA.SEARCH_PP;
sRet = ExecuteHappyPointUseIrt(PosConst.CANCEL_DIV.NORMAL, siNqType, sTranType, sWcc, sCardData, nPayAmt, "", "" );
if (sRet != UserCom.RST_OK) return sRet;
}
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);
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>
/// 결제 등록(제휴 포인트 사용)
/// </summary>
/// <param name="aParam"></param>
/// <returns></returns>
public string SetPayment(string[] aParam)
{
string sRet = UserCom.RST_ERR;
string sPosMenuKey = "", sWcc = "", siNqType = "", sCardData = "", sTranType = "";
double nPayAmt = 0;
string sHappyPointSave = "";
try
{
sPosMenuKey = aParam[0]; // 메뉴키
sWcc = aParam[1]; // 입력구분
sCardData = aParam[2]; // 카드번호
nPayAmt = CmUtil.DoubleParse(aParam[3]); // 금액
sHappyPointSave = aParam[4]; // 0:등록, 1:적립
//m_cEtcItem = new Column.TR_ETC.DATA(); // 결과 저장 변수 생성
ArrayList alEtcItem = (ArrayList)StateObject.GetItemObject(Column.TR_ETC.ITEM); // 기타 내역 받아 오기
m_cEtcItem.ETC_WAY_CD = GetMenuKeyToPayWayCd(sPosMenuKey);
m_cEtcItem.ETC_DTL_CD_01 = GetMenuKeyToPayDtlCd(sPosMenuKey);
bool bExist = false;
if (sPosMenuKey == PosKey.MENU_KEY.HAPPY_POINT_USE_CHINA)
{
// 포인트 사용
siNqType = PosConst.POS_POINT_INQ_TYPE_CHINA.USE;
sTranType = PosConst.POS_POINT_TRAN_TYPE_CHINA.USE_POINT_APPROVAL;
}
else if (sPosMenuKey == PosKey.MENU_KEY.HAPPY_POINT_SAVE_CHINA)
{
// 포인트 적립
siNqType = PosConst.POS_POINT_INQ_TYPE_CHINA.SAVE;
sTranType = PosConst.POS_POINT_TRAN_TYPE_CHINA.SAVE_POINT_APPROVAL;
// 해피포인트 카드 기등록 여부 체크
foreach (Column.TR_ETC.DATA cEtcItem in alEtcItem)
{
if (cEtcItem.CANCEL_DIV == PosConst.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.POINT_SAVE_CHINA)
{
if (sHappyPointSave == "1")
{
bExist = true;
m_cEtcItem = cEtcItem;
break;
}
else
{
return UserCom.RST_OK;
}
}
}
if (sHappyPointSave != "1")
{
// 결제할인 마스터의 결제할인 중복 가능 여부 체크
if (m_cDataCommon.PayDcDuplicationCheck(ItemConst.TR_ITEM_ID.ETC_INFO_ITEM, ItemConst.TR_ITEM_ID.ETC_INFO.POINT_SAVE_CHINA, false) == false) return sRet;
}
}
else if (sPosMenuKey == PosKey.MENU_KEY.PREPAID_CARDS_HPJOY)
{
// 선불 조회
siNqType = PosConst.POS_POINT_INQ_TYPE_CHINA.USE;
sTranType = PosConst.POS_POINT_TRAN_TYPE_CHINA.USE_PP_APPROVAL;
}
if (sHappyPointSave == "1")
{
// 적립
sRet = ExecuteHappyPointUseIrt(PosConst.CANCEL_DIV.NORMAL, siNqType, sTranType, sWcc, sCardData, nPayAmt, "", "");
if (sRet != UserCom.RST_OK) return sRet;
}
if (bExist == false || sHappyPointSave != "1")
{
// 결제 아이템 추가
m_cEtcItem.SEQ = alEtcItem.Count + 1;
alEtcItem.Add(m_cEtcItem);
}
if (m_cTrnStatus.Sale.RemainPayAmt > 0)
{
// 캠페인(해피포인트 할인) 처리(키값(취소시사용), 카드번호, 고객구분(앱여부))
m_cEtcItem.AMT_ENTRY_02 = m_cCampaingMain.ExecuteCampaignPluHappyPoint(PosConst.CAMPAIGN_PAY_KEY.HP_DIS, false, PosConst.SALE_PLU_INPUT_TYPE.FREEGIFT_HP,
sCardData, m_cEtcItem.OCCUR_ENTRY_12, m_cEtcItem.OCCUR_ENTRY_10); // 해피포인트 캠페인 계산
if (m_cEtcItem.AMT_ENTRY_02 > m_cTrnStatus.Sale.RemainPayAmt)
{
//if (m_bErrMsgShow == true) WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0391);
m_cEtcItem.AMT_ENTRY_02 = 0;
// 캠페인(해피포인트 할인) 취소 처리
m_cCampaingMain.ExecuteCampaignPluHappyPoint("", false, "", "", "", ""); // 상품 캠페인 계산
}
}
m_cEtcItem.HP_CUST_NAME = CmUtil.MidH(sCardData, 0, 6);
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 sCardData);
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 sWcc = "", siNqType = "", sCardData = "", sTranType = "";
string sPAY_WAY_CD = "";
string sPAY_DTL_CD_01 = "";
double nPayAmt = 0;
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_ETC.ITEM);
m_cEtcItem = (Column.TR_ETC.DATA)alPayItem[nPayRow];
sPAY_WAY_CD = m_cEtcItem.ETC_WAY_CD;
sPAY_DTL_CD_01 = m_cEtcItem.ETC_DTL_CD_01;
sWcc = m_cEtcItem.OCCUR_ENTRY_05; // 카드번호
sCardData = m_cEtcItem.OCCUR_ENTRY_01; // 입력구분
nPayAmt = m_cEtcItem.ETC_AMT; // 금액
string sApprDate = m_cEtcItem.OCCUR_ENTRY_03; // 승인일자
string sApprNo = m_cEtcItem.OCCUR_ENTRY_02; // 승인번호
if (sPAY_WAY_CD == ItemConst.TR_ITEM_ID.POINT_ITEM)
{
// 포인트 사용
siNqType = PosConst.POS_POINT_INQ_TYPE_CHINA.USE;
sTranType = PosConst.POS_POINT_TRAN_TYPE_CHINA.USE_POINT_REFUND;
}
else if (sPAY_WAY_CD == ItemConst.TR_ITEM_ID.ETC_INFO_ITEM)
{
// 포인트 적립
nPayAmt = m_cEtcItem.AMT_ENTRY_08;
siNqType = PosConst.POS_POINT_INQ_TYPE_CHINA.SAVE;
sTranType = PosConst.POS_POINT_TRAN_TYPE_CHINA.SAVE_POINT_REFUND;
// 캠페인(해피포인트 할인) 취소 처리
m_cCampaingMain.ExecuteCampaignPluHappyPoint("", false, "", "", "", ""); // 상품 캠페인 계산
}
else if (sPAY_WAY_CD == ItemConst.TR_ITEM_ID.PPCARD_ITEM)
{
// 선불
siNqType = PosConst.POS_POINT_INQ_TYPE_CHINA.USE;
sTranType = PosConst.POS_POINT_TRAN_TYPE_CHINA.USE_PP_REFUND;
}
//sRet = ExecuteHappyPointUseIrt(PosConst.CANCEL_DIV.CANCEL, siNqType, sTranType, sWcc, sCardData, nPayAmt, sApprDate, sApprNo);
//if (sRet != UserCom.RST_OK)
//{
// return sRet;
// //if (siNqType == PosConst.POS_POINT_INQ_TYPE_CHINA.SAVE && sTranType == PosConst.POS_POINT_TRAN_TYPE_CHINA.SAVE_POINT_REFUND)
// // sTranType = PosConst.POS_POINT_TRAN_TYPE_CHINA.SAVE_POINT_NETREFUND;
// //else if (siNqType == PosConst.POS_POINT_INQ_TYPE_CHINA.SAVE && sTranType == PosConst.POS_POINT_TRAN_TYPE_CHINA.SAVE_PP_REFUND)
// // sTranType = PosConst.POS_POINT_TRAN_TYPE_CHINA.SAVE_PP_NETREFUND;
// //else if (siNqType == PosConst.POS_POINT_INQ_TYPE_CHINA.USE && sTranType == PosConst.POS_POINT_TRAN_TYPE_CHINA.USE_POINT_REFUND)
// // sTranType = PosConst.POS_POINT_TRAN_TYPE_CHINA.USE_POINT_NETREFUND;
// //else if (siNqType == PosConst.POS_POINT_INQ_TYPE_CHINA.USE && sTranType == PosConst.POS_POINT_TRAN_TYPE_CHINA.USE_PP_REFUND)
// // sTranType = PosConst.POS_POINT_TRAN_TYPE_CHINA.USE_PP_NETREFUND;
// //sRet = ExecuteHappyPointUseIrt(PosConst.CANCEL_DIV.CANCEL, siNqType, sTranType, sWcc, sCardData, nPayAmt, sApprDate, sApprNo);
// //if (sRet != UserCom.RST_OK) return sRet;
//}
m_cEtcItem.CANCEL_DIV = PosConst.CANCEL_DIV.CANCEL;
ICampaignUs cCampaingMain = (ICampaignUs)sManager.InitServiceInstance(ServiceLists.ASV_CAMPAIGN.DLL, ServiceLists.ASV_CAMPAIGN.CAMPAIGN_MAIN);
// 캠페인 취소 처리
cCampaingMain.CancelCampaignPayment(aParam[0], "");
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 sCardData);
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 sWcc = "", siNqType = "", sCardData = "", sTranType = "";
double nPayAmt = 0;
string sPAY_WAY_CD = "";
string sPAY_DTL_CD_01 = "";
try
{
int nPayRow = CmUtil.IntParse(aParam[0]); // 취소할 행번호
// 결제 내역 받아 오기
ArrayList alPayItem = (ArrayList)StateObject.GetItemObject(Column.TR_ETC.ITEM);
m_cEtcItem = (Column.TR_ETC.DATA)alPayItem[nPayRow];
sPAY_WAY_CD = m_cEtcItem.ETC_WAY_CD;
sPAY_DTL_CD_01 = m_cEtcItem.ETC_DTL_CD_01;
sWcc = m_cEtcItem.OCCUR_ENTRY_05; // 카드번호
sCardData = m_cEtcItem.OCCUR_ENTRY_01; // 입력구분
nPayAmt = m_cEtcItem.ETC_AMT; // 금액
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
{
string sApprDate = m_cEtcItem.OCCUR_ENTRY_03; // 승인일자
string sApprNo = m_cEtcItem.OCCUR_ENTRY_02; // 승인번호
if (sPAY_WAY_CD == ItemConst.TR_ITEM_ID.POINT_ITEM)
{
// 포인트 사용
siNqType = PosConst.POS_POINT_INQ_TYPE_CHINA.USE;
sTranType = PosConst.POS_POINT_TRAN_TYPE_CHINA.USE_POINT_REFUND;
}
else if (sPAY_WAY_CD == ItemConst.TR_ITEM_ID.ETC_INFO_ITEM)
{
// 포인트 적립
nPayAmt = m_cEtcItem.AMT_ENTRY_08;
siNqType = PosConst.POS_POINT_INQ_TYPE_CHINA.SAVE;
sTranType = PosConst.POS_POINT_TRAN_TYPE_CHINA.SAVE_POINT_REFUND;
}
else if (sPAY_WAY_CD == ItemConst.TR_ITEM_ID.PPCARD_ITEM)
{
// 선불
siNqType = PosConst.POS_POINT_INQ_TYPE_CHINA.USE;
sTranType = PosConst.POS_POINT_TRAN_TYPE_CHINA.USE_PP_REFUND;
}
//Rhee, #2017/09/09 중국 프린트 해피포인트 차감 오류 Start
// 기존
//sRet = ExecuteHappyPointUseIrt(PosConst.CANCEL_DIV.CANCEL, siNqType, sTranType, sWcc, sCardData, nPayAmt, sApprDate, sApprNo);
// 변경
/// ExecuteHappyPointUseIrt함수내에 PosConst.CANCEL_DIV.CANCEL 처리 루틴없음
/// 현재, 적립과 차감 루틴이 같아 동일 처리함( 이 후 변경시 별도 루틴 필요 )
sRet = ExecuteHappyPointUseIrt(PosConst.CANCEL_DIV.NORMAL, siNqType, sTranType, sWcc, sCardData, nPayAmt, sApprDate, sApprNo);
//Rhee, #2017/09/09 중국 프린트 해피포인트 차감 오류 End
if (sRet != UserCom.RST_OK)
{
if (siNqType == PosConst.POS_POINT_INQ_TYPE_CHINA.SAVE && sTranType == PosConst.POS_POINT_TRAN_TYPE_CHINA.SAVE_POINT_REFUND)
sTranType = PosConst.POS_POINT_TRAN_TYPE_CHINA.SAVE_POINT_NETREFUND;
else if (siNqType == PosConst.POS_POINT_INQ_TYPE_CHINA.SAVE && sTranType == PosConst.POS_POINT_TRAN_TYPE_CHINA.SAVE_PP_REFUND)
sTranType = PosConst.POS_POINT_TRAN_TYPE_CHINA.SAVE_PP_NETREFUND;
else if (siNqType == PosConst.POS_POINT_INQ_TYPE_CHINA.USE && sTranType == PosConst.POS_POINT_TRAN_TYPE_CHINA.USE_POINT_REFUND)
sTranType = PosConst.POS_POINT_TRAN_TYPE_CHINA.USE_POINT_NETREFUND;
else if (siNqType == PosConst.POS_POINT_INQ_TYPE_CHINA.USE && sTranType == PosConst.POS_POINT_TRAN_TYPE_CHINA.USE_PP_REFUND)
sTranType = PosConst.POS_POINT_TRAN_TYPE_CHINA.USE_PP_NETREFUND;
sRet = ExecuteHappyPointUseIrt(PosConst.CANCEL_DIV.CANCEL, siNqType, sTranType, sWcc, sCardData, nPayAmt, sApprDate, sApprNo);
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);
}
finally
{
//여전법 대응!
//////////////////////////////////////////////////////////////////////////////////
CmUtil.ZeroFillClear(ref sCardData);
CmUtil.ZeroFillClear(ref aParam);
//////////////////////////////////////////////////////////////////////////////////
}
return sRet;
}
#endregion
#region SetMenualPayment
public string SetMenualPayment(string[] aParam)
{
throw new NotImplementedException();
}
#endregion
#region ,
/// <summary>
/// 해피포인트 조회,사용
/// </summary>
public string ExecuteHappyPointUseIrt(string sTradeDiv, string siNqType, string sTranType, string sWcc, string sCardData, double nPayAmt, string sApprDate, string sApprNo)
{
string sRet = UserCom.RST_ERR;
try
{
// 연습모드이면 연습 데이터 설정
if (m_cPosStatus.Base.TrainingFlag == "1" || m_cPosStatus.Mst.TestStorYn == "1") return SetTrainingData(sTradeDiv, siNqType, sTranType, sWcc, sCardData, nPayAmt, sApprDate, sApprNo);
string sVanCD = GetPayDtlCdToVanCode(m_cEtcItem.ETC_WAY_CD, m_cEtcItem.ETC_DTL_CD_01); // 승인업체 코드 조회
if (sVanCD == "")
{
WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0563);
return sRet;
}
// 포인트 조회,사용,사용취소
string[] aIrtRsp = null;
string[] aIrtHdrRsp = null;
sRet = ExecuteIrt(sTradeDiv, m_cEtcItem.ETC_WAY_CD, m_cEtcItem.ETC_DTL_CD_01, siNqType, sTranType, sWcc, sCardData, nPayAmt, sApprDate, sApprNo, ref aIrtHdrRsp, ref aIrtRsp);
if (sRet != UserCom.RST_OK) return sRet;
if (sTradeDiv == PosConst.CANCEL_DIV.NORMAL)
{
m_cEtcItem.ETC_DTL_CD_03 = "0"; // 할인금액 아이템 적용여부(0:미적용, 1:적용)
m_cEtcItem.ETC_DTL_CD_05 = PosConst.PAY_DC_TYPE.DC; // 할인결제구분 (1:결제, 2:할인)
m_cEtcItem.AMT_ENTRY_02 = 0;
if (siNqType == PosConst.POS_POINT_INQ_TYPE_CHINA.SEARCH)
{
// 포인트 소숫점 처리(2017.06.26)
m_cEtcItem.AMT_ENTRY_04 = CmUtil.DoubleParse(aIrtRsp[Column.POS_REQ_SEL_POINT_CHINA.SEQ.SaleAmt1] + "." + aIrtRsp[Column.POS_REQ_POINT_CHINA.SEQ.SaleAmt2]); // 가용포인트
//m_cEtcItem.AMT_ENTRY_04 = CmUtil.DoubleParse(aIrtRsp[Column.POS_REQ_SEL_POINT_CHINA.SEQ.SaleAmt1]); // 가용포인트
}
else
{
if (siNqType == PosConst.POS_POINT_INQ_TYPE_CHINA.SAVE)
{
m_cEtcItem.ETC_AMT = CmUtil.DoubleParse(aIrtRsp[Column.POS_REQ_POINT_CHINA.SEQ.SaleAmt1] + "." + aIrtRsp[Column.POS_REQ_POINT_CHINA.SEQ.SaleAmt2]);
m_cEtcItem.AMT_ENTRY_08 = nPayAmt;
}
else
{
m_cEtcItem.ETC_AMT = nPayAmt;
}
m_cEtcItem.AMT_ENTRY_01 = m_cEtcItem.ETC_AMT;
// 거래후잔액
m_cEtcItem.AMT_ENTRY_03 = CmUtil.DoubleParse(aIrtRsp[Column.POS_REQ_POINT_CHINA.SEQ.BalanceAmt1] + "." + aIrtRsp[Column.POS_REQ_POINT_CHINA.SEQ.BalanceAmt2]);
m_cEtcItem.AMT_ENTRY_05 = m_cEtcItem.AMT_ENTRY_03;
m_cEtcItem.OCCUR_ENTRY_02 = aIrtRsp[Column.POS_REQ_POINT_CHINA.SEQ.ApprNo].Trim(); // 승인번호
m_cEtcItem.OCCUR_ENTRY_17 = aIrtHdrRsp[Column.POS_POINT_HEADER_CHINA.SEQ.UniqueID].Trim(); // 거래고유번호
}
m_cEtcItem.OCCUR_ENTRY_01 = sCardData; // 카드번호
m_cEtcItem.OCCUR_ENTRY_03 = DateTime.Now.ToString("yyMMdd"); // 승인일자
m_cEtcItem.OCCUR_ENTRY_04 = DateTime.Now.ToString("HHmmss"); // 승인시간
m_cEtcItem.OCCUR_ENTRY_05 = sWcc; // 입력 구분
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_16 = sVanCD; // VAN 구분
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 = "";
m_cEtcItem.HP_RESERVED = ""; // 예약필드
m_cEtcItem.HP_CAMPAIGN_INFO = ""; // 캠페인정보
}
else
{
m_cEtcItem.OCCUR_ENTRY_01 = sCardData; // 카드번호
m_cEtcItem.OCCUR_ENTRY_03 = DateTime.Now.ToString("yyMMdd"); // 승인일자
m_cEtcItem.OCCUR_ENTRY_04 = DateTime.Now.ToString("HHmmss"); // 승인시간
m_cEtcItem.OCCUR_ENTRY_05 = sWcc; // 입력 구분
m_cEtcItem.OCCUR_ENTRY_06 = sApprNo; // 원승인번호
m_cEtcItem.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 sCardData);
CmUtil.ZeroFillClear(ref sCardData);
//////////////////////////////////////////////////////////////////////////////////
}
return sRet;
}
/// <summary>
/// 연습 데이터 설정
/// </summary>
public string SetTrainingData(string sTradeDiv, string siNqType, string sTranType, string sWcc, string sCardData, double nPayAmt, string sApprDate, string sApprNo)
{
string sRet = UserCom.RST_ERR;
try
{
// 연습모드이면 연습 데이터 설정
string sVanCD = GetPayDtlCdToVanCode(m_cEtcItem.ETC_WAY_CD, m_cEtcItem.ETC_DTL_CD_01); // 승인업체 코드 조회
if (sVanCD == "")
{
WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0563);
return sRet;
}
m_cEtcItem.ETC_AMT = nPayAmt;
m_cEtcItem.ETC_DTL_CD_03 = "0"; // 할인금액 아이템 적용여부(0:미적용, 1:적용)
m_cEtcItem.ETC_DTL_CD_05 = PosConst.PAY_DC_TYPE.DC; // 할인결제구분 (1:결제, 2:할인)
m_cEtcItem.AMT_ENTRY_01 = m_cEtcItem.ETC_AMT; // 사용포인트
m_cEtcItem.AMT_ENTRY_03 = 99990; // 총포인트
m_cEtcItem.AMT_ENTRY_04 = 99990; // 가용포인트
m_cEtcItem.AMT_ENTRY_05 = 99990; // 잔여포인트
m_cEtcItem.OCCUR_ENTRY_01 = sCardData; // 카드번호
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 = sWcc; // 입력 구분
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_16 = sVanCD; // VAN 구분
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 = "";
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);
CmUtil.ZeroFillClear(ref sCardData);
//////////////////////////////////////////////////////////////////////////////////
}
return sRet;
}
#endregion
#region
/// <summary>
/// 포인트 조회 실행
/// </summary>
private string ExecuteIrt(string sTradeDiv, string sPAY_WAY_CD, string sPAY_DTL_CD_01, string siNqType, string sTranType, string sWcc, string sCardData, double nPayAmt, string sApprDate, string sApprNo, ref string[] aIrtHdrRsp, ref string[] aIrtRsp)
{
string sSendData = "", sRecvData = "";
int nNowPos = 0;
string sRet = UserCom.RST_ERR;
string sServerIP = "";
string sServerPort = "";
int iRecvTimeOut = 10000;
try
{
// VAN 정보 조회
if (m_cEtcItem.OCCUR_ENTRY_16.Trim().Length != 0)
{
// VAN_ID가 있는 경우 VAN_ID로 VAN 정보 조회
sServerIP = PosMstManager.GetMstVan(m_cEtcItem.OCCUR_ENTRY_16.Trim(), PosMst.MST_VAN.DATA.IP);
sServerPort = PosMstManager.GetMstVan(m_cEtcItem.OCCUR_ENTRY_16.Trim(), PosMst.MST_VAN.DATA.PORT);
}
else
{
// VAN_ID가 미정인 경우 결제수단으로 VAN 정보 조회
sServerIP = PosMstManager.GetMstVan(m_cEtcItem.ETC_WAY_CD, m_cEtcItem.ETC_DTL_CD_01, PosMst.MST_VAN.DATA.IP);
sServerPort = PosMstManager.GetMstVan(m_cEtcItem.ETC_WAY_CD, m_cEtcItem.ETC_DTL_CD_01, PosMst.MST_VAN.DATA.PORT);
}
if (sServerIP.Trim() == "")
{
WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0565);
return sRet;
}
// 포인트 전문 생성
sSendData = MakePoint(siNqType, sTranType, sWcc, sCardData, nPayAmt, sApprDate, sApprNo);
// 요청 - 승인로그 저장 (판매구분, [0]결제수단, [1]결제상세코드, [2]전문구분, [3]요청구분, [4]카드번호, [5]결제금액, [6]승인번호, [7]승인일자, [8]승인시간, [9]응답상태값, [10]응답메시지, [11]전문)
m_cDataCommon.SetSaleApprLog(sTradeDiv, new string[] { sPAY_WAY_CD, sPAY_DTL_CD_01, siNqType, "S", sCardData, nPayAmt.ToString(), "", "", "", "", "", sSendData });
// 전문 송수신
sRet = m_cDataCommon.ExecuteLenIrt(sServerIP, CmUtil.IntParse(sServerPort), iRecvTimeOut, sSendData, ref sRecvData, 4, 0);
if (sRet != UserCom.RST_OK)
{
WinManager.ErrorMessage(sRet);
return sRet;
}
byte[] bytes = Encoding.Default.GetBytes(sRecvData);
aIrtHdrRsp = new string[Column.POS_POINT_HEADER_CHINA.LEN.Length];
ItemColumn.ParseMessage(Column.POS_POINT_HEADER_CHINA.LEN, Column.POS_POINT_HEADER_CHINA.TYPE, bytes, ref nNowPos, ref aIrtHdrRsp);
if (siNqType == PosConst.POS_POINT_INQ_TYPE_CHINA.SEARCH)
{
aIrtRsp = new string[Column.POS_REQ_SEL_POINT_CHINA.LEN.Length];
ItemColumn.ParseMessage(Column.POS_REQ_SEL_POINT_CHINA.LEN, Column.POS_REQ_SEL_POINT_CHINA.TYPE, bytes, ref nNowPos, ref aIrtRsp);
// 응답 - 승인로그 저장 (판매구분, [0]결제수단, [1]결제상세코드, [2]전문구분, [3]요청구분, [4]카드번호, [5]결제금액, [6]승인번호, [7]승인일자, [8]승인시간, [9]응답상태값, [10]응답메시지, [11]전문)
m_cDataCommon.SetSaleApprLog(sTradeDiv, new string[] { sPAY_WAY_CD, sPAY_DTL_CD_01, siNqType, "R"
, sCardData, CmUtil.DoubleParse(aIrtRsp[Column.POS_REQ_SEL_POINT_CHINA.SEQ.SaleAmt1]).ToString()
, aIrtRsp[Column.POS_REQ_SEL_POINT_CHINA.SEQ.ApprNo].Trim(), CmUtil.MidH(aIrtHdrRsp[Column.POS_POINT_HEADER_CHINA.SEQ.SaleDate], 0, 6), CmUtil.MidH(aIrtHdrRsp[Column.POS_POINT_HEADER_CHINA.SEQ.SaleTime], 6, 4)
, aIrtHdrRsp[Column.POS_POINT_HEADER_CHINA.SEQ.ResCD].Trim()
, aIrtRsp[Column.POS_REQ_SEL_POINT_CHINA.SEQ.Message1].Trim() + aIrtRsp[Column.POS_REQ_SEL_POINT_CHINA.SEQ.Message2].Trim()
, sRecvData });
// - '0000O' : 승인 '그외' : 거절
if (aIrtHdrRsp[Column.POS_POINT_HEADER_CHINA.SEQ.ResCD] != "00000")
{
if (aIrtRsp[Column.POS_REQ_SEL_POINT_CHINA.SEQ.Message1] == "" && aIrtRsp[Column.POS_REQ_SEL_POINT_CHINA.SEQ.Message2].Trim() == "")
sRet = MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0158) + "[" + aIrtHdrRsp[Column.POS_POINT_HEADER_CHINA.SEQ.ResCD] + "]";
else
sRet = aIrtRsp[Column.POS_REQ_SEL_POINT_CHINA.SEQ.Message1].Trim() + "\n" + aIrtRsp[Column.POS_REQ_SEL_POINT_CHINA.SEQ.Message2].Trim();
if (m_bErrMsgShow == true) WinManager.ErrorMessage(sRet);
return sRet;
}
}
else
{
aIrtRsp = new string[Column.POS_REQ_POINT_CHINA.LEN.Length];
ItemColumn.ParseMessage(Column.POS_REQ_POINT_CHINA.LEN, Column.POS_REQ_POINT_CHINA.TYPE, bytes, ref nNowPos, ref aIrtRsp);
// 응답 - 승인로그 저장 (판매구분, [0]결제수단, [1]결제상세코드, [2]전문구분, [3]요청구분, [4]카드번호, [5]결제금액, [6]승인번호, [7]승인일자, [8]승인시간, [9]응답상태값, [10]응답메시지, [11]전문)
m_cDataCommon.SetSaleApprLog(sTradeDiv, new string[] { sPAY_WAY_CD, sPAY_DTL_CD_01, siNqType, "R"
, sCardData, CmUtil.DoubleParse(aIrtRsp[Column.POS_REQ_POINT_CHINA.SEQ.SaleAmt1]).ToString()
, aIrtRsp[Column.POS_REQ_POINT_CHINA.SEQ.ApprNo].Trim(), CmUtil.MidH(aIrtHdrRsp[Column.POS_POINT_HEADER_CHINA.SEQ.SaleDate], 0, 6), CmUtil.MidH(aIrtHdrRsp[Column.POS_POINT_HEADER_CHINA.SEQ.SaleTime], 6, 4)
, aIrtHdrRsp[Column.POS_POINT_HEADER_CHINA.SEQ.ResCD].Trim()
, aIrtRsp[Column.POS_REQ_POINT_CHINA.SEQ.Message1].Trim() + aIrtRsp[Column.POS_REQ_POINT_CHINA.SEQ.Message2].Trim()
, sRecvData });
// - '0000O' : 승인 '그외' : 거절
if (aIrtHdrRsp[Column.POS_POINT_HEADER_CHINA.SEQ.ResCD] != "00000")
{
if (aIrtRsp[Column.POS_REQ_SEL_POINT_CHINA.SEQ.Message1] == "" && aIrtRsp[Column.POS_REQ_SEL_POINT_CHINA.SEQ.Message2].Trim() == "")
sRet = MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0158) + "[" + aIrtHdrRsp[Column.POS_POINT_HEADER_CHINA.SEQ.ResCD] + "]";
else
sRet = aIrtRsp[Column.POS_REQ_POINT_CHINA.SEQ.Message1].Trim() + "\n" + aIrtRsp[Column.POS_REQ_POINT_CHINA.SEQ.Message2].Trim();
if (m_bErrMsgShow == true) 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);
}
return sRet;
}
#endregion
#region
/// <summary>
/// 포인트 요청 전문 생성
/// </summary>
/// <param name="sPointType"></param>
/// <param name="sInPutType"></param>
/// <param name="sCardData"></param>
/// <param name="nPayAmt"></param>
/// <param name="sApprDate"></param>
/// <param name="sApprNo"></param>
/// <returns></returns>
private string MakePoint(string siNqType, string sTranType, string sWcc, string sCardData, double nPayAmt, string sApprDate, string sApprNo)
{
string sSendData = string.Empty;
string sSendBodyData = string.Empty;
int nDataLen = 0;
try
{
// 카드번호 = 이하 자름
if (sCardData.IndexOf("=") > 0) sCardData = CmUtil.MidH(sCardData, 0, sCardData.IndexOf("="));
// 가맹점 정보 획득(회사승인ID,점포승인ID)
string sApprID = PosMstManager.GetMstVan(m_cEtcItem.ETC_WAY_CD, m_cEtcItem.ETC_DTL_CD_01, PosMst.MST_VAN.DATA.APPR_ID);
if (siNqType == PosConst.POS_POINT_INQ_TYPE_CHINA.SEARCH)
{
// 조회
string[] aIrtBody = new string[Column.POS_RES_SEL_POINT_CHINA.LEN.Length];
// Body 길이
nDataLen = ItemColumn.LenMessage(Column.POS_RES_SEL_POINT_CHINA.LEN);
aIrtBody[Column.POS_RES_SEL_POINT_CHINA.SEQ.CardNo] = sCardData;
sSendBodyData = ItemColumn.MakeMessage(aIrtBody, Column.POS_RES_SEL_POINT_CHINA.LEN, Column.POS_RES_SEL_POINT_CHINA.TYPE);
}
else
{
// 사용/적립/충전
string[] aIrtBody = new string[Column.POS_RES_POINT_CHINA.LEN.Length];
// Body 길이
nDataLen = ItemColumn.LenMessage(Column.POS_RES_POINT_CHINA.LEN);
aIrtBody[Column.POS_RES_POINT_CHINA.SEQ.CardNo] = sCardData;
// 중국 해피포인트 적립 소숫점 사용(2017.06.26)
aIrtBody[Column.POS_RES_POINT_CHINA.SEQ.SaleAmt1] = ((long)nPayAmt).ToString();
aIrtBody[Column.POS_RES_POINT_CHINA.SEQ.SaleAmt2] = (CmUtil.DoubleMultiplication(CmUtil.DoubleSubtraction(nPayAmt, (long)nPayAmt), 100)).ToString();
aIrtBody[Column.POS_RES_POINT_CHINA.SEQ.OrgApprNo] = sApprNo;
aIrtBody[Column.POS_RES_POINT_CHINA.SEQ.OrgSaleDate] = sApprDate;
sSendBodyData = ItemColumn.MakeMessage(aIrtBody, Column.POS_RES_POINT_CHINA.LEN, Column.POS_RES_POINT_CHINA.TYPE);
}
// 헤더
string[] aIrtHeader = new string[Column.POS_POINT_HEADER_CHINA.LEN.Length];
// 헤더 길이
nDataLen += ItemColumn.LenMessage(Column.POS_POINT_HEADER_CHINA.LEN) - 4;
aIrtHeader[Column.POS_POINT_HEADER_CHINA.SEQ.InqLen] = nDataLen.ToString();
aIrtHeader[Column.POS_POINT_HEADER_CHINA.SEQ.InqType] = siNqType;
aIrtHeader[Column.POS_POINT_HEADER_CHINA.SEQ.TranType] = sTranType;
aIrtHeader[Column.POS_POINT_HEADER_CHINA.SEQ.TeminalID] = sApprID;
aIrtHeader[Column.POS_POINT_HEADER_CHINA.SEQ.SaleDate] = DateTime.Now.ToString("yyyyMMdd");
aIrtHeader[Column.POS_POINT_HEADER_CHINA.SEQ.SaleTime] = DateTime.Now.ToString("HHmmss");
aIrtHeader[Column.POS_POINT_HEADER_CHINA.SEQ.UniqueID] = m_cPosStatus.Base.SaleDate + m_cPosStatus.Base.PosNo + m_cPosStatus.Base.TradeNo + string.Format("{0:00000}", DateTime.Now.ToString("ssfff"));
aIrtHeader[Column.POS_POINT_HEADER_CHINA.SEQ.ResCD] = "";
aIrtHeader[Column.POS_POINT_HEADER_CHINA.SEQ.WCC] = sWcc;
aIrtHeader[Column.POS_POINT_HEADER_CHINA.SEQ.Filler] = "";
// 포인트 요청 전문 생성
sSendData = ItemColumn.MakeMessage(aIrtHeader, Column.POS_POINT_HEADER_CHINA.LEN, Column.POS_POINT_HEADER_CHINA.TYPE);
sSendData += sSendBodyData;
UserLog.WriteLogFile(UserCom.LOG_OP, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", "@@sSendData=" + sSendData);
}
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 sSendData;
}
#endregion
}
}