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

1348 lines
82 KiB
C#

using System;
using System.Data;
using System.Collections;
using Cosmos.UserFrame;
using Cosmos.ServiceProvider;
using Cosmos.Common;
using Cosmos.CommonManager;
using System.Data.SqlClient;
/*-----------------------------------------------------------------------------------------------*/
// 설 명 : 입출금/준비금/마감입금
// 작 성 자 :
// 변경 이력 :
/*-----------------------------------------------------------------------------------------------*/
namespace Cosmos.Service
{
/// <summary>
///
/// </summary>
public class AccADMT : IAccADMT
{
#region
private SManager sManager = new SManager(); // 이 객체를 통해 업무 Service 호출
private PosStatus m_cPosStatus = new PosStatus(); //기본정보 참조
private IMasterUs m_cMstService = null; // 마스터 인터페이스
private StateServer StateObject = (StateServer)StateServer.GetInstance(); // StateObject : StateServer Object (객체)
private IDataProcessUs m_cDataService = null;
private TranStatus m_cTrnStatus = new TranStatus(); //거래정보 참조
private ISaleCompleteUs m_cSaleComplete = null; // 거래완료처리
private IDatabaseSQL m_cSqlDbService = null; // 데이터베이스 관리
private IDataCommonUs m_cDataCommon = null; // POS 공통함수 인터페이스
public AccADMT()
{
m_cPosStatus = (PosStatus)StateObject.POS; // POS 기본정보
m_cTrnStatus = (TranStatus)StateObject.TRAN; // POS 거래정보
m_cMstService = (IMasterUs)sManager.InitServiceInstance(ServiceLists.ASV_MASTER.DLL, ServiceLists.ASV_MASTER.POS_MASTER);
m_cDataService = (IDataProcessUs)sManager.InitServiceInstance(ServiceLists.ASV_DATA_PROCESS.DLL, ServiceLists.ASV_DATA_PROCESS.DATA_SERVICE);
m_cSaleComplete = (ISaleCompleteUs)sManager.InitServiceInstance(ServiceLists.ASV_DATA_PROCESS.DLL, ServiceLists.ASV_DATA_PROCESS.SALE_COMPLETE);
m_cSqlDbService = (IDatabaseSQL)sManager.InitServiceInstance(ServiceLists.AGENT_DATABASE.DLL, ServiceLists.AGENT_DATABASE.DATABASE_MSSQL);
m_cDataCommon = (IDataCommonUs)sManager.InitServiceInstance(ServiceLists.ASV_DATA_PROCESS.DLL, ServiceLists.ASV_DATA_PROCESS.DATA_COMMON);
}
#endregion
#region
///// <summary>
///// 조회
///// </summary>
///// <param name="aParam"></param>
///// <returns></returns>
//public DataTable GetData(string[] aParam)
//{
// string sSql = "";
// try
// {
// string sKind = aParam[0];
// //string sSimplePrint = aParam[1];
// sSql = "";
// sSql += " SELECT \n";
// sSql += " ISNULL(MBT.BILL_TYPE_DIV, '') BILL_TYPE_DIV \n";
// sSql += " , ISNULL(MBT.SEQ_NO, 0) SEQ_NO \n";
// sSql += " , ISNULL(MBT.SORT_DIV, '2') SORT_DIV \n";
// sSql += " , ISNULL(MBT.SIZE_DIV, '0') SIZE_DIV \n";
// sSql += " , CASE WHEN SUBSTRING(MBT.BILL_TYPE_TAG, 1, 6) = '<CODE>' THEN SUBSTRING(MBT.BILL_TYPE_TAG, 1, 6) ELSE ISNULL(MBT.BILL_TYPE_TAG, '') END BILL_TYPE_TAG \n";
// sSql += " , ISNULL(MM.QTY, 0) QTY \n";
// sSql += " , ISNULL(MM.AMT, 0) AMT \n";
// sSql += " , ISNULL(MM.MSG1, '') MSG \n";
// sSql += " FROM POSMST.dbo.MST_BILL_TYPE MBT \n";
// sSql += " LEFT JOIN ( \n";
// sSql += " SELECT \n";
// sSql += " MM.CMP_CD \n";
// sSql += " , MM.STOR_CD \n";
// sSql += " , MM.ADMT_CD \n";
// sSql += " , ISNULL(SUM(MM.QTY), 0) QTY \n";
// sSql += " , ISNULL(SUM(MM.AMT), 0) AMT \n";
// sSql += " , ISNULL(MM.MSG1, '') MSG1 \n";
// sSql += " FROM ( \n";
// sSql += " SELECT \n";
// sSql += " MBT.CMP_CD \n";
// sSql += " , MBT.STOR_CD \n";
// sSql += " , ISNULL(SUBSTRING(MBT.BILL_TYPE_TAG, 7, 4) , '') ADMT_CD \n";
// sSql += " , 0 QTY \n";
// sSql += " , 0 AMT \n";
// sSql += " , ISNULL(CMM.ENTRY_NM, '') MSG1 \n";
// sSql += " , ISNULL(CMM.DISP_SEQ, 0) DISP_SEQ \n";
// sSql += " FROM POSMST..MST_BILL_TYPE MBT \n";
// sSql += " INNER JOIN POSMST..MST_CMM CMM \n";
// sSql += " ON CMM.CMP_CD = MBT.CMP_CD \n";
// sSql += " AND CMM.CMM_GRP_CD = '" + PosConst.COMMON_CODE_GROUP.Z0013 + "' \n";
// sSql += " AND ISNULL(CMM.CHAR_VAL_TITLE_VAL_01, '') LIKE '" + sSimplePrint + "' + '%' \n";
// sSql += " AND CMM.CMM_CD = SUBSTRING(MBT.BILL_TYPE_TAG, 7, 4) \n";
// sSql += " AND CMM.LANG_TYPE = '" + m_cPosStatus.Base.Country + "' \n";
// sSql += " AND CMM.USE_YN = '1' \n";
// sSql += " WHERE \n";
// sSql += " MBT.CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n";
// sSql += " AND MBT.STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n";
// sSql += " AND MBT.BILL_TYPE_GRP_CD = '" + CmUtil.GetDataRowStr(PosMstManager.GetMstPos(), PosMst.MST_POS.DATA.BILL_TYPEGRP) + "' \n";
// sSql += " AND MBT.BILL_TYPE_DIV = '" + PosConst.BILL_TYPE_DIV.ADMT_TRAN + "' \n";
// sSql += " AND SUBSTRING(MBT.BILL_TYPE_TAG, 1, 6) = '<CODE>' \n";
// sSql += " AND MBT.USE_YN = '1' \n";
// sSql += " \n";
// sSql += " UNION ALL \n";
// sSql += " \n";
// sSql += " SELECT \n";
// sSql += " TSH.CMP_CD \n";
// sSql += " , TSH.STOR_CD \n";
// sSql += " , TSA.ADMT_CD ADMT_CD \n";
// sSql += " , TSA.QTY \n";
// sSql += " , TSA.AMT \n";
// sSql += " , ISNULL(CMM.ENTRY_NM, '') MSG1 \n";
// sSql += " , ISNULL(CMM.DISP_SEQ, 0) DISP_SEQ \n";
// sSql += " FROM \n";
// sSql += " POSLOG..TR_SALE_HEADER TSH \n";
// sSql += " INNER JOIN POSLOG..TR_SALE_ADMT TSA \n";
// sSql += " ON TSA.CMP_CD = TSH.CMP_CD \n";
// sSql += " AND TSA.SALE_DT = TSH.SALE_DT \n";
// sSql += " AND TSA.STOR_CD = TSH.STOR_CD \n";
// sSql += " AND TSA.POS_NO = TSH.POS_NO \n";
// sSql += " AND TSA.TRADE_NO = TSH.TRADE_NO \n";
// sSql += " INNER JOIN POSMST..MST_POS MP \n";
// sSql += " ON MP.CMP_CD = TSH.CMP_CD \n";
// sSql += " AND MP.STOR_CD = TSH.STOR_CD \n";
// sSql += " AND MP.POS_NO IN ('00', TSH.POS_NO) \n";
// sSql += " AND MP.USE_YN = '1' \n";
// sSql += " RIGHT JOIN POSMST..MST_BILL_TYPE MBT \n";
// sSql += " ON MBT.CMP_CD = TSH.CMP_CD \n";
// sSql += " AND MBT.STOR_CD = TSH.STOR_CD \n";
// sSql += " AND MBT.BILL_TYPE_GRP_CD = MP.BILL_TYPEGRP \n";
// sSql += " AND MBT.BILL_TYPE_DIV = '" + PosConst.BILL_TYPE_DIV.ADMT_TRAN + "' \n";
// sSql += " AND SUBSTRING(MBT.BILL_TYPE_TAG, 1, 6) = '<CODE>' \n";
// sSql += " AND SUBSTRING(MBT.BILL_TYPE_TAG, 7, 4) = TSA.ADMT_CD \n";
// sSql += " AND MBT.USE_YN = '1' \n";
// sSql += " LEFT JOIN POSMST..MST_CMM CMM \n";
// sSql += " ON CMM.CMP_CD = MBT.CMP_CD \n";
// sSql += " AND CMM.CMM_GRP_CD = '" + PosConst.COMMON_CODE_GROUP.Z0013 + "' \n";
// sSql += " AND ISNULL(CMM.CHAR_VAL_TITLE_VAL_01, '') LIKE '" + sSimplePrint + "' + '%' \n";
// sSql += " AND CMM.CMM_CD = SUBSTRING(MBT.BILL_TYPE_TAG, 7, 4) \n";
// sSql += " AND CMM.LANG_TYPE = '" + m_cPosStatus.Base.Country + "' \n";
// sSql += " AND CMM.USE_YN = '1' \n";
// sSql += " WHERE \n";
// sSql += " TSH.CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n";
// sSql += " AND TSH.SALE_DT = '" + m_cPosStatus.Base.SaleDate + "' \n";
// sSql += " AND TSH.STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n";
// sSql += " AND TSH.POS_NO = '" + m_cPosStatus.Base.PosNo + "' \n";
// sSql += " AND TSH.TRADE_KINDPER IN ('" + ItemConst.TRAN_KIND.STATEMENT.MIDDLE_ADJUSTMENT + "', '" + ItemConst.TRAN_KIND.STATEMENT.ADJUSTMENT + "') \n";
// sSql += " AND TSH.TRADE_NO = (SELECT MAX(TSH1.TRADE_NO) \n";
// sSql += " FROM POSLOG..TR_SALE_HEADER TSH1 \n";
// sSql += " WHERE \n";
// sSql += " TSH1.CMP_CD = TSH.CMP_CD \n";
// sSql += " AND TSH1.SALE_DT = TSH.SALE_DT \n";
// sSql += " AND TSH1.STOR_CD = TSH.STOR_CD \n";
// sSql += " AND TSH1.POS_NO = TSH.POS_NO \n";
// sSql += " AND TSH1.TRADE_DIV = '0' \n";
// sSql += " AND TSH1.TRAIN_MODE_YN = '0' \n";
// sSql += " AND TSH1.TRADE_KINDPER IN ('" + ItemConst.TRAN_KIND.STATEMENT.MIDDLE_ADJUSTMENT + "', '" + ItemConst.TRAN_KIND.STATEMENT.ADJUSTMENT + "')) \n";
// sSql += " ) MM \n";
// sSql += " GROUP BY MM.CMP_CD, MM.STOR_CD, MM.ADMT_CD, ISNULL(MM.MSG1, '') \n";
// sSql += " ) MM \n";
// sSql += " ON MBT.CMP_CD = MM.CMP_CD \n";
// sSql += " AND MBT.STOR_CD = MM.STOR_CD \n";
// sSql += " AND SUBSTRING(MBT.BILL_TYPE_TAG, 7, 4) = MM.ADMT_CD \n";
// sSql += " WHERE \n";
// sSql += " MBT.CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n";
// sSql += " AND MBT.STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n";
// sSql += " AND MBT.BILL_TYPE_GRP_CD = '" + CmUtil.GetDataRowStr(PosMstManager.GetMstPos(), PosMst.MST_POS.DATA.BILL_TYPEGRP) + "' \n";
// sSql += " AND MBT.BILL_TYPE_DIV = '" + PosConst.BILL_TYPE_DIV.ADMT_TRAN + "' \n";
// sSql += " AND MBT.USE_YN = '1' \n";
// sSql += " ORDER BY 1, 2 \n";
// sSql = sSql.Replace("\t", " ");
// DataTable dtDataInfo = m_cMstService.Select(new string[] { sSql });
// return dtDataInfo;
// }
// catch (Exception ex)
// {
// WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
// System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
// }
// return null;
//}
#endregion
#region
/// <summary>
/// 중간정산 횟수 조회
/// </summary>
/// <param name="aParam"></param>
/// <returns></returns>
public DataTable GetADMTCount(string[] aParam)
{
string sSql = "";
try
{
sSql = "";
sSql += "SELECT \n";
sSql += " COUNT(*) QTY \n";
sSql += "FROM POSLOG..TR_SALE_HEADER TSH \n";
sSql += "WHERE \n";
sSql += " TSH.CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n";
sSql += "AND TSH.SALE_DT = '" + m_cPosStatus.Base.SaleDate + "' \n";
sSql += "AND TSH.STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n";
sSql += "AND TSH.POS_NO = '" + m_cPosStatus.Base.PosNo + "' \n";
sSql += "AND TSH.TRADE_KINDPER IN ('" + ItemConst.TRAN_KIND.STATEMENT.MIDDLE_ADJUSTMENT + "') \n";
// sSql += "AND TSH.TRADE_KINDPER IN ('" + ItemConst.TRAN_KIND.STATEMENT.MIDDLE_ADJUSTMENT + "', '" + ItemConst.TRAN_KIND.STATEMENT.ADJUSTMENT + "') \n";
sSql = sSql.Replace("\t", " ");
DataTable dtDataInfo = m_cMstService.Select(new string[] { sSql });
return dtDataInfo;
}
catch (Exception ex)
{
WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
}
return null;
}
#endregion
#region
/// <summary>
/// 과부족 조회
/// </summary>
/// <param name="aParam"></param>
/// <returns></returns>
public DataTable GetOverAmtSelect(string[] aParam)
{
string sSql = "";
try
{
//sSql = "";
//sSql += " SELECT \n";
//sSql += " ISNULL(TSA.AMT, 0) AMT \n";
//sSql += " FROM \n";
//sSql += " POSLOG..TR_SALE_HEADER TSH \n";
//sSql += " RIGHT JOIN POSLOG..TR_SALE_ADMT_CHECK TSA \n";
//sSql += " ON TSA.CMP_CD = TSH.CMP_CD \n";
//sSql += " AND TSA.SALE_DT = TSH.SALE_DT \n";
//sSql += " AND TSA.STOR_CD = TSH.STOR_CD \n";
//sSql += " AND TSA.POS_NO = TSH.POS_NO \n";
//sSql += " AND TSA.TRADE_NO = TSH.TRADE_NO \n";
//sSql += " AND TSA.ADMT_CD = '" + aParam[0] + "' \n";
//sSql += " WHERE \n";
//sSql += " TSH.CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n";
//sSql += " AND TSH.SALE_DT = '" + m_cPosStatus.Base.SaleDate + "' \n";
//sSql += " AND TSH.STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n";
//sSql += " AND TSH.POS_NO = '" + m_cPosStatus.Base.PosNo + "' \n";
////sSql += " AND TSH.TRADE_KINDPER IN ('" + ItemConst.TRAN_KIND.STATEMENT.MIDDLE_ADJUSTMENT + "', '" + ItemConst.TRAN_KIND.STATEMENT.ADJUSTMENT + "') \n";
//sSql += " AND TSH.TRADE_NO = (SELECT MAX(TSH1.TRADE_NO) \n";
//sSql += " FROM POSLOG..TR_SALE_HEADER TSH1 \n";
//sSql += " WHERE \n";
//sSql += " TSH1.CMP_CD = TSH.CMP_CD \n";
//sSql += " AND TSH1.SALE_DT = TSH.SALE_DT \n";
//sSql += " AND TSH1.STOR_CD = TSH.STOR_CD \n";
//sSql += " AND TSH1.POS_NO = TSH.POS_NO \n";
//sSql += " AND TSH1.TRADE_DIV = '0' \n";
//sSql += " AND TSH1.TRAIN_MODE_YN = '0') \n";
////sSql += " AND TSH1.TRADE_KINDPER IN ('" + ItemConst.TRAN_KIND.STATEMENT.MIDDLE_ADJUSTMENT + "', '" + ItemConst.TRAN_KIND.STATEMENT.ADJUSTMENT + "')) \n";
sSql = "";
sSql += " SELECT \n";
sSql += " ISNULL(TSA.AMT, 0) AMT \n";
sSql += " FROM \n";
sSql += " POSLOG..TR_SALE_ADMT_CHECK TSA \n";
sSql += " WHERE \n";
sSql += " TSA.CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n";
sSql += " AND TSA.SALE_DT = '" + m_cPosStatus.Base.SaleDate + "' \n";
sSql += " AND TSA.STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n";
sSql += " AND TSA.POS_NO = '" + m_cPosStatus.Base.PosNo + "' \n";
sSql += " AND TSA.ADMT_TYPE IN ('" + ItemConst.TRAN_KIND.STATEMENT.MIDDLE_ADJUSTMENT + "', '" + ItemConst.TRAN_KIND.STATEMENT.ADJUSTMENT + "') \n";
sSql += " AND TSA.ADMT_CD = '" + aParam[0] + "' \n";
sSql += " AND TSA.TRADE_NO = (SELECT MAX(TSA1.TRADE_NO) \n";
sSql += " FROM POSLOG..TR_SALE_ADMT_CHECK TSA1 \n";
sSql += " WHERE \n";
sSql += " TSA1.CMP_CD = TSA.CMP_CD \n";
sSql += " AND TSA1.SALE_DT = TSA.SALE_DT \n";
sSql += " AND TSA1.STOR_CD = TSA.STOR_CD \n";
sSql += " AND TSA1.POS_NO = TSA.POS_NO \n";
sSql += " AND TSA1.ADMT_TYPE IN ('" + ItemConst.TRAN_KIND.STATEMENT.MIDDLE_ADJUSTMENT + "', '" + ItemConst.TRAN_KIND.STATEMENT.ADJUSTMENT + "')) \n";
sSql = sSql.Replace("\t", " ");
DataTable dtDataInfo = m_cMstService.Select(new string[] { sSql });
return dtDataInfo;
}
catch (Exception ex)
{
WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
}
return null;
}
#endregion
#region
/// <summary>
/// 저장
/// </summary>
/// <param name="aParam"></param>
/// <param name="oParam"></param>
/// <returns></returns>
public string SetData(string[] aParam, object oParam, string sSimplePrint)
{
string sRet = UserCom.RST_ERR;
double nTotalAmount = 0;
string sPrint = "0";
try
{
DataTable dParam = (DataTable)oParam;
if (aParam == null) return sRet;
m_cDataService.SetTranBaseToHead(); //트란 헤더 정보 재설정
m_cTrnStatus.Head.TradeKind = aParam[0]; // ItemConst.TRAN_KIND.STATEMENT.RESERVE_FUND;
m_cTrnStatus.Head.TradeDiv = aParam[1]; // ItemConst.TRAN_DIV.NORMAL;
//if (m_cTrnStatus.Head.TradeKind == ItemConst.TRAN_KIND.STATEMENT.ADJUSTMENT || m_cTrnStatus.Head.TradeKind == ItemConst.TRAN_KIND.STATEMENT.MIDDLE_ADJUSTMENT)
if (m_cTrnStatus.Head.TradeKind == ItemConst.TRAN_KIND.STATEMENT.CLOSING_MONEY)
{
//결과 저장
ArrayList aDpstWthdr = (ArrayList)StateObject.GetItemObject(Column.SALE_DPST_WTHDR.ITEM);
Column.SALE_DPST_WTHDR.DATA cDpstWthdr = new Column.SALE_DPST_WTHDR.DATA();
int i = 1;
foreach (DataRow dr in dParam.Rows)
{
nTotalAmount = CmUtil.DoubleAdd(nTotalAmount, m_cDataService.DoubleParse(dr["DPST_WTHDR_AMT"].ToString()));
i++;
cDpstWthdr = new Column.SALE_DPST_WTHDR.DATA();
cDpstWthdr.SEQ = i;
cDpstWthdr.DPST_WTHDR_TYPE = aParam[0];
cDpstWthdr.DPST_WTHDR_CD = dr["DPST_WTHDR_CD"].ToString();
cDpstWthdr.DPST_WTHDR_AMT = m_cDataService.DoubleParse(dr["DPST_WTHDR_AMT"].ToString());
cDpstWthdr.DPST_WTHDR_NM = dr["DPST_WTHDR_NM"].ToString();
cDpstWthdr.DPST_WTHDR_QTY = m_cDataService.IntParse(dr["DPST_WTHDR_QTY"].ToString());
cDpstWthdr.CUST_NO = "";
cDpstWthdr.SLACK_FIELD_01 = "";
aDpstWthdr.Add(cDpstWthdr);
}
sPrint = "1";
}
else if (m_cTrnStatus.Head.TradeKind == ItemConst.TRAN_KIND.STATEMENT.ADJUSTMENT || m_cTrnStatus.Head.TradeKind == ItemConst.TRAN_KIND.STATEMENT.MIDDLE_ADJUSTMENT)
{
sPrint = "1";
}
// 2019-04-24 - 1997fx11 : 정산지 출력여부
sPrint = "0";
m_cTrnStatus.Head.TotSaleAmt = nTotalAmount;
// 거래 완료 처리
sRet = m_cSaleComplete.OpenCloseExecute(new string[] { sPrint, sSimplePrint });
if (sRet != UserCom.RST_OK) return sRet;
bool bIncTradeNo = m_cDataCommon.TradeNoAddCheck("");
//bool bAddTradeNo = (aParam[0] == ItemConst.TRAN_KIND.STATEMENT.CLOSING_MONEY || aParam[0] == ItemConst.TRAN_KIND.LOG.POS_CLOSE || aParam[0] == ItemConst.TRAN_KIND.LOG.POS_OPEN) ? false : true;
m_cDataService.TranComplete();
m_cDataService.SetMsgNoInc(true, !bIncTradeNo, bIncTradeNo, aParam[0]); // 거래번호 증가
if (m_cTrnStatus.Head.TradeKind == ItemConst.TRAN_KIND.STATEMENT.CLOSING_MONEY)
{
m_cTrnStatus.Head.RegNo = m_cPosStatus.Base.RegNo; // REG_NO
}
//////#region 후불 정보 초기화 - 개점으로 이동
//////if (m_cTrnStatus.Head.TradeKind == ItemConst.TRAN_KIND.STATEMENT.ADJUSTMENT)
//////{
////// using (SqlDB sqlDb = new SqlDB(m_cPosStatus.Base.LocalDbSource, m_cPosStatus.Base.LocalDbCatalog, m_cPosStatus.Base.LocalDbUserID, m_cPosStatus.Base.LocalDbPassword))
////// {
////// string sQuery = "";
////// if (m_cPosStatus.Base.PosCommunicationType == PosConst.MAIN_POS_DIV.MAIN_POS)
////// {
////// // 테이블마스터 매출정보 삭제
////// sQuery = " UPDATE POSMST..MST_TBL ";
////// sQuery += " SET TBL_USE_DIV = '0'";
////// sQuery += " , CUST_CNT = 0";
////// sQuery += " , FIRST_ORD_HOUR = ''";
////// sQuery += " , ORD_AMT = 0";
////// sQuery += " , TBL_OP_DIV = '0'";
////// sQuery += " , OP_FLOOR_CD = ''";
////// sQuery += " , OP_TBL_NO = ''";
////// sQuery += " , PAY_CMPT_DIV = ''";
////// sQuery += " , FILLER1 = ''";
////// sQuery += " , FILLER2 = ''";
////// sQuery += " , FILLER3 = ''"; // Add, 2017.02.22, 테이블그룹순번
////// sQuery += " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' ";
////// sQuery += " AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' ";
////// sqlDb.DBExecuteNonQuery(new string[] { sQuery }, CommandType.Text, (SqlParameter[])null);
////// // 주문데이터 삭제
////// sQuery = " TRUNCATE TABLE POSMST..MST_ORD ";
////// sqlDb.DBExecuteNonQuery(new string[] { sQuery }, CommandType.Text, (SqlParameter[])null);
////// // 주방데이터 삭제
////// sQuery = " TRUNCATE TABLE POSMST..MST_KTCH_ORD_MSG ";
////// sqlDb.DBExecuteNonQuery(new string[] { sQuery }, CommandType.Text, (SqlParameter[])null);
////// // 추가주방데이터 삭제
////// sQuery = " TRUNCATE TABLE POSMST..MST_KTCH_ORD_MSG_ADD ";
////// sqlDb.DBExecuteNonQuery(new string[] { sQuery }, CommandType.Text, (SqlParameter[])null);
////// // 주방프린터 데이터 삭제
////// sQuery = " TRUNCATE TABLE POSMST..MST_KPS_ORD_MSG ";
////// sqlDb.DBExecuteNonQuery(new string[] { sQuery }, CommandType.Text, (SqlParameter[])null);
////// // KDS 데이터 삭제
////// sQuery = " TRUNCATE TABLE POSMST..MST_KDS_ORD_MSG ";
////// sqlDb.DBExecuteNonQuery(new string[] { sQuery }, CommandType.Text, (SqlParameter[])null);
////// // 좌석메모 데이터 삭제
////// sQuery = " TRUNCATE TABLE POSMST..MST_SEAT_MEMO ";
////// sqlDb.DBExecuteNonQuery(new string[] { sQuery }, CommandType.Text, (SqlParameter[])null);
////// }
////// }
//////}
//////#endregion
}
catch (Exception ex)
{
WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
}
return sRet;
}
#endregion
#region
/// <summary>
/// 정산
/// </summary>
/// <param name="aParam"></param>
/// <returns></returns>
public string SetADMTData(string[] aParam)
{
string sRet = UserCom.RST_ERR;
try
{
if (aParam == null) return sRet;
m_cDataService.SetTranBaseToHead(); //트란 헤더 정보 재설정
m_cTrnStatus.Head.TradeKind = aParam[0]; // ItemConst.TRAN_KIND.STATEMENT.RESERVE_FUND;
m_cTrnStatus.Head.TradeDiv = aParam[1]; // ItemConst.TRAN_DIV.NORMAL;
// 거래 완료 처리
sRet = m_cSaleComplete.OpenCloseExecute(new string[] { });
if (sRet != UserCom.RST_OK) return sRet;
bool bIncTradeNo = m_cDataCommon.TradeNoAddCheck("");
m_cDataService.TranComplete();
m_cDataService.SetMsgNoInc(true, !bIncTradeNo, bIncTradeNo); // 거래번호 증가
}
catch (Exception ex)
{
WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
}
return sRet;
}
#endregion
#region
/// <summary>
/// 정산취소
/// </summary>
/// <param name="aParam"></param>
/// <returns></returns>
public string RefundADMTData(string[] aParam)
{
string sRet = UserCom.RST_ERR;
try
{
if (aParam == null) return sRet;
m_cDataService.SetTranBaseToHead(); //트란 헤더 정보 재설정
m_cTrnStatus.Head.TradeKind = aParam[0]; // ItemConst.TRAN_KIND.STATEMENT.RESERVE_FUND;
m_cTrnStatus.Head.TradeDiv = aParam[1]; // ItemConst.TRAN_DIV.NORMAL;
// 원거래정보
m_cTrnStatus.Head.OrgPosNo = m_cPosStatus.Base.PosNo;
m_cTrnStatus.Head.OrgSaleDate = m_cPosStatus.Base.SaleDate;
m_cTrnStatus.Head.OrgTradeNo = aParam[2];
// 거래 완료 처리
sRet = m_cSaleComplete.OpenCloseExecute(new string[] { "0" });
if (sRet != UserCom.RST_OK) return sRet;
bool bIncTradeNo = m_cDataCommon.TradeNoAddCheck("");
m_cDataService.TranComplete();
m_cDataService.SetMsgNoInc(true, !bIncTradeNo, bIncTradeNo, aParam[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 sRet;
}
#endregion
#region
/// <summary>
/// 실행
/// </summary>
/// <param name="aParam"></param>
/// <returns></returns>
public string Execute(string[] aParam)
{
throw new NotImplementedException();
}
#endregion
#region
/// <summary>
/// 입금취소
/// </summary>
/// <param name="aParam"></param>
/// <param name="oParam"></param>
/// <returns></returns>
public string SetRefund(string[] aParam, object oParam)
{
string sRet = UserCom.RST_ERR;
double nTotalAmount = 0;
try
{
DataTable dParam = (DataTable)oParam;
if (aParam == null) return sRet;
m_cDataService.SetTranBaseToHead(); //트란 헤더 정보 재설정
m_cTrnStatus.Head.TradeKind = aParam[0]; // ItemConst.TRAN_KIND.STATEMENT.RESERVE_FUND;
m_cTrnStatus.Head.TradeDiv = aParam[1]; // ItemConst.TRAN_DIV.NORMAL;
// 원거래정보
m_cTrnStatus.Head.OrgPosNo = m_cPosStatus.Base.PosNo;
m_cTrnStatus.Head.OrgSaleDate = m_cPosStatus.Base.SaleDate;
m_cTrnStatus.Head.OrgTradeNo = aParam[2];
//결과 저장
ArrayList aDpstWthdr = (ArrayList)StateObject.GetItemObject(Column.SALE_DPST_WTHDR.ITEM);
Column.SALE_DPST_WTHDR.DATA cDpstWthdr = new Column.SALE_DPST_WTHDR.DATA();
int i = 1;
foreach (DataRow dr in dParam.Rows)
{
nTotalAmount = CmUtil.DoubleAdd(nTotalAmount, m_cDataService.DoubleParse(dr["DPST_WTHDR_AMT"].ToString()));
i++;
cDpstWthdr = new Column.SALE_DPST_WTHDR.DATA();
cDpstWthdr.SEQ = i;
cDpstWthdr.DPST_WTHDR_TYPE = aParam[0];
cDpstWthdr.DPST_WTHDR_CD = dr["DPST_WTHDR_CD"].ToString();
cDpstWthdr.DPST_WTHDR_AMT = m_cDataService.DoubleParse(dr["DPST_WTHDR_AMT"].ToString());
cDpstWthdr.DPST_WTHDR_NM = dr["DPST_WTHDR_NM"].ToString();
cDpstWthdr.DPST_WTHDR_QTY = m_cDataService.IntParse(dr["DPST_WTHDR_QTY"].ToString());
cDpstWthdr.CUST_NO = "";
cDpstWthdr.SLACK_FIELD_01 = "";
aDpstWthdr.Add(cDpstWthdr);
}
m_cTrnStatus.Head.TotSaleAmt = nTotalAmount;
// 거래 완료 처리
sRet = m_cSaleComplete.OpenCloseExecute(new string[] { });
if (sRet != UserCom.RST_OK) return sRet;
bool bIncTradeNo = m_cDataCommon.TradeNoAddCheck("");
m_cDataService.TranComplete();
m_cDataService.SetMsgNoInc(true, !bIncTradeNo, bIncTradeNo); // 거래번호 증가
}
catch (Exception ex)
{
WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
}
return sRet;
}
#endregion
#region
/// <summary>
/// 정산 출력 데이터 조회
/// </summary>
/// <param name="aParam"></param>
/// <returns></returns>
public DataTable GetData_ADMTPrint(string[] aParam)
{
string sSql = "";
try
{
sSql = "";
sSql += " SELECT \n";
sSql += " ISNULL(MBT.BILL_TYPE_DIV, '') BILL_TYPE_DIV \n";
sSql += " , ISNULL(MBT.SEQ_NO, 0) SEQ_NO \n";
sSql += " , ISNULL(MBT.SORT_DIV, '2') SORT_DIV \n";
sSql += " , ISNULL(MBT.SIZE_DIV, '0') SIZE_DIV \n";
sSql += " , CASE WHEN SUBSTRING(MBT.BILL_TYPE_TAG, 1, 6) = '<CODE>' THEN SUBSTRING(MBT.BILL_TYPE_TAG, 1, 6) ELSE ISNULL(MBT.BILL_TYPE_TAG, '') END BILL_TYPE_TAG \n";
sSql += " , ISNULL(MM.QTY, 0) QTY \n";
sSql += " , ISNULL(MM.AMT, 0) AMT \n";
sSql += " , ISNULL(MM.MSG1, '') MSG \n";
sSql += " FROM POSMST.dbo.MST_BILL_TYPE MBT \n";
sSql += " LEFT JOIN ( \n";
sSql += " SELECT \n";
sSql += " MM.CMP_CD \n";
sSql += " , MM.STOR_CD \n";
sSql += " , MM.ADMT_CD \n";
sSql += " , ISNULL(SUM(MM.QTY), 0) QTY \n";
sSql += " , ISNULL(SUM(MM.AMT), 0) AMT \n";
sSql += " , ISNULL(MM.MSG1, '') MSG1 \n";
sSql += " FROM ( \n";
sSql += " SELECT \n";
sSql += " MBT.CMP_CD \n";
sSql += " , MBT.STOR_CD \n";
sSql += " , ISNULL(SUBSTRING(MBT.BILL_TYPE_TAG, 7, 4) , '') ADMT_CD \n";
sSql += " , 0 QTY \n";
sSql += " , 0 AMT \n";
sSql += " , ISNULL(CMM.ENTRY_NM, '') MSG1 \n";
sSql += " , ISNULL(CMM.DISP_SEQ, 0) DISP_SEQ \n";
sSql += " FROM POSMST..MST_BILL_TYPE MBT \n";
sSql += " INNER JOIN POSMST..MST_CMM CMM \n";
sSql += " ON CMM.CMP_CD = MBT.CMP_CD \n";
sSql += " AND CMM.CMM_GRP_CD = '" + PosConst.COMMON_CODE_GROUP.Z0013 + "' \n";
//sSql += " AND ISNULL(CMM.CHAR_VAL_TITLE_VAL_01, '') LIKE '" + sSimplePrint + "' + '%' \n";
sSql += " AND CMM.CMM_CD = SUBSTRING(MBT.BILL_TYPE_TAG, 7, 4) \n";
sSql += " AND CMM.LANG_TYPE = '" + m_cPosStatus.Base.Country + "' \n";
sSql += " AND CMM.USE_YN = '1' \n";
sSql += " WHERE \n";
sSql += " MBT.CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n";
sSql += " AND MBT.STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n";
sSql += " AND MBT.BILL_TYPE_GRP_CD = '" + CmUtil.GetDataRowStr(PosMstManager.GetMstPos(), PosMst.MST_POS.DATA.BILL_TYPEGRP) + "' \n";
sSql += " AND MBT.BILL_TYPE_DIV = '" + PosConst.BILL_TYPE_DIV.ADMT_TRAN + "' \n";
sSql += " AND SUBSTRING(MBT.BILL_TYPE_TAG, 1, 6) = '<CODE>' \n";
sSql += " AND MBT.USE_YN = '1' \n";
sSql += " \n";
sSql += " UNION ALL \n";
sSql += " \n";
sSql += " SELECT \n";
sSql += " TSH.CMP_CD \n";
sSql += " , TSH.STOR_CD \n";
sSql += " , TSA.ADMT_CD ADMT_CD \n";
sSql += " , TSA.QTY \n";
sSql += " , TSA.AMT \n";
sSql += " , ISNULL(CMM.ENTRY_NM, '') MSG1 \n";
sSql += " , ISNULL(CMM.DISP_SEQ, 0) DISP_SEQ \n";
sSql += " FROM \n";
sSql += " POSLOG..TR_SALE_HEADER TSH \n";
sSql += " INNER JOIN POSLOG..TR_SALE_ADMT TSA \n";
sSql += " ON TSA.CMP_CD = TSH.CMP_CD \n";
sSql += " AND TSA.SALE_DT = TSH.SALE_DT \n";
sSql += " AND TSA.STOR_CD = TSH.STOR_CD \n";
sSql += " AND TSA.POS_NO = TSH.POS_NO \n";
sSql += " AND TSA.TRADE_NO = TSH.TRADE_NO \n";
sSql += " INNER JOIN POSMST..MST_POS MP \n";
sSql += " ON MP.CMP_CD = TSH.CMP_CD \n";
sSql += " AND MP.STOR_CD = TSH.STOR_CD \n";
sSql += " AND MP.POS_NO IN ('00', TSH.POS_NO) \n";
sSql += " AND MP.USE_YN = '1' \n";
sSql += " RIGHT JOIN POSMST..MST_BILL_TYPE MBT \n";
sSql += " ON MBT.CMP_CD = TSH.CMP_CD \n";
sSql += " AND MBT.STOR_CD = TSH.STOR_CD \n";
sSql += " AND MBT.BILL_TYPE_GRP_CD = MP.BILL_TYPEGRP \n";
sSql += " AND MBT.BILL_TYPE_DIV = '" + PosConst.BILL_TYPE_DIV.ADMT_TRAN + "' \n";
sSql += " AND SUBSTRING(MBT.BILL_TYPE_TAG, 1, 6) = '<CODE>' \n";
sSql += " AND SUBSTRING(MBT.BILL_TYPE_TAG, 7, 4) = TSA.ADMT_CD \n";
sSql += " AND MBT.USE_YN = '1' \n";
sSql += " LEFT JOIN POSMST..MST_CMM CMM \n";
sSql += " ON CMM.CMP_CD = MBT.CMP_CD \n";
sSql += " AND CMM.CMM_GRP_CD = '" + PosConst.COMMON_CODE_GROUP.Z0013 + "' \n";
//sSql += " AND ISNULL(CMM.CHAR_VAL_TITLE_VAL_01, '') LIKE '" + sSimplePrint + "' + '%' \n";
sSql += " AND CMM.CMM_CD = SUBSTRING(MBT.BILL_TYPE_TAG, 7, 4) \n";
sSql += " AND CMM.LANG_TYPE = '" + m_cPosStatus.Base.Country + "' \n";
sSql += " AND CMM.USE_YN = '1' \n";
sSql += " WHERE \n";
sSql += " TSH.CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n";
sSql += " AND TSH.SALE_DT = '" + m_cPosStatus.Base.SaleDate + "' \n";
sSql += " AND TSH.STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n";
sSql += " AND TSH.POS_NO = '" + m_cPosStatus.Base.PosNo + "' \n";
sSql += " AND TSH.TRADE_KINDPER IN ('" + ItemConst.TRAN_KIND.STATEMENT.MIDDLE_ADJUSTMENT + "', '" + ItemConst.TRAN_KIND.STATEMENT.ADJUSTMENT + "') \n";
sSql += " AND TSH.TRADE_NO = (SELECT MAX(TSH1.TRADE_NO) \n";
sSql += " FROM POSLOG..TR_SALE_HEADER TSH1 \n";
sSql += " WHERE \n";
sSql += " TSH1.CMP_CD = TSH.CMP_CD \n";
sSql += " AND TSH1.SALE_DT = TSH.SALE_DT \n";
sSql += " AND TSH1.STOR_CD = TSH.STOR_CD \n";
sSql += " AND TSH1.POS_NO = TSH.POS_NO \n";
sSql += " AND TSH1.TRADE_DIV = '0' \n";
sSql += " AND TSH1.TRAIN_MODE_YN = '0' \n";
sSql += " AND TSH1.TRADE_KINDPER IN ('" + ItemConst.TRAN_KIND.STATEMENT.MIDDLE_ADJUSTMENT + "', '" + ItemConst.TRAN_KIND.STATEMENT.ADJUSTMENT + "')) \n";
sSql += " ) MM \n";
sSql += " GROUP BY MM.CMP_CD, MM.STOR_CD, MM.ADMT_CD, ISNULL(MM.MSG1, '') \n";
sSql += " ) MM \n";
sSql += " ON MBT.CMP_CD = MM.CMP_CD \n";
sSql += " AND MBT.STOR_CD = MM.STOR_CD \n";
sSql += " AND SUBSTRING(MBT.BILL_TYPE_TAG, 7, 4) = MM.ADMT_CD \n";
sSql += " WHERE \n";
sSql += " MBT.CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n";
sSql += " AND MBT.STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n";
sSql += " AND MBT.BILL_TYPE_GRP_CD = '" + CmUtil.GetDataRowStr(PosMstManager.GetMstPos(), PosMst.MST_POS.DATA.BILL_TYPEGRP) + "' \n";
sSql += " AND MBT.BILL_TYPE_DIV = '" + PosConst.BILL_TYPE_DIV.ADMT_TRAN + "' \n";
sSql += " AND MBT.USE_YN = '1' \n";
sSql += " ORDER BY 1, 2 \n";
sSql = sSql.Replace("\t", " ");
DataTable dtDataInfo = m_cMstService.Select(new string[] { sSql });
return dtDataInfo;
}
catch (Exception ex)
{
WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
}
return null;
}
#endregion
#region /
/// <summary>
/// 상품별/분류별 판매 이력 조회
/// </summary>
/// <param name="aParam"></param>
/// <returns></returns>
public DataTable SelectiTemClass(string[] aParam)
{
string sSql = "";
try
{
// 중간정산 옵션값변경(2017.06.14) => 중간점검 사용 여부 (0:사용안함, 1: 사용함, 2:사용함[차수별])
string sMidCloseSeq = m_cPosStatus.Base.MidCloseSeq;
if (sMidCloseSeq != "99" && PosMstManager.GetPosOption(POS_OPTION.OPT321) != "2") sMidCloseSeq = "";
if (aParam[0] == "<ITEM>")
{
// 품목별 정산 내역 조회
sSql += "SELECT MM.* \n";
sSql += "FROM ( \n";
sSql += "SELECT \n";
sSql += " '#SUM#' ITEM_NM \n";
sSql += " , ISNULL(SUM(CASE TSH.TRADE_DIV WHEN '0' THEN ISNULL(TSD.SALE_QTY, 0) \n";
sSql += " ELSE ISNULL(TSD.SALE_QTY, 0) * (-1) \n";
sSql += " END), 0) SALE_QTY \n";
sSql += " , ISNULL(SUM(CASE TSH.TRADE_DIV WHEN '0' THEN ISNULL(TSD.SALE_AMT, 0) \n";
sSql += " ELSE ISNULL(TSD.SALE_AMT, 0) * (-1) \n";
sSql += " END), 0) SALE_AMT \n";
sSql += " , '' ITEM_PLU_CD \n";
sSql += " , '1' DISP_SEQ \n";
sSql += "FROM POSLOG..TR_SALE_HEADER TSH \n";
sSql += " LEFT JOIN POSLOG..TR_SALE_DETAIL TSD \n";
sSql += " ON TSD.CMP_CD = TSH.CMP_CD \n";
sSql += " AND TSD.SALE_DT = TSH.SALE_DT \n";
sSql += " AND TSD.STOR_CD = TSH.STOR_CD \n";
sSql += " AND TSD.POS_NO = TSH.POS_NO \n";
sSql += " AND TSD.TRADE_NO = TSH.TRADE_NO \n";
sSql += " AND TSD.CANCEL_DIV = '0' \n";
sSql += " LEFT JOIN POSMST..MST_ITEM MI \n";
sSql += " ON TSD.CMP_CD = MI.CMP_CD \n";
sSql += " AND TSD.STOR_CD = MI.STOR_CD \n";
sSql += " AND TSD.SUB_SHOP_CD = MI.SUB_STOR_CD \n";
sSql += " AND TSD.ITEM_PLU_CD = MI.ITEM_CD \n";
sSql += "WHERE \n";
sSql += " TSH.CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n";
sSql += "AND TSH.SALE_DT = '" + m_cPosStatus.Base.SaleDate + "' \n";
sSql += "AND TSH.STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n";
sSql += "AND TSH.POS_NO = '" + m_cPosStatus.Base.PosNo + "' \n";
sSql += "AND TSH.TRAIN_MODE_YN = '0' \n";
sSql += "AND ISNULL(TSH.MID_CLOSE_SEQ, '') LIKE '" + sMidCloseSeq + "' + '%' \n";
//sSql += "AND ISNULL(TSH.MID_CLOSE_SEQ, '') LIKE '" + m_cPosStatus.Base.MidCloseSeq + "' + '%' \n";
sSql += "AND TSH.TRADE_KINDPER IN ('00', '10', '11', '20', '21', '42', '43') \n";
sSql += "AND TSD.ITEM_PLU_CD IS NOT NULL\n";
//#17283 PB 한화에코 - 중간 마감 정산지 출력 시 상품별 집계 상단에 항목 공백으로 표기되는 증상 start
//부가상품(속성) 안보이도록 수정
sSql += "AND TSD.SUBPRC_MENU_KEY_DIV <> '1'\n";
//#17283 PB 한화에코 - 중간 마감 정산지 출력 시 상품별 집계 상단에 항목 공백으로 표기되는 증상 end
sSql += "UNION ALL \n";
sSql += "SELECT \n";
sSql += " ISNULL(MI.SHTCUT_ITEMNM, '') ITEM_NM \n";
sSql += " , ISNULL(SUM(CASE TSH.TRADE_DIV WHEN '0' THEN ISNULL(TSD.SALE_QTY, 0) \n";
sSql += " ELSE ISNULL(TSD.SALE_QTY, 0) * (-1) \n";
sSql += " END), 0) SALE_QTY \n";
sSql += " , ISNULL(SUM(CASE TSH.TRADE_DIV WHEN '0' THEN ISNULL(TSD.SALE_AMT, 0) \n";
sSql += " ELSE ISNULL(TSD.SALE_AMT, 0) * (-1) \n";
sSql += " END), 0) SALE_AMT \n";
sSql += " , TSD.ITEM_PLU_CD \n";
sSql += " , '0' DISP_SEQ \n";
sSql += "FROM POSLOG..TR_SALE_HEADER TSH \n";
sSql += " LEFT JOIN POSLOG..TR_SALE_DETAIL TSD \n";
sSql += " ON TSD.CMP_CD = TSH.CMP_CD \n";
sSql += " AND TSD.SALE_DT = TSH.SALE_DT \n";
sSql += " AND TSD.STOR_CD = TSH.STOR_CD \n";
sSql += " AND TSD.POS_NO = TSH.POS_NO \n";
sSql += " AND TSD.TRADE_NO = TSH.TRADE_NO \n";
sSql += " AND TSD.CANCEL_DIV = '0' \n";
sSql += " LEFT JOIN POSMST..MST_ITEM MI \n";
sSql += " ON TSD.CMP_CD = MI.CMP_CD \n";
sSql += " AND TSD.STOR_CD = MI.STOR_CD \n";
sSql += " AND TSD.SUB_SHOP_CD = MI.SUB_STOR_CD \n";
sSql += " AND TSD.ITEM_PLU_CD = MI.ITEM_CD \n";
sSql += "WHERE \n";
sSql += " TSH.CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n";
sSql += "AND TSH.SALE_DT = '" + m_cPosStatus.Base.SaleDate + "' \n";
sSql += "AND TSH.STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n";
sSql += "AND TSH.POS_NO = '" + m_cPosStatus.Base.PosNo + "' \n";
sSql += "AND TSH.TRAIN_MODE_YN = '0' \n";
sSql += "AND ISNULL(TSH.MID_CLOSE_SEQ, '') LIKE '" + sMidCloseSeq + "' + '%' \n";
//sSql += "AND ISNULL(TSH.MID_CLOSE_SEQ, '') LIKE '" + m_cPosStatus.Base.MidCloseSeq + "' + '%' \n";
sSql += "AND TSH.TRADE_KINDPER IN ('00', '10', '11', '20', '21', '42', '43') \n";
sSql += "AND TSD.ITEM_PLU_CD IS NOT NULL\n";
//#17283 PB 한화에코 - 중간 마감 정산지 출력 시 상품별 집계 상단에 항목 공백으로 표기되는 증상 start
//부가상품(속성) 안보이도록 수정
sSql += "AND TSD.SUBPRC_MENU_KEY_DIV <> '1'\n";
//#17283 PB 한화에코 - 중간 마감 정산지 출력 시 상품별 집계 상단에 항목 공백으로 표기되는 증상 end
sSql += "GROUP BY TSD.ITEM_PLU_CD, MI.SHTCUT_ITEMNM \n";
sSql += ") MM \n";
sSql += "WHERE ISNULL(MM.SALE_QTY, 0) > 0 \n";
sSql += "ORDER BY MM.DISP_SEQ, MM.ITEM_NM \n";
}
else if (aParam[0] == "<CLASS>")
{
// #20170915 분류별 정산 내역 추가 start, phj
//변경
/*
// 분류별 정산 내역 조회
sSql += "SELECT MM.* \n";
sSql += "FROM ( \n";
sSql += "SELECT \n";
sSql += " '#SUM#' ITEM_NM \n";
sSql += " , ISNULL(SUM(CASE TSH.TRADE_DIV WHEN '0' THEN ISNULL(TSD.SALE_QTY, 0) \n";
sSql += " ELSE ISNULL(TSD.SALE_QTY, 0) * (-1) \n";
sSql += " END), 0) SALE_QTY \n";
sSql += " , ISNULL(SUM(CASE TSH.TRADE_DIV WHEN '0' THEN ISNULL(TSD.SALE_AMT, 0) \n";
sSql += " ELSE ISNULL(TSD.SALE_AMT, 0) * (-1) \n";
sSql += " END), 0) SALE_AMT \n";
sSql += " , '' ITEM_CLSS_CD \n";
sSql += " , '1' DISP_SEQ \n";
sSql += "FROM POSLOG..TR_SALE_HEADER TSH \n";
sSql += " LEFT JOIN POSLOG..TR_SALE_DETAIL TSD \n";
sSql += " ON TSD.CMP_CD = TSH.CMP_CD \n";
sSql += " AND TSD.SALE_DT = TSH.SALE_DT \n";
sSql += " AND TSD.STOR_CD = TSH.STOR_CD \n";
sSql += " AND TSD.POS_NO = TSH.POS_NO \n";
sSql += " AND TSD.TRADE_NO = TSH.TRADE_NO \n";
sSql += " AND TSD.CANCEL_DIV = '0' \n";
sSql += " LEFT JOIN POSMST..MST_ITEM MI \n";
sSql += " ON TSD.CMP_CD = MI.CMP_CD \n";
sSql += " AND TSD.STOR_CD = MI.STOR_CD \n";
sSql += " AND TSD.SUB_SHOP_CD = MI.SUB_STOR_CD \n";
sSql += " AND TSD.ITEM_PLU_CD = MI.ITEM_CD \n";
sSql += " LEFT JOIN POSMST..MST_ITEM_CLSS MIC \n";
sSql += " ON MIC.CMP_CD = MI.CMP_CD \n";
sSql += " AND MIC.ITEM_CLSS_TYPE_CD = '00' \n";
sSql += " AND MIC.ITEM_CLSS_CD = MI.S_CLSS \n";
sSql += " AND MIC.ITEM_CLSS_LVL_TYPE = 'S' \n";
sSql += " AND MIC.USE_YN = '" + PosConst.MST_USE_YN.YES + "' \n";
sSql += "WHERE \n";
sSql += " TSH.CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n";
sSql += "AND TSH.SALE_DT = '" + m_cPosStatus.Base.SaleDate + "' \n";
sSql += "AND TSH.STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n";
sSql += "AND TSH.POS_NO = '" + m_cPosStatus.Base.PosNo + "' \n";
sSql += "AND TSH.TRAIN_MODE_YN = '0' \n";
sSql += "AND ISNULL(TSH.MID_CLOSE_SEQ, '') LIKE '" + sMidCloseSeq + "' + '%' \n";
//sSql += "AND ISNULL(TSH.MID_CLOSE_SEQ, '') LIKE '" + m_cPosStatus.Base.MidCloseSeq + "' + '%' \n";
sSql += "AND TSH.TRADE_KINDPER IN ('00', '10', '11', '20', '21', '42', '43') \n";
sSql += "AND TSD.ITEM_PLU_CD IS NOT NULL\n";
sSql += "UNION ALL \n";
sSql += "SELECT \n";
sSql += " ISNULL(MIC.ITEM_CLSS_NM, 'Non Registered') ITEM_NM \n";
sSql += " , ISNULL(SUM(CASE TSH.TRADE_DIV WHEN '0' THEN ISNULL(TSD.SALE_QTY, 0) \n";
sSql += " ELSE ISNULL(TSD.SALE_QTY, 0) * (-1) \n";
sSql += " END), 0) SALE_QTY \n";
sSql += " , ISNULL(SUM(CASE TSH.TRADE_DIV WHEN '0' THEN ISNULL(TSD.SALE_AMT, 0) \n";
sSql += " ELSE ISNULL(TSD.SALE_AMT, 0) * (-1) \n";
sSql += " END), 0) SALE_AMT \n";
sSql += " , MIC.ITEM_CLSS_CD \n";
sSql += " , '0' DISP_SEQ \n";
sSql += "FROM POSLOG..TR_SALE_HEADER TSH \n";
sSql += " LEFT JOIN POSLOG..TR_SALE_DETAIL TSD \n";
sSql += " ON TSD.CMP_CD = TSH.CMP_CD \n";
sSql += " AND TSD.SALE_DT = TSH.SALE_DT \n";
sSql += " AND TSD.STOR_CD = TSH.STOR_CD \n";
sSql += " AND TSD.POS_NO = TSH.POS_NO \n";
sSql += " AND TSD.TRADE_NO = TSH.TRADE_NO \n";
sSql += " AND TSD.CANCEL_DIV = '0' \n";
sSql += " LEFT JOIN POSMST..MST_ITEM MI \n";
sSql += " ON TSD.CMP_CD = MI.CMP_CD \n";
sSql += " AND TSD.STOR_CD = MI.STOR_CD \n";
sSql += " AND TSD.SUB_SHOP_CD = MI.SUB_STOR_CD \n";
sSql += " AND TSD.ITEM_PLU_CD = MI.ITEM_CD \n";
sSql += " LEFT JOIN POSMST..MST_ITEM_CLSS MIC \n";
sSql += " ON MIC.CMP_CD = MI.CMP_CD \n";
sSql += " AND MIC.ITEM_CLSS_TYPE_CD = '00' \n";
sSql += " AND MIC.ITEM_CLSS_CD = MI.S_CLSS \n";
sSql += " AND MIC.ITEM_CLSS_LVL_TYPE = 'S' \n";
sSql += " AND MIC.USE_YN = '" + PosConst.MST_USE_YN.YES + "' \n";
sSql += "WHERE \n";
sSql += " TSH.CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n";
sSql += "AND TSH.SALE_DT = '" + m_cPosStatus.Base.SaleDate + "' \n";
sSql += "AND TSH.STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n";
sSql += "AND TSH.POS_NO = '" + m_cPosStatus.Base.PosNo + "' \n";
sSql += "AND TSH.TRAIN_MODE_YN = '0' \n";
sSql += "AND ISNULL(TSH.MID_CLOSE_SEQ, '') LIKE '" + sMidCloseSeq + "' + '%' \n";
//sSql += "AND ISNULL(TSH.MID_CLOSE_SEQ, '') LIKE '" + m_cPosStatus.Base.MidCloseSeq + "' + '%' \n";
sSql += "AND TSH.TRADE_KINDPER IN ('00', '10', '11', '20', '21', '42', '43') \n";
sSql += "AND TSD.ITEM_PLU_CD IS NOT NULL\n";
sSql += "GROUP BY MIC.ITEM_CLSS_CD, MIC.ITEM_CLSS_NM \n";
sSql += ") MM \n";
sSql += "WHERE ISNULL(MM.SALE_QTY, 0) > 0 \n";
sSql += "ORDER BY MM.DISP_SEQ, MM.ITEM_CLSS_CD \n";
*/
//변경
sSql += "SELECT GROUPING(MM.ITEM_CLSS_CD) + GROUPING(MM.ITEM_NM) AS LEVEL_GB, \n";
sSql += " MM.ITEM_CLSS_CD, \n";
sSql += " CASE GROUPING(MM.ITEM_CLSS_CD) + GROUPING(MM.ITEM_NM) WHEN 2 THEN '#SUM#' \n";
sSql += " ELSE MM.ITEM_NM \n";
sSql += " END AS ITEM_NM, \n";
sSql += " SUM(MM.BILL_AMT) BILL_AMT, \n";
sSql += " SUM(MM.SALE_AMT) SALE_AMT, \n";
sSql += " SUM(MM.SALE_QTY) SALE_QTY \n";
sSql += " FROM \n";
sSql += "( \n";
sSql += "SELECT \n";
sSql += " ISNULL(MIC.ITEM_CLSS_NM, 'Non Registered') AS ITEM_NM, \n";
sSql += " CASE TSH.TRADE_DIV WHEN '0' THEN ISNULL(TSD.SALE_QTY, 0) \n";
sSql += " ELSE ISNULL(TSD.SALE_QTY, 0) * (-1) \n";
sSql += " END AS SALE_QTY, \n";
sSql += " CASE TSH.TRADE_DIV WHEN '0' THEN ISNULL(TSD.SALE_AMT, 0) \n";
sSql += "ELSE ISNULL(TSD.SALE_AMT, 0) * (-1) \n";
sSql += " END AS SALE_AMT, \n";
sSql += " CASE TSH.TRADE_DIV WHEN '0' THEN ISNULL(TSD.BILL_AMT, 0) \n";
sSql += " ELSE ISNULL(TSD.BILL_AMT, 0) * (-1) \n";
sSql += " END AS BILL_AMT, \n";
sSql += " MIC.ITEM_CLSS_CD, \n";
sSql += " '0' DISP_SEQ \n";
sSql += " FROM POSLOG..TR_SALE_HEADER TSH \n";
sSql += " LEFT JOIN POSLOG..TR_SALE_DETAIL TSD \n";
sSql += " ON TSD.CMP_CD = TSH.CMP_CD \n";
sSql += " AND TSD.SALE_DT = TSH.SALE_DT \n";
sSql += " AND TSD.STOR_CD = TSH.STOR_CD \n";
sSql += " AND TSD.POS_NO = TSH.POS_NO \n";
sSql += " AND TSD.TRADE_NO = TSH.TRADE_NO \n";
sSql += " AND TSD.CANCEL_DIV = '0' \n";
sSql += " AND TSD.ITEM_DIV = '0' \n";
sSql += " LEFT JOIN POSMST..MST_ITEM MI \n";
sSql += " ON TSD.CMP_CD = MI.CMP_CD \n";
sSql += " AND TSD.STOR_CD = MI.STOR_CD \n";
sSql += " AND TSD.SUB_SHOP_CD = MI.SUB_STOR_CD \n";
sSql += " AND TSD.ITEM_PLU_CD = MI.ITEM_CD \n";
sSql += " LEFT JOIN POSMST..MST_ITEM_CLSS MIC \n";
sSql += " ON MIC.CMP_CD = MI.CMP_CD \n";
sSql += " AND MIC.ITEM_CLSS_TYPE_CD = '00' \n";
sSql += " AND MIC.ITEM_CLSS_CD = substring(MI.L_CLSS,1,3) + '0000' \n";
sSql += " AND MIC.ITEM_CLSS_LVL_TYPE = 'L' \n";
sSql += " AND MIC.USE_YN = '" + PosConst.MST_USE_YN.YES + "' \n";
sSql += "WHERE TSH.CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n";
sSql += " AND TSH.SALE_DT = '" + m_cPosStatus.Base.SaleDate + "' \n";
//일마감이 아니면
if (m_cPosStatus.Base.MidCloseSeq != "99")
{
//1: 누적집계, 2: 차수집계
if (PosMstManager.GetPosOption(POS_OPTION.OPT321) == "2")
{
sSql += " AND ISNULL(TSH.MID_CLOSE_SEQ, '') LIKE '" + m_cPosStatus.Base.MidCloseSeq + "' + '%' \n";
}
}
sSql += " AND TSH.STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n";
sSql += " AND TSH.POS_NO = '" + m_cPosStatus.Base.PosNo + "' \n";
sSql += " AND TSH.TRAIN_MODE_YN = '0' \n";
sSql += " AND TSH.TRADE_KINDPER IN ('00', '10', '11', '20', '21', '42', '43') \n";
sSql += " AND TSD.ITEM_PLU_CD IS NOT NULL \n";
sSql += " ) MM \n";
sSql += "GROUP BY MM.ITEM_CLSS_CD, MM.ITEM_NM WITH ROLLUP \n";
sSql += "HAVING ((GROUPING(MM.ITEM_CLSS_CD) + GROUPING(MM.ITEM_NM) IN (0,2)) \n";
// #20170915 분류별 정산 내역 추가 start, 20180103
//수량이 0이 아닌 경우를 체크해서 정상, 반품 수량이 동일하지만 금액이 다른 경우 집계되지 않는 현상 수정
//기존
//sSql += "AND SUM(MM.SALE_QTY) <> 0) \n";
//변경
sSql += "AND SUM(MM.SALE_AMT) <> 0) \n";
// #20170915 분류별 정산 내역 추가 end, 20180103
sSql += "ORDER BY 1,2 \n";
// #20170915 분류별 정산 내역 추가 end
}
else if (aParam[0] == "<TENDER>")
{
// 결제 내역 조회
sSql += "SELECT MM.* \n";
sSql += "FROM ( \n";
sSql += "SELECT '' PAY_WAY_CD, '' PAY_DTL_CD_01, \n";
sSql += " '#SUM#' ITEM_NM \n";
sSql += " , ISNULL(SUM(CASE TSH.TRADE_DIV WHEN '0' THEN 1 \n";
sSql += " ELSE (-1) \n";
sSql += " END), 0) SALE_QTY \n";
sSql += " , ISNULL(SUM(CASE TSH.TRADE_DIV WHEN '0' THEN CASE TSP.PAY_WAY_CD WHEN '06' THEN ISNULL(TSP.AMT_ENTRY_01, 0) ELSE ISNULL(TSP.PAY_AMT, 0) END \n";
sSql += " ELSE CASE TSP.PAY_WAY_CD WHEN '06' THEN ISNULL(TSP.AMT_ENTRY_01, 0) * (-1) ELSE ISNULL(TSP.PAY_AMT, 0) * (-1) END \n";
sSql += " END), 0) SALE_AMT \n";
sSql += " , '1' DISP_SEQ \n";
sSql += "FROM POSLOG..TR_SALE_HEADER TSH \n";
sSql += " LEFT JOIN POSLOG..TR_SALE_PAY TSP \n";
sSql += " ON TSP.CMP_CD = TSH.CMP_CD \n";
sSql += " AND TSP.SALE_DT = TSH.SALE_DT \n";
sSql += " AND TSP.STOR_CD = TSH.STOR_CD \n";
sSql += " AND TSP.POS_NO = TSH.POS_NO \n";
sSql += " AND TSP.TRADE_NO = TSH.TRADE_NO \n";
sSql += " AND TSP.CANCEL_DIV = '0' \n";
sSql += " LEFT JOIN POSMST..MST_PAY_DC MPD \n";
sSql += " ON TSP.CMP_CD = MPD.CMP_CD \n";
sSql += " AND TSP.STOR_CD = MPD.STOR_CD \n";
sSql += " AND TSP.PAY_WAY_CD = MPD.PAY_DC_GRP_TYPE \n";
sSql += " AND TSP.PAY_DTL_CD_01 = MPD.PAY_DC_CD \n";
sSql += " AND MPD.USE_YN = '" + PosConst.MST_USE_YN.YES + "' \n";
sSql += "WHERE \n";
sSql += " TSH.CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n";
sSql += "AND TSH.SALE_DT = '" + m_cPosStatus.Base.SaleDate + "' \n";
sSql += "AND TSH.STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n";
sSql += "AND TSH.POS_NO = '" + m_cPosStatus.Base.PosNo + "' \n";
sSql += "AND TSH.TRAIN_MODE_YN = '0' \n";
sSql += "AND ISNULL(TSH.MID_CLOSE_SEQ, '') LIKE '" + sMidCloseSeq + "' + '%' \n";
//sSql += "AND ISNULL(TSH.MID_CLOSE_SEQ, '') LIKE '" + m_cPosStatus.Base.MidCloseSeq + "' + '%' \n";
sSql += "AND TSH.TRADE_KINDPER IN ('00', '10', '11', '20', '21', '42', '43') \n";
sSql += "AND TSP.PAY_WAY_CD IS NOT NULL \n";
sSql += "UNION ALL \n";
sSql += "SELECT TSP.PAY_WAY_CD, TSP.PAY_DTL_CD_01, \n";
sSql += " ISNULL(MPD.PAY_DC_NM, '') ITEM_NM \n";
sSql += " , ISNULL(SUM(CASE TSH.TRADE_DIV WHEN '0' THEN 1 \n";
sSql += " ELSE (-1) \n";
sSql += " END), 0) SALE_QTY \n";
sSql += " , ISNULL(SUM(CASE TSH.TRADE_DIV WHEN '0' THEN CASE TSP.PAY_WAY_CD WHEN '06' THEN ISNULL(TSP.AMT_ENTRY_01, 0) ELSE ISNULL(TSP.PAY_AMT, 0) END \n";
sSql += " ELSE CASE TSP.PAY_WAY_CD WHEN '06' THEN ISNULL(TSP.AMT_ENTRY_01, 0) * (-1) ELSE ISNULL(TSP.PAY_AMT, 0) * (-1) END \n";
sSql += " END), 0) SALE_AMT \n";
sSql += " , '0' DISP_SEQ \n";
sSql += "FROM POSLOG..TR_SALE_HEADER TSH \n";
sSql += " LEFT JOIN POSLOG..TR_SALE_PAY TSP \n";
sSql += " ON TSP.CMP_CD = TSH.CMP_CD \n";
sSql += " AND TSP.SALE_DT = TSH.SALE_DT \n";
sSql += " AND TSP.STOR_CD = TSH.STOR_CD \n";
sSql += " AND TSP.POS_NO = TSH.POS_NO \n";
sSql += " AND TSP.TRADE_NO = TSH.TRADE_NO \n";
sSql += " AND TSP.CANCEL_DIV = '0' \n";
sSql += " LEFT JOIN POSMST..MST_PAY_DC MPD \n";
sSql += " ON TSP.CMP_CD = MPD.CMP_CD \n";
sSql += " AND TSP.STOR_CD = MPD.STOR_CD \n";
sSql += " AND TSP.PAY_WAY_CD = MPD.PAY_DC_GRP_TYPE \n";
sSql += " AND TSP.PAY_DTL_CD_01 = MPD.PAY_DC_CD \n";
sSql += " AND MPD.USE_YN = '" + PosConst.MST_USE_YN.YES + "' \n";
sSql += "WHERE \n";
sSql += " TSH.CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n";
sSql += "AND TSH.SALE_DT = '" + m_cPosStatus.Base.SaleDate + "' \n";
sSql += "AND TSH.STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n";
sSql += "AND TSH.POS_NO = '" + m_cPosStatus.Base.PosNo + "' \n";
sSql += "AND TSH.TRAIN_MODE_YN = '0' \n";
sSql += "AND ISNULL(TSH.MID_CLOSE_SEQ, '') LIKE '" + sMidCloseSeq + "' + '%' \n";
//sSql += "AND ISNULL(TSH.MID_CLOSE_SEQ, '') LIKE '" + m_cPosStatus.Base.MidCloseSeq + "' + '%' \n";
sSql += "AND TSH.TRADE_KINDPER IN ('00', '10', '11', '20', '21', '42', '43') \n";
sSql += "AND TSP.PAY_WAY_CD IS NOT NULL \n";
sSql += "GROUP BY TSP.PAY_WAY_CD, TSP.PAY_DTL_CD_01, MPD.PAY_DC_NM \n";
sSql += ") MM \n";
sSql += "WHERE ISNULL(MM.SALE_AMT, 0) > 0 \n";
sSql += "ORDER BY MM.DISP_SEQ, MM.PAY_WAY_CD, MM.PAY_DTL_CD_01 \n";
}
else if (aParam[0] == "<CASHREFUND>") // 현금반품 내역 추가 20170830 goblin6
{
// 현금반품 내역 조회
sSql += "SELECT \n";
sSql += " TSH.TRADE_NO ITEM_NM \n";
sSql += " , ISNULL(SUBSTRING(TSH.PAY_TIME, 1, 2) + ':' + SUBSTRING(TSH.PAY_TIME, 3, 2) + ':' + SUBSTRING(TSH.PAY_TIME, 5, 2), '') SALE_QTY \n";
sSql += " , ISNULL(SUM(CASE TSH.TRADE_DIV WHEN '0' THEN 0 \n";
sSql += " ELSE \n";
sSql += " CASE TSP.PAY_WAY_CD WHEN '00' THEN ISNULL(TSP.PAY_AMT, 0) * (-1) \n";
sSql += " WHEN '01' THEN ISNULL(TSP.PAY_AMT, 0) * (-1) \n";
sSql += " WHEN '09' THEN ISNULL(TSP.AMT_ENTRY_06, 0) \n";
sSql += " ELSE ISNULL(TSP.AMT_ENTRY_02, 0) END \n";
sSql += " END), 0) SALE_AMT \n";
sSql += "FROM POSLOG..TR_SALE_HEADER TSH \n";
sSql += " RIGHT JOIN POSLOG..TR_SALE_PAY TSP \n";
sSql += " ON TSP.CMP_CD = TSH.CMP_CD \n";
sSql += " AND TSP.SALE_DT = TSH.SALE_DT \n";
sSql += " AND TSP.STOR_CD = TSH.STOR_CD \n";
sSql += " AND TSP.POS_NO = TSH.POS_NO \n";
sSql += " AND TSP.TRADE_NO = TSH.TRADE_NO \n";
sSql += " AND TSP.PAY_WAY_CD IN ('00', '01', '17') \n";
sSql += " AND TSP.CANCEL_DIV = '0' \n";
sSql += " AND TSP.PAY_AMT <> 0 \n";
sSql += " LEFT JOIN POSLOG..TR_SALE_ETC TSE \n";
sSql += " ON TSE.CMP_CD = TSH.CMP_CD \n";
sSql += " AND TSE.SALE_DT = TSH.SALE_DT \n";
sSql += " AND TSE.STOR_CD = TSH.STOR_CD \n";
sSql += " AND TSE.POS_NO = TSH.POS_NO \n";
sSql += " AND TSE.TRADE_NO = TSH.TRADE_NO \n";
sSql += " AND TSE.ETC_WAY_CD = '80' \n";
sSql += " AND TSE.ETC_DTL_CD_01 = '01' \n";
sSql += " LEFT JOIN POSLOG..TR_SALE_PAY TSP2 \n";
sSql += " ON TSP2.CMP_CD = TSH.CMP_CD \n";
sSql += " AND TSP2.SALE_DT = TSH.SALE_DT \n";
sSql += " AND TSP2.STOR_CD = TSH.STOR_CD \n";
sSql += " AND TSP2.POS_NO = TSH.POS_NO \n";
sSql += " AND TSP2.TRADE_NO = TSH.TRADE_NO \n";
sSql += " AND TSP2.PAY_WAY_CD NOT IN ('00', '01', '17') \n";
sSql += " AND TSP2.CANCEL_DIV = '0' \n";
sSql += " AND TSP2.PAY_AMT <> 0 \n";
sSql += "WHERE \n";
sSql += " TSH.CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n";
sSql += "AND TSH.SALE_DT = '" + m_cPosStatus.Base.SaleDate + "' \n";
sSql += "AND TSH.STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n";
sSql += "AND TSH.POS_NO = '" + m_cPosStatus.Base.PosNo + "' \n";
sSql += "AND TSH.TRAIN_MODE_YN = '0' \n";
sSql += "AND TSH.TRADE_DIV = '1' \n";
//sSql += "AND ISNULL(TSH.MID_CLOSE_SEQ, '') LIKE '" + sMidCloseSeq + "' + '%' \n";
sSql += "AND TSH.TRADE_KINDPER IN ('00','10', '11', '20', '21', '42', '43') \n"; //-- 일반거래, 미결거래, 대외거래, 선불판매, 상품권판매
sSql += "AND TSE.SALE_DT IS NULL \n";
sSql += "AND TSP2.SALE_DT IS NULL \n";
sSql += "GROUP BY \n";
sSql += " TSH.CMP_CD, TSH.SALE_DT, TSH.STOR_CD, TSH.POS_NO, TSH.TRADE_NO, TSH.PAY_TIME \n";
}
sSql = sSql.Replace("\t", " ");
DataTable dtDataInfo = m_cMstService.Select(new string[] { sSql });
return dtDataInfo;
}
catch (Exception ex)
{
WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
}
return null;
}
#endregion
#region /
/// <summary>
/// 중간/마감입금 조회
/// </summary>
/// <param name="aParam"></param>
/// <returns></returns>
public DataTable GetData_PayList(string[] aParam)
{
string sSql = "";
try
{
sSql = "";
sSql += "SELECT \n";
sSql += " ISNULL(CMM.ENTRY_NM, '') CD_NM \n";
sSql += " , ISNULL(TSA.QTY, 0) QTY \n";
sSql += " , ISNULL(TSA.AMT, 0) AMT \n";
sSql += " , CMM.CMM_CD \n";
sSql += " , ISNULL(CMM.CHAR_VAL_TITLE_VAL_01, '0') CHAR_VAL_TITLE_VAL_01 \n";
sSql += " , ISNULL(CMM.CHAR_VAL_TITLE_VAL_02, '0') CHAR_VAL_TITLE_VAL_02 \n";
sSql += " , ISNULL(CMM.CHAR_VAL_TITLE_VAL_03, '0') CHAR_VAL_TITLE_VAL_03 \n";
sSql += " , ISNULL(CMM.CHAR_VAL_TITLE_VAL_04, '0') CHAR_VAL_TITLE_VAL_04 \n";
sSql += "FROM POSMST..MST_CMM CMM \n";
sSql += " LEFT JOIN POSLOG..TR_SALE_HEADER TSH \n";
sSql += " ON TSH.CMP_CD = CMM.CMP_CD \n";
sSql += " AND TSH.SALE_DT = '" + m_cPosStatus.Base.SaleDate + "' \n";
sSql += " AND TSH.STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n";
sSql += " AND TSH.POS_NO = '" + m_cPosStatus.Base.PosNo + "' \n";
sSql += " AND TSH.TRADE_KINDPER IN ('" + ItemConst.TRAN_KIND.STATEMENT.MIDDLE_ADJUSTMENT + "', '" + ItemConst.TRAN_KIND.STATEMENT.ADJUSTMENT + "') \n";
sSql += " AND TSH.TRADE_NO = (SELECT MAX(TSH1.TRADE_NO) \n";
sSql += " FROM POSLOG..TR_SALE_HEADER TSH1 \n";
sSql += " WHERE \n";
sSql += " TSH1.CMP_CD = TSH.CMP_CD \n";
sSql += " AND TSH1.SALE_DT = TSH.SALE_DT \n";
sSql += " AND TSH1.STOR_CD = TSH.STOR_CD \n";
sSql += " AND TSH1.POS_NO = TSH.POS_NO \n";
sSql += " AND TSH1.TRADE_DIV = '0' \n";
sSql += " AND TSH1.TRAIN_MODE_YN = '0' \n";
sSql += " AND TSH1.TRADE_KINDPER IN ('" + ItemConst.TRAN_KIND.STATEMENT.MIDDLE_ADJUSTMENT + "', '" + ItemConst.TRAN_KIND.STATEMENT.ADJUSTMENT + "')) \n";
sSql += " LEFT JOIN POSLOG..TR_SALE_ADMT TSA \n";
sSql += " ON TSA.CMP_CD = TSH.CMP_CD \n";
sSql += " AND TSA.SALE_DT = TSH.SALE_DT \n";
sSql += " AND TSA.STOR_CD = TSH.STOR_CD \n";
sSql += " AND TSA.POS_NO = TSH.POS_NO \n";
sSql += " AND TSA.TRADE_NO = TSH.TRADE_NO \n";
sSql += " AND CONVERT(NUMERIC(4), TSA.ADMT_CD) = CONVERT(NUMERIC(4), CMM.CMM_CD) + " + aParam[1] + " \n";
sSql += "WHERE \n";
sSql += " CMM.CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n";
sSql += "AND CMM.CMM_GRP_CD = '" + aParam[0] + "' \n";
sSql += "AND CMM.LANG_TYPE = '" + m_cPosStatus.Base.Country + "' \n";
sSql += "AND CMM.USE_YN = '1' \n";
sSql += "AND ISNULL(CMM.CHAR_VAL_TITLE_VAL_04, '0') NOT IN( '" + (PosMstManager.GetPosOption(POS_OPTION.OPT010) != "1" ? "4" : "") + "' ) \n"; // 외화 사용여부 체크
sSql += "ORDER BY CMM.DISP_SEQ \n";
sSql = sSql.Replace("\t", " ");
DataTable dtDataInfo = m_cMstService.Select(new string[] { sSql });
return dtDataInfo;
}
catch (Exception ex)
{
WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
}
return null;
}
#endregion
#region /
/// <summary>
/// 중간/마감입금 점검지 조회
/// </summary>
/// <param name="aParam"></param>
/// <returns></returns>
public DataTable GetData_PayCheckList(string[] aParam)
{
string sSql = "";
try
{
sSql = "";
sSql += "SELECT \n";
sSql += " CMM.CMM_CD \n";
sSql += " , ISNULL(CMM.ENTRY_NM, '') CD_NM \n";
sSql += " , ISNULL(CMM.DISP_SEQ, 9999) DISP_SEQ \n";
//sSql += " , ISNULL(TSA.QTY, 0) QTY \n";
//sSql += " , ISNULL(TSA.AMT, 0) AMT \n";
sSql += " , ISNULL(CMM.CHAR_VAL_TITLE_VAL_01, '0') CHAR_VAL_TITLE_VAL_01 \n";
sSql += " , ISNULL(CMM.CHAR_VAL_TITLE_VAL_02, '0') CHAR_VAL_TITLE_VAL_02 \n";
sSql += " , ISNULL(CMM.CHAR_VAL_TITLE_VAL_03, '0') CHAR_VAL_TITLE_VAL_03 \n";
sSql += " , ISNULL(CMM.CHAR_VAL_TITLE_VAL_04, '0') CHAR_VAL_TITLE_VAL_04 \n";
sSql += "FROM POSMST..MST_CMM CMM \n";
//sSql += " LEFT JOIN POSLOG..TR_SALE_ADMT_CHECK TSA \n";
//sSql += " ON TSA.CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n";
//sSql += " AND TSA.SALE_DT = '" + m_cPosStatus.Base.SaleDate + "' \n";
//sSql += " AND TSA.STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n";
//sSql += " AND TSA.POS_NO = '" + m_cPosStatus.Base.PosNo + "' \n";
//sSql += " AND TSA.ADMT_TYPE IN ('" + ItemConst.TRAN_KIND.STATEMENT.MIDDLE_ADJUSTMENT + "', '" + ItemConst.TRAN_KIND.STATEMENT.ADJUSTMENT + "') \n";
//sSql += " AND TSA.TRADE_NO = (SELECT MAX(TSA1.TRADE_NO) \n";
//sSql += " FROM POSLOG..TR_SALE_ADMT_CHECK TSA1 \n";
//sSql += " WHERE \n";
//sSql += " TSA1.CMP_CD = TSA.CMP_CD \n";
//sSql += " AND TSA1.SALE_DT = TSA.SALE_DT \n";
//sSql += " AND TSA1.STOR_CD = TSA.STOR_CD \n";
//sSql += " AND TSA1.POS_NO = TSA.POS_NO \n";
//sSql += " AND TSA.ADMT_TYPE IN ('" + ItemConst.TRAN_KIND.STATEMENT.MIDDLE_ADJUSTMENT + "', '" + ItemConst.TRAN_KIND.STATEMENT.ADJUSTMENT + "')) \n";
//sSql += " AND CONVERT(NUMERIC(4), TSA.ADMT_CD) = CONVERT(NUMERIC(4), CMM.CMM_CD) + " + aParam[1] + " \n";
sSql += "WHERE \n";
sSql += " CMM.CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n";
sSql += "AND CMM.CMM_GRP_CD = '" + aParam[0] + "' \n";
sSql += "AND CMM.LANG_TYPE = '" + m_cPosStatus.Base.Country + "' \n";
sSql += "AND CMM.USE_YN = '1' \n";
sSql += "ORDER BY CMM.DISP_SEQ \n";
sSql = sSql.Replace("\t", " ");
DataTable dtDataInfo = m_cMstService.Select(new string[] { sSql });
return dtDataInfo;
}
catch (Exception ex)
{
WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
}
return null;
}
#endregion
#region
/// <summary>
/// 업무마감 최종 거래번호 조회
/// </summary>
/// <param name="aParam"></param>
/// <returns></returns>
public DataTable GetMax_ADMT_TradeNo(string[] aParam)
{
string sSql = "";
try
{
sSql = "";
sSql += "SELECT \n";
sSql += " ISNULL(MAX(TRADE_NO), '') TRADE_NO \n";
if (aParam[0] == ItemConst.TRAN_KIND.LOG.POS_CLOSE)
sSql += "FROM POSLOG..ETC_SALE_HEADER \n";
else
sSql += "FROM POSLOG..TR_SALE_HEADER \n";
sSql += "WHERE \n";
sSql += " CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n";
sSql += "AND SALE_DT = '" + m_cPosStatus.Base.SaleDate + "' \n";
sSql += "AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n";
sSql += "AND POS_NO = '" + m_cPosStatus.Base.PosNo + "' \n";
sSql += "AND TRADE_DIV = '0' \n";
sSql += "AND TRAIN_MODE_YN = '0' \n";
sSql += "AND TRADE_KINDPER = '" + aParam[0] + "' \n";
sSql = sSql.Replace("\t", " ");
DataTable dtDataInfo = m_cMstService.Select(new string[] { sSql });
return dtDataInfo;
}
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
}
}