Sfoglia il codice sorgente

完成大部分功能

张洋 4 anni fa
parent
commit
40dc991323

+ 4 - 4
bin/Win32/Debug/zhipuzi_pos_windows/skin/diandan_page.xml

@@ -85,7 +85,7 @@
 						<Label text="更多支付" width="110" height="35" font="14" float="true" pos="415,35,525,70" mouse="false"></Label>
 					</HorizontalLayout>
 					
-					<Button visible="false" name="btn_diandan_jixujiacai" text="继续点单" height="55" padding="15,20,0,15" textcolor="#FFFFFFFF"></Button>
+					<Button visible="false" name="btn_diandan_jixujiacai" text="继续点单" height="55" padding="20,20,20,15" textcolor="#FFFFFFFF"></Button>
 				</VerticalLayout>
 			</VerticalLayout>
 			
@@ -113,7 +113,7 @@
 			
 			<HorizontalLayout name="diandan_jiesuan_layout" bkcolor="#FFFFFFFF" visible="false">
 				<VerticalLayout width="420">
-					<Label text="选择优惠" width="100" height="58" padding="20,0,0,0" font="24"></Label>
+					<Label text="选择优惠" width="100" height="58" padding="20,0,0,0" font="20"></Label>
 					
 					<Control height="1" bkcolor="#FFEBE8E8" padding="10,0,10,0"></Control>
 					
@@ -183,7 +183,7 @@
 				<Control width="1" bkcolor="#FFEBE8E8"></Control>
 				
 				<VerticalLayout vscrollbar="true">
-					<Label text="账单明细" height="58" padding="20,0,0,0" font="24"></Label>
+					<Label text="账单明细" height="58" padding="20,0,0,0" font="20"></Label>
 					
 					<Control height="1" bkcolor="#FFEBE8E8" padding="10,0,10,0"></Control>
 					
@@ -198,7 +198,7 @@
 						<Label name="diandan_jiesuan_total_yingshou" text="" height="50" align="right" padding="0,0,15,0"/>
 					</HorizontalLayout>
 					
-					<Label text="支付方式" width="100" height="58" padding="20,30,0,0" font="24"></Label>
+					<Label text="支付方式" width="100" height="58" padding="20,30,0,0" font="20"></Label>
 					
 					<Control height="1" bkcolor="#FFEBE8E8" padding="10,0,10,0"></Control>
 					

+ 7 - 1
bin/Win32/Debug/zhipuzi_pos_windows/skin/setting_page.xml

@@ -3,7 +3,7 @@
 	<SettingPage name="setting_page" bkcolor="#FFEFF6EE">
 		<HorizontalLayout>
 			<HorizontalLayout width="350" bkcolor="#FFF6F6F6">
-				<VerticalLayout height="800" inset="0,0,0,0">
+				<VerticalLayout height="900" inset="0,0,0,0">
 					<Option name="setting_waimai_order_switch" selected="true" text="外卖订单设置" group="setting_switch" align="center" height="69"  padding="0,0,0,0" selectedimage="file='white_bkg.png'" textcolor="#FF666666" selectedtextcolor="#FF000000" />
 					<Control height="1" bkcolor="#FFD1D1D1"></Control>
 					<Option name="setting_diannei_order_switch" text="店内订单设置" group="setting_switch" align="center" height="69" padding="0,0,0,0" selectedimage="file='white_bkg.png'" textcolor="#FF666666" selectedtextcolor="#FF000000" />
@@ -20,6 +20,8 @@
 					<Control height="1" bkcolor="#FFD1D1D1"></Control>
 					<Option name="setting_xianshi_switch" text="显示设置" group="setting_switch" align="center" height="69" padding="0,0,0,0" selectedimage="file='white_bkg.png'" textcolor="#FF666666" selectedtextcolor="#FF000000" />
 					<Control height="1" bkcolor="#FFD1D1D1"></Control>
