|
|
@@ -33,7 +33,13 @@ void CMqttClientWorker::Start()
|
|
|
|
|
|
void CMqttClientWorker::Stop()
|
|
|
{
|
|
|
- m_is_running = false;
|
|
|
+ m_is_running = false;
|
|
|
+
|
|
|
+ //等待进程结束
|
|
|
+ while (m_nStopNum < 1)
|
|
|
+ {
|
|
|
+ Sleep(50);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
void CMqttClientWorker::Run()
|
|
|
@@ -242,19 +248,37 @@ void CMqttClientWorker::HandleMessage(std::string message)
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- rapidjson::Value& data = document["data"];
|
|
|
+ if (!document.HasMember("version"))
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ std::string version = CLewaimaiJson::ToString(document["version"]);
|
|
|
+ if (version < "1.0")
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- int type = CLewaimaiJson::ToInt(data["msg_type"]);
|
|
|
+ std::string timestamp = CLewaimaiJson::ToString(document["timestamp"]);
|
|
|
+ long int int_timesteamp = atol(timestamp.c_str());
|
|
|
|
|
|
- if (type == MESSAGE_TYPE::LOGIN_OFFLINE)
|
|
|
+ time_t now = time(NULL);
|
|
|
+
|
|
|
+ if (now - int_timesteamp > 60 * 3)
|
|
|
{
|
|
|
- //这个表示被人挤下线了
|
|
|
- PostMessage(m_hwnd, WM_LOGIN_AGAIN_OUT, 0, 0);
|
|
|
+ //大于3分钟的消息直接丢弃
|
|
|
+ return;
|
|
|
}
|
|
|
- else if (type == MESSAGE_TYPE::NEW_WAIMAI_ORDER)
|
|
|
+
|
|
|
+ rapidjson::Value& data = document["body"];
|
|
|
+
|
|
|
+ std::string type = CLewaimaiJson::ToString(data["order_type"]);
|
|
|
+
|
|
|
+ if (type == "waimai")
|
|
|
{
|
|
|
- std::string order_id = CLewaimaiJson::ToString(data["waimai_order_id"]);
|
|
|
- std::string order_no = CLewaimaiJson::ToString(data["waimai_order_no"]);
|
|
|
+ //外卖新订单(非预约单,或者预约单快到时间了)
|
|
|
+ std::string order_id = CLewaimaiJson::ToString(data["order_id"]);
|
|
|
+ std::string order_no = CLewaimaiJson::ToString(data["order_no"]);
|
|
|
|
|
|
//新订单来了,首先判断是否要语音提醒
|
|
|
if (CSetting::GetInstance()->GetParam("setting_is_new_waimai_voice") == "1")
|
|
|
@@ -278,17 +302,38 @@ void CMqttClientWorker::HandleMessage(std::string message)
|
|
|
CPosPrinter printer;
|
|
|
printer.PrintWaimaiOrder(order_id, order_no);
|
|
|
}
|
|
|
- else if (type == MESSAGE_TYPE::QUXIAO_WAIMAI_ORDER)
|
|
|
+ else if (type == "waimai_yuyue_notify")
|
|
|
{
|
|
|
+ //外卖新订单(预约单的通知)
|
|
|
+ std::string order_id = CLewaimaiJson::ToString(data["order_id"]);
|
|
|
+ std::string order_no = CLewaimaiJson::ToString(data["order_no"]);
|
|
|
+
|
|
|
+ //新订单来了,首先判断是否要语音提醒
|
|
|
+ if (CSetting::GetInstance()->GetParam("setting_is_new_waimai_voice") == "1")
|
|
|
+ {
|
|
|
+ CVoiceWorker::GetInstance()->AddVoice(1);
|
|
|
+ }
|
|
|
+
|
|
|
+ //判断是否要自动确认
|
|
|
+ if (CSetting::GetInstance()->GetParam("setting_is_new_waimai_autoconfirm") == "1")
|
|
|
+ {
|
|
|
+ CCommonWorker::GetInstance()->AddConfirm(order_id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (type == "waimai_cancel")
|
|
|
+ {
|
|
|
+ //取消外卖订单
|
|
|
CVoiceWorker::GetInstance()->AddVoice(3);
|
|
|
}
|
|
|
- else if (type == MESSAGE_TYPE::REFUND_WAIMAI_ORDER)
|
|
|
+ else if (type == "waimai_order_refund")
|
|
|
{
|
|
|
+ //外卖订单退款
|
|
|
CVoiceWorker::GetInstance()->AddVoice(4);
|
|
|
}
|
|
|
- else if (type == MESSAGE_TYPE::NEW_KAUICANTANGSHI_ORDER)
|
|
|
+ else if (type == "tangshi")
|
|
|
{
|
|
|
- std::string order_id = CLewaimaiJson::ToString(data["waimai_order_id"]);
|
|
|
+ //快餐扫码下单
|
|
|
+ std::string order_id = CLewaimaiJson::ToString(data["order_id"]);
|
|
|
|
|
|
//新订单来了,首先判断是否要语音提醒
|
|
|
if (CSetting::GetInstance()->GetParam("setting_is_new_diannei_voice") == "1")
|
|
|
@@ -302,9 +347,10 @@ void CMqttClientWorker::HandleMessage(std::string message)
|
|
|
printer.PrintDiandanOrder(order_id);
|
|
|
}
|
|
|
}
|
|
|
- else if (type == MESSAGE_TYPE::NEW_KUAICANSHANGJIAAPP_ORDER)
|
|
|
+ else if (type == "kuaican")
|
|
|
{
|
|
|
- std::string order_id = CLewaimaiJson::ToString(data["waimai_order_id"]);
|
|
|
+ //新的快餐订单,商家app下单
|
|
|
+ std::string order_id = CLewaimaiJson::ToString(data["order_id"]);
|
|
|
|
|
|
//新订单来了,首先判断是否要语音提醒
|
|
|
if (CSetting::GetInstance()->GetParam("setting_is_new_diannei_voice") == "1")
|
|
|
@@ -318,9 +364,10 @@ void CMqttClientWorker::HandleMessage(std::string message)
|
|
|
printer.PrintDiandanOrder(order_id);
|
|
|
}
|
|
|
}
|
|
|
- else if (type == MESSAGE_TYPE::NEW_ZHENGCAN_JIACAI)
|
|
|
+ else if (type == "zhengcan_jiacai")
|
|
|
{
|
|
|
- std::string order_id = CLewaimaiJson::ToString(data["waimai_order_id"]);
|
|
|
+ //这个是通过商家app加菜,或者H5加菜被商家app确认,提醒收银系统去打印
|
|
|
+ std::string order_id = CLewaimaiJson::ToString(data["order_id"]);
|
|
|
std::string jiacai_no = CLewaimaiJson::ToString(data["jiacai_no"]);
|
|
|
|
|
|
if (CSetting::GetInstance()->GetParam("setting_is_new_diannei_saomadiancan_printer") == "1")
|
|
|
@@ -329,16 +376,18 @@ void CMqttClientWorker::HandleMessage(std::string message)
|
|
|
printer.PrintZhengcanOrderXiadan(order_id, jiacai_no);
|
|
|
}
|
|
|
}
|
|
|
- else if (type == MESSAGE_TYPE::NEW_ZHENGCAN_H5_JIACAI)
|
|
|
+ else if (type == "zhengcan_jiacai_h5")
|
|
|
{
|
|
|
+ //通过扫码下单加菜,还没确认,提醒收银系统确认
|
|
|
CVoiceWorker::GetInstance()->AddVoice(6);
|
|
|
|
|
|
//同时自动刷新桌位
|
|
|
PostMessage(m_hwnd, WM_ZHENGCAN_SAOMADIANCAI_XIADAN, 0, 0);
|
|
|
}
|
|
|
- else if (type == MESSAGE_TYPE::NEW_ZHENGCAN_TUICAI)
|
|
|
+ else if (type == "zhengcan_tuicai")
|
|
|
{
|
|
|
- std::string order_id = CLewaimaiJson::ToString(data["waimai_order_id"]);
|
|
|
+ //正餐退菜
|
|
|
+ std::string order_id = CLewaimaiJson::ToString(data["order_id"]);
|
|
|
std::string tuicai_item_id = CLewaimaiJson::ToString(data["tuicai_item_id"]);
|
|
|
|
|
|
if (CSetting::GetInstance()->GetParam("setting_is_new_diannei_saomadiancan_printer") == "1")
|
|
|
@@ -347,9 +396,10 @@ void CMqttClientWorker::HandleMessage(std::string message)
|
|
|
printer.PrintZhengcanOrderTuicai(order_id, tuicai_item_id);
|
|
|
}
|
|
|
}
|
|
|
- else if (type == MESSAGE_TYPE::NEW_ZHENGCAN_JIESUAN)
|
|
|
+ else if (type == "zhengcan_jiesuan")
|
|
|
{
|
|
|
- std::string order_id = CLewaimaiJson::ToString(data["waimai_order_id"]);
|
|
|
+ //推送正餐收银订单H5上支付成功的消息给收银机,收银打印结算小票
|
|
|
+ std::string order_id = CLewaimaiJson::ToString(data["order_id"]);
|
|
|
|
|
|
if (CSetting::GetInstance()->GetParam("setting_is_new_diannei_saomadiancan_printer") == "1")
|
|
|
{
|
|
|
@@ -357,6 +407,26 @@ void CMqttClientWorker::HandleMessage(std::string message)
|
|
|
printer.PrintZhengcanOrderJiesuan(order_id);
|
|
|
}
|
|
|
}
|
|
|
+ else if (type == "shouyintai_order")
|
|
|
+ {
|
|
|
+ std::string content = CLewaimaiJson::ToString(data["content"]);
|
|
|
+
|
|
|
+ CVoiceWorker::GetInstance()->AddVoice(content);
|
|
|
+ }
|
|
|
+ else if (type == "tangshi_service")
|
|
|
+ {
|
|
|
+ std::string content = CLewaimaiJson::ToString(data["content"]);
|
|
|
+
|
|
|
+ CVoiceWorker::GetInstance()->AddVoice(content);
|
|
|
+ }
|
|
|
+ else if (type == "yuyue_order")
|
|
|
+ {
|
|
|
+ //预约功能的预约单,不是外卖的预约单
|
|
|
+ std::string order_id = CLewaimaiJson::ToString(data["order_id"]);
|
|
|
+ std::string content = CLewaimaiJson::ToString(data["content"]);
|
|
|
+
|
|
|
+ CVoiceWorker::GetInstance()->AddVoice(content);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
void CMqttClientWorker::AddStopNum()
|