Explorar el Código

换台差不多了

zhangyang hace 3 años
padre
commit
4d4c582223

+ 14 - 0
zhipuzi_pos_windows/control/CZhengcanTableItemUI.cpp

@@ -147,4 +147,18 @@ void CZhengcanTableItemUI::ShowZhuanchu(bool is_show)
 	{
 		zhuanchuControl->SetVisible(false);
 	}
+}
+
+void CZhengcanTableItemUI::ShowZhuanru(bool is_show)
+{
+	CControlUI* zhuanruControl = static_cast<CControlUI*>(this->FindSubControl(L"zhuantai_zhuanru"));
+
+	if (is_show == true)
+	{
+		zhuanruControl->SetVisible(true);
+	}
+	else
+	{
+		zhuanruControl->SetVisible(false);
+	}
 }

+ 4 - 0
zhipuzi_pos_windows/control/CZhengcanTableItemUI.h

@@ -38,8 +38,12 @@ public:
 		return m_table_name;
 	}
 
+	//是否展示转出标志
 	void ShowZhuanchu(bool is_show);
 
+	//是否展示转入标志
+	void ShowZhuanru(bool is_show);
+
 private:
 	std::string m_table_id;
 	std::string m_table_name;

+ 147 - 35
zhipuzi_pos_windows/page/CZhengcanPageUI.cpp

@@ -41,6 +41,10 @@ void CZhengcanPageUI::HandleClickMsg(TNotifyUI& msg)
 	{
 		this->CancelZhuanTai();
 	}
+	else if (name == L"zhengcan_zhuantai_queding")
+	{
+		this->QurenZhuantai();
+	}
 }
 
 //处理option切换事件
@@ -423,56 +427,87 @@ void CZhengcanPageUI::ClickTableAction()
 	std::string order_id = m_cur_click_table_item->GetOrderId();
 	std::string table_name = m_cur_click_table_item->GetTableName();
 
-	if (status == "0")
+	if (m_nModel == 1)
 	{
-		//未开台,弹框进行人数选择
-		CZhengcanKaitaiWnd* pKaitaiDlg = new CZhengcanKaitaiWnd();
-
-		if (pKaitaiDlg != NULL)
+		if (status == "0")
 		{
-			pKaitaiDlg->Create(m_pManager->GetPaintWindow(), _T(""), UI_WNDSTYLE_DIALOG, WS_EX_WINDOWEDGE);
-			pKaitaiDlg->SetIcon(IDI_ICON_DUILIB);
-			pKaitaiDlg->CenterWindow();
+			//未开台,弹框进行人数选择
+			CZhengcanKaitaiWnd* pKaitaiDlg = new CZhengcanKaitaiWnd();
 
-			pKaitaiDlg->SetTitle(CLewaimaiString::UTF8ToUnicode(table_name));
-
-			UINT ret = pKaitaiDlg->ShowModal();
-
-			if (ret == IDOK)
+			if (pKaitaiDlg != NULL)
 			{
-				//这说明人数输入了
-				std::string renshu = pKaitaiDlg->getContent();
+				pKaitaiDlg->Create(m_pManager->GetPaintWindow(), _T(""), UI_WNDSTYLE_DIALOG, WS_EX_WINDOWEDGE);
+				pKaitaiDlg->SetIcon(IDI_ICON_DUILIB);
+				pKaitaiDlg->CenterWindow();
+
+				pKaitaiDlg->SetTitle(CLewaimaiString::UTF8ToUnicode(table_name));
 
-				bool ret = this->Kaitai(table_id, renshu);
+				UINT ret = pKaitaiDlg->ShowModal();
 
-				if (ret == true)
+				if (ret == IDOK)
 				{
-					//开台成功,进入桌子
-					this->EnterTable(table_id);
+					//这说明人数输入了
+					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;
 				}
 				else
 				{
-					this->m_pMainWnd->ShowToast(L"开台失败!");
-				}
-				
-				delete pKaitaiDlg;
-			}
-			else
-			{
-				delete pKaitaiDlg;
+					delete pKaitaiDlg;
 
-				return;
+					return;
+				}
 			}
 		}
+		else if (status == "1")
+		{
+			//预约中
+		}
+		else if (status == "2")
+		{
+			//已开台
+			this->EnterTable(table_id);
+		}
 	}
