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

668 lines
37 KiB
C#
Raw Permalink Normal View History

2019-06-16 05:12:09 +00:00
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 OnLineCoupon : OnLineCouponBase, IPaymentUs
{
/// <summary>
///
/// </summary>
public OnLineCoupon()
{
}
#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 sInPutType = "", sInPutData = "", sTranKind = "";
try
{
sInPutType = aParam[0]; // 입력구분
sInPutData = aParam[1]; // 입력데이터(쿠폰번호)
sTranKind = aParam[2]; // 거래구분 요청구분 2 N 10 : 발행, 20 : 승인)
int nPluCount = 0; double nPluAmount = 0; // 상품라인수, 상품금액
string sPluInfo = GetSalePluInfo(ref nPluCount, ref nPluAmount); // 상품정보 생성
m_cPayItem = new Column.TR_PAYMENT.DATA();
m_cPayItem.PAY_WAY_CD = ItemConst.TR_ITEM_ID.COUPON_ITEM;
m_cPayItem.PAY_DTL_CD_01 = ItemConst.TR_ITEM_ID.COUPON.ONLINE;
// 온라인쿠폰 조회(금액설정 => 총매출, 받을금액 JIN확인(07.01.05))
sRet = ExecuteOnLineCouponIrt("", sTranKind, sInPutType, sInPutData, m_cTrnStatus.Head.TotSaleAmt, nPluCount, m_cTrnStatus.Sale.RemainPayAmt, sPluInfo, "", "");
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);
}
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 sInPutType = "", sInPutData = "";
int nSelRow = -1;
try
{
if (m_cTrnStatus.Head.TradeDiv != ItemConst.TRAN_DIV.NORMAL) return sRet;
sInPutType = aParam[0]; // 입력구분
sInPutData = aParam[1]; // 입력데이터(쿠폰번호)
ArrayList alTrPluItem = (ArrayList)StateObject.GetItemObject(Column.TR_PLU.ITEM); // 상품 아이템
ArrayList alTrPayItem = (ArrayList)StateObject.GetItemObject(Column.TR_PAYMENT.ITEM); // 결제
string sCouponKind = CmUtil.MidH(sInPutData, 8, 1); // 쿠폰종류 1:교환권, 2:증정권, 3:금액권, 4:할인권, 5:상품지정할인권
// ================================================================================================================================
// 쿠폰 중복 가능여부 체크
// ================================================================================================================================
foreach (Column.TR_PAYMENT.DATA cPayItem in alTrPayItem)
{
if (cPayItem.CANCEL_DIV == PosConst.CANCEL_DIV.CANCEL) continue;
if (cPayItem.PAY_WAY_CD == ItemConst.TR_ITEM_ID.COUPON_ITEM && cPayItem.PAY_DTL_CD_01 == ItemConst.TR_ITEM_ID.COUPON.ONLINE)
{
bool bCouponExist = true;
if (sCouponKind == PosConst.ONLINE_CPN_KIND.AMTPAY) // 금액권만 중복 가능
{
if ( cPayItem.PAY_DTL_CD_02 == PosConst.ONLINE_CPN_KIND.AMTPAY) bCouponExist = false;
}
if (bCouponExist == true)
{
WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0609);
return sRet;
}
}
}
int nPluCount = 0; double nPluAmount = 0; // 상품라인수, 상품금액
string sPluInfo = GetSalePluInfo(ref nPluCount, ref nPluAmount); // 상품정보 생성
if (nPluCount <= 0)
{
WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0610);
return sRet;
}
string sTranKind = "20"; // 거래구분 요청구분 2 N 10 : 발행, 20 : 승인)
// 온라인쿠폰 승인(금액설정 => 총매출, 받을금액 JIN확인(07.01.05))
sRet = ExecuteOnLineCouponIrt(PosConst.CANCEL_DIV.NORMAL, sTranKind, sInPutType, sInPutData, m_cTrnStatus.Head.TotSaleAmt, nPluCount, m_cTrnStatus.Sale.RemainPayAmt, sPluInfo, "", "");
if (sRet != UserCom.RST_OK) return sRet;
// 쿠폰 적용 처리
if (sCouponKind == PosConst.ONLINE_CPN_KIND.CHANGE)
{
// 교환권 : 액면금액 결제처리 하고, 잔액(액면금액-점포판매가)은 금액할인처리
nSelRow = SelectDestPluRow(sCouponKind, m_cPayItem.HP_RESERVED); // 쿠폰 대상상품 선택
if (nSelRow == -1) return UserCom.RST_ERR;
Column.TR_PLU.DATA cSaleItem = (Column.TR_PLU.DATA)alTrPluItem[nSelRow];
m_cPayItem.PAY_DTL_CD_03 = "0"; // 할인금액아이템적용여부 (0:미적용, 1:적용)
m_cPayItem.PAY_DTL_CD_04 = cSaleItem.ITEM_PLU_CD; // 쿠폰결제정보에 대상상품코드 설정
m_cPayItem.PAY_DTL_CD_05 = PosConst.PAY_DC_TYPE.PAY; // 할인결제구분 (1:결제, 2:할인)
// 점포판매가가 액면가보다 작으면 점포판매가 결제 처리
if (m_cPayItem.AMT_ENTRY_01 > cSaleItem.SALE_PRC)
{
m_cPayItem.PAY_AMT = cSaleItem.SALE_PRC; // 결제금액=상품판매가
m_cPayItem.AMT_ENTRY_01 = m_cPayItem.PAY_AMT;
m_cPayItem.AMT_ENTRY_02 = 0;
}
else
{
m_cPayItem.PAY_AMT = m_cPayItem.AMT_ENTRY_01; // 결제금액=액면금액
m_cPayItem.AMT_ENTRY_02 = CmUtil.DoubleSubtraction(cSaleItem.SALE_PRC, m_cPayItem.AMT_ENTRY_01); // 할인금액(점포판매가-액면금액)
if (m_cPayItem.AMT_ENTRY_02 > 0)
{
m_cPayItem.PAY_DTL_CD_03 = "1"; // 할인금액아이템적용여부 (0:미적용, 1:적용)
// 할인금액 상품에 설정
SetPluDiscountAmount(nSelRow, m_cPayItem.PAY_WAY_CD + m_cPayItem.PAY_DTL_CD_01, sInPutData, m_cPayItem.AMT_ENTRY_02, true);
}
}
}
else if (sCouponKind == PosConst.ONLINE_CPN_KIND.PRESENT)
{
// 증정권 : 금액과 상관없이 해당상품 무료증정(할인 처리)
nSelRow = SelectDestPluRow(sCouponKind, m_cPayItem.HP_RESERVED); // 쿠폰 대상상품 선택
if (nSelRow == -1) return UserCom.RST_ERR;
Column.TR_PLU.DATA cSaleItem = (Column.TR_PLU.DATA)alTrPluItem[nSelRow];
m_cPayItem.PAY_DTL_CD_03 = "1"; // 할인금액아이템적용여부 (0:미적용, 1:적용)
m_cPayItem.PAY_DTL_CD_04 = cSaleItem.ITEM_PLU_CD; // 쿠폰결제정보에 대상상품코드 설정
m_cPayItem.PAY_DTL_CD_05 = PosConst.PAY_DC_TYPE.DC; // 할인결제구분 (1:결제, 2:할인)
m_cPayItem.PAY_AMT = cSaleItem.SALE_PRC; // 결제금액=할인금액
m_cPayItem.AMT_ENTRY_01 = m_cPayItem.PAY_AMT;
m_cPayItem.AMT_ENTRY_02 = cSaleItem.SALE_PRC; // 할인금액
// 할인금액 상품에 설정
SetPluDiscountAmount(nSelRow, m_cPayItem.PAY_WAY_CD + m_cPayItem.PAY_DTL_CD_01, sInPutData, m_cPayItem.AMT_ENTRY_02, false);
}
else if (sCouponKind == PosConst.ONLINE_CPN_KIND.AMTPAY)
{
// 금액권 : 발행가 결제처리 하고, 할인금액(액면가-발행가) 발생시 전체상품에 할인 처리
if (m_cPayItem.AMT_ENTRY_01 > m_cTrnStatus.Sale.RemainPayAmt) // 액면금액이 받을금액 초과시 쿠폰 등록 불가 처리
{
WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0618);
return UserCom.RST_ERR;
}
m_cPayItem.PAY_DTL_CD_03 = "0"; // 할인금액아이템적용여부 (0:미적용, 1:적용)
m_cPayItem.PAY_DTL_CD_05 = PosConst.PAY_DC_TYPE.PAY; // 할인결제구분 (1:결제, 2:할인)
m_cPayItem.PAY_AMT = m_cPayItem.AMT_ENTRY_03; // 결제금액=발행금액
m_cPayItem.AMT_ENTRY_01 = m_cPayItem.PAY_AMT;
m_cPayItem.AMT_ENTRY_02 = CmUtil.DoubleSubtraction(m_cPayItem.AMT_ENTRY_01, m_cPayItem.AMT_ENTRY_03); // 할인금액(액면가-발행가)
if (m_cPayItem.AMT_ENTRY_02 > 0)
{
m_cPayItem.PAY_DTL_CD_03 = "1"; // 할인금액아이템적용여부 (0:미적용, 1:적용)
// 할인금액 상품에 설정
SetPluDiscountAmount(nSelRow, m_cPayItem.PAY_WAY_CD + m_cPayItem.PAY_DTL_CD_01, sInPutData, m_cPayItem.AMT_ENTRY_02, false);
}
}
else if (sCouponKind == PosConst.ONLINE_CPN_KIND.DISCOUNT)
{
// 할인권 : 상품상관없이 할인금액만큼 전체상품에 할인 처리
m_cPayItem.PAY_DTL_CD_03 = "1"; // 할인금액아이템적용여부 (0:미적용, 1:적용)
m_cPayItem.PAY_DTL_CD_05 = PosConst.PAY_DC_TYPE.DC; // 할인결제구분 (1:결제, 2:할인)
m_cPayItem.PAY_AMT = m_cPayItem.AMT_ENTRY_02; // 결제금액=할인금액
m_cPayItem.AMT_ENTRY_01 = m_cPayItem.PAY_AMT;
// 할인금액 상품에 설정
SetPluDiscountAmount(nSelRow, m_cPayItem.PAY_WAY_CD + m_cPayItem.PAY_DTL_CD_01, sInPutData, m_cPayItem.AMT_ENTRY_02, false);
}
else if (sCouponKind == PosConst.ONLINE_CPN_KIND.PLUDIS)
{
// 상품지정할인권 : 해당 상품에 할인금액 만큼 할인 처리
nSelRow = SelectDestPluRow(sCouponKind, m_cPayItem.HP_RESERVED); // 쿠폰 대상상품 선택
if (nSelRow == -1) return UserCom.RST_ERR;
Column.TR_PLU.DATA cSaleItem = (Column.TR_PLU.DATA)alTrPluItem[nSelRow];
m_cPayItem.PAY_DTL_CD_03 = "1"; // 할인금액아이템적용여부 (0:미적용, 1:적용)
m_cPayItem.PAY_DTL_CD_04 = cSaleItem.ITEM_PLU_CD; // 쿠폰결제정보에 대상상품코드 설정
m_cPayItem.PAY_DTL_CD_05 = PosConst.PAY_DC_TYPE.DC; // 할인결제구분 (1:결제, 2:할인)
m_cPayItem.PAY_AMT = m_cPayItem.AMT_ENTRY_02; // 결제금액=할인금액
m_cPayItem.AMT_ENTRY_01 = m_cPayItem.PAY_AMT;
// 할인금액 상품에 설정
SetPluDiscountAmount(nSelRow, m_cPayItem.PAY_WAY_CD + m_cPayItem.PAY_DTL_CD_01, sInPutData, m_cPayItem.AMT_ENTRY_02, false);
}
// 결제 아이템 추가
m_cPayItem.SEQ = alTrPayItem.Count + 1;
alTrPayItem.Add(m_cPayItem);
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);
}
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 = "";
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; // 입력데이터
double nNetSaleAmt = m_cPayItem.AMT_ENTRY_10; // 받을금액
string sApprDate = m_cPayItem.OCCUR_ENTRY_03 + m_cPayItem.OCCUR_ENTRY_04; // 승인일자
string sApprNo = m_cPayItem.OCCUR_ENTRY_02; // 승인번호
string sTranKind = "20"; // 거래구분 요청구분 2 N 10 : 발행, 20 : 승인)
sRet = ExecuteOnLineCouponIrt(PosConst.CANCEL_DIV.CANCEL, sTranKind, sInPutType, sInPutData, 0, 0, 0, "", sApprDate, sApprNo);
if (sRet != UserCom.RST_OK) return sRet;
if (m_cPayItem.AMT_ENTRY_02 > 0)
{
if (m_cPayItem.PAY_DTL_CD_02 == PosConst.ONLINE_CPN_KIND.CHANGE)
{
SubPluDiscountAmount(m_cPayItem.PAY_WAY_CD + m_cPayItem.PAY_DTL_CD_01, sInPutData, m_cPayItem.AMT_ENTRY_02);
}
else
{
ClearPluDiscountAmount(m_cPayItem.PAY_WAY_CD + m_cPayItem.PAY_DTL_CD_01, sInPutData);
}
}
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);
}
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 = "";
try
{
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; // 입력데이터
if (m_cPayItem.OCCUR_ENTRY_08.ToString() != ItemConst.PAY_APP_DIV.NORMAL)
{
m_cPayItem.OCCUR_ENTRY_06 = m_cPayItem.OCCUR_ENTRY_02; // 원승인번호
m_cPayItem.OCCUR_ENTRY_07 = m_cPayItem.OCCUR_ENTRY_03; // 원승인일자
}
else
{
string sApprDate = m_cPayItem.OCCUR_ENTRY_03 + m_cPayItem.OCCUR_ENTRY_04; // 승인일자
string sApprNo = m_cPayItem.OCCUR_ENTRY_02; // 승인번호
string sTranKind = "20"; // 거래구분 요청구분 2 N 10 : 발행, 20 : 승인)
sRet = ExecuteOnLineCouponIrt(PosConst.CANCEL_DIV.CANCEL, sTranKind, sInPutType, sInPutData, 0, 0, 0, "", sApprDate, sApprNo);
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 SetMenualPayment
public string SetMenualPayment(string[] aParam)
{
throw new NotImplementedException();
}
#endregion
#region
/// <summary>
/// 온라인쿠폰 승인
/// </summary>
public string ExecuteOnLineCouponIrt(string sTradeDiv, string sTranKind, string sInPutType, string sInPutData, double nTotSaleAmt, int nPluCount, double nNetSaleAmt, string sPluInfo, string sApprDate, string sApprNo)
{
string sRet = UserCom.RST_ERR;
string sVanCode = "", sServerIP = "", sServerPort = "";
try
{
// 연습모드이면 연습 데이터 설정
if (m_cPosStatus.Base.TrainingFlag == "1" || m_cPosStatus.Mst.TestStorYn == "1")
{
return SetTrainingData(sTradeDiv, sInPutType, sInPutData, nTotSaleAmt, nPluCount, nNetSaleAmt, sPluInfo, sApprDate, sApprNo);
}
// 승인업체 정보 획득
sVanCode = PosMstManager.GetMstPayDc(m_cPayItem.PAY_WAY_CD, m_cPayItem.PAY_DTL_CD_01, PosMst.MST_PAY_DC.DATA.APPR_VEND_CD);
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);
if (sVanCode == "" || sServerIP == "" || sServerPort == "")
{
WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0563);
return sRet;
}
// 전송 데이터 생성
string sSendData = MakeOnLineCouponSendData(sTradeDiv, sTranKind, sInPutType, sInPutData, nTotSaleAmt, nPluCount, nNetSaleAmt, sPluInfo, sApprDate, sApprNo);
// 전문 송수신 처리
string[] aIrtRsp = new string[Column.POS_RES_ONLINE_COUPON.LEN.Length];
if (ExecuteTcpSocket(sServerIP, sServerPort, sSendData, ref aIrtRsp) == false) return UserCom.RST_ERR; // 송수신
// 응답코드 체크
string sResCD = aIrtRsp[Column.POS_RES_ONLINE_COUPON.SEQ.ResCD];
if (sResCD != "0000")
{
m_cPayItem.HP_CUST_NAME = aIrtRsp[Column.POS_RES_ONLINE_COUPON.SEQ.CpnName].Trim() + " " + GetCouponKindName(sInPutData); // 쿠폰명
m_cPayItem.HP_RESERVED = aIrtRsp[Column.POS_RES_ONLINE_COUPON.SEQ.PluInfo]; // 상품정보
if (sTranKind == "10" && (sResCD == "7022" || sResCD == "9002"))
{
// 10:상품조회 - 7022:판매할 제품을 선택해 주세요. 9002:상품정보가존재하지않습니다
}
else
{
string sResMsg = "";
DataTable dtData = m_cDataCommon.SeletCommonCode(PosConst.COMMON_CODE_GROUP.Z0021, aIrtRsp[Column.POS_RES_ONLINE_COUPON.SEQ.ResCD]);
if (dtData != null && dtData.Rows.Count > 0)
{
DataRow dr = dtData.Rows[0];
sResMsg = CmUtil.GetDataRowStr(dr, PosMst.MST_COMMON.DATA.CD_NM);
}
if (sResCD == "7005") // 7005:이미사용한 쿠폰입니다
{
string sUseDT = aIrtRsp[Column.POS_RES_ONLINE_COUPON.SEQ.ErrMsg].Trim();
if (sUseDT.Length > 14)
{
// 사용일시
sResMsg += PosConst.CRLF + MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0631) + " : "
+ sUseDT.Substring(0, 4) + "-" + sUseDT.Substring(4, 2) + "-" + sUseDT.Substring(6, 2) + " "
+ sUseDT.Substring(8, 2) + ":" + sUseDT.Substring(10, 2) + ":" + sUseDT.Substring(12, 2);
// 사용점포
sResMsg += PosConst.CRLF + MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0986) + " : "
+ GetStoreName(sUseDT.Substring(14)) + "[" + sUseDT.Substring(14) + "]";
}
}
WinManager.ErrorMessage(sResMsg); // 메시지 표시
}
return UserCom.RST_ERR;
}
if (sTradeDiv == PosConst.CANCEL_DIV.NORMAL || sTradeDiv == "")
{
m_cPayItem.PAY_AMT = CmUtil.DoubleParse(aIrtRsp[Column.POS_RES_ONLINE_COUPON.SEQ.DisCpnAmt]); // 결제금액
m_cPayItem.PAY_DTL_CD_02 = CmUtil.MidH(sInPutData, 8, 1); // 쿠폰종류 1:교환권, 2:증정권, 3:금액권, 4:할인권, 5:상품지정할인권
m_cPayItem.PAY_DTL_CD_03 = "0"; // 할인금액아이템적용여부 (0:미적용, 1:적용)
m_cPayItem.PAY_DTL_CD_05 = PosConst.PAY_DC_TYPE.PAY; // 할인결제구분 (1:결제, 2:할인)
m_cPayItem.QTY_ENTRY_01 = 1; // 수량
m_cPayItem.AMT_ENTRY_01 = CmUtil.DoubleParse(aIrtRsp[Column.POS_RES_ONLINE_COUPON.SEQ.TotCpnAmt]); // 받은금액(액면금액)
m_cPayItem.AMT_ENTRY_02 = CmUtil.DoubleParse(aIrtRsp[Column.POS_RES_ONLINE_COUPON.SEQ.DisCpnAmt]); // 할인금액
m_cPayItem.AMT_ENTRY_03 = CmUtil.DoubleParse(aIrtRsp[Column.POS_RES_ONLINE_COUPON.SEQ.NetCpnAmt]); // 발행금액
m_cPayItem.AMT_ENTRY_10 = nNetSaleAmt; // 대상상품금액
m_cPayItem.OCCUR_ENTRY_01 = sInPutData; // 쿠폰번호
m_cPayItem.OCCUR_ENTRY_02 = aIrtRsp[Column.POS_RES_ONLINE_COUPON.SEQ.ApprNo].Trim(); // 승인번호
m_cPayItem.OCCUR_ENTRY_03 = CmUtil.MidH(aIrtRsp[Column.POS_RES_ONLINE_COUPON.SEQ.ApprDT], 0, 8); // 승인일자
m_cPayItem.OCCUR_ENTRY_04 = CmUtil.MidH(aIrtRsp[Column.POS_RES_ONLINE_COUPON.SEQ.ApprDT], 8, 6); // 승인시간
m_cPayItem.OCCUR_ENTRY_05 = sInPutType; // 입력구분
m_cPayItem.OCCUR_ENTRY_06 = ""; // 원승인번호
m_cPayItem.OCCUR_ENTRY_07 = ""; // 원승인일자
m_cPayItem.OCCUR_ENTRY_08 = ItemConst.PAY_APP_DIV.NORMAL; // 승인구분
m_cPayItem.OCCUR_ENTRY_16 = sVanCode; // VAN 구분
m_cPayItem.OCCUR_ENTRY_18 = ""; // 가맹점번호
m_cPayItem.OCCUR_ENTRY_19 = GetCouponKindName(sInPutData); // 쿠폰종류명
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.HP_CUST_NAME = aIrtRsp[Column.POS_RES_ONLINE_COUPON.SEQ.CpnName].Trim() + " " + GetCouponKindName(sInPutData); // 쿠폰명
m_cPayItem.HP_RESERVED = aIrtRsp[Column.POS_RES_ONLINE_COUPON.SEQ.PluInfo]; // 상품정보
}
else
{
m_cPayItem.OCCUR_ENTRY_01 = sInPutData; // 카드번호
m_cPayItem.OCCUR_ENTRY_02 = aIrtRsp[Column.POS_RES_ONLINE_COUPON.SEQ.ApprNo].Trim(); // 승인번호
m_cPayItem.OCCUR_ENTRY_03 = CmUtil.MidH(aIrtRsp[Column.POS_RES_ONLINE_COUPON.SEQ.ApprDT], 0, 8); // 승인일자
m_cPayItem.OCCUR_ENTRY_04 = CmUtil.MidH(aIrtRsp[Column.POS_RES_ONLINE_COUPON.SEQ.ApprDT], 8, 6); // 승인시간
m_cPayItem.OCCUR_ENTRY_05 = sInPutType; // 입력 구분
m_cPayItem.OCCUR_ENTRY_06 = sApprNo; // 원승인번호
m_cPayItem.OCCUR_ENTRY_07 = sApprDate.Substring(0, 8); // 원승인일자
}
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 sTradeDiv, string sInPutType, string sInPutData, double nTotSaleAmt, int nPluCount, double nNetSaleAmt, string sPluInfo, string sApprDate, string sApprNo)
{
string sRet = UserCom.RST_ERR;
try
{
if (sTradeDiv == PosConst.CANCEL_DIV.NORMAL || sTradeDiv == "")
{
// 대상 상품정보[상품코드(10) + 수량(3) + 단가(6)
double nPluAmount = sPluInfo == "" ? 1000 : CmUtil.DoubleParse(sPluInfo.Substring(13, 6));
m_cPayItem.PAY_AMT = m_cDataCommon.ExecTermCoopCmpPayDc(m_cPayItem.PAY_WAY_CD, m_cPayItem.PAY_DTL_CD_01, "", nPluAmount); // 제휴사 결제 할인 금액 계산
m_cPayItem.PAY_DTL_CD_02 = CmUtil.MidH(sInPutData, 8, 1); // 쿠폰종류 1:교환권, 2:증정권, 3:금액권, 4:할인권, 5:상품지정할인권
m_cPayItem.PAY_DTL_CD_03 = "0"; // 할인금액아이템적용여부 (0:미적용, 1:적용)
m_cPayItem.PAY_DTL_CD_05 = PosConst.PAY_DC_TYPE.PAY; // 할인결제구분 (1:결제, 2:할인)
m_cPayItem.QTY_ENTRY_01 = 1; // 수량
m_cPayItem.AMT_ENTRY_01 = nPluAmount; // 받은금액(액면금액)
m_cPayItem.AMT_ENTRY_02 = m_cPayItem.PAY_AMT; // 할인금액
m_cPayItem.AMT_ENTRY_03 = nPluAmount; // 발행금액
m_cPayItem.AMT_ENTRY_10 = nNetSaleAmt; // 대상상품금액
m_cPayItem.OCCUR_ENTRY_01 = sInPutData; // 쿠폰번호
m_cPayItem.OCCUR_ENTRY_02 = "99999999"; // 승인번호
m_cPayItem.OCCUR_ENTRY_03 = DateTime.Now.ToString("yyyyMMdd"); // 승인일자
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_16 = ""; // VAN 구분
m_cPayItem.OCCUR_ENTRY_18 = ""; // 가맹점번호
m_cPayItem.OCCUR_ENTRY_19 = GetCouponKindName(sInPutData); // 쿠폰종류명
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.HP_CUST_NAME = GetPayDtlCdToPayDtlName(m_cPayItem.PAY_WAY_CD, m_cPayItem.PAY_DTL_CD_01) + "-" + GetCouponKindName(sInPutData); // 쿠폰명
m_cPayItem.HP_RESERVED = sPluInfo == "" ? "" : "001" + sPluInfo.Substring(0, 10); // 상품정보(앞자리 3자리: 상품코드 개수 승인정상응답시 해당교환상품코드
}
else
{
m_cPayItem.OCCUR_ENTRY_01 = sInPutData; // 쿠폰번호
m_cPayItem.OCCUR_ENTRY_02 = "99999999"; // 승인번호
m_cPayItem.OCCUR_ENTRY_03 = DateTime.Now.ToString("yyyyMMdd"); // 승인일자
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; // 원승인일자
}
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
/// <summary>
/// 온라인 쿠폰 TCP 전문 송수신 처리
/// </summary>
/// <param name="sServerIP"></param>
/// <param name="sServerPort"></param>
/// <param name="sSendData"></param>
/// <param name="saRecv"></param>
/// <returns></returns>
public bool ExecuteTcpSocket(string sServerIP,string sServerPort, string sSendData, ref string[] saRecv)
{
try
{
// 데이터 송신
byte[] byteSend = Encoding.Default.GetBytes(sSendData);
// 데이터 수신
byte[] byteRecv = new byte[4096];
int nRecvLen = m_cDataCommon.ExecuteTcpClientIrt("ExecuteOnLineCoupon", sServerIP, CmUtil.IntParse(sServerPort), 10000, byteSend, ref byteRecv, 0);
if (nRecvLen <= 0)
{
WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0158);
return false;
}
string sRecvData = Encoding.Default.GetString(byteRecv, 0, nRecvLen);
// 수신데이터 파싱
int nNowPos = 0;
ItemColumn.ParseMessage(Column.POS_RES_ONLINE_COUPON.LEN, Column.POS_RES_ONLINE_COUPON.TYPE, byteRecv, ref nNowPos, ref saRecv);
// 가변 필드(상품정보 데이터 획득)
nNowPos--;
byte[] byValue = new byte[nRecvLen - nNowPos - 1];
Array.Copy(byteRecv, nNowPos, byValue, 0, nRecvLen - nNowPos - 1);
saRecv[saRecv.Length - 1] = Encoding.Default.GetString(byValue, 0, byValue.Length);
return true;
}
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 false;
}
/// <summary>
/// 쿠폰 대상 상품 선택
/// </summary>
/// <param name="sCouponKind"></param>
/// <returns></returns>
public int SelectDestPluRow(string sCouponKind, string sPluInfo)
{
int nSelRow = -1;
try
{
ArrayList alTrPluItem = (ArrayList)StateObject.GetItemObject(Column.TR_PLU.ITEM); // 상품 아이템
// 상품대상 쿠폰이면 상품을 체크 => 1:교환권, 2:무료증정권, 5:상품지정할인권
if (sCouponKind == PosConst.ONLINE_CPN_KIND.CHANGE || sCouponKind == PosConst.ONLINE_CPN_KIND.PRESENT || sCouponKind == PosConst.ONLINE_CPN_KIND.PLUDIS)
{
if (sPluInfo.Trim().Length >= 4) // 앞자리 3자리: 상품코드 개수, 승인정상응답시 해당교환상품코드
{
int nMaxPrice = 0;
int nResPluCnt = CmUtil.IntParse(CmUtil.MidH(sPluInfo, 0, 3));
for (int i = 0; i < nResPluCnt; i++)
{
string sResPluCode = CmUtil.MidH(sPluInfo, i * 10 + 3, 10).Trim();
for (int j = 0; j < alTrPluItem.Count; j++)
{
Column.TR_PLU.DATA cPluItem = (Column.TR_PLU.DATA)alTrPluItem[j];
// 대상상품 할인 가능여부 체크
if (m_cDataService.CheckPluDiscountAble(PosKey.MENU_KEY.ONLINE_COUPONS, cPluItem) == false) continue;
if (cPluItem.ITEM_PLU_CD == sResPluCode)
{
// 단가 최고가 상품 선택
if (nMaxPrice == 0 || nMaxPrice < cPluItem.SALE_PRC) nSelRow = j;
}
}
}
}
if (nSelRow == -1)
{
WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0610);
}
}
}
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 nSelRow;
}
}
}