Explorar o código

继续做正餐收银

张洋 %!s(int64=3) %!d(string=hai) anos
pai
achega
fb8c32da25

BIN=BIN
bin/Win32/Debug/zhipuzi_pos_windows/skin/zhengcan_people_1.png


BIN=BIN
bin/Win32/Debug/zhipuzi_pos_windows/skin/zhengcan_people_2.png


+ 5 - 2
bin/Win32/Debug/zhipuzi_pos_windows/skin/zhengcan_tableitem.xml

@@ -8,8 +8,11 @@
 		
 		<Control></Control>
 		<HorizontalLayout name="zhengcan_tableitem_bottom" height="32" bkcolor="#FFEBEBEB">
-			<Label name="renshu" visible="true" width="50" height="26" font="14" text="6人" float="true" pos="33,5,63,30" align="center"></Label>		
-			<Label name="shijian" visible="true" width="50" height="26" font="14" text="50分钟" float="true" pos="110,5,160,30" align="center"></Label>	
+			<Control name="people_image" bkimage="zhengcan_people_2.png" float="true" pos="10,9,28,25"></Control>
+			<Label name="renshu" visible="true" width="50" height="26" font="14" text="6人" float="true" pos="33,5,63,30"></Label>
+
+			<Control name="time_image" bkimage="zhengcan_time_2.png" float="true" pos="97,10,115,26"></Control>			
+			<Label name="shijian" visible="true" font="14" text="" float="true" pos="113,5,175,30"></Label>	
 		</HorizontalLayout>
 	</ZhengcanTableItem>
 </Window>

BIN=BIN
bin/Win32/Debug/zhipuzi_pos_windows/skin/zhengcan_time_1.png


BIN=BIN
bin/Win32/Debug/zhipuzi_pos_windows/skin/zhengcan_time_2.png


+ 28 - 0
zhipuzi_pos_windows/control/CZhengcanTableItemUI.cpp

@@ -56,10 +56,17 @@ void CZhengcanTableItemUI::UpdateShow()
 	CLabelUI* pRenshu = static_cast<CLabelUI*>(this->FindSubControl(_T("renshu")));
 	CLabelUI* pShijian = static_cast<CLabelUI*>(this->FindSubControl(_T("shijian")));
 
+	CControlUI* pPeopleImage = static_cast<CControlUI*>(this->FindSubControl(_T("people_image")));
+	CControlUI* pTimeImage = static_cast<CControlUI*>(this->FindSubControl(_T("time_image")));
+
 	if (m_status == "0")
 	{
 		//未开台
 		pStatus->SetText(L"未开台");
+
+		//隐藏时钟
+		pTimeImage->SetVisible(false);
+		pShijian->SetVisible(false);
 	}
 	else if (m_status == "1")
 	{
@@ -74,6 +81,27 @@ void CZhengcanTableItemUI::UpdateShow()
 		pRenshu->SetTextColor(0xFFFFFFFF);
 		pShijian->SetTextColor(0xFFFFFFFF);
 
+		pPeopleImage->SetBkImage(L"zhengcan_people_1.png");
+		pTimeImage->SetBkImage(L"zhengcan_time_1.png");
+
+		time_t now = time(NULL);
+		time_t init_time = CLewaimaiTime::StringToDatetime(m_order_init_time);
+
+		time_t diff = now - init_time;
+		int fenzhong = (int)(diff / 60);
+		
+		std::wstring ws_fenzhong;
+		if (fenzhong > 999)
+		{
+			ws_fenzhong = L">999";
+		}
+		else
+		{
+			ws_fenzhong = to_wstring(fenzhong);
+		}
+
+		pShijian->SetText((ws_fenzhong + L"分钟").c_str());
+
 		CHorizontalLayoutUI* pBottom = static_cast<CHorizontalLayoutUI*>(this->FindSubControl(L"zhengcan_tableitem_bottom"));
 
 		//区分待下单、待结账、待清台这3个状态

+ 66 - 1
zhipuzi_pos_windows/page/CZhengcanPageUI.cpp

@@ -428,9 +428,20 @@ void CZhengcanPageUI::ClickTableAction()
 
 			if (ret == IDOK)
 			{
-				//这说明折扣输入了
+				//这说明人数输入了
 				std::string renshu = pKaitaiDlg->getContent();
 
+				bool ret = this->Kaitai(table_id, renshu);
+
+				if (ret == true)
+				{
+					//开台成功,进入桌子
+					this->EnterTable(table_id);
+				}
+				else
+				{
+					this->m_pMainWnd->ShowToast(L"开台失败!");
+				}
 				
 				delete pKaitaiDlg;
 			}
@@ -451,4 +462,58 @@ void CZhengcanPageUI::ClickTableAction()
 		//已开台
 
 	}
+}
+
+bool CZhengcanPageUI::Kaitai(std::string table_id, std::string renshu)
+{
+	std::map<string, string> params;
+
+	params["table_id"] = table_id;
+	params["person"] = renshu;
+
+	std::string response;
+
+	std::string url = "/dinnercash/opentable";
+	bool ret = CZhipuziHttpClient::GetInstance()->Request(url.c_str(), params, response);
+	if (ret == false)
+	{
+		return false;
+	}
+
+	rapidjson::Document document;
+	document.Parse(response.c_str());
+
+	if (document.HasParseError())
+	{
+		LOG_INFO("parse response error!");
+		return false;
+	}
+
+	if (!document.HasMember("errcode") || !document.HasMember("errmsg"))
+	{
+		LOG_INFO("json error!");
+
+		return false;
+	}
+
+	rapidjson::Value& v_errcode = document["errcode"];
+	int errcode = v_errcode.GetInt();
+	if (errcode != 0)
+	{
+		return false;
+	}
+
+	if (!document.HasMember("data"))
+	{
+		return false;
+	}
+
+	rapidjson::Value& data = document["data"];
+
+	return true;
+}
+
+void CZhengcanPageUI::EnterTable(std::string table_id)
+{
+
 }

+ 7 - 0
zhipuzi_pos_windows/page/CZhengcanPageUI.h

@@ -56,6 +56,13 @@ public:
 	void ClickTableAction();
 
 private:
+	//执行开台动作,请求服务器
+	bool Kaitai(std::string table_id, std::string renshu);
+
+	//进入桌子
+	void EnterTable(std::string table_id);
+
+private:
 	//当前控件的实际宽度
 	int m_nPageWidth;