3873 lines
210 KiB
C#
3873 lines
210 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using System.Collections;
|
|
using System.Data;
|
|
|
|
using Cosmos.BaseFrame;
|
|
using Cosmos.UserFrame;
|
|
using Cosmos.ServiceProvider;
|
|
using Cosmos.Common;
|
|
using Cosmos.CommonManager;
|
|
|
|
/*-----------------------------------------------------------------------------------------------*/
|
|
// 설 명 : 캠페인 공통 처리
|
|
// 작 성 자 :
|
|
// 변경 이력 :
|
|
/*-----------------------------------------------------------------------------------------------*/
|
|
namespace Cosmos.Service
|
|
{
|
|
class CampaignBase
|
|
{
|
|
#region 변수 선언
|
|
protected SManager sManager = new SManager(); // 이 객체를 통해 업무 Service 호출
|
|
protected StateServer StateObject = (StateServer)StateServer.GetInstance(); // StateObject : StateServer Object (객체)
|
|
protected PosStatus m_cPosStatus = new PosStatus(); // 기본정보 참조
|
|
protected TranStatus m_cTrnStatus = new TranStatus(); // 거래정보 참조
|
|
|
|
/// <summary>
|
|
/// 캠페인트란 아이템
|
|
/// </summary>
|
|
protected ArrayList m_alTrSaleCpi = null;
|
|
/// <summary>
|
|
/// 상품트란 아이템
|
|
/// </summary>
|
|
protected ArrayList m_alTrPluItem = null;
|
|
|
|
/// <summary>
|
|
/// 결제캠페인 적용정보
|
|
/// </summary>
|
|
protected ArrayList m_alSaleCpiPay = null;
|
|
/// <summary>
|
|
/// 캠페인 수량 조회 정보
|
|
/// </summary>
|
|
protected ArrayList m_alSaleCpiQtyLmt = null;
|
|
|
|
/// <summary>
|
|
/// 캠페인 조건 아이템
|
|
/// </summary>
|
|
protected static Hashtable m_htMstSaleCpi = new Hashtable();
|
|
protected static ArrayList m_alMstSaleCpi = new ArrayList();
|
|
|
|
/// <summary>
|
|
/// 캠페인 카드 마스터
|
|
/// </summary>
|
|
protected static ArrayList m_alMstCpiCard = new ArrayList();
|
|
/// <summary>
|
|
/// 캠페인 출력메시지 마스터
|
|
/// </summary>
|
|
protected static ArrayList m_alMstCpiPrtMsg = new ArrayList();
|
|
|
|
/// <summary>
|
|
/// 거래데이터 합계금액 계산 및 관리
|
|
/// </summary>
|
|
protected IDataProcessUs m_cDataService = null;
|
|
/// <summary>
|
|
/// 판매공통 모듈
|
|
/// </summary>
|
|
protected IDataCommonUs m_cDataCommon = null;
|
|
/// <summary>
|
|
/// 마스터 인터페이스
|
|
/// </summary>
|
|
protected IMasterUs m_cMstService = null;
|
|
/// <summary>
|
|
/// 고객디스플레이 관리
|
|
/// </summary>
|
|
protected ICustDisplayUs m_cCustDisp = null;
|
|
/// <summary>
|
|
/// HP포인트 고객번호
|
|
/// </summary>
|
|
protected string m_sHpCustID = "";
|
|
/// <summary>
|
|
/// 실효포인트
|
|
/// </summary>
|
|
protected double m_nHpExpPoint = 0;
|
|
#endregion
|
|
|
|
#region 생성자
|
|
public CampaignBase()
|
|
{
|
|
m_cPosStatus = (PosStatus)StateObject.POS; // POS 기본정보
|
|
m_cTrnStatus = (TranStatus)StateObject.TRAN; // POS 거래정보
|
|
|
|
m_alTrSaleCpi = (ArrayList)StateObject.GetItemObject(Column.TR_SALE_CPI_RSLT.ITEM); // 캠페인트란 아이템
|
|
m_alTrPluItem = (ArrayList)StateObject.GetItemObject(Column.TR_PLU.ITEM); // 상품 아이템
|
|
m_alSaleCpiPay = (ArrayList)StateObject.GetItemObject(Column.SALE_CPI_PAY.ITEM); // 캠페인결제정보
|
|
m_alSaleCpiQtyLmt = (ArrayList)StateObject.GetItemObject(Column.SALE_CPI_PAY.ITEM); // 수량제한 캠페인 조회 정보
|
|
|
|
m_cDataService = (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);
|
|
m_cMstService = (IMasterUs)sManager.InitServiceInstance(ServiceLists.ASV_MASTER.DLL, ServiceLists.ASV_MASTER.POS_MASTER);
|
|
m_cCustDisp = (ICustDisplayUs)sManager.InitServiceInstance(ServiceLists.ASV_CUSTDISPLAY.DLL, ServiceLists.ASV_CUSTDISPLAY.CUST_DISPLAY);
|
|
}
|
|
#endregion
|
|
|
|
#region CheckCampaignDateTime 캠페인 적용일자 및 시간 체크
|
|
/// <summary>
|
|
/// 캠페인 적용일자 및 시간 체크
|
|
/// </summary>
|
|
/// <param name="cMstSaleCpi"></param>
|
|
/// <returns></returns>
|
|
public bool CheckCampaignDateTime(Column.MST_SALE_CPI.DATA cMstSaleCpi)
|
|
{
|
|
try
|
|
{
|
|
// 행사기간 체크
|
|
if (CmUtil.LongParse(cMstSaleCpi.STARTDAY) > CmUtil.LongParse(m_cTrnStatus.Head.SysYmd)
|
|
|| CmUtil.LongParse(cMstSaleCpi.FNSHDAY) < CmUtil.LongParse(m_cTrnStatus.Head.SysYmd)) return false;
|
|
|
|
DateTime dt = new DateTime(int.Parse(m_cTrnStatus.Head.SysYmd.Substring(0, 4)), int.Parse(m_cTrnStatus.Head.SysYmd.Substring(4, 2)), int.Parse(m_cTrnStatus.Head.SysYmd.Substring(6, 2)));
|
|
// REPT_TYPE(반복 형태) => 1:매주, 2:매월
|
|
if (cMstSaleCpi.REPT_APPNT_TYPE == "1")
|
|
{
|
|
// 반복 주차 체크
|
|
if (cMstSaleCpi.REPT_WEEK.Trim().Length > 0)
|
|
{
|
|
int nWeek = 0;
|
|
int nDay = int.Parse(m_cTrnStatus.Head.SysYmd.Substring(6, 2)) - (int)dt.DayOfWeek;
|
|
while (nDay > 1)
|
|
{
|
|
nDay -= 7;
|
|
nWeek++;
|
|
}
|
|
if (nWeek >= 5) nWeek = 4;
|
|
if (cMstSaleCpi.REPT_WEEK.Substring(nWeek, 1) == "0") return false;
|
|
}
|
|
}
|
|
if (cMstSaleCpi.REPT_APPNT_TYPE == "2")
|
|
{
|
|
// 반복일자 체크
|
|
if (cMstSaleCpi.REPT_DT.Trim().Length > 0)
|
|
{
|
|
if (int.Parse(cMstSaleCpi.REPT_DT) != int.Parse(m_cTrnStatus.Head.SysYmd.Substring(6, 2))) return false;
|
|
}
|
|
}
|
|
|
|
// 캠페인 시간 마스터 체크
|
|
bool bCpiHour = true;
|
|
if (cMstSaleCpi.alDATA_HOUR.Count > 0)
|
|
{
|
|
bCpiHour = false;
|
|
foreach (Column.MST_SALE_CPI.DATA_HOUR cMstCpiHour in cMstSaleCpi.alDATA_HOUR)
|
|
{
|
|
if (CmUtil.IntParse(cMstCpiHour.DOW_DIV) != (int)dt.DayOfWeek + 1) continue;
|
|
|
|
//#14375 PB 카페신촌 - 19일 스마일페이 행사 할인안된이유 확인요청 start,phj
|
|
//캠페인 시간체크 시 시스템 시간으로 체크하도록 변경
|
|
|
|
//기존
|
|
//if (CmUtil.IntParse(cMstCpiHour.START_HOUR) > CmUtil.IntParse(m_cTrnStatus.Head.PayHms.Substring(0, 4))
|
|
// || CmUtil.IntParse(cMstCpiHour.FNSH_HOUR) < CmUtil.IntParse(m_cTrnStatus.Head.PayHms.Substring(0, 4))) continue;
|
|
//변경
|
|
string sNowHour = DateTime.Now.ToString("HHmm");
|
|
if (CmUtil.IntParse(cMstCpiHour.START_HOUR) > CmUtil.IntParse(sNowHour) ||
|
|
CmUtil.IntParse(cMstCpiHour.FNSH_HOUR) < CmUtil.IntParse(sNowHour))
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//#14375 PB 카페신촌 - 19일 스마일페이 행사 할인안된이유 확인요청 end,phj
|
|
|
|
bCpiHour = true;
|
|
}
|
|
}
|
|
if (bCpiHour == false) return false;
|
|
|
|
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;
|
|
}
|
|
#endregion
|
|
|
|
#region 공통 상품행사 계산
|
|
|
|
/// <summary>
|
|
/// 상품별 상품 할인
|
|
/// </summary>
|
|
/// <param name="cMstSaleCpi"></param>
|
|
/// <param name="nPayAmt">결제금액</param>
|
|
/// <returns></returns>
|
|
public double CampaignPluItemDiscount(Column.MST_SALE_CPI.DATA cMstSaleCpi, double nPayAmt)
|
|
{
|
|
return CampaignPluItemDiscount(cMstSaleCpi, nPayAmt, PosConst.PAY_DC_TYPE.DC);
|
|
}
|
|
/// <summary>
|
|
/// 상품별 상품 할인
|
|
/// </summary>
|
|
/// <param name="cMstSaleCpi"></param>
|
|
/// <param name="nPayAmt">결제금액</param>
|
|
/// <param name="sPayDcDiv">결제할인구분</param>
|
|
/// <returns></returns>
|
|
public double CampaignPluItemDiscount(Column.MST_SALE_CPI.DATA cMstSaleCpi, double nPayAmt, string sPayDcDiv)
|
|
{
|
|
double nTotSaleAmt = 0, nTotDisAmt = 0;
|
|
double nSaleAmt = 0, nDisAmt = 0;
|
|
long nTotDisQty = 0, nSaleQty = 0, nDisQty = 0;
|
|
//#20171206 17크리스마스캠페인 start, 20171218
|
|
double nTotCampAmt = 0;
|
|
//#20171206 17크리스마스캠페인 end, 20171218
|
|
try
|
|
{
|
|
if (cMstSaleCpi.alDATA_COMPNT.Count == 0) return 0;
|
|
Column.MST_SALE_CPI.DATA_COMPNT cMstCpiCompnt = (Column.MST_SALE_CPI.DATA_COMPNT)cMstSaleCpi.alDATA_COMPNT[0];
|
|
|
|
// 대상 상품 금액 획득
|
|
GetCampaignSaleQtyAmt(cMstSaleCpi, cMstSaleCpi.CPI_CD, "", "", ref nSaleQty, ref nSaleAmt, sPayDcDiv);
|
|
if (nSaleQty == 0 && nSaleAmt == 0) return 0;
|
|
|
|
// 캠페인 성립금액 구분 체크
|
|
if (CheckCampaignReqAmt(cMstSaleCpi, "", nSaleQty, nSaleAmt ) == false) return 0;
|
|
|
|
for (int i = 0; i < m_alTrPluItem.Count; i++)
|
|
{
|
|
Column.TR_PLU.DATA cSaleItem = (Column.TR_PLU.DATA)m_alTrPluItem[i];
|
|
if (cSaleItem.CANCEL_DIV == PosConst.CANCEL_DIV.CANCEL || cSaleItem.CANCEL_DIV_MAIN == PosConst.CANCEL_DIV.CANCEL) continue; // 지정취소
|
|
|
|
// 상품별 행사 기적용 여부 체크(상품별 행사는 상품별로 한번만 체크)
|
|
bool bExist = false;
|
|
for (int j = 0; j < i; j++)
|
|
{
|
|
Column.TR_PLU.DATA cAgoItem = (Column.TR_PLU.DATA)m_alTrPluItem[j];
|
|
if (cAgoItem.CANCEL_DIV == PosConst.CANCEL_DIV.CANCEL || cAgoItem.CANCEL_DIV_MAIN == PosConst.CANCEL_DIV.CANCEL) continue; // 지정취소
|
|
|
|
if ( cSaleItem.SUB_SHOP_CD == cAgoItem.SUB_SHOP_CD && cSaleItem.ITEM_PLU_CD == cAgoItem.ITEM_PLU_CD)
|
|
{
|
|
bExist = true;
|
|
break;
|
|
}
|
|
}
|
|
if (bExist == true) continue;
|
|
|
|
foreach (Column.TR_SALE_CPI_RSLT.DATA cTrSaleCpi in cSaleItem.alTrSaleCpi)
|
|
{
|
|
if (cMstSaleCpi.CPI_CD == cTrSaleCpi.CPI_CD)
|
|
{
|
|
// 대상 상품 금액 획득
|
|
double nPrice = GetCampaignSaleQtyAmt(cMstSaleCpi, cMstSaleCpi.CPI_CD, "", cTrSaleCpi.SUB_SHOP_CD + cTrSaleCpi.ITEM_PLU_CD, ref nSaleQty, ref nSaleAmt, sPayDcDiv);
|
|
if (nSaleQty <= 0 && nSaleAmt <= 0) continue;
|
|
|
|
// 캠페인 구성 자격 구분에 따른 대상 상품수량 획득
|
|
nDisQty = 0;
|
|
if (cMstCpiCompnt.CPI_COND_TYPE == ItemConst.CPI_COND_TYPE.MATCH_QTY) // 수량
|
|
{
|
|
if (cMstCpiCompnt.QTY_AMT == 0) cMstCpiCompnt.QTY_AMT = 1;
|
|
|
|
nDisQty = nSaleQty /(long)cMstCpiCompnt.QTY_AMT;
|
|
|
|
// 결제캠페인 최소 결제금액 체크
|
|
if (nPayAmt > 0)
|
|
{
|
|
if (nTotSaleAmt == 0 && nPayAmt < CmUtil.DoubleMultiplication(cMstCpiCompnt.QTY_AMT, nPrice)) continue;
|
|
|
|
while (nDisQty > 0)
|
|
{
|
|
if (nPayAmt < CmUtil.DoubleAdd(nTotSaleAmt, CmUtil.DoubleMultiplication(nDisQty * (long)cMstCpiCompnt.QTY_AMT, nPrice)))
|
|
nDisQty--;
|
|
else
|
|
break;
|
|
}
|
|
if (nDisQty == 0) continue;
|
|
}
|
|
if (nSaleQty != nDisQty * (long)cMstCpiCompnt.QTY_AMT)
|
|
{
|
|
nSaleAmt = CmUtil.DoubleMultiplication(nDisQty * (long)cMstCpiCompnt.QTY_AMT, nPrice);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (cMstCpiCompnt.CPI_COND_TYPE == ItemConst.CPI_COND_TYPE.MIN_AMT) // 금액
|
|
{
|
|
if (nSaleAmt >= cMstCpiCompnt.QTY_AMT) nDisQty = nSaleQty;
|
|
// 결제캠페인 최소 결제금액 체크
|
|
if (nPayAmt > 0 && nTotSaleAmt == 0 && nPayAmt < cMstCpiCompnt.QTY_AMT) continue;
|
|
}
|
|
else if (cMstCpiCompnt.CPI_COND_TYPE == ItemConst.CPI_COND_TYPE.MIN_QTY) // 최소수량
|
|
{
|
|
if (nSaleQty >= (long)cMstCpiCompnt.QTY_AMT) nDisQty = nSaleQty;
|
|
// 결제캠페인 최소 결제금액 체크
|
|
if (nPayAmt > 0 && nTotSaleAmt == 0 && nPayAmt < CmUtil.DoubleMultiplication(cMstCpiCompnt.QTY_AMT, nPrice)) continue;
|
|
}
|
|
|
|
// 결제캠페인 결제금액 체크
|
|
if (nPayAmt > 0)
|
|
{
|
|
//#20171206 17크리스마스캠페인 start, 20171218
|
|
//기존
|
|
/*
|
|
while (nDisQty > 0)
|
|
{
|
|
if (nPayAmt < CmUtil.DoubleAdd(nTotSaleAmt, CmUtil.DoubleMultiplication(nDisQty, nPrice)))
|
|
nDisQty--;
|
|
else
|
|
break;
|
|
}
|
|
*/
|
|
//변경
|
|
nTotCampAmt = nTotCampAmt + CmUtil.DoubleMultiplication(nDisQty, nPrice);
|
|
|
|
if (nTotCampAmt > nPayAmt)
|
|
{
|
|
ClearCampaginItem(cMstSaleCpi.CPI_CD);
|
|
return 0;
|
|
}
|
|
//#20171206 17크리스마스캠페인 end, 20171218
|
|
|
|
if (nDisQty == 0) continue;
|
|
|
|
if (nSaleQty != nDisQty) nSaleAmt = CmUtil.DoubleMultiplication(nDisQty, nPrice);
|
|
}
|
|
}
|
|
if (nDisQty == 0) continue;
|
|
|
|
// 캠페인 제한 수량 체크
|
|
nDisQty = CheckCampaignQtyLimit(cMstSaleCpi, nTotDisQty, nDisQty);
|
|
if (nDisQty <= 0) continue;
|
|
|
|
if (cMstCpiCompnt.CPI_COND_TYPE == ItemConst.CPI_COND_TYPE.MATCH_QTY)
|
|
{
|
|
nDisAmt = SetCampaignSaleQtyAmt(cMstSaleCpi, cMstSaleCpi.CPI_CD, "", cTrSaleCpi.SUB_SHOP_CD + cTrSaleCpi.ITEM_PLU_CD, nDisQty * (long)cMstCpiCompnt.QTY_AMT, cMstCpiCompnt.CPI_DC_TYPE, 0, sPayDcDiv);
|
|
if (nDisAmt == 0 && cMstCpiCompnt.CPI_DC_TYPE.Trim() != "" && cMstCpiCompnt.DC_RATE_QTY_AMT > 0)
|
|
{
|
|
if (cMstCpiCompnt.CPI_DC_TYPE == ItemConst.CPI_DC_TYPE.RATE)
|
|
{
|
|
nDisAmt = CmUtil.MathAmtPercent(nSaleAmt, cMstCpiCompnt.DC_RATE_QTY_AMT);
|
|
nDisAmt = CmUtil.MathRounds(nDisAmt, m_cPosStatus.Mst.DcRudDwLocMethd, CmUtil.IntParse(m_cPosStatus.Mst.DcRudDwLoc));
|
|
}
|
|
else
|
|
{
|
|
nDisAmt = CmUtil.DoubleMultiplication(nDisQty, cMstCpiCompnt.DC_RATE_QTY_AMT);
|
|
}
|
|
nDisAmt = SetCampaignSaleDiv(cMstSaleCpi, cMstSaleCpi.CPI_CD, "", cTrSaleCpi.SUB_SHOP_CD + cTrSaleCpi.ITEM_PLU_CD, nDisQty * (long)cMstCpiCompnt.QTY_AMT, nDisAmt, sPayDcDiv);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
nDisAmt = SetCampaignSaleQtyAmt(cMstSaleCpi, cMstSaleCpi.CPI_CD, "", cTrSaleCpi.SUB_SHOP_CD + cTrSaleCpi.ITEM_PLU_CD, nDisQty, cMstCpiCompnt.CPI_DC_TYPE, 0, sPayDcDiv);
|
|
if (nDisAmt == 0 && cMstCpiCompnt.CPI_DC_TYPE.Trim() != "" && cMstCpiCompnt.DC_RATE_QTY_AMT > 0)
|
|
{
|
|
if (cMstCpiCompnt.CPI_DC_TYPE == ItemConst.CPI_DC_TYPE.RATE)
|
|
{
|
|
nDisAmt = CmUtil.MathAmtPercent(nSaleAmt, cMstCpiCompnt.DC_RATE_QTY_AMT);
|
|
nDisAmt = CmUtil.MathRounds(nDisAmt, m_cPosStatus.Mst.DcRudDwLocMethd, CmUtil.IntParse(m_cPosStatus.Mst.DcRudDwLoc));
|
|
}
|
|
else
|
|
{
|
|
nDisAmt = CmUtil.DoubleMultiplication(nDisQty, cMstCpiCompnt.DC_RATE_QTY_AMT);
|
|
}
|
|
nDisAmt = SetCampaignSaleDiv(cMstSaleCpi, cMstSaleCpi.CPI_CD, "", cTrSaleCpi.SUB_SHOP_CD + cTrSaleCpi.ITEM_PLU_CD, nDisQty, nDisAmt, sPayDcDiv);
|
|
}
|
|
}
|
|
|
|
nTotSaleAmt = CmUtil.DoubleAdd(nTotSaleAmt, nSaleAmt);
|
|
nTotDisAmt = CmUtil.DoubleAdd(nTotDisAmt, nDisAmt);
|
|
nTotDisQty += nDisQty;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
// 실효100% 행사 체크
|
|
nTotDisAmt = CheckCampaignExpPointAll(cMstSaleCpi, nTotSaleAmt, nTotDisAmt);
|
|
}
|
|
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 nTotDisAmt;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 상품합산 할인
|
|
/// </summary>
|
|
/// <param name="cMstSaleCpi"></param>
|
|
/// <param name="nPayAmt"></param>
|
|
/// <returns></returns>
|
|
public double CampaignPluSumDiscount(Column.MST_SALE_CPI.DATA cMstSaleCpi, double nPayAmt)
|
|
{
|
|
return CampaignPluSumDiscount(cMstSaleCpi, nPayAmt, PosConst.PAY_DC_TYPE.DC);
|
|
}
|
|
/// <summary>
|
|
/// 상품합산 할인
|
|
/// </summary>
|
|
/// <param name="cMstSaleCpi"></param>
|
|
/// <param name="nPayAmt"></param>
|
|
/// <param name="sPayDcDiv"></param>
|
|
/// <returns></returns>
|
|
public double CampaignPluSumDiscount(Column.MST_SALE_CPI.DATA cMstSaleCpi, double nPayAmt, string sPayDcDiv)
|
|
{
|
|
double nSaleAmt = 0, nDisAmt = 0;
|
|
long nSaleQty = 0, nDisQty = 0;
|
|
long nCompntRow = -1, nCompntQty = 0; // 구성자격구분 적용 행
|
|
double nCompntAmt = 0, nDisSaleAmt = 0;
|
|
try
|
|
{
|
|
// 대상 상품 금액 획득
|
|
double nPrice = GetCampaignSaleQtyAmt(cMstSaleCpi, cMstSaleCpi.CPI_CD, "", "", ref nSaleQty, ref nSaleAmt, sPayDcDiv);
|
|
if (nSaleQty == 0 && nSaleAmt == 0) return 0;
|
|
|
|
// 캠페인 성립금액 구분 체크
|
|
if (CheckCampaignReqAmt(cMstSaleCpi, "", nSaleQty, nSaleAmt) == false) return 0;
|
|
|
|
// 구성 자격 구분 체크
|
|
Column.MST_SALE_CPI.DATA_COMPNT cMstCpiCompnt;
|
|
for (int i = 0; i < cMstSaleCpi.alDATA_COMPNT.Count; i++)
|
|
{
|
|
cMstCpiCompnt = (Column.MST_SALE_CPI.DATA_COMPNT)cMstSaleCpi.alDATA_COMPNT[i];
|
|
|
|
nCompntQty = 0;
|
|
nCompntAmt = nSaleAmt;
|
|
// 캠페인 구성 자격 구분에 따른 대상 상품수량 획득
|
|
if (cMstCpiCompnt.CPI_COND_TYPE == ItemConst.CPI_COND_TYPE.MATCH_QTY) // 수량
|
|
{
|
|
if (cMstCpiCompnt.QTY_AMT == 0) cMstCpiCompnt.QTY_AMT = 1;
|
|
|
|
nCompntQty = nSaleQty / (long)cMstCpiCompnt.QTY_AMT;
|
|
|
|
// 결제캠페인 최소 결제금액 체크
|
|
if (nPayAmt > 0 && nPayAmt < nCompntAmt)
|
|
{
|
|
while (nCompntQty > 0)
|
|
{
|
|
nCompntAmt = GetCampaignMaxQtyToSaleAmt(cMstSaleCpi, cMstSaleCpi.CPI_CD, "", "", nCompntQty * (long)cMstCpiCompnt.QTY_AMT, sPayDcDiv);
|
|
if (nPayAmt < nCompntAmt)
|
|
nCompntQty--;
|
|
else
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (nSaleQty != nCompntQty * (long)cMstCpiCompnt.QTY_AMT)
|
|
{
|
|
nCompntAmt = GetCampaignMaxQtyToSaleAmt(cMstSaleCpi, cMstSaleCpi.CPI_CD, "", "", nCompntQty * (long)cMstCpiCompnt.QTY_AMT, sPayDcDiv);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (cMstCpiCompnt.CPI_COND_TYPE == ItemConst.CPI_COND_TYPE.MIN_AMT) // 금액
|
|
{
|
|
if (nSaleAmt >= cMstCpiCompnt.QTY_AMT) nCompntQty = nSaleQty;
|
|
// 결제캠페인 최소 결제금액 체크
|
|
if (nPayAmt > 0 && nPayAmt < cMstCpiCompnt.QTY_AMT) break;
|
|
}
|
|
else if (cMstCpiCompnt.CPI_COND_TYPE == ItemConst.CPI_COND_TYPE.MIN_QTY) // 최소수량
|
|
{
|
|
if (nSaleQty >= (long)cMstCpiCompnt.QTY_AMT) nCompntQty = nSaleQty;
|
|
// 결제캠페인 최소 결제금액 체크
|
|
if (nPayAmt > 0 && nPayAmt < nCompntAmt)
|
|
{
|
|
nCompntAmt = GetCampaignMaxQtyToSaleAmt(cMstSaleCpi, cMstSaleCpi.CPI_CD, "", "", (long)cMstCpiCompnt.QTY_AMT, sPayDcDiv);
|
|
if (nPayAmt < nCompntAmt) break;
|
|
}
|
|
}
|
|
// 결제캠페인 결제금액 체크
|
|
if (nPayAmt > 0)
|
|
{
|
|
while (nCompntQty > 0)
|
|
{
|
|
nCompntAmt = GetCampaignMaxQtyToSaleAmt(cMstSaleCpi, cMstSaleCpi.CPI_CD, "", "", nCompntQty, sPayDcDiv);
|
|
if (nPayAmt < nCompntAmt)
|
|
nCompntQty--;
|
|
else
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
if (nCompntQty == 0) break;
|
|
|
|
// 구성 자격 적용 행
|
|
nCompntRow = i;
|
|
nDisQty = nCompntQty; // 할인대상수량
|
|
nDisSaleAmt = nCompntAmt; // 할인대상금액
|
|
}
|
|
if (nCompntRow == -1) return 0;
|
|
|
|
cMstCpiCompnt = (Column.MST_SALE_CPI.DATA_COMPNT)cMstSaleCpi.alDATA_COMPNT[(int)nCompntRow];
|
|
|
|
if (cMstCpiCompnt.CPI_COND_TYPE == ItemConst.CPI_COND_TYPE.MATCH_QTY)
|
|
{
|
|
// 수량 단위로 캠페인 적용
|
|
if (cMstCpiCompnt.CPI_DC_TYPE == ItemConst.CPI_DC_TYPE.RATE)
|
|
{
|
|
nDisAmt = CmUtil.MathAmtPercent(nDisSaleAmt, cMstCpiCompnt.DC_RATE_QTY_AMT);
|
|
nDisAmt = CmUtil.MathRounds(nDisAmt, m_cPosStatus.Mst.DcRudDwLocMethd, CmUtil.IntParse(m_cPosStatus.Mst.DcRudDwLoc));
|
|
|
|
if (cMstCpiCompnt.DC_MAX_AMT > 0 && cMstCpiCompnt.DC_MAX_AMT < nDisAmt) nDisAmt = cMstCpiCompnt.DC_MAX_AMT;
|
|
}
|
|
else if (cMstCpiCompnt.CPI_DC_TYPE == ItemConst.CPI_DC_TYPE.AMT)
|
|
{
|
|
nDisAmt = CmUtil.DoubleMultiplication(nDisQty, cMstCpiCompnt.DC_RATE_QTY_AMT);
|
|
}
|
|
else
|
|
{
|
|
nDisSaleAmt = GetCampaignMaxQtyToSaleAmt(cMstSaleCpi, cMstSaleCpi.CPI_CD, "", "", nDisQty * (long)cMstCpiCompnt.QTY_AMT, sPayDcDiv);
|
|
|
|
nDisAmt = CmUtil.DoubleSubtraction(nDisSaleAmt, CmUtil.DoubleMultiplication(nDisQty, cMstCpiCompnt.DC_RATE_QTY_AMT));
|
|
if (nDisAmt < 0) nDisAmt = 0;
|
|
}
|
|
nDisAmt = SetCampaignSaleDiv(cMstSaleCpi, cMstSaleCpi.CPI_CD, "", "", nDisQty * (long)cMstCpiCompnt.QTY_AMT, nDisAmt, sPayDcDiv);
|
|
}
|
|
else
|
|
{
|
|
if (cMstCpiCompnt.CPI_DC_TYPE == ItemConst.CPI_DC_TYPE.RATE)
|
|
{
|
|
nDisAmt = CmUtil.MathAmtPercent(nDisSaleAmt, cMstCpiCompnt.DC_RATE_QTY_AMT);
|
|
nDisAmt = CmUtil.MathRounds(nDisAmt, m_cPosStatus.Mst.DcRudDwLocMethd, CmUtil.IntParse(m_cPosStatus.Mst.DcRudDwLoc));
|
|
|
|
if (cMstCpiCompnt.DC_MAX_AMT > 0 && cMstCpiCompnt.DC_MAX_AMT < nDisAmt) nDisAmt = cMstCpiCompnt.DC_MAX_AMT;
|
|
}
|
|
else
|
|
{
|
|
nDisAmt = cMstCpiCompnt.DC_RATE_QTY_AMT;
|
|
}
|
|
nDisAmt = SetCampaignSaleDiv(cMstSaleCpi, cMstSaleCpi.CPI_CD, "", "", 0, nDisAmt, sPayDcDiv);
|
|
}
|
|
|
|
// 실효100% 행사 체크
|
|
nDisAmt = CheckCampaignExpPointAll(cMstSaleCpi, nDisSaleAmt, nDisAmt);
|
|
}
|
|
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 nDisAmt;
|
|
}
|
|
|
|
/// <summary>
|
|
/// M+N 행사
|
|
/// </summary>
|
|
/// <param name="cMstSaleCpi"></param>
|
|
/// <param name="nPayAmt"></param>
|
|
/// <returns></returns>
|
|
public double CampaignPlusOneDiscount(Column.MST_SALE_CPI.DATA cMstSaleCpi, double nPayAmt)
|
|
{
|
|
return CampaignPlusOneDiscount(cMstSaleCpi, nPayAmt, PosConst.PAY_DC_TYPE.DC);
|
|
}
|
|
/// <summary>
|
|
/// M+N 행사
|
|
/// </summary>
|
|
/// <param name="cMstSaleCpi"></param>
|
|
/// <param name="nPayAmt"></param>
|
|
/// <param name="sPayDcDiv"></param>
|
|
/// <returns></returns>
|
|
public double CampaignPlusOneDiscount(Column.MST_SALE_CPI.DATA cMstSaleCpi, double nPayAmt, string sPayDcDiv)
|
|
{
|
|
double nSaleAmt = 0, nDisAmt = 0;
|
|
long nSaleQty = 0, nDisQty = 0, nCpiQty = 0;
|
|
try
|
|
{
|
|
if (cMstSaleCpi.alDATA_COMPNT.Count == 0) return 0;
|
|
Column.MST_SALE_CPI.DATA_COMPNT cMstCpiCompnt = (Column.MST_SALE_CPI.DATA_COMPNT)cMstSaleCpi.alDATA_COMPNT[0];
|
|
|
|
double nPrice = GetCampaignSaleQtyAmt(cMstSaleCpi, cMstSaleCpi.CPI_CD, "", "", ref nSaleQty, ref nSaleAmt, sPayDcDiv);
|
|
if (nSaleQty == 0 && nSaleAmt == 0) return 0;
|
|
|
|
// 캠페인 성립금액 구분 체크
|
|
if (CheckCampaignReqAmt(cMstSaleCpi, "", nSaleQty, nSaleAmt) == false) return 0;
|
|
|
|
if (cMstCpiCompnt.QTY_AMT == 0 || cMstCpiCompnt.DC_RATE_QTY_AMT == 0) return 0;
|
|
|
|
// 행사 성립수량(M+N);
|
|
nCpiQty = (long)cMstCpiCompnt.QTY_AMT + (long)cMstCpiCompnt.DC_RATE_QTY_AMT;
|
|
|
|
// +N 수량
|
|
nDisQty = nSaleQty / nCpiQty;
|
|
if (nPayAmt > 0) // 카드행사
|
|
{
|
|
while (nDisQty > 0)
|
|
{
|
|
if (nPayAmt < CmUtil.DoubleMultiplication(nDisQty * nCpiQty, nPrice))
|
|
nDisQty--;
|
|
else
|
|
break;
|
|
}
|
|
}
|
|
if (nDisQty == 0) return 0;
|
|
|
|
// 조건수량 행사 적용
|
|
SetCampaignQtyDiv(cMstSaleCpi, cMstSaleCpi.CPI_CD, "", "", nDisQty * (long)cMstCpiCompnt.QTY_AMT, sPayDcDiv);
|
|
|
|
// 증정수량 행사 적용
|
|
nDisAmt = SetCampaignSaleFreeGiftPlusN(cMstSaleCpi, cMstSaleCpi.CPI_CD, "", "", nDisQty * (long)cMstCpiCompnt.DC_RATE_QTY_AMT, false, sPayDcDiv);
|
|
|
|
// 실효100% 행사 체크
|
|
nDisAmt = CheckCampaignExpPointAll(cMstSaleCpi, nSaleAmt, nDisAmt);
|
|
}
|
|
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 nDisAmt;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 연계(결합) 할인
|
|
/// </summary>
|
|
/// <param name="cMstSaleCpi"></param>
|
|
/// <param name="nPayAmt"></param>
|
|
/// <returns></returns>
|
|
public double CampaignLinkPluDiscount(Column.MST_SALE_CPI.DATA cMstSaleCpi, double nPayAmt)
|
|
{
|
|
return CampaignLinkPluDiscount(cMstSaleCpi, nPayAmt, PosConst.PAY_DC_TYPE.DC);
|
|
}
|
|
/// <summary>
|
|
/// 연계(결합) 할인
|
|
/// </summary>
|
|
/// <param name="cMstSaleCpi"></param>
|
|
/// <param name="nPayAmt"></param>
|
|
/// <returns></returns>
|
|
public double CampaignLinkPluDiscount(Column.MST_SALE_CPI.DATA cMstSaleCpi, double nPayAmt, string sPayDcDiv)
|
|
{
|
|
double nTotSaleAmt = 0, nTotDisAmt = 0, nTotSetAmt = 0;
|
|
double nSaleAmt = 0, nDisAmt = 0;
|
|
long nSaleQty = 0, nDisQty = 0, nMatchQty = 0;
|
|
|
|
try
|
|
{
|
|
GetCampaignSaleQtyAmt(cMstSaleCpi, cMstSaleCpi.CPI_CD, "", "", ref nSaleQty, ref nSaleAmt, sPayDcDiv);
|
|
if (nSaleQty == 0 && nSaleAmt == 0) return 0;
|
|
|
|
// 캠페인 성립금액 구분 체크
|
|
if (CheckCampaignReqAmt(cMstSaleCpi, "", nSaleQty, nSaleAmt) == false) return 0;
|
|
|
|
for (int i = 0; i < cMstSaleCpi.alDATA_COMPNT.Count; i++)
|
|
{
|
|
Column.MST_SALE_CPI.DATA_COMPNT cMstCpiCompnt = (Column.MST_SALE_CPI.DATA_COMPNT)cMstSaleCpi.alDATA_COMPNT[i];
|
|
|
|
// 대상 상품 금액 획득
|
|
double nPrice = GetCampaignSaleQtyAmt(cMstSaleCpi, cMstSaleCpi.CPI_CD, cMstCpiCompnt.CPI_ITEM_GRP_CD, "", ref nSaleQty, ref nSaleAmt, sPayDcDiv);
|
|
|
|
// 캠페인 구성 자격 구분에 따른 대상 상품수량 획득
|
|
if (cMstCpiCompnt.QTY_AMT == 0) cMstCpiCompnt.QTY_AMT = 1;
|
|
|
|
nDisQty = GetCampaignDisQtyCompntReqDiv(cMstCpiCompnt.CPI_COND_TYPE, cMstCpiCompnt.QTY_AMT, nSaleQty, nSaleAmt);
|
|
if (nDisQty == 0) return 0;
|
|
|
|
if (nMatchQty == 0 || nMatchQty > nDisQty) nMatchQty = nDisQty;
|
|
|
|
// 연계세트당 구성금액 계산
|
|
if (cMstCpiCompnt.CPI_COND_TYPE == ItemConst.CPI_COND_TYPE.MIN_AMT) // 금액
|
|
nTotSetAmt = CmUtil.DoubleAdd(nTotSetAmt, cMstCpiCompnt.QTY_AMT);
|
|
else
|
|
nTotSetAmt = CmUtil.DoubleAdd(nTotSetAmt, CmUtil.DoubleMultiplication(nPrice, cMstCpiCompnt.QTY_AMT));
|
|
}
|
|
|
|
if (nPayAmt > 0) // 결제(카드) 행사
|
|
{
|
|
while (nMatchQty > 0)
|
|
{
|
|
if (nPayAmt < CmUtil.DoubleMultiplication(nMatchQty, nTotSetAmt))
|
|
nMatchQty--;
|
|
else
|
|
break;
|
|
}
|
|
}
|
|
if (nMatchQty == 0) return 0;
|
|
|
|
for (int i = 0; i < cMstSaleCpi.alDATA_COMPNT.Count; i++)
|
|
{
|
|
Column.MST_SALE_CPI.DATA_COMPNT cMstCpiCompnt = (Column.MST_SALE_CPI.DATA_COMPNT)cMstSaleCpi.alDATA_COMPNT[i];
|
|
|
|
// 대상 상품 금액 획득
|
|
double nPrice = GetCampaignSaleQtyAmt(cMstSaleCpi, cMstSaleCpi.CPI_CD, cMstCpiCompnt.CPI_ITEM_GRP_CD, "", ref nSaleQty, ref nSaleAmt, sPayDcDiv);
|
|
nDisAmt = 0;
|
|
if (cMstCpiCompnt.DC_RATE_QTY_AMT > 0)
|
|
{
|
|
if (cMstCpiCompnt.CPI_COND_TYPE == ItemConst.CPI_COND_TYPE.MATCH_QTY)
|
|
{
|
|
// 수량 단위로 캠페인 적용
|
|
if (cMstCpiCompnt.CPI_DC_TYPE == ItemConst.CPI_DC_TYPE.RATE)
|
|
{
|
|
nSaleAmt = GetCampaignMaxQtyToSaleAmt(cMstSaleCpi, cMstSaleCpi.CPI_CD, cMstCpiCompnt.CPI_ITEM_GRP_CD, "", nMatchQty * (long)cMstCpiCompnt.QTY_AMT, sPayDcDiv);
|
|
|
|
nDisAmt = CmUtil.MathAmtPercent(nSaleAmt, cMstCpiCompnt.DC_RATE_QTY_AMT);
|
|
nDisAmt = CmUtil.MathRounds(nDisAmt, m_cPosStatus.Mst.DcRudDwLocMethd, CmUtil.IntParse(m_cPosStatus.Mst.DcRudDwLoc));
|
|
|
|
if (cMstCpiCompnt.DC_MAX_AMT > 0 && cMstCpiCompnt.DC_MAX_AMT < nDisAmt) nDisAmt = cMstCpiCompnt.DC_MAX_AMT;
|
|
}
|
|
else if (cMstCpiCompnt.CPI_DC_TYPE == ItemConst.CPI_DC_TYPE.AMT)
|
|
{
|
|
nDisAmt = CmUtil.DoubleMultiplication(nMatchQty, cMstCpiCompnt.DC_RATE_QTY_AMT);
|
|
}
|
|
//#20171128 결합캠페인 할인유형 추가(1:율, 2:금액, 3:판매금액) start
|
|
|
|
else if (cMstCpiCompnt.CPI_DC_TYPE == ItemConst.CPI_DC_TYPE.PRICE)
|
|
{
|
|
nSaleAmt = GetCampaignMaxQtyToSaleAmt(cMstSaleCpi, cMstSaleCpi.CPI_CD, cMstCpiCompnt.CPI_ITEM_GRP_CD, "", nMatchQty * (long)cMstCpiCompnt.QTY_AMT, sPayDcDiv);
|
|
|
|
nDisAmt = CmUtil.DoubleSubtraction(nSaleAmt, CmUtil.DoubleMultiplication(nMatchQty, cMstCpiCompnt.DC_RATE_QTY_AMT));
|
|
if (nDisAmt < 0) nDisAmt = 0;
|
|
}
|
|
|
|
//#20171128 결합캠페인 할인유형 추가(1:율, 2:금액, 3:판매금액) end
|
|
else
|
|
{
|
|
nSaleAmt = GetCampaignMaxQtyToSaleAmt(cMstSaleCpi, cMstSaleCpi.CPI_CD, cMstCpiCompnt.CPI_ITEM_GRP_CD, "", nMatchQty * (long)cMstCpiCompnt.QTY_AMT, sPayDcDiv);
|
|
|
|
nDisAmt = CmUtil.DoubleSubtraction(nSaleAmt, CmUtil.DoubleMultiplication(nMatchQty, cMstCpiCompnt.DC_RATE_QTY_AMT));
|
|
if (nDisAmt < 0) nDisAmt = 0;
|
|
}
|
|
nDisAmt = SetCampaignSaleDiv(cMstSaleCpi, cMstSaleCpi.CPI_CD, cMstCpiCompnt.CPI_ITEM_GRP_CD, "", nMatchQty * (long)cMstCpiCompnt.QTY_AMT, nDisAmt, sPayDcDiv);
|
|
}
|
|
else
|
|
{
|
|
if (cMstCpiCompnt.CPI_DC_TYPE == ItemConst.CPI_DC_TYPE.RATE)
|
|
{
|
|
nDisAmt = CmUtil.MathAmtPercent(nSaleAmt, cMstCpiCompnt.DC_RATE_QTY_AMT);
|
|
nDisAmt = CmUtil.MathRounds(nDisAmt, m_cPosStatus.Mst.DcRudDwLocMethd, CmUtil.IntParse(m_cPosStatus.Mst.DcRudDwLoc));
|
|
|
|
if (cMstCpiCompnt.DC_MAX_AMT > 0 && cMstCpiCompnt.DC_MAX_AMT < nDisAmt) nDisAmt = cMstCpiCompnt.DC_MAX_AMT;
|
|
}
|
|
else
|
|
{
|
|
nDisAmt = cMstCpiCompnt.DC_RATE_QTY_AMT;
|
|
}
|
|
nDisAmt = SetCampaignSaleDiv(cMstSaleCpi, cMstSaleCpi.CPI_CD, cMstCpiCompnt.CPI_ITEM_GRP_CD, "", 0, nDisAmt, sPayDcDiv);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// 캠페인 성립 수량 설정
|
|
if (cMstCpiCompnt.CPI_COND_TYPE == ItemConst.CPI_COND_TYPE.MATCH_QTY)
|
|
{
|
|
SetCampaignQtyDiv(cMstSaleCpi, cMstSaleCpi.CPI_CD, cMstCpiCompnt.CPI_ITEM_GRP_CD, "", nMatchQty * (long)cMstCpiCompnt.QTY_AMT, sPayDcDiv);
|
|
}
|
|
else
|
|
{
|
|
SetCampaignQtyDiv(cMstSaleCpi, cMstSaleCpi.CPI_CD, cMstCpiCompnt.CPI_ITEM_GRP_CD, "", nSaleQty, sPayDcDiv);
|
|
}
|
|
}
|
|
nTotSaleAmt = CmUtil.DoubleAdd(nTotSaleAmt, nSaleAmt);
|
|
nTotDisAmt = CmUtil.DoubleAdd(nTotDisAmt, nDisAmt);
|
|
}
|
|
|
|
// 실효100% 행사 체크
|
|
nTotDisAmt = CheckCampaignExpPointAll(cMstSaleCpi, nTotSaleAmt, nTotDisAmt);
|
|
}
|
|
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 nTotDisAmt;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 전체상품 할인
|
|
/// </summary>
|
|
/// <param name="cMstSaleCpi"></param>
|
|
/// <param name="nPayAmt"></param>
|
|
/// <returns></returns>
|
|
public double CampaignRectSumDiscount(Column.MST_SALE_CPI.DATA cMstSaleCpi, double nPayAmt)
|
|
{
|
|
return CampaignRectSumDiscount(cMstSaleCpi, nPayAmt, PosConst.PAY_DC_TYPE.DC);
|
|
}
|
|
/// <summary>
|
|
/// 전체상품 할인
|
|
/// </summary>
|
|
/// <param name="cMstSaleCpi"></param>
|
|
/// <param name="nPayAmt"></param>
|
|
/// <returns></returns>
|
|
public double CampaignRectSumDiscount(Column.MST_SALE_CPI.DATA cMstSaleCpi, double nPayAmt, string sPayDcDiv)
|
|
{
|
|
double nSaleAmt = 0, nDisAmt = 0;
|
|
long nSaleQty = 0, nDisQty = 0;
|
|
long nCompntRow = -1, nCompntQty = 0; // 구성자격구분 적용 행
|
|
double nCompntAmt = 0, nDisSaleAmt = 0;
|
|
|
|
try
|
|
{
|
|
// 대상 상품 금액 획득
|
|
double nPrice = GetCampaignSaleQtyAmt(cMstSaleCpi, cMstSaleCpi.CPI_CD, "", "", ref nSaleQty, ref nSaleAmt, sPayDcDiv);
|
|
if (nSaleQty == 0 && nSaleAmt == 0) return 0;
|
|
|
|
// 캠페인 성립금액 구분 체크
|
|
if (CheckCampaignReqAmt(cMstSaleCpi, "", nSaleQty, nSaleAmt) == false) return 0;
|
|
|
|
if (nPayAmt > 0 && cMstSaleCpi.TRGT_AMT > nPayAmt) return 0; // 카드행사
|
|
|
|
// 구성 자격 구분 체크
|
|
Column.MST_SALE_CPI.DATA_COMPNT cMstCpiCompnt;
|
|
for (int i = 0; i < cMstSaleCpi.alDATA_COMPNT.Count; i++)
|
|
{
|
|
cMstCpiCompnt = (Column.MST_SALE_CPI.DATA_COMPNT)cMstSaleCpi.alDATA_COMPNT[i];
|
|
|
|
nCompntQty = 0;
|
|
nCompntAmt = nSaleAmt;
|
|
// 캠페인 구성 자격 구분에 따른 대상 상품수량 획득
|
|
if (cMstCpiCompnt.CPI_COND_TYPE == ItemConst.CPI_COND_TYPE.MATCH_QTY) // 수량
|
|
{
|
|
if (cMstCpiCompnt.QTY_AMT == 0) cMstCpiCompnt.QTY_AMT = 1;
|
|
|
|
nCompntQty = nSaleQty / (long)cMstCpiCompnt.QTY_AMT;
|
|
|
|
// 결제캠페인 최소 결제금액 체크
|
|
if (nPayAmt > 0 && nPayAmt < nCompntAmt)
|
|
{
|
|
while (nCompntQty > 0)
|
|
{
|
|
nCompntAmt = GetCampaignMaxQtyToSaleAmt(cMstSaleCpi, cMstSaleCpi.CPI_CD, "", "", nCompntQty * (long)cMstCpiCompnt.QTY_AMT, sPayDcDiv);
|
|
if (nPayAmt < nCompntAmt)
|
|
nCompntQty--;
|
|
else
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (nSaleQty != nCompntQty * (long)cMstCpiCompnt.QTY_AMT)
|
|
{
|
|
nCompntAmt = GetCampaignMaxQtyToSaleAmt(cMstSaleCpi, cMstSaleCpi.CPI_CD, "", "", nCompntQty * (long)cMstCpiCompnt.QTY_AMT, sPayDcDiv);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (cMstCpiCompnt.CPI_COND_TYPE == ItemConst.CPI_COND_TYPE.MIN_AMT) // 금액
|
|
{
|
|
if (nSaleAmt >= cMstCpiCompnt.QTY_AMT) nCompntQty = nSaleQty;
|
|
// 결제캠페인 최소 결제금액 체크
|
|
if (nPayAmt > 0 && nPayAmt < cMstCpiCompnt.QTY_AMT) break;
|
|
}
|
|
else if (cMstCpiCompnt.CPI_COND_TYPE == ItemConst.CPI_COND_TYPE.MIN_QTY) // 최소수량
|
|
{
|
|
if (nSaleQty >= (long)cMstCpiCompnt.QTY_AMT) nCompntQty = nSaleQty;
|
|
// 결제캠페인 최소 결제금액 체크
|
|
if (nPayAmt > 0 && nPayAmt < nCompntAmt)
|
|
{
|
|
nCompntAmt = GetCampaignMaxQtyToSaleAmt(cMstSaleCpi, cMstSaleCpi.CPI_CD, "", "", (long)cMstCpiCompnt.QTY_AMT, sPayDcDiv);
|
|
if (nPayAmt < nCompntAmt) break;
|
|
}
|
|
}
|
|
// 결제캠페인 결제금액 체크
|
|
if (nPayAmt > 0)
|
|
{
|
|
while (nCompntQty > 0)
|
|
{
|
|
nCompntAmt = GetCampaignMaxQtyToSaleAmt(cMstSaleCpi, cMstSaleCpi.CPI_CD, "", "", nCompntQty, sPayDcDiv);
|
|
if (nPayAmt < nCompntAmt)
|
|
nCompntQty--;
|
|
else
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
if (nCompntQty == 0) break;
|
|
|
|
// 구성 자격 적용 행
|
|
nCompntRow = i;
|
|
nDisQty = nCompntQty;
|
|
nDisSaleAmt = nCompntAmt;
|
|
}
|
|
if (nCompntRow == -1) return 0;
|
|
|
|
cMstCpiCompnt = (Column.MST_SALE_CPI.DATA_COMPNT)cMstSaleCpi.alDATA_COMPNT[(int)nCompntRow];
|
|
|
|
if (cMstCpiCompnt.CPI_COND_TYPE == ItemConst.CPI_COND_TYPE.MATCH_QTY)
|
|
{
|
|
// 수량 단위로 캠페인 적용
|
|
if (cMstCpiCompnt.CPI_DC_TYPE == ItemConst.CPI_DC_TYPE.RATE)
|
|
{
|
|
nDisAmt = CmUtil.MathAmtPercent(nDisSaleAmt, cMstCpiCompnt.DC_RATE_QTY_AMT);
|
|
nDisAmt = CmUtil.MathRounds(nDisAmt, m_cPosStatus.Mst.DcRudDwLocMethd, CmUtil.IntParse(m_cPosStatus.Mst.DcRudDwLoc));
|
|
|
|
if (cMstCpiCompnt.DC_MAX_AMT > 0 && cMstCpiCompnt.DC_MAX_AMT < nDisAmt) nDisAmt = cMstCpiCompnt.DC_MAX_AMT;
|
|
}
|
|
else
|
|
{
|
|
nDisAmt = CmUtil.DoubleMultiplication(nDisQty, cMstCpiCompnt.DC_RATE_QTY_AMT);
|
|
}
|
|
nDisAmt = SetCampaignSaleDiv(cMstSaleCpi, cMstSaleCpi.CPI_CD, "", "", nDisQty * (long)cMstCpiCompnt.QTY_AMT, nDisAmt, sPayDcDiv);
|
|
}
|
|
else
|
|
{
|
|
if (cMstCpiCompnt.CPI_DC_TYPE == ItemConst.CPI_DC_TYPE.RATE)
|
|
{
|
|
nDisAmt = CmUtil.MathAmtPercent(nDisSaleAmt, cMstCpiCompnt.DC_RATE_QTY_AMT);
|
|
nDisAmt = CmUtil.MathRounds(nDisAmt, m_cPosStatus.Mst.DcRudDwLocMethd, CmUtil.IntParse(m_cPosStatus.Mst.DcRudDwLoc));
|
|
|
|
if (cMstCpiCompnt.DC_MAX_AMT > 0 && cMstCpiCompnt.DC_MAX_AMT < nDisAmt) nDisAmt = cMstCpiCompnt.DC_MAX_AMT;
|
|
}
|
|
else
|
|
{
|
|
nDisAmt = cMstCpiCompnt.DC_RATE_QTY_AMT;
|
|
}
|
|
nDisAmt = SetCampaignSaleDiv(cMstSaleCpi, cMstSaleCpi.CPI_CD, "", "", 0, nDisAmt, sPayDcDiv);
|
|
}
|
|
|
|
// 실효100% 행사 체크
|
|
nDisAmt = CheckCampaignExpPointAll(cMstSaleCpi, nDisSaleAmt, nDisAmt);
|
|
}
|
|
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 nDisAmt;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 결제금액 할인
|
|
/// </summary>
|
|
/// <param name="cMstSaleCpi"></param>
|
|
/// <param name="nPayAmt"></param>
|
|
/// <returns></returns>
|
|
public double CampaignPaymentDiscount(Column.MST_SALE_CPI.DATA cMstSaleCpi, double nPayAmt)
|
|
{
|
|
return CampaignPaymentDiscount(cMstSaleCpi, nPayAmt, PosConst.PAY_DC_TYPE.DC);
|
|
}
|
|
/// <summary>
|
|
/// 결제금액 할인
|
|
/// </summary>
|
|
/// <param name="cMstSaleCpi"></param>
|
|
/// <param name="nPayAmt"></param>
|
|
/// <returns></returns>
|
|
public double CampaignPaymentDiscount(Column.MST_SALE_CPI.DATA cMstSaleCpi, double nPayAmt, string sPayDcDiv)
|
|
{
|
|
double nSaleAmt = 0, nDisAmt = 0;
|
|
long nSaleQty = 0, nDisQty = 0;
|
|
long nCompntRow = -1, nCompntQty = 0; // 구성자격구분 적용 행
|
|
double nCompntAmt = 0, nDisSaleAmt = 0;
|
|
|
|
//#20171206 17크리스마스캠페인 start, 20171218
|
|
double nTotCampAmt = 0;
|
|
//#20171206 17크리스마스캠페인 end, 20171218
|
|
|
|
try
|
|
{
|
|
// 대상 상품 금액 획득
|
|
double nPrice = GetCampaignSaleQtyAmt(cMstSaleCpi, cMstSaleCpi.CPI_CD, "", "", ref nSaleQty, ref nSaleAmt, sPayDcDiv);
|
|
if (nSaleQty == 0 && nSaleAmt == 0) return 0;
|
|
|
|
// 캠페인 성립금액 구분 체크
|
|
if (CheckCampaignReqAmt(cMstSaleCpi, "", nSaleQty, nSaleAmt) == false) return 0;
|
|
|
|
if (cMstSaleCpi.TRGT_AMT > nPayAmt) return 0; // 결제행사
|
|
|
|
// 구성 자격 구분 체크
|
|
Column.MST_SALE_CPI.DATA_COMPNT cMstCpiCompnt;
|
|
for (int i = 0; i < cMstSaleCpi.alDATA_COMPNT.Count; i++)
|
|
{
|
|
cMstCpiCompnt = (Column.MST_SALE_CPI.DATA_COMPNT)cMstSaleCpi.alDATA_COMPNT[i];
|
|
nCompntQty = 0;
|
|
nCompntAmt = nSaleAmt;
|
|
// 캠페인 구성 자격 구분에 따른 대상 상품수량 획득
|
|
if (cMstCpiCompnt.CPI_COND_TYPE == ItemConst.CPI_COND_TYPE.MATCH_QTY) // 수량
|
|
{
|
|
if (cMstCpiCompnt.QTY_AMT == 0) cMstCpiCompnt.QTY_AMT = 1;
|
|
|
|
nCompntQty = nSaleQty / (long)cMstCpiCompnt.QTY_AMT;
|
|
|
|
// 결제캠페인 최소 결제금액 체크
|
|
if (nPayAmt > 0 && nPayAmt < nCompntAmt)
|
|
{
|
|
while (nCompntQty > 0)
|
|
{
|
|
nCompntAmt = GetCampaignMaxQtyToSaleAmt(cMstSaleCpi, cMstSaleCpi.CPI_CD, "", "", nCompntQty * (long)cMstCpiCompnt.QTY_AMT, sPayDcDiv);
|
|
if (nPayAmt < nCompntAmt)
|
|
nCompntQty--;
|
|
else
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (nSaleQty != nCompntQty * (long)cMstCpiCompnt.QTY_AMT)
|
|
{
|
|
nCompntAmt = GetCampaignMaxQtyToSaleAmt(cMstSaleCpi, cMstSaleCpi.CPI_CD, "", "", nCompntQty * (long)cMstCpiCompnt.QTY_AMT, sPayDcDiv);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (cMstCpiCompnt.CPI_COND_TYPE == ItemConst.CPI_COND_TYPE.MIN_AMT) // 금액
|
|
{
|
|
if (nSaleAmt >= cMstCpiCompnt.QTY_AMT) nCompntQty = nSaleQty;
|
|
// 결제캠페인 최소 결제금액 체크
|
|
if (nPayAmt > 0 && nPayAmt < cMstCpiCompnt.QTY_AMT) break;
|
|
}
|
|
else if (cMstCpiCompnt.CPI_COND_TYPE == ItemConst.CPI_COND_TYPE.MIN_QTY) // 최소수량
|
|
{
|
|
if (nSaleQty >= (long)cMstCpiCompnt.QTY_AMT) nCompntQty = nSaleQty;
|
|
// 결제캠페인 최소 결제금액 체크
|
|
if (nPayAmt > 0 && nPayAmt < nCompntAmt)
|
|
{
|
|
nCompntAmt = GetCampaignMaxQtyToSaleAmt(cMstSaleCpi, cMstSaleCpi.CPI_CD, "", "", (long)cMstCpiCompnt.QTY_AMT, sPayDcDiv);
|
|
if (nPayAmt < nCompntAmt) break;
|
|
}
|
|
}
|
|
// 결제캠페인 결제금액 체크
|
|
if (nPayAmt > 0)
|
|
{
|
|
//#20171206 17크리스마스캠페인 start, 20171218
|
|
//기존
|
|
/*
|
|
while (nCompntQty > 0)
|
|
{
|
|
nCompntAmt = GetCampaignMaxQtyToSaleAmt(cMstSaleCpi, cMstSaleCpi.CPI_CD, "", "", nCompntQty, sPayDcDiv);
|
|
if (nPayAmt < nCompntAmt)
|
|
nCompntQty--;
|
|
else
|
|
break;
|
|
}
|
|
*/
|
|
//변경
|
|
nCompntAmt = GetCampaignMaxQtyToSaleAmt(cMstSaleCpi, cMstSaleCpi.CPI_CD, "", "", nCompntQty, sPayDcDiv);
|
|
|
|
nTotCampAmt = nTotCampAmt + nCompntAmt;
|
|
|
|
if (nTotCampAmt > nPayAmt)
|
|
{
|
|
ClearCampaginItem(cMstSaleCpi.CPI_CD);
|
|
return 0;
|
|
}
|
|
//#20171206 17크리스마스캠페인 end, 20171218
|
|
|
|
}
|
|
}
|
|
if (nCompntQty == 0) break;
|
|
|
|
// 구성 자격 적용 행
|
|
nCompntRow = i;
|
|
nDisQty = nCompntQty;
|
|
if (nCompntAmt < nPayAmt && nPayAmt < nSaleAmt)
|
|
nDisSaleAmt = nPayAmt;
|
|
else
|
|
nDisSaleAmt = nCompntAmt;
|
|
}
|
|
if (nCompntRow == -1) return 0;
|
|
|
|
cMstCpiCompnt = (Column.MST_SALE_CPI.DATA_COMPNT)cMstSaleCpi.alDATA_COMPNT[(int)nCompntRow];
|
|
|
|
if (cMstCpiCompnt.CPI_COND_TYPE == ItemConst.CPI_COND_TYPE.MATCH_QTY)
|
|
{
|
|
// 수량 단위로 캠페인 적용
|
|
if (cMstCpiCompnt.CPI_DC_TYPE == ItemConst.CPI_DC_TYPE.RATE)
|
|
{
|
|
nDisAmt = CmUtil.MathAmtPercent(nDisSaleAmt, cMstCpiCompnt.DC_RATE_QTY_AMT);
|
|
nDisAmt = CmUtil.MathRounds(nDisAmt, m_cPosStatus.Mst.DcRudDwLocMethd, CmUtil.IntParse(m_cPosStatus.Mst.DcRudDwLoc));
|
|
|
|
if (cMstCpiCompnt.DC_MAX_AMT > 0 && cMstCpiCompnt.DC_MAX_AMT < nDisAmt) nDisAmt = cMstCpiCompnt.DC_MAX_AMT;
|
|
}
|
|
else
|
|
{
|
|
nDisAmt = CmUtil.DoubleMultiplication(nDisQty, cMstCpiCompnt.DC_RATE_QTY_AMT);
|
|
}
|
|
nDisAmt = SetCampaignSaleDiv(cMstSaleCpi, cMstSaleCpi.CPI_CD, "", "", nDisQty * (long)cMstCpiCompnt.QTY_AMT, nDisAmt, sPayDcDiv);
|
|
}
|
|
else
|
|
{
|
|
if (cMstCpiCompnt.CPI_DC_TYPE == ItemConst.CPI_DC_TYPE.RATE)
|
|
{
|
|
nDisAmt = CmUtil.MathAmtPercent(nDisSaleAmt, cMstCpiCompnt.DC_RATE_QTY_AMT);
|
|
nDisAmt = CmUtil.MathRounds(nDisAmt, m_cPosStatus.Mst.DcRudDwLocMethd, CmUtil.IntParse(m_cPosStatus.Mst.DcRudDwLoc));
|
|
|
|
if (cMstCpiCompnt.DC_MAX_AMT > 0 && cMstCpiCompnt.DC_MAX_AMT < nDisAmt) nDisAmt = cMstCpiCompnt.DC_MAX_AMT;
|
|
}
|
|
else
|
|
{
|
|
nDisAmt = cMstCpiCompnt.DC_RATE_QTY_AMT;
|
|
}
|
|
nDisAmt = SetCampaignSaleDiv(cMstSaleCpi, cMstSaleCpi.CPI_CD, "", "", 0, nDisAmt, sPayDcDiv);
|
|
}
|
|
|
|
// 실효100% 행사 체크
|
|
nDisAmt = CheckCampaignExpPointAll(cMstSaleCpi, nDisSaleAmt, nDisAmt);
|
|
}
|
|
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 nDisAmt;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 사은품 증정
|
|
/// </summary>
|
|
/// <param name="cMstSaleCpi"></param>
|
|
/// <param name="nPayAmt"></param>
|
|
/// <returns></returns>
|
|
public double CampaignFreeGiftDiscount(Column.MST_SALE_CPI.DATA cMstSaleCpi, double nPayAmt, string sCampaignPosOpInputDiv, string sCustID)
|
|
{
|
|
double nSaleAmt = 0, nDisAmt = 0;
|
|
long nSaleQty = 0, nDisQty = 0;
|
|
double nPrice = 0;
|
|
|
|
try
|
|
{
|
|
// 대상 상품 금액 획득(사은품지급기준 첫번째 그룹)
|
|
if (sCampaignPosOpInputDiv == PosConst.SALE_PLU_INPUT_TYPE.FREEGIFT_HP)
|
|
nPrice = GetCampaignSaleQtyAmt(cMstSaleCpi, cMstSaleCpi.CPI_CD, "01", "", ref nSaleQty, ref nSaleAmt, "3");
|
|
else
|
|
nPrice = GetCampaignSaleQtyAmt(cMstSaleCpi, cMstSaleCpi.CPI_CD, "01", "", ref nSaleQty, ref nSaleAmt, PosConst.PAY_DC_TYPE.PAY);
|
|
if (nSaleQty == 0 && nSaleAmt == 0) return 0;
|
|
|
|
// 캠페인 성립금액 구분 체크
|
|
if (CheckCampaignReqAmt(cMstSaleCpi, "", nSaleQty, nSaleAmt) == false) return 0;
|
|
|
|
// 사은품 구분(0:대상 아님, 1:금액당 개수, 2:최소금액 이상 개수, 3: 수량당 개수)
|
|
if (cMstSaleCpi.FREE_GIFT_PROVD_STD == "1")
|
|
{
|
|
if (cMstSaleCpi.FREE_GIFT_STD_AMT == 0) cMstSaleCpi.FREE_GIFT_STD_AMT = 1;
|
|
|
|
// 1:금액당 개수
|
|
nDisQty = (long)(nSaleAmt / cMstSaleCpi.FREE_GIFT_STD_AMT);
|
|
if (nPayAmt > 0) // 카드행사
|
|
{
|
|
while (nDisQty > 0)
|
|
{
|
|
if (nPayAmt < nDisQty * cMstSaleCpi.FREE_GIFT_STD_AMT)
|
|
nDisQty--;
|
|
else
|
|
break;
|
|
}
|
|
}
|
|
nDisQty *= cMstSaleCpi.FREE_GIFT_PROVD_QTY;
|
|
}
|
|
else if (cMstSaleCpi.FREE_GIFT_PROVD_STD == "2")
|
|
{
|
|
// 2:최소금액 이상 개수
|
|
if (nSaleAmt >= cMstSaleCpi.FREE_GIFT_STD_AMT) nDisQty = cMstSaleCpi.FREE_GIFT_PROVD_QTY;
|
|
|
|
if (nPayAmt > 0 && nPayAmt < cMstSaleCpi.FREE_GIFT_STD_AMT) nDisQty = 0; // 카드행사
|
|
}
|
|
if (cMstSaleCpi.FREE_GIFT_PROVD_STD == "3")
|
|
{
|
|
if (cMstSaleCpi.FREE_GIFT_STD_AMT == 0) cMstSaleCpi.FREE_GIFT_STD_AMT = 1;
|
|
|
|
// 3:수량당 개수
|
|
nDisQty = (long)(nSaleQty / cMstSaleCpi.FREE_GIFT_STD_AMT);
|
|
if (nPayAmt > 0) // 카드행사
|
|
{
|
|
while (nDisQty > 0)
|
|
{
|
|
if (nPayAmt < nDisQty * cMstSaleCpi.FREE_GIFT_STD_AMT * nPrice)
|
|
nDisQty--;
|
|
else
|
|
break;
|
|
}
|
|
}
|
|
nDisQty *= cMstSaleCpi.FREE_GIFT_PROVD_QTY;
|
|
}
|
|
|
|
if (nDisQty > 0)
|
|
{
|
|
// 캠페인 제한 수량 체크
|
|
nDisQty = CheckCampaignQtyLimit(cMstSaleCpi, 0, nDisQty);
|
|
if (nDisQty <= 0) return 0;
|
|
//if (CheckCampaignQtyLimit(cMstSaleCpi) == false) return 0;
|
|
|
|
// 캠페인 HP횟수제한 체크
|
|
if (CheckCampaignCntLimit(cMstSaleCpi, sCustID) == false) return 0;
|
|
|
|
if (sCampaignPosOpInputDiv == PosConst.SALE_PLU_INPUT_TYPE.FREEGIFT_HP)
|
|
{
|
|
// 해피 사은품 캠페인 일때 일반 사은품 캠페인 삭제 처리
|
|
for (int i = 0; i < m_alTrPluItem.Count; i++)
|
|
{
|
|
Column.TR_PLU.DATA cPluItem = (Column.TR_PLU.DATA)m_alTrPluItem[i];
|
|
|
|
if (cPluItem.CAMPAIGN_FREEGIFT == PosConst.SALE_PLU_INPUT_TYPE.FREEGIFT)
|
|
{
|
|
if (cPluItem.alTrSaleCpi != null)
|
|
{
|
|
foreach (Column.TR_SALE_CPI_RSLT.DATA cTrSaleCpi in cPluItem.alTrSaleCpi)
|
|
{
|
|
ClearCampaginItem(cTrSaleCpi.CPI_CD);
|
|
}
|
|
}
|
|
|
|
m_alTrPluItem.Remove(cPluItem);
|
|
i--;
|
|
}
|
|
}
|
|
}
|
|
|
|
// 사은품 등록 처리
|
|
frmCampPresent fPresent = new frmCampPresent();
|
|
fPresent.CampaignCode = cMstSaleCpi.CPI_CD;
|
|
fPresent.CampaignName = cMstSaleCpi.CPI_NM;
|
|
fPresent.CampaignPreQty = nDisQty.ToString();
|
|
fPresent.CampaignAddSaleYn = cMstSaleCpi.FREE_GIFT_ADD_SALE_YN;
|
|
fPresent.CampaignPosOpInputDiv = sCampaignPosOpInputDiv;
|
|
if (fPresent.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
|
{
|
|
long nSrcQty = nSaleQty;
|
|
// 사은품 상품
|
|
GetCampaignSaleQtyAmt(cMstSaleCpi, cMstSaleCpi.CPI_CD, "11", "", ref nSaleQty, ref nSaleAmt, PosConst.PAY_DC_TYPE.DC);
|
|
if (nSaleQty > 0)
|
|
{
|
|
// 캠페인 성립 수량 설정(기준상품)
|
|
SetCampaignQtyDiv(cMstSaleCpi, cMstSaleCpi.CPI_CD, "01", "", nSrcQty, PosConst.PAY_DC_TYPE.PAY);
|
|
|
|
if (nDisQty > nSaleQty) nDisQty = nSaleQty;
|
|
// 사은품 할인 처리
|
|
nDisAmt = SetCampaignSaleFreeGiftPlusN(cMstSaleCpi, cMstSaleCpi.CPI_CD, "11", "", nDisQty, true, PosConst.PAY_DC_TYPE.DC);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
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 nDisAmt;
|
|
}
|
|
#endregion
|
|
|
|
#region 등록된 상품리스트 상품할인 행사 적용
|
|
/// <summary>
|
|
/// 등록된 상품리스트에서 행사 대상 상품의 특정 수량 만큼 할인 금액을 배분 처리 한다
|
|
/// </summary>
|
|
/// <param name="cMstSaleCpi"></param>
|
|
/// <param name="sCpiCode"></param>
|
|
/// <param name="sGroupCode"></param>
|
|
/// <param name="sPluCode"></param>
|
|
/// <param name="nTotDisAmt"></param>
|
|
/// <returns></returns>
|
|
public double SetCampaignSaleDiv(Column.MST_SALE_CPI.DATA cMstSaleCpi, string sCpiCode, string sGroupCode, string sPluCode, long nTotDisQty, double nTotDisAmt, string sPayDcDiv)
|
|
{
|
|
double nTotSaleAmt = 0, nSaleAmt = 0, nDisAmt = 0, nDisPrc = 0;
|
|
long nSaleQty = 0, nDisQty = 0, nApplyQty = 0;
|
|
double nMaxAmt = 0, nApplyAmt = 0;
|
|
|
|
Column.TR_PLU.DATA cMaxSaleItem = null;
|
|
|
|
try
|
|
{
|
|
// 상품 합계금액 구하기
|
|
foreach (Column.TR_PLU.DATA cSaleItem in m_alTrPluItem)
|
|
{
|
|
if (sPluCode != "" && sPluCode != cSaleItem.SUB_SHOP_CD + cSaleItem.ITEM_PLU_CD) continue;
|
|
|
|
foreach (Column.TR_SALE_CPI_RSLT.DATA cTrSaleCpi in cSaleItem.alTrSaleCpi)
|
|
{
|
|
if (sCpiCode != cTrSaleCpi.CPI_CD) continue;
|
|
if (sGroupCode != "" && sGroupCode != cTrSaleCpi.cMST_CPI_ITEM.CPI_ITEM_GRP_CD) continue;
|
|
|
|
double nPrice = GetCampaignSaleItemQtyAmt(cMstSaleCpi, cSaleItem, ref nSaleQty, ref nSaleAmt, sPayDcDiv);
|
|
if (nSaleAmt <= 0) continue;
|
|
|
|
nDisQty = nSaleQty;
|
|
if ( nTotDisQty > 0 && nTotDisQty < nApplyQty + nSaleQty) nDisQty = nTotDisQty - nApplyQty;
|
|
|
|
if (nDisQty != nSaleQty)
|
|
{
|
|
nSaleAmt = (nSaleAmt / nSaleQty) * nDisQty;
|
|
}
|
|
|
|
nApplyQty += nDisQty;
|
|
nTotSaleAmt = CmUtil.DoubleAdd(nTotSaleAmt, nSaleAmt);
|
|
|
|
if (nMaxAmt == 0 || nMaxAmt < nSaleAmt)
|
|
{
|
|
nMaxAmt = nSaleAmt;
|
|
cMaxSaleItem = cSaleItem;
|
|
}
|
|
break;
|
|
}
|
|
if (nApplyQty >= nTotDisQty && nTotDisQty > 0) break;
|
|
}
|
|
|
|
// 할인 금액 배분 처리
|
|
nApplyQty = 0;
|
|
foreach (Column.TR_PLU.DATA cSaleItem in m_alTrPluItem)
|
|
{
|
|
if (sPluCode != "" && sPluCode != cSaleItem.SUB_SHOP_CD + cSaleItem.ITEM_PLU_CD) continue;
|
|
|
|
foreach (Column.TR_SALE_CPI_RSLT.DATA cTrSaleCpi in cSaleItem.alTrSaleCpi)
|
|
{
|
|
if (sCpiCode != cTrSaleCpi.CPI_CD) continue;
|
|
if (sGroupCode != "" && sGroupCode != cTrSaleCpi.cMST_CPI_ITEM.CPI_ITEM_GRP_CD) continue;
|
|
|
|
double nPrice = GetCampaignSaleItemQtyAmt(cMstSaleCpi, cSaleItem, ref nSaleQty, ref nSaleAmt, sPayDcDiv);
|
|
if (nSaleAmt <= 0) continue;
|
|
|
|
nDisQty = nSaleQty;
|
|
if (nTotDisQty > 0 && nTotDisQty < nApplyQty + nSaleQty) nDisQty = nTotDisQty - nApplyQty;
|
|
|
|
if (nDisQty != nSaleQty) nSaleAmt = (nSaleAmt / nSaleQty) * nDisQty;
|
|
|
|
nDisAmt = CmUtil.DoubleMultiplication(nTotDisAmt, CmUtil.DoubleDivision(nSaleAmt, nTotSaleAmt));
|
|
nDisAmt = CmUtil.MathRounds(nDisAmt, m_cPosStatus.Mst.ItemRudDwLocMethd, CmUtil.IntParse(m_cPosStatus.Mst.ItemRudDwLoc));
|
|
if (nDisAmt > 0)
|
|
{
|
|
// 캠페인 할인 금액 설정
|
|
nDisAmt = SetCampaignSaleItemDcAmt(cMstSaleCpi, cSaleItem, cTrSaleCpi, nDisAmt / nDisQty, nDisQty, nDisAmt, sPayDcDiv);
|
|
|
|
nApplyQty += nDisQty;
|
|
nApplyAmt = CmUtil.DoubleAdd(nApplyAmt, nDisAmt);
|
|
}
|
|
break;
|
|
}
|
|
ExeccutePluItemAmount(cSaleItem); // 해당상품 판매금액 계산
|
|
|
|
if (nApplyAmt >= nTotDisAmt) break;
|
|
if (nApplyQty >= nTotDisQty && nTotDisQty > 0) break;
|
|
}
|
|
|
|
// 자투리 금액
|
|
if (nTotDisAmt != nApplyAmt)
|
|
{
|
|
foreach (Column.TR_SALE_CPI_RSLT.DATA cTrSaleCpi in cMaxSaleItem.alTrSaleCpi)
|
|
{
|
|
if (sCpiCode != cTrSaleCpi.CPI_CD) continue;
|
|
if (sGroupCode != "" && sGroupCode != cTrSaleCpi.cMST_CPI_ITEM.CPI_ITEM_GRP_CD) continue;
|
|
|
|
cTrSaleCpi.DC_SUM_AMT = CmUtil.DoubleAdd(cTrSaleCpi.DC_SUM_AMT, CmUtil.DoubleSubtraction(nTotDisAmt, nApplyAmt));
|
|
break;
|
|
}
|
|
ExeccutePluItemAmount(cMaxSaleItem); // 해당상품 판매금액 계산
|
|
}
|
|
}
|
|
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 nTotDisAmt;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 캠페인 성립 수량 설정
|
|
/// </summary>
|
|
/// <param name="cMstSaleCpi"></param>
|
|
/// <param name="sCpiCode"></param>
|
|
/// <param name="sGroupCode"></param>
|
|
/// <param name="sPluCode"></param>
|
|
/// <param name="nTotDisQty"></param>
|
|
/// <returns></returns>
|
|
public double SetCampaignQtyDiv(Column.MST_SALE_CPI.DATA cMstSaleCpi, string sCpiCode, string sGroupCode, string sPluCode, long nTotDisQty, string sPayDcDiv)
|
|
{
|
|
double nSaleAmt = 0;
|
|
long nSaleQty = 0, nDisQty = 0, nApplyQty = 0;
|
|
|
|
try
|
|
{
|
|
// 캠페인 성립 수량 설정 처리
|
|
nApplyQty = 0;
|
|
foreach (Column.TR_PLU.DATA cSaleItem in m_alTrPluItem)
|
|
{
|
|
if (sPluCode != "" && sPluCode != cSaleItem.SUB_SHOP_CD + cSaleItem.ITEM_PLU_CD) continue;
|
|
|
|
foreach (Column.TR_SALE_CPI_RSLT.DATA cTrSaleCpi in cSaleItem.alTrSaleCpi)
|
|
{
|
|
if (sCpiCode != cTrSaleCpi.CPI_CD) continue;
|
|
if (sGroupCode != "" && sGroupCode != cTrSaleCpi.cMST_CPI_ITEM.CPI_ITEM_GRP_CD) continue;
|
|
|
|
double nPrice = GetCampaignSaleItemQtyAmt(cMstSaleCpi, cSaleItem, ref nSaleQty, ref nSaleAmt, sPayDcDiv);
|
|
if (nSaleQty <= 0) continue;
|
|
|
|
nDisQty = nSaleQty;
|
|
if (nTotDisQty > 0 && nTotDisQty < nApplyQty + nSaleQty) nDisQty = nTotDisQty - nApplyQty;
|
|
|
|
if (nDisQty != nSaleQty) nSaleAmt = (nSaleAmt / nSaleQty) * nDisQty;
|
|
|
|
if (nDisQty > 0)
|
|
{
|
|
// 캠페인 성립 수량 설정
|
|
SetCampaignSaleItemDcAmt(cMstSaleCpi, cSaleItem, cTrSaleCpi, 0, nDisQty, 0, sPayDcDiv);
|
|
|
|
nApplyQty += nDisQty;
|
|
}
|
|
break;
|
|
}
|
|
|
|
if (nApplyQty >= nTotDisQty) break;
|
|
}
|
|
}
|
|
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 nTotDisQty;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 등록된 상품리스트에서 행사 대상 상품의 특정 수량 만큼 할인 처리 한다
|
|
/// </summary>
|
|
/// <param name="cMstSaleCpi"></param>
|
|
/// <param name="sCpiCode"></param>
|
|
/// <param name="sGroupCode"></param>
|
|
/// <param name="sPluCode"></param>
|
|
/// <param name="nDisQty"></param>
|
|
/// <param name="sDcDiv"></param>
|
|
/// <param name="nRateAmt"></param>
|
|
/// <returns></returns>
|
|
public double SetCampaignSaleQtyAmt(Column.MST_SALE_CPI.DATA cMstSaleCpi, string sCpiCode, string sGroupCode, string sPluCode, long nTotDisQty, string sDcDiv, double nRateAmt, string sPayDcDiv)
|
|
{
|
|
double nTotDisAmt = 0;
|
|
double nSaleAmt = 0, nDisAmt = 0, nDisPrc = 0;
|
|
long nSaleQty = 0, nDisQty = 0, nApplyQty = 0;
|
|
|
|
try
|
|
{
|
|
foreach (Column.TR_PLU.DATA cSaleItem in m_alTrPluItem)
|
|
{
|
|
if (sPluCode != "" && sPluCode != cSaleItem.SUB_SHOP_CD + cSaleItem.ITEM_PLU_CD) continue;
|
|
|
|
foreach (Column.TR_SALE_CPI_RSLT.DATA cTrSaleCpi in cSaleItem.alTrSaleCpi)
|
|
{
|
|
if (sCpiCode != cTrSaleCpi.CPI_CD) continue;
|
|
if (sGroupCode != "" && sGroupCode != cTrSaleCpi.cMST_CPI_ITEM.CPI_ITEM_GRP_CD) continue;
|
|
|
|
nDisPrc = GetCampaignSaleItemQtyAmt(cMstSaleCpi, cSaleItem, ref nSaleQty, ref nSaleAmt, sPayDcDiv);
|
|
if (nSaleQty <= 0 && nSaleAmt <= 0) continue;
|
|
|
|
nDisQty = nSaleQty; // 할인수량
|
|
if (nTotDisQty < nApplyQty + nSaleQty) nDisQty = nTotDisQty - nApplyQty;
|
|
|
|
if (nRateAmt == 0) // 구성마스터에 금액,율이 없다면 캠페인 행사상품마스터의 금액,율 참조
|
|
{
|
|
sDcDiv = cTrSaleCpi.cMST_CPI_ITEM.CPI_DC_TYPE;
|
|
nRateAmt = cTrSaleCpi.cMST_CPI_ITEM.DC_RATE_AMT;
|
|
}
|
|
|
|
if (sDcDiv == ItemConst.CPI_DC_TYPE.AMT) // 금액
|
|
{
|
|
if (nRateAmt <= nDisPrc || sPayDcDiv == PosConst.PAY_DC_TYPE.PAY)
|
|
{
|
|
nDisPrc = nRateAmt;
|
|
nDisAmt = nRateAmt * nDisQty;
|
|
}
|
|
else
|
|
{
|
|
UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
|
|
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()",
|
|
"Master Error. EvtCode=" + cTrSaleCpi.CPI_CD + ", PluCode=" + cTrSaleCpi.ITEM_PLU_CD);
|
|
break;
|
|
}
|
|
}
|
|
else if (sDcDiv == ItemConst.CPI_DC_TYPE.RATE) // 율
|
|
{
|
|
if (nRateAmt <= 100)
|
|
{
|
|
if (nDisQty == cSaleItem.SALE_QTY)
|
|
{
|
|
nDisAmt = CmUtil.MathAmtPercent(nSaleAmt, nRateAmt);
|
|
nDisAmt = CmUtil.MathRounds(nDisAmt, m_cPosStatus.Mst.DcRudDwLocMethd, CmUtil.IntParse(m_cPosStatus.Mst.DcRudDwLoc));
|
|
nDisPrc = CmUtil.DoubleDivision(nDisAmt, nDisQty);
|
|
}
|
|
else
|
|
{
|
|
nDisPrc = CmUtil.MathAmtPercent(nSaleAmt / nSaleQty, nRateAmt);
|
|
nDisPrc = CmUtil.MathRounds(nDisPrc, m_cPosStatus.Mst.DcRudDwLocMethd, CmUtil.IntParse(m_cPosStatus.Mst.DcRudDwLoc));
|
|
|
|
nDisAmt = CmUtil.DoubleMultiplication(nDisPrc, nDisQty);
|
|
nDisAmt = CmUtil.MathRounds(nDisAmt, m_cPosStatus.Mst.DcRudDwLocMethd, CmUtil.IntParse(m_cPosStatus.Mst.DcRudDwLoc));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
|
|
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()",
|
|
"Master Error. EvtCode=" + cTrSaleCpi.CPI_CD + ", PluCode=" + cTrSaleCpi.ITEM_PLU_CD);
|
|
break;
|
|
}
|
|
}
|
|
else if (sDcDiv == ItemConst.CPI_DC_TYPE.PRICE) // 단가
|
|
{
|
|
if (nRateAmt > 0 && nRateAmt < cSaleItem.SALE_PRC)
|
|
{
|
|
nDisPrc = cSaleItem.SALE_PRC - nRateAmt;
|
|
nDisAmt = nDisPrc * nDisQty;
|
|
}
|
|
else
|
|
{
|
|
UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
|
|
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()",
|
|
"Master Error. EvtCode=" + cTrSaleCpi.CPI_CD + ", PluCode=" + cTrSaleCpi.ITEM_PLU_CD);
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (nDisQty > 0 || nDisAmt > 0)
|
|
{
|
|
// 캠페인 할인 금액 설정
|
|
nDisAmt = SetCampaignSaleItemDcAmt(cMstSaleCpi, cSaleItem, cTrSaleCpi, nDisPrc, nDisQty, nDisAmt, sPayDcDiv);
|
|
|
|
nApplyQty += nDisQty;
|
|
nTotDisAmt = CmUtil.DoubleAdd(nTotDisAmt, cTrSaleCpi.DC_SUM_AMT);
|
|
}
|
|
break;
|
|
}
|
|
ExeccutePluItemAmount(cSaleItem); // 해당상품 판매금액 계산
|
|
|
|
if (nApplyQty >= nTotDisQty && nTotDisQty > 0) break;
|
|
}
|
|
}
|
|
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 nTotDisAmt;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 등록된 상품리스트에서 행사 대상 상품에 해당 수량 사은품증정 및 +N 증정 처리
|
|
/// </summary>
|
|
/// <param name="cMstSaleCpi"></param>
|
|
/// <param name="sCpiCode"></param>
|
|
/// <param name="sGroupCode"></param>
|
|
/// <param name="sPluCode"></param>
|
|
/// <param name="nTotDisQty"></param>
|
|
/// <param name="bFreeGift"></param>
|
|
/// <param name="nFreePrice"></param>
|
|
/// <returns></returns>
|
|
public double SetCampaignSaleFreeGiftPlusN(Column.MST_SALE_CPI.DATA cMstSaleCpi, string sCpiCode, string sGroupCode, string sPluCode, long nTotDisQty, bool bFreeGift, string sPayDcDiv)
|
|
{
|
|
double nTotDisAmt = 0;
|
|
double nSaleAmt = 0, nDisAmt = 0, nDisPrc = 0;
|
|
long nSaleQty = 0, nDisQty = 0, nApplyQty = 0;
|
|
try
|
|
{
|
|
foreach (Column.TR_PLU.DATA cSaleItem in m_alTrPluItem)
|
|
{
|
|
if (sPluCode != "" && sPluCode != cSaleItem.SUB_SHOP_CD + cSaleItem.ITEM_PLU_CD) continue;
|
|
|
|
if (bFreeGift == true)
|
|
{
|
|
if (cSaleItem.CAMPAIGN_FREEGIFT != PosConst.SALE_PLU_INPUT_TYPE.FREEGIFT && cSaleItem.CAMPAIGN_FREEGIFT != PosConst.SALE_PLU_INPUT_TYPE.FREEGIFT_HP) continue;
|
|
}
|
|
|
|
foreach (Column.TR_SALE_CPI_RSLT.DATA cTrSaleCpi in cSaleItem.alTrSaleCpi)
|
|
{
|
|
if (sCpiCode != cTrSaleCpi.CPI_CD) continue;
|
|
if (sGroupCode != "" && sGroupCode != cTrSaleCpi.cMST_CPI_ITEM.CPI_ITEM_GRP_CD) continue;
|
|
|
|
nDisPrc = GetCampaignSaleItemQtyAmt(cMstSaleCpi, cSaleItem, ref nSaleQty, ref nSaleAmt, sPayDcDiv);
|
|
if (nSaleQty <= 0 && nSaleAmt <= 0) continue;
|
|
|
|
nDisQty = nSaleQty;
|
|
if (nTotDisQty < nApplyQty + nSaleQty) nDisQty = nTotDisQty - nApplyQty;
|
|
|
|
if (bFreeGift == true)
|
|
{
|
|
// 사은품 증정
|
|
double nFreePrice = cTrSaleCpi.cMST_CPI_ITEM.DC_RATE_AMT; // 사은품 판매가
|
|
if (nFreePrice <= cSaleItem.SALE_PRC)
|
|
{
|
|
nDisPrc = CmUtil.DoubleSubtraction(cSaleItem.SALE_PRC, nFreePrice);
|
|
nDisAmt = CmUtil.DoubleMultiplication(nDisPrc, nDisQty);
|
|
|
|
cSaleItem.CPI_PRESENT_DIV = "1";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// PLUS N
|
|
if (nDisQty == cSaleItem.SALE_QTY)
|
|
{
|
|
nDisPrc = CmUtil.DoubleDivision(nSaleAmt, nDisQty);
|
|
nDisAmt = nSaleAmt;
|
|
}
|
|
else
|
|
{
|
|
nDisAmt = CmUtil.DoubleMultiplication(nDisPrc, nDisQty);
|
|
}
|
|
}
|
|
|
|
if (nDisQty > 0 || nDisAmt > 0)
|
|
{
|
|
// 캠페인 할인 금액 설정
|
|
nDisAmt = SetCampaignSaleItemDcAmt(cMstSaleCpi, cSaleItem, cTrSaleCpi, nDisPrc, nDisQty, nDisAmt, sPayDcDiv);
|
|
|
|
nApplyQty += nSaleQty;
|
|
nTotDisAmt = CmUtil.DoubleAdd(nTotDisAmt, nDisAmt);
|
|
}
|
|
break;
|
|
}
|
|
ExeccutePluItemAmount(cSaleItem); // 해당상품 판매금액 계산
|
|
|
|
if (nApplyQty >= nTotDisQty) break;
|
|
}
|
|
}
|
|
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 nTotDisAmt;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 캠페인 금액 설정
|
|
/// </summary>
|
|
/// <param name="cMstSaleCpi"></param>
|
|
/// <param name="cTrSaleCpi"></param>
|
|
/// <param name="sDcPrc"></param>
|
|
/// <param name="nDcQty"></param>
|
|
/// <param name="nDcAmt"></param>
|
|
/// <param name="sPayDcDiv">결제할인구분</param>
|
|
public double SetCampaignSaleItemDcAmt(Column.MST_SALE_CPI.DATA cMstSaleCpi, Column.TR_PLU.DATA cSaleItem, Column.TR_SALE_CPI_RSLT.DATA cTrSaleCpi, double sDcPrc, long nDcQty, double nDcAmt, string sPayDcDiv)
|
|
{
|
|
try
|
|
{
|
|
// 캠페인 할인금액이 판매가 초과 할수 없도록 체크
|
|
double nTotDisAmt = 0;
|
|
nTotDisAmt = CmUtil.DoubleAdd(nTotDisAmt, cSaleItem.ITEM_DC_AMT);
|
|
nTotDisAmt = CmUtil.DoubleAdd(nTotDisAmt, cSaleItem.SUM_DC_AMT); // 단품 할인, 소계 할인 금액
|
|
nTotDisAmt = CmUtil.DoubleAdd(nTotDisAmt, cSaleItem.COOP_CARD_DC_AMT); // 제휴 할인 금액
|
|
nTotDisAmt = CmUtil.DoubleAdd(nTotDisAmt, cSaleItem.POINT_DC_AMT); // 포인트 할인 금액
|
|
nTotDisAmt = CmUtil.DoubleAdd(nTotDisAmt, cSaleItem.CPN_DC_AMT); // 쿠폰 할인 금액
|
|
nTotDisAmt = CmUtil.DoubleAdd(nTotDisAmt, cSaleItem.EMP_DC_AMT); // 직원 할인 금액
|
|
nTotDisAmt = CmUtil.DoubleAdd(nTotDisAmt, cSaleItem.SET_DC_AMT); // 세트할인
|
|
nTotDisAmt = CmUtil.DoubleAdd(nTotDisAmt, cSaleItem.EXCEP_DC_AMT); // 예외할인
|
|
nTotDisAmt = CmUtil.DoubleAdd(nTotDisAmt, cSaleItem.ETC_DC_AMT); // 기타할인
|
|
|
|
// 할인가능금액
|
|
double nRemainAmt = CmUtil.DoubleSubtraction(cSaleItem.SALE_PRC * cSaleItem.SALE_QTY, nTotDisAmt);
|
|
if (nRemainAmt < nDcAmt) nDcAmt = nRemainAmt;
|
|
|
|
// 캠페인 성립정보 설정
|
|
cTrSaleCpi.DC_PRC = sDcPrc;
|
|
cTrSaleCpi.DC_QTY += nDcQty;
|
|
cTrSaleCpi.DC_SUM_AMT = nDcAmt;
|
|
|
|
// 결제할인구분 (1:결제, 2:할인)
|
|
cTrSaleCpi.PAY_DC_DIV = sPayDcDiv;
|
|
// 고객번호
|
|
cTrSaleCpi.SLACK_FIELD = m_sHpCustID;
|
|
}
|
|
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 nDcAmt;
|
|
}
|
|
#endregion
|
|
|
|
#region 등록된 상품리스트에서 행사 대상 상품 획득
|
|
/// <summary>
|
|
/// 등록된 상품리스트에서 행사 대상 상품의 수량 및 금액을 획득
|
|
/// </summary>
|
|
/// <param name="cMstSaleCpi"></param>
|
|
/// <param name="sCpiCode"></param>
|
|
/// <param name="sGroupCode"></param>
|
|
/// <param name="nSaleQty"></param>
|
|
/// <param name="nSaleAmt"></param>
|
|
/// <returns></returns>
|
|
public double GetCampaignSaleQtyAmt(Column.MST_SALE_CPI.DATA cMstSaleCpi, string sCpiCode, string sGroupCode, string sPluCode, ref long nSaleQty, ref double nSaleAmt, string sPayDcDiv)
|
|
{
|
|
long nQty = 0;
|
|
double nAmt = 0, nPrice = 0, nLowPrice = 0;
|
|
|
|
try
|
|
{
|
|
nSaleQty = 0; nSaleAmt = 0;
|
|
|
|
foreach (Column.TR_PLU.DATA cSaleItem in m_alTrPluItem)
|
|
{
|
|
if (cMstSaleCpi.ITEM_APPLY_METHD == ItemConst.CPI_ITEM_APPLY_METHD.RECTSUM || cMstSaleCpi.ITEM_APPLY_METHD == ItemConst.CPI_ITEM_APPLY_METHD.PAYMENT)
|
|
{
|
|
if (sGroupCode != "11")
|
|
{
|
|
// 해당 캠페인이 상품에 등록되어 있는지 체크 => 등록되어 있지 않다면 등록 처리
|
|
bool bExist = false;
|
|
foreach (Column.TR_SALE_CPI_RSLT.DATA cTrSaleCpi in cSaleItem.alTrSaleCpi)
|
|
{
|
|
if (sCpiCode == cTrSaleCpi.CPI_CD)
|
|
{
|
|
bExist = true;
|
|
break;
|
|
}
|
|
}
|
|
if (bExist == false)
|
|
{
|
|
Column.TR_SALE_CPI_RSLT.DATA cTrSaleCpi = AddSaleItemTrSaleCpiData(cSaleItem, sCpiCode, sGroupCode, "", 0);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (sPluCode != "" && sPluCode != cSaleItem.SUB_SHOP_CD + cSaleItem.ITEM_PLU_CD) continue;
|
|
|
|
foreach (Column.TR_SALE_CPI_RSLT.DATA cTrSaleCpi in cSaleItem.alTrSaleCpi)
|
|
{
|
|
if (sCpiCode != cTrSaleCpi.CPI_CD) continue;
|
|
if (sGroupCode != "" && sGroupCode != cTrSaleCpi.cMST_CPI_ITEM.CPI_ITEM_GRP_CD) continue;
|
|
|
|
nPrice = GetCampaignSaleItemQtyAmt(cMstSaleCpi, cSaleItem, ref nQty, ref nAmt, sPayDcDiv);
|
|
if (nQty > 0 || nAmt > 0)
|
|
{
|
|
nSaleQty += nQty;
|
|
nSaleAmt = CmUtil.DoubleAdd(nSaleAmt, nAmt);
|
|
|
|
if (nLowPrice == 0 || nLowPrice > nPrice) nLowPrice = nPrice;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
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 nLowPrice;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 등록된 상품리스트에서 행사 대상상품의 특정수량 까지의 금액을 획득
|
|
/// </summary>
|
|
/// <param name="cMstSaleCpi"></param>
|
|
/// <param name="sCpiCode"></param>
|
|
/// <param name="sGroupCode"></param>
|
|
/// <param name="sPluCode"></param>
|
|
/// <param name="nMaxQty"></param>
|
|
/// <param name="sPayDcDiv"></param>
|
|
/// <returns></returns>
|
|
public double GetCampaignMaxQtyToSaleAmt(Column.MST_SALE_CPI.DATA cMstSaleCpi, string sCpiCode, string sGroupCode, string sPluCode, long nMaxQty, string sPayDcDiv)
|
|
{
|
|
long nQty = 0, nTotQty = 0;
|
|
double nAmt = 0, nTotAmt = 0;
|
|
|
|
try
|
|
{
|
|
foreach (Column.TR_PLU.DATA cSaleItem in m_alTrPluItem)
|
|
{
|
|
if (cSaleItem.CANCEL_DIV == PosConst.CANCEL_DIV.CANCEL || cSaleItem.CANCEL_DIV_MAIN == PosConst.CANCEL_DIV.CANCEL) return 0;// 지정취소
|
|
if (cSaleItem.BILLSPR_NO != m_cTrnStatus.Sale.BillSplitNo) return 0; // 빌분리번호
|
|
if (cMstSaleCpi.DC_NOADM_PASS_YN != "1" && cSaleItem.DC_PRMT_YN == "1") return 0; // 할인 불가 여부(0:가능, 1:불가)
|
|
|
|
if (sPluCode != "" && sPluCode != cSaleItem.SUB_SHOP_CD + cSaleItem.ITEM_PLU_CD) continue;
|
|
|
|
foreach (Column.TR_SALE_CPI_RSLT.DATA cTrSaleCpi in cSaleItem.alTrSaleCpi)
|
|
{
|
|
if (sCpiCode != cTrSaleCpi.CPI_CD) continue;
|
|
if (sGroupCode != "" && sGroupCode != cTrSaleCpi.cMST_CPI_ITEM.CPI_ITEM_GRP_CD) continue;
|
|
|
|
double nPrice = GetCampaignSaleItemQtyAmt(cMstSaleCpi, cSaleItem, ref nQty, ref nAmt, sPayDcDiv);
|
|
if (nQty > 0 || nAmt > 0)
|
|
{
|
|
if (nMaxQty > 0 && nTotQty + nQty > nMaxQty)
|
|
{
|
|
for (int i = 1; i <= nQty; i++)
|
|
{
|
|
nTotQty += 1;
|
|
nTotAmt = CmUtil.DoubleAdd(nTotAmt, nPrice);
|
|
|
|
if (nMaxQty > 0 && nTotQty >= nMaxQty) break;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
nTotQty += nQty;
|
|
nTotAmt = CmUtil.DoubleAdd(nTotAmt, nAmt);
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
if (nMaxQty > 0 && nTotQty >= nMaxQty) break;
|
|
}
|
|
}
|
|
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 nTotAmt;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 캠페인 대상상품 수량 및 상품금액 획득
|
|
/// </summary>
|
|
/// <param name="cMstSaleCpi">캠페인정보</param>
|
|
/// <param name="cTrSaleCpi">상품정보</param>
|
|
/// <param name="nQty">대상수량</param>
|
|
/// <param name="nAmount">대상금액</param>
|
|
/// <param name="sPayDcDiv">결제할인구분</param>
|
|
/// <returns>단가</returns>
|
|
public double GetCampaignSaleItemQtyAmt(Column.MST_SALE_CPI.DATA cMstSaleCpi, Column.TR_PLU.DATA cSaleItem, ref long nDestQty, ref double nDestAmt, string sPayDcDiv)
|
|
{
|
|
double nPrice = 0;
|
|
long nDisQty = 0;
|
|
|
|
try
|
|
{
|
|
nDestQty = 0; nDestAmt = 0;
|
|
|
|
if (cSaleItem.CANCEL_DIV == PosConst.CANCEL_DIV.CANCEL || cSaleItem.CANCEL_DIV_MAIN == PosConst.CANCEL_DIV.CANCEL) return 0;// 지정취소
|
|
if (cSaleItem.BILLSPR_NO != m_cTrnStatus.Sale.BillSplitNo) return 0; // 빌분리번호
|
|
if (cMstSaleCpi.DC_NOADM_PASS_YN != "1" && cSaleItem.DC_PRMT_YN == "1") return 0; // 할인 불가 여부(0:가능, 1:불가)
|
|
if (cSaleItem.FLAVOUR_DIV == ItemConst.PLU_FLAVOUR_DIV.FLAVOUR) return 0; // 플레이버 제외
|
|
if (cSaleItem.ITEM_DIV == ItemConst.PLU_ITEM_DIV.OPT_MENU && cSaleItem.SUBPRC_MENU_KEY_DIV == "1") return 0; // 부가상품(속성) 제외
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
//if ((cMstSaleCpi.CPI_CUST_BNFT_TYPE != ItemConst.CPI_CUST_BNFT.FREEGIFT && cMstSaleCpi.CPI_CUST_BNFT_TYPE != ItemConst.CPI_CUST_BNFT.FREE_SAVE) && cSaleItem.FREE_GIFT_YN == "1") return 0; // 사은품제외
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// 기존 할인이 적용되어 있으면 캠페인 적용 안함.
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
if (cMstSaleCpi.TELECOM_COOP_DUP_PRMT_YN == "0" && cSaleItem.COOP_CARD_DC_AMT > 0) return 0; // 제휴카드 할인 금액
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
if ((cSaleItem.ITEM_DC_AMT > 0 || cSaleItem.SUM_DC_AMT > 0) && cSaleItem.DC_DIV.Length >= 4) // 단품 할인, 소계 할인 금액
|
|
{
|
|
// 캠페인중복 여부(0:불가, 1:가능)
|
|
if (PosMstManager.GetMstPayDc(cSaleItem.DC_DIV.Substring(0, 2), cSaleItem.DC_DIV.Substring(2, 2), PosMst.MST_PAY_DC.DATA.CPI_DUP_YN) == "0") return 0;
|
|
}
|
|
if (cSaleItem.COOP_CARD_DC_AMT > 0 && cSaleItem.COOP_CARD_DC_DIV.Length >= 4) // 제휴 할인 금액
|
|
{
|
|
// 캠페인중복 여부(0:불가, 1:가능)
|
|
if (PosMstManager.GetMstPayDc(cSaleItem.COOP_CARD_DC_DIV.Substring(0, 2), cSaleItem.COOP_CARD_DC_DIV.Substring(2, 2), PosMst.MST_PAY_DC.DATA.CPI_DUP_YN) == "0") return 0;
|
|
}
|
|
if (cSaleItem.POINT_DC_AMT > 0 && cSaleItem.POINT_DC_DIV.Length >= 4) // 포인트 할인 금액
|
|
{
|
|
// 캠페인중복 여부(0:불가, 1:가능)
|
|
if (PosMstManager.GetMstPayDc(cSaleItem.POINT_DC_DIV.Substring(0, 2), cSaleItem.POINT_DC_DIV.Substring(2, 2), PosMst.MST_PAY_DC.DATA.CPI_DUP_YN) == "0") return 0;
|
|
}
|
|
if (cSaleItem.CPN_DC_AMT > 0 && cSaleItem.CPN_DC_DIV.Length >= 4) // 쿠폰 할인 금액
|
|
{
|
|
// 캠페인중복 여부(0:불가, 1:가능)
|
|
if (PosMstManager.GetMstPayDc(cSaleItem.CPN_DC_DIV.Substring(0, 2), cSaleItem.CPN_DC_DIV.Substring(2, 2), PosMst.MST_PAY_DC.DATA.CPI_DUP_YN) == "0") return 0;
|
|
}
|
|
if (cSaleItem.EMP_DC_AMT > 0 && cSaleItem.EMP_DC_DIV.Length >= 4) // 직원 할인 금액
|
|
{
|
|
// 캠페인중복 여부(0:불가, 1:가능)
|
|
if (PosMstManager.GetMstPayDc(cSaleItem.EMP_DC_DIV.Substring(0, 2), cSaleItem.EMP_DC_DIV.Substring(2, 2), PosMst.MST_PAY_DC.DATA.CPI_DUP_YN) == "0") return 0;
|
|
}
|
|
if (cSaleItem.SET_DC_AMT > 0) // 세트할인
|
|
{
|
|
// 캠페인중복 여부(0:불가, 1:가능)
|
|
if (PosMstManager.GetMstPayDc(ItemConst.PLU_DC_DIV.SET_DC.Substring(0, 2), ItemConst.PLU_DC_DIV.SET_DC.Substring(2, 2), PosMst.MST_PAY_DC.DATA.CPI_DUP_YN) == "0") return 0;
|
|
}
|
|
|
|
if (sPayDcDiv == PosConst.PAY_DC_TYPE.DC) // 할인결제구분 (1:결제, 2:할인) )
|
|
{
|
|
// 할인 행사
|
|
foreach (Column.TR_SALE_CPI_RSLT.DATA cTrSaleCpi in cSaleItem.alTrSaleCpi)
|
|
{
|
|
// 할인행사 이면 할인행가 간 중복 안됨
|
|
if (cTrSaleCpi.PAY_DC_DIV == PosConst.PAY_DC_TYPE.DC)
|
|
{
|
|
nDisQty += cTrSaleCpi.DC_QTY;
|
|
break;
|
|
}
|
|
if (cTrSaleCpi.PAY_DC_DIV == PosConst.PAY_DC_TYPE.PAY)
|
|
{
|
|
if (cTrSaleCpi.CPI_CUST_BNFT_TYPE == ItemConst.CPI_CUST_BNFT.FREEGIFT || cTrSaleCpi.CPI_CUST_BNFT_TYPE == ItemConst.CPI_CUST_BNFT.FREE_SAVE)
|
|
{
|
|
// 캠페인 사은품대상 상품과 중복가능여부 체크
|
|
if ((cMstSaleCpi.ITEM_DUP_PRMT_YN == "0" || cTrSaleCpi.ITEM_DUP_PRMT_YN == "0") && cTrSaleCpi.DC_QTY > 0)
|
|
{
|
|
nDisQty += cTrSaleCpi.DC_QTY;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else if (sPayDcDiv == PosConst.PAY_DC_TYPE.PAY) // 할인결제구분 (1:결제, 2:할인) )
|
|
{
|
|
// 결제 행사
|
|
foreach (Column.TR_SALE_CPI_RSLT.DATA cTrSaleCpi in cSaleItem.alTrSaleCpi)
|
|
{
|
|
if (cMstSaleCpi.CPI_CUST_BNFT_TYPE == ItemConst.CPI_CUST_BNFT.FREEGIFT || cMstSaleCpi.CPI_CUST_BNFT_TYPE == ItemConst.CPI_CUST_BNFT.FREE_SAVE)
|
|
{
|
|
// 사은품
|
|
if (cTrSaleCpi.PAY_DC_DIV == PosConst.PAY_DC_TYPE.DC)
|
|
{
|
|
// 캠페인 할인 상품과 중복가능여부체크
|
|
if ((cMstSaleCpi.ITEM_DUP_PRMT_YN == "0" || cTrSaleCpi.ITEM_DUP_PRMT_YN == "0") && cTrSaleCpi.DC_QTY > 0)
|
|
{
|
|
nDisQty += cTrSaleCpi.DC_QTY;
|
|
break;
|
|
}
|
|
}
|
|
else if (cTrSaleCpi.PAY_DC_DIV == PosConst.PAY_DC_TYPE.PAY)
|
|
{
|
|
// 캠페인 사은품대상 상품과 중복불가 체크
|
|
if (cTrSaleCpi.CPI_CUST_BNFT_TYPE == ItemConst.CPI_CUST_BNFT.FREEGIFT || cTrSaleCpi.CPI_CUST_BNFT_TYPE == ItemConst.CPI_CUST_BNFT.FREE_SAVE)
|
|
{
|
|
nDisQty += cTrSaleCpi.DC_QTY;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// 결제할인
|
|
if (cTrSaleCpi.PAY_DC_DIV == PosConst.PAY_DC_TYPE.DC)
|
|
{
|
|
// 캠페인 할인 상품과 중복가능여부체크
|
|
if ((cMstSaleCpi.ITEM_DUP_PRMT_YN == "0" || cTrSaleCpi.ITEM_DUP_PRMT_YN == "0") && cTrSaleCpi.DC_QTY > 0)
|
|
{
|
|
nDisQty += cTrSaleCpi.DC_QTY;
|
|
break;
|
|
}
|
|
}
|
|
else if (cTrSaleCpi.PAY_DC_DIV == PosConst.PAY_DC_TYPE.PAY)
|
|
{
|
|
if ((cTrSaleCpi.CPI_CUST_BNFT_TYPE == ItemConst.CPI_CUST_BNFT.FREEGIFT || cTrSaleCpi.CPI_CUST_BNFT_TYPE == ItemConst.CPI_CUST_BNFT.FREE_SAVE)
|
|
&& cTrSaleCpi.DC_SUM_AMT == 0) continue;
|
|
|
|
// 캠페인 결제할인 상품과 중복가능여부체크
|
|
nDisQty += cTrSaleCpi.DC_QTY;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// HP 사은품 행사
|
|
foreach (Column.TR_SALE_CPI_RSLT.DATA cTrSaleCpi in cSaleItem.alTrSaleCpi)
|
|
{
|
|
if (cMstSaleCpi.CPI_CUST_BNFT_TYPE == ItemConst.CPI_CUST_BNFT.FREEGIFT || cMstSaleCpi.CPI_CUST_BNFT_TYPE == ItemConst.CPI_CUST_BNFT.FREE_SAVE)
|
|
{
|
|
// 사은품
|
|
if (cTrSaleCpi.PAY_DC_DIV == PosConst.PAY_DC_TYPE.DC)
|
|
{
|
|
// 캠페인 할인 상품과 중복가능여부체크
|
|
if ((cMstSaleCpi.ITEM_DUP_PRMT_YN == "0" || cTrSaleCpi.ITEM_DUP_PRMT_YN == "0") && cTrSaleCpi.DC_QTY > 0)
|
|
{
|
|
nDisQty += cTrSaleCpi.DC_QTY;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// 결제할인
|
|
if (cTrSaleCpi.PAY_DC_DIV == PosConst.PAY_DC_TYPE.DC)
|
|
{
|
|
// 캠페인 할인 상품과 중복가능여부체크
|
|
if ((cMstSaleCpi.ITEM_DUP_PRMT_YN == "0" || cTrSaleCpi.ITEM_DUP_PRMT_YN == "0") && cTrSaleCpi.DC_QTY > 0)
|
|
{
|
|
nDisQty += cTrSaleCpi.DC_QTY;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (nDisQty == 0)
|
|
{
|
|
nDestQty = cSaleItem.SALE_QTY;
|
|
nPrice = cSaleItem.SALE_PRC;
|
|
|
|
// 캠페인 대상 체크(상품캠페인) - 예외할인, 추가금액할인 제외
|
|
if (cMstSaleCpi.TRGT_CUST_TYPE == ItemConst.CPI_TRGT_CUST_TYPE.NORMAL && cMstSaleCpi.CUST_PAY_TYPE == ItemConst.CPI_CUST_PAY_TYPE.NORMAL)
|
|
{
|
|
nDestAmt = CmUtil.DoubleAdd(cSaleItem.BILL_AMT, CmUtil.DoubleAdd(cSaleItem.EXCEP_DC_AMT, cSaleItem.ETC_DC_AMT));
|
|
}
|
|
else
|
|
{
|
|
//#20171206 17크리스마스캠페인 start
|
|
//할인, 할인+적립 캠페인인 경우 제휴할인그룹 중복 여부에 따라 할인대상금액 계산
|
|
//기존
|
|
//nDestAmt = cSaleItem.BILL_AMT;
|
|
//변경
|
|
|
|
if (cMstSaleCpi.CPI_CUST_BNFT_TYPE == ItemConst.CPI_CUST_BNFT.DISCOUNT || cMstSaleCpi.CPI_CUST_BNFT_TYPE == ItemConst.CPI_CUST_BNFT.DIS_SAVE)
|
|
{
|
|
if ((cMstSaleCpi.TELECOM_COOP_DUP_PRMT_YN == "2") &&
|
|
(cSaleItem.COOP_CARD_DC_DIV.Substring(0, 2) == ItemConst.TR_ITEM_ID.MOBILE_COM_POINT) &&
|
|
(cSaleItem.COOP_CARD_DC_DIV.Substring(2, 2) == ItemConst.TR_ITEM_ID.MOBILE_COM.MOBILE_SKT ||
|
|
cSaleItem.COOP_CARD_DC_DIV.Substring(2, 2) == ItemConst.TR_ITEM_ID.MOBILE_COM.MOBILE_KTF ||
|
|
//#20180413 웰컴카드 신규기능 추가 start,phj
|
|
cSaleItem.COOP_CARD_DC_DIV.Substring(2, 2) == ItemConst.TR_ITEM_ID.MOBILE_COM.WELCOMECARD ||
|
|
//#20180413 웰컴카드 신규기능 추가 end,phj
|
|
cSaleItem.COOP_CARD_DC_DIV.Substring(2, 2) == ItemConst.TR_ITEM_ID.MOBILE_COM.MOBILE_LGT))
|
|
{
|
|
nDestAmt = cSaleItem.BILL_AMT + cSaleItem.COOP_CARD_DC_AMT;
|
|
}
|
|
else
|
|
{
|
|
nDestAmt = cSaleItem.BILL_AMT;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
nDestAmt = cSaleItem.BILL_AMT;
|
|
}
|
|
|
|
//#20171206 17크리스마스캠페인 end
|
|
}
|
|
}
|
|
else if (cSaleItem.SALE_QTY > nDisQty)
|
|
{
|
|
nDestQty = cSaleItem.SALE_QTY - nDisQty;
|
|
nPrice = cSaleItem.SALE_PRC;
|
|
|
|
// 캠페인 대상 체크(상품캠페인) - 예외할인, 추가금액할인 제외
|
|
if (cMstSaleCpi.TRGT_CUST_TYPE == ItemConst.CPI_TRGT_CUST_TYPE.NORMAL && cMstSaleCpi.CUST_PAY_TYPE == ItemConst.CPI_CUST_PAY_TYPE.NORMAL)
|
|
{
|
|
nDestAmt = CmUtil.DoubleAdd(cSaleItem.BILL_AMT,CmUtil.DoubleAdd(cSaleItem.EXCEP_DC_AMT, cSaleItem.ETC_DC_AMT));
|
|
nDestAmt = CmUtil.DoubleMultiplication(CmUtil.DoubleDivision(nDestAmt, cSaleItem.SALE_QTY), nDestQty);
|
|
}
|
|
else
|
|
{
|
|
nDestAmt = CmUtil.DoubleMultiplication(nDestQty, nPrice);
|
|
}
|
|
}
|
|
|
|
if (sPayDcDiv == PosConst.PAY_DC_TYPE.PAY)
|
|
{
|
|
if (nDestAmt / nDestQty < nPrice) nPrice = CmUtil.DoubleDivision(nDestAmt, nDestQty);
|
|
}
|
|
}
|
|
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 nPrice;
|
|
}
|
|
#endregion
|
|
|
|
#region ExistCampaignDiscount 캠페인 할인 적용 여부 체크
|
|
/// <summary>
|
|
/// 캠페인 할인 적용(중복불가 체크) 여부 체크
|
|
/// </summary>
|
|
/// <returns>true:중복불가, false:중복가능</returns>
|
|
public bool ExistCampaignDupApply(string sCPI_CUST_BNFT_TYPE, string sDUP_APPLY_YN)
|
|
{
|
|
try
|
|
{
|
|
// 캠페인 상품
|
|
foreach (Column.TR_PLU.DATA cSaleItem in m_alTrPluItem)
|
|
{
|
|
if (cSaleItem.CANCEL_DIV == PosConst.CANCEL_DIV.CANCEL || cSaleItem.CANCEL_DIV_MAIN == PosConst.CANCEL_DIV.CANCEL) continue; // 지정취소
|
|
if (cSaleItem.BILLSPR_NO != m_cTrnStatus.Sale.BillSplitNo) continue; // 빌분리번호
|
|
if (cSaleItem.SALE_PRC == 0) continue;
|
|
|
|
foreach (Column.TR_SALE_CPI_RSLT.DATA cTrSaleCpi in cSaleItem.alTrSaleCpi)
|
|
{
|
|
// 캠페인 할인이 적용 되어있으면 중복 안함 => 중복 가능여부(1:중복적용 가능, 0:중복적용 불가)
|
|
if (cTrSaleCpi.DC_SUM_AMT > 0 && sDUP_APPLY_YN == "0") return true;
|
|
if (cTrSaleCpi.DC_SUM_AMT > 0 && cTrSaleCpi.DUP_APPLY_YN == "0") return true;
|
|
}
|
|
}
|
|
|
|
// 캠페인 정보
|
|
foreach (Column.TR_SALE_CPI_RSLT.DATA cTrSaleCpi in m_alTrSaleCpi)
|
|
{
|
|
if (cTrSaleCpi.CANCEL_DIV == PosConst.CANCEL_DIV.CANCEL) continue;
|
|
|
|
// 적립 캠페인은 다름 캠페인과 중복 불가 체크 하지 않음
|
|
if (cTrSaleCpi.CPI_CUST_BNFT_TYPE == ItemConst.CPI_CUST_BNFT.PNTSAVE ||
|
|
|
|
//#17169 스마일페이 변경요청 건 start
|
|
//기존
|
|
//cTrSaleCpi.CPI_CUST_BNFT_TYPE == ItemConst.CPI_CUST_BNFT.DIS_SAVE ||
|
|
//변경
|
|
//스마일페이결제할인캠페인일 때는 ItemConst.CPI_CUST_BNFT.DIS_SAVE 값이라도 중복가능여부 체크하도록 할까?
|
|
//어차피 아직은 스마일페이결제할인캠페인은 m_alTrSaleCpi 이곳에 없겠지만....
|
|
(cTrSaleCpi.CPI_CUST_BNFT_TYPE == ItemConst.CPI_CUST_BNFT.DIS_SAVE && cTrSaleCpi.CUST_PAY_TYPE != ItemConst.CPI_CUST_PAY_TYPE.SMILEPAY) ||
|
|
//#17169 스마일페이 변경요청 건 end
|
|
|
|
cTrSaleCpi.CPI_CUST_BNFT_TYPE == ItemConst.CPI_CUST_BNFT.FREE_SAVE) continue;
|
|
|
|
// 캠페인 중복적용 여부(1:중복적용 가능, 0:중복적용 불가)
|
|
if (cTrSaleCpi.DUP_APPLY_YN == "0" || sDUP_APPLY_YN == "0") 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>
|
|
/// <returns></returns>
|
|
public bool ExistCampaignDiscount(string sCPI_CD)
|
|
{
|
|
try
|
|
{
|
|
foreach (Column.TR_PLU.DATA cSaleItem in m_alTrPluItem)
|
|
{
|
|
if (cSaleItem.CANCEL_DIV == PosConst.CANCEL_DIV.CANCEL || cSaleItem.CANCEL_DIV_MAIN == PosConst.CANCEL_DIV.CANCEL) continue; // 지정취소
|
|
if (cSaleItem.BILLSPR_NO != m_cTrnStatus.Sale.BillSplitNo) continue; // 빌분리번호
|
|
if (cSaleItem.SALE_PRC == 0) continue;
|
|
|
|
foreach (Column.TR_SALE_CPI_RSLT.DATA cTrSaleCpi in cSaleItem.alTrSaleCpi)
|
|
{
|
|
if (sCPI_CD != cTrSaleCpi.CPI_CD) continue;
|
|
|
|
if (cTrSaleCpi.DC_SUM_AMT > 0) 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;
|
|
}
|
|
#endregion
|
|
|
|
#region GetCampaignSaleQtyReqDiv 캠페인 구성 자격 구분에 따른 대상 상품수량 획득
|
|
/// <summary>
|
|
/// 캠페인 구성 자격 구분에 따른 대상 상품수량 획득
|
|
/// </summary>
|
|
/// <param name="sCompntReqDiv">구성자격구분</param>
|
|
/// <param name="nCompntAmt">구성금액</param>
|
|
/// <param name="nQty">수량</param>
|
|
/// <param name="nAmount">금액</param>
|
|
/// <returns></returns>
|
|
public long GetCampaignDisQtyCompntReqDiv(string sCompntReqDiv, double nCompntAmt, long nQty, double nAmount)
|
|
{
|
|
long nDisQty = 0;
|
|
try
|
|
{
|
|
if (sCompntReqDiv == ItemConst.CPI_COND_TYPE.MATCH_QTY) // 수량
|
|
{
|
|
nDisQty = nQty / (long)nCompntAmt;
|
|
}
|
|
else if (sCompntReqDiv == ItemConst.CPI_COND_TYPE.MIN_AMT) // 금액
|
|
{
|
|
if (nAmount >= nCompntAmt) nDisQty = nQty;
|
|
}
|
|
else if (sCompntReqDiv == ItemConst.CPI_COND_TYPE.MIN_QTY) // 최소수량
|
|
{
|
|
if (nQty >= (long)nCompntAmt) nDisQty = nQty;
|
|
}
|
|
}
|
|
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 nDisQty;
|
|
}
|
|
#endregion
|
|
|
|
#region CheckCampaignReqAmt 캠페인 성립금액 구분 체크
|
|
/// <summary>
|
|
/// 캠페인 성립금액 구분 체크
|
|
/// </summary>
|
|
/// <param name="cMstSaleCpi"></param>
|
|
/// <param name="sCpiCode"></param>
|
|
/// <param name="nSaleAmt"></param>
|
|
/// <returns></returns>
|
|
public bool CheckCampaignReqAmt(Column.MST_SALE_CPI.DATA cMstSaleCpi, string sCpiCode, long nSaleQty, double nSaleAmt)
|
|
{
|
|
try
|
|
{
|
|
// 조건의 캠페인 성립금액 체크
|
|
if (cMstSaleCpi.TRGT_AMT_TYPE == ItemConst.CPI_TRGT_AMT_TYPE.RECT_AMT || cMstSaleCpi.TRGT_AMT_TYPE == ItemConst.CPI_TRGT_AMT_TYPE.RECT_ITEM_AMT)
|
|
{
|
|
//캠페인 구매금액 체크
|
|
if (cMstSaleCpi.TRGT_AMT > m_cTrnStatus.Sale.NetSaleAmt) return false; // 구매금액체크
|
|
}
|
|
|
|
if (cMstSaleCpi.TRGT_AMT_TYPE == ItemConst.CPI_TRGT_AMT_TYPE.ITEM_AMT || cMstSaleCpi.TRGT_AMT_TYPE == ItemConst.CPI_TRGT_AMT_TYPE.RECT_ITEM_AMT)
|
|
{
|
|
// 대상상품 금액체크
|
|
if (sCpiCode != "") GetCampaignSaleQtyAmt(cMstSaleCpi, cMstSaleCpi.CPI_CD, "", "", ref nSaleQty, ref nSaleAmt, "0");
|
|
|
|
// 대상상품 등록 여부 체크
|
|
if (nSaleQty == 0 && nSaleAmt == 0) return false;
|
|
|
|
// 대상상품 금액체크
|
|
if (cMstSaleCpi.TRGT_AMT_TYPE == ItemConst.CPI_TRGT_AMT_TYPE.ITEM_AMT)
|
|
{
|
|
//캠페인 구매금액 체크
|
|
if (cMstSaleCpi.TRGT_AMT > nSaleAmt) return false;
|
|
}
|
|
}
|
|
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;
|
|
}
|
|
#endregion
|
|
|
|
#region ClearCampaginItem 등록된 캠페인 리스트에서 해당 캠페인의 적용정보를 삭제 한다
|
|
/// <summary>
|
|
/// 등록된 캠페인 리스트에서 해당 캠페인의 적용정보를 삭제.
|
|
/// </summary>
|
|
/// <param name="sCpiCode">캠페인코드</param>
|
|
/// <returns></returns>
|
|
public bool ClearCampaginItem(string sCpiCode)
|
|
{
|
|
return ClearCampaginItem(sCpiCode, true);
|
|
}
|
|
/// <summary>
|
|
/// 등록된 캠페인 리스트에서 해당 캠페인의 적용정보를 삭제.
|
|
/// </summary>
|
|
/// <param name="sCpiCode">캠페인코드</param>
|
|
/// <param name="bClearPlu">상품캠페인삭제여부</param>
|
|
/// <returns></returns>
|
|
public bool ClearCampaginItem(string sCpiCode, bool bClearPlu)
|
|
{
|
|
try
|
|
{
|
|
if (bClearPlu == true)
|
|
{
|
|
// 상품 캠페인 정보
|
|
foreach (Column.TR_PLU.DATA cPluItem in m_alTrPluItem)
|
|
{
|
|
if (cPluItem.alTrSaleCpi == null) continue;
|
|
|
|
foreach (Column.TR_SALE_CPI_RSLT.DATA cTrSaleCpi in cPluItem.alTrSaleCpi)
|
|
{
|
|
if (sCpiCode == "" || sCpiCode == cTrSaleCpi.CPI_CD)
|
|
{
|
|
cTrSaleCpi.DC_QTY = 0;
|
|
cTrSaleCpi.DC_PRC = 0;
|
|
cTrSaleCpi.DC_SUM_AMT = 0;
|
|
cTrSaleCpi.ACCUM_POINT = 0;
|
|
|
|
cTrSaleCpi.PAY_DC_DIV = "0";
|
|
}
|
|
}
|
|
|
|
ExeccutePluItemAmount(cPluItem);
|
|
}
|
|
}
|
|
|
|
// 상품외 캠페인 정보
|
|
foreach(Column.TR_SALE_CPI_RSLT.DATA cTrSaleCpi in m_alTrSaleCpi)
|
|
{
|
|
if (sCpiCode == "" || sCpiCode == cTrSaleCpi.CPI_CD) cTrSaleCpi.CANCEL_DIV = "1";
|
|
}
|
|
|
|
// 상품 합계금액 계산(거래해더)
|
|
m_cDataService.UpdatePluAmount(true);
|
|
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;
|
|
}
|
|
#endregion
|
|
|
|
#region ExeccutePluItemAmount 상품 판매가 재계산
|
|
/// <summary>
|
|
/// 상품 판매가 재계산
|
|
/// </summary>
|
|
private void ExeccutePluItemAmount(Column.TR_PLU.DATA cPluItem)
|
|
{
|
|
try
|
|
{
|
|
// 캠페인 행사 합계금액 계산
|
|
cPluItem.CPI_DC_QTY = 0;
|
|
cPluItem.CPI_DC_AMT = 0;
|
|
foreach (Column.TR_SALE_CPI_RSLT.DATA cTrSaleCpi in cPluItem.alTrSaleCpi)
|
|
{
|
|
if (cTrSaleCpi.PAY_DC_DIV == PosConst.PAY_DC_TYPE.DC) // 결제할인구분 (1:결제, 2:할인)
|
|
{
|
|
cPluItem.CPI_DC_QTY += cTrSaleCpi.DC_QTY;
|
|
cPluItem.CPI_DC_AMT = CmUtil.DoubleAdd(cPluItem.CPI_DC_AMT, cTrSaleCpi.DC_SUM_AMT);
|
|
}
|
|
}
|
|
|
|
// 상품별 판매금액 재계산
|
|
m_cDataService.UpdatePluItemAmount(cPluItem);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
|
|
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region AddSaleItemTrSaleCpiData 상품정보에 캠페인 정보 추가
|
|
/// <summary>
|
|
/// 상품정보에 캠페인 정보 추가
|
|
/// </summary>
|
|
public Column.TR_SALE_CPI_RSLT.DATA AddSaleItemTrSaleCpiData(Column.TR_PLU.DATA cSaleItem, string sCPI_CD, string sITEM_COMPNT_GRP, string sCPI_DC_DIV, double nCPI_DC_AMT)
|
|
{
|
|
try
|
|
{
|
|
if (cSaleItem.alTrSaleCpi == null) return null;
|
|
|
|
foreach (Column.TR_SALE_CPI_RSLT.DATA cSaleCpi in cSaleItem.alTrSaleCpi)
|
|
{
|
|
if (cSaleCpi.CPI_CD == sCPI_CD && cSaleCpi.cMST_CPI_ITEM.CPI_ITEM_GRP_CD == sITEM_COMPNT_GRP) return cSaleCpi;
|
|
}
|
|
|
|
if (m_htMstSaleCpi.Contains(sCPI_CD) == false) return null;
|
|
|
|
// 캠페인 조건 정보 획득
|
|
Column.MST_SALE_CPI.DATA cMstSaleCpi = (Column.MST_SALE_CPI.DATA)m_htMstSaleCpi[sCPI_CD];
|
|
|
|
Column.TR_SALE_CPI_RSLT.DATA cTrSaleCpi = new Column.TR_SALE_CPI_RSLT.DATA();
|
|
|
|
// 캠페인 실적 정보 설정
|
|
cTrSaleCpi.CPI_CD = sCPI_CD;
|
|
cTrSaleCpi.ITEM_APPLY_METHD = cMstSaleCpi.ITEM_APPLY_METHD;
|
|
cTrSaleCpi.SUB_SHOP_CD = cSaleItem.SUB_SHOP_CD;
|
|
cTrSaleCpi.ITEM_PLU_CD = cSaleItem.ITEM_PLU_CD;
|
|
cTrSaleCpi.DC_QTY = 0;
|
|
cTrSaleCpi.DC_PRC = 0;
|
|
cTrSaleCpi.DC_SUM_AMT = 0;
|
|
cTrSaleCpi.CPI_CUST_BNFT_TYPE = cMstSaleCpi.CPI_CUST_BNFT_TYPE;
|
|
cTrSaleCpi.LTTR_NMPLAT_NO = "";
|
|
cTrSaleCpi.TRGT_CUST_TYPE = cMstSaleCpi.TRGT_CUST_TYPE;
|
|
cTrSaleCpi.BILLSPR_NO = m_cTrnStatus.Sale.BillSplitNo;
|
|
cTrSaleCpi.SLACK_FIELD = "";
|
|
cTrSaleCpi.CANCEL_DIV = "0";
|
|
cTrSaleCpi.ACCUM_POINT = 0;
|
|
cTrSaleCpi.CUST_PAY_TYPE = cMstSaleCpi.CUST_PAY_TYPE;
|
|
cTrSaleCpi.PRESENT_DIV = "0";
|
|
|
|
cTrSaleCpi.PAY_DC_DIV = "0";
|
|
cTrSaleCpi.BASIC_RULE_EXCEP_YN = cMstSaleCpi.BASIC_RULE_EXCEP_YN;
|
|
cTrSaleCpi.TELECOM_COOP_DUP_PRMT_YN = cMstSaleCpi.TELECOM_COOP_DUP_PRMT_YN;
|
|
|
|
//#15583 캠페인 기능 개선 요청 start
|
|
cTrSaleCpi.MOBILE_CPN_DUP_PRMT_YN = cMstSaleCpi.MOBILE_CPN_DUP_PRMT_YN;
|
|
cTrSaleCpi.HPY_CPN_DUP_PRMT_YN = cMstSaleCpi.HPY_CPN_DUP_PRMT_YN;
|
|
//#15583 캠페인 기능 개선 요청 end
|
|
|
|
cTrSaleCpi.BASIC_HP_ACCUM_YN = cMstSaleCpi.BASIC_HP_ACCUM_YN;
|
|
cTrSaleCpi.BASIC_HP_ACCUM_STD = cMstSaleCpi.BASIC_HP_ACCUM_STD;
|
|
cTrSaleCpi.DUP_APPLY_YN = cMstSaleCpi.DUP_APPLY_YN;
|
|
|
|
// 캠페인 상품정보 설정
|
|
cTrSaleCpi.cMST_CPI_ITEM.CPI_ITEM_GRP_CD = sITEM_COMPNT_GRP.Trim();
|
|
cTrSaleCpi.cMST_CPI_ITEM.CPI_DC_TYPE = sCPI_DC_DIV;
|
|
cTrSaleCpi.cMST_CPI_ITEM.DC_RATE_AMT = nCPI_DC_AMT;
|
|
|
|
cTrSaleCpi.ITEM_DUP_PRMT_YN = cMstSaleCpi.ITEM_DUP_PRMT_YN;
|
|
|
|
//#17169 스마일페이 변경요청 건 start
|
|
cTrSaleCpi.OFFER_ID = cMstSaleCpi.OFFER_ID;
|
|
//#17169 스마일페이 변경요청 건 end
|
|
|
|
cSaleItem.alTrSaleCpi.Add(cTrSaleCpi);
|
|
|
|
return cTrSaleCpi;
|
|
}
|
|
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 AddTrCampaignData 캠페인 아이템에 캠페인 실적정보 추가
|
|
/// <summary>
|
|
/// 캠페인 아이템에 캠페인 실적정보 추가
|
|
/// </summary>
|
|
public Column.TR_SALE_CPI_RSLT.DATA AddTrCampaignData(string sCPI_CD, long nSavePnt, string sLttrNmplatNo, string sLttrGrade)
|
|
{
|
|
try
|
|
{
|
|
// 캠페인 조건 정보 획득
|
|
if (m_htMstSaleCpi.Contains(sCPI_CD) == false) return null;
|
|
Column.MST_SALE_CPI.DATA cMstSaleCpi = (Column.MST_SALE_CPI.DATA)m_htMstSaleCpi[sCPI_CD];
|
|
|
|
Column.TR_SALE_CPI_RSLT.DATA cTrSaleCpi = new Column.TR_SALE_CPI_RSLT.DATA();
|
|
|
|
// 캠페인 실적 정보 설정
|
|
cTrSaleCpi.CPI_CD = sCPI_CD;
|
|
cTrSaleCpi.ITEM_APPLY_METHD = cMstSaleCpi.ITEM_APPLY_METHD;
|
|
cTrSaleCpi.SUB_SHOP_CD = "";
|
|
cTrSaleCpi.ITEM_PLU_CD = "";
|
|
cTrSaleCpi.DC_QTY = 1;
|
|
cTrSaleCpi.DC_PRC = 0;
|
|
cTrSaleCpi.DC_SUM_AMT = 0;
|
|
cTrSaleCpi.CPI_CUST_BNFT_TYPE = cMstSaleCpi.CPI_CUST_BNFT_TYPE;
|
|
cTrSaleCpi.LTTR_NMPLAT_NO = sLttrNmplatNo;
|
|
cTrSaleCpi.TRGT_CUST_TYPE = cMstSaleCpi.TRGT_CUST_TYPE;
|
|
cTrSaleCpi.BILLSPR_NO = m_cTrnStatus.Sale.BillSplitNo;
|
|
cTrSaleCpi.SLACK_FIELD = m_sHpCustID;
|
|
cTrSaleCpi.CANCEL_DIV = "0";
|
|
cTrSaleCpi.ACCUM_POINT = nSavePnt;
|
|
cTrSaleCpi.CUST_PAY_TYPE = cMstSaleCpi.CUST_PAY_TYPE;
|
|
cTrSaleCpi.PRESENT_DIV = "0";
|
|
|
|
cTrSaleCpi.PAY_DC_DIV = "0";
|
|
cTrSaleCpi.BASIC_RULE_EXCEP_YN = cMstSaleCpi.BASIC_RULE_EXCEP_YN;
|
|
cTrSaleCpi.TELECOM_COOP_DUP_PRMT_YN = cMstSaleCpi.TELECOM_COOP_DUP_PRMT_YN;
|
|
|
|
//#15583 캠페인 기능 개선 요청 start
|
|
cTrSaleCpi.MOBILE_CPN_DUP_PRMT_YN = cMstSaleCpi.MOBILE_CPN_DUP_PRMT_YN;
|
|
cTrSaleCpi.HPY_CPN_DUP_PRMT_YN = cMstSaleCpi.HPY_CPN_DUP_PRMT_YN;
|
|
//#15583 캠페인 기능 개선 요청 end
|
|
|
|
cTrSaleCpi.BASIC_HP_ACCUM_YN = cMstSaleCpi.BASIC_HP_ACCUM_YN;
|
|
cTrSaleCpi.BASIC_HP_ACCUM_STD = cMstSaleCpi.BASIC_HP_ACCUM_STD;
|
|
cTrSaleCpi.LTTR_GRADE = sLttrGrade;
|
|
cTrSaleCpi.DUP_APPLY_YN = cMstSaleCpi.DUP_APPLY_YN;
|
|
cTrSaleCpi.OFFER_ID = cMstSaleCpi.OFFER_ID;
|
|
|
|
cTrSaleCpi.ITEM_DUP_PRMT_YN = cMstSaleCpi.ITEM_DUP_PRMT_YN;
|
|
|
|
m_alTrSaleCpi.Add(cTrSaleCpi);
|
|
|
|
return cTrSaleCpi;
|
|
}
|
|
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 CheckCampaginCard 캠페인 카드 마스터 체크
|
|
/// <summary>
|
|
/// 캠페인 카드 마스터 체크
|
|
/// </summary>
|
|
/// <param name="sCpiCode"></param>
|
|
/// <param name="sCardNo"></param>
|
|
/// <returns></returns>
|
|
public bool CheckCampaginCard(string sCpiCode, string sCardNo, bool bUsePrefix)
|
|
{
|
|
bool bExistCpi = false;
|
|
bool bExistCardPreFix = false;
|
|
|
|
try
|
|
{
|
|
foreach (string[] saCpiCard in m_alMstCpiCard)
|
|
{
|
|
if(saCpiCard[0] == sCpiCode)
|
|
{
|
|
bExistCpi = true;
|
|
|
|
int nLen = saCpiCard[1].Length;
|
|
if (nLen > 0 && sCardNo.Length >= nLen)
|
|
{
|
|
bool bExist = false;
|
|
if (saCpiCard[1] == sCardNo.Substring(0, nLen)) bExist = true;
|
|
else if (nLen == 6)
|
|
{
|
|
if (saCpiCard[1] == sCardNo.Substring(0, 5) + "X") bExist = true;
|
|
else if (saCpiCard[1] == sCardNo.Substring(0, 4) + "XX") bExist = true;
|
|
else if (saCpiCard[1] == sCardNo.Substring(0, 3) + "XXX") bExist = true;
|
|
else if (saCpiCard[1] == sCardNo.Substring(0, 2) + "XXXX") bExist = true;
|
|
else if (saCpiCard[1] == sCardNo.Substring(0, 1) + "XXXXX") bExist = true;
|
|
}
|
|
if (bExist == false) continue;
|
|
}
|
|
|
|
// 서비스코드 체크
|
|
int nLoc = CmUtil.IntParse(saCpiCard[2]);
|
|
string sCheckValue = saCpiCard[3];
|
|
if (nLoc > 0 && sCheckValue.Trim() != "")
|
|
{
|
|
if (CmUtil.MidH(sCardNo, nLoc - 1, sCheckValue.Length) == sCheckValue)
|
|
{
|
|
bExistCardPreFix = true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
bExistCardPreFix = true;
|
|
}
|
|
|
|
if (bExistCardPreFix == true) break;
|
|
}
|
|
}
|
|
|
|
if (bExistCpi == false && bUsePrefix == false) bExistCardPreFix = 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 bExistCardPreFix;
|
|
}
|
|
#endregion
|
|
|
|
#region 추가 적립 행사 계산
|
|
/// <summary>
|
|
/// 추가 적립 행사 계산
|
|
/// </summary>
|
|
/// <param name="cMstSaleCpi"></param>
|
|
/// <returns></returns>
|
|
public long CampaignHappyPointSave(Column.MST_SALE_CPI.DATA cMstSaleCpi, ref double nSaveAmt, ref long nSavePnt)
|
|
{
|
|
nSaveAmt = 0; nSavePnt = 0;
|
|
try
|
|
{
|
|
foreach (Column.TR_PLU.DATA cPluItem in m_alTrPluItem)
|
|
{
|
|
if (cPluItem.ACCUM_PRMT_YN == "0") continue; // 추가적립구분 => 대상상품
|
|
|
|
if (cPluItem.CANCEL_DIV == PosConst.CANCEL_DIV.CANCEL || cPluItem.CANCEL_DIV_MAIN == PosConst.CANCEL_DIV.CANCEL) continue; // 지정취소
|
|
if (cPluItem.BILLSPR_NO != m_cTrnStatus.Sale.BillSplitNo) continue; // 빌분리번호
|
|
if (cPluItem.SALE_PRC == 0) continue;
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
bool bExist = false;
|
|
if (cMstSaleCpi.ADD_HP_ACCUM_TRGT_STD == ItemConst.CPI_ADD_ACCUM_DIV.ITEM_AMT)
|
|
{
|
|
// 추가적립구분 => 대상상품
|
|
foreach (Column.TR_SALE_CPI_RSLT.DATA cTrSaleCpi in cPluItem.alTrSaleCpi)
|
|
{
|
|
if (cMstSaleCpi.CPI_CD == cTrSaleCpi.CPI_CD)
|
|
{
|
|
bExist = true;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
bExist = true;
|
|
if (cMstSaleCpi.ADD_HP_ACCUM_TRGT_STD == ItemConst.CPI_ADD_ACCUM_DIV.NOT_ITEM_AMT)
|
|
{
|
|
// 추가적립구분 => 대상상품외
|
|
foreach (Column.TR_SALE_CPI_RSLT.DATA cTrSaleCpi in cPluItem.alTrSaleCpi)
|
|
{
|
|
if (cMstSaleCpi.CPI_CD == cTrSaleCpi.CPI_CD)
|
|
{
|
|
bExist = false;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (bExist == false) continue;
|
|
|
|
// 추가적립 대상 상품 존재
|
|
if ((cPluItem.ITEM_DC_AMT > 0 || cPluItem.SUM_DC_AMT > 0) && cPluItem.DC_DIV.Length >= 4) // 단품 할인, 소계 할인 금액
|
|
{
|
|
// HP 기본 적립 여부(0:불가, 1:가능, 2:제외)
|
|
if (PosMstManager.GetMstPayDc(cPluItem.DC_DIV.Substring(0, 2), cPluItem.DC_DIV.Substring(2, 2), PosMst.MST_PAY_DC.DATA.HP_BASIC_ACCUM_YN) == "0") return 0;
|
|
if (PosMstManager.GetMstPayDc(cPluItem.DC_DIV.Substring(0, 2), cPluItem.DC_DIV.Substring(2, 2), PosMst.MST_PAY_DC.DATA.HP_BASIC_ACCUM_YN) == "2") continue;
|
|
}
|
|
if (cPluItem.COOP_CARD_DC_AMT > 0 && cPluItem.COOP_CARD_DC_DIV.Length >= 4) // 제휴 할인 금액
|
|
{
|
|
// HP 기본 적립 여부(0:불가, 1:가능, 2:제외)
|
|
if (PosMstManager.GetMstPayDc(cPluItem.COOP_CARD_DC_DIV.Substring(0, 2), cPluItem.COOP_CARD_DC_DIV.Substring(2, 2), PosMst.MST_PAY_DC.DATA.HP_BASIC_ACCUM_YN) == "0") return 0;
|
|
if (PosMstManager.GetMstPayDc(cPluItem.COOP_CARD_DC_DIV.Substring(0, 2), cPluItem.COOP_CARD_DC_DIV.Substring(2, 2), PosMst.MST_PAY_DC.DATA.HP_BASIC_ACCUM_YN) == "2") continue;
|
|
}
|
|
if (cPluItem.POINT_DC_AMT > 0 && cPluItem.POINT_DC_DIV.Length >= 4) // 포인트 할인 금액
|
|
{
|
|
// HP 기본 적립 여부(0:불가, 1:가능, 2:제외)
|
|
if (PosMstManager.GetMstPayDc(cPluItem.POINT_DC_DIV.Substring(0, 2), cPluItem.POINT_DC_DIV.Substring(2, 2), PosMst.MST_PAY_DC.DATA.HP_BASIC_ACCUM_YN) == "0") return 0;
|
|
if (PosMstManager.GetMstPayDc(cPluItem.POINT_DC_DIV.Substring(0, 2), cPluItem.POINT_DC_DIV.Substring(2, 2), PosMst.MST_PAY_DC.DATA.HP_BASIC_ACCUM_YN) == "2") continue;
|
|
}
|
|
if (cPluItem.CPN_DC_AMT > 0 && cPluItem.CPN_DC_DIV.Length >= 4) // 쿠폰 할인 금액
|
|
{
|
|
// HP 기본 적립 여부(0:불가, 1:가능, 2:제외)
|
|
if (PosMstManager.GetMstPayDc(cPluItem.CPN_DC_DIV.Substring(0, 2), cPluItem.CPN_DC_DIV.Substring(2, 2), PosMst.MST_PAY_DC.DATA.HP_BASIC_ACCUM_YN) == "0") return 0;
|
|
if (PosMstManager.GetMstPayDc(cPluItem.CPN_DC_DIV.Substring(0, 2), cPluItem.CPN_DC_DIV.Substring(2, 2), PosMst.MST_PAY_DC.DATA.HP_BASIC_ACCUM_YN) == "2") continue;
|
|
}
|
|
if (cPluItem.EMP_DC_AMT > 0 && cPluItem.EMP_DC_DIV.Length >= 4) // 직원 할인 금액
|
|
{
|
|
// HP 기본 적립 여부(0:불가, 1:가능, 2:제외)
|
|
if (PosMstManager.GetMstPayDc(cPluItem.EMP_DC_DIV.Substring(0, 2), cPluItem.EMP_DC_DIV.Substring(2, 2), PosMst.MST_PAY_DC.DATA.HP_BASIC_ACCUM_YN) == "0") return 0;
|
|
if (PosMstManager.GetMstPayDc(cPluItem.EMP_DC_DIV.Substring(0, 2), cPluItem.EMP_DC_DIV.Substring(2, 2), PosMst.MST_PAY_DC.DATA.HP_BASIC_ACCUM_YN) == "2") continue;
|
|
}
|
|
if (cPluItem.SET_DC_AMT > 0) // 세트할인
|
|
{
|
|
// HP 기본 적립 여부(0:불가, 1:가능, 2:제외)
|
|
if (PosMstManager.GetMstPayDc(ItemConst.PLU_DC_DIV.SET_DC.Substring(0, 2), ItemConst.PLU_DC_DIV.SET_DC.Substring(2, 2), PosMst.MST_PAY_DC.DATA.HP_BASIC_ACCUM_YN) == "0") return 0;
|
|
if (PosMstManager.GetMstPayDc(ItemConst.PLU_DC_DIV.SET_DC.Substring(0, 2), ItemConst.PLU_DC_DIV.SET_DC.Substring(2, 2), PosMst.MST_PAY_DC.DATA.HP_BASIC_ACCUM_YN) == "2") continue;
|
|
}
|
|
if (cPluItem.ETC_DC_AMT > 0 && cPluItem.ETC_DC_DIV.Length >= 4) // 기타 할인 금액
|
|
{
|
|
// HP 기본 적립 여부(0:불가, 1:가능, 2:제외)
|
|
if (PosMstManager.GetMstPayDc(cPluItem.ETC_DC_DIV.Substring(0, 2), cPluItem.ETC_DC_DIV.Substring(2, 2), PosMst.MST_PAY_DC.DATA.HP_BASIC_ACCUM_YN) == "0") return 0;
|
|
if (PosMstManager.GetMstPayDc(cPluItem.ETC_DC_DIV.Substring(0, 2), cPluItem.ETC_DC_DIV.Substring(2, 2), PosMst.MST_PAY_DC.DATA.HP_BASIC_ACCUM_YN) == "2") continue;
|
|
}
|
|
|
|
// 추가적립일때 캠페인 성립 상품과 중복 적용 가능여부 체크
|
|
long nDisQty = 0;
|
|
if (cPluItem.alTrSaleCpi != null)
|
|
{
|
|
foreach (Column.TR_SALE_CPI_RSLT.DATA cTrSaleCpi in cPluItem.alTrSaleCpi)
|
|
{
|
|
if (cMstSaleCpi.CPI_CD == cTrSaleCpi.CPI_CD) continue;
|
|
|
|
if (cTrSaleCpi.PAY_DC_DIV == PosConst.PAY_DC_TYPE.DC)
|
|
{
|
|
// 캠페인 할인 상품과 중복가능여부체크
|
|
if ((cMstSaleCpi.ITEM_DUP_PRMT_YN == "0" || cTrSaleCpi.ITEM_DUP_PRMT_YN == "0") && cTrSaleCpi.DC_QTY > 0)
|
|
{
|
|
nDisQty += cTrSaleCpi.DC_QTY;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (nDisQty == 0)
|
|
{
|
|
nSaveAmt = CmUtil.DoubleAdd(nSaveAmt, cPluItem.BILL_AMT);
|
|
}
|
|
else if (cPluItem.SALE_QTY > nDisQty)
|
|
{
|
|
nSaveAmt = CmUtil.DoubleAdd(nSaveAmt, CmUtil.DoubleMultiplication(cPluItem.SALE_QTY - nDisQty, cPluItem.SALE_PRC));
|
|
}
|
|
}
|
|
if (nSaveAmt <= 0) return 0;
|
|
|
|
// 캠페인 성립금액 구분 체크
|
|
if (CheckCampaignReqAmt(cMstSaleCpi, "", 0, nSaveAmt) == false) return 0;
|
|
|
|
// 해피포인트 적립 대상금액은 결제 금액중 적립가능 결제금액만 설정 함.
|
|
double nExceptPayAmt = 0;
|
|
ArrayList alPayItem = (ArrayList)StateObject.GetItemObject(Column.TR_PAYMENT.ITEM);
|
|
foreach (Column.TR_PAYMENT.DATA cPayItem in alPayItem)
|
|
{
|
|
if (cPayItem.CANCEL_DIV != PosConst.CANCEL_DIV.NORMAL) continue;
|
|
|
|
if (cPayItem.PAY_DTL_CD_05 == PosConst.PAY_DC_TYPE.PAY) // 할인결제구분 (1:결제, 2:할인)
|
|
{
|
|
// 결제수단별 HP 기본 적립 여부 체크(적립불가 결제수단) => HP 기본 적립 여부(0:불가, 1:가능, 2:제외)
|
|
if (PosMstManager.GetMstPayDc(cPayItem.PAY_WAY_CD, cPayItem.PAY_DTL_CD_01, PosMst.MST_PAY_DC.DATA.HP_BASIC_ACCUM_YN) == "0") return 0;
|
|
if (PosMstManager.GetMstPayDc(cPayItem.PAY_WAY_CD, cPayItem.PAY_DTL_CD_01, PosMst.MST_PAY_DC.DATA.HP_BASIC_ACCUM_YN) == "2")
|
|
{
|
|
nExceptPayAmt = CmUtil.DoubleAdd(nExceptPayAmt, cPayItem.PAY_AMT);
|
|
}
|
|
else if (cPayItem.PAY_WAY_CD == ItemConst.TR_ITEM_ID.CREDITCARD_ITEM && cPayItem.PAY_DTL_CD_01 == ItemConst.TR_ITEM_ID.CREDITCARD.CREDIT_CARD)
|
|
{
|
|
//#16745 신용카드 포인트 결제 시 해피포인트 취소되는 현상 확인요청 start
|
|
//기존
|
|
#region 기존
|
|
/*
|
|
// 신용카드 포인트사용 결제 적립 없음
|
|
if (CmUtil.IntParse(cPayItem.OCCUR_ENTRY_14) >= 60) nExceptPayAmt = CmUtil.DoubleAdd(nExceptPayAmt, cPayItem.PAY_AMT);
|
|
*/
|
|
#endregion 기존
|
|
//변경
|
|
#region 변경
|
|
if (CmUtil.IntParse(cPayItem.OCCUR_ENTRY_14) >= 60 && cPayItem.PAY_DTL_CD_02 != "")
|
|
{
|
|
switch (cPayItem.PAY_DTL_CD_02)
|
|
{
|
|
#region
|
|
case ItemConst.CREDITCARD_DC_TY.CREDIT_SPNT: //삼성포인트
|
|
if (PosMstManager.GetMstPayDc(ItemConst.TR_ITEM_ID.POINT_ITEM, ItemConst.TR_ITEM_ID.POINT_USE.SAMSUNG_POINT, PosMst.MST_PAY_DC.DATA.HP_BASIC_ACCUM_YN) == "0")
|
|
{
|
|
return 0;
|
|
}
|
|
else if (PosMstManager.GetMstPayDc(ItemConst.TR_ITEM_ID.POINT_ITEM, ItemConst.TR_ITEM_ID.POINT_USE.SAMSUNG_POINT, PosMst.MST_PAY_DC.DATA.HP_BASIC_ACCUM_YN) == "2")
|
|
{
|
|
nExceptPayAmt = CmUtil.DoubleAdd(nExceptPayAmt, cPayItem.PAY_AMT);
|
|
}
|
|
break;
|
|
case ItemConst.CREDITCARD_DC_TY.SHINHAN_CARD_POINT: //신한포인트
|
|
if (PosMstManager.GetMstPayDc(ItemConst.TR_ITEM_ID.POINT_ITEM, ItemConst.TR_ITEM_ID.POINT_USE.SHINHAN_POINT, PosMst.MST_PAY_DC.DATA.HP_BASIC_ACCUM_YN) == "0")
|
|
{
|
|
return 0;
|
|
}
|
|
else if (PosMstManager.GetMstPayDc(ItemConst.TR_ITEM_ID.POINT_ITEM, ItemConst.TR_ITEM_ID.POINT_USE.SHINHAN_POINT, PosMst.MST_PAY_DC.DATA.HP_BASIC_ACCUM_YN) == "2")
|
|
{
|
|
nExceptPayAmt = CmUtil.DoubleAdd(nExceptPayAmt, cPayItem.PAY_AMT);
|
|
}
|
|
break;
|
|
case ItemConst.CREDITCARD_DC_TY.HYUNDAI_M_POINTS: //현대M
|
|
if (PosMstManager.GetMstPayDc(ItemConst.TR_ITEM_ID.POINT_ITEM, ItemConst.TR_ITEM_ID.POINT_USE.HYUNDAI_MPOINTS, PosMst.MST_PAY_DC.DATA.HP_BASIC_ACCUM_YN) == "0")
|
|
{
|
|
return 0;
|
|
}
|
|
else if (PosMstManager.GetMstPayDc(ItemConst.TR_ITEM_ID.POINT_ITEM, ItemConst.TR_ITEM_ID.POINT_USE.HYUNDAI_MPOINTS, PosMst.MST_PAY_DC.DATA.HP_BASIC_ACCUM_YN) == "2")
|
|
{
|
|
nExceptPayAmt = CmUtil.DoubleAdd(nExceptPayAmt, cPayItem.PAY_AMT);
|
|
}
|
|
break;
|
|
// grayber@20180102 우리모아포인트 추가 start - 결제수단별 HP 기본 적립 여부 체크 분기 추가
|
|
case ItemConst.CREDITCARD_DC_TY.WOORIMORE_POINTS:
|
|
if (PosMstManager.GetMstPayDc(ItemConst.TR_ITEM_ID.POINT_ITEM, ItemConst.TR_ITEM_ID.POINT_USE.WOORIMORE_POINTS, PosMst.MST_PAY_DC.DATA.HP_BASIC_ACCUM_YN) == "0")
|
|
{
|
|
return 0;
|
|
}
|
|
else if (PosMstManager.GetMstPayDc(ItemConst.TR_ITEM_ID.POINT_ITEM, ItemConst.TR_ITEM_ID.POINT_USE.WOORIMORE_POINTS, PosMst.MST_PAY_DC.DATA.HP_BASIC_ACCUM_YN) == "2")
|
|
{
|
|
nExceptPayAmt = CmUtil.DoubleAdd(nExceptPayAmt, cPayItem.PAY_AMT);
|
|
}
|
|
break;
|
|
// grayber@20180102 우리모아포인트 추가 end
|
|
default:
|
|
if (CmUtil.IntParse(cPayItem.OCCUR_ENTRY_14) >= 60) nExceptPayAmt = CmUtil.DoubleAdd(nExceptPayAmt, cPayItem.PAY_AMT);
|
|
break;
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// 신용카드 포인트사용 결제 적립 없음
|
|
if (CmUtil.IntParse(cPayItem.OCCUR_ENTRY_14) >= 60) nExceptPayAmt = CmUtil.DoubleAdd(nExceptPayAmt, cPayItem.PAY_AMT);
|
|
}
|
|
#endregion 변경
|
|
//#16745 신용카드 포인트 결제 시 해피포인트 취소되는 현상 확인요청 end
|
|
|
|
}
|
|
}
|
|
}
|
|
if (nExceptPayAmt > 0)
|
|
{
|
|
//#20171219 할인, 적립 제외 금액 계산시 상품리스트에서 계산된 금액에서 빼도록 수정 start
|
|
//기존
|
|
//double nPaySaveAmt = m_cTrnStatus.Head.NetSaleAmt - nExceptPayAmt;
|
|
//변경
|
|
double nPaySaveAmt = nSaveAmt - nExceptPayAmt;
|
|
//#20171219 할인, 적립 제외 금액 계산시 상품리스트에서 계산된 금액에서 빼도록 수정 end
|
|
|
|
//#20171222 대상금액이 0보다 작은 경우 전문 오류 발생으로 0으로 변경 start
|
|
if (nPaySaveAmt <= 0) return 0;
|
|
//#20171222 대상금액이 0보다 작은 경우 전문 오류 발생으로 0으로 변경 end
|
|
|
|
if (nSaveAmt > nPaySaveAmt) nSaveAmt = nPaySaveAmt;
|
|
}
|
|
|
|
// 적립 포인트 계산
|
|
nSavePnt = (long)CmUtil.MathRounds(CmUtil.MathAmtPercent(nSaveAmt, cMstSaleCpi.ADD_HP_ACCUM_RATE), PosConst.MATH_ROUND.CEILING, 0);
|
|
}
|
|
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 nSavePnt;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 결제수단별 추가 적립 계산
|
|
/// </summary>
|
|
/// <param name="cMstSaleCpi"></param>
|
|
/// <returns></returns>
|
|
public double PaymentHappyPointSave()
|
|
{
|
|
double nSaveAmt = 0;
|
|
try
|
|
{
|
|
foreach (Column.TR_PLU.DATA cPluItem in m_alTrPluItem)
|
|
{
|
|
if (cPluItem.ACCUM_PRMT_YN == "0") continue; // 추가적립구분 => 대상상품
|
|
|
|
if (cPluItem.CANCEL_DIV == PosConst.CANCEL_DIV.CANCEL || cPluItem.CANCEL_DIV_MAIN == PosConst.CANCEL_DIV.CANCEL) continue; // 지정취소
|
|
if (cPluItem.BILLSPR_NO != m_cTrnStatus.Sale.BillSplitNo) continue; // 빌분리번호
|
|
if (cPluItem.SALE_PRC == 0) continue;
|
|
|
|
// 추가적립 대상 상품 존재
|
|
if ((cPluItem.ITEM_DC_AMT > 0 || cPluItem.SUM_DC_AMT > 0) && cPluItem.DC_DIV.Length >= 4) // 단품 할인, 소계 할인 금액
|
|
{
|
|
// HP 추가 적립 여부(0:불가, 1:가능, 2:제외)
|
|
if (PosMstManager.GetMstPayDc(cPluItem.DC_DIV.Substring(0, 2), cPluItem.DC_DIV.Substring(2, 2), PosMst.MST_PAY_DC.DATA.HP_ADD_ACCUM_DIV) == "0") return 0;
|
|
if (PosMstManager.GetMstPayDc(cPluItem.DC_DIV.Substring(0, 2), cPluItem.DC_DIV.Substring(2, 2), PosMst.MST_PAY_DC.DATA.HP_ADD_ACCUM_DIV) == "2") continue;
|
|
}
|
|
if (cPluItem.COOP_CARD_DC_AMT > 0 && cPluItem.COOP_CARD_DC_DIV.Length >= 4) // 제휴 할인 금액
|
|
{
|
|
// HP 추가 적립 여부(0:불가, 1:가능, 2:제외)
|
|
if (PosMstManager.GetMstPayDc(cPluItem.COOP_CARD_DC_DIV.Substring(0, 2), cPluItem.COOP_CARD_DC_DIV.Substring(2, 2), PosMst.MST_PAY_DC.DATA.HP_ADD_ACCUM_DIV) == "0") return 0;
|
|
if (PosMstManager.GetMstPayDc(cPluItem.COOP_CARD_DC_DIV.Substring(0, 2), cPluItem.COOP_CARD_DC_DIV.Substring(2, 2), PosMst.MST_PAY_DC.DATA.HP_ADD_ACCUM_DIV) == "2") continue;
|
|
}
|
|
if (cPluItem.POINT_DC_AMT > 0 && cPluItem.POINT_DC_DIV.Length >= 4) // 포인트 할인 금액
|
|
{
|
|
// HP 추가 적립 여부(0:불가, 1:가능, 2:제외)
|
|
if (PosMstManager.GetMstPayDc(cPluItem.POINT_DC_DIV.Substring(0, 2), cPluItem.POINT_DC_DIV.Substring(2, 2), PosMst.MST_PAY_DC.DATA.HP_ADD_ACCUM_DIV) == "0") return 0;
|
|
if (PosMstManager.GetMstPayDc(cPluItem.POINT_DC_DIV.Substring(0, 2), cPluItem.POINT_DC_DIV.Substring(2, 2), PosMst.MST_PAY_DC.DATA.HP_ADD_ACCUM_DIV) == "2") continue;
|
|
}
|
|
if (cPluItem.CPN_DC_AMT > 0 && cPluItem.CPN_DC_DIV.Length >= 4) // 쿠폰 할인 금액
|
|
{
|
|
// HP 추가 적립 여부(0:불가, 1:가능, 2:제외)
|
|
if (PosMstManager.GetMstPayDc(cPluItem.CPN_DC_DIV.Substring(0, 2), cPluItem.CPN_DC_DIV.Substring(2, 2), PosMst.MST_PAY_DC.DATA.HP_ADD_ACCUM_DIV) == "0") return 0;
|
|
if (PosMstManager.GetMstPayDc(cPluItem.CPN_DC_DIV.Substring(0, 2), cPluItem.CPN_DC_DIV.Substring(2, 2), PosMst.MST_PAY_DC.DATA.HP_ADD_ACCUM_DIV) == "2") continue;
|
|
}
|
|
if (cPluItem.EMP_DC_AMT > 0 && cPluItem.EMP_DC_DIV.Length >= 4) // 직원 할인 금액
|
|
{
|
|
// HP 추가 적립 여부(0:불가, 1:가능, 2:제외)
|
|
if (PosMstManager.GetMstPayDc(cPluItem.EMP_DC_DIV.Substring(0, 2), cPluItem.EMP_DC_DIV.Substring(2, 2), PosMst.MST_PAY_DC.DATA.HP_ADD_ACCUM_DIV) == "0") return 0;
|
|
if (PosMstManager.GetMstPayDc(cPluItem.EMP_DC_DIV.Substring(0, 2), cPluItem.EMP_DC_DIV.Substring(2, 2), PosMst.MST_PAY_DC.DATA.HP_ADD_ACCUM_DIV) == "2") continue;
|
|
}
|
|
if (cPluItem.SET_DC_AMT > 0) // 세트할인
|
|
{
|
|
// HP 추가 적립 여부(0:불가, 1:가능, 2:제외)
|
|
if (PosMstManager.GetMstPayDc(ItemConst.PLU_DC_DIV.SET_DC.Substring(0, 2), ItemConst.PLU_DC_DIV.SET_DC.Substring(2, 2), PosMst.MST_PAY_DC.DATA.HP_ADD_ACCUM_DIV) == "0") return 0;
|
|
if (PosMstManager.GetMstPayDc(ItemConst.PLU_DC_DIV.SET_DC.Substring(0, 2), ItemConst.PLU_DC_DIV.SET_DC.Substring(2, 2), PosMst.MST_PAY_DC.DATA.HP_ADD_ACCUM_DIV) == "2") continue;
|
|
}
|
|
if (cPluItem.ETC_DC_AMT > 0 && cPluItem.ETC_DC_DIV.Length >= 4) // 기타 할인 금액
|
|
{
|
|
// HP 추가 적립 여부(0:불가, 1:가능, 2:제외)
|
|
if (PosMstManager.GetMstPayDc(cPluItem.ETC_DC_DIV.Substring(0, 2), cPluItem.ETC_DC_DIV.Substring(2, 2), PosMst.MST_PAY_DC.DATA.HP_ADD_ACCUM_DIV) == "0") return 0;
|
|
if (PosMstManager.GetMstPayDc(cPluItem.ETC_DC_DIV.Substring(0, 2), cPluItem.ETC_DC_DIV.Substring(2, 2), PosMst.MST_PAY_DC.DATA.HP_ADD_ACCUM_DIV) == "2") continue;
|
|
}
|
|
|
|
nSaveAmt = CmUtil.DoubleAdd(nSaveAmt, cPluItem.BILL_AMT);
|
|
}
|
|
if (nSaveAmt <= 0) return 0;
|
|
|
|
double nExceptPayAmt = 0;
|
|
ArrayList alPayItem = (ArrayList)StateObject.GetItemObject(Column.TR_PAYMENT.ITEM);
|
|
foreach (Column.TR_PAYMENT.DATA cPayItem in alPayItem)
|
|
{
|
|
if (cPayItem.CANCEL_DIV != PosConst.CANCEL_DIV.NORMAL) continue;
|
|
|
|
if (cPayItem.PAY_DTL_CD_05 == PosConst.PAY_DC_TYPE.PAY) // 할인결제구분 (1:결제, 2:할인)
|
|
{
|
|
// 결제수단별 추가 적립 여부(0:불가, 1:가능, 2:제외)
|
|
if (PosMstManager.GetMstPayDc(cPayItem.PAY_WAY_CD, cPayItem.PAY_DTL_CD_01, PosMst.MST_PAY_DC.DATA.HP_ADD_ACCUM_DIV) == "0") return 0;
|
|
if (PosMstManager.GetMstPayDc(cPayItem.PAY_WAY_CD, cPayItem.PAY_DTL_CD_01, PosMst.MST_PAY_DC.DATA.HP_ADD_ACCUM_DIV) == "2")
|
|
{
|
|
nExceptPayAmt = CmUtil.DoubleAdd(nExceptPayAmt, cPayItem.PAY_AMT);
|
|
}
|
|
else if (cPayItem.PAY_WAY_CD == ItemConst.TR_ITEM_ID.CREDITCARD_ITEM && cPayItem.PAY_DTL_CD_01 == ItemConst.TR_ITEM_ID.CREDITCARD.CREDIT_CARD)
|
|
{
|
|
//#16745 신용카드 포인트 결제 시 해피포인트 취소되는 현상 확인요청 start
|
|
//기존
|
|
#region 기존
|
|
/*
|
|
// 신용카드 포인트사용 결제 적립 없음
|
|
if (CmUtil.IntParse(cPayItem.OCCUR_ENTRY_14) >= 60) nExceptPayAmt = CmUtil.DoubleAdd(nExceptPayAmt, cPayItem.PAY_AMT);
|
|
*/
|
|
#endregion 기존
|
|
//변경
|
|
#region 변경
|
|
if (CmUtil.IntParse(cPayItem.OCCUR_ENTRY_14) >= 60 && cPayItem.PAY_DTL_CD_02 != "")
|
|
{
|
|
switch (cPayItem.PAY_DTL_CD_02)
|
|
{
|
|
#region
|
|
case ItemConst.CREDITCARD_DC_TY.CREDIT_SPNT: //삼성포인트
|
|
if (PosMstManager.GetMstPayDc(ItemConst.TR_ITEM_ID.POINT_ITEM, ItemConst.TR_ITEM_ID.POINT_USE.SAMSUNG_POINT, PosMst.MST_PAY_DC.DATA.HP_BASIC_ACCUM_YN) == "0")
|
|
{
|
|
return 0;
|
|
}
|
|
else if (PosMstManager.GetMstPayDc(ItemConst.TR_ITEM_ID.POINT_ITEM, ItemConst.TR_ITEM_ID.POINT_USE.SAMSUNG_POINT, PosMst.MST_PAY_DC.DATA.HP_BASIC_ACCUM_YN) == "2")
|
|
{
|
|
nExceptPayAmt = CmUtil.DoubleAdd(nExceptPayAmt, cPayItem.PAY_AMT);
|
|
}
|
|
break;
|
|
case ItemConst.CREDITCARD_DC_TY.SHINHAN_CARD_POINT: //신한포인트
|
|
if (PosMstManager.GetMstPayDc(ItemConst.TR_ITEM_ID.POINT_ITEM, ItemConst.TR_ITEM_ID.POINT_USE.SHINHAN_POINT, PosMst.MST_PAY_DC.DATA.HP_BASIC_ACCUM_YN) == "0")
|
|
{
|
|
return 0;
|
|
}
|
|
else if (PosMstManager.GetMstPayDc(ItemConst.TR_ITEM_ID.POINT_ITEM, ItemConst.TR_ITEM_ID.POINT_USE.SHINHAN_POINT, PosMst.MST_PAY_DC.DATA.HP_BASIC_ACCUM_YN) == "2")
|
|
{
|
|
nExceptPayAmt = CmUtil.DoubleAdd(nExceptPayAmt, cPayItem.PAY_AMT);
|
|
}
|
|
break;
|
|
case ItemConst.CREDITCARD_DC_TY.HYUNDAI_M_POINTS: //현대M
|
|
if (PosMstManager.GetMstPayDc(ItemConst.TR_ITEM_ID.POINT_ITEM, ItemConst.TR_ITEM_ID.POINT_USE.HYUNDAI_MPOINTS, PosMst.MST_PAY_DC.DATA.HP_BASIC_ACCUM_YN) == "0")
|
|
{
|
|
return 0;
|
|
}
|
|
else if (PosMstManager.GetMstPayDc(ItemConst.TR_ITEM_ID.POINT_ITEM, ItemConst.TR_ITEM_ID.POINT_USE.HYUNDAI_MPOINTS, PosMst.MST_PAY_DC.DATA.HP_BASIC_ACCUM_YN) == "2")
|
|
{
|
|
nExceptPayAmt = CmUtil.DoubleAdd(nExceptPayAmt, cPayItem.PAY_AMT);
|
|
}
|
|
break;
|
|
// grayber@20180102 우리모아포인트 추가 start - 결제수단별 HP 기본 적립 여부 체크 분기 추가
|
|
case ItemConst.CREDITCARD_DC_TY.WOORIMORE_POINTS:
|
|
if (PosMstManager.GetMstPayDc(ItemConst.TR_ITEM_ID.POINT_ITEM, ItemConst.TR_ITEM_ID.POINT_USE.WOORIMORE_POINTS, PosMst.MST_PAY_DC.DATA.HP_BASIC_ACCUM_YN) == "0")
|
|
{
|
|
return 0;
|
|
}
|
|
else if (PosMstManager.GetMstPayDc(ItemConst.TR_ITEM_ID.POINT_ITEM, ItemConst.TR_ITEM_ID.POINT_USE.WOORIMORE_POINTS, PosMst.MST_PAY_DC.DATA.HP_BASIC_ACCUM_YN) == "2")
|
|
{
|
|
nExceptPayAmt = CmUtil.DoubleAdd(nExceptPayAmt, cPayItem.PAY_AMT);
|
|
}
|
|
break;
|
|
// grayber@20180102 우리모아포인트 추가 end
|
|
default:
|
|
if (CmUtil.IntParse(cPayItem.OCCUR_ENTRY_14) >= 60) nExceptPayAmt = CmUtil.DoubleAdd(nExceptPayAmt, cPayItem.PAY_AMT);
|
|
break;
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// 신용카드 포인트사용 결제 적립 없음
|
|
if (CmUtil.IntParse(cPayItem.OCCUR_ENTRY_14) >= 60) nExceptPayAmt = CmUtil.DoubleAdd(nExceptPayAmt, cPayItem.PAY_AMT);
|
|
}
|
|
#endregion 변경
|
|
//#16745 신용카드 포인트 결제 시 해피포인트 취소되는 현상 확인요청 end
|
|
}
|
|
}
|
|
}
|
|
if (nExceptPayAmt > 0)
|
|
{
|
|
//#20171219 할인, 적립 제외 금액 계산시 상품리스트에서 계산된 금액에서 빼도록 수정 start
|
|
//기존
|
|
//double nPaySaveAmt = m_cTrnStatus.Head.NetSaleAmt - nExceptPayAmt;
|
|
//변경
|
|
double nPaySaveAmt = nSaveAmt - nExceptPayAmt;
|
|
//#20171219 할인, 적립 제외 금액 계산시 상품리스트에서 계산된 금액에서 빼도록 수정 end
|
|
|
|
//#20171222 대상금액이 0보다 작은 경우 전문 오류 발생으로 0으로 변경 start
|
|
if (nPaySaveAmt <= 0) return 0;
|
|
//#20171222 대상금액이 0보다 작은 경우 전문 오류 발생으로 0으로 변경 end
|
|
|
|
if (nSaveAmt > nPaySaveAmt) nSaveAmt = nPaySaveAmt;
|
|
}
|
|
}
|
|
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 nSaveAmt;
|
|
}
|
|
#endregion
|
|
|
|
#region 스템프 캠페인 대상 상품정보 설정
|
|
/// <summary>
|
|
/// 스템프 캠페인 대상 상품정보 설정
|
|
/// </summary>
|
|
/// <param name="cMstSaleCpi"></param>
|
|
/// <returns></returns>
|
|
public string CampaignHappyPointStamp(Column.MST_SALE_CPI.DATA cMstSaleCpi, ref ArrayList alStampPluInfo)
|
|
{
|
|
double nSaleAmt = 0, nAmt = 0;
|
|
long nPluCnt = 0, nSaleQty = 0, nQty = 0;
|
|
try
|
|
{
|
|
// 대상 상품 금액 획득
|
|
foreach (Column.TR_PLU.DATA cSaleItem in m_alTrPluItem)
|
|
{
|
|
if (cSaleItem.CANCEL_DIV == PosConst.CANCEL_DIV.CANCEL || cSaleItem.CANCEL_DIV_MAIN == PosConst.CANCEL_DIV.CANCEL) continue; // 지정취소
|
|
if (cSaleItem.BILLSPR_NO != m_cTrnStatus.Sale.BillSplitNo) continue; // 빌분리번호
|
|
if (cMstSaleCpi.DC_NOADM_PASS_YN != "1" && cSaleItem.DC_PRMT_YN == "1") continue; // 할인 불가 여부(0:가능, 1:불가)
|
|
|
|
nQty = 0; nAmt = 0;
|
|
if (cMstSaleCpi.ITEM_APPLY_METHD == ItemConst.CPI_ITEM_APPLY_METHD.RECTSUM || cMstSaleCpi.ITEM_APPLY_METHD == ItemConst.CPI_ITEM_APPLY_METHD.PAYMENT)
|
|
{
|
|
// 전체상품
|
|
GetCampaignSaleItemQtyAmt(cMstSaleCpi, cSaleItem, ref nQty, ref nAmt, "0");
|
|
}
|
|
else
|
|
{
|
|
// 상품합산
|
|
foreach (Column.TR_SALE_CPI_RSLT.DATA cTrSaleCpi in cSaleItem.alTrSaleCpi)
|
|
{
|
|
if (cMstSaleCpi.CPI_CD == cTrSaleCpi.CPI_CD)
|
|
{
|
|
GetCampaignSaleItemQtyAmt(cMstSaleCpi, cSaleItem, ref nQty, ref nAmt, "0");
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
nSaleQty += nQty;
|
|
nSaleAmt = CmUtil.DoubleAdd(nSaleAmt, nAmt);
|
|
}
|
|
if (nSaleQty == 0 && nSaleAmt == 0) return "";
|
|
|
|
// 캠페인 성립금액 구분 체크
|
|
if (CheckCampaignReqAmt(cMstSaleCpi, cMstSaleCpi.CPI_CD, nSaleQty, nSaleAmt) == false) return "";
|
|
|
|
// 캠페인 대상 상품 설정
|
|
foreach (Column.TR_PLU.DATA cSaleItem in m_alTrPluItem)
|
|
{
|
|
if (cSaleItem.CANCEL_DIV == PosConst.CANCEL_DIV.CANCEL || cSaleItem.CANCEL_DIV_MAIN == PosConst.CANCEL_DIV.CANCEL) continue; // 지정취소
|
|
if (cSaleItem.BILLSPR_NO != m_cTrnStatus.Sale.BillSplitNo) continue; // 빌분리번호
|
|
if (cMstSaleCpi.DC_NOADM_PASS_YN != "1" && cSaleItem.DC_PRMT_YN == "1") continue; // 할인 불가 여부(0:가능, 1:불가)
|
|
|
|
nQty = 0; nAmt = 0;
|
|
if (cMstSaleCpi.TRGT_AMT_TYPE == ItemConst.CPI_TRGT_AMT_TYPE.RECT_AMT) // 구매금액체크
|
|
{
|
|
// 전체상품
|
|
GetCampaignSaleItemQtyAmt(cMstSaleCpi, cSaleItem, ref nQty, ref nAmt, "0");
|
|
}
|
|
else
|
|
{
|
|
// 대상상품
|
|
foreach (Column.TR_SALE_CPI_RSLT.DATA cTrSaleCpi in cSaleItem.alTrSaleCpi)
|
|
{
|
|
if (cMstSaleCpi.CPI_CD == cTrSaleCpi.CPI_CD)
|
|
{
|
|
GetCampaignSaleItemQtyAmt(cMstSaleCpi, cSaleItem, ref nQty, ref nAmt, "0");
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
if (nQty == 0 && nAmt == 0) continue;
|
|
|
|
nPluCnt++;
|
|
if (alStampPluInfo.Count < 30) // 스템프 상품은 최대 30개까지 가능
|
|
{
|
|
bool bExist = false;
|
|
for (int i = 0; i < alStampPluInfo.Count; i++)
|
|
{
|
|
string sInfo = (string)alStampPluInfo[i];
|
|
if (sInfo.StartsWith(cSaleItem.ITEM_PLU_CD.Trim()) == true)
|
|
{
|
|
long nNewQty = (CmUtil.LongParse(sInfo.Substring(6, 3)) + nQty > 999) ? 999 : CmUtil.LongParse(sInfo.Substring(6, 3)) + nQty;
|
|
// 상품정보 = 제품코드(6)+구매수량(3)+FS
|
|
alStampPluInfo[i] = CmUtil.RPadH(cSaleItem.ITEM_PLU_CD, 6) + string.Format("{0:D3}", nNewQty) + PosConst.VAN_HEXA.FS;
|
|
bExist = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (bExist == false)
|
|
{
|
|
long nNewQty = (cSaleItem.SALE_QTY > 999) ? 999 : nQty;
|
|
// 상품정보 = 제품코드(6)+구매수량(3)+FS
|
|
string sNewInfo = CmUtil.RPadH(cSaleItem.ITEM_PLU_CD, 6) + string.Format("{0:D3}", nNewQty) + PosConst.VAN_HEXA.FS;
|
|
|
|
alStampPluInfo.Add(sNewInfo);
|
|
}
|
|
}
|
|
}
|
|
if (nPluCnt == 0) return "";
|
|
|
|
// 스템프 캠페인 실적 생성
|
|
AddTrCampaignData(cMstSaleCpi.CPI_CD, 0, "", "");
|
|
}
|
|
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 "";
|
|
}
|
|
#endregion
|
|
|
|
#region 영수증 출력 행사 계산 처리
|
|
/// <summary>
|
|
/// 상품합산, 전체상품 영수 행사
|
|
/// </summary>
|
|
/// <param name="cMstSaleCpi"></param>
|
|
/// <returns></returns>
|
|
public long CampaignPluRectPrint(Column.MST_SALE_CPI.DATA cMstSaleCpi)
|
|
{
|
|
double nSaleAmt = 0, nAmt = 0;
|
|
long nSaleQty = 0, nDisQty = 0, nQty = 0;
|
|
|
|
try
|
|
{
|
|
// 대상 상품 금액 획득
|
|
foreach (Column.TR_PLU.DATA cSaleItem in m_alTrPluItem)
|
|
{
|
|
if (cSaleItem.CANCEL_DIV == PosConst.CANCEL_DIV.CANCEL || cSaleItem.CANCEL_DIV_MAIN == PosConst.CANCEL_DIV.CANCEL) continue; // 지정취소
|
|
if (cSaleItem.BILLSPR_NO != m_cTrnStatus.Sale.BillSplitNo) continue; // 빌분리번호
|
|
if (cMstSaleCpi.DC_NOADM_PASS_YN != "1" && cSaleItem.DC_PRMT_YN == "1") continue; // 할인 불가 여부(0:가능, 1:불가)
|
|
|
|
nQty = 0; nAmt = 0;
|
|
if (cMstSaleCpi.ITEM_APPLY_METHD == ItemConst.CPI_ITEM_APPLY_METHD.RECTSUM || cMstSaleCpi.ITEM_APPLY_METHD == ItemConst.CPI_ITEM_APPLY_METHD.PAYMENT)
|
|
{
|
|
// 전체상품
|
|
GetCampaignSaleItemQtyAmt(cMstSaleCpi, cSaleItem, ref nQty, ref nAmt, "0");
|
|
}
|
|
else
|
|
{
|
|
// 상품합산
|
|
foreach (Column.TR_SALE_CPI_RSLT.DATA cTrSaleCpi in cSaleItem.alTrSaleCpi)
|
|
{
|
|
if (cMstSaleCpi.CPI_CD == cTrSaleCpi.CPI_CD)
|
|
{
|
|
GetCampaignSaleItemQtyAmt(cMstSaleCpi, cSaleItem, ref nQty, ref nAmt, "0");
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
nSaleQty += nQty;
|
|
nSaleAmt = CmUtil.DoubleAdd(nSaleAmt, nAmt);
|
|
}
|
|
if (nSaleQty == 0 && nSaleAmt == 0) return 0;
|
|
|
|
// 캠페인 성립금액 구분 체크
|
|
if (CheckCampaignReqAmt(cMstSaleCpi, "", nSaleQty, nSaleAmt) == false) return 0;
|
|
|
|
nDisQty = nSaleQty;
|
|
if (cMstSaleCpi.alDATA_COMPNT.Count > 0)
|
|
{
|
|
nDisQty = 0;
|
|
// 구성 자격 구분 체크
|
|
Column.MST_SALE_CPI.DATA_COMPNT cMstCpiCompnt = (Column.MST_SALE_CPI.DATA_COMPNT)cMstSaleCpi.alDATA_COMPNT[0];
|
|
|
|
// 캠페인 구성 자격 구분에 따른 대상 상품수량 획득
|
|
if (cMstCpiCompnt.CPI_COND_TYPE == ItemConst.CPI_COND_TYPE.MATCH_QTY) // 수량
|
|
{
|
|
if (cMstCpiCompnt.QTY_AMT == 0) cMstCpiCompnt.QTY_AMT = 1;
|
|
|
|
nDisQty = nSaleQty / (long)cMstCpiCompnt.QTY_AMT;
|
|
}
|
|
else if (cMstCpiCompnt.CPI_COND_TYPE == ItemConst.CPI_COND_TYPE.MIN_QTY) // 최소수량
|
|
{
|
|
if (nSaleQty >= (long)cMstCpiCompnt.QTY_AMT) nDisQty = nSaleQty;
|
|
}
|
|
else // 금액
|
|
{
|
|
if (nSaleAmt >= cMstCpiCompnt.QTY_AMT) nDisQty = nSaleQty;
|
|
}
|
|
|
|
}
|
|
if (nDisQty == 0) return 0;
|
|
|
|
string sLttrNmplatNo = "", sLttrGrade = ""; // 복권번호, 등수
|
|
// 캠페인고객혜택=> 영수행사(복권)
|
|
if (cMstSaleCpi.CPI_CUST_BNFT_TYPE == ItemConst.CPI_CUST_BNFT.LOTTERY || cMstSaleCpi.CPI_CUST_BNFT_TYPE == ItemConst.CPI_CUST_BNFT.LOTT_REC)
|
|
{
|
|
long nIssueCnt = 1;
|
|
if (cMstSaleCpi.LTTR_MULTI_PRT_YN == "1") nIssueCnt = nDisQty > 10 ? 10 : nDisQty;
|
|
// 복권 번호 획득(서버 IRT)
|
|
if (ExecuteLttrPosIrt(cMstSaleCpi.CPI_CD, nSaleAmt, nIssueCnt, ref sLttrNmplatNo, ref sLttrGrade) != true) return 0;
|
|
|
|
// 복권당첨메시지 삭제(2017.04.03) BR(황D) PB(안K)
|
|
//WinManager.ConfirmMessage(string.Format(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0558), sLttrGrade) + PosConst.CRLF
|
|
// + MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0399) + " : " + cMstSaleCpi.CPI_NM );
|
|
}
|
|
if (cMstSaleCpi.CPI_CUST_BNFT_TYPE == ItemConst.CPI_CUST_BNFT.ENTRY || cMstSaleCpi.CPI_CUST_BNFT_TYPE == ItemConst.CPI_CUST_BNFT.ENTR_REC)
|
|
{
|
|
// 응모권 번호 생성
|
|
if (ExecuteMakeEntryNo(cMstSaleCpi.CPI_CD, ref sLttrNmplatNo) != true) return 0;
|
|
}
|
|
|
|
// 캠페인 실적 생성
|
|
AddTrCampaignData(cMstSaleCpi.CPI_CD, 0, sLttrNmplatNo, sLttrGrade);
|
|
|
|
return nDisQty;
|
|
}
|
|
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 0;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 복권 번호 조회
|
|
/// </summary>
|
|
/// <param name="sCPI_CD"></param>
|
|
/// <returns></returns>
|
|
public bool ExecuteLttrPosIrt(string sCPI_CD, double nSaleAmt, long nIssueCnt, ref string sLttrNmplatNo, ref string sLttrGrade)
|
|
{
|
|
try
|
|
{
|
|
// 연습모드이면
|
|
if (m_cPosStatus.Base.TrainingFlag == "1" || m_cPosStatus.Mst.TestStorYn == "1") return false;
|
|
|
|
Hashtable htSendData = new Hashtable();
|
|
Hashtable htRecvData = new Hashtable();
|
|
|
|
htSendData.Add(Column.IQ_LOTTERY_NUMBERINQ_REQ.DATA.INQ_TYPE, ItemConst.IRT_INQ_TYPE.LOTTERY_NUMBERINQ);
|
|
htSendData.Add(Column.IQ_LOTTERY_NUMBERINQ_REQ.DATA.STOR_CD, m_cPosStatus.Base.StoreNo);
|
|
htSendData.Add(Column.IQ_LOTTERY_NUMBERINQ_REQ.DATA.SALE_DT, m_cPosStatus.Base.SaleDate);
|
|
htSendData.Add(Column.IQ_LOTTERY_NUMBERINQ_REQ.DATA.CAMPAIGN_CODE, sCPI_CD);
|
|
htSendData.Add(Column.IQ_LOTTERY_NUMBERINQ_REQ.DATA.INQ_FLAG, "00");
|
|
htSendData.Add(Column.IQ_LOTTERY_NUMBERINQ_REQ.DATA.COND_AMT, nSaleAmt.ToString());
|
|
htSendData.Add(Column.IQ_LOTTERY_NUMBERINQ_REQ.DATA.ISSUE_CNT, nIssueCnt.ToString());
|
|
|
|
string sRet = m_cDataCommon.ExecutePosIrt(ItemConst.COMM_MSG_TYPE.POSIRT, m_cPosStatus.Base.CommSvrIp, (int)m_cPosStatus.Base.PayInqPort, 10000, htSendData, ref htRecvData);
|
|
if ( sRet != UserCom.RST_OK)
|
|
{
|
|
UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name
|
|
, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()"
|
|
, MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0127));
|
|
//WinManager.ErrorMessage(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0127));
|
|
return false;
|
|
}
|
|
|
|
if (htRecvData[Column.IQ_LOTTERY_NUMBERINQ_RSP.DATA.RES_CD].ToString() != "0")
|
|
{
|
|
UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name
|
|
, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()"
|
|
, MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0127) + ", " + htRecvData[Column.IQ_LOTTERY_NUMBERINQ_RSP.DATA.RES_MSG]);
|
|
return false;
|
|
}
|
|
|
|
sLttrNmplatNo = htRecvData[Column.IQ_LOTTERY_NUMBERINQ_RSP.DATA.LOTTERY_NO].ToString();
|
|
sLttrGrade = htRecvData[Column.IQ_LOTTERY_NUMBERINQ_RSP.DATA.LOTTERY_GRADE].ToString();
|
|
|
|
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="sCPI_CD"></param>
|
|
/// <returns></returns>
|
|
public bool ExecuteMakeEntryNo(string sCPI_CD, ref string sLttrNmplatNo)
|
|
{
|
|
try
|
|
{
|
|
// 일자정보 = 년도 끝자리 (1) + 일자를365로환산(3) + 시간HHMMDD를 초로환산(5) 9자리로 생성
|
|
string sEntryInfo = DateTime.Now.ToString("yyyy").Substring(3,1) + string.Format("{0:D3}{1:D5}", DateTime.Now.DayOfYear, (int)DateTime.Now.TimeOfDay.TotalSeconds);
|
|
|
|
// 체크 디지트 생성
|
|
int nCheckSum = 0;
|
|
for (int i = 0; i < sEntryInfo.Length; i++)
|
|
{
|
|
if (i % 2 == 0)
|
|
nCheckSum += CmUtil.IntParse(sEntryInfo.Substring(i, 1)) * 3;
|
|
else
|
|
nCheckSum += CmUtil.IntParse(sEntryInfo.Substring(i, 1));
|
|
}
|
|
nCheckSum = 10 - (nCheckSum % 10);
|
|
if (nCheckSum == 10) nCheckSum = 0;
|
|
|
|
// 점포정보 = 점포코드(앞3)3 + 체크디지트1 + 점포코드(뒤2)2 + 포스번호1
|
|
string sStoreInfo = m_cPosStatus.Base.StoreNo.Substring(0, 3) + nCheckSum + m_cPosStatus.Base.StoreNo.Substring(3, 2)
|
|
+ m_cPosStatus.Base.PosNo.Substring(m_cPosStatus.Base.PosNo.Length - 1, 1);
|
|
|
|
sLttrNmplatNo = sStoreInfo + sEntryInfo;
|
|
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="sCPI_CD"></param>
|
|
/// <returns></returns>
|
|
public void GetCampaignPrintData(string sCPI_CUST_BNFT_TYPE, string sCPI_CD, string sLTTR_NMPLAT_NO, string sGradeCD, ref ArrayList alPrintBuf)
|
|
{
|
|
GetCampaignPrintData(sCPI_CUST_BNFT_TYPE, sCPI_CD, sLTTR_NMPLAT_NO, sGradeCD, ref alPrintBuf, true);
|
|
}
|
|
public void GetCampaignPrintData(string sCPI_CUST_BNFT_TYPE, string sCPI_CD, string sLTTR_NMPLAT_NO, string sGradeCD, ref ArrayList alPrintBuf, bool bLastLine)
|
|
{
|
|
try
|
|
{
|
|
string sLottoRecType = "0"; //명판,복권 구분(0:명판, 1:복권)
|
|
if (sCPI_CUST_BNFT_TYPE != "")
|
|
{
|
|
if (sCPI_CUST_BNFT_TYPE == ItemConst.CPI_CUST_BNFT.LOTTERY || sCPI_CUST_BNFT_TYPE == ItemConst.CPI_CUST_BNFT.LOTT_REC)
|
|
{
|
|
// 복권번호
|
|
if (sLTTR_NMPLAT_NO.Trim() != "")
|
|
{
|
|
//alPrintBuf.Add(PosConst.PRT_HDR.PRT_NOR + "------------------------------------------");
|
|
alPrintBuf.Add(PosConst.PRT_HDR.PRT_NOR + MessageManager.GetPrintMessage(POS_MESSAGE.PRINT.MSG_0072) + " : " + m_cPosStatus.Global.DateToCulture(DateTime.Now.ToString("yyyyMMdd")));
|
|
alPrintBuf.Add(PosConst.PRT_HDR.PRT_BAR + sLTTR_NMPLAT_NO.Trim());
|
|
alPrintBuf.Add(PosConst.PRT_HDR.PRT_NOR + "------------------------------------------");
|
|
alPrintBuf.Add(PosConst.PRT_HDR.PRT_NOR + MessageManager.GetPrintMessage(POS_MESSAGE.PRINT.MSG_0056) + " : [ " + sLTTR_NMPLAT_NO.Trim() + " ]");
|
|
alPrintBuf.Add(PosConst.PRT_HDR.PRT_NOR);
|
|
}
|
|
}
|
|
else if (sCPI_CUST_BNFT_TYPE == ItemConst.CPI_CUST_BNFT.ENTRY || sCPI_CUST_BNFT_TYPE == ItemConst.CPI_CUST_BNFT.ENTR_REC)
|
|
{
|
|
// 응모번호
|
|
if (sLTTR_NMPLAT_NO.Trim() != "")
|
|
{
|
|
alPrintBuf.Add(PosConst.PRT_HDR.PRT_NOR + "------------------------------------------");
|
|
alPrintBuf.Add(PosConst.PRT_HDR.PRT_BLD + MessageManager.GetPrintMessage(POS_MESSAGE.PRINT.MSG_0073) + " : [ "
|
|
+ sLTTR_NMPLAT_NO.Substring(0, 4) + "-" + sLTTR_NMPLAT_NO.Substring(4, 4) + "-" + sLTTR_NMPLAT_NO.Substring(8, 4) + "-" + sLTTR_NMPLAT_NO.Substring(12, 4) + " ]");
|
|
alPrintBuf.Add(PosConst.PRT_HDR.PRT_NOR);
|
|
}
|
|
}
|
|
sLottoRecType = "1"; //복권 출력데이터
|
|
|
|
//#20170807 명판 캠페인 커팅 start
|
|
|
|
//grayber@20171214 캠페인 리펀드 쿠폰 start
|
|
// 캠페인 리펀드 사용하지 않더라도 명판 출력 할 수 있도록 분기 처리
|
|
if(PosMstManager.GetPosOption(POS_OPTION.OPT431).Equals("1") == true )
|
|
{
|
|
if (sCPI_CUST_BNFT_TYPE == ItemConst.CPI_CUST_BNFT.RECEIPT || sCPI_CUST_BNFT_TYPE == ItemConst.CPI_CUST_BNFT.REFUND)
|
|
{
|
|
sLottoRecType = "0"; //명판 출력데이터
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (sCPI_CUST_BNFT_TYPE == ItemConst.CPI_CUST_BNFT.RECEIPT)
|
|
{
|
|
{
|
|
sLottoRecType = "0"; //명판 출력데이터
|
|
}
|
|
}
|
|
}
|
|
//grayber@20171214 캠페인 리펀드 쿠폰 end
|
|
|
|
}
|
|
|
|
bool bExistPrtData = false;
|
|
foreach (string[] saCpiPrtMsg in m_alMstCpiPrtMsg)
|
|
{
|
|
//0:유형(0:명판,1:복권), 1:캠페인코드, 2:출력위치(등수), 3:확대문자, 4:BOLD여부, 5:정렬유형, 6:문자열
|
|
if (saCpiPrtMsg[0] != sLottoRecType) continue;
|
|
if (saCpiPrtMsg[1] != sCPI_CD ) continue;
|
|
if (sGradeCD != "" && saCpiPrtMsg[2] != sGradeCD) continue;
|
|
|
|
// 정렬 방식
|
|
string sPrtData = saCpiPrtMsg[6];
|
|
if (saCpiPrtMsg[5] == PosConst.PRT_ALIGN_TYPE.RIGHT) // 오른쪽 정렬
|
|
{
|
|
sPrtData = CmUtil.LPadH(saCpiPrtMsg[6], 42);
|
|
}
|
|
else if (saCpiPrtMsg[5] == PosConst.PRT_ALIGN_TYPE.CENTER) // 중앙정렬
|
|
{
|
|
if (saCpiPrtMsg[3] == PosConst.PRT_EXPAND_TYPE.HOR || saCpiPrtMsg[3] == PosConst.PRT_EXPAND_TYPE.BOTH)
|
|
{
|
|
if (CmUtil.LenH(saCpiPrtMsg[6]) <= 21) sPrtData = CmUtil.LPadH("", 10 - (CmUtil.LenH(saCpiPrtMsg[6]) / 2)) + saCpiPrtMsg[6];
|
|
}
|
|
else
|
|
{
|
|
if (CmUtil.LenH(saCpiPrtMsg[6]) <= 42) sPrtData = CmUtil.LPadH("", 21 - (CmUtil.LenH(saCpiPrtMsg[6]) / 2)) + saCpiPrtMsg[6];
|
|
}
|
|
}
|
|
alPrintBuf.Add(CmUtil.GetPrtMstToPrtHeadConst(saCpiPrtMsg[3],saCpiPrtMsg[4]) + sPrtData);
|
|
|
|
bExistPrtData = true;
|
|
}
|
|
if (bExistPrtData == true && bLastLine == true)
|
|
{
|
|
alPrintBuf.Add(PosConst.PRT_HDR.PRT_NOR + "------------------------------------------");
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
|
|
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 스템프 캠페인 쿠폰 출력데이터 획득
|
|
/// </summary>
|
|
/// <param name="sHP_CAMPAIGN_INFO"></param>
|
|
/// <returns></returns>
|
|
public void GetStampCouponPrintData( string sCPI_CD, string sCOUPON_NO, string sHP_CAMPAIGN_INFO, ref ArrayList alPrintBuf)
|
|
{
|
|
string sPrtData = "";
|
|
try
|
|
{
|
|
//alPrintBuf.Add(PosConst.PRT_HDR.PRT_NOR + MessageManager.GetPrintMessage(POS_MESSAGE.PRINT.MSG_0072) + " : " + m_cPosStatus.Global.DateToCulture(DateTime.Now.ToString("yyyyMMdd")));
|
|
//alPrintBuf.Add(PosConst.PRT_HDR.PRT_NOR + "------------------------------------------");
|
|
|
|
GetCampaignPrintData("", sCPI_CD, "", "1", ref alPrintBuf, true);
|
|
|
|
string[] saPrtData = sHP_CAMPAIGN_INFO.Split(new string[] { "\n\r", "\r\n" }, StringSplitOptions.None);
|
|
foreach (string sData in saPrtData)
|
|
{
|
|
alPrintBuf.Add(PosConst.PRT_HDR.PRT_NOR + sData);
|
|
}
|
|
|
|
alPrintBuf.Add(PosConst.PRT_HDR.PRT_BAR + sCOUPON_NO);
|
|
alPrintBuf.Add(PosConst.PRT_HDR.PRT_NOR + " [No " + sCOUPON_NO.Trim() + " ]");
|
|
alPrintBuf.Add(PosConst.PRT_HDR.PRT_NOR + "------------------------------------------");
|
|
|
|
GetCampaignPrintData("", sCPI_CD, "", "3", ref alPrintBuf, false);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
|
|
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 스템프 캠페인 수량표시 출력데이터 획득
|
|
/// </summary>
|
|
/// <param name="sStampCntInfo"></param>
|
|
/// <returns></returns>
|
|
public void GetStampCntPrintData(string sCPI_CD, string sHP_CAMPAIGN_INFO, string sStampCntInfo, ref ArrayList alPrintBuf)
|
|
{
|
|
string sPrtData = "";
|
|
try
|
|
{
|
|
GetCampaignPrintData("", sCPI_CD, "", "2", ref alPrintBuf, false);
|
|
|
|
string[] saPrtData = sHP_CAMPAIGN_INFO.Split(new string[] { "\n\r", "\r\n" }, StringSplitOptions.None);
|
|
foreach (string sData in saPrtData)
|
|
{
|
|
alPrintBuf.Add(PosConst.PRT_HDR.PRT_NOR + sData);
|
|
}
|
|
|
|
// 스템프 수량 파싱(구매,잔여,누적)
|
|
if (sStampCntInfo.Trim() != "")
|
|
{
|
|
Column.MST_SALE_CPI.DATA cMstSaleCpi = (Column.MST_SALE_CPI.DATA)m_htMstSaleCpi[sCPI_CD];
|
|
|
|
string[] saStampCnt = sStampCntInfo.Split(',');
|
|
if (saStampCnt.Length >= 3)
|
|
{
|
|
if (cMstSaleCpi.STAMP_QTY > 0 && cMstSaleCpi.STAMP_QTY <= 15)
|
|
{
|
|
//alPrintBuf.Add(PosConst.PRT_HDR.PRT_NOR + "------------------------------------------");
|
|
string[] saNumber = new string[] { "①", "②", "③", "④", "⑤", "⑥", "⑦", "⑧", "⑨", "⑩", "⑪", "⑫", "⑬", "⑭", "⑮" };
|
|
|
|
sPrtData = "";
|
|
for (int i = 1; i <= cMstSaleCpi.STAMP_QTY; i++)
|
|
{
|
|
if (i <= cMstSaleCpi.STAMP_QTY - CmUtil.IntParse(saStampCnt[1])) // 구매수량
|
|
sPrtData += " [●] ";
|
|
else
|
|
sPrtData += " [" + saNumber[i - 1] + "] ";
|
|
|
|
if (i % 5 == 0)
|
|
{
|
|
alPrintBuf.Add(PosConst.PRT_HDR.PRT_NOR + sPrtData);
|
|
sPrtData = "";
|
|
}
|
|
}
|
|
if (sPrtData != "") alPrintBuf.Add(PosConst.PRT_HDR.PRT_NOR + sPrtData);
|
|
alPrintBuf.Add(PosConst.PRT_HDR.PRT_NOR + "------------------------------------------");
|
|
}
|
|
}
|
|
}
|
|
GetCampaignPrintData("", sCPI_CD, "", "3", ref alPrintBuf, 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);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// 수량 제한 캠페인 수량 초과 체크
|
|
/// </summary>
|
|
/// <param name="cMstSaleCpi"></param>
|
|
/// <returns></returns>
|
|
public long CheckCampaignQtyLimit(Column.MST_SALE_CPI.DATA cMstSaleCpi, long nTotDisQty, long nDisQty)
|
|
{
|
|
string[] saCpiQtyLmtInfo = null;
|
|
try
|
|
{
|
|
if (cMstSaleCpi.LMT_QTY <= 0) return nDisQty;
|
|
// 연습모드이면
|
|
if (m_cPosStatus.Base.TrainingFlag == "1" || m_cPosStatus.Mst.TestStorYn == "1") return nDisQty;
|
|
|
|
foreach (string[] saCpiQtyLmt in m_alSaleCpiQtyLmt)
|
|
{
|
|
if (saCpiQtyLmt[0] == cMstSaleCpi.CPI_CD)
|
|
{
|
|
saCpiQtyLmtInfo = saCpiQtyLmt;
|
|
}
|
|
}
|
|
|
|
if (saCpiQtyLmtInfo == null)
|
|
{
|
|
Hashtable htSendData = new Hashtable();
|
|
Hashtable htRecvData = new Hashtable();
|
|
|
|
htSendData.Add(Column.IQ_POSLINEUPORDER_REQ.DATA.INQ_TYPE, ItemConst.IRT_INQ_TYPE.POSLINEUPORDER_REQ);
|
|
htSendData.Add(Column.IQ_POSLINEUPORDER_REQ.DATA.STOR_CD, m_cPosStatus.Base.StoreNo);
|
|
htSendData.Add(Column.IQ_POSLINEUPORDER_REQ.DATA.CPI_CD, cMstSaleCpi.CPI_CD);
|
|
htSendData.Add(Column.IQ_POSLINEUPORDER_REQ.DATA.LIMIT_DIV, cMstSaleCpi.QTY_LMT_STD);
|
|
if (cMstSaleCpi.QTY_LMT_STD == "1") // 수량 제한 기준(1:일별, 2:행사기간별)
|
|
{
|
|
htSendData.Add(Column.IQ_POSLINEUPORDER_REQ.DATA.LIMIT_ST_DATE, m_cTrnStatus.Head.SysYmd);
|
|
htSendData.Add(Column.IQ_POSLINEUPORDER_REQ.DATA.LIMIT_ED_DATE, m_cTrnStatus.Head.SysYmd);
|
|
}
|
|
else
|
|
{
|
|
htSendData.Add(Column.IQ_POSLINEUPORDER_REQ.DATA.LIMIT_ST_DATE, cMstSaleCpi.STARTDAY);
|
|
htSendData.Add(Column.IQ_POSLINEUPORDER_REQ.DATA.LIMIT_ED_DATE, m_cTrnStatus.Head.SysYmd);
|
|
}
|
|
htSendData.Add(Column.IQ_POSLINEUPORDER_REQ.DATA.CPI_CNT, "0");
|
|
htSendData.Add(Column.IQ_POSLINEUPORDER_REQ.DATA.RES_CD, "00");
|
|
|
|
string sCpiQty = "0";
|
|
string sRet = m_cDataCommon.ExecutePosIrt(ItemConst.COMM_MSG_TYPE.POSIRT, m_cPosStatus.Base.CommSvrIp, (int)m_cPosStatus.Base.PayInqPort, 10000, htSendData, ref htRecvData);
|
|
if (sRet == UserCom.RST_OK)
|
|
{
|
|
if (htRecvData[Column.IQ_POSLINEUPORDER_REQ.DATA.RES_CD].ToString() == "00")
|
|
{
|
|
sCpiQty = htRecvData[Column.IQ_POSLINEUPORDER_REQ.DATA.CPI_CNT].ToString();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
string sQuery = "";
|
|
sQuery += " SELECT ISNULL(SUM(CASE WHEN TRADE_DIV = '0' THEN B.DC_QTY ELSE B.DC_QTY * -1 END), 0) SUM_QTY FROM POSLOG..TR_SALE_HEADER A ";
|
|
sQuery += " JOIN POSLOG..TR_SALE_CPI_RSLT B ON A.CMP_CD=B.CMP_CD AND A.SALE_DT = B.SALE_DT AND A.STOR_CD=B.STOR_CD AND A.POS_NO = B.POS_NO AND A.TRADE_NO = B.TRADE_NO ";
|
|
sQuery += " WHERE A.CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' ";
|
|
sQuery += " AND A.STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' ";
|
|
if (cMstSaleCpi.QTY_LMT_STD == "1") // 수량 제한 기준(1:일별, 2:행사기간별)
|
|
sQuery += " AND A.SALE_DT BETWEEN '" + m_cTrnStatus.Head.SysYmd + "' AND '" + m_cTrnStatus.Head.SysYmd + "' ";
|
|
else
|
|
sQuery += " AND A.SALE_DT BETWEEN '" + cMstSaleCpi.STARTDAY + "' AND '" + m_cTrnStatus.Head.SysYmd + "' ";
|
|
sQuery += " AND B.CPI_CD = '" + cMstSaleCpi.CPI_CD + "' ";
|
|
|
|
DataTable dtCpiRslt = m_cMstService.Select(new string[] { sQuery });
|
|
if (dtCpiRslt != null && dtCpiRslt.Rows.Count > 0)
|
|
{
|
|
DataRow dr = dtCpiRslt.Rows[0];
|
|
|
|
sCpiQty = CmUtil.GetDataRowStr(dr, "SUM_QTY");
|
|
}
|
|
}
|
|
|
|
// 캠페인코드(0), 이전성립수량(1), 캠페인명(2), 제한수량(3), 현성립수량(4)
|
|
saCpiQtyLmtInfo = new string[] { cMstSaleCpi.CPI_CD, sCpiQty, cMstSaleCpi.CPI_NM, cMstSaleCpi.LMT_QTY.ToString(), nDisQty.ToString() };
|
|
|
|
m_alSaleCpiQtyLmt.Add(saCpiQtyLmtInfo);
|
|
}
|
|
|
|
if (CmUtil.LongParse(saCpiQtyLmtInfo[1]) >= cMstSaleCpi.LMT_QTY)
|
|
{
|
|
//UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.INFO_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
|
|
// System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()"
|
|
// , string.Format("CAMPAIGN QTY LIMIT OVER => CODE:{0}={1}, LimitQty:{2}, AgoDisQty:{3}", cMstSaleCpi.CPI_CD, cMstSaleCpi.CPI_NM, cMstSaleCpi.LMT_QTY, saCpiQtyLmtInfo[1]));
|
|
|
|
// 제한수량 초과(적용 불가)
|
|
nDisQty = 0;
|
|
}
|
|
|
|
if (CmUtil.LongParse(saCpiQtyLmtInfo[1]) + nTotDisQty + nDisQty > cMstSaleCpi.LMT_QTY)
|
|
{
|
|
UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.INFO_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
|
|
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()"
|
|
, string.Format("CAMPAIGN QTY LIMIT OVER => CODE:{0}={1}, LimitQty:{2}, AgoDisQty:{3}", cMstSaleCpi.CPI_CD, cMstSaleCpi.CPI_NM, cMstSaleCpi.LMT_QTY, saCpiQtyLmtInfo[1]));
|
|
|
|
// 제한수량 초과(일부 적용)
|
|
nDisQty = cMstSaleCpi.LMT_QTY - CmUtil.LongParse(saCpiQtyLmtInfo[1]) - nTotDisQty;
|
|
}
|
|
saCpiQtyLmtInfo[4] = (nTotDisQty + nDisQty).ToString(); // 현성립수량
|
|
|
|
return nDisQty;
|
|
}
|
|
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 nDisQty;
|
|
}
|
|
|
|
/// <summary>
|
|
/// HP 횟수 제한 캠페인 수량 초과 체크
|
|
/// </summary>
|
|
/// <param name="cMstSaleCpi"></param>
|
|
/// <returns>false:행사불가</returns>
|
|
public bool CheckCampaignCntLimit(Column.MST_SALE_CPI.DATA cMstSaleCpi, string sCustID)
|
|
{
|
|
string[] saCpiQtyLmtInfo = null;
|
|
try
|
|
{
|
|
// 연습모드이면
|
|
if (m_cPosStatus.Base.TrainingFlag == "1" || m_cPosStatus.Mst.TestStorYn == "1") return true;
|
|
|
|
if (cMstSaleCpi.HP_CUST_MAX_JOIN_CNT <= 0 || sCustID.Trim() == "") return true;
|
|
|
|
foreach (string[] saCpiQtyLmt in m_alSaleCpiQtyLmt)
|
|
{
|
|
if (saCpiQtyLmt[0] == cMstSaleCpi.CPI_CD)
|
|
{
|
|
saCpiQtyLmtInfo = saCpiQtyLmt;
|
|
}
|
|
}
|
|
|
|
if (saCpiQtyLmtInfo == null)
|
|
{
|
|
Hashtable htSendData = new Hashtable();
|
|
Hashtable htRecvData = new Hashtable();
|
|
|
|
htSendData.Add(Column.IQ_CAMPAIGN_HPCNT_REQ.DATA.INQ_TYPE, ItemConst.IRT_INQ_TYPE.CAMPAIGN_HPCNT_REQ);
|
|
htSendData.Add(Column.IQ_CAMPAIGN_HPCNT_REQ.DATA.STOR_CD, m_cPosStatus.Base.StoreNo);
|
|
htSendData.Add(Column.IQ_CAMPAIGN_HPCNT_REQ.DATA.CPI_CD, cMstSaleCpi.CPI_CD);
|
|
htSendData.Add(Column.IQ_CAMPAIGN_HPCNT_REQ.DATA.LIMIT_DIV, cMstSaleCpi.HP_CUST_JOIN_LMT_STD);
|
|
if (cMstSaleCpi.HP_CUST_JOIN_LMT_STD == "1") // 수량 제한 기준(1:일별, 2:행사기간별)
|
|
{
|
|
htSendData.Add(Column.IQ_CAMPAIGN_HPCNT_REQ.DATA.LIMIT_ST_DATE, m_cTrnStatus.Head.SysYmd);
|
|
htSendData.Add(Column.IQ_CAMPAIGN_HPCNT_REQ.DATA.LIMIT_ED_DATE, m_cTrnStatus.Head.SysYmd);
|
|
}
|
|
else
|
|
{
|
|
htSendData.Add(Column.IQ_CAMPAIGN_HPCNT_REQ.DATA.LIMIT_ST_DATE, cMstSaleCpi.STARTDAY);
|
|
htSendData.Add(Column.IQ_CAMPAIGN_HPCNT_REQ.DATA.LIMIT_ED_DATE, m_cTrnStatus.Head.SysYmd);
|
|
}
|
|
htSendData.Add(Column.IQ_CAMPAIGN_HPCNT_REQ.DATA.CPI_CNT, "0");
|
|
htSendData.Add(Column.IQ_CAMPAIGN_HPCNT_REQ.DATA.CUST_ID, sCustID);
|
|
htSendData.Add(Column.IQ_CAMPAIGN_HPCNT_REQ.DATA.RES_CD, "00");
|
|
|
|
string sCpiCnt = "0";
|
|
string sRet = m_cDataCommon.ExecutePosIrt(ItemConst.COMM_MSG_TYPE.POSIRT, m_cPosStatus.Base.CommSvrIp, (int)m_cPosStatus.Base.PayInqPort, 10000, htSendData, ref htRecvData);
|
|
if (sRet == UserCom.RST_OK)
|
|
{
|
|
if (htRecvData[Column.IQ_CAMPAIGN_HPCNT_REQ.DATA.RES_CD].ToString() == "00")
|
|
{
|
|
sCpiCnt = htRecvData[Column.IQ_CAMPAIGN_HPCNT_REQ.DATA.CPI_CNT].ToString();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
string sQuery = "";
|
|
sQuery += " SELECT ISNULL(SUM(CASE WHEN TRADE_DIV = '0' THEN 1 ELSE -1 END), 0) SUM_QTY FROM POSLOG..TR_SALE_HEADER A ";
|
|
sQuery += " JOIN (SELECT DISTINCT CMP_CD, SALE_DT, STOR_CD, POS_NO, TRADE_NO, CPI_CD, SLACK_FIELD FROM POSLOG..TR_SALE_CPI_RSLT) B ON A.CMP_CD=B.CMP_CD AND A.SALE_DT = B.SALE_DT AND A.STOR_CD=B.STOR_CD AND A.POS_NO = B.POS_NO AND A.TRADE_NO = B.TRADE_NO ";
|
|
sQuery += " WHERE A.CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' ";
|
|
sQuery += " AND A.STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' ";
|
|
if (cMstSaleCpi.HP_CUST_JOIN_LMT_STD == "1") // 수량 제한 기준(1:일별, 2:행사기간별)
|
|
sQuery += " AND A.SALE_DT BETWEEN '" + m_cTrnStatus.Head.SysYmd + "' AND '" + m_cTrnStatus.Head.SysYmd + "' ";
|
|
else
|
|
sQuery += " AND A.SALE_DT BETWEEN '" + cMstSaleCpi.STARTDAY + "' AND '" + m_cTrnStatus.Head.SysYmd + "' ";
|
|
sQuery += " AND B.CPI_CD = '" + cMstSaleCpi.CPI_CD + "' ";
|
|
sQuery += " AND B.SLACK_FIELD = '" + sCustID + "' ";
|
|
|
|
DataTable dtCpiRslt = m_cMstService.Select(new string[] { sQuery });
|
|
if (dtCpiRslt != null && dtCpiRslt.Rows.Count > 0)
|
|
{
|
|
DataRow dr = dtCpiRslt.Rows[0];
|
|
|
|
sCpiCnt = CmUtil.GetDataRowStr(dr, "SUM_QTY");
|
|
}
|
|
}
|
|
|
|
string sCPI_NAME = cMstSaleCpi.CPI_NM;
|
|
if (cMstSaleCpi.QTY_LIMIT_MSG.Trim() != "") sCPI_NAME = cMstSaleCpi.QTY_LIMIT_MSG;
|
|
// 캠페인코드(0), 이전성립수량(1), 캠페인명(2), 제한수량(3), 현성립수량(4)
|
|
saCpiQtyLmtInfo = new string[] { cMstSaleCpi.CPI_CD, sCpiCnt, sCPI_NAME, cMstSaleCpi.HP_CUST_MAX_JOIN_CNT.ToString(), "1" };
|
|
//
|
|
m_alSaleCpiQtyLmt.Add(saCpiQtyLmtInfo);
|
|
}
|
|
|
|
if (CmUtil.LongParse(saCpiQtyLmtInfo[1]) >= cMstSaleCpi.HP_CUST_MAX_JOIN_CNT)
|
|
{
|
|
UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.INFO_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
|
|
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()"
|
|
, string.Format("CAMPAIGN CNT LIMIT OVER => CODE:{0}={1}, LimitCnt:{2}, AgoDisCnt:{3}", cMstSaleCpi.CPI_CD, cMstSaleCpi.CPI_NM, cMstSaleCpi.HP_CUST_MAX_JOIN_CNT, saCpiQtyLmtInfo[1]));
|
|
|
|
//WinManager.ConfirmMessage(cMstSaleCpi.CPI_NM + PosConst.CRLF + MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0589));
|
|
return false;
|
|
}
|
|
|
|
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 true;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 캠페인 참여문의 여부
|
|
/// </summary>
|
|
/// <param name="cMstSaleCpi"></param>
|
|
/// <returns>false:행사불가</returns>
|
|
public bool CheckCampaignJoinQustn(Column.MST_SALE_CPI.DATA cMstSaleCpi, bool bFocusQustn = false)
|
|
{
|
|
try
|
|
{
|
|
if (cMstSaleCpi.JOIN_QUSTN_YN == "1")
|
|
{
|
|
if (cMstSaleCpi.JOIN_QUSTN_ANSWER == "" || bFocusQustn == true)
|
|
{
|
|
if (WinManager.QuestionMessage(cMstSaleCpi.CPI_NM + PosConst.CRLF + MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0556)) == true)
|
|
cMstSaleCpi.JOIN_QUSTN_ANSWER = "1";
|
|
else
|
|
cMstSaleCpi.JOIN_QUSTN_ANSWER = "0";
|
|
|
|
UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.INFO_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
|
|
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()"
|
|
, "CAMPAIGN JOIN QUSTN ANSWER => " + cMstSaleCpi.JOIN_QUSTN_ANSWER);
|
|
}
|
|
|
|
if (cMstSaleCpi.JOIN_QUSTN_ANSWER == "0") return false;
|
|
}
|
|
}
|
|
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 true;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 실효100% 행사 체크
|
|
/// </summary>
|
|
/// <param name="cMstSaleCpi"></param>
|
|
/// <param name="nTotSaleAmt"></param>
|
|
/// <param name="nTotDisAmt"></param>
|
|
/// <returns></returns>
|
|
public double CheckCampaignExpPointAll(Column.MST_SALE_CPI.DATA cMstSaleCpi, double nTotSaleAmt, double nTotDisAmt)
|
|
{
|
|
try
|
|
{
|
|
if (cMstSaleCpi.CPI_CUST_BNFT_TYPE == ItemConst.CPI_CUST_BNFT.DIS_POINT_ALL)
|
|
{
|
|
// 실효 100% 캠페인은 실효 포인트 100% 있어야 함.
|
|
//if (nTotSaleAmt > nTotDisAmt + m_nHpExpPoint)
|
|
if (nTotSaleAmt > m_nHpExpPoint) // 실효포인트가 상품금액만큼 있어야함.(2017.06.12)
|
|
{
|
|
//UserLog.WriteLogFile(UserCom.LOG_IOS, UserCom.INFO_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
|
|
// System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()"
|
|
// , string.Format( "EXP POINT LESS => SaleAmt={0}, TotDisAmt={1}, ExpPoint={2}", nTotSaleAmt, nTotDisAmt, m_nHpExpPoint));
|
|
|
|
ClearCampaginItem(cMstSaleCpi.CPI_CD);
|
|
return 0;
|
|
}
|
|
}
|
|
return nTotDisAmt;
|
|
}
|
|
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 0;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 캠페인 중복 가능 여부 체크
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public bool CheckCampaignDuplication()
|
|
{
|
|
try
|
|
{
|
|
foreach (Column.TR_PLU.DATA cSaleItem in m_alTrPluItem)
|
|
{
|
|
if (cSaleItem.CANCEL_DIV == PosConst.CANCEL_DIV.CANCEL || cSaleItem.CANCEL_DIV_MAIN == PosConst.CANCEL_DIV.CANCEL) continue;// 지정취소
|
|
if (cSaleItem.BILLSPR_NO != m_cTrnStatus.Sale.BillSplitNo) continue; // 빌분리번호
|
|
if (cSaleItem.FLAVOUR_DIV == ItemConst.PLU_FLAVOUR_DIV.FLAVOUR) continue; // 플레이버 제외
|
|
if (cSaleItem.ITEM_DIV == ItemConst.PLU_ITEM_DIV.OPT_MENU && cSaleItem.SUBPRC_MENU_KEY_DIV == "1") continue; // 부가상품(속성) 제외
|
|
|
|
if ((cSaleItem.ITEM_DC_AMT > 0 || cSaleItem.SUM_DC_AMT > 0) && cSaleItem.DC_DIV.Length >= 4) // 단품 할인, 소계 할인 금액
|
|
{
|
|
// 캠페인중복 여부(0:불가, 1:가능)
|
|
if (PosMstManager.GetMstPayDc(cSaleItem.DC_DIV.Substring(0, 2), cSaleItem.DC_DIV.Substring(2, 2), PosMst.MST_PAY_DC.DATA.CPI_DUP_YN) == "0") return false;
|
|
}
|
|
if (cSaleItem.COOP_CARD_DC_AMT > 0 && cSaleItem.COOP_CARD_DC_DIV.Length >= 4) // 제휴 할인 금액
|
|
{
|
|
// 캠페인중복 여부(0:불가, 1:가능)
|
|
if (PosMstManager.GetMstPayDc(cSaleItem.COOP_CARD_DC_DIV.Substring(0, 2), cSaleItem.COOP_CARD_DC_DIV.Substring(2, 2), PosMst.MST_PAY_DC.DATA.CPI_DUP_YN) == "0") return false;
|
|
}
|
|
if (cSaleItem.POINT_DC_AMT > 0 && cSaleItem.POINT_DC_DIV.Length >= 4) // 포인트 할인 금액
|
|
{
|
|
// 캠페인중복 여부(0:불가, 1:가능)
|
|
if (PosMstManager.GetMstPayDc(cSaleItem.POINT_DC_DIV.Substring(0, 2), cSaleItem.POINT_DC_DIV.Substring(2, 2), PosMst.MST_PAY_DC.DATA.CPI_DUP_YN) == "0") return false;
|
|
}
|
|
if (cSaleItem.CPN_DC_AMT > 0 && cSaleItem.CPN_DC_DIV.Length >= 4) // 쿠폰 할인 금액
|
|
{
|
|
// 캠페인중복 여부(0:불가, 1:가능)
|
|
if (PosMstManager.GetMstPayDc(cSaleItem.CPN_DC_DIV.Substring(0, 2), cSaleItem.CPN_DC_DIV.Substring(2, 2), PosMst.MST_PAY_DC.DATA.CPI_DUP_YN) == "0") return false;
|
|
}
|
|
if (cSaleItem.EMP_DC_AMT > 0 && cSaleItem.EMP_DC_DIV.Length >= 4) // 직원 할인 금액
|
|
{
|
|
// 캠페인중복 여부(0:불가, 1:가능)
|
|
if (PosMstManager.GetMstPayDc(cSaleItem.EMP_DC_DIV.Substring(0, 2), cSaleItem.EMP_DC_DIV.Substring(2, 2), PosMst.MST_PAY_DC.DATA.CPI_DUP_YN) == "0") return false;
|
|
}
|
|
if (cSaleItem.SET_DC_AMT > 0) // 세트할인
|
|
{
|
|
// 캠페인중복 여부(0:불가, 1:가능)
|
|
if (PosMstManager.GetMstPayDc(ItemConst.PLU_DC_DIV.SET_DC.Substring(0, 2), ItemConst.PLU_DC_DIV.SET_DC.Substring(2, 2), PosMst.MST_PAY_DC.DATA.CPI_DUP_YN) == "0") return false;
|
|
}
|
|
}
|
|
|
|
ArrayList alPayItem = (ArrayList)StateObject.GetItemObject(Column.TR_PAYMENT.ITEM);
|
|
foreach (Column.TR_PAYMENT.DATA cPayItem in alPayItem)
|
|
{
|
|
if (cPayItem.CANCEL_DIV != PosConst.CANCEL_DIV.NORMAL) continue;
|
|
|
|
if (cPayItem.PAY_DTL_CD_05 == PosConst.PAY_DC_TYPE.PAY) // 할인결제구분 (1:결제, 2:할인)
|
|
{
|
|
// 캠페인중복 여부(0:불가, 1:가능)
|
|
if (PosMstManager.GetMstPayDc(cPayItem.PAY_WAY_CD, cPayItem.PAY_DTL_CD_01, PosMst.MST_PAY_DC.DATA.CPI_DUP_YN) == "0") return false;
|
|
}
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
//#15583 캠페인 기능 개선 요청 start
|
|
/// <summary>
|
|
/// 캠페인 마스터의 중복 가능 여부 체크(통신사 제휴 중복 허용 여부, 모바일쿠폰 중복 허용 여부, 해피쿠폰 중복 허용 여부)
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public bool CheckCampaignMstDuplication(Column.MST_SALE_CPI.DATA cMstSaleCpi)
|
|
{
|
|
try
|
|
{
|
|
// TELECOM_COOP_DUP_PRMT_YN -> 제휴할인그룹 중복 여부(1:중복적용가능, 0:중복적용불가)
|
|
// MOBILE_CPN_DUP_PRMT_YN -> 모바일쿠폰 그룹 중복 여부(1:중복적용가능, 0:중복적용불가)
|
|
// HPY_CPN_DUP_PRMT_YN -> 해피쿠폰 사용 중복 허용 여부(1:중복적용가능, 0:중복적용불가)
|
|
// CPI_CUST_BNFT_TYPE -> 캠페인 고객해택 구분(01:할인,02:적립,03:할인+적립,04:사은품,05:복권,06:명판,07:복권+명판,08:응모권,09:응모권+명판,10:스템프,11:할인(실효100%),12:사은품+적립,13:할인(실효))
|
|
|
|
if (cMstSaleCpi.TELECOM_COOP_DUP_PRMT_YN == "1" &&
|
|
cMstSaleCpi.MOBILE_CPN_DUP_PRMT_YN == "1" &&
|
|
cMstSaleCpi.HPY_CPN_DUP_PRMT_YN == "1")
|
|
{
|
|
return true;
|
|
}
|
|
|
|
// 결제 리스트에서 모바일쿠폰 결제 여부 채크
|
|
bool bMobileCpnYN = false;
|
|
|
|
ArrayList alPayItem = (ArrayList)StateObject.GetItemObject(Column.TR_PAYMENT.ITEM);
|
|
foreach (Column.TR_PAYMENT.DATA cPayItem in alPayItem)
|
|
{
|
|
if (cPayItem.CANCEL_DIV != PosConst.CANCEL_DIV.NORMAL) continue;
|
|
|
|
if (cPayItem.PAY_DTL_CD_05 == PosConst.PAY_DC_TYPE.PAY) // 할인결제구분 (1:결제, 2:할인)
|
|
{
|
|
if (cPayItem.PAY_WAY_CD == ItemConst.TR_ITEM_ID.MOBILECON_ITEM)
|
|
{
|
|
bMobileCpnYN = true;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
// 상품 리스트에서 중복 여부 체크
|
|
foreach (Column.TR_PLU.DATA cSaleItem in m_alTrPluItem)
|
|
{
|
|
if (cSaleItem.CANCEL_DIV == PosConst.CANCEL_DIV.CANCEL || cSaleItem.CANCEL_DIV_MAIN == PosConst.CANCEL_DIV.CANCEL) continue;// 지정취소
|
|
if (cSaleItem.BILLSPR_NO != m_cTrnStatus.Sale.BillSplitNo) continue; // 빌분리번호
|
|
if (cSaleItem.FLAVOUR_DIV == ItemConst.PLU_FLAVOUR_DIV.FLAVOUR) continue; // 플레이버 제외
|
|
if (cSaleItem.ITEM_DIV == ItemConst.PLU_ITEM_DIV.OPT_MENU && cSaleItem.SUBPRC_MENU_KEY_DIV == "1") continue; // 부가상품(속성) 제외
|
|
|
|
if (cMstSaleCpi.CPI_CUST_BNFT_TYPE == ItemConst.CPI_CUST_BNFT.LOTTERY ||
|
|
cMstSaleCpi.CPI_CUST_BNFT_TYPE == ItemConst.CPI_CUST_BNFT.RECEIPT ||
|
|
cMstSaleCpi.CPI_CUST_BNFT_TYPE == ItemConst.CPI_CUST_BNFT.LOTT_REC ||
|
|
cMstSaleCpi.CPI_CUST_BNFT_TYPE == ItemConst.CPI_CUST_BNFT.ENTRY ||
|
|
cMstSaleCpi.CPI_CUST_BNFT_TYPE == ItemConst.CPI_CUST_BNFT.ENTR_REC ||
|
|
cMstSaleCpi.CPI_CUST_BNFT_TYPE == ItemConst.CPI_CUST_BNFT.HP_STAMP)
|
|
{
|
|
if (cMstSaleCpi.TELECOM_COOP_DUP_PRMT_YN == "0" && cSaleItem.COOP_CARD_DC_AMT > 0) return false; // 제휴카드 할인 금액
|
|
}
|
|
|
|
if (cMstSaleCpi.HPY_CPN_DUP_PRMT_YN == "0" && cSaleItem.CPN_DC_AMT > 0) return false; // 쿠폰 할인 금액
|
|
|
|
if (cMstSaleCpi.MOBILE_CPN_DUP_PRMT_YN == "0" && bMobileCpnYN == true) return false; // 모바일쿠폰 결제 여부
|
|
}
|
|
|
|
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;
|
|
}
|
|
//#15583 캠페인 기능 개선 요청 end
|
|
|
|
}
|
|
}
|