Commit 3f7705ee by wuyang.zou

1、当店员正在为线下客户服务时,触发异常请求:actionId=6,gloSimErrCode=20;用来解锁外卖插件的悬浮框;

2、门店店员切换账号后,及时更新显示到插件上的收银员;
3、修复外卖插件,有订单待录入POS时,会一直闪烁提醒;
parent ce69fe0e
...@@ -32,6 +32,7 @@ FlowControl::FlowControl() ...@@ -32,6 +32,7 @@ FlowControl::FlowControl()
{ {
m_bLoginResult =false; m_bLoginResult =false;
m_bFirstRecvInfo = true; m_bFirstRecvInfo = true;
m_bFloatFromLockSt = false;
m_loginSocket = NULL; m_loginSocket = NULL;
m_pullOrderSocket = NULL; m_pullOrderSocket = NULL;
...@@ -44,9 +45,11 @@ FlowControl::FlowControl() ...@@ -44,9 +45,11 @@ FlowControl::FlowControl()
m_pullTimer=new QTimer(this); m_pullTimer=new QTimer(this);
m_loginTimer=new QTimer(this); m_loginTimer=new QTimer(this);
m_notifySimPullTimer = new QTimer(this); m_notifySimPullTimer = new QTimer(this);
m_remindCasherBlinkFloatTimer = new QTimer(this);
connect(m_loginTimer,&QTimer::timeout,this,&FlowControl::_ClickToLogin); connect(m_loginTimer,&QTimer::timeout,this,&FlowControl::_ClickToLogin);
connect(m_notifySimPullTimer,&QTimer::timeout,this,&FlowControl::_ClickToNotifySimPullOrder); connect(m_notifySimPullTimer,&QTimer::timeout,this,&FlowControl::_ClickToNotifySimPullOrder);
connect(m_remindCasherBlinkFloatTimer,&QTimer::timeout,this,&FlowControl::_RemindCasherBlinkFloatForm);
connect(m_pullTimer,&QTimer::timeout,this,&FlowControl::_PullOrderData); connect(m_pullTimer,&QTimer::timeout,this,&FlowControl::_PullOrderData);
connect(m_clearTimer,&QTimer::timeout,this,&FlowControl::_CrondClearExpireOrder); connect(m_clearTimer,&QTimer::timeout,this,&FlowControl::_CrondClearExpireOrder);
connect(m_heartTimer,&QTimer::timeout,this,&FlowControl::_SendHeart); connect(m_heartTimer,&QTimer::timeout,this,&FlowControl::_SendHeart);
...@@ -188,13 +191,24 @@ bool FlowControl::_TryAddOrderPull(const QString &orderId, const QString &channe ...@@ -188,13 +191,24 @@ bool FlowControl::_TryAddOrderPull(const QString &orderId, const QString &channe
{ {
bool btryLock = m_PullOrderDataMutex.tryLock(2000); bool btryLock = m_PullOrderDataMutex.tryLock(2000);
if (btryLock){ if (btryLock){
QLOG_INFO()<<QString::fromLocal8Bit("[<<<<---FlowControl::_TryAddOrderPull orderId:%1--->>>>]").arg(orderId);
//调用此函数:_TryAddOrderPull() 的函数:_ResponseOMS11Request()没有能百分之百锁定住:插件正触发Simphony在录销售单时,插件立刻接受到OMS推送过来的退货单;
if(!m_simValidOrdersList.isEmpty()){
//缩小锁住订单的条件范围: 服务端推单给插件程序且插件程序拒绝本次订单状态发生变化的请求
if(orderId == m_simValidOrdersList.first() && m_bFloatFromLockSt) {
QLOG_INFO()<<QString::fromLocal8Bit("[<<<<---FlowControl::_TryAddOrderPull orderId:%1 当前订单正在录POS系统,请耐心等待--->>>>]").arg(orderId);
m_PullOrderDataMutex.unlock();
return false;
}
}
/***组装从FM外卖service端的拉单请求参数***/ /***组装从FM外卖service端的拉单请求参数***/
PullOrderInfo* orderPull = new PullOrderInfo(); PullOrderInfo* orderPull = new PullOrderInfo();
orderPull->orderId=orderId; orderPull->orderId=orderId;
orderPull->channel=channel; orderPull->channel=channel;
orderPull->pageNumber=pageNumber; orderPull->pageNumber=pageNumber;
orderPull->pageSize=pageSize; orderPull->pageSize=pageSize;
QLOG_INFO()<<QString::fromLocal8Bit("[<<<<---FlowControl::_TryAddOrderPull orderId:%1--->>>>]").arg(orderId);
m_orderPullList.append(orderPull); m_orderPullList.append(orderPull);
m_PullOrderDataMutex.unlock(); m_PullOrderDataMutex.unlock();
} }
...@@ -237,13 +251,14 @@ void FlowControl::_ClickToLogin() ...@@ -237,13 +251,14 @@ void FlowControl::_ClickToLogin()
void FlowControl::_ClickToNotifySimPullOrder() void FlowControl::_ClickToNotifySimPullOrder()
{ {
QLOG_INFO()<<QString::fromLocal8Bit("[<<<<---触发按钮点击事件:_ClickToNotifySimPullOrder: m_simValidOrdersList.isEmpty():%2--->>>>>]").arg(m_simValidOrdersList.isEmpty()); QLOG_INFO()<<QString::fromLocal8Bit("[<<<<---触发按钮点击事件:_ClickToNotifySimPullOrder: m_simValidOrdersList.isEmpty()==%1--->>>>>]").arg(m_simValidOrdersList.isEmpty());
if(!m_simValidOrdersList.isEmpty()) if(!m_simValidOrdersList.isEmpty())
{ {
m_notifySimPullTimer->start(1000*10); m_notifySimPullTimer->start(1000*10);
QLOG_INFO()<<QString::fromLocal8Bit("[<<<<---FM外卖插件通知 Simphony 获取订单数据--->>>>]"); QLOG_INFO()<<QString::fromLocal8Bit("[<<<<---FM外卖插件通知 Simphony 获取订单数据--->>>>]");
emit doHideMainShowFloatFrom(); emit doHideMainShowFloatFrom();
emit doLockFloatForm(); emit doLockFloatForm();
m_bFloatFromLockSt = true; //更新悬浮框的锁定状态 =true;
_ClickOMSAssignArea(); _ClickOMSAssignArea();
}else{ }else{
m_notifySimPullTimer->start(1000*20); m_notifySimPullTimer->start(1000*20);
...@@ -251,6 +266,20 @@ void FlowControl::_ClickToNotifySimPullOrder() ...@@ -251,6 +266,20 @@ void FlowControl::_ClickToNotifySimPullOrder()
} }
void FlowControl::_RemindCasherBlinkFloatForm()
{
QLOG_INFO()<<QString::fromLocal8Bit("[<<<<---_RemindCasherBlinkFloatForm: m_simValidOrdersList.isEmpty()==%1--->>>>>]").arg(m_simValidOrdersList.isEmpty());
if(!m_simValidOrdersList.isEmpty())
{
m_remindCasherBlinkFloatTimer->start(1000*5);
emit startRemind(REMIND_SIM_ORDERLIST_NOEMPTY);
}else{
m_remindCasherBlinkFloatTimer->start(1000*15);
}
}
void FlowControl::_OrderAnalysis(const QJsonObject& jsonObject) void FlowControl::_OrderAnalysis(const QJsonObject& jsonObject)
{ {
OrderObject *orderObject = NULL; OrderObject *orderObject = NULL;
...@@ -340,6 +369,7 @@ void FlowControl::_OrderAnalysis(const QJsonObject& jsonObject) ...@@ -340,6 +369,7 @@ void FlowControl::_OrderAnalysis(const QJsonObject& jsonObject)
}else{ }else{
emit doHideMainShowFloatFrom(); emit doHideMainShowFloatFrom();
emit doLockFloatForm(); emit doLockFloatForm();
m_bFloatFromLockSt = true; //更新悬浮框的锁定状态 =true;
_ClickOMSAssignArea(); _ClickOMSAssignArea();
} }
} }
...@@ -365,6 +395,7 @@ void FlowControl::_OrderAnalysis(const QJsonObject& jsonObject) ...@@ -365,6 +395,7 @@ void FlowControl::_OrderAnalysis(const QJsonObject& jsonObject)
}else{ }else{
emit doHideMainShowFloatFrom(); emit doHideMainShowFloatFrom();
emit doLockFloatForm(); emit doLockFloatForm();
m_bFloatFromLockSt = true; //更新悬浮框的锁定状态 =true;
_ClickOMSAssignArea(); _ClickOMSAssignArea();
} }
} }
...@@ -388,6 +419,7 @@ void FlowControl::_OrderAnalysis(const QJsonObject& jsonObject) ...@@ -388,6 +419,7 @@ void FlowControl::_OrderAnalysis(const QJsonObject& jsonObject)
}else{ }else{
emit doHideMainShowFloatFrom(); emit doHideMainShowFloatFrom();
emit doLockFloatForm(); emit doLockFloatForm();
m_bFloatFromLockSt = true; //更新悬浮框的锁定状态 =true;
_ClickOMSAssignArea(); _ClickOMSAssignArea();
} }
} }
...@@ -410,6 +442,7 @@ void FlowControl::_OrderAnalysis(const QJsonObject& jsonObject) ...@@ -410,6 +442,7 @@ void FlowControl::_OrderAnalysis(const QJsonObject& jsonObject)
}else{ }else{
emit doHideMainShowFloatFrom(); emit doHideMainShowFloatFrom();
emit doLockFloatForm(); emit doLockFloatForm();
m_bFloatFromLockSt = true; //更新悬浮框的锁定状态 =true;
_ClickOMSAssignArea(); _ClickOMSAssignArea();
} }
} }
...@@ -453,9 +486,11 @@ void FlowControl::_OrderAnalysis(const QJsonObject& jsonObject) ...@@ -453,9 +486,11 @@ void FlowControl::_OrderAnalysis(const QJsonObject& jsonObject)
QLOG_INFO() << QString("[<<<<---FmTakeout _OrderAnalysis:Cancled m_simValidOrdersList:%1 --->>>>]")<< m_simValidOrdersList; QLOG_INFO() << QString("[<<<<---FmTakeout _OrderAnalysis:Cancled m_simValidOrdersList:%1 --->>>>]")<< m_simValidOrdersList;
QLOG_INFO() << QString("[<<<<---FmTakeout _OrderAnalysis:Cancled _ClickOMSAssignArea --->>>>]"); QLOG_INFO() << QString("[<<<<---FmTakeout _OrderAnalysis:Cancled _ClickOMSAssignArea --->>>>]");
//怕程序会卡死或者程序阻塞,所以只能先将此类订单添加到Simphony的有效队列中; //怕程序会卡死或者程序阻塞,所以只能先将此类订单添加到Simphony的有效队列中;
//emit doHideMainShowFloatFrom(); //May Cause Program Blocking. Add By ZouWuYang For Reduce The Possibility Of Locking Deliver Refund Order. //
//emit doLockFloatForm(); emit doHideMainShowFloatFrom();
//_ClickOMSAssignArea(); emit doLockFloatForm();
m_bFloatFromLockSt = true; //更新悬浮框的锁定状态 =true;
_ClickOMSAssignArea();
} }
/***case:校验此订单push到POS后的小票号是否空:[POS已模拟点单但未返回小票号]***/ /***case:校验此订单push到POS后的小票号是否空:[POS已模拟点单但未返回小票号]***/
//else{未处理} //else{未处理}
...@@ -545,25 +580,21 @@ bool FlowControl::_Login() ...@@ -545,25 +580,21 @@ bool FlowControl::_Login()
}*/ }*/
// 测试oms服务down后,退单时会导致插件程序退出; // 测试oms服务down后,退单时会导致插件程序退出;
qDebug()<<ConfigManger::GetInstance().GetLoginServerUrl()+ QLOG_INFO()<<ConfigManger::GetInstance().GetLoginServerUrl()+
ConfigManger::GetInstance().GetInterfaceName(INI_INTERFACE_ILOGIN); ConfigManger::GetInstance().GetInterfaceName(INI_INTERFACE_ILOGIN);
m_loginSocket->SetUrl(QUrl(ConfigManger::GetInstance().GetLoginServerUrl()+ m_loginSocket->SetUrl(QUrl(ConfigManger::GetInstance().GetLoginServerUrl()+
ConfigManger::GetInstance().GetInterfaceName(INI_INTERFACE_ILOGIN))); ConfigManger::GetInstance().GetInterfaceName(INI_INTERFACE_ILOGIN)));
QLOG_INFO() << QString("[<<<<---_Login Qurl: --->>>>]")<<m_loginSocket->GetUrl(); QLOG_INFO() << QString("[<<<<---_Login Qurl: --->>>>]")<<m_loginSocket->GetUrl();
result = m_loginSocket->PostRequest(sendJson, recvJson, error); result = m_loginSocket->PostRequest(sendJson, recvJson, error);
QLOG_INFO() << QString("[<<<<---Login Finshed--->>>>][result:%1][msg:%2][recvData:").arg(result).arg(error)<<recvJson; QLOG_INFO() << QString("[<<<<---Login Finshed--->>>>][result:%1][msg:%2][recvData:").arg(result).arg(error)<<recvJson;
if(!result) if(!result) {
{
emit showAlert(AlertForm::MSGERROR, QString::fromLocal8Bit("登录失败![网络错误]")); emit showAlert(AlertForm::MSGERROR, QString::fromLocal8Bit("登录失败![网络错误]"));
}else } else {
{
//if(JSON_STATUSCODE_OK != recvJson[JSON_STATUSCODE].toInt()) //if(JSON_STATUSCODE_OK != recvJson[JSON_STATUSCODE].toInt())
if(JSON_STATUSCODE_OK != recvJson[JSON_LOGINCODE].toInt()) if(JSON_STATUSCODE_OK != recvJson[JSON_LOGINCODE].toInt()) {
{
result = false; result = false;
emit showAlert(AlertForm::MSGERROR, QString::fromLocal8Bit("登录失败![%1]").arg(recvJson[JSON_MESSAGE].toString())); emit showAlert(AlertForm::MSGERROR, QString::fromLocal8Bit("登录失败![%1]").arg(recvJson[JSON_MESSAGE].toString()));
}else } else {
{
m_storeName = recvJson[JSON_STORENAME].toString(); m_storeName = recvJson[JSON_STORENAME].toString();
DataManger::GetInstance().SetToken(recvJson[JSON_DATA].toObject()[JSON_TOKEN].toString()); DataManger::GetInstance().SetToken(recvJson[JSON_DATA].toObject()[JSON_TOKEN].toString());
DataManger::GetInstance().SetStoreId(m_storeId); DataManger::GetInstance().SetStoreId(m_storeId);
...@@ -571,18 +602,33 @@ bool FlowControl::_Login() ...@@ -571,18 +602,33 @@ bool FlowControl::_Login()
DataManger::GetInstance().SetPartnerId(ConfigManger::GetInstance().GetPartnerId()); DataManger::GetInstance().SetPartnerId(ConfigManger::GetInstance().GetPartnerId());
emit hideAlert(); emit hideAlert();
emit setStoreInfo(m_storeId); emit setStoreInfo(m_storeId);
//emit setCashierInfo(m_cashierId);
emit setCashierInfo(m_cashierName); emit setCashierInfo(m_cashierName);
//***********************登陆时获取门店的营业状态 begin ************************//
/*
QJsonObject storeStatusData = recvJson[JSON_DATA].toObject();
QLOG_INFO()<<"FlowControl::_Login:"<<storeStatusData;
if(1==storeStatusData["appStoreStatus"].toInt() || 1==storeStatusData["eleStoreStatus"].toInt()) {
QString strOpeStatus = QString::fromLocal8Bit("开店");
emit setOpeStatus(strOpeStatus);
emit doUpdateStoreStatus(true);
}else {
QString strOpeStatus = QString::fromLocal8Bit("关店");
emit setOpeStatus(strOpeStatus);
emit doUpdateStoreStatus(false);
}
*/
//***********************登陆时获取门店的营业状态 end ************************//
m_bLoginResult= true; m_bLoginResult= true;
m_clearTimer->start(1000*60*60*2); // 5分钟执行一次清理任务:正式上线需要两小时清理一次; m_clearTimer->start(1000*60*60*2); // 5分钟执行一次清理任务:正式上线需要两小时清理一次;
m_heartTimer->start(1000*60*5); m_heartTimer->start(1000*60*5);
m_pullTimer->start(1000*2); m_pullTimer->start(1000*2);
m_notifySimPullTimer->start(10*1000); m_notifySimPullTimer->start(10*1000);
m_remindCasherBlinkFloatTimer->start(5*1000);
_AddOrderPull(QString(),QString()); _AddOrderPull(QString(),QString());
} }
} }
if(!result) if(!result) {
{
QLOG_INFO() << QString("[<<<<---Login Retry--->>>>] %1 msec after login...").arg(VALUE_RELOGINTIME); QLOG_INFO() << QString("[<<<<---Login Retry--->>>>] %1 msec after login...").arg(VALUE_RELOGINTIME);
QTimer::singleShot(VALUE_RELOGINTIME, this, &FlowControl::_Login); QTimer::singleShot(VALUE_RELOGINTIME, this, &FlowControl::_Login);
} }
...@@ -876,6 +922,7 @@ bool FlowControl::_ConfirmOrder(const QString &orderId) ...@@ -876,6 +922,7 @@ bool FlowControl::_ConfirmOrder(const QString &orderId)
QLOG_INFO() << QString("[<<<<---FmTakeout _ConfirmOrder: _ClickOMSAssignArea --->>>>]"); QLOG_INFO() << QString("[<<<<---FmTakeout _ConfirmOrder: _ClickOMSAssignArea --->>>>]");
emit doHideMainShowFloatFrom(); emit doHideMainShowFloatFrom();
emit doLockFloatForm(); emit doLockFloatForm();
m_bFloatFromLockSt = true; //更新悬浮框的锁定状态 =true;
_ClickOMSAssignArea(); _ClickOMSAssignArea();
} }
} }
...@@ -944,6 +991,7 @@ bool FlowControl::_RefuseOrder(const QString &orderId, int refuseCode,const QStr ...@@ -944,6 +991,7 @@ bool FlowControl::_RefuseOrder(const QString &orderId, int refuseCode,const QStr
QLOG_INFO() << QString("[<<<<---FmTakeout _RefuseOrder: _ClickOMSAssignArea --->>>>]"); QLOG_INFO() << QString("[<<<<---FmTakeout _RefuseOrder: _ClickOMSAssignArea --->>>>]");
emit doHideMainShowFloatFrom(); emit doHideMainShowFloatFrom();
emit doLockFloatForm(); emit doLockFloatForm();
m_bFloatFromLockSt = true; //更新悬浮框的锁定状态 =true;
_ClickOMSAssignArea(); _ClickOMSAssignArea();
} }
} }
...@@ -1135,6 +1183,7 @@ bool FlowControl::_RefundOrder(const QString &orderId,int reasonCode,const QStri ...@@ -1135,6 +1183,7 @@ bool FlowControl::_RefundOrder(const QString &orderId,int reasonCode,const QStri
if (OrderObject::Refunded == orderObject->orderStatus && OrderObject::SimExceptSale != oldOrderStatus && OrderObject::SimExceptRefund != oldOrderStatus) { if (OrderObject::Refunded == orderObject->orderStatus && OrderObject::SimExceptSale != oldOrderStatus && OrderObject::SimExceptRefund != oldOrderStatus) {
//只有退单成功 且 是录POS 成功的才进行加锁; //只有退单成功 且 是录POS 成功的才进行加锁;
emit doLockFloatForm(); emit doLockFloatForm();
m_bFloatFromLockSt = true; //更新悬浮框的锁定状态 =true;
//能退单成功就肯定能断言,此订单是没有录过退货的 //能退单成功就肯定能断言,此订单是没有录过退货的
// 判断Simphony 队列中的订单是否已经存在:不存在(Simphony已经点单完成后会移除)则添加; 如果存在(说明此订单还拟点单),则需要直接向现存在Sim有效队列中的记录移除;没有模 // 判断Simphony 队列中的订单是否已经存在:不存在(Simphony已经点单完成后会移除)则添加; 如果存在(说明此订单还拟点单),则需要直接向现存在Sim有效队列中的记录移除;没有模
m_OrderEntryMutex.lock(); m_OrderEntryMutex.lock();
...@@ -1161,6 +1210,7 @@ bool FlowControl::_RefundOrder(const QString &orderId,int reasonCode,const QStri ...@@ -1161,6 +1210,7 @@ bool FlowControl::_RefundOrder(const QString &orderId,int reasonCode,const QStri
//正向单已经录入成功,录退单报错的的处理机制; //正向单已经录入成功,录退单报错的的处理机制;
} else if(OrderObject::SimExceptRefund == oldOrderStatus){ } else if(OrderObject::SimExceptRefund == oldOrderStatus){
emit doLockFloatForm(); emit doLockFloatForm();
m_bFloatFromLockSt = true; //更新悬浮框的锁定状态 =true;
m_OrderEntryMutex.lock(); m_OrderEntryMutex.lock();
if(!m_simValidOrdersList.contains(orderObject->id)) //不存在队列中,则将其加入到队列中; if(!m_simValidOrdersList.contains(orderObject->id)) //不存在队列中,则将其加入到队列中;
{ {
...@@ -1483,7 +1533,6 @@ bool FlowControl::_ResponseHttpRequest(const QJsonObject &content,QJsonObject &d ...@@ -1483,7 +1533,6 @@ bool FlowControl::_ResponseHttpRequest(const QJsonObject &content,QJsonObject &d
break; break;
case 4://simphony汇报小票号信息回复 case 4://simphony汇报小票号信息回复
result=_ResponseSimphony04Request(content,data,error); result=_ResponseSimphony04Request(content,data,error);
//emit doUnLockFloatFrom();
break; break;
case 5://simphony更新订单数据到POS本地数据库以便POS打印小票及汇总单信息 回复 case 5://simphony更新订单数据到POS本地数据库以便POS打印小票及汇总单信息 回复
result=_ResponseSimphony05Request(content,data,error); result=_ResponseSimphony05Request(content,data,error);
...@@ -1495,7 +1544,7 @@ bool FlowControl::_ResponseHttpRequest(const QJsonObject &content,QJsonObject &d ...@@ -1495,7 +1544,7 @@ bool FlowControl::_ResponseHttpRequest(const QJsonObject &content,QJsonObject &d
result=_ResponseOMS11Request(content,data,error); result=_ResponseOMS11Request(content,data,error);
break; break;
case 12://推送门店营业状态 case 12://推送门店营业状态
result=_ResponseSimphony12Request(content,data,error); result=_ResponseOMS12Request(content,data,error);
break; break;
case 21://盒马生鲜 推送订单 case 21://盒马生鲜 推送订单
result=_ResponseHM21Request(content,data,error); result=_ResponseHM21Request(content,data,error);
...@@ -1562,6 +1611,8 @@ bool FlowControl::_ResponseSimphony04Request(const QJsonObject &content, QJsonOb ...@@ -1562,6 +1611,8 @@ bool FlowControl::_ResponseSimphony04Request(const QJsonObject &content, QJsonOb
if (!order_p) { if (!order_p) {
QLOG_ERROR()<<QString::fromLocal8Bit("[<<<<---%1订单并不存在m_FmOrdersMap[键值对]中;m_FmOrdersMap.size()=%2--->>>>]").arg(orderId).arg(m_FmOrdersMap.size()); QLOG_ERROR()<<QString::fromLocal8Bit("[<<<<---%1订单并不存在m_FmOrdersMap[键值对]中;m_FmOrdersMap.size()=%2--->>>>]").arg(orderId).arg(m_FmOrdersMap.size());
error=QString::fromLocal8Bit("Request Action04: %1 Delivery Order Don't Exist In m_FmOrdersMap[key-map] m_FmOrdersMap.size()=%2").arg(orderId).arg(m_FmOrdersMap.size()); error=QString::fromLocal8Bit("Request Action04: %1 Delivery Order Don't Exist In m_FmOrdersMap[key-map] m_FmOrdersMap.size()=%2").arg(orderId).arg(m_FmOrdersMap.size());
emit doUnLockFloatFrom();//****************解锁悬浮框**************//
m_bFloatFromLockSt = false; //更新悬浮框的锁定状态 =false;
return false; return false;
} }
...@@ -1614,9 +1665,8 @@ bool FlowControl::_ResponseSimphony04Request(const QJsonObject &content, QJsonOb ...@@ -1614,9 +1665,8 @@ bool FlowControl::_ResponseSimphony04Request(const QJsonObject &content, QJsonOb
result=false; result=false;
error=QString::fromLocal8Bit("Request Action04: Request Pragram Error"); error=QString::fromLocal8Bit("Request Action04: Request Pragram Error");
} }
//****************解锁悬浮框**************// emit doUnLockFloatFrom();//****************解锁悬浮框**************//
emit doUnLockFloatFrom(); m_bFloatFromLockSt = false; //更新悬浮框的锁定状态 =false;
return result; return result;
} }
...@@ -1713,10 +1763,34 @@ bool FlowControl::_ResponseSimphony06Request(const QJsonObject &content, QJsonOb ...@@ -1713,10 +1763,34 @@ bool FlowControl::_ResponseSimphony06Request(const QJsonObject &content, QJsonOb
QString simExceptCode=content["simExceptCode"].toString(); QString simExceptCode=content["simExceptCode"].toString();
if(!simExceptCode.isEmpty()&&!orderId.isEmpty()) { if(!simExceptCode.isEmpty()&&!orderId.isEmpty()) {
//新增一种case: 门店店员正在操作POS,从而阻塞插件程序录外卖订单,此时必须解锁悬浮框,从而减少Simphony队列中first出现OMS退单的请求;
//此时的订单号时固定给的620620 [action:6,simExceptCode=20]
if( 20 == simExceptCode.toInt() ){
error=QString::fromLocal8Bit("Request Action06: Partner is serving Offline Customer ");
QLOG_INFO()<<QString::fromLocal8Bit("[<<<<---_ResponseSimphony06Request::%1--->>>>>]").arg(error);
emit doUnLockFloatFrom(); //****************解锁悬浮框*****************//
m_bFloatFromLockSt = false; //更新悬浮框的锁定状态 =false;
QJsonObject rObj, cObj;
rObj.insert("fm_cmd", "");
rObj.insert("fm_ver", "1.0");
cObj.insert("pay_id", "002");
cObj.insert("pay_str", QString::fromLocal8Bit("FmTakeout"));
cObj.insert("reqResult",1); //响应SIM汇报异常结果:[1:处理异常成功;0:处理异常失败]
cObj.insert("paid_trans_id",orderId);
rObj.insert("pay_id", cObj);
data = rObj;
return true;
}
OrderObject* order_p = m_FmOrdersMap.value(orderId); OrderObject* order_p = m_FmOrdersMap.value(orderId);
if (!order_p) { if (!order_p) {
QLOG_ERROR()<<QString::fromLocal8Bit("[<<<<---%1订单并不存在m_FmOrdersMap[键值对]中;m_FmOrdersMap.size()=%2--->>>>]").arg(orderId).arg(m_FmOrdersMap.size()); QLOG_ERROR()<<QString::fromLocal8Bit("[<<<<---%1订单并不存在m_FmOrdersMap[键值对]中;m_FmOrdersMap.size()=%2--->>>>]").arg(orderId).arg(m_FmOrdersMap.size());
error=QString::fromLocal8Bit("Request Action06: %1 Delivery Order Don't Exist In m_FmOrdersMap[key-map]; m_FmOrdersMap.size()=%2").arg(orderId).arg(m_FmOrdersMap.size()); error=QString::fromLocal8Bit("Request Action06: %1 Delivery Order Don't Exist In m_FmOrdersMap[key-map]; m_FmOrdersMap.size()=%2").arg(orderId).arg(m_FmOrdersMap.size());
emit doUnLockFloatFrom();//****************解锁悬浮框*****************//
m_bFloatFromLockSt = false; //更新悬浮框的锁定状态 =false;
return false; return false;
} }
// 判断SIM是否存在错误码: // 判断SIM是否存在错误码:
...@@ -1773,6 +1847,7 @@ bool FlowControl::_ResponseSimphony06Request(const QJsonObject &content, QJsonOb ...@@ -1773,6 +1847,7 @@ bool FlowControl::_ResponseSimphony06Request(const QJsonObject &content, QJsonOb
} }
//****************解锁悬浮框*****************// //****************解锁悬浮框*****************//
emit doUnLockFloatFrom(); emit doUnLockFloatFrom();
m_bFloatFromLockSt = false; //更新悬浮框的锁定状态 =false;
return result; return result;
} }
...@@ -1794,7 +1869,8 @@ bool FlowControl::_ResponseOMS11Request(const QJsonObject &content, QJsonObject ...@@ -1794,7 +1869,8 @@ bool FlowControl::_ResponseOMS11Request(const QJsonObject &content, QJsonObject
} else { } else {
if(!m_simValidOrdersList.isEmpty()){ if(!m_simValidOrdersList.isEmpty()){
QString simValidOrderListFirstOne = m_simValidOrdersList.first(); QString simValidOrderListFirstOne = m_simValidOrdersList.first();
if(content[JSON_ORDER_ID].toString() == simValidOrderListFirstOne){ //缩小锁住订单的条件范围: 服务端推单给插件程序且插件程序拒绝本次订单状态发生变化的请求
if(content[JSON_ORDER_ID].toString() == simValidOrderListFirstOne && m_bFloatFromLockSt){
error =QString::fromLocal8Bit("当前订单正在录POS系统,请耐心等待"); error =QString::fromLocal8Bit("当前订单正在录POS系统,请耐心等待");
return false; return false;
} }
...@@ -1814,20 +1890,38 @@ bool FlowControl::_ResponseOMS11Request(const QJsonObject &content, QJsonObject ...@@ -1814,20 +1890,38 @@ bool FlowControl::_ResponseOMS11Request(const QJsonObject &content, QJsonObject
} }
return result; return result;
} }
bool FlowControl::_ResponseSimphony12Request(const QJsonObject &content, QJsonObject &data, QString &error)
bool FlowControl::_ResponseOMS12Request(const QJsonObject &content, QJsonObject &data, QString &error)
{ {
QLOG_INFO()<<__FUNCTION__;
Q_UNUSED(data); Q_UNUSED(data);
if(!content["storeId"].toString().compare(m_storeId)) //判断当前POS插件是否登录成功: 如果没有登录成功,尝试在次登录;
{ bool result = true;
QJsonArray array=content["data"].toArray(); if(!m_bLoginResult&&content.contains("storeId")) {
emit setStoreStatusChanged(array); result=_ResponseSimReqTryLogin(content,error);
error=QString("success");
return true;
} }
else{ //如果登录成功 or 插件正在尝试登录中:则return true 并返回相应的错误信息;
error=QString::fromLocal8Bit("门店信息不匹配"); if(result){
if(!content["storeId"].toString().compare(m_storeId)) {
QJsonObject storeStatusData = content["data"].toObject();
QLOG_INFO()<<"FlowControl::_ResponseOMS12Request:"<<storeStatusData;
if(1==storeStatusData["appStoreStatus"].toInt() || 1==storeStatusData["eleStoreStatus"].toInt()) {
QString strOpeStatus=QString::fromLocal8Bit("开店");
emit setOpeStatus(strOpeStatus);
emit doUpdateStoreStatus(true);
}else {
QString strOpeStatus=QString::fromLocal8Bit("关店");
emit setOpeStatus(strOpeStatus);
emit doUpdateStoreStatus(false);
}
error=QString("success");
result = true;
} else {
error=QString::fromLocal8Bit("门店信息不匹配");
result = false;
}
} }
return false; return result;
} }
...@@ -1853,14 +1947,14 @@ bool FlowControl::_ResponseHM21Request(const QJsonObject &content, QJsonObject & ...@@ -1853,14 +1947,14 @@ bool FlowControl::_ResponseHM21Request(const QJsonObject &content, QJsonObject &
} else { } else {
if(!m_simValidOrdersList.isEmpty()){ if(!m_simValidOrdersList.isEmpty()){
QString simValidOrderListFirstOne = m_simValidOrdersList.first(); QString simValidOrderListFirstOne = m_simValidOrdersList.first();
if(content[JSON_ORDER_ID].toString() == simValidOrderListFirstOne){ //缩小锁住订单的条件范围: 服务端推单给插件程序且插件程序拒绝本次订单状态发生变化的请求
if(content[JSON_ORDER_ID].toString() == simValidOrderListFirstOne && m_bFloatFromLockSt){
error =QString::fromLocal8Bit("当前订单正在录POS系统,请耐心等待"); error =QString::fromLocal8Bit("当前订单正在录POS系统,请耐心等待");
return false; return false;
} }
} }
} }
QJsonObject hmOrderJson = content["orderDetail"].toObject(); QJsonObject hmOrderJson = content["orderDetail"].toObject();
QLOG_INFO()<<"FlowControl::_ResponseHM21Request:"<<hmOrderJson; QLOG_INFO()<<"FlowControl::_ResponseHM21Request:"<<hmOrderJson;
if(!hmOrderJson.isEmpty()){ if(!hmOrderJson.isEmpty()){
...@@ -1905,6 +1999,7 @@ bool FlowControl::_ResponseSimReqFristOrderData(const QJsonObject &content, QJso ...@@ -1905,6 +1999,7 @@ bool FlowControl::_ResponseSimReqFristOrderData(const QJsonObject &content, QJso
m_posId=content["posId"].toString(); m_posId=content["posId"].toString();
m_cashierId=content["operatorId"].toString(); m_cashierId=content["operatorId"].toString();
m_cashierName=content["operatorName"].toString(); m_cashierName=content["operatorName"].toString();
emit setCashierInfo(m_cashierName); //POS上收银员切换账号后,插件上右下角的收银员信息也及时更新;
QLOG_INFO()<<QString::fromLocal8Bit("[<<<<---Simphony_Script请求[ACTION:01: 获取订单数据] 开始获取 OrderId:%1 给simphony:--->>>>>]").arg(orderId); QLOG_INFO()<<QString::fromLocal8Bit("[<<<<---Simphony_Script请求[ACTION:01: 获取订单数据] 开始获取 OrderId:%1 给simphony:--->>>>>]").arg(orderId);
bool result=true; bool result=true;
...@@ -2152,26 +2247,21 @@ void FlowControl::onGetBusinessStatus() ...@@ -2152,26 +2247,21 @@ void FlowControl::onGetBusinessStatus()
sendJson = DataManger::GetInstance().GetStoreChannelInfoData(); sendJson = DataManger::GetInstance().GetStoreChannelInfoData();
m_pullDishesSocket->SetUrl(QUrl(ConfigManger::GetInstance().GetStoreServerUrl()+ m_pullDishesSocket->SetUrl(QUrl(ConfigManger::GetInstance().GetStoreServerUrl()+
ConfigManger::GetInstance().GetInterfaceName(INI_INTERFACE_GETSTORESTATE))); ConfigManger::GetInstance().GetInterfaceName(INI_INTERFACE_GETSTORESTATE)));
qDebug()<<ConfigManger::GetInstance().GetStoreServerUrl()+ ConfigManger::GetInstance().GetInterfaceName(INI_INTERFACE_GETSTORESTATE); QLOG_INFO()<<ConfigManger::GetInstance().GetStoreServerUrl()+ ConfigManger::GetInstance().GetInterfaceName(INI_INTERFACE_GETSTORESTATE);
emit showAlert(AlertForm::LOADING, QString::fromLocal8Bit("正在获取平台营业状态......")); emit showAlert(AlertForm::LOADING, QString::fromLocal8Bit("正在获取平台营业状态......"));
QLOG_INFO() << QString("[---GetStoreChannelInfo---]. [requestData:%1]")<<sendJson; QLOG_INFO() << QString("[---GetStoreChannelInfo---]. [requestData:%1]")<<sendJson;
result = m_pullDishesSocket->PostRequest(sendJson, recvJson, error); result = m_pullDishesSocket->PostRequest(sendJson, recvJson, error);
QLOG_INFO() << QString("GetStoreChannelInfo finsh. [result:%1][msg:%2][recvData:%3]") QLOG_INFO() << QString("GetStoreChannelInfo finsh. [result:%1][msg:%2][recvData:%3]")
.arg(result).arg(error)<<recvJson; .arg(result).arg(error)<<recvJson;
if(!result) if(!result) {
{
emit showAlert(AlertForm::MSGERROR, QString::fromLocal8Bit("获取平台营业状态失败![网络错误]")); emit showAlert(AlertForm::MSGERROR, QString::fromLocal8Bit("获取平台营业状态失败![网络错误]"));
}else } else {
{ if(JSON_STATUSCODE_OK != recvJson[JSON_STATUSCODE].toInt()) {
if(JSON_STATUSCODE_OK != recvJson[JSON_STATUSCODE].toInt())
{
emit showAlert(AlertForm::MSGERROR, QString::fromLocal8Bit("获取平台营业状态失败![%1]").arg(recvJson[JSON_MESSAGE].toString())); emit showAlert(AlertForm::MSGERROR, QString::fromLocal8Bit("获取平台营业状态失败![%1]").arg(recvJson[JSON_MESSAGE].toString()));
}else } else {
{
QJsonArray array=recvJson[JSON_DATA].toArray(); QJsonArray array=recvJson[JSON_DATA].toArray();
QStringList strListChannels; QStringList strListChannels;
foreach(QJsonValue v, array) foreach(QJsonValue v, array) {
{
QJsonObject channel = v.toObject(); QJsonObject channel = v.toObject();
QString channelName = channel["channelname"].toString(); QString channelName = channel["channelname"].toString();
QString channelCode = channel["channel"].toString(); QString channelCode = channel["channel"].toString();
...@@ -2180,13 +2270,11 @@ void FlowControl::onGetBusinessStatus() ...@@ -2180,13 +2270,11 @@ void FlowControl::onGetBusinessStatus()
strListChannels.append(channelCode+":"+channelName+":"+channelStatus); strListChannels.append(channelCode+":"+channelName+":"+channelStatus);
} }
if(!strListChannels.isEmpty()) if(!strListChannels.isEmpty()) {
{
emit hideAlert(); emit hideAlert();
// 通知界面显示 // 通知界面显示
emit initChannelsData(strListChannels); // emit initChannelsData(strListChannels);
}else } else {
{
emit showAlert(AlertForm::MSGERROR, QString::fromLocal8Bit("未获取到平台信息!")); emit showAlert(AlertForm::MSGERROR, QString::fromLocal8Bit("未获取到平台信息!"));
} }
} }
......
...@@ -84,6 +84,7 @@ private: ...@@ -84,6 +84,7 @@ private:
QTimer *m_pullTimer; QTimer *m_pullTimer;
QTimer *m_loginTimer; QTimer *m_loginTimer;
QTimer *m_notifySimPullTimer; QTimer *m_notifySimPullTimer;
QTimer *m_remindCasherBlinkFloatTimer; //插件程序收到外卖订单后,需要一致提醒店员[直到此外卖订单被全部录入到POS系统]
// 网络通信 // 网络通信
BillSocket *m_loginSocket; BillSocket *m_loginSocket;
BillSocket *m_pullOrderSocket; BillSocket *m_pullOrderSocket;
...@@ -96,6 +97,8 @@ private: ...@@ -96,6 +97,8 @@ private:
bool m_bFirstRecvInfo; bool m_bFirstRecvInfo;
bool m_bLoginResult; bool m_bLoginResult;
bool m_bOperateResult; bool m_bOperateResult;
// 标记目前悬浮框是否 锁住状态[false:悬浮框解锁状态; true:悬浮框锁住状态];
bool m_bFloatFromLockSt;
// HttpServer // HttpServer
//JQHttpServer::TcpServerManage* m_tcpServerManage; //JQHttpServer::TcpServerManage* m_tcpServerManage;
LoaclHttpServer* loaclHttpServer; LoaclHttpServer* loaclHttpServer;
...@@ -315,6 +318,7 @@ private slots: ...@@ -315,6 +318,7 @@ private slots:
void _ClickOMSAssignArea(); void _ClickOMSAssignArea();
void _ClickToLogin(); void _ClickToLogin();
void _ClickToNotifySimPullOrder(); void _ClickToNotifySimPullOrder();
void _RemindCasherBlinkFloatForm();
void _OrderAnalysis(const QJsonObject &jsonObject); void _OrderAnalysis(const QJsonObject &jsonObject);
...@@ -442,11 +446,11 @@ public slots: ...@@ -442,11 +446,11 @@ public slots:
bool _ResponseOMS11Request(const QJsonObject &content, QJsonObject &data,QString &error); bool _ResponseOMS11Request(const QJsonObject &content, QJsonObject &data,QString &error);
/** /**
*功能:FM外卖插件为响应Simphony请求[action:12 -> Sim/POS推送门店营业状态]准备返回数据 *功能:FM外卖插件为响应OMS推送门店状态 请求[action:12 -> OMS->POS推送门店营业状态]准备返回数据
*参数:1、请求json参数;2、准备返回请求数据的Buff;3、返回错误信息; *参数:1、请求json参数;2、准备返回请求数据的Buff;3、返回错误信息;
*返回:是否准备成功; *返回:是否准备成功;
**/ **/
bool _ResponseSimphony12Request(const QJsonObject &content, QJsonObject &data,QString &error); bool _ResponseOMS12Request(const QJsonObject &content, QJsonObject &data,QString &error);
/** /**
......
...@@ -27,6 +27,9 @@ ...@@ -27,6 +27,9 @@
#include "QsLogDestConsole.h" #include "QsLogDestConsole.h"
#include "QsLogDestFile.h" #include "QsLogDestFile.h"
#include "QsLogDestFunctor.h" #include "QsLogDestFunctor.h"
#include <QDir>
#include <QDate>
#include <QDateTime>
#include <QString> #include <QString>
namespace QsLogging namespace QsLogging
...@@ -37,6 +40,7 @@ Destination::~Destination() ...@@ -37,6 +40,7 @@ Destination::~Destination()
} }
//! destination factory //! destination factory
/*
DestinationPtr DestinationFactory::MakeFileDestination(const QString& filePath, DestinationPtr DestinationFactory::MakeFileDestination(const QString& filePath,
LogRotationOption rotation, const MaxSizeBytes &sizeInBytesToRotateAfter, LogRotationOption rotation, const MaxSizeBytes &sizeInBytesToRotateAfter,
const MaxOldLogCount &oldLogsToKeep) const MaxOldLogCount &oldLogsToKeep)
...@@ -51,6 +55,32 @@ DestinationPtr DestinationFactory::MakeFileDestination(const QString& filePath, ...@@ -51,6 +55,32 @@ DestinationPtr DestinationFactory::MakeFileDestination(const QString& filePath,
return DestinationPtr(new FileDestination(filePath, RotationStrategyPtr(new NullRotationStrategy))); return DestinationPtr(new FileDestination(filePath, RotationStrategyPtr(new NullRotationStrategy)));
} }
*/
DestinationPtr DestinationFactory::MakeFileDestination(const QString& fileDir, const QString &filePrefix, int fileHoldDays,
LogRotationOption rotation, const MaxSizeBytes &sizeInBytesToRotateAfter,const MaxOldLogCount &oldLogsToKeep){
//清理之前的日志
QDir dir(fileDir);
if(dir.exists()) {
dir.setFilter(QDir::Files | QDir::NoSymLinks);
QFileInfoList list = dir.entryInfoList();
foreach(QFileInfo info, list) {
if(info.baseName().startsWith(filePrefix) && QDate::currentDate()>=info.lastModified().date().addDays(fileHoldDays))
{ QFile(info.filePath()).remove();}
}
}
QString logPath = QString("%1/%2%3.log").arg(fileDir, filePrefix, QDate::currentDate().toString("yyyy-MM-dd"));
if (EnableLogRotation == rotation) {
QScopedPointer<SizeRotationStrategy> logRotation(new SizeRotationStrategy);
logRotation->setMaximumSizeInBytes(sizeInBytesToRotateAfter.size);
logRotation->setBackupCount(oldLogsToKeep.count);
return DestinationPtr(new FileDestination(logPath, RotationStrategyPtr(logRotation.take())));
}
return DestinationPtr(new FileDestination(logPath, RotationStrategyPtr(new NullRotationStrategy)));
}
DestinationPtr DestinationFactory::MakeDebugOutputDestination() DestinationPtr DestinationFactory::MakeDebugOutputDestination()
{ {
......
...@@ -94,10 +94,21 @@ struct QSLOG_SHARED_OBJECT MaxOldLogCount ...@@ -94,10 +94,21 @@ struct QSLOG_SHARED_OBJECT MaxOldLogCount
class QSLOG_SHARED_OBJECT DestinationFactory class QSLOG_SHARED_OBJECT DestinationFactory
{ {
public: public:
/*
static DestinationPtr MakeFileDestination(const QString& filePath, static DestinationPtr MakeFileDestination(const QString& filePath,
LogRotationOption rotation = DisableLogRotation, LogRotationOption rotation = DisableLogRotation,
const MaxSizeBytes &sizeInBytesToRotateAfter = MaxSizeBytes(), const MaxSizeBytes &sizeInBytesToRotateAfter = MaxSizeBytes(),
const MaxOldLogCount &oldLogsToKeep = MaxOldLogCount()); const MaxOldLogCount &oldLogsToKeep = MaxOldLogCount());
*/
static DestinationPtr MakeFileDestination(const QString& fileDir,
const QString& filePrefix,
int fileHoldDays = 10,
LogRotationOption rotation = DisableLogRotation,
const MaxSizeBytes &sizeInBytesToRotateAfter = MaxSizeBytes(),
const MaxOldLogCount &oldLogsToKeep = MaxOldLogCount());
static DestinationPtr MakeDebugOutputDestination(); static DestinationPtr MakeDebugOutputDestination();
// takes a pointer to a function // takes a pointer to a function
static DestinationPtr MakeFunctorDestination(Destination::LogFunction f); static DestinationPtr MakeFunctorDestination(Destination::LogFunction f);
......
...@@ -20,6 +20,7 @@ QString g_appDir; ...@@ -20,6 +20,7 @@ QString g_appDir;
QThread tcpThread; QThread tcpThread;
QThread workThread; QThread workThread;
/*
void InitLogger() void InitLogger()
{ {
QString logDir = QString("%1/log").arg(g_appDir); QString logDir = QString("%1/log").arg(g_appDir);
...@@ -33,6 +34,20 @@ void InitLogger() ...@@ -33,6 +34,20 @@ void InitLogger()
DestinationPtr consoleDst(DestinationFactory::MakeDebugOutputDestination()); DestinationPtr consoleDst(DestinationFactory::MakeDebugOutputDestination());
logger.addDestination(consoleDst); logger.addDestination(consoleDst);
} }
*/
void InitLogger(){
QString logDir = QString("%1/log").arg(g_appDir);
QDir().mkdir(logDir);
QsLogging::Logger& logger = QsLogging::Logger::instance();
logger.setLoggingLevel(QsLogging::TraceLevel);
//日志按天输出
QsLogging::DestinationPtr fileDst(QsLogging::DestinationFactory::MakeFileDestination(logDir,"FmPlugin", 30,QsLogging::EnableLogRotation,
QsLogging::MaxSizeBytes(10*1024*1024), QsLogging::MaxOldLogCount(50)));
logger.addDestination(fileDst);
QsLogging::DestinationPtr consoleDst(QsLogging::DestinationFactory::MakeDebugOutputDestination());
logger.addDestination(consoleDst);
}
void LoadTheme(const QString& theme) void LoadTheme(const QString& theme)
{ {
......
...@@ -173,6 +173,7 @@ ...@@ -173,6 +173,7 @@
#define REMIND_REQREFUND_ORDER 7 // 请求退单的订单: 目前如果有请求退单;POS会自动发起退单请求,完成退单动作; #define REMIND_REQREFUND_ORDER 7 // 请求退单的订单: 目前如果有请求退单;POS会自动发起退单请求,完成退单动作;
#define REMIND_AGRREFUND_ORDER 30 #define REMIND_AGRREFUND_ORDER 30
#define REMIND_COMPLAINT_ORDER 12 // 客诉单:最多且重要的case; #define REMIND_COMPLAINT_ORDER 12 // 客诉单:最多且重要的case;
#define REMIND_SIM_ORDERLIST_NOEMPTY 50 // Simphony有效队列中存在有订单待录入:就需要闪烁提醒;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment