|
|
@@ -2694,8 +2694,13 @@ void CZhengcanDiandanPageUI::ClickXidanBtn()
|
|
|
std::string status = CLewaimaiJson::ToString(data["status"]);
|
|
|
if (status == "success")
|
|
|
{
|
|
|
- //下单成功了,返回到桌子列表
|
|
|
- m_pMainWnd->SwitchPage(CMainWnd::ZHENGCAN);
|
|
|
+ std::string show_trade_no = CLewaimaiJson::ToString(data["show_trade_no"]);
|
|
|
+ std::string id = CLewaimaiJson::ToString(data["id"]);
|
|
|
+
|
|
|
+ Value& stock = data["stock"];
|
|
|
+ std::string kucun_string = CLewaimaiJson::JsonToString(stock);
|
|
|
+
|
|
|
+ this->StartWorkAfterXiadan(kucun_string, show_trade_no);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -4114,6 +4119,22 @@ void CZhengcanDiandanPageUI::StopSerachFood()
|
|
|
this->InitFoodShow();
|
|
|
}
|
|
|
|
|
|
+//执行下单成功后的所有操作逻辑
|
|
|
+void CZhengcanDiandanPageUI::StartWorkAfterXiadan(std::string kucunstring, std::string show_trade_no)
|
|
|
+{
|
|
|
+ //更新商品库存
|
|
|
+ this->UpdateFoodStock(kucunstring);
|
|
|
+
|
|
|
+ //处理打印
|
|
|
+ CZhengcanOrder order = this->GetPrintOrderinfoXiadan(show_trade_no);
|
|
|
+
|
|
|
+ CPosPrinter printer;
|
|
|
+ printer.PrintZhengcanOrder(order);
|
|
|
+
|
|
|
+ //下单成功了,返回到桌子列表
|
|
|
+ m_pMainWnd->SwitchPage(CMainWnd::ZHENGCAN);
|
|
|
+}
|
|
|
+
|
|
|
void CZhengcanDiandanPageUI::StartWorkAfterShoukuan(std::string kucunstring, std::string take_food_code, std::string show_trade_no, std::string shoukuan_type, std::string balance, std::string member_number)
|
|
|
{
|
|
|
//针对现金收款成功,单独做一个打开钱箱的判断处理
|
|
|
@@ -4141,6 +4162,82 @@ void CZhengcanDiandanPageUI::StartWorkAfterShoukuan(std::string kucunstring, std
|
|
|
m_pMainWnd->SwitchPage(CMainWnd::ZHENGCAN);
|
|
|
}
|
|
|
|
|
|
+CZhengcanOrder CZhengcanDiandanPageUI::GetPrintOrderinfoXiadan(std::string show_trade_no)
|
|
|
+{
|
|
|
+ m_cur_diandan_order.shopname = CShopinfo::GetInstance()->m_shop_name;
|
|
|
+ m_cur_diandan_order.show_trade_no = show_trade_no;
|
|
|
+ m_cur_diandan_order.table_name = m_table_name;
|
|
|
+
|
|
|
+ m_cur_diandan_order.order_from = 1;
|
|
|
+ m_cur_diandan_order.init_time = CLewaimaiTime::DatetimeToString(time(NULL));
|
|
|
+
|
|
|
+ for (std::vector<CZhengcanOrderItem>::iterator it = m_cur_diandan_order.m_items.begin(); it != m_cur_diandan_order.m_items.end(); it++)
|
|
|
+ {
|
|
|
+ CZhengcanOrderItemPrint itemPrint;
|
|
|
+
|
|
|
+ itemPrint.m_food_name = it->getNameWanzhengShow();
|
|
|
+ itemPrint.m_quantity = it->num;
|
|
|
+ itemPrint.m_item_price = it->getSinglePrice();
|
|
|
+ itemPrint.m_type_id = it->type_id;
|
|
|
+
|
|
|
+ if (it->m_is_taocan == true)
|
|
|
+ {
|
|
|
+ itemPrint.is_taocan = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ m_cur_diandan_order.m_items_print.push_back(itemPrint);
|
|
|
+
|
|
|
+ if (it->m_is_taocan == true)
|
|
|
+ {
|
|
|
+ //开始保存套餐里面的商品详情,主要用于厨房打印
|
|
|
+ CFoodpackage foodpackageinfo;
|
|
|
+ foodpackageinfo = it->GetFoodpackageInfo();
|
|
|
+
|
|
|
+ std::string nature = foodpackageinfo.nature;
|
|
|
+
|
|
|
+ rapidjson::Document document;
|
|
|
+ document.Parse(nature.c_str());
|
|
|
+
|
|
|
+ if (document.HasParseError())
|
|
|
+ {
|
|
|
+ //属性json报错,直接不处理了
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ rapidjson::Value& data = document;
|
|
|
+
|
|
|
+ //接下来要把这个套餐的详情也保存下来
|
|
|
+ for (std::vector<FoodNatureSelectValue>::iterator it_2 = it->natureSelectedArray.begin(); it_2 != it->natureSelectedArray.end(); it_2++)
|
|
|
+ {
|
|
|
+ std::string food_id = data[it_2->nNameIndex]["value"][it_2->nature_select_index].GetString();
|
|
|
+
|
|
|
+ //要根据商品ID找出商品的名字
|
|
|
+ CFood foodinfo;
|
|
|
+ CSqlite3 sqlite;
|
|
|
+ bool is_found = sqlite.GetFoodById(food_id, foodinfo);
|
|
|
+ if (!is_found)
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ CZhengcanOrderItemPrint foodpackageitemPrint;
|
|
|
+
|
|
|
+ foodpackageitemPrint.m_food_name = foodinfo.name;
|
|
|
+ foodpackageitemPrint.m_quantity = it->num;
|
|
|
+ foodpackageitemPrint.m_item_price = foodinfo.price;
|
|
|
+ foodpackageitemPrint.m_type_id = foodinfo.type_id;
|
|
|
+
|
|
|
+ foodpackageitemPrint.is_taocan = false;
|
|
|
+ foodpackageitemPrint.is_taocan_item = true;
|
|
|
+
|
|
|
+ m_cur_diandan_order.m_items_print.push_back(foodpackageitemPrint);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return m_cur_diandan_order;
|
|
|
+}
|
|
|
+
|
|
|
CZhengcanOrder CZhengcanDiandanPageUI::GetPrintOrderinfo(std::string take_food_code, std::string show_trade_no, std::string shoukuan_type, std::string balance, std::string member_number)
|
|
|
{
|
|
|
m_cur_diandan_order.shopname = CShopinfo::GetInstance()->m_shop_name;
|