+					<Option name="setting_tongbu_switch" text="数据同步" group="setting_switch" align="center" height="69" padding="0,0,0,0" selectedimage="file='white_bkg.png'" textcolor="#FF666666" selectedtextcolor="#FF000000" />
+					<Control height="1" bkcolor="#FFD1D1D1"></Control>
 					<Option name="setting_system_switch" text="系统设置" group="setting_switch" align="center" height="69" padding="0,0,0,0" selectedimage="file='white_bkg.png'" textcolor="#FF666666" selectedtextcolor="#FF000000" />
 					<Control height="1" bkcolor="#FFD1D1D1"></Control>
 					<Option name="setting_system_about" text="关于" group="setting_switch" align="center" height="69" padding="0,0,0,0" selectedimage="file='white_bkg.png'" textcolor="#FF666666" selectedtextcolor="#FF000000" />
@@ -62,6 +64,10 @@
 				<VerticalLayout bkcolor="#FFFFFFFF" inset="15,15,15,15">
 					<Include source="setting_xianshi.xml" />
 				</VerticalLayout>
+				
+				<VerticalLayout bkcolor="#FFFFFFFF" inset="15,15,15,15">
+					<Include source="setting_tongbu.xml" />
+				</VerticalLayout>
 
 				<VerticalLayout bkcolor="#FFFFFFFF" inset="15,15,15,15">
 					<Include source="setting_system.xml" />

File diff suppressed because it is too large
+ 28 - 0
bin/Win32/Debug/zhipuzi_pos_windows/skin/setting_tongbu.xml


BIN
bin/Win32/Release/setup/zhipuzi_pos_windows_setup_1.0.0.1.exe


+ 4 - 0
zhipuzi_pos_windows/helper/define.h

@@ -37,3 +37,7 @@
 //交班相关的
 #define WM_JIAOBAN_REFRESH 10501
 
+//设置相关的
+#define WM_SETTING_TONGBU_SUCCESS 10601
+#define WM_SETTING_TONGBU_FAIL 10602
+

+ 68 - 2
zhipuzi_pos_windows/page/CSettingPageUI.cpp

@@ -9,6 +9,8 @@
 
 #include <boost/array.hpp>
 
+#include "../tool/CFoodHandle.h"
+
 CSettingPageUI::CSettingPageUI()
 {
 
@@ -1460,6 +1462,10 @@ void CSettingPageUI::HandleClickMsg(TNotifyUI& msg)
 		//退出登录
 		m_pMainWnd->LoginOut(1);
 	}
+	else if (name == L"setting_tongbu_btn")
+	{
+		StartTongbu();
+	}
 }
 
 //处理option切换事件,radio事件
@@ -1508,16 +1514,24 @@ void CSettingPageUI::HandleSelectChangeMsg(TNotifyUI& msg)
 		CTabLayoutUI* pControl = static_cast<CTabLayoutUI*>(this->FindSubControl(_T("setting_switch")));
 		pControl->SelectItem(7);
 	}
-	else if (name == _T("setting_system_switch"))
+	else if (name == _T("setting_tongbu_switch"))
 	{
 		CTabLayoutUI* pControl = static_cast<CTabLayoutUI*>(this->FindSubControl(_T("setting_switch")));
 		pControl->SelectItem(8);
+
+		CLabelUI* label = static_cast<CLabelUI*>(this->FindSubControl(L"setting_tongbu_result"));
+		label->SetVisible(false);
 	}
-	else if (name == _T("setting_system_about"))
+	else if (name == _T("setting_system_switch"))
 	{
 		CTabLayoutUI* pControl = static_cast<CTabLayoutUI*>(this->FindSubControl(_T("setting_switch")));
 		pControl->SelectItem(9);
 	}
