spc-kiosk-pb/Agent/InterfaceOutside/TranInterfaceOutside.cs

1980 lines
109 KiB
C#
Raw Permalink Normal View History

2019-06-16 05:12:09 +00:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Cosmos.Common;
using Cosmos.BaseFrame;
using Cosmos.UserFrame;
using Cosmos.ServiceProvider;
using System.Runtime.Serialization.Formatters.Soap;
using System.Threading;
using System.Data;
using System.Data.SqlClient;
using System.Net;
using System.IO;
using System.Xml;
using System.Net.Sockets;
namespace Cosmos.TranInterfaceOutside
{
public class TranInterfaceOutside : lTranInterfaceOutside
{
#region
/// <summary>
/// StateServer Object (StateServer 객체)
/// </summary>
private StateServer StateObject = (StateServer)StateServer.GetInstance();
/// <summary>
/// POS Status Value (POS 상태값)
/// </summary>
private PosStatus m_cPosStatus = null;
/// <summary>
/// MSSQL DB 관련 객체
/// </summary>
private static SqlDB sqlDb = null;
/// <summary>
/// Inteferface Thread
/// </summary>
private Thread m_tIFProc = null;
/// <summary>
/// 동작 여부
/// </summary>
private bool m_IFProcRunning = false;
/// <summary>
/// 처리중
/// </summary>
private bool m_ProcStart = false;
/// <summary>
/// 대기시간
/// </summary>
private int nWAIT_TIME = 6000;
/// <summary>
/// 전송할 데이터
/// </summary>
private string m_sSendData = string.Empty;
/// <summary>
/// FTP 모듈
/// </summary>
private NetworkFtp m_cNetworkFTP = null;
protected TcpSocket m_cTcpSocket = null;
#endregion
#region
/// <summary>
/// InterfaceOutside
/// </summary>
public TranInterfaceOutside()
{
m_cPosStatus = (PosStatus)StateObject.POS;
m_cNetworkFTP = new NetworkFtp();
m_cTcpSocket = new TcpSocket();
}
#endregion
#region
/// <summary>
/// 스레드 시작
/// </summary>
public void Start()
{
try
{
// Database Connection
sqlDb = new SqlDB(m_cPosStatus.Base.LocalDbSource, m_cPosStatus.Base.LocalDbCatalog, m_cPosStatus.Base.LocalDbUserID, m_cPosStatus.Base.LocalDbPassword);
m_sSendData = string.Empty;
m_tIFProc = new Thread(new ThreadStart(IFExecuteProc));
m_IFProcRunning = true;
m_tIFProc.Start();
}
catch (Exception ex)
{
UserLog.WriteLogFile(UserCom.LOG_DEBUG,
System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명)
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + // Class Name (Class Name (클래스명))
System.Reflection.MethodBase.GetCurrentMethod().Name + "()", // Function Name (Function Name (함수명))
ex.Message);
}
}
/// <summary>
/// 스레드 종료
/// </summary>
public void Stop()
{
try
{
m_IFProcRunning = false;
int count = 0;
while (count < 10)
{
if (m_tIFProc != null && m_tIFProc.IsAlive) m_IFProcRunning = false;
else break;
count++;
Thread.Sleep(10);
}
if (count == 10)
{
UserLog.WriteLogFile(UserCom.LOG_DEBUG,
UserCom.INFO_LEVEL,
System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명)
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + // Class Name (Class Name (클래스명))
System.Reflection.MethodBase.GetCurrentMethod().Name + "()", // Function Name (Function Name (함수명))
"Force I/F Agent Stop!!!");
m_tIFProc.Abort();
}
// DB Close
sqlDb.DBClose();
}
catch (Exception ex)
{
UserLog.WriteLogFile(UserCom.LOG_DEBUG,
System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명)
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + // Class Name (Class Name (클래스명))
System.Reflection.MethodBase.GetCurrentMethod().Name + "()", // Function Name (Function Name (함수명))
ex.Message);
}
}
#endregion
#region Interface
private void IFExecuteProc()
{
int nCount = 0;
string sRet = UserCom.RST_ERR;
while (m_IFProcRunning)
{
try
{
// Set Wait Time
Thread.Sleep((int)nWAIT_TIME);
// 1분 대기후 처리
if (nCount >= 1)
{
// 현재 처리중이면 Skip
if (m_ProcStart != true)
{
m_ProcStart = true;
// 생성 처리
sRet = IF_ExecMake(m_cPosStatus.Mst.ETC_IF_DIV);
// 90일전 데이터 삭제
sRet = IFSendDataDelete();
m_ProcStart = false;
nCount = 0;
}
}
nCount++;
}
catch (Exception ex)
{
UserLog.WriteLogFile(UserCom.LOG_DEBUG,
System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명)
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + // Class Name (Class Name (클래스명))
System.Reflection.MethodBase.GetCurrentMethod().Name + "()", // Function Name (Function Name (함수명))
ex.Message);
}
}
}
#endregion
#region
/// <summary>
/// 인터페이스 생성
/// </summary>
/// <param name="sIFDiv"></param>
/// <returns></returns>
private string IF_ExecMake(string sIFDiv)
{
string sRet = UserCom.RST_ERR;
bool bRet = false;
DataTable dtData = new DataTable();
string sResCD = "99";
string sResMsg = "Not Send";
string sResData = "";
string sSendYn = "0";
int iRecvTimeOut = 10000;
string sRecvData = "";
try
{
// I/F 대상 거래 조회
sRet = SelTranData(ref dtData, sIFDiv);
if (sRet == UserCom.RST_OK)
{
foreach (DataRow dr in dtData.Rows)
{
// 전송상태
sSendYn = "0";
switch (sIFDiv)
{
#region 1.
case ItemConst.TranInterfaceOutside.IF_CHN_01: // 무역센터
{
// 생성
sRet = CHN_01_Make(dr);
if (sRet == UserCom.RST_OK)
{
// 데이터 전송
sResCD = "99";
//sRet = HttpPOST_SendReceive("http://10.254.10.60/ChiaTai/salestrans.asmx", m_sSendData, ref sResCD, ref sResMsg, ref sResData);
sRet = HttpPOST_SendReceive(sIFDiv, m_cPosStatus.Mst.ETC_IF_URL1, m_sSendData, ref sResCD, ref sResMsg, ref sResData);
if (sRet == UserCom.RST_OK)
{
if (sResCD == "0") sSendYn = "1";
}
if (sResCD != "0")
{
// 실패시
string sFileName = "FAIL" + CmUtil.GetDataRowStr(dr, "SALE_DT") + "_" + CmUtil.GetDataRowStr(dr, "TRADE_NO") + ".XML";
CmUtil.CreateDirectory(BaseCom.NxBinPath + @"TRADE\FAIL\");
CmUtil.FileDelete(BaseCom.NxBinPath + @"TRADE\FAIL\" + sFileName);
bRet = WriteFile(BaseCom.NxBinPath + @"TRADE\FAIL\", BaseCom.NxBinPath + @"TRADE\FAIL\" + sFileName, m_sSendData);
}
}
break;
}
#endregion
#region 2.
case ItemConst.TranInterfaceOutside.IF_CHN_02: // 상해쩡따광장
{
// 생성
sRet = CHN_02_Make(dr);
if (sRet == UserCom.RST_OK)
{
// 파일명
string sFileName = "C" + m_cPosStatus.Mst.JOIN_STOR_CD + "_" + m_cPosStatus.Mst.JOIN_BRAND_CD + "_" + CmUtil.GetDataRowStr(dr, "SALE_DT") + "_" + CmUtil.GetDataRowStr(dr, "POS_NO") + CmUtil.GetDataRowStr(dr, "TRADE_NO") + ".dat";
// 파일저장
CmUtil.CreateDirectory(BaseCom.NxBinPath + @"FTPDATA\");
CmUtil.FileDelete(BaseCom.NxBinPath + @"FTPDATA\" + sFileName);
bRet = WriteFile(BaseCom.NxBinPath + "FTPDATA", BaseCom.NxBinPath + @"FTPDATA\" + sFileName, m_sSendData);
if (CmUtil.Exists(sFileName) == true)
{
// ftp 전송
if (m_cNetworkFTP.Connect(m_cPosStatus.Mst.ETC_IF_FTP_IP, m_cPosStatus.Mst.ETC_IF_FTP_ID, m_cPosStatus.Mst.ETC_IF_FTP_PW, 10, CmUtil.IntParse(m_cPosStatus.Mst.ETC_IF_FTP_PORT)) == 0)
{
// FTP 다운로드
int iRet = m_cNetworkFTP.Upload(m_cPosStatus.Mst.ETC_IF_FTP_PATH, BaseCom.NxBinPath + @"FTPDATA\", sFileName);
if (iRet == 0)
{
// 정상
CmUtil.FileDelete(BaseCom.NxBinPath + @"FTPDATA\" + sFileName);
sSendYn = "1";
sResCD = "00";
sResMsg = "OK";
}
}
}
}
break;
}
#endregion
#region 3.
case ItemConst.TranInterfaceOutside.IF_CHN_03: // 왕진활현
{
// 생성
sRet = CHN_03_Make(dr);
if (sRet == UserCom.RST_OK)
{
// 파일저장
//CmUtil.FileDelete(BaseCom.NxBinPath + @"CapitaInterface\possalesdata.txt"); // 개점시 삭제
bRet = WriteFile(@"C:\HOME\IMPORT\", @"C:\HOME\IMPORT\possalesdata.txt", m_sSendData);
// 처리 거래정보 저장
sRet = SavePOSInfoini(dr);
if (bRet == true)
{
// 생성후 데몬이 전송처리하여 생성만 되면 전상 처리
sSendYn = "1";
sResCD = "00";
sResMsg = "OK";
}
}
break;
}
#endregion
#region 4.
case ItemConst.TranInterfaceOutside.IF_CHN_04: // 조양따훼청
{
// 생성
sRet = CHN_04_Make(dr);
if (sRet == UserCom.RST_OK)
{
// 파일명
string sFileName = CmUtil.GetDataRowStr(dr, "SALE_DT") + "_" + CmUtil.GetDataRowStr(dr, "POS_NO") + "_" + CmUtil.GetDataRowStr(dr, "TRADE_NO") + ".dat";
// 파일저장
CmUtil.CreateDirectory(@"C:\PosData\import\");
CmUtil.FileDelete(@"C:\PosData\import\" + sFileName);
bRet = WriteFile(@"C:\PosData\import\", @"C:\PosData\import\" + sFileName, m_sSendData);
if (CmUtil.Exists(@"C:\PosData\import\" + sFileName) == true)
{
// 생성후 데몬이 전송처리하여 생성만 되면 전상 처리
sSendYn = "1";
sResCD = "00";
sResMsg = "OK";
}
}
break;
}
#endregion
#region 5.
case ItemConst.TranInterfaceOutside.IF_CHN_05: // 풍란
{
// 생성
sRet = CHN_05_Make(dr);
if (sRet == UserCom.RST_OK)
{
// 파일명
string sFileName = CmUtil.GetDataRowStr(dr, "SALE_DT") + "_" + CmUtil.GetDataRowStr(dr, "TRADE_NO") + ".XML";
// 파일저장
CmUtil.FileDelete(BaseCom.NxBinPath + @"FENGLAN\" + sFileName);
bRet = WriteFile(BaseCom.NxBinPath + @"FENGLAN\", BaseCom.NxBinPath + @"FENGLAN\" + sFileName, m_sSendData);
if (CmUtil.Exists(BaseCom.NxBinPath + @"FENGLAN\" + sFileName) == true)
{
sRet = XMLSendSocket(m_cPosStatus.Mst.ETC_IF_FTP_IP, CmUtil.IntParse(m_cPosStatus.Mst.ETC_IF_FTP_PORT), m_sSendData, ref sRecvData);
// 생성후 데몬이 전송처리하여 생성만 되면 정상 처리
sResCD = "99";
sRet = XmlParser(ItemConst.TranInterfaceOutside.IF_CHN_05, sRecvData, "result", ref sResCD, ref sResMsg);
if (sRet == UserCom.RST_OK)
{
if (sResCD == "0")
{
sSendYn = "1";
// 정상 처리사 삭제
CmUtil.FileDelete(BaseCom.NxBinPath + @"FENGLAN\" + sFileName);
}
}
if (sResCD != "0")
{
// 오류시 FIAL 폴더로 이동
sSendYn = "9";
CmUtil.CreateDirectory(BaseCom.NxBinPath + @"FENGLAN\FAIL\");
CmUtil.FileMove(BaseCom.NxBinPath + @"FENGLAN\" + sFileName, BaseCom.NxBinPath + @"FENGLAN\FAIL\" + sFileName);
}
}
}
break;
}
#endregion
#region 7.-
case ItemConst.TranInterfaceOutside.IF_SIN_01: // 창이공항
{
// 생성
sRet = SIN_01_Make(dr);
if (sRet == UserCom.RST_OK)
{
// 파일명
string sFileName = string.Format("{0:0000}", CmUtil.GetDataRowDouble(dr, "POS_NO")) + "_" + CmUtil.GetDataRowStr(dr, "TRADE_NO");
// 파일저장
CmUtil.FileDelete(BaseCom.NxBinPath + @"FTPDATA\" + sFileName);
bRet = WriteFile(BaseCom.NxBinPath + "FTPDATA", BaseCom.NxBinPath + @"FTPDATA\" + sFileName, m_sSendData);
if (CmUtil.Exists(BaseCom.NxBinPath + @"FTPDATA\" + sFileName) == true)
{
// ftp 전송
if (m_cNetworkFTP.Connect(m_cPosStatus.Mst.ETC_IF_FTP_IP, m_cPosStatus.Mst.ETC_IF_FTP_ID, m_cPosStatus.Mst.ETC_IF_FTP_PW, 10, CmUtil.IntParse(m_cPosStatus.Mst.ETC_IF_FTP_PORT)) == 0)
{
// FTP 다운로드
int iRet = m_cNetworkFTP.Upload(m_cPosStatus.Mst.ETC_IF_FTP_PATH, BaseCom.NxBinPath + @"FTPDATA\", sFileName);
if (iRet == 0)
{
// 정상
CmUtil.FileDelete(BaseCom.NxBinPath + @"FTPDATA\" + sFileName);
sSendYn = "1";
sResCD = "00";
sResMsg = "OK";
}
else
{
sSendYn = "9";
CmUtil.CreateDirectory(BaseCom.NxBinPath + @"FTPDATA\BackUp\");
CmUtil.FileMove(BaseCom.NxBinPath + @"FTPDATA\" + sFileName, BaseCom.NxBinPath + @"FTPDATA\BackUp\" + sFileName);
}
}
}
}
break;
}
#endregion
}
// 전송후 상태값 저장
sRet = IFSendFlgUpdate(dr, sIFDiv, sResCD, sResMsg, m_sSendData, sResData, sSendYn);
}
}
}
catch (Exception ex)
{
UserLog.WriteLogFile(UserCom.LOG_DEBUG,
System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명)
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + // Class Name (Class Name (클래스명))
System.Reflection.MethodBase.GetCurrentMethod().Name + "()", // Function Name (Function Name (함수명))
ex.Message);
}
return sRet;
}
#endregion
#region I/F
/// <summary>
/// I/F 대상 거래 조회
/// </summary>
/// <param name="dtData"></param>
/// <param name="sIFDiv"></param>
/// <returns></returns>
private string SelTranData(ref DataTable dtData, string sIFDiv)
{
string sQuery = string.Empty;
string sRet = UserCom.RST_ERR;
try
{
sQuery = "";
sQuery += " SELECT \n";
sQuery += " TSH.CMP_CD \n";
sQuery += " , TSH.SALE_DT \n";
sQuery += " , TSH.STOR_CD \n";
sQuery += " , TSH.POS_NO \n";
sQuery += " , TSH.TRADE_NO \n";
sQuery += " , TSH.TRADE_DIV \n";
sQuery += " , TSH.PAY_TIME \n";
sQuery += " , TSH.ORG_BILLDT \n";
sQuery += " , TSH.ORG_BILL_NO \n";
sQuery += " , TSH.ORG_BILL_POSNO \n";
sQuery += " , ISNULL(SUM(TSH.QTY), 0) QTY \n";
sQuery += " , ISNULL(SUM(TSH.NET_SALE_AMT), 0) SALE_AMT \n";
sQuery += "FROM POSLOG..TR_SALE_HEADER TSH \n";
sQuery += " LEFT JOIN POSLOG..LOG_SALE_IF LSI \n";
sQuery += " ON TSH.CMP_CD = LSI.CMP_CD \n";
sQuery += " AND TSH.SALE_DT = LSI.SALE_DT \n";
sQuery += " AND TSH.STOR_CD = LSI.STOR_CD \n";
sQuery += " AND TSH.POS_NO = LSI.POS_NO \n";
sQuery += " AND TSH.TRADE_NO = LSI.TRADE_NO \n";
sQuery += " AND LSI.IF_DIV = '" + sIFDiv.Trim() + "' \n";
sQuery += "WHERE \n";
sQuery += " TSH.CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n";
sQuery += "AND TSH.SALE_DT >= CONVERT(VARCHAR(8), DATEADD(day, -3, '" + m_cPosStatus.Base.SaleDate + "'), 112) \n"; // 영업일 기준 3일 이전부터 체크
sQuery += "AND TSH.STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n";
sQuery += "AND TSH.POS_NO = '" + m_cPosStatus.Base.PosNo + "' \n";
sQuery += "AND TSH.TRAIN_MODE_YN = '0' \n";
sQuery += "AND TSH.TRADE_KINDPER = '00' \n"; // 거래구분 ('00', '10', '11', '20', '21', '42', '43') -- 일반거래, 미결거래, 대외거래, 선불판매, 상품권판매
sQuery += "AND LSI.CMP_CD IS NULL \n";
sQuery += "GROUP BY \n";
sQuery += " TSH.CMP_CD \n";
sQuery += " , TSH.SALE_DT \n";
sQuery += " , TSH.STOR_CD \n";
sQuery += " , TSH.POS_NO \n";
sQuery += " , TSH.TRADE_NO \n";
sQuery += " , TSH.TRADE_DIV \n";
sQuery += " , TSH.PAY_TIME \n";
sQuery += " , TSH.ORG_BILLDT \n";
sQuery += " , TSH.ORG_BILL_NO \n";
sQuery += " , TSH.ORG_BILL_POSNO \n";
sQuery += "ORDER BY 1, 2, 3, 4, 5 \n";
sQuery = sQuery.Replace("\t", " ");
// 조회
if (sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtData) == UserCom.OK)
{
sRet = UserCom.RST_OK;
}
}
catch (Exception ex)
{
UserLog.WriteLogFile(UserCom.LOG_DEBUG,
System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명)
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + // Class Name (Class Name (클래스명))
System.Reflection.MethodBase.GetCurrentMethod().Name + "()", // Function Name (Function Name (함수명))
ex.Message);
}
return sRet;
}
#endregion
#region 1. -
#region CHN_01_Make
/// <summary>
/// CHN_01_Make 생성
/// </summary>
/// <param name="dr"></param>
/// <returns></returns>
private string CHN_01_Make(DataRow dr)
{
string sRet = UserCom.RST_ERR;
try
{
// 1.헤더정보
sRet = CHN_01_Header(dr);
if(sRet != UserCom.RST_OK ) return sRet;
// 2.상품정보
sRet = CHN_01_iTem(dr);
if(sRet != UserCom.RST_OK ) return sRet;
// 3.결제정보
sRet = CHN_01_Tender(dr);
if(sRet != UserCom.RST_OK ) return sRet;
// 4.종결
m_sSendData += "</astr_request>" + PosConst.CRLF;
m_sSendData += "</postsalescreate>" + PosConst.CRLF;
m_sSendData += "</soap12:Body>" + PosConst.CRLF;
m_sSendData += "</soap12:Envelope>" + PosConst.CRLF;
sRet = UserCom.RST_OK;
}
catch (Exception ex)
{
UserLog.WriteLogFile(UserCom.LOG_DEBUG,
System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명)
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + // Class Name (Class Name (클래스명))
System.Reflection.MethodBase.GetCurrentMethod().Name + "()", // Function Name (Function Name (함수명))
ex.Message);
}
return sRet;
}
#endregion
#region CHN_01_Header
/// <summary>
/// CHN_01_Header 헤더
/// </summary>
/// <param name="dr"></param>
/// <returns></returns>
private string CHN_01_Header(DataRow dr)
{
string sRet = UserCom.RST_ERR;
try
{
m_sSendData = "";
m_sSendData += "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + PosConst.CRLF;
m_sSendData += "<soap12:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap12=\"http://www.w3.org/2003/05/soap-envelope\">" + PosConst.CRLF;
m_sSendData += "<soap12:Body>" + PosConst.CRLF;
m_sSendData += "<postsalescreate xmlns=\"http://tempurl.org\">" + PosConst.CRLF;
m_sSendData += "<astr_request>" + PosConst.CRLF;
// 1. XML 헤더
m_sSendData += PosConst.CRLF;
m_sSendData += "<header>" + PosConst.CRLF;
m_sSendData += "<licensekey></licensekey>" + PosConst.CRLF;
m_sSendData += "<username>SB124A</username>" + PosConst.CRLF;
m_sSendData += "<password>SB124A</password>" + PosConst.CRLF;
m_sSendData += "<lang></lang>" + PosConst.CRLF;
m_sSendData += "<pagerecords>" + IntParse(CmUtil.GetDataRowStr(dr, "TRADE_NO")) + "</pagerecords>" + PosConst.CRLF; // 거래번호
m_sSendData += "<pageno>" + IntParse(CmUtil.GetDataRowStr(dr, "TRADE_NO")) + "</pageno>" + PosConst.CRLF; // 거래번호
m_sSendData += "<updatecount>0</updatecount>" + PosConst.CRLF;
m_sSendData += "<messagetype>SALESDATA</messagetype>" + PosConst.CRLF;
m_sSendData += "<messageid>332</messageid>" + PosConst.CRLF;
m_sSendData += "<version>V332M</version>" + PosConst.CRLF;
m_sSendData += "</header>" + PosConst.CRLF;
m_sSendData += "" + PosConst.CRLF;
m_sSendData += "" + PosConst.CRLF;
// 2. XML 합계정보
m_sSendData += "<salestotal>" + PosConst.CRLF;
m_sSendData += "<localstorecode>SB124A</localstorecode>" + PosConst.CRLF;
m_sSendData += "<reservedocno></reservedocno>" + PosConst.CRLF;
m_sSendData += "<txdate_yyyymmdd>" + CmUtil.GetDataRowStr(dr, "SALE_DT") + "</txdate_yyyymmdd>" + PosConst.CRLF;
m_sSendData += "<txtime_hhmmss>" + CmUtil.GetDataRowStr(dr, "PAY_TIME") + "</txtime_hhmmss>" + PosConst.CRLF;
m_sSendData += "<mallid>2037</mallid>" + PosConst.CRLF;
m_sSendData += "<storecode>SB124A</storecode>" + PosConst.CRLF;
m_sSendData += "<tillid>" + CmUtil.GetDataRowStr(dr, "POS_NO") + "</tillid>" + PosConst.CRLF;
string sTranDiv = "SA";
if (CmUtil.GetDataRowStr(dr, "TRADE_DIV") == "1") sTranDiv = "SR";
m_sSendData += "<salestype>" + sTranDiv + "</salestype>" + PosConst.CRLF;
m_sSendData += "<txdocno>" + CmUtil.GetDataRowStr(dr, "TRADE_NO") + "</txdocno>" + PosConst.CRLF;
m_sSendData += "<orgtxdate_yyyymmdd>" + CmUtil.GetDataRowStr(dr, "ORG_BILLDT") + "</orgtxdate_yyyymmdd>" + PosConst.CRLF;
m_sSendData += "<orgstorecode>" + CmUtil.GetDataRowStr(dr, "STOR_CD") + "</orgstorecode>" + PosConst.CRLF;
m_sSendData += "<orgtillid>" + CmUtil.GetDataRowStr(dr, "ORG_BILL_POSNO") + "</orgtillid>" + PosConst.CRLF;
m_sSendData += "<txorgdocno></txorgdocno>" + PosConst.CRLF;
m_sSendData += "<mallitemcode></mallitemcode>" + PosConst.CRLF;
m_sSendData += "<cashier>SB124A</cashier>" + PosConst.CRLF;
m_sSendData += "<vipcode></vipcode>" + PosConst.CRLF;
m_sSendData += "<salesman></salesman>" + PosConst.CRLF;
m_sSendData += "<demographiccode></demographiccode>" + PosConst.CRLF;
m_sSendData += "<demographicdata></demographicdata>" + PosConst.CRLF;
m_sSendData += "<netqty>" + IntParse(CmUtil.GetDataRowStr(dr, "QTY")) + "</netqty>" + PosConst.CRLF;
m_sSendData += "<originalamount>0.00</originalamount>" + PosConst.CRLF;
m_sSendData += "<sellingamount>" + DoubleParse(CmUtil.GetDataRowStr(dr, "SALE_AMT")) + "</sellingamount>" + PosConst.CRLF;
m_sSendData += "<couponnumber></couponnumber>" + PosConst.CRLF;
m_sSendData += "<coupongroup></coupongroup>" + PosConst.CRLF;
m_sSendData += "<coupontype></coupontype>" + PosConst.CRLF;
m_sSendData += "<couponqty>0</couponqty>" + PosConst.CRLF;
m_sSendData += "<totaldiscount></totaldiscount>" + PosConst.CRLF;
m_sSendData += "<ttltaxamount1>0</ttltaxamount1>" + PosConst.CRLF;
m_sSendData += "<ttltaxamount2>0</ttltaxamount2>" + PosConst.CRLF;
m_sSendData += "<netamount>" + DoubleParse(CmUtil.GetDataRowStr(dr, "SALE_AMT")) + "</netamount>" + PosConst.CRLF;
m_sSendData += "<paidamount>" + DoubleParse(CmUtil.GetDataRowStr(dr, "SALE_AMT")) + "</paidamount>" + PosConst.CRLF;
m_sSendData += "<changeamount>0.00</changeamount>" + PosConst.CRLF;
m_sSendData += "<priceincludetax></priceincludetax>" + PosConst.CRLF;
m_sSendData += "<shoptaxgroup></shoptaxgroup>" + PosConst.CRLF;
m_sSendData += "<extendparam></extendparam>" + PosConst.CRLF;
m_sSendData += "<invoicetitle></invoicetitle>" + PosConst.CRLF;
m_sSendData += "<invoicecontent></invoicecontent>" + PosConst.CRLF;
m_sSendData += "<issueby>SB124A</issueby>" + PosConst.CRLF;
m_sSendData += "<issuedate_yyyymmdd>" + CmUtil.GetDataRowStr(dr, "SALE_DT") + "</issuedate_yyyymmdd>" + PosConst.CRLF;
m_sSendData += "<issuetime_hhmmss>" + CmUtil.GetDataRowStr(dr, "PAY_TIME") + "</issuetime_hhmmss>" + PosConst.CRLF;
m_sSendData += "<ecorderno></ecorderno>" + PosConst.CRLF;
m_sSendData += "<buyerremark></buyerremark>" + PosConst.CRLF;
m_sSendData += "<orderremark></orderremark>" + PosConst.CRLF;
m_sSendData += "<status>10</status>" + PosConst.CRLF;
m_sSendData += "<ttpossalesdocno></ttpossalesdocno>" + PosConst.CRLF;
m_sSendData += "</salestotal>" + PosConst.CRLF;
m_sSendData += "" + PosConst.CRLF;
m_sSendData += "" + PosConst.CRLF;
sRet = UserCom.RST_OK;
}
catch (Exception ex)
{
UserLog.WriteLogFile(UserCom.LOG_DEBUG,
System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명)
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + // Class Name (Class Name (클래스명))
System.Reflection.MethodBase.GetCurrentMethod().Name + "()", // Function Name (Function Name (함수명))
ex.Message);
}
return sRet;
}
#endregion
#region CHN_01_iTem
/// <summary>
/// CHN_01_iTem 상품정보
/// </summary>
/// <param name="dr"></param>
/// <returns></returns>
private string CHN_01_iTem(DataRow dr)
{
string sQuery = string.Empty;
string sRet = UserCom.RST_ERR;
DataTable dtData = new DataTable();
try
{
sQuery = "";
sQuery += " SELECT \n";
sQuery += " TSD.SEQ \n";
sQuery += " , TSD.ITEM_PLU_CD \n";
sQuery += " , ISNULL(TSD.SALE_QTY, 0) SALE_QTY \n";
sQuery += " , ISNULL(TSD.BILL_AMT, 0) BILL_AMT \n";
sQuery += "FROM POSLOG..TR_SALE_DETAIL TSD \n";
sQuery += "WHERE \n";
sQuery += " TSD.CMP_CD = '" + CmUtil.GetDataRowStr(dr, "CMP_CD") + "' \n";
sQuery += "AND TSD.SALE_DT = '" + CmUtil.GetDataRowStr(dr, "SALE_DT") + "' \n";
sQuery += "AND TSD.STOR_CD = '" + CmUtil.GetDataRowStr(dr, "STOR_CD") + "' \n";
sQuery += "AND TSD.POS_NO = '" + CmUtil.GetDataRowStr(dr, "POS_NO") + "' \n";
sQuery += "AND TSD.TRADE_NO = '" + CmUtil.GetDataRowStr(dr, "TRADE_NO") + "' \n";
sQuery += "AND TSD.CANCEL_DIV = '0' \n";
sQuery += "ORDER BY TSD.SEQ \n";
sQuery = sQuery.Replace("\t", " ");
// 조회
if (sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtData) == UserCom.OK)
{
m_sSendData += "<salesitems>" + PosConst.CRLF;
foreach(DataRow dri in dtData.Rows)
{
m_sSendData += "<salesitem>" + PosConst.CRLF;
m_sSendData += "<iscounteritemcode>1</iscounteritemcode>" + PosConst.CRLF;
m_sSendData += "<lineno>" + IntParse(CmUtil.GetDataRowStr(dri, "SEQ")) + "</lineno>" + PosConst.CRLF;
m_sSendData += "<storecode>SB124A</storecode>" + PosConst.CRLF;
m_sSendData += "<mallitemcode>SB124A1</mallitemcode>" + PosConst.CRLF;
m_sSendData += "<counteritemcode>SB124A1</counteritemcode> " + PosConst.CRLF;
m_sSendData += "<itemcode>" + CmUtil.GetDataRowStr(dri, "ITEM_PLU_CD") + "</itemcode>" + PosConst.CRLF;
m_sSendData += "<plucode>" + CmUtil.GetDataRowStr(dri, "ITEM_PLU_CD") + "</plucode>" + PosConst.CRLF;
m_sSendData += "<colorcode></colorcode>" + PosConst.CRLF;
m_sSendData += "<sizecode></sizecode>" + PosConst.CRLF;
m_sSendData += "<itemlotnum>*</itemlotnum>" + PosConst.CRLF;
m_sSendData += "<serialnum></serialnum>" + PosConst.CRLF;
m_sSendData += "<isdeposit>0</isdeposit>" + PosConst.CRLF;
m_sSendData += "<iswholesale>0</iswholesale>" + PosConst.CRLF;
m_sSendData += "<invttype>1</invttype>" + PosConst.CRLF;
m_sSendData += "<qty>" + IntParse(CmUtil.GetDataRowStr(dri, "SALE_QTY")) + "</qty>" + PosConst.CRLF;
m_sSendData += "<exstk2sales>1.00</exstk2sales>" + PosConst.CRLF;
m_sSendData += "<originalprice>0.00</originalprice>" + PosConst.CRLF;
m_sSendData += "<sellingprice>0.00</sellingprice>" + PosConst.CRLF;
m_sSendData += "<pricemode></pricemode>" + PosConst.CRLF;
m_sSendData += "<priceapprove></priceapprove>" + PosConst.CRLF;
m_sSendData += "<couponnumber></couponnumber>" + PosConst.CRLF;
m_sSendData += "<coupongroup></coupongroup>" + PosConst.CRLF;
m_sSendData += "<coupontype></coupontype>" + PosConst.CRLF;
m_sSendData += "<itemdiscount></itemdiscount>" + PosConst.CRLF;
m_sSendData += "<vipdiscountpercent>0</vipdiscountpercent>" + PosConst.CRLF;
m_sSendData += "<vipdiscountless>0</vipdiscountless>" + PosConst.CRLF;
m_sSendData += "<promotion>" + PosConst.CRLF;
m_sSendData += "</promotion>" + PosConst.CRLF;
m_sSendData += "<totaldiscountless1>0</totaldiscountless1>" + PosConst.CRLF;
m_sSendData += "<totaldiscountless2>0</totaldiscountless2>" + PosConst.CRLF;
m_sSendData += "<totaldiscountless>0</totaldiscountless>" + PosConst.CRLF;
m_sSendData += "<tax>" + PosConst.CRLF;
m_sSendData += "</tax>" + PosConst.CRLF;
m_sSendData += "<netamount>" + DoubleParse(CmUtil.GetDataRowStr(dri, "BILL_AMT")) + "</netamount>" + PosConst.CRLF;
m_sSendData += "<bonusearn>0</bonusearn>" + PosConst.CRLF;
m_sSendData += "<salesitemremark></salesitemremark>" + PosConst.CRLF;
m_sSendData += "<refundreasoncode></refundreasoncode>" + PosConst.CRLF;
m_sSendData += "<extendparam></extendparam>" + PosConst.CRLF;
m_sSendData += "</salesitem>" + PosConst.CRLF;
}
m_sSendData += "</salesitems>" + PosConst.CRLF;
m_sSendData += "" + PosConst.CRLF;
m_sSendData += "" + PosConst.CRLF;
sRet = UserCom.RST_OK;
}
}
catch (Exception ex)
{
UserLog.WriteLogFile(UserCom.LOG_DEBUG,
System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명)
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + // Class Name (Class Name (클래스명))
System.Reflection.MethodBase.GetCurrentMethod().Name + "()", // Function Name (Function Name (함수명))
ex.Message);
}
return sRet;
}
#endregion
#region CHN_01_Tender
/// <summary>
/// CHN_01_Tender 결제정보
/// </summary>
/// <param name="dr"></param>
/// <returns></returns>
private string CHN_01_Tender(DataRow dr)
{
string sQuery = string.Empty;
string sRet = UserCom.RST_ERR;
DataTable dtData = new DataTable();
try
{
sQuery = "";
sQuery += " SELECT \n";
sQuery += " TSP.SEQ \n";
sQuery += " , CASE ISNULL(TSP.PAY_WAY_CD, '00') WHEN '00' THEN 'CH' \n";
sQuery += " WHEN '02' THEN 'CI' \n";
sQuery += " ELSE 'OH' END PAY_WAY_CD \n";
sQuery += " , ISNULL(TSP.QTY_ENTRY_01, 0) QTY \n";
sQuery += " , ISNULL(TSP.PAY_AMT, 0) PAY_AMT \n";
sQuery += "FROM POSLOG..TR_SALE_PAY TSP \n";
sQuery += "WHERE \n";
sQuery += " TSP.CMP_CD = '" + CmUtil.GetDataRowStr(dr, "CMP_CD") + "' \n";
sQuery += "AND TSP.SALE_DT = '" + CmUtil.GetDataRowStr(dr, "SALE_DT") + "' \n";
sQuery += "AND TSP.STOR_CD = '" + CmUtil.GetDataRowStr(dr, "STOR_CD") + "' \n";
sQuery += "AND TSP.POS_NO = '" + CmUtil.GetDataRowStr(dr, "POS_NO") + "' \n";
sQuery += "AND TSP.TRADE_NO = '" + CmUtil.GetDataRowStr(dr, "TRADE_NO") + "' \n";
sQuery += "AND TSP.CANCEL_DIV = '0' \n";
sQuery += "ORDER BY TSP.SEQ \n";
sQuery = sQuery.Replace("\t", " ");
// 조회
if (sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtData) == UserCom.OK)
{
m_sSendData += "<salestenders> " + PosConst.CRLF;
foreach(DataRow dri in dtData.Rows)
{
m_sSendData += "<salestender>" + PosConst.CRLF;
m_sSendData += "<lineno>" + IntParse(CmUtil.GetDataRowStr(dri, "SEQ")) + "</lineno>" + PosConst.CRLF;
m_sSendData += "<tendercode>" + CmUtil.GetDataRowStr(dri, "PAY_WAY_CD") + "</tendercode>" + PosConst.CRLF;
m_sSendData += "<tendertype>0</tendertype>" + PosConst.CRLF;
m_sSendData += "<tendercategory>0</tendercategory>" + PosConst.CRLF;
m_sSendData += "<payamount>" + DoubleParse(CmUtil.GetDataRowStr(dri, "PAY_AMT")) + "</payamount>" + PosConst.CRLF;
m_sSendData += "<baseamount>" + DoubleParse(CmUtil.GetDataRowStr(dri, "PAY_AMT")) + "</baseamount>" + PosConst.CRLF;
m_sSendData += "<excessamount>0</excessamount>" + PosConst.CRLF;
m_sSendData += "<extendparam>-BS2037A00181,-DTSA,-CT99,</extendparam>" + PosConst.CRLF;
m_sSendData += "<remark></remark>" + PosConst.CRLF;
m_sSendData += "</salestender>" + PosConst.CRLF;
}
m_sSendData += "</salestenders> " + PosConst.CRLF;
sRet = UserCom.RST_OK;
}
}
catch (Exception ex)
{
UserLog.WriteLogFile(UserCom.LOG_DEBUG,
System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명)
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + // Class Name (Class Name (클래스명))
System.Reflection.MethodBase.GetCurrentMethod().Name + "()", // Function Name (Function Name (함수명))
ex.Message);
}
return sRet;
}
#endregion
#endregion
#region 2.
#region CHN_02_Make
/// <summary>
/// CHN_02_Make 생성
/// </summary>
/// <param name="dr"></param>
/// <returns></returns>
private string CHN_02_Make(DataRow dr)
{
string sRet = UserCom.RST_ERR;
try
{
// 1.헤더정보
sRet = CHN_02_Header(dr);
if (sRet != UserCom.RST_OK) return sRet;
// 2.상품정보
sRet = CHN_02_iTem(dr);
if (sRet != UserCom.RST_OK) return sRet;
// 3.결제정보
sRet = CHN_02_Tender(dr);
if (sRet != UserCom.RST_OK) return sRet;
}
catch (Exception ex)
{
UserLog.WriteLogFile(UserCom.LOG_DEBUG,
System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명)
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + // Class Name (Class Name (클래스명))
System.Reflection.MethodBase.GetCurrentMethod().Name + "()", // Function Name (Function Name (함수명))
ex.Message);
}
return sRet;
}
#endregion
#region CHN_02_Header
/// <summary>
/// CHN_02_Header 헤더
/// </summary>
/// <param name="dr"></param>
/// <returns></returns>
private string CHN_02_Header(DataRow dr)
{
string sRet = UserCom.RST_ERR;
try
{
m_sSendData = "";
m_sSendData += "C";
m_sSendData += m_cPosStatus.Mst.JOIN_BRAND_CD; // 임대번호
m_sSendData += "~";
m_sSendData += m_cPosStatus.Mst.JOIN_STOR_CD; // 기계번호
m_sSendData += "~";
m_sSendData += "H"; // 기록유형 (H-head)
m_sSendData += "~";
m_sSendData += m_cPosStatus.Base.PosNo; // pos번호
m_sSendData += "~";
m_sSendData += m_cPosStatus.Base.TradeNo; // 거래번호
m_sSendData += "~";
string sTranDiv = "1";
if (CmUtil.GetDataRowStr(dr, "TRADE_DIV") == "1") sTranDiv = "2";
m_sSendData += sTranDiv; // 거래유형 (1:매출, 2:환불)
m_sSendData += "~";
m_sSendData += DoubleParse(CmUtil.GetDataRowStr(dr, "SALE_AMT")); // 거래총금액
m_sSendData += "~";
m_sSendData += ""; // 회원카드번호
m_sSendData += "~";
m_sSendData += CmUtil.GetDataRowStr(dr, "SALE_DT") + CmUtil.GetDataRowStr(dr, "PAY_TIME"); // 거래일시
m_sSendData += PosConst.CRLF;
sRet = UserCom.RST_OK;
}
catch (Exception ex)
{
UserLog.WriteLogFile(UserCom.LOG_DEBUG,
System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명)
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + // Class Name (Class Name (클래스명))
System.Reflection.MethodBase.GetCurrentMethod().Name + "()", // Function Name (Function Name (함수명))
ex.Message);
}
return sRet;
}
#endregion
#region CHN_02_iTem
/// <summary>
/// CHN_02_iTem 상품정보
/// </summary>
/// <param name="dr"></param>
/// <returns></returns>
private string CHN_02_iTem(DataRow dr)
{
string sQuery = string.Empty;
string sRet = UserCom.RST_ERR;
DataTable dtData = new DataTable();
try
{
sQuery = "";
sQuery += " SELECT \n";
sQuery += " TSD.SEQ \n";
sQuery += " , TSD.ITEM_PLU_CD \n";
sQuery += " , ISNULL(TSD.SALE_QTY, 0) SALE_QTY \n";
sQuery += " , ISNULL(TSD.BILL_AMT, 0) BILL_AMT \n";
sQuery += " , ISNULL(MI.SHTCUT_ITEMNM, '') ITEM_NM \n";
sQuery += "FROM POSLOG..TR_SALE_DETAIL TSD \n";
sQuery += " LEFT JOIN POSMST..MST_ITEM MI \n";
sQuery += " ON MI.CMP_CD = TSD.CMP_CD \n";
sQuery += " AND MI.STOR_CD = TSD.STOR_CD \n";
sQuery += " AND MI.SUB_STOR_CD = TSD.SUB_SHOP_CD \n";
sQuery += " AND MI.ITEM_CD = TSD.ITEM_PLU_CD \n";
sQuery += " AND MI.USE_YN = '" + PosConst.MST_USE_YN.YES + "' \n";
sQuery += "WHERE \n";
sQuery += " TSD.CMP_CD = '" + CmUtil.GetDataRowStr(dr, "CMP_CD") + "' \n";
sQuery += "AND TSD.SALE_DT = '" + CmUtil.GetDataRowStr(dr, "SALE_DT") + "' \n";
sQuery += "AND TSD.STOR_CD = '" + CmUtil.GetDataRowStr(dr, "STOR_CD") + "' \n";
sQuery += "AND TSD.POS_NO = '" + CmUtil.GetDataRowStr(dr, "POS_NO") + "' \n";
sQuery += "AND TSD.TRADE_NO = '" + CmUtil.GetDataRowStr(dr, "TRADE_NO") + "' \n";
sQuery += "AND TSD.CANCEL_DIV = '0' \n";
sQuery += "ORDER BY TSD.SEQ \n";
sQuery = sQuery.Replace("\t", " ");
// 조회
if (sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtData) == UserCom.OK)
{
foreach (DataRow dri in dtData.Rows)
{
m_sSendData += "C";
m_sSendData += m_cPosStatus.Mst.JOIN_BRAND_CD; // 임대번호
m_sSendData += "~";
m_sSendData += m_cPosStatus.Mst.JOIN_STOR_CD; // 기계번호
m_sSendData += "~";
m_sSendData += "I"; // 기록유형 (I-item)
m_sSendData += "~";
m_sSendData += CmUtil.GetDataRowStr(dri, "ITEM_PLU_CD"); // 상품코드
m_sSendData += "~";
m_sSendData += IntParse(CmUtil.GetDataRowStr(dri, "SALE_QTY")); // 수량
m_sSendData += "~";
m_sSendData += DoubleParse(CmUtil.GetDataRowStr(dri, "BILL_AMT")); // 금액
m_sSendData += "~";
m_sSendData += CmUtil.MidH(CmUtil.GetDataRowStr(dri, "ITEM_NM"), 0, 40); // 명칭
m_sSendData += PosConst.CRLF;
}
sRet = UserCom.RST_OK;
}
}
catch (Exception ex)
{
UserLog.WriteLogFile(UserCom.LOG_DEBUG,
System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명)
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + // Class Name (Class Name (클래스명))
System.Reflection.MethodBase.GetCurrentMethod().Name + "()", // Function Name (Function Name (함수명))
ex.Message);
}
return sRet;
}
#endregion
#region CHN_02_Tender
/// <summary>
/// CHN_02_Tender 결제정보
/// </summary>
/// <param name="dr"></param>
/// <returns></returns>
private string CHN_02_Tender(DataRow dr)
{
string sQuery = string.Empty;
string sRet = UserCom.RST_ERR;
DataTable dtData = new DataTable();
try
{
sQuery = "";
sQuery += " SELECT \n";
sQuery += " TSP.SEQ \n";
sQuery += " , CASE ISNULL(TSP.PAY_WAY_CD, '00') WHEN '00' THEN '1' \n";
sQuery += " WHEN '02' THEN (CASE ISNULL(TSP.OCCUR_ENTRY_05, '') WHEN 'C' THEN '3' ELSE '2' END) \n";
sQuery += " WHEN '06' THEN '4' \n";
sQuery += " ELSE '5' END PAY_WAY_CD \n";
sQuery += " , ISNULL(TSP.QTY_ENTRY_01, 0) QTY \n";
sQuery += " , ISNULL(TSP.PAY_AMT, 0) PAY_AMT \n";
sQuery += "FROM POSLOG..TR_SALE_PAY TSP \n";
sQuery += "WHERE \n";
sQuery += " TSP.CMP_CD = '" + CmUtil.GetDataRowStr(dr, "CMP_CD") + "' \n";
sQuery += "AND TSP.SALE_DT = '" + CmUtil.GetDataRowStr(dr, "SALE_DT") + "' \n";
sQuery += "AND TSP.STOR_CD = '" + CmUtil.GetDataRowStr(dr, "STOR_CD") + "' \n";
sQuery += "AND TSP.POS_NO = '" + CmUtil.GetDataRowStr(dr, "POS_NO") + "' \n";
sQuery += "AND TSP.TRADE_NO = '" + CmUtil.GetDataRowStr(dr, "TRADE_NO") + "' \n";
sQuery += "AND TSP.CANCEL_DIV = '0' \n";
sQuery += "ORDER BY TSP.SEQ \n";
sQuery = sQuery.Replace("\t", " ");
// 조회
if (sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtData) == UserCom.OK)
{
foreach (DataRow dri in dtData.Rows)
{
m_sSendData += "C";
m_sSendData += m_cPosStatus.Mst.JOIN_BRAND_CD; // 임대번호
m_sSendData += "~";
m_sSendData += m_cPosStatus.Mst.JOIN_STOR_CD; // 기계번호
m_sSendData += "~";
m_sSendData += "T"; // 기록유형 (T-TENDER)
m_sSendData += "~";
m_sSendData += CmUtil.GetDataRowStr(dri, "PAY_WAY_CD"); // 지불방식: 1-현금 2-신용카드 3-IC카드 4-상품권 5-기타
m_sSendData += "~";
m_sSendData += DoubleParse(CmUtil.GetDataRowStr(dri, "PAY_AMT")); // 금액
m_sSendData += PosConst.CRLF;
}
sRet = UserCom.RST_OK;
}
}
catch (Exception ex)
{
UserLog.WriteLogFile(UserCom.LOG_DEBUG,
System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명)
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + // Class Name (Class Name (클래스명))
System.Reflection.MethodBase.GetCurrentMethod().Name + "()", // Function Name (Function Name (함수명))
ex.Message);
}
return sRet;
}
#endregion
#endregion
#region 3.
#region CHN_03_Make
/// <summary>
/// CHN_03_Make 생성
/// </summary>
/// <param name="dr"></param>
/// <returns></returns>
private string CHN_03_Make(DataRow dr)
{
string sQuery = string.Empty;
string sRet = UserCom.RST_ERR;
DataTable dtData = new DataTable();
try
{
m_sSendData = "";
sQuery = "";
sQuery += " SELECT \n";
sQuery += " TSH.CMP_CD \n";
sQuery += " , '2052011401001' STOR_CD \n";
sQuery += " , TSH.POS_NO \n";
sQuery += " , TSH.SALE_DT \n";
sQuery += " , TSH.PAY_TIME \n";
sQuery += " , TSH.TRADE_NO \n";
sQuery += " , TSH.TRADE_DIV \n";
sQuery += " , '2052011401001' ITEM_CD \n";
sQuery += " , ISNULL(SUM(TSH.NET_SALE_AMT), 0) SALE_AMT \n";
sQuery += " FROM POSLOG..TR_SALE_HEADER TSH \n";
sQuery += " WHERE \n";
sQuery += " TSH.CMP_CD = '" + CmUtil.GetDataRowStr(dr, "CMP_CD") + "' \n";
sQuery += " AND TSH.SALE_DT = '" + CmUtil.GetDataRowStr(dr, "SALE_DT") + "' \n";
sQuery += " AND TSH.STOR_CD = '" + CmUtil.GetDataRowStr(dr, "STOR_CD") + "' \n";
sQuery += " AND TSH.POS_NO = '" + CmUtil.GetDataRowStr(dr, "POS_NO") + "' \n";
sQuery += " AND TSH.TRADE_NO = '" + CmUtil.GetDataRowStr(dr, "TRADE_NO") + "' \n";
sQuery += " AND TSH.TRAIN_MODE_YN = '0' \n";
sQuery += " AND TSH.TRADE_KINDPER = '00' \n";
sQuery += " GROUP BY \n";
sQuery += " TSH.CMP_CD \n";
sQuery += " , TSH.SALE_DT \n";
sQuery += " , TSH.STOR_CD \n";
sQuery += " , TSH.POS_NO \n";
sQuery += " , TSH.TRADE_NO \n";
sQuery += " , TSH.TRADE_DIV \n";
sQuery += " , TSH.PAY_TIME \n";
sQuery = sQuery.Replace("\t", " ");
// 조회
if (sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtData) == UserCom.OK)
{
foreach (DataRow dri in dtData.Rows)
{
double nTranDiv = 1;
if (CmUtil.GetDataRowStr(dri, "TRADE_DIV") == ItemConst.PAY_CANCEL_DIV.CANCEL) nTranDiv = -1;
m_sSendData += " "; // 스페이스
m_sSendData += "\t";
m_sSendData += m_cPosStatus.Mst.JOIN_STOR_CD; // 점포코드
m_sSendData += "\t";
m_sSendData += CmUtil.GetDataRowStr(dri, "POS_NO"); // POS번호
m_sSendData += "\t";
m_sSendData += CmUtil.GetDataRowStr(dri, "SALE_DT"); // 거래일자
m_sSendData += "\t";
m_sSendData += CmUtil.GetDataRowStr(dri, "PAY_TIME"); // 거래시간
m_sSendData += "\t";
m_sSendData += CmUtil.GetDataRowStr(dri, "TRADE_NO"); // 거래번호
m_sSendData += "\t";
m_sSendData += m_cPosStatus.Mst.JOIN_ITEM_CD; // 상품코드
m_sSendData += "\t";
m_sSendData += CmUtil.DoubleMultiplication(DoubleParse(CmUtil.GetDataRowStr(dri, "SALE_AMT")), nTranDiv); // 결제금액
m_sSendData += "\t";
m_sSendData += ""; // TENDER
m_sSendData += PosConst.CRLF;
}
sRet = UserCom.RST_OK;
}
}
catch (Exception ex)
{
UserLog.WriteLogFile(UserCom.LOG_DEBUG,
System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명)
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + // Class Name (Class Name (클래스명))
System.Reflection.MethodBase.GetCurrentMethod().Name + "()", // Function Name (Function Name (함수명))
ex.Message);
}
return sRet;
}
#endregion
#endregion
#region 4.
#region CHN_04_Make
/// <summary>
/// CHN_04_Make 생성
/// </summary>
/// <param name="dr"></param>
/// <returns></returns>
private string CHN_04_Make(DataRow dr)
{
string sQuery = string.Empty;
string sRet = UserCom.RST_ERR;
DataTable dtData = new DataTable();
try
{
m_sSendData = "";
sQuery = "";
sQuery += " SELECT \n";
sQuery += " TSH.CMP_CD \n";
sQuery += " , '1F31A1' STOR_CD \n";
sQuery += " , TSH.POS_NO \n";
sQuery += " , TSH.SALE_DT \n";
sQuery += " , TSH.PAY_TIME \n";
sQuery += " , TSH.TRADE_NO \n";
sQuery += " , TSH.TRADE_DIV \n";
sQuery += " , '1031110' ITEM_CD \n";
sQuery += " , ISNULL(SUM(CASE ISNULL(TSP.PAY_WAY_CD, '') WHEN '00' THEN ISNULL(TSP.PAY_AMT, 0) ELSE 0 END), 0) CASH_AMT \n";
sQuery += " , ISNULL(SUM(CASE ISNULL(TSP.PAY_WAY_CD, '') WHEN '02' THEN (CASE WHEN ISNULL(TSP.OCCUR_ENTRY_18, '') = '20' THEN ISNULL(TSP.PAY_AMT, 0) ELSE 0 END) ELSE 0 END), 0) CARD_UN_SUM \n";
sQuery += " , ISNULL(SUM(CASE ISNULL(TSP.PAY_WAY_CD, '') WHEN '02' THEN (CASE WHEN ISNULL(TSP.OCCUR_ENTRY_18, '') <> '20' THEN ISNULL(TSP.PAY_AMT, 0) ELSE 0 END) ELSE 0 END), 0) CARD_20_SUM \n";
sQuery += " , ISNULL(SUM(CASE ISNULL(TSP.PAY_WAY_CD, '') WHEN '00' THEN 0 \n";
sQuery += " WHEN '02' THEN 0 \n";
sQuery += " ELSE ISNULL(TSP.PAY_AMT, 0) END), 0) ETC_SUM \n";
sQuery += " , ISNULL(SUM(TSH.NET_SALE_AMT), 0) SALE_AMT \n";
sQuery += " FROM POSLOG..TR_SALE_HEADER TSH \n";
sQuery += " LEFT JOIN POSLOG..TR_SALE_PAY TSP \n";
sQuery += " ON TSP.CMP_CD = TSH.CMP_CD \n";
sQuery += " AND TSP.SALE_DT = TSH.SALE_DT \n";
sQuery += " AND TSP.STOR_CD = TSH.STOR_CD \n";
sQuery += " AND TSP.POS_NO = TSH.POS_NO \n";
sQuery += " AND TSP.TRADE_NO = TSH.TRADE_NO \n";
sQuery += " AND TSP.CANCEL_DIV = '0' \n";
sQuery += " WHERE \n";
sQuery += " TSH.CMP_CD = '" + CmUtil.GetDataRowStr(dr, "CMP_CD") + "' \n";
sQuery += " AND TSH.SALE_DT = '" + CmUtil.GetDataRowStr(dr, "SALE_DT") + "' \n";
sQuery += " AND TSH.STOR_CD = '" + CmUtil.GetDataRowStr(dr, "STOR_CD") + "' \n";
sQuery += " AND TSH.POS_NO = '" + CmUtil.GetDataRowStr(dr, "POS_NO") + "' \n";
sQuery += " AND TSH.TRADE_NO = '" + CmUtil.GetDataRowStr(dr, "TRADE_NO") + "' \n";
sQuery += " AND TSH.TRAIN_MODE_YN = '0' \n";
sQuery += " AND TSH.TRADE_KINDPER = '00' \n";
sQuery += " GROUP BY \n";
sQuery += " TSH.CMP_CD \n";
sQuery += " , TSH.SALE_DT \n";
sQuery += " , TSH.STOR_CD \n";
sQuery += " , TSH.POS_NO \n";
sQuery += " , TSH.TRADE_NO \n";
sQuery += " , TSH.TRADE_DIV \n";
sQuery += " , TSH.PAY_TIME \n";
sQuery = sQuery.Replace("\t", " ");
// 조회
if (sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtData) == UserCom.OK)
{
foreach (DataRow dri in dtData.Rows)
{
double nTranDiv = 1;
if (CmUtil.GetDataRowStr(dri, "TRADE_DIV") == ItemConst.PAY_CANCEL_DIV.CANCEL) nTranDiv = -1;
m_sSendData += " "; // 스페이스
m_sSendData += "\t";
m_sSendData += m_cPosStatus.Mst.JOIN_STOR_CD; // 점포코드
m_sSendData += "\t";
m_sSendData += CmUtil.GetDataRowStr(dri, "POS_NO"); // POS번호
m_sSendData += "\t";
m_sSendData += CmUtil.GetDataRowStr(dri, "SALE_DT"); // 거래일자
m_sSendData += "\t";
m_sSendData += CmUtil.GetDataRowStr(dri, "PAY_TIME"); // 거래시간
m_sSendData += "\t";
m_sSendData += CmUtil.GetDataRowStr(dri, "TRADE_NO"); // 거래번호
m_sSendData += "\t";
m_sSendData += m_cPosStatus.Mst.JOIN_ITEM_CD; // 상품코드
m_sSendData += "\t";
m_sSendData += CmUtil.DoubleMultiplication(DoubleParse(CmUtil.GetDataRowStr(dri, "CASH_AMT")), nTranDiv); // 현금
m_sSendData += "\t";
m_sSendData += CmUtil.DoubleMultiplication(DoubleParse(CmUtil.GetDataRowStr(dri, "CARD_UN_SUM")), nTranDiv); // 중국은행카드
m_sSendData += "\t";
m_sSendData += CmUtil.DoubleMultiplication(DoubleParse(CmUtil.GetDataRowStr(dri, "CARD_20_SUM")), nTranDiv); // 해외은행카드
m_sSendData += "\t";
m_sSendData += CmUtil.DoubleMultiplication(DoubleParse(CmUtil.GetDataRowStr(dri, "ETC_SUM")), nTranDiv); // 기타
m_sSendData += "\t";
m_sSendData += CmUtil.DoubleMultiplication(DoubleParse(CmUtil.GetDataRowStr(dri, "SALE_AMT")), nTranDiv); // 합계
m_sSendData += PosConst.CRLF;
}
sRet = UserCom.RST_OK;
}
}
catch (Exception ex)
{
UserLog.WriteLogFile(UserCom.LOG_DEBUG,
System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명)
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + // Class Name (Class Name (클래스명))
System.Reflection.MethodBase.GetCurrentMethod().Name + "()", // Function Name (Function Name (함수명))
ex.Message);
}
return sRet;
}
#endregion
#endregion
#region 5.
#region CHN_05_Make
/// <summary>
/// CHN_05_Make 생성
/// </summary>
/// <param name="dr"></param>
/// <returns></returns>
private string CHN_05_Make(DataRow dr)
{
string sQuery = string.Empty;
string sRet = UserCom.RST_ERR;
DataTable dtData = new DataTable();
string sDocNo = "";
string sSaleDate = "";
try
{
sQuery = "";
sQuery += " SELECT \n";
sQuery += " TSH.CMP_CD \n";
sQuery += " , '000984' STOR_CD \n";
sQuery += " , TSH.POS_NO \n";
sQuery += " , TSH.SALE_DT \n";
sQuery += " , TSH.PAY_TIME \n";
sQuery += " , TSH.TRADE_NO \n";
sQuery += " , TSH.TRADE_DIV \n";
sQuery += " , '000984' ITEM_CD \n";
sQuery += " , ISNULL(SUM(CASE ISNULL(TSP.PAY_WAY_CD, '') WHEN '00' THEN ISNULL(TSP.PAY_AMT, 0) ELSE 0 END), 0) CASH_AMT \n";
sQuery += " , ISNULL(SUM(CASE ISNULL(TSP.PAY_WAY_CD, '') WHEN '02' THEN (CASE WHEN ISNULL(TSP.OCCUR_ENTRY_18, '') = '20' THEN ISNULL(TSP.PAY_AMT, 0) ELSE 0 END) ELSE 0 END), 0) CARD_UN_SUM \n";
sQuery += " , ISNULL(SUM(CASE ISNULL(TSP.PAY_WAY_CD, '') WHEN '02' THEN (CASE WHEN ISNULL(TSP.OCCUR_ENTRY_18, '') <> '20' THEN ISNULL(TSP.PAY_AMT, 0) ELSE 0 END) ELSE 0 END), 0) CARD_20_SUM \n";
sQuery += " , ISNULL(SUM(CASE ISNULL(TSP.PAY_WAY_CD, '') WHEN '00' THEN 0 \n";
sQuery += " WHEN '02' THEN 0 \n";
sQuery += " ELSE ISNULL(TSP.PAY_AMT, 0) END), 0) ETC_SUM \n";
sQuery += " , ISNULL(SUM(TSH.TOTDC_AMT), 0) TOTDC_AMT \n";
sQuery += " , ISNULL(SUM(TSH.NET_SALE_AMT), 0) SALE_AMT \n";
sQuery += " FROM POSLOG..TR_SALE_HEADER TSH \n";
sQuery += " LEFT JOIN POSLOG..TR_SALE_PAY TSP \n";
sQuery += " ON TSP.CMP_CD = TSH.CMP_CD \n";
sQuery += " AND TSP.SALE_DT = TSH.SALE_DT \n";
sQuery += " AND TSP.STOR_CD = TSH.STOR_CD \n";
sQuery += " AND TSP.POS_NO = TSH.POS_NO \n";
sQuery += " AND TSP.TRADE_NO = TSH.TRADE_NO \n";
sQuery += " AND TSP.CANCEL_DIV = '0' \n";
sQuery += " WHERE \n";
sQuery += " TSH.CMP_CD = '" + CmUtil.GetDataRowStr(dr, "CMP_CD") + "' \n";
sQuery += " AND TSH.SALE_DT = '" + CmUtil.GetDataRowStr(dr, "SALE_DT") + "' \n";
sQuery += " AND TSH.STOR_CD = '" + CmUtil.GetDataRowStr(dr, "STOR_CD") + "' \n";
sQuery += " AND TSH.POS_NO = '" + CmUtil.GetDataRowStr(dr, "POS_NO") + "' \n";
sQuery += " AND TSH.TRADE_NO = '" + CmUtil.GetDataRowStr(dr, "TRADE_NO") + "' \n";
sQuery += " AND TSH.TRAIN_MODE_YN = '0' \n";
sQuery += " AND TSH.TRADE_KINDPER = '00' \n";
sQuery += " GROUP BY \n";
sQuery += " TSH.CMP_CD \n";
sQuery += " , TSH.SALE_DT \n";
sQuery += " , TSH.STOR_CD \n";
sQuery += " , TSH.POS_NO \n";
sQuery += " , TSH.TRADE_NO \n";
sQuery += " , TSH.TRADE_DIV \n";
sQuery += " , TSH.PAY_TIME \n";
sQuery = sQuery.Replace("\t", " ");
// 조회
if (sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtData) == UserCom.OK)
{
m_sSendData = "";
foreach (DataRow dri in dtData.Rows)
{
double nTranDiv = 1;
if (CmUtil.GetDataRowStr(dri, "TRADE_DIV") == ItemConst.PAY_CANCEL_DIV.CANCEL) nTranDiv = -1;
m_sSendData += "<request>";
m_sSendData += "<cmd>SENDSALE</cmd>"; // doc
m_sSendData += "<code>" + m_cPosStatus.Mst.JOIN_STOR_CD + "</code>"; // 점포코드
m_sSendData += "<tillid>" + CmUtil.GetDataRowStr(dri, "POS_NO").PadLeft(3, '0') + "</tillid>"; // POS번호
sDocNo = "S" + CmUtil.MidH(CmUtil.GetDataRowStr(dri, "SALE_DT"), 2, 6) + CmUtil.MidH(CmUtil.GetDataRowStr(dri, "TRADE_NO"), 2, 3);
m_sSendData += "<docno>" + sDocNo + "</docno>"; // 증빙서류
m_sSendData += "<plu>" + m_cPosStatus.Mst.JOIN_ITEM_CD + "</plu>"; // 상품코드
m_sSendData += "<vipcode>" + "" + "</vipcode>"; // vip 코드
sSaleDate = string.Format("0:0000/00/00", CmUtil.DoubleParse(CmUtil.GetDataRowStr(dri, "SALE_DT"))) + " " + CmUtil.MidH(CmUtil.GetDataRowStr(dri, "PAY_TIME"), 0, 4);
m_sSendData += "<txdate>" + sSaleDate + "</txdate>"; // 매출일시
m_sSendData += "<ch>" + CmUtil.DoubleMultiplication(DoubleParse(CmUtil.GetDataRowStr(dri, "CASH_AMT")), nTranDiv) + "</ch>"; // 현금
m_sSendData += "<ci>" + CmUtil.DoubleMultiplication(DoubleParse(CmUtil.GetDataRowStr(dri, "CARD_UN_SUM")), nTranDiv) + "</ci>"; // 내부카드
m_sSendData += "<co>" + CmUtil.DoubleMultiplication(DoubleParse(CmUtil.GetDataRowStr(dri, "CARD_20_SUM")), nTranDiv) + "</co>"; // 외부카드
m_sSendData += "<ot>" + CmUtil.DoubleMultiplication(DoubleParse(CmUtil.GetDataRowStr(dri, "ETC_SUM")), nTranDiv) + "</ot>"; // 기타
m_sSendData += "<ttldiscount>" + CmUtil.DoubleMultiplication(DoubleParse(CmUtil.GetDataRowStr(dri, "TOTDC_AMT")), nTranDiv) + "</ttldiscount>"; // 할인
m_sSendData += "<netamt>" + CmUtil.DoubleMultiplication(DoubleParse(CmUtil.GetDataRowStr(dri, "SALE_AMT")), nTranDiv) + "</netamt>"; // 총금액
m_sSendData += "</request>";
m_sSendData += PosConst.CRLF;
}
sRet = UserCom.RST_OK;
}
}
catch (Exception ex)
{
UserLog.WriteLogFile(UserCom.LOG_DEBUG,
System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명)
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + // Class Name (Class Name (클래스명))
System.Reflection.MethodBase.GetCurrentMethod().Name + "()", // Function Name (Function Name (함수명))
ex.Message);
}
return sRet;
}
#endregion
#endregion
#region 7.
#region SIN_01_Make
/// <summary>
/// SIN_01_Make 생성
/// </summary>
/// <param name="dr"></param>
/// <returns></returns>
private string SIN_01_Make(DataRow dr)
{
string sQuery = string.Empty;
string sRet = UserCom.RST_ERR;
DataTable dtData = new DataTable();
double nTotalAmt = 0;
double nSubAmt = 0;
double nSumDCAmt = 0;
double nSumTax = 0;
double nDCAmt = 0;
try
{
m_sSendData = "";
sQuery = "";
sQuery += " SELECT \n";
sQuery += " TSH.CMP_CD \n";
sQuery += " , TSH.STOR_CD \n";
sQuery += " , TSH.POS_NO \n" ;
sQuery += " , TSH.SALE_DT \n" ;
sQuery += " , TSH.PAY_TIME \n" ;
sQuery += " , TSH.TRADE_NO \n" ;
sQuery += " , TSH.TRADE_DIV \n" ;
sQuery += " , TSD.ITEM_PLU_CD ITEM_CD \n";
sQuery += " , ISNULL(MI.SHTCUT_ITEMNM, '') ITEM_NM \n";
sQuery += " , ISNULL(TSD.SALE_QTY, 0) SALE_QTY \n";
sQuery += " , ISNULL(TSD.BILL_AMT, 0) BILL_AMT \n";
sQuery += " , ISNULL(TSD.APPLY_TAX_AMT, 0) APPLY_TAX_AMT \n";
sQuery += " , ISNULL(TSD.ITEM_DC_AMT, 0) \n";
sQuery += " + ISNULL(TSD.SUM_DC_AMT, 0) \n";
sQuery += " + ISNULL(TSD.CPI_DC_AMT, 0) \n";
sQuery += " + ISNULL(TSD.COOP_CARD_DC_AMT, 0) \n";
sQuery += " + ISNULL(TSD.POINT_DC_AMT, 0) \n";
sQuery += " + ISNULL(TSD.CPN_DC_AMT, 0) \n";
sQuery += " + ISNULL(TSD.EMP_DC_AMT, 0) \n";
sQuery += " + ISNULL(TSD.SET_DC_AMT, 0) \n";
sQuery += " + ISNULL(TSD.ETC_DC_AMT, 0) \n";
sQuery += " + ISNULL(TSD.EXCEP_DC_AMT, 0) ITEM_DC_AMT \n";
sQuery += " , 0 TAX1 \n";
sQuery += " , '1' TAX2 \n";
sQuery += " , 0 TAX3 \n";
sQuery += " , 0 SERV1 \n";
sQuery += " , 0 SERV2 \n";
sQuery += " , (SELECT ISNULL(MIC.ITEM_CLSS_NM, '') ITEM_CLSS_NM \n";
sQuery += " FROM POSMST..MST_ITEM_CLSS MIC \n";
sQuery += " WHERE \n";
sQuery += " MIC.CMP_CD = MI.CMP_CD \n";
sQuery += " AND MIC.ITEM_CLSS_TYPE_CD = '00' \n";
sQuery += " AND MIC.ITEM_CLSS_CD = MI.L_CLSS \n";
sQuery += " AND MIC.ITEM_CLSS_LVL_TYPE = 'L' \n";
sQuery += " AND MIC.USE_YN = '" + PosConst.MST_USE_YN.YES + "') ITEM_CLSS_NM \n";
sQuery += " FROM POSLOG..TR_SALE_HEADER TSH \n";
sQuery += " LEFT JOIN POSLOG..TR_SALE_DETAIL TSD \n";
sQuery += " ON TSD.CMP_CD = TSH.CMP_CD \n";
sQuery += " AND TSD.SALE_DT = TSH.SALE_DT \n";
sQuery += " AND TSD.STOR_CD = TSH.STOR_CD \n";
sQuery += " AND TSD.POS_NO = TSH.POS_NO \n";
sQuery += " AND TSD.TRADE_NO = TSH.TRADE_NO \n";
sQuery += " AND TSD.CANCEL_DIV = '0' \n";
sQuery += " LEFT JOIN POSMST..MST_ITEM MI \n";
sQuery += " ON MI.CMP_CD = TSD.CMP_CD \n";
sQuery += " AND MI.STOR_CD = TSD.STOR_CD \n";
sQuery += " AND MI.SUB_STOR_CD = TSD.SUB_SHOP_CD \n";
sQuery += " AND MI.ITEM_CD = TSD.ITEM_PLU_CD \n";
sQuery += " AND MI.USE_YN = '" + PosConst.MST_USE_YN.YES + "' \n";
sQuery += " WHERE \n";
sQuery += " TSH.CMP_CD = '" + CmUtil.GetDataRowStr(dr, "CMP_CD") + "' \n";
sQuery += " AND TSH.SALE_DT = '" + CmUtil.GetDataRowStr(dr, "SALE_DT") + "' \n";
sQuery += " AND TSH.STOR_CD = '" + CmUtil.GetDataRowStr(dr, "STOR_CD") + "' \n";
sQuery += " AND TSH.POS_NO = '" + CmUtil.GetDataRowStr(dr, "POS_NO") + "' \n";
sQuery += " AND TSH.TRADE_NO = '" + CmUtil.GetDataRowStr(dr, "TRADE_NO") + "' \n";
sQuery += " AND TSH.TRAIN_MODE_YN = '0' \n";
sQuery += " AND TSH.TRADE_KINDPER = '00' \n";
sQuery += " ORDER BY \n";
sQuery += " TSH.CMP_CD \n";
sQuery += " , TSH.SALE_DT \n";
sQuery += " , TSH.STOR_CD \n";
sQuery += " , TSH.POS_NO \n";
sQuery += " , TSH.TRADE_NO \n";
sQuery += " , TSH.TRADE_DIV \n";
sQuery += " , TSD.SEQ \n";
sQuery = sQuery.Replace("\t", " ");
// 조회
if (sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtData) == UserCom.OK)
{
foreach (DataRow dri in dtData.Rows)
{
double nTranDiv = 1;
if (CmUtil.GetDataRowStr(dri, "TRADE_DIV") == ItemConst.PAY_CANCEL_DIV.CANCEL) nTranDiv = -1;
nSubAmt = CmUtil.DoubleAdd(nSubAmt, CmUtil.DoubleMultiplication(DoubleParse(CmUtil.GetDataRowStr(dri, "BILL_AMT")), nTranDiv));
nDCAmt = CmUtil.DoubleMultiplication(DoubleParse(CmUtil.GetDataRowStr(dri, "ITEM_DC_AMT")), nTranDiv);
nSumDCAmt = CmUtil.DoubleAdd(nSumDCAmt, nDCAmt);
nSumTax = CmUtil.DoubleAdd(nSumTax, CmUtil.DoubleMultiplication(DoubleParse(CmUtil.GetDataRowStr(dri, "APPLY_TAX_AMT")), nTranDiv));
nTotalAmt = CmUtil.DoubleAdd(nTotalAmt, CmUtil.DoubleMultiplication(DoubleParse(CmUtil.GetDataRowStr(dri, "BILL_AMT")), nTranDiv));
nTotalAmt = CmUtil.DoubleAdd(nTotalAmt, CmUtil.DoubleMultiplication(DoubleParse(CmUtil.GetDataRowStr(dri, "APPLY_TAX_AMT")), nTranDiv));
m_sSendData += "I"; // 구분
m_sSendData += "," + CmUtil.GetDataRowStr(dri, "TRADE_NO"); // 거래번호
m_sSendData += "," + CmUtil.GetDataRowStr(dri, "ITEM_CD"); // 상품코드
m_sSendData += "," + CmUtil.GetDataRowStr(dri, "ITEM_NM"); // 상품명
m_sSendData += "," + IntParse(CmUtil.GetDataRowStr(dri, "SALE_QTY")); // 수량
m_sSendData += "," + CmUtil.DoubleMultiplication(DoubleParse(CmUtil.GetDataRowStr(dri, "BILL_AMT")), nTranDiv); // 판매금액
m_sSendData += "," + nDCAmt; // 할인금액
if (nDCAmt > 0)
m_sSendData += "," + "1"; // 할인구분 (1:할인, 0:미할인)
else
m_sSendData += "," + "0";
m_sSendData += "," + DoubleParse(CmUtil.GetDataRowStr(dri, "TAX1")); // 봉사료
m_sSendData += "," + DoubleParse(CmUtil.GetDataRowStr(dri, "TAX2")); // 부가세율
m_sSendData += "," + DoubleParse(CmUtil.GetDataRowStr(dri, "TAX3")); // 고정
m_sSendData += "," + DoubleParse(CmUtil.GetDataRowStr(dri, "SERV1")); // 고정
m_sSendData += "," + DoubleParse(CmUtil.GetDataRowStr(dri, "SERV1")); // 고정
m_sSendData += "," + CmUtil.GetDataRowStr(dri, "ITEM_CLSS_NM"); // 분류명
m_sSendData += PosConst.CRLF;
}
// 계
if (m_sSendData.Trim() != "")
{
m_sSendData += "D" + "," + "subtotal" + "," + nSubAmt + PosConst.CRLF; // 순매출
m_sSendData += "D" + "," + "disc" + "," + nSumDCAmt + PosConst.CRLF; // 할인
m_sSendData += "D" + "," + "tax2" + "," + nSumTax + PosConst.CRLF; // 부가세
m_sSendData += "D" + "," + "total" + "," + nTotalAmt; // 총매출
}
sRet = UserCom.RST_OK;
}
}
catch (Exception ex)
{
UserLog.WriteLogFile(UserCom.LOG_DEBUG,
System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명)
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + // Class Name (Class Name (클래스명))
System.Reflection.MethodBase.GetCurrentMethod().Name + "()", // Function Name (Function Name (함수명))
ex.Message);
}
return sRet;
}
#endregion
#endregion
#region I/F POST방식 Request
/// <summary>
/// I/F POST방식 Request
/// </summary>
/// <param name="sUrl"></param>
/// <param name="sSendData"></param>
/// <param name="sResCD"></param>
/// <param name="sResMsg"></param>
/// <param name="sResvData"></param>
/// <returns></returns>
public string HttpPOST_SendReceive(string sIFDiv, string sUrl, string sSendData, ref string sResCD, ref string sResMsg, ref string sResData)
{
string sRet = UserCom.RST_ERR;
string sRespString = string.Empty;
string[] sResponeData = new string[4];
try
{
if (sIFDiv == ItemConst.TranInterfaceOutside.IF_CHN_01)
{
// 무역센터
sResponeData[0] = "application/soap+xml"; // ContentType
sResponeData[1] = "postsalescreate"; // SelectNodes
sResponeData[2] = "responsecode"; // res cd
sResponeData[3] = "responsemessage"; // res msg
}
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(sUrl);
byte[] reqByte = Encoding.UTF8.GetBytes(sSendData);
req.Method = "POST";
req.ContentType = sResponeData[0];
req.ContentLength = reqByte.Length;
// create our stream to send
Stream webDataStream = req.GetRequestStream();
webDataStream.Write(reqByte, 0, reqByte.Length);
// get thre response from our stream
WebResponse resp = req.GetResponse();
webDataStream = resp.GetResponseStream();
// convert the result into a string
StreamReader respStreamReader = new StreamReader(webDataStream);
string respFromServer = respStreamReader.ReadToEnd();
respStreamReader.Close();
// 파싱
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(respFromServer);
XmlNodeList xnList = xmlDoc.SelectNodes(sResponeData[1]);
foreach (XmlNode xn in xnList)
{
if (sIFDiv == ItemConst.TranInterfaceOutside.IF_CHN_01)
{
sResCD = xn[sResponeData[2]].InnerText;
sResMsg = xn[sResponeData[3]].InnerText;
sResData = respFromServer;
}
else
{
sResData = respFromServer;
}
}
sRet = UserCom.RST_OK;
}
catch(Exception ex)
{
UserLog.WriteLogFile(UserCom.LOG_ERROR,
System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
System.Reflection.MethodBase.GetCurrentMethod().Name + "()",
ex.ToString());
}
return sRet;
}
#endregion
#region
/// <summary>
/// 전송 상태값 저장
/// </summary>
/// <param name="dr"></param>
/// <param name="sIFDiv"></param>
/// <param name="sResCD"></param>
/// <param name="sResMsg"></param>
/// <param name="sSData"></param>
/// <param name="sRData"></param>
/// <returns></returns>
private string IFSendFlgUpdate(DataRow dr, string sIFDiv, string sResCD, string sResMsg, string sSData, string sRData, string sSendYn)
{
int iRet = UserCom.NG;
string sRet = UserCom.RST_ERR;
string sQuery = string.Empty;
try
{
if (CmUtil.GetDataRowStr(dr, "CMP_CD").Trim() == "") return sRet;
sResMsg = sResMsg.Replace("'", "`");
sSData = sSData.Replace("'", "`");
sRData = sRData.Replace("'", "`");
sQuery = "";
sQuery += "BEGIN \n";
sQuery += " UPDATE POSLOG..LOG_SALE_IF \n";
sQuery += " SET \n";
sQuery += " RES_CD = '" + sResCD.Trim() + "' \n";
sQuery += " , RES_MSG = N'" + sResMsg.Trim() + "' \n";
sQuery += " , SDATA = N'" + sSData.Trim() + "' \n";
sQuery += " , RDATA = N'" + sRData.Trim() + "' \n";
sQuery += " , SEND_YN = '" + sSendYn + "' \n";
sQuery += " , UPD_DATE = CONVERT(VARCHAR(8), GETDATE(), 112) + REPLACE(CONVERT(VARCHAR(8), GETDATE(), 114), ':', '') \n";
sQuery += " WHERE \n";
sQuery += " CMP_CD = '" + CmUtil.GetDataRowStr(dr, "CMP_CD") + "' \n";
sQuery += " AND SALE_DT = '" + CmUtil.GetDataRowStr(dr, "SALE_DT")+ "' \n";
sQuery += " AND STOR_CD = '" + CmUtil.GetDataRowStr(dr, "STOR_CD") + "' \n";
sQuery += " AND POS_NO = '" + CmUtil.GetDataRowStr(dr, "POS_NO") + "' \n";
sQuery += " AND TRADE_NO = '" + CmUtil.GetDataRowStr(dr, "TRADE_NO") + "' \n";
sQuery += " AND IF_DIV = '" + sIFDiv.Trim() + "' \n";
sQuery += " \n";
sQuery += " IF @@ROWCOUNT = 0 \n";
sQuery += " BEGIN \n";
sQuery += " INSERT INTO POSLOG..LOG_SALE_IF \n";
sQuery += " (CMP_CD, SALE_DT, STOR_CD, POS_NO, TRADE_NO, IF_DIV, RES_CD, RES_MSG, SDATA, RDATA, SEND_YN, REG_DATE) \n";
sQuery += " VALUES( \n";
sQuery += " '" + CmUtil.GetDataRowStr(dr, "CMP_CD") + "' \n";
sQuery += " , '" + CmUtil.GetDataRowStr(dr, "SALE_DT") + "' \n";
sQuery += " , '" + CmUtil.GetDataRowStr(dr, "STOR_CD") + "' \n";
sQuery += " , '" + CmUtil.GetDataRowStr(dr, "POS_NO") + "' \n";
sQuery += " , '" + CmUtil.GetDataRowStr(dr, "TRADE_NO") + "' \n";
sQuery += " , '" + sIFDiv.Trim() + "' \n";
sQuery += " , '" + sResCD.Trim() + "' \n";
sQuery += " , N'" + sResMsg.Trim() + "' \n";
sQuery += " , N'" + sSData.Trim() + "' \n";
sQuery += " , N'" + sRData.Trim() + "' \n";
sQuery += " , '" + sSendYn.Trim() + "' \n";
sQuery += " , CONVERT(VARCHAR(8), GETDATE(), 112) + REPLACE(CONVERT(VARCHAR(8), GETDATE(), 114), ':', '') \n";
sQuery += " ) \n";
sQuery += " END \n";
sQuery += "END \n";
sQuery = sQuery.Replace("\t", " ");
iRet = sqlDb.DBExecuteNonQuery(sQuery, CommandType.Text, (System.Data.SqlClient.SqlParameter[])null);
if (iRet > 0 )
{
sRet = UserCom.RST_OK;
}
}
catch (Exception ex)
{
UserLog.WriteLogFile(UserCom.LOG_ERROR,
System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명)
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + // Class Name (Class Name (클래스명))
System.Reflection.MethodBase.GetCurrentMethod().Name + "()", // Function Name (Function Name (함수명))
ex.Message);
}
return sRet;
}
#endregion
#region 90
/// <summary>
/// 90 이전 데이터 삭제
/// </summary>
/// <returns></returns>
private string IFSendDataDelete()
{
int iRet = UserCom.NG;
string sRet = UserCom.RST_ERR;
string sQuery = string.Empty;
try
{
sQuery = "";
sQuery += " DELETE POSLOG..LOG_SALE_IF \n";
sQuery += " WHERE \n";
sQuery += " CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n";
sQuery += " AND SALE_DT <= CONVERT(VARCHAR(8), DATEADD(day, -90, GETDATE()), 112) \n";
sQuery += " AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n";
sQuery += " AND SEND_YN = '1' \n";
sQuery = sQuery.Replace("\t", " ");
iRet = sqlDb.DBExecuteNonQuery(sQuery, CommandType.Text, (System.Data.SqlClient.SqlParameter[])null);
sRet = UserCom.RST_OK;
}
catch (Exception ex)
{
UserLog.WriteLogFile(UserCom.LOG_ERROR,
System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명)
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + // Class Name (Class Name (클래스명))
System.Reflection.MethodBase.GetCurrentMethod().Name + "()", // Function Name (Function Name (함수명))
ex.Message);
}
return sRet;
}
#endregion
#region
/// <summary>
/// 파일 저장
/// </summary>
/// <param name="sFullPath"></param>
/// <param name="sFileName"></param>
/// <param name="sFileData"></param>
/// <returns></returns>
public bool WriteFile(string sFullPath, string sFileName, string sFileData)
{
bool bRet = false;
try
{
// 디렉토리 생성
CmUtil.CreateDirectory(sFullPath);
// 파일 저장
FileStream fs = new FileStream(sFileName, FileMode.Append, FileAccess.Write);
StreamWriter sw = new StreamWriter(fs, System.Text.Encoding.Default);
try
{
sw.BaseStream.Seek(0, SeekOrigin.End);
sw.WriteLine(sFileData);
sw.Flush();
bRet = true;
}
catch
{
}
finally
{
sw.Close();
fs.Close();
}
}
catch
{
return false;
}
return bRet;
}
#endregion
#region xml
/// <summary>
/// XMLSendSocket
/// </summary>
/// <param name="sHostIp"></param>
/// <param name="nPort"></param>
/// <param name="sSendData"></param>
/// <returns></returns>
private string XMLSendSocket(String sHostIp, int nPort, String sSendData, ref string sRecvData)
{
string sRet = UserCom.RST_ERR;
try
{
TcpClient client = new TcpClient();
client.Connect(sHostIp, nPort);
if (client == null) return sRet;
NetworkStream nsStream = client.GetStream();
StreamWriter writer = new StreamWriter(nsStream, Encoding.UTF8);
writer.AutoFlush = false;
writer.Write(sSendData);
writer.Flush();
StreamReader reader = new StreamReader(nsStream, Encoding.UTF8);
sRecvData = reader.ReadLine();
nsStream.Close();
sRet = UserCom.RST_OK;
}
catch (Exception ex)
{
UserLog.WriteLogFile(UserCom.LOG_ERROR,
System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명)
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + // Class Name (Class Name (클래스명))
System.Reflection.MethodBase.GetCurrentMethod().Name + "()", // Function Name (Function Name (함수명))
ex.Message);
}
return sRet;
}
#endregion
#region xml
/// <summary>
/// xml 파싱
/// </summary>
/// <param name="sIFDiv"></param>
/// <param name="sXMLData"></param>
/// <param name="sSelectNode"></param>
/// <param name="sResCD"></param>
/// <param name="sResMsg"></param>
/// <returns></returns>
private string XmlParser(string sIFDiv, string sXMLData, string sSelectNode, ref string sResCD, ref string sResMsg)
{
string sRet = UserCom.RST_ERR;
try
{
sResCD = "99";
sResMsg = "not xml data";
if (sXMLData.Trim() == "") return sRet;
// 파싱
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(sXMLData);
XmlNodeList xnList = xmlDoc.SelectNodes(sSelectNode);
foreach (XmlNode xn in xnList)
{
if (sIFDiv == ItemConst.TranInterfaceOutside.IF_CHN_05)
{
sResCD = xn["code"].InnerText;
sResMsg = xn["message"].InnerText;
}
}
sRet = UserCom.RST_OK;
}
catch (Exception ex)
{
UserLog.WriteLogFile(UserCom.LOG_ERROR,
System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명)
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + // Class Name (Class Name (클래스명))
System.Reflection.MethodBase.GetCurrentMethod().Name + "()", // Function Name (Function Name (함수명))
ex.Message);
}
return sRet;
}
#endregion
#region ini ()
/// <summary>
/// 처리정보 ini 저장 (왕진활현)
/// </summary>
/// <param name="dr"></param>
/// <returns></returns>
private string SavePOSInfoini(DataRow dr)
{
string sRet = UserCom.RST_ERR;
string sFilePath = @"C:\HOME\IMPORT\";
string sFileName = "POSINFO.ini";
try
{
CmUtil.CreateDirectory(sFilePath);
WinAPI.WritePrivateProfileString("POSINFO", "StoreCode", m_cPosStatus.Mst.JOIN_STOR_CD, sFilePath + sFileName); // 점포코드
WinAPI.WritePrivateProfileString("POSINFO", "Tillid", CmUtil.GetDataRowStr(dr, "POS_NO"), sFilePath + sFileName); // POS번호
WinAPI.WritePrivateProfileString("POSINFO", "ItemCode", m_cPosStatus.Mst.JOIN_ITEM_CD, sFilePath + sFileName); // 상품코드
WinAPI.WritePrivateProfileString("POSINFO", "PathName", sFilePath, sFilePath + sFileName); // 경로
WinAPI.WritePrivateProfileString("POSINFO", "FileName", "possalesdata.txt", sFilePath + sFileName); // 상품코드
WinAPI.WritePrivateProfileString("DATAINFO", "LASTTXDATE", CmUtil.GetDataRowStr(dr, "SALE_DT"), sFilePath + sFileName); // 거래일자
WinAPI.WritePrivateProfileString("DATAINFO", "LASTDOCNO", CmUtil.GetDataRowStr(dr, "TRADE_NO"), sFilePath + sFileName); // 최종거래번호
// POSINFO.INI 파일을 CapitaInterface.zip 파일로 압축
bool bRet = CmUtil.ZipFile(sFilePath, sFilePath + "CapitaInterface.zip", "POSINFO.ini");
if (bRet == true) sRet = UserCom.RST_OK;
}
catch (Exception ex)
{
UserLog.WriteLogFile(UserCom.LOG_ERROR,
System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명)
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + // Class Name (Class Name (클래스명))
System.Reflection.MethodBase.GetCurrentMethod().Name + "()", // Function Name (Function Name (함수명))
ex.Message);
}
return sRet;
}
#endregion
#region
/// <summary>
/// 문자열의 숫자(Int)로 변환
/// </summary>
/// <param name="sValue"></param>
/// <returns></returns>
public int IntParse(string sValue)
{
return (int)DoubleParse(sValue);
}
/// <summary>
/// 문자열의 숫자(Long)로 변환
/// </summary>
/// <param name="sValue"></param>
/// <returns></returns>
public long LongParse(string sValue)
{
return (long)DoubleParse(sValue);
}
/// <summary>
/// 문자열의 숫자(Double)로 변환
/// </summary>
/// <param name="sValue"></param>
/// <returns></returns>
public double DoubleParse(string sValue)
{
double dValue = 0;
try
{
if (sValue.Trim().Length > 0)
{
// 화폐 문자열 이면 글로벌 변환 처리
if (sValue.Trim().Contains(m_cPosStatus.Global.m_stCultureMaster.strGroupingSymbol) == true || sValue.Trim().Contains(m_cPosStatus.Global.m_stCultureMaster.strDecimalSymbol) == true)
dValue = m_cPosStatus.Global.CurrencyTONumeric(sValue.Trim());
else
dValue = double.Parse(sValue.Trim());
}
}
catch { }
return dValue;
}
#endregion
}
}