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 CouponDC : PaymentBase, IPaymentUs
{
public CouponDC()
{
}
#region SearchPayment 결제 조회
///
/// 결제 조회
///
///
///
///
public string SearchPayment(string[] aParam, ref string[] aRet)
{
string sRet = UserCom.RST_ERR;
try
{
string sPosMenuKey = aParam[0]; // 메뉴키
string sInPutType = aParam[1]; // 입력구분
string sInPutData = aParam[2]; // 입력데이터
string sCardData = aParam[3]; // 카드데이터
double nPayAmt = CmUtil.DoubleParse(aParam[4]); // 대상금액
}
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 결제 정보 획득
///
/// 결제 정보 획득
///
///
///
public object GetPayment(string[] aParam)
{
return m_cPayItem;
}
#endregion
#region SetPayment 결제 등록
///
/// 결제 등록
///
///
///
public string SetPayment(string[] aParam)
{
string sRet = UserCom.RST_ERR;
try
{
string sPosMenuKey = aParam[0]; // 메뉴키
string sInPutType = aParam[1]; // 입력구분
string sInPutData = aParam[2]; // 입력데이터
string sCardData = aParam[3]; // 카드데이터
double nPayAmt = CmUtil.DoubleParse(aParam[4]); // 대상금액
double nSaleAmt = CmUtil.DoubleParse(aParam[5]); // 받을금액
string sCouponGroup = aParam[6]; // 쿠폰그룹
string sTrType = "";
if (m_cTrnStatus.Head.TradeDiv == ItemConst.TRAN_DIV.NORMAL)
sTrType = PosConst.POS_VAN_MASTER.TRADE_ID.VAN_POT_DIS_A;
else
sTrType = PosConst.POS_VAN_MASTER.TRADE_ID.VAN_POT_DIS_C;
string sPointType = "";
m_cPayItem = new Column.TR_PAYMENT.DATA(); // 결과 저장 변수 생성
m_cPayItem.PAY_WAY_CD = GetMenuKeyToPayWayCd(sPosMenuKey);
m_cPayItem.PAY_DTL_CD_01 = GetMenuKeyToPayDtlCd(sPosMenuKey);
sRet = ExecuteIrt(sTrType, sPointType, sInPutType, sInPutData, sCardData, nSaleAmt, nPayAmt, sCouponGroup, "", "");
if (sRet != UserCom.RST_OK) return sRet;
// 결제 아이템 추가
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(); // 결제 금액 재 계산 처리
//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 결제 취소
///
/// 결제 취소
///
///
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.COUPON_ITEM && clPayItem.PAY_DTL_CD_01 == ItemConst.TR_ITEM_ID.COUPON.NORMAL)
{
// 결제 수단 취소
sRet = CancelPaymentSub(new string[] { iRow.ToString() });
if (sRet != UserCom.RST_OK) return sRet;
m_cPayItem.CANCEL_DIV = PosConst.CANCEL_DIV.CANCEL;
}
}
// ---------------------------------------------------------------------------------------------------------------------------------------
// ---------------------------------------------------------------------------------------------------------------------------------------
// 상품정보
// ---------------------------------------------------------------------------------------------------------------------------------------
ArrayList aSaleItem = (ArrayList)StateObject.GetItemObject(Column.TR_PLU.ITEM);
for (int iRow = 0; iRow < aSaleItem.Count; iRow++)
{
Column.TR_PLU.DATA cSaleItem = (Column.TR_PLU.DATA)aSaleItem[iRow];
if (cSaleItem.CANCEL_DIV == PosConst.CANCEL_DIV.CANCEL || cSaleItem.CANCEL_DIV_MAIN == PosConst.CANCEL_DIV.CANCEL) continue;// 지정취소
if (cSaleItem.CPN_DC_DIV == ItemConst.PLU_CPN_DC_TYPE.DC_CPN && cSaleItem.CPN_DC_AMT > 0)
{
// 상품할인 적용
cSaleItem.CPN_DC_AMT = 0;
cSaleItem.CPN_DC_DIV = ItemConst.PLU_CPN_DC_TYPE.NORMAL; // 쿠폰 할인 구분
cSaleItem.CPN_NO = ""; // 쿠폰번호
// 상품행별 영수 금액 재계산 처리
m_cDataService.UpdatePluItemAmount(cSaleItem);
}
}
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 결제 반품
///
/// 결제 반품
///
///
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.COUPON_ITEM && clPayItem.PAY_DTL_CD_01 == ItemConst.TR_ITEM_ID.COUPON.NORMAL)
// {
// 결제 수단 반품
sRet = RefundPaymentSub(new string[] { aParam[0].ToString() });
if (sRet != UserCom.RST_OK) return sRet;
// }
//}
//// ---------------------------------------------------------------------------------------------------------------------------------------
//// ---------------------------------------------------------------------------------------------------------------------------------------
//// 상품정보
//// ---------------------------------------------------------------------------------------------------------------------------------------
//ArrayList aSaleItem = (ArrayList)StateObject.GetItemObject(Column.TR_PLU.ITEM);
//for (int iRow = 0; iRow < aSaleItem.Count; iRow++)
//{
// Column.TR_PLU.DATA cSaleItem = (Column.TR_PLU.DATA)aSaleItem[iRow];
// if (cSaleItem.CPN_DC_AMT == 0) continue; // 할인 금액
// // 상품할인 적용
// cSaleItem.CPN_DC_AMT = 0;
// cSaleItem.CPN_DC_DIV = ItemConst.PLU_CPN_DC_TYPE.NORMAL; // 쿠폰 할인 구분(00:없음, 01:쿠폰, 02:해피쿠폰할인(스템프,복권), 03:인카드쿠폰, 04:매장쿠폰)
// cSaleItem.CPN_NO = ""; // 쿠폰번호
// // 상품행별 영수 금액 재계산 처리
// m_cDataService.UpdatePluItemAmount(cSaleItem);
//}
//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 RefundPaymentSub 결제 반품
///
/// 결제 반품
///
///
///
public string RefundPaymentSub(string[] aParam)
{
string sRet = UserCom.RST_ERR;
try
{
int nPayRow = CmUtil.IntParse(aParam[0]); // 취소할 행번호
// 결제 내역 받아 오기
ArrayList alPayItem = (ArrayList)StateObject.GetItemObject(Column.TR_PAYMENT.ITEM);
m_cPayItem = (Column.TR_PAYMENT.DATA)alPayItem[nPayRow];
string sInPutType = m_cPayItem.OCCUR_ENTRY_05; // 입력구분
string sInPutData = m_cPayItem.OCCUR_ENTRY_01; // 입력데이터
string sCardData = m_cPayItem.OCCUR_ENTRY_22; // 카드데이터
double nPayAmt = m_cPayItem.AMT_ENTRY_01; // 대상금액
double nSaleAmt = m_cPayItem.QTY_ENTRY_01; // 받을금액
string sCouponGroup = m_cPayItem.OCCUR_ENTRY_09; // 쿠폰그룹코드
string sTrType = PosConst.POS_VAN_MASTER.TRADE_ID.VAN_POT_DIS_C;
string sPointType = "";
sRet = ExecuteIrt(sTrType, sPointType, sInPutType, sInPutData, sCardData, nSaleAmt, nPayAmt, sCouponGroup, "", "");
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 SetMenualPayment
public string SetMenualPayment(string[] aParam)
{
throw new NotImplementedException();
}
#endregion
#region CancelPaymentSub 결제 취소
///
/// 결제 취소
///
///
///
public string CancelPaymentSub(string[] aParam)
{
string sRet = UserCom.RST_ERR;
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 sInPutType = m_cPayItem.OCCUR_ENTRY_05; // 입력구분
string sInPutData = m_cPayItem.OCCUR_ENTRY_01; // 입력데이터
string sCardData = m_cPayItem.OCCUR_ENTRY_22; // 카드데이터
double nPayAmt = m_cPayItem.AMT_ENTRY_01; // 대상금액
double nSaleAmt = m_cPayItem.QTY_ENTRY_01; // 받을금액
string sCouponGroup = m_cPayItem.OCCUR_ENTRY_09; // 쿠폰그룹코드
string sTrType = PosConst.POS_VAN_MASTER.TRADE_ID.VAN_POT_DIS_C;
string sPointType = "";
sRet = ExecuteIrt(sTrType, sPointType, sInPutType, sInPutData, sCardData, nSaleAmt, nPayAmt, sCouponGroup, "", "");
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 조회 실행
///
/// 조회 실행
///
public string ExecuteIrt(string sTrType, string sPointType, string sInPutType, string sInPutData, string sCardData, double nSaleAmt, double nPayAmt, string sCouponGroup, string sApprDate, string sApprNo)
{
string sRet = UserCom.RST_ERR;
try
{
// 연습모드이면 연습 데이터 설정
if (m_cPosStatus.Base.TrainingFlag == "1" || m_cPosStatus.Mst.TestStorYn == "1" ) return SetTrainingData(sTrType, sPointType, sInPutType, sInPutData, sCardData, nSaleAmt, nPayAmt, sCouponGroup, sApprDate, sApprNo);
// 결제구분 (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(nPayAmt.ToString());
m_cPayItem.PAY_DTL_CD_02 = ""; // 캠페인코드
m_cPayItem.PAY_DTL_CD_03 = "1"; // 할인금액 아이템 적용 여부 (0:미적용, 1:적용)
m_cPayItem.PAY_DTL_CD_04 = ""; // 상품코드
m_cPayItem.PAY_DTL_CD_05 = PosConst.PAY_DC_TYPE.DC; // 할인결제구분 (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 = CmUtil.DoubleParse(nPayAmt.ToString()); // 받은돈
m_cPayItem.AMT_ENTRY_02 = CmUtil.DoubleParse(nPayAmt.ToString()); // 할인금액
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.AMT_ENTRY_09 = 0;
m_cPayItem.AMT_ENTRY_10 = 0;
m_cPayItem.OCCUR_ENTRY_01 = sInPutData; // 카드번호
m_cPayItem.OCCUR_ENTRY_02 = ""; // 승인번호
m_cPayItem.OCCUR_ENTRY_03 = ""; // 승인일자
m_cPayItem.OCCUR_ENTRY_04 = ""; // 승인시간
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_09 = sCouponGroup; // 쿠폰그룹코드
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_22 = 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;
}
///
/// 연습 데이터 설정
///
public string SetTrainingData(string sTrType, string sPointType, string sInPutType, string sInPutData, string sCardData, double nSaleAmt, double nPayAmt, string sCouponGroup, 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 = m_cPayItem.PAY_AMT;
m_cPayItem.PAY_DTL_CD_02 = ""; // 캠페인코드
m_cPayItem.PAY_DTL_CD_03 = "1"; // 할인금액 아이템 적용 여부 (0:미적용, 1:적용)
m_cPayItem.PAY_DTL_CD_04 = ""; // 상품코드
m_cPayItem.PAY_DTL_CD_05 = PosConst.PAY_DC_TYPE.DC; // 할인결제구분 (1:결제, 2:할인)
m_cPayItem.QTY_ENTRY_01 = nPayAmt; // 받을금액
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 = 0;
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 = sInPutData; // 카드번호
m_cPayItem.OCCUR_ENTRY_02 = ""; // 승인번호
m_cPayItem.OCCUR_ENTRY_03 = ""; // 승인일자
m_cPayItem.OCCUR_ENTRY_04 = ""; // 승인시간
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.COMPULSION; //승인구분
m_cPayItem.OCCUR_ENTRY_09 = sCouponGroup; // 쿠폰그룹코드
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_22 = 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
}
}