+	else if (name == _T("setting_system_about"))
+	{
+		CTabLayoutUI* pControl = static_cast<CTabLayoutUI*>(this->FindSubControl(_T("setting_switch")));
+		pControl->SelectItem(10);
+	}
 	else if (name == _T("xianshi_setting_youtu"))
 	{
 		CSetting::GetInstance()->SetParam("setting_xianshi_is_youtu", "1");
@@ -1799,6 +1813,26 @@ void CSettingPageUI::HandleTextCapture(std::string content)
 
 }
 
+bool CSettingPageUI::HandleCustomMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+	if (uMsg == WM_SETTING_TONGBU_SUCCESS)
+	{
+		CLabelUI* label = static_cast<CLabelUI*>(this->FindSubControl(L"setting_tongbu_result"));
+
+		label->SetText(L"同步成功!");
+		label->SetVisible(true);
+	}
+	else if (uMsg == WM_SETTING_TONGBU_FAIL)
+	{
+		CLabelUI* label = static_cast<CLabelUI*>(this->FindSubControl(L"setting_tongbu_result"));
+
+		label->SetText(m_tongbu_error.c_str());
+		label->SetVisible(true);
+	}
+
+	return false;
+}
+
 void CSettingPageUI::StartTongbuBiaoqiancheng()
 {
 	std::thread(&CSettingPageUI::HandleTongbuBiaoqiancheng, this).detach();
@@ -2203,4 +2237,36 @@ void CSettingPageUI::HandleQiongkongPLU()
 
 		LOG_INFO("发送清空历史记录命令成功,返回信息:" << buf);
 	}
+}
+
+void CSettingPageUI::StartTongbu()
+{
+	std::thread(&CSettingPageUI::HandleTongbu, this).detach();
+}
+
+void CSettingPageUI::HandleTongbu()
+{
+	bool ret = CFoodHandle::GetInstance()->InitAllFood();
+	if (!ret)
+	{
+		m_tongbu_error = L"同步商品失败!";
+		
+		::PostMessage(m_pManager->GetPaintWindow(), WM_SETTING_TONGBU_FAIL, 0, 0);
+
+		return;
+	}
+
+	//获取店铺信息
+	std::wstring errmsg;
+	ret = CShopinfo::GetInstance()->UpdateOneShopinfo(errmsg);
+	if (!ret)
+	{
+		m_tongbu_error = errmsg;
+
+		::PostMessage(m_pManager->GetPaintWindow(), WM_SETTING_TONGBU_FAIL, 0, 0);
+
+		return;
+	}
+
+	::PostMessage(m_pManager->GetPaintWindow(), WM_SETTING_TONGBU_SUCCESS, 0, 0);
 }

+ 8 - 4
zhipuzi_pos_windows/page/CSettingPageUI.h

@@ -28,10 +28,7 @@ public:
 	void HandleTextCapture(std::string content);
 
 	//处理自定义消息,各个页面处理各个页面自己的(是自己处理的消息返回true,不是自己处理的消息返回false)
-	bool HandleCustomMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
-	{
-		return false;
-	}
+	bool HandleCustomMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
 
 	//开始同步商品到标签秤
 	void StartTongbuBiaoqiancheng();
@@ -47,7 +44,14 @@ public:
 	void StartQiongkongPLU();
 
 	void HandleQiongkongPLU();
+
+	void StartTongbu();
+
+	void HandleTongbu();
+
 private:
 	std::wstring m_errinfo;
+
+	std::wstring m_tongbu_error;
 };
 

+ 2 - 2
zhipuzi_pos_windows/print/CPosPrinterData.cpp

@@ -522,8 +522,8 @@ std::string CPosPrinterData::PrintWaimaiOrderBiaoqian(CWaimaiOrder& order)
 
 	std::vector<CWaimaiOrderItem> cur_printer_use; 
 