-	else if (status == "1")
-	{
-		//预约中
-	}
-	else if (status == "2")
+	else if (m_nModel == 2)
 	{
-		//已开台
-		this->EnterTable(table_id);
+		if (status == "0")
+		{
+			if (m_cur_zhuanru_item != NULL)
+			{
+				m_cur_zhuanru_item->ShowZhuanru(false);
+			}
+
+			//未开台,正常选中
+			m_cur_zhuanru_item = m_cur_click_table_item;
+
+			m_cur_zhuanru_item->ShowZhuanru(true);
+
+			CButtonUI* zhuantaiQuerenBtn = static_cast<CButtonUI*>(this->FindSubControl(L"zhengcan_zhuantai_queding"));
+			zhuantaiQuerenBtn->SetEnabled(true);
+		}
+		else if (status == "1")
+		{
+			//预约中
+			m_pMainWnd->ShowToast(L"只有未开台的桌子才能转入");
+		}
+		else if (status == "2")
+		{
+			//已开台
+			m_pMainWnd->ShowToast(L"只有未开台的桌子才能转入");
+		}
 	}
 }
 
@@ -562,6 +597,12 @@ void CZhengcanPageUI::ShowZhuanTai()
 
 	CHorizontalLayoutUI* pZhuantaiLayout = static_cast<CHorizontalLayoutUI*>(this->FindSubControl(_T("zhengcan_zhuantai_layout")));
 	pZhuantaiLayout->SetVisible(true);
+
+	//初始化转出没选中
+	m_cur_zhuanru_item = NULL;
+
+	CButtonUI* zhuantaiQuerenBtn = static_cast<CButtonUI*>(this->FindSubControl(L"zhengcan_zhuantai_queding"));
+	zhuantaiQuerenBtn->SetEnabled(false);
 }
 
 void CZhengcanPageUI::CancelZhuanTai()
@@ -580,4 +621,75 @@ void CZhengcanPageUI::CancelZhuanTai()
 
 	CHorizontalLayoutUI* pZhuantaiLayout = static_cast<CHorizontalLayoutUI*>(this->FindSubControl(_T("zhengcan_zhuantai_layout")));
 	pZhuantaiLayout->SetVisible(false);
+
+	if (m_cur_zhuanru_item != NULL)
+	{
+		m_cur_zhuanru_item->ShowZhuanru(false);
+	}
+}
+
+void CZhengcanPageUI::QurenZhuantai()
+{
+	if (m_nModel != 2)
+	{
+		return;
+	}
+
+	if (m_cur_zhuanru_item == NULL)
+	{
+		m_pMainWnd->ShowToast(L"还未选择转入桌子,无法确认");
+	}
+
+	std::string ZhuanruTableId = m_cur_zhuanru_item->GetTableId();
+
+	std::map<string, string> params;
+	params["old_table_id"] = m_HuantaiTableId;
+	params["new_table_id"] = ZhuanruTableId;
+
+	std::string response;
+
+	std::string url = "/dinnercash/changetable";
+	bool ret = CZhipuziHttpClient::GetInstance()->Request(url.c_str(), params, response);
+	if (ret == false)
+	{
+		m_pMainWnd->ShowToast(L"服务器错误,转台失败");
+		return;
+	}
+
+	rapidjson::Document document;
+	document.Parse(response.c_str());
+
+	if (document.HasParseError())
+	{
+		m_pMainWnd->ShowToast(L"服务器错误,转台失败");
+		return;
+	}
+
+	if (!document.HasMember("errcode") || !document.HasMember("errmsg"))
+	{
+		m_pMainWnd->ShowToast(L"服务器错误,转台失败");
+		return;
+	}
+
+	rapidjson::Value& v_errcode = document["errcode"];
+	int errcode = v_errcode.GetInt();
+	if (errcode != 0)
+	{
+		m_pMainWnd->ShowToast(L"服务器错误,转台失败");
+		return;
+	}
+
+	if (!document.HasMember("data"))
+	{
+		m_pMainWnd->ShowToast(L"服务器错误,转台失败");
+		return;
+	}
+
+	rapidjson::Value& data = document["data"];
+
+	//走到这里说明转台成功了
+
+	m_nModel = 1;
+
+	InitShow();
 }

+ 6 - 1
zhipuzi_pos_windows/page/CZhengcanPageUI.h

@@ -76,6 +76,9 @@ private:
 	//退出转台模式,回到正常模式
 	void CancelZhuanTai();
 
+	//确认转台
+	void QurenZhuantai();
+
 private:
 	//当前控件的实际宽度
 	int m_nPageWidth;
@@ -94,7 +97,9 @@ private:
 	std::string m_cur_type_id = "";
 	CControlUI* m_curZhuozitypeOption;
 
-	CZhengcanTableItemUI* m_cur_click_table_item;
+	CZhengcanTableItemUI* m_cur_click_table_item = NULL;
+
+	CZhengcanTableItemUI* m_cur_zhuanru_item = NULL;
 
 	//当刷新桌子时
 	std::mutex m_table_mutex;