|
|
@@ -635,14 +635,19 @@ void CMainWnd::HandleClickMsg(TNotifyUI& msg)
|
|
|
{
|
|
|
//这个时候是点击保存返回了,厨房打印机的数据已经建立好了,这个时候刷新表格的显示
|
|
|
CListUI* pPrinterList = static_cast<CListUI*>(m_pm.FindControl(_T("setting_chufang_printer_list")));
|
|
|
+
|
|
|
//把最后一个厨房打印机取出来
|
|
|
+
|
|
|
ChufangPrinter newPrinter = CSetting::getLastChufangPrinter();
|
|
|
CDialogBuilder builder;
|
|
|
CListContainerElementUI* pEle = static_cast<CListContainerElementUI*>(builder.Create(_T("setting_chufang_printer_item.xml"), (UINT)0, NULL, &m_pm));
|
|
|
+
|
|
|
CLabelUI* pName = static_cast<CLabelUI*>(pEle->FindSubControl(_T("setting_chufang_printer_item_name")));
|
|
|
pName->SetText(CLewaimaiString::UTF8ToUnicode(newPrinter.name).c_str());
|
|
|
+
|
|
|
CLabelUI* pIP = static_cast<CLabelUI*>(pEle->FindSubControl(_T("setting_chufang_printer_item_ip")));
|
|
|
pIP->SetText(CLewaimaiString::UTF8ToUnicode(newPrinter.ip).c_str());
|
|
|
+
|
|
|
CLabelUI* pGuige = static_cast<CLabelUI*>(pEle->FindSubControl(_T("setting_chufang_printer_guige")));
|
|
|
|
|
|
if(newPrinter.guige == "58")
|
|
|
@@ -665,17 +670,41 @@ void CMainWnd::HandleClickMsg(TNotifyUI& msg)
|
|
|
pFendan->SetText(L"否");
|
|
|
}
|
|
|
|
|
|
- CLabelUI* pFenlei = static_cast<CLabelUI*>(pEle->FindSubControl(_T("setting_chufang_printer_item_fenlei")));
|
|
|
+ CLabelUI* pFenlei = static_cast<CLabelUI*>(pEle->FindSubControl(_T("setting_chufang_printer_item_fenlei")));
|
|
|
|
|
|
- if (newPrinter.fenlei == "1")
|
|
|
- {
|
|
|
- pFenlei->SetText(L"是");
|
|
|
- }
|
|
|
- else
|
|
|
+ if(newPrinter.fenlei == "1")
|
|
|
+ {
|
|
|
+ pFenlei->SetText(L"是");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ pFenlei->SetText(L"否");
|
|
|
+ }
|
|
|
+
|
|
|
+ std::string foodtypeNames = "";
|
|
|
+
|
|
|
+ std::string foodtype_ids = newPrinter.fenlei_ids;
|
|
|
+ std::vector<string> ids = CLewaimaiString::Split(foodtype_ids, ",");
|
|
|
+ for (std::vector<string>::iterator it = ids.begin(); it != ids.end(); it++)
|
|
|
{
|
|
|
- pFenlei->SetText(L"否");
|
|
|
+ std::string name = CSetting::getFoodtypeName((*it));
|
|
|
+ std::wstring ws_name = CLewaimaiString::UTF8ToUnicode(name);
|
|
|
+ if (name == "zhipuzi_not_found_xxx")
|
|
|
+ {
|
|
|
+ //这种情况是以前保存的分类后来被删掉了
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ foodtypeNames += name + " ";
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+ foodtypeNames = foodtypeNames.substr(0, foodtypeNames.size() - 1);
|
|
|
+ std::wstring ws_foodtypeNames = CLewaimaiString::UTF8ToUnicode(foodtypeNames);
|
|
|
+
|
|
|
+ CLabelUI* pFenleiIds = static_cast<CLabelUI*>(pEle->FindSubControl(_T("setting_chufang_printer_item_fenlei_ids")));
|
|
|
+ pFenleiIds->SetText(ws_foodtypeNames.c_str());
|
|
|
+
|
|
|
pEle->AddCustomAttribute(L"date", CLewaimaiString::UTF8ToUnicode(newPrinter.date).c_str());
|
|
|
pPrinterList->Add(pEle);
|
|
|
}
|
|
|
@@ -767,6 +796,41 @@ void CMainWnd::HandleClickMsg(TNotifyUI& msg)
|
|
|
{
|
|
|
pFendan->SetText(L"否");
|
|
|
}
|
|
|
+
|
|
|
+ CLabelUI* pFenlei = static_cast<CLabelUI*>(pEle->FindSubControl(_T("setting_chufang_printer_item_fenlei")));
|
|
|
+
|
|
|
+ if (newPrinter.fenlei == "1")
|
|
|
+ {
|
|
|
+ pFenlei->SetText(L"是");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ pFenlei->SetText(L"否");
|
|
|
+ }
|
|
|
+
|
|
|
+ std::string foodtypeNames = "";
|
|
|
+
|
|
|
+ std::string foodtype_ids = newPrinter.fenlei_ids;
|
|
|
+ std::vector<string> ids = CLewaimaiString::Split(foodtype_ids, ",");
|
|
|
+ for (std::vector<string>::iterator it = ids.begin(); it != ids.end(); it++)
|
|
|
+ {
|
|
|
+ std::string name = CSetting::getFoodtypeName((*it));
|
|
|
+ std::wstring ws_name = CLewaimaiString::UTF8ToUnicode(name);
|
|
|
+ if (name == "zhipuzi_not_found_xxx")
|
|
|
+ {
|
|
|
+ //这种情况是以前保存的分类后来被删掉了
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ foodtypeNames += name + " ";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ foodtypeNames = foodtypeNames.substr(0, foodtypeNames.size() - 1);
|
|
|
+ std::wstring ws_foodtypeNames = CLewaimaiString::UTF8ToUnicode(foodtypeNames);
|
|
|
+
|
|
|
+ CLabelUI* pFenleiIds = static_cast<CLabelUI*>(pEle->FindSubControl(_T("setting_chufang_printer_item_fenlei_ids")));
|
|
|
+ pFenleiIds->SetText(ws_foodtypeNames.c_str());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -1019,7 +1083,7 @@ void CMainWnd::HandleItemSelectMsg(TNotifyUI& msg)
|
|
|
else if(name == _T("setting_biaoqian_printer_usb"))
|
|
|
{
|
|
|
CComboUI* com = static_cast<CComboUI*>(m_pm.FindControl(_T("setting_biaoqian_printer_usb")));
|
|
|
- wstring usb_device = com->GetText();;
|
|
|
+ wstring usb_device = com->GetText();;
|
|
|
|
|
|
CSetting::SetParam("setting_biaoqian_printer_usb", CLewaimaiString::UnicodeToUTF8(usb_device));
|
|
|
}
|
|
|
@@ -1103,7 +1167,7 @@ LRESULT CMainWnd::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|
|
|
|
|
LRESULT CMainWnd::MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, bool& bHandled)
|
|
|
{
|
|
|
- return false;
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
LRESULT CMainWnd::OnSysCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
|
|
|
@@ -1387,14 +1451,14 @@ LRESULT CMainWnd::OnLoginOut(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHan
|
|
|
|
|
|
void CMainWnd::InitSettingStatus()
|
|
|
{
|
|
|
- //显示当前软件版本和登录账号信息
|
|
|
+ //显示当前软件版本和登录账号信息
|
|
|
CLabelUI* name_version = static_cast<CLabelUI*>(m_pm.FindControl(_T("main_name_version")));
|
|
|
- std::wstring wsShowName = L"乐外卖接单软件 " + CLewaimaiString::UTF8ToUnicode(CSystem::GetVersion());
|
|
|
+ std::wstring wsShowName = L"乐外卖接单软件 " + CLewaimaiString::UTF8ToUnicode(CSystem::GetVersion());
|
|
|
|
|
|
- std::string last_login_username = CSetting::GetParam("last_login_username");
|
|
|
- std::wstring wx_last_login_username = CLewaimaiString::UTF8ToUnicode(last_login_username);
|
|
|
+ std::string last_login_username = CSetting::GetParam("last_login_username");
|
|
|
+ std::wstring wx_last_login_username = CLewaimaiString::UTF8ToUnicode(last_login_username);
|
|
|
|
|
|
- wsShowName += L"(登录账号:" + wx_last_login_username + L")";
|
|
|
+ wsShowName += L"(登录账号:" + wx_last_login_username + L")";
|
|
|
|
|
|
name_version->SetText(wsShowName.c_str());
|
|
|
|
|
|
@@ -1747,16 +1811,16 @@ void CMainWnd::InitSettingStatus()
|
|
|
}
|
|
|
|
|
|
//初始化标签打印机的设置
|
|
|
- box = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("setting_is_new_waimai_biaoqian_printer")));
|
|
|
+ box = static_cast<CCheckBoxUI*>(m_pm.FindControl(_T("setting_is_new_waimai_biaoqian_printer")));
|
|
|
|
|
|
- if (CSetting::GetParam("setting_is_new_waimai_biaoqian_printer") == "1")
|
|
|
- {
|
|
|
- box->Selected(true, false);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- box->Selected(false, false);
|
|
|
- }
|
|
|
+ if(CSetting::GetParam("setting_is_new_waimai_biaoqian_printer") == "1")
|
|
|
+ {
|
|
|
+ box->Selected(true, false);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ box->Selected(false, false);
|
|
|
+ }
|
|
|
|
|
|
//usb下拉框默认选中
|
|
|
CComboUI* com_usb = static_cast<CComboUI*>(m_pm.FindControl(_T("setting_biaoqian_printer_usb")));
|
|
|
@@ -1794,51 +1858,58 @@ void CMainWnd::InitSettingStatus()
|
|
|
//这里开始,初始化厨房打印机的设置
|
|
|
CListUI* pPrinterList = static_cast<CListUI*>(m_pm.FindControl(_T("setting_chufang_printer_list")));
|
|
|
|
|
|
- //获取当前店铺的商品分类信息,用于设置厨房打印机的分类打印
|
|
|
- std::map<string, string> params;
|
|
|
- std::string response;
|
|
|
+ //获取当前店铺的商品分类信息,用于设置厨房打印机的分类打印
|
|
|
|
|
|
- std::string url = "/goodstype/getlist";
|
|
|
+ //先清空一次分类(主要考虑退出登陆重新登录的情况)
|
|
|
+ CSetting::ClearFoodtype();
|
|
|
|
|
|
- CLewaimaiHttpClient::Request(url.c_str(), params, response);
|
|
|
+ std::map<string, string> params;
|
|
|
+ params["shop_id"] = "424298";
|
|
|
|
|
|
- rapidjson::Document document;
|
|
|
- document.Parse(response.c_str());
|
|
|
+ std::string response;
|
|
|
|
|
|
- if (document.HasParseError())
|
|
|
- {
|
|
|
- LOG_INFO("parse response error!");
|
|
|
- return;
|
|
|
- }
|
|
|
+ std::string url = "/goodstype/getlist";
|
|
|
|
|
|
- if (!document.HasMember("errcode") || !document.HasMember("errmsg") || !document.HasMember("data"))
|
|
|
- {
|
|
|
- LOG_INFO("json error!");
|
|
|
- return;
|
|
|
- }
|
|
|
+ CLewaimaiHttpClient::Request(url.c_str(), params, response);
|
|
|
|
|
|
- rapidjson::Value& v_errcode = document["errcode"];
|
|
|
- int errcode = v_errcode.GetInt();
|
|
|
- if (errcode != 0)
|
|
|
- {
|
|
|
- LOG_INFO("response failed! message:" << document["errmsg"].GetString());
|
|
|
- return;
|
|
|
- }
|
|
|
+ rapidjson::Document document;
|
|
|
+ document.Parse(response.c_str());
|
|
|
|
|
|
- //获得数据成功,把分类信息保存起来
|
|
|
- rapidjson::Value& data = document["data"];
|
|
|
+ if(document.HasParseError())
|
|
|
+ {
|
|
|
+ LOG_INFO("parse response error!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- rapidjson::Value& v_rows = data["goods_types"];
|
|
|
+ if(!document.HasMember("errcode") || !document.HasMember("errmsg") || !document.HasMember("data"))
|
|
|
+ {
|
|
|
+ LOG_INFO("json error!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- for (rapidjson::SizeType i = 0; i < v_rows.Size(); ++i)
|
|
|
- {
|
|
|
- rapidjson::Value& v_row_i = v_rows[i];
|
|
|
+ rapidjson::Value& v_errcode = document["errcode"];
|
|
|
+ int errcode = v_errcode.GetInt();
|
|
|
|
|
|
- std::string type_id = v_row_i["type_id"].GetString();
|
|
|
- std::string name = v_row_i["name"].GetString();
|
|
|
+ if(errcode != 0)
|
|
|
+ {
|
|
|
+ LOG_INFO("response failed! message:" << document["errmsg"].GetString());
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- CSetting::AddFoodtype(name, type_id);
|
|
|
- }
|
|
|
+ //获得数据成功,把分类信息保存起来
|
|
|
+ rapidjson::Value& data = document["data"];
|
|
|
+
|
|
|
+ rapidjson::Value& v_rows = data["goods_types"];
|
|
|
+
|
|
|
+ for(rapidjson::SizeType i = 0; i < v_rows.Size(); ++i)
|
|
|
+ {
|
|
|
+ rapidjson::Value& v_row_i = v_rows[i];
|
|
|
+
|
|
|
+ std::string type_id = v_row_i["type_id"].GetString();
|
|
|
+ std::string name = v_row_i["name"].GetString();
|
|
|
+
|
|
|
+ CSetting::AddFoodtype(name, type_id);
|
|
|
+ }
|
|
|
|
|
|
//获取厨房打印机的集合
|
|
|
std::vector<ChufangPrinter> printers = CSetting::getChufangPrints();
|
|
|
@@ -1877,52 +1948,55 @@ void CMainWnd::InitSettingStatus()
|
|
|
pFendan->SetText(L"否");
|
|
|
}
|
|
|
|
|
|
- CLabelUI* pFenlei = static_cast<CLabelUI*>(pEle->FindSubControl(_T("setting_chufang_printer_item_fenlei")));
|
|
|
-
|
|
|
- if (newPrinter.fenlei == "1")
|
|
|
- {
|
|
|
- pFenlei->SetText(L"是");
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- pFenlei->SetText(L"否");
|
|
|
- }
|
|
|
-
|
|
|
- std::string foodtypeNames = "";
|
|
|
-
|
|
|
- std::string foodtype_ids = newPrinter.fenlei_ids;
|
|
|
-
|
|
|
- //这个是删除掉不存在的type_id之后的
|
|
|
- std::string new_foodtype_ids = "";
|
|
|
-
|
|
|
- std::vector<string> ids = CLewaimaiString::Split(foodtype_ids, ",");
|
|
|
- for (std::vector<string>::iterator it = ids.begin(); it != ids.end(); it++)
|
|
|
- {
|
|
|
- std::string name = CSetting::getFoodtypeName((*it));
|
|
|
- if (name == "zhipuzi_not_found_xxx")
|
|
|
- {
|
|
|
- //这种情况是以前保存的分类后来被删掉了
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- foodtypeNames += name + " ";
|
|
|
-
|
|
|
- new_foodtype_ids += (*it) + ",";
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //删掉不存在的type_id,更新内存和数据库
|
|
|
- new_foodtype_ids = new_foodtype_ids.substr(0, new_foodtype_ids.length() - 1);
|
|
|
- if (new_foodtype_ids.compare(foodtype_ids) != 0)
|
|
|
- {
|
|
|
- CSetting::UpdateChufangPrinter(newPrinter.date, newPrinter.name, newPrinter.ip, newPrinter.guige, newPrinter.fendan, newPrinter.fenlei, new_foodtype_ids, true);
|
|
|
- }
|
|
|
-
|
|
|
- foodtypeNames = foodtypeNames.substr(0, foodtypeNames.size() - 1);
|
|
|
- std::wstring ws_foodtypeNames = CLewaimaiString::UTF8ToUnicode(foodtypeNames);
|
|
|
-
|
|
|
- CLabelUI* pFenleiIds = static_cast<CLabelUI*>(pEle->FindSubControl(_T("setting_chufang_printer_item_fenlei_ids")));
|
|
|
- pFenleiIds->SetText(ws_foodtypeNames.c_str());
|
|
|
+ CLabelUI* pFenlei = static_cast<CLabelUI*>(pEle->FindSubControl(_T("setting_chufang_printer_item_fenlei")));
|
|
|
+
|
|
|
+ if(newPrinter.fenlei == "1")
|
|
|
+ {
|
|
|
+ pFenlei->SetText(L"是");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ pFenlei->SetText(L"否");
|
|
|
+ }
|
|
|
+
|
|
|
+ std::string foodtypeNames = "";
|
|
|
+
|
|
|
+ std::string foodtype_ids = newPrinter.fenlei_ids;
|
|
|
+
|
|
|
+ //这个是删除掉不存在的type_id之后的
|
|
|
+ std::string new_foodtype_ids = "";
|
|
|
+
|
|
|
+ std::vector<string> ids = CLewaimaiString::Split(foodtype_ids, ",");
|
|
|
+
|
|
|
+ for(std::vector<string>::iterator it = ids.begin(); it != ids.end(); it++)
|
|
|
+ {
|
|
|
+ std::string name = CSetting::getFoodtypeName((*it));
|
|
|
+
|
|
|
+ if(name == "zhipuzi_not_found_xxx")
|
|
|
+ {
|
|
|
+ //这种情况是以前保存的分类后来被删掉了
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ foodtypeNames += name + " ";
|
|
|
+
|
|
|
+ new_foodtype_ids += (*it) + ",";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //删掉不存在的type_id,更新内存和数据库
|
|
|
+ new_foodtype_ids = new_foodtype_ids.substr(0, new_foodtype_ids.length() - 1);
|
|
|
+
|
|
|
+ if(new_foodtype_ids.compare(foodtype_ids) != 0)
|
|
|
+ {
|
|
|
+ CSetting::UpdateChufangPrinter(newPrinter.date, newPrinter.name, newPrinter.ip, newPrinter.guige, newPrinter.fendan, newPrinter.fenlei, new_foodtype_ids, true);
|
|
|
+ }
|
|
|
+
|
|
|
+ foodtypeNames = foodtypeNames.substr(0, foodtypeNames.size() - 1);
|
|
|
+ std::wstring ws_foodtypeNames = CLewaimaiString::UTF8ToUnicode(foodtypeNames);
|
|
|
+
|
|
|
+ CLabelUI* pFenleiIds = static_cast<CLabelUI*>(pEle->FindSubControl(_T("setting_chufang_printer_item_fenlei_ids")));
|
|
|
+ pFenleiIds->SetText(ws_foodtypeNames.c_str());
|
|
|
|
|
|
//设置标记属性,用于修改时候匹配
|
|
|
pEle->AddCustomAttribute(L"date", CLewaimaiString::UTF8ToUnicode(newPrinter.date).c_str());
|