-	std::string setting_biaoqian_printer_is_type = "setting_biaoqian_printer_is_type";
-	std::string setting_biaoqian_printer_type_ids = "setting_biaoqian_printer_type_ids";
+	std::string setting_biaoqian_printer_is_type = CSetting::GetInstance()->GetParam("setting_biaoqian_printer_is_type");
+	std::string setting_biaoqian_printer_type_ids = CSetting::GetInstance()->GetParam("setting_biaoqian_printer_type_ids");
 
 	if (setting_biaoqian_printer_is_type == "0")
 	{

BIN
zhipuzi_pos_windows/resource/skin.zip


+ 4 - 70
zhipuzi_pos_windows/wnd/CLoginWnd.cpp

@@ -554,9 +554,12 @@ void CLoginWnd::HandleLogin()
 		}
 
 		//获取店铺信息
-		ret = this->GetShopinfo();
+		std::wstring errmsg;
+		ret = CShopinfo::GetInstance()->UpdateOneShopinfo(errmsg);
 		if (!ret)
 		{
+			m_wsLoginErrMsg = errmsg;
+			PostMessage(WM_LOGIN_ERROR);
 			return;
 		}
 
@@ -651,73 +654,4 @@ void CLoginWnd::ShowInitData()
 
 	CVerticalLayoutUI* pIniting = static_cast<CVerticalLayoutUI*>(m_pm.FindControl(_T("login_init_data_ing")));
 	pIniting->SetVisible(true);
-}
-
-bool CLoginWnd::GetShopinfo()
-{
-	std::map<string, string> params;
-
-	std::string response;
-	bool ret = CZhipuziHttpClient::GetInstance()->Request("/shop/getoneshopinfo", params, response);
-	if (!ret)
-	{
-		m_wsLoginErrMsg = _T("网络请求出错");
-		PostMessage(WM_LOGIN_ERROR);
-
-		return false;
-	}
-
-	rapidjson::Document document;
-	document.Parse(response.c_str());
-
-	if (document.HasParseError())
-	{
-		m_wsLoginErrMsg = _T("服务器返回数据格式错误");
-		PostMessage(WM_LOGIN_ERROR);
-
-		return false;
-	}
-
-	if (!document.HasMember("data"))
-	{
-		m_wsLoginErrMsg = _T("服务器返回数据格式错误");
-		PostMessage(WM_LOGIN_ERROR);
-
-		return false;
-	}	
-	
-	if (document.HasMember("error_code"))
-	{
-		rapidjson::Value& v_errcode = document["error_code"];
-		int errcode = v_errcode.GetInt();
-		if (errcode != 0)
-		{
-			std::string errmsg = "response failed! message:" + string(document["error_msg"].GetString());
-			m_wsLoginErrMsg = CLewaimaiString::UTF8ToUnicode(errmsg);
-			PostMessage(WM_LOGIN_ERROR);
-
-			return false;
-		}
-	}
-	else
-	{
-		rapidjson::Value& v_errcode = document["errcode"];
-		int errcode = v_errcode.GetInt();
-		if (errcode != 0)
-		{
-			std::string errmsg = "response failed! message:" + string(document["errmsg"].GetString());
-			m_wsLoginErrMsg = CLewaimaiString::UTF8ToUnicode(errmsg);
-			PostMessage(WM_LOGIN_ERROR);
-
-			return false;
-		}
-	}
-
-	//获得数据成功
-	rapidjson::Value& data = document["data"];
-
-	//把获取到的数据保存起来
-	CShopinfo::GetInstance()->InitShopinfoByGetshopinfo(data);
-
-	return true;
 }

+ 0 - 3
zhipuzi_pos_windows/wnd/CLoginWnd.h

@@ -75,9 +75,6 @@ public:
 	//登录的工作线程
 	void HandleLogin();
 
-	//获取店铺信息(例如支付方式、打印二维码等等)
-	bool GetShopinfo();
-
 public:
     CPaintManagerUI m_pm;
 

+ 93 - 26
zhipuzi_pos_windows/zhipuzi/CShopinfo.cpp

@@ -79,14 +79,92 @@ void CShopinfo::InitShopinfoByLogin(rapidjson::Value& v_data)
 	this->m_is_meishicheng = v_authority["is_meishicheng"].GetString();
 }
 
