|
|
@@ -20,7 +20,7 @@ CPosPrinter::~CPosPrinter()
|
|
|
bool CPosPrinter::InitShouyin()
|
|
|
{
|
|
|
//遍历USB设备,找到POS打印机路径
|
|
|
-
|
|
|
+
|
|
|
//设备路径
|
|
|
TCHAR* szDevicePath[MAX_DEVICE];
|
|
|
|
|
|
@@ -37,7 +37,7 @@ bool CPosPrinter::InitShouyin()
|
|
|
|
|
|
//取设备路径
|
|
|
int nDevice = GetDevicePath((LPGUID)&USB_GUID, szDevicePath);
|
|
|
- LOG_INFO("nDevice:" << nDevice);
|
|
|
+ LOG_INFO("nDevice:" << nDevice);
|
|
|
int i = 0;
|
|
|
|
|
|
while(i < nDevice)
|
|
|
@@ -62,11 +62,12 @@ bool CPosPrinter::InitShouyin()
|
|
|
|
|
|
void CPosPrinter::PrintWaimaiOrderShouyin(CWaimaiOrder& order)
|
|
|
{
|
|
|
- //设置模式,后面输出数据不会错
|
|
|
- m_type = 1;
|
|
|
+ //设置模式,后面输出数据不会错
|
|
|
+ m_type = 1;
|
|
|
|
|
|
//初始化收银打印机的链接
|
|
|
bool ret = InitShouyin();
|
|
|
+
|
|
|
if(ret == false)
|
|
|
{
|
|
|
LOG_INFO("打开收银打印机端口失败!");
|
|
|
@@ -112,8 +113,8 @@ void CPosPrinter::PrintWaimaiOrderShouyin(CWaimaiOrder& order)
|
|
|
POS_FeedLine();
|
|
|
|
|
|
//订单号
|
|
|
- string order_no = "订单号:" + CLewaimaiString::UTF8ToANSI(order.m_order_no);
|
|
|
- POS_TextOut(order_no);
|
|
|
+ string order_num = "订单号:" + CLewaimaiString::UTF8ToANSI(order.m_order_num);
|
|
|
+ POS_TextOut(order_num);
|
|
|
POS_FeedLine();
|
|
|
|
|
|
//姓名
|
|
|
@@ -225,15 +226,17 @@ void CPosPrinter::PrintWaimaiOrderShouyin(CWaimaiOrder& order)
|
|
|
|
|
|
std::string firstLine = m_names[0];
|
|
|
|
|
|
- int nGuige;
|
|
|
- if (guige == "58")
|
|
|
- {
|
|
|
- nGuige = 1;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- nGuige = 2;
|
|
|
- }
|
|
|
+ int nGuige;
|
|
|
+
|
|
|
+ if(guige == "58")
|
|
|
+ {
|
|
|
+ nGuige = 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ else
|
|
|
+ {
|
|
|
+ nGuige = 2;
|
|
|
+ }
|
|
|
|
|
|
std::string priceShow = HandleFoodItemPrice(food_price, nGuige);
|
|
|
std::string quantityShow = HandleFoodQuantity(quantity, nGuige);
|
|
|
@@ -373,8 +376,8 @@ void CPosPrinter::PrintWaimaiOrderShouyin(CWaimaiOrder& order)
|
|
|
|
|
|
void CPosPrinter::PrintWaimaiOrderChufang(CWaimaiOrder& order)
|
|
|
{
|
|
|
- //设置模式,后面输出数据不会错
|
|
|
- m_type = 2;
|
|
|
+ //设置模式,后面输出数据不会错
|
|
|
+ m_type = 2;
|
|
|
|
|
|
//读取厨房打印机信息
|
|
|
std::vector<ChufangPrinter> total_printers = CSetting::getChufangPrints();
|
|
|
@@ -482,20 +485,22 @@ void CPosPrinter::PrintWaimaiOrderChufang(CWaimaiOrder& order)
|
|
|
}
|
|
|
|
|
|
std::string firstLine = m_names[0];
|
|
|
-
|
|
|
- int nGuige;
|
|
|
- if (guige == "58")
|
|
|
- {
|
|
|
- nGuige = 1;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- nGuige = 2;
|
|
|
- }
|
|
|
-
|
|
|
- std::string priceShow = HandleFoodItemPrice(food_price, nGuige);
|
|
|
- std::string quantityShow = HandleFoodQuantity(quantity, nGuige);
|
|
|
- std::string priceTotalShow = HandleFoodTotalPrice(food_total_price, nGuige);
|
|
|
+
|
|
|
+ int nGuige;
|
|
|
+
|
|
|
+ if(guige == "58")
|
|
|
+ {
|
|
|
+ nGuige = 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ else
|
|
|
+ {
|
|
|
+ nGuige = 2;
|
|
|
+ }
|
|
|
+
|
|
|
+ std::string priceShow = HandleFoodItemPrice(food_price, nGuige);
|
|
|
+ std::string quantityShow = HandleFoodQuantity(quantity, nGuige);
|
|
|
+ std::string priceTotalShow = HandleFoodTotalPrice(food_total_price, nGuige);
|
|
|
|
|
|
std::string firstLineShow = firstLine + priceShow + quantityShow + priceTotalShow;
|
|
|
|
|
|
@@ -526,6 +531,7 @@ void CPosPrinter::PrintWaimaiOrderChufang(CWaimaiOrder& order)
|
|
|
|
|
|
POS_CutPaper();
|
|
|
}
|
|
|
+
|
|
|
else
|
|
|
{
|
|
|
POS_Reset();
|
|
|
@@ -636,7 +642,7 @@ void CPosPrinter::PrintWaimaiOrderChufang(CWaimaiOrder& order)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- m_socket.close();
|
|
|
+ m_socket.close();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -658,9 +664,9 @@ int CPosPrinter::GetDevicePath(LPGUID lpGuid, LPTSTR* pszDevicePath)
|
|
|
int nTotle;
|
|
|
BOOL bResult;
|
|
|
|
|
|
- //这2个字符串,用于根据usb的名字对比是否为打印机设备
|
|
|
+ //这2个字符串,用于根据usb的名字对比是否为打印机设备
|
|
|
wstring strUSBPrint = TEXT("USB 打印支持");
|
|
|
- wstring strUSBPrint_EN = L"USB Printing Support";
|
|
|
+ wstring strUSBPrint_EN = L"USB Printing Support";
|
|
|
|
|
|
// 取得一个该GUID相关的设备信息集句柄
|
|
|
hDevInfoSet = ::SetupDiGetClassDevs(lpGuid, // class GUID
|
|
|
@@ -715,7 +721,7 @@ int CPosPrinter::GetDevicePath(LPGUID lpGuid, LPTSTR* pszDevicePath)
|
|
|
lstrcpy(buf, _T("Unknown"));
|
|
|
}
|
|
|
|
|
|
- //LOG_INFO("buf:" << buf);
|
|
|
+ //LOG_INFO("buf:" << buf);
|
|
|
|
|
|
//是否是要找的设备类型
|
|
|
if(_tcscmp(buf, strUSBPrint.c_str()) != 0 && _tcscmp(buf, strUSBPrint_EN.c_str()) != 0)
|
|
|
@@ -723,7 +729,7 @@ int CPosPrinter::GetDevicePath(LPGUID lpGuid, LPTSTR* pszDevicePath)
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
- //LOG_INFO("找到打印的USB设备!");
|
|
|
+ //LOG_INFO("找到打印的USB设备!");
|
|
|
|
|
|
ifData.cbSize = sizeof(ifData);
|
|
|
// 枚舉符合該GUID的設備接口
|
|
|
@@ -778,16 +784,17 @@ int CPosPrinter::WriteData(string msg)
|
|
|
|
|
|
else
|
|
|
{
|
|
|
- try
|
|
|
- {
|
|
|
- m_socket.write_some(boost::asio::buffer(msg.c_str(), msg.length()));
|
|
|
- }
|
|
|
- catch (const std::exception& e)
|
|
|
- {
|
|
|
- LOG_INFO(e.what());
|
|
|
- }
|
|
|
-
|
|
|
- return 0;
|
|
|
+ try
|
|
|
+ {
|
|
|
+ m_socket.write_some(boost::asio::buffer(msg.c_str(), msg.length()));
|
|
|
+ }
|
|
|
+
|
|
|
+ catch(const std::exception& e)
|
|
|
+ {
|
|
|
+ LOG_INFO(e.what());
|
|
|
+ }
|
|
|
+
|
|
|
+ return 0;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -801,16 +808,17 @@ int CPosPrinter::WriteBuf(char* buf, int len)
|
|
|
|
|
|
else
|
|
|
{
|
|
|
- try
|
|
|
- {
|
|
|
- m_socket.write_some(boost::asio::buffer(buf, len));
|
|
|
- }
|
|
|
- catch (const std::exception& e)
|
|
|
- {
|
|
|
- LOG_INFO(e.what());
|
|
|
- }
|
|
|
-
|
|
|
- return 0;
|
|
|
+ try
|
|
|
+ {
|
|
|
+ m_socket.write_some(boost::asio::buffer(buf, len));
|
|
|
+ }
|
|
|
+
|
|
|
+ catch(const std::exception& e)
|
|
|
+ {
|
|
|
+ LOG_INFO(e.what());
|
|
|
+ }
|
|
|
+
|
|
|
+ return 0;
|
|
|
}
|
|
|
}
|
|
|
|