Browse Source

修复几个bug

zhangyang 6 years ago
parent
commit
ecc5170e7e

BIN
bin/Win32/Debug/zhipuzi_pos_windows/db/pos.db


+ 5 - 3
bin/Win32/Debug/zhipuzi_pos_windows/skin/setting_chufang_printer_item.xml

@@ -8,12 +8,14 @@
 			<Label name="setting_chufang_printer_guige" width="100" align="center"/>
 			<Label name="setting_chufang_printer_fendan" width="100" align="center"/> 
 			<Label name="setting_chufang_printer_item_fenlei" width="200" align="center"/> 
-			<HorizontalLayout height="80" valign="center">
+			<HorizontalLayout width="300" height="80" valign="center">
 				<Label name="setting_chufang_printer_item_fenlei_ids" width="300" multiline="true" align="center" valign="center"/> 
 			</HorizontalLayout>
 			<HorizontalLayout name="setting_chufang_printer_caozuo" align="center">
-				<Button name="setting_chufang_printer_item_update_btn" align="center" width="26" height="27" normalimage="file='Setting_Btn.png'" hotimage="file='Setting_Btn_Hover.png'" pushedimage="file='Setting_Btn_Active.png'" />
-				<Button name="setting_chufang_printer_item_delete_btn" align="center" width="18" height="18" padding="20,4,0,0" normalimage="file='Delete_Members_Icon.png'" hotimage="file='Delete_Members_Icon_Hover.png'" pushedimage="file='Delete_Members_Icon_Click.png'" />
+				<Control></Control>
+				<Button name="setting_chufang_printer_item_update_btn" align="center" width="26" height="27" padding="20,25,0,0" normalimage="file='Setting_Btn.png'" hotimage="file='Setting_Btn_Hover.png'" pushedimage="file='Setting_Btn_Active.png'" />
+				<Button name="setting_chufang_printer_item_delete_btn" align="center" width="18" height="18" padding="20,29,0,0" normalimage="file='Delete_Members_Icon.png'" hotimage="file='Delete_Members_Icon_Hover.png'" pushedimage="file='Delete_Members_Icon_Click.png'" />
+				<Control></Control>
 			</HorizontalLayout>
 		</HorizontalLayout> 
 	</ListContainerElement> 

BIN
bin/Win32/Debug/zhipuzi_pos_windows/zhipuzi_pos_windows.exe


+ 47 - 22
zhipuzi_pos_windows/network/CMessagePush.cpp

@@ -245,7 +245,7 @@ void CMessagePush::ReceiveMessage()
 
 				}
 
-				AddPinter(order_id, order_no);
+				AddPinter(order_id, order_no, 1);
 			}
 			else if (type == "2")
 			{
@@ -299,17 +299,18 @@ void CMessagePush::AddConfirm(std::string order_id)
     m_confirm_mutex.unlock();
 }
 
-void CMessagePush::AddPinter(std::string order_id, std::string order_no)
+void CMessagePush::AddPinter(std::string order_id, std::string order_no, int print_type)
 {
-    m_printer_mutex.lock();
+	m_printer_mutex.lock();
 
-    WaimaiPinterInfo newPrinter;
-    newPrinter.order_id = order_id;
-    newPrinter.order_no = order_no;
+	WaimaiPinterInfo newPrinter;
+	newPrinter.order_id = order_id;
+	newPrinter.order_no = order_no;
+	newPrinter.print_type = print_type;
 
-    m_printer_queue.push(newPrinter);
+	m_printer_queue.push(newPrinter);
 
-    m_printer_mutex.unlock();
+	m_printer_mutex.unlock();
 }
 
 void CMessagePush::AddShouyinPrinter(CWaimaiOrder order)
@@ -420,28 +421,52 @@ void CMessagePush::HandlePrinter()
         WaimaiPinterInfo printerInfo = m_printer_queue.front();
         std::string order_id = printerInfo.order_id;
         std::string order_no = printerInfo.order_no;
+		int print_type = printerInfo.print_type;
 
         m_printer_queue.pop();
 
         m_printer_mutex.unlock();
 
         CWaimaiOrder order;
-        if(CSetting::GetParam("setting_is_new_waimai_printer") == "1" || CSetting::GetParam("setting_is_new_waimai_chufang_printer") == "1")
-        {
-            order.InitData(order_id, order_no);
-        }
+		if (print_type == 1)
+		{
+			if (CSetting::GetParam("setting_is_new_waimai_printer") == "1" || CSetting::GetParam("setting_is_new_waimai_chufang_printer") == "1")
+			{
+				bool ret = order.InitData(order_id, order_no);
 
-        //判断是否自动打印收银小票
-        if(CSetting::GetParam("setting_is_new_waimai_printer") == "1")
-        {
-            AddShouyinPrinter(order);
-        }
+				if (ret == false)
+				{
+					this->AddPinter(order_id, order_no, print_type);
+					continue;
+				}
+			}
 
-        //判断是否进行自动的厨房打印
-        if(CSetting::GetParam("setting_is_new_waimai_chufang_printer") == "1")
-        {
-            AddChufangPrinter(order);
-        }
+			//判断是否自动打印收银小票
+			if (CSetting::GetParam("setting_is_new_waimai_printer") == "1")
+			{
+				AddShouyinPrinter(order);
+			}
+
+			//判断是否进行自动的厨房打印
+			if (CSetting::GetParam("setting_is_new_waimai_chufang_printer") == "1")
+			{
+				AddChufangPrinter(order);
+			}
+		}
+		else
+		{
+			bool ret = order.InitData(order_id, order_no);
+
+			if (ret == false)
+			{
+				this->AddPinter(order_id, order_no, print_type);
+				continue;
+			}
+
+			AddShouyinPrinter(order);
+
+			AddChufangPrinter(order);
+		}
     }
 
 	AddStopNum();

+ 2 - 1
zhipuzi_pos_windows/network/CMessagePush.h

@@ -20,6 +20,7 @@ class WaimaiPinterInfo
 public:
 	std::string order_id;
 	std::string order_no;
+	int print_type; //打印类型 1:新订单自动打印 2:手动打印
 };
 
 class CMessagePush
@@ -55,7 +56,7 @@ public:
 
 	void AddVoice(int voice_type);
 	void AddConfirm(std::string order_id);
-	void AddPinter(std::string order_id, std::string order_no);
+	void AddPinter(std::string order_id, std::string order_no, int print_type);
 	void AddShouyinPrinter(CWaimaiOrder order);
 	void AddChufangPrinter(CWaimaiOrder order);
 

+ 7 - 1
zhipuzi_pos_windows/order/CWaimaiOrder.cpp

@@ -11,7 +11,7 @@ CWaimaiOrder::~CWaimaiOrder()
 }
 
 //通过订单ID,获取订单详情
-void CWaimaiOrder::InitData(std::string order_id, std::string order_no)
+bool CWaimaiOrder::InitData(std::string order_id, std::string order_no)
 {
 	std::map<string, string> params;
 	params["id"] = order_id;
@@ -22,6 +22,7 @@ void CWaimaiOrder::InitData(std::string order_id, std::string order_no)
 	if (!ret)
 	{
 		LOG_INFO("网络请求出错");
+		return false;
 	}
 
 	rapidjson::Document document;
@@ -30,12 +31,14 @@ void CWaimaiOrder::InitData(std::string order_id, std::string order_no)
 	if (document.HasParseError())
 	{
 		LOG_INFO("parse response error!");
+		return false;
 	}
 	else
 	{
 		if (!document.HasMember("errcode") || !document.HasMember("errmsg") || !document.HasMember("data"))
 		{
 			LOG_INFO("json error!");
+			return false;
 		}
 
 		rapidjson::Value& v_errcode = document["errcode"];
@@ -43,6 +46,7 @@ void CWaimaiOrder::InitData(std::string order_id, std::string order_no)
 		if (errcode != 0)
 		{
 			LOG_INFO("response failed! message:" << document["errmsg"].GetString());
+			return false;
 		}
 		{
 			//获得数据成功
@@ -174,6 +178,8 @@ void CWaimaiOrder::InitData(std::string order_id, std::string order_no)
 			}
 		}
 	}
+
+	return true;
 }
 
 bool CWaimaiOrder::ConfirmeOrder(std::string order_id)

+ 1 - 1
zhipuzi_pos_windows/order/CWaimaiOrder.h

@@ -32,7 +32,7 @@ public:
 	CWaimaiOrder();
 	~CWaimaiOrder();
 
-	void InitData(std::string order_id, std::string order_no);
+	bool InitData(std::string order_id, std::string order_no);
 
 	bool ConfirmeOrder(std::string order_id);
 	bool SuccessOrder(std::string order_id);

+ 8 - 2
zhipuzi_pos_windows/tool/CSqlite3.cpp

@@ -5,11 +5,17 @@
 
 CSqlite3::CSqlite3()
 {
-    wstring folderPath = CSystem::GetProgramDir() + L"\\db";
+	wstring folderPath = CSystem::GetProgramDir() + L"\\db";
 	if (!CSystem::IsDirExist(folderPath))
 	{
+		LOG_INFO("folderPath:" << folderPath.c_str() << ",没有找到对应的目录,即将创建");
 		bool flag = CreateDirectory(folderPath.c_str(), NULL);
-		bool a = flag;
+		if (flag == false)
+		{
+			LOG_INFO("新建 db 目录失败!");
+		}
+
+		LOG_INFO("新建 db 目录成功!");
 	}
 
     //如果没有这个文件,这里会创建这个文件

+ 2 - 2
zhipuzi_pos_windows/wnd/CMainWnd.cpp

@@ -132,7 +132,7 @@ void CMainWnd::HandleClickMsg(TNotifyUI& msg)
         std::string waimai_order_id = item->getOrderID();
         std::string waimai_order_no = item->getOrderNo();
 
-		m_push->AddPinter(waimai_order_id, waimai_order_no);
+		m_push->AddPinter(waimai_order_id, waimai_order_no, 2);
     }
 
     else if(name == _T("waimai_order_list_confirme"))
@@ -296,7 +296,7 @@ void CMainWnd::HandleClickMsg(TNotifyUI& msg)
     {
         CWaimaiOrderInfoUI* order_info_page = static_cast<CWaimaiOrderInfoUI*>(m_pm.FindControl(_T("waimaiorder_info_page")));
 
-		m_push->AddPinter(order_info_page->m_order.m_order_id, order_info_page->m_order.m_order_no);
+		m_push->AddPinter(order_info_page->m_order.m_order_id, order_info_page->m_order.m_order_no, 2);
     }
 
     else if(name == _T("waimai_order_info_page_confirme"))