-//处理登录成功后,通过获取店铺信息接口获取的信息并保存
-void CShopinfo::InitShopinfoByGetshopinfo(rapidjson::Value& data)
+std::wstring CShopinfo::GetMachineLogoPath()
+{
+	string folderPath = CLewaimaiString::UnicodeToANSI(CSystem::GetProgramDir()) + "\\tmp\\image\\";
+	std::wstring ws_folderPath = CLewaimaiString::ANSIToUnicode(folderPath);
+	if (!CSystem::IsDirExist(ws_folderPath))
+	{
+		LOG_INFO("folderPath:" << folderPath.c_str() << ",没有找到对应的目录,即将创建");
+		CSystem::CreateMultiLevel(folderPath);
+	}
+
+	//纯文件名
+	std::string file_name = CLewaimaiString::GetPathOrURLShortName(m_machine_logo_url);
+
+	//根据文件名,计算文件临时路径
+	wstring imagePath = ws_folderPath + CLewaimaiString::UTF8ToUnicode(file_name);
+
+	return imagePath;
+}
+
+bool CShopinfo::UpdateOneShopinfo(std::wstring& errmsg)
 {
+	std::map<string, string> params;
+
+	std::string response;
+	bool ret = CZhipuziHttpClient::GetInstance()->Request("/shop/getoneshopinfo", params, response);
+	if (!ret)
+	{
+		errmsg = _T("网络请求出错");
+
+		return false;
+	}
+
+	rapidjson::Document document;
+	document.Parse(response.c_str());
+
+	if (document.HasParseError())
+	{
+		errmsg = _T("服务器返回数据格式错误");
+
+		return false;
+	}
+
+	if (!document.HasMember("data"))
+	{
+		errmsg = _T("服务器返回数据格式错误");
+
+		return false;
+	}
+
+	if (document.HasMember("error_code"))
+	{
+		rapidjson::Value& v_errcode = document["error_code"];
+		int errcode = v_errcode.GetInt();
+		if (errcode != 0)
+		{
+			std::string s_errmsg = "response failed! message:" + string(document["error_msg"].GetString());
+			errmsg = CLewaimaiString::UTF8ToUnicode(s_errmsg);
+
+			return false;
+		}
+	}
+	else
+	{
+		rapidjson::Value& v_errcode = document["errcode"];
+		int errcode = v_errcode.GetInt();
+		if (errcode != 0)
+		{
+			std::string s_errmsg = "response failed! message:" + string(document["errmsg"].GetString());
+			errmsg = CLewaimaiString::UTF8ToUnicode(s_errmsg);
+
+			return false;
+		}
+	}
+
+	//获得数据成功
+	rapidjson::Value& data = document["data"];
+
+	//把获取到的数据保存起来
 	m_is_discount = data["is_discount"].GetString();
 	m_discount_value = data["discount_value"].GetString();
 	m_discountlimitmember = data["discountlimitmember"].GetString();
 	m_open_addservice = data["open_addservice"].GetString();
 
+	//开始处理增值服务
+	m_addservice.clear();
+
 	rapidjson::Value& addservice = data["addservice"];
 	for (rapidjson::SizeType i = 0; i < addservice.Size(); ++i)
 	{
@@ -101,6 +179,9 @@ void CShopinfo::InitShopinfoByGetshopinfo(rapidjson::Value& data)
 		m_addservice.push_back(newAddService);
 	}
 
+	//开始处理满减
+	m_promotion.clear();
+
 	m_open_promotion = data["open_promotion"].GetString();
 
 	rapidjson::Value& promotion = data["promotion"];
@@ -137,12 +218,14 @@ void CShopinfo::InitShopinfoByGetshopinfo(rapidjson::Value& data)
 	m_eq_card_discount_value = data["eq_card_discount_value"].GetString();
 
 	//处理会员折扣
+	m_discount_info.clear();
+
 	std::string s_discount_info = data["discount_info"].GetString();
 
-	rapidjson::Document document;
-	document.Parse(s_discount_info.c_str());
+	rapidjson::Document document_2;
+	document_2.Parse(s_discount_info.c_str());
 
-	rapidjson::Value& discount = document;
+	rapidjson::Value& discount = document_2;
 	for (rapidjson::SizeType i = 0; i < discount.Size(); ++i)
 	{
 		rapidjson::Value& discountinfo = discount[i];
@@ -189,6 +272,8 @@ void CShopinfo::InitShopinfoByGetshopinfo(rapidjson::Value& data)
 	m_machinecode_logo = data["machinecode_logo"].GetString();
 
 	//开始处理自定义支付
+	m_self_pay.clear();
+
 	rapidjson::Value& self_pay = data["self_pay"];
 	for (rapidjson::SizeType i = 0; i < self_pay.Size(); ++i)
 	{
@@ -216,7 +301,7 @@ void CShopinfo::InitShopinfoByGetshopinfo(rapidjson::Value& data)
 	{
 		m_is_cash_pay_open = to_string(data["default_pay_open"]["is_cash_pay_open"].GetInt());
 	}
-	
+
 	if (data["default_pay_open"]["is_online_pay_open"].IsString())
 	{
 		m_is_online_pay_open = data["default_pay_open"]["is_online_pay_open"].GetString();
@@ -268,7 +353,7 @@ void CShopinfo::InitShopinfoByGetshopinfo(rapidjson::Value& data)
 	{
 		m_is_open_fulika_pay = "0";
 	}
-	
+
 	//开始下载小票打印的logo图
 	std::string logo_url = "http://img.zhipuzi.com" + m_machine_logo_url + "!max400"; //下载小图
 
@@ -279,30 +364,12 @@ void CShopinfo::InitShopinfoByGetshopinfo(rapidjson::Value& data)
 		if (URLDownloadToFile(NULL, CLewaimaiString::UTF8ToUnicode(logo_url).c_str(), imagePath.c_str(), 0, NULL) == S_OK)
 		{
 			//图片下载成功了,发个消息,更新图片
-			int a = 1;
 		}
 		else
 		{
 			LOG_INFO("URLDownloadToFile Fail,Error" << GetLastError());
 		}
 	}
-}
-
-std::wstring CShopinfo::GetMachineLogoPath()
-{
-	string folderPath = CLewaimaiString::UnicodeToANSI(CSystem::GetProgramDir()) + "\\tmp\\image\\";
-	std::wstring ws_folderPath = CLewaimaiString::ANSIToUnicode(folderPath);
-	if (!CSystem::IsDirExist(ws_folderPath))
-	{
-		LOG_INFO("folderPath:" << folderPath.c_str() << ",没有找到对应的目录,即将创建");
-		CSystem::CreateMultiLevel(folderPath);
-	}
-
-	//纯文件名
-	std::string file_name = CLewaimaiString::GetPathOrURLShortName(m_machine_logo_url);
 
-	//根据文件名,计算文件临时路径
-	wstring imagePath = ws_folderPath + CLewaimaiString::UTF8ToUnicode(file_name);
-
-	return imagePath;
+	return true;
 }

+ 2 - 3
zhipuzi_pos_windows/zhipuzi/CShopinfo.h

@@ -54,11 +54,10 @@ public:
 	//处理登录接口返回的店铺信息
 	void InitShopinfoByLogin(rapidjson::Value& v_data);
 
-	//处理登录成功后,通过获取店铺信息接口获取的信息并保存
-	void InitShopinfoByGetshopinfo(rapidjson::Value& data);
-
 	std::wstring GetMachineLogoPath();
 
+	bool UpdateOneShopinfo(std::wstring& errmsg);
+
 public:
 	//当前系统版本 1餐饮版 2零售版
 	std::string m_version_type;