Commit 1c5be854 by shangshang.dai

新增

1:销售单状态汇报
2:门店被平台下线,强制置顶提醒.
优化
1:查询数据库放到单独的线程中处理,避免影响外卖流程.
2:软件界面错误提示语优化.
parent 52e1cf13
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include <QDir> #include <QDir>
#include <QApplication> #include <QApplication>
#include <QHostInfo> #include <QHostInfo>
#include <QtConcurrent/QtConcurrent>
FlowControl &FlowControl::GetInstance() FlowControl &FlowControl::GetInstance()
{ {
...@@ -24,6 +25,9 @@ FlowControl::FlowControl() ...@@ -24,6 +25,9 @@ FlowControl::FlowControl()
m_loginSocket = NULL; m_loginSocket = NULL;
m_pullOrderSocket = NULL; m_pullOrderSocket = NULL;
m_procOrderSocket = NULL; m_procOrderSocket = NULL;
m_synInterval = VALUE_SYNSTOCKINTERVAL;
m_bShowShopStatus = true;
} }
bool FlowControl::_GetStoreInfo() bool FlowControl::_GetStoreInfo()
...@@ -74,7 +78,7 @@ bool FlowControl::_Login() ...@@ -74,7 +78,7 @@ bool FlowControl::_Login()
.arg(result).arg(error, _GetJsonStr(recvJson)); .arg(result).arg(error, _GetJsonStr(recvJson));
if(!result) if(!result)
{ {
emit showAlert(AlertForm::ERROR, "登录失败![网络错误]"); emit showAlert(AlertForm::ERROR, "登录失败![与服务器通信超时,请稍后重试!]");
}else }else
{ {
if(JSON_STATUSCODE_OK != recvJson[JSON_STATUSCODE].toInt()) if(JSON_STATUSCODE_OK != recvJson[JSON_STATUSCODE].toInt())
...@@ -89,7 +93,7 @@ bool FlowControl::_Login() ...@@ -89,7 +93,7 @@ bool FlowControl::_Login()
emit setStoreInfo(m_storeId); emit setStoreInfo(m_storeId);
_PullOrder(); _PullOrder();
_SynStock(); _onSynStockTimerOut();
} }
} }
...@@ -132,15 +136,28 @@ bool FlowControl::_PullOrder() ...@@ -132,15 +136,28 @@ bool FlowControl::_PullOrder()
// 获取门店营业状态 // 获取门店营业状态
QString strOpeStatus("正常"); QString strOpeStatus("正常");
QJsonArray opeStatus = recvJson[JSON_SHOPSTATUS].toArray(); QJsonArray opeStatus = recvJson[JSON_SHOPSTATUS].toArray();
bool tmp_remark = true;
foreach(QJsonValue status, opeStatus) foreach(QJsonValue status, opeStatus)
{ {
QJsonObject jsonObject = status.toObject(); QJsonObject jsonObject = status.toObject();
if(jsonObject[JSON_SHOPSTATUSDESC].toString().compare("营业中")) if(jsonObject[JSON_SHOPSTATUSDESC].toString().compare("营业中"))
{ {
tmp_remark = false;
if(m_bShowShopStatus)
{
emit showAlert(AlertForm::ERROR, QString("<font color='#ff0000'>门店当前营业异常,请到非码网页后台重新操作上线.</font>"));
m_bShowShopStatus = false;
}
strOpeStatus = QString("<font color='#ff0000'>异常</font>"); strOpeStatus = QString("<font color='#ff0000'>异常</font>");
break; break;
} }
} }
if(tmp_remark)
{
m_bShowShopStatus = true;
}
emit setOpeStatus(strOpeStatus); emit setOpeStatus(strOpeStatus);
// 获取订单信息 // 获取订单信息
QJsonArray orders = recvJson[JSON_ORDERS].toArray(); QJsonArray orders = recvJson[JSON_ORDERS].toArray();
...@@ -180,9 +197,13 @@ bool FlowControl::_PullOrder() ...@@ -180,9 +197,13 @@ bool FlowControl::_PullOrder()
m_cashierObject.shiftId, m_cashierObject.shiftName, error)) m_cashierObject.shiftId, m_cashierObject.shiftName, error))
{ {
QLOG_ERROR() << QString("order retry entry failed,[%1]").arg(error); QLOG_ERROR() << QString("order retry entry failed,[%1]").arg(error);
_ReportBillEntryResult(orderObject->order_id, 0, error);
}else }else
{ {
QLOG_INFO() << QString("order retry entry success.[%1]").arg(error); QLOG_INFO() << QString("order retry entry success.[%1]").arg(error);
_ReportBillEntryResult(orderObject->order_id, 1, QString("成功"));
} }
} }
...@@ -217,7 +238,7 @@ bool FlowControl::_GetDelivers(const QString &orderId) ...@@ -217,7 +238,7 @@ bool FlowControl::_GetDelivers(const QString &orderId)
.arg(result).arg(error, _GetJsonStr(recvJson)); .arg(result).arg(error, _GetJsonStr(recvJson));
if(!result) if(!result)
{ {
emit showAlert(AlertForm::ERROR, "获取配送员失败![网络错误]"); emit showAlert(AlertForm::ERROR, "获取配送员失败![与服务器通信超时,请稍后重试!]");
}else }else
{ {
if(JSON_STATUSCODE_OK != recvJson[JSON_STATUSCODE].toInt()) if(JSON_STATUSCODE_OK != recvJson[JSON_STATUSCODE].toInt())
...@@ -264,7 +285,7 @@ bool FlowControl::_ConfirmOrder(const QString &orderId, const DeliverObject &del ...@@ -264,7 +285,7 @@ bool FlowControl::_ConfirmOrder(const QString &orderId, const DeliverObject &del
.arg(result).arg(error, _GetJsonStr(recvJson)); .arg(result).arg(error, _GetJsonStr(recvJson));
if(!result) if(!result)
{ {
emit showAlert(AlertForm::ERROR, "接单失败![网络错误]"); emit showAlert(AlertForm::ERROR, "接单失败![与服务器通信超时,请稍后重试!]");
}else }else
{ {
if(JSON_STATUSCODE_OK != recvJson[JSON_STATUSCODE].toInt()) if(JSON_STATUSCODE_OK != recvJson[JSON_STATUSCODE].toInt())
...@@ -343,7 +364,7 @@ bool FlowControl::_RefuseOrder(const QString &orderId, int refuseCode) ...@@ -343,7 +364,7 @@ bool FlowControl::_RefuseOrder(const QString &orderId, int refuseCode)
.arg(result).arg(error, _GetJsonStr(recvJson)); .arg(result).arg(error, _GetJsonStr(recvJson));
if(!result) if(!result)
{ {
emit showAlert(AlertForm::ERROR, "拒单失败![网络错误]"); emit showAlert(AlertForm::ERROR, "拒单失败![与服务器通信超时,请稍后重试!]");
}else }else
{ {
if(JSON_STATUSCODE_OK != recvJson[JSON_STATUSCODE].toInt()) if(JSON_STATUSCODE_OK != recvJson[JSON_STATUSCODE].toInt())
...@@ -382,7 +403,7 @@ bool FlowControl::_SendOrder(const QString& orderId) ...@@ -382,7 +403,7 @@ bool FlowControl::_SendOrder(const QString& orderId)
.arg(result).arg(error, _GetJsonStr(recvJson)); .arg(result).arg(error, _GetJsonStr(recvJson));
if(!result) if(!result)
{ {
emit showAlert(AlertForm::ERROR, "送出失败![网络错误]"); emit showAlert(AlertForm::ERROR, "送出失败![与服务器通信超时,请稍后重试!]");
}else }else
{ {
if(JSON_STATUSCODE_OK != recvJson[JSON_STATUSCODE].toInt()) if(JSON_STATUSCODE_OK != recvJson[JSON_STATUSCODE].toInt())
...@@ -421,7 +442,7 @@ bool FlowControl::_CompleteOrder(const QString& orderId) ...@@ -421,7 +442,7 @@ bool FlowControl::_CompleteOrder(const QString& orderId)
.arg(result).arg(error, _GetJsonStr(recvJson)); .arg(result).arg(error, _GetJsonStr(recvJson));
if(!result) if(!result)
{ {
emit showAlert(AlertForm::ERROR, "完成失败![网络错误]"); emit showAlert(AlertForm::ERROR, "完成失败![与服务器通信超时,请稍后重试!]");
}else }else
{ {
if(JSON_STATUSCODE_OK != recvJson[JSON_STATUSCODE].toInt()) if(JSON_STATUSCODE_OK != recvJson[JSON_STATUSCODE].toInt())
...@@ -460,7 +481,7 @@ bool FlowControl::_RefuseRefund(const QString& orderId) ...@@ -460,7 +481,7 @@ bool FlowControl::_RefuseRefund(const QString& orderId)
.arg(result).arg(error, _GetJsonStr(recvJson)); .arg(result).arg(error, _GetJsonStr(recvJson));
if(!result) if(!result)
{ {
emit showAlert(AlertForm::ERROR, "拒绝退单失败![网络错误]"); emit showAlert(AlertForm::ERROR, "拒绝退单失败![与服务器通信超时,请稍后重试!]");
}else }else
{ {
if(JSON_STATUSCODE_OK != recvJson[JSON_STATUSCODE].toInt()) if(JSON_STATUSCODE_OK != recvJson[JSON_STATUSCODE].toInt())
...@@ -503,11 +524,19 @@ bool FlowControl::_GetCashiers(QList<CashierObject> &cashiersList) ...@@ -503,11 +524,19 @@ bool FlowControl::_GetCashiers(QList<CashierObject> &cashiersList)
return result; return result;
} }
void FlowControl::_onSynStockTimerOut()
{
QLOG_INFO() << __FUNCTION__ << QThread::currentThreadId();
QtConcurrent::run(this, _SynStock);
QTimer::singleShot(m_synInterval, this, &FlowControl::_onSynStockTimerOut);
}
bool FlowControl::_SynStock() bool FlowControl::_SynStock()
{ {
QLOG_INFO() << __FUNCTION__ << QThread::currentThreadId();
QList<StockObject> stockList; QList<StockObject> stockList;
QString strStock, error; QString strStock, error;
int synInterval = VALUE_SYNSTOCKINTERVAL;
bool result; bool result;
QLOG_INFO() << QString("[---get stockInfo---]."); QLOG_INFO() << QString("[---get stockInfo---].");
...@@ -531,13 +560,12 @@ bool FlowControl::_SynStock() ...@@ -531,13 +560,12 @@ bool FlowControl::_SynStock()
{ {
if(JSON_STATUSCODE_OK == recvJson[JSON_STATUSCODE].toInt()) if(JSON_STATUSCODE_OK == recvJson[JSON_STATUSCODE].toInt())
{ {
synInterval = recvJson[JSON_SYNCTIME].toInt()*1000; m_synInterval = recvJson[JSON_SYNCTIME].toInt()*1000;
} }
} }
} }
QLOG_INFO() << QString("%1 msec after synStock...").arg(synInterval); QLOG_INFO() << QString("%1 msec after synStock...").arg(m_synInterval);
QTimer::singleShot(synInterval, this, &FlowControl::_SynStock);
return result; return result;
} }
...@@ -572,6 +600,23 @@ QString FlowControl::_GetJsonStr(const QJsonObject &json) ...@@ -572,6 +600,23 @@ QString FlowControl::_GetJsonStr(const QJsonObject &json)
return QString(QJsonDocument(json).toJson(QJsonDocument::Compact)).replace("\"",""); return QString(QJsonDocument(json).toJson(QJsonDocument::Compact)).replace("\"","");
} }
bool FlowControl::_ReportBillEntryResult(QString orderId, int status, QString error)
{
bool result;
QJsonObject sendJson;
QJsonObject recvJson;
sendJson = DataManger::GetInstance().GetReportOERData(orderId, status, error);
QLOG_INFO() << QString("[---report bill result---]. [requestData:%1]").arg(_GetJsonStr(sendJson));
QString error1;
result = m_procOrderSocket->Request(sendJson, recvJson, error1);
QLOG_INFO() << QString("report bill result finsh. [result:%1][msg:%2][recvData:%3]")
.arg(result).arg(error1, _GetJsonStr(recvJson));
return result;
}
void FlowControl::onFlowStart() void FlowControl::onFlowStart()
{ {
m_timestamp = "0"; m_timestamp = "0";
......
...@@ -41,6 +41,10 @@ private: ...@@ -41,6 +41,10 @@ private:
QMap<QString, OrderObject*> m_ordersMap; QMap<QString, OrderObject*> m_ordersMap;
// 当前收银员 // 当前收银员
CashierObject m_cashierObject; CashierObject m_cashierObject;
// 同步库存的时间间隔
int m_synInterval;
// 是否提醒门店下线
bool m_bShowShopStatus;
signals: signals:
/* 功能:连接数据库完成 /* 功能:连接数据库完成
...@@ -155,6 +159,7 @@ private slots: ...@@ -155,6 +159,7 @@ private slots:
* 返回:成功true失败false * 返回:成功true失败false
* */ * */
bool _SynStock(); bool _SynStock();
void _onSynStockTimerOut();
/* 功能:检测收银员合法性 /* 功能:检测收银员合法性
* 参数:NULL * 参数:NULL
* 返回:合法true不合法false * 返回:合法true不合法false
...@@ -165,6 +170,11 @@ private slots: ...@@ -165,6 +170,11 @@ private slots:
* 返回:Json字符串 * 返回:Json字符串
* */ * */
QString _GetJsonStr(const QJsonObject& json); QString _GetJsonStr(const QJsonObject& json);
/* 功能:获取Json对象的字符
* 参数:NULL
* 返回:Json字符串
* */
bool _ReportBillEntryResult(QString orderId, int status, QString error);
public slots: public slots:
/* 功能:开启流程控制器 /* 功能:开启流程控制器
......
...@@ -8,6 +8,7 @@ enum ...@@ -8,6 +8,7 @@ enum
REFUSE_ORDER,COMPLETE_ORDER = 16, REFUSE_ORDER,COMPLETE_ORDER = 16,
REFUSE_REFUND = 18,SEND_ORDER = 19, REFUSE_REFUND = 18,SEND_ORDER = 19,
REFUND_ORDER = 20, GET_DELIVER=21, REFUND_ORDER = 20, GET_DELIVER=21,
REPORT_BILL_RESULT = 23,CHARGEOFF_ORDER=71,
UPDATE_STOCK=80 UPDATE_STOCK=80
}; };
...@@ -151,3 +152,16 @@ QJsonObject DataManger::GetSynStockData(const QList<StockObject> &stockList) ...@@ -151,3 +152,16 @@ QJsonObject DataManger::GetSynStockData(const QList<StockObject> &stockList)
rObj.insert(JSON_POSVERSION, APP_VERSION); rObj.insert(JSON_POSVERSION, APP_VERSION);
return rObj; return rObj;
} }
QJsonObject DataManger::GetReportOERData(const QString &orderId, int status, const QString &error)
{
QJsonObject rObj, cObj;
rObj.insert(JSON_REQTYPE, REPORT_BILL_RESULT);
cObj.insert(JSON_ORDERID, orderId);
cObj.insert("bill_status", status);
cObj.insert(JSON_REASON, error);
rObj.insert(JSON_ORDER, cObj);
rObj.insert(JSON_TOKEN, m_token);
rObj.insert(JSON_POSVERSION, APP_VERSION);
return rObj;
}
...@@ -67,7 +67,11 @@ public: ...@@ -67,7 +67,11 @@ public:
* 返回:同步库存数据 * 返回:同步库存数据
* */ * */
QJsonObject GetSynStockData(const QList<StockObject>& stockList); QJsonObject GetSynStockData(const QList<StockObject>& stockList);
/* 功能:获取汇报销售单结果的数据
* 参数:[1]订单ID [2]写订单结果0失败1成功 [3]错误信息
* 返回:汇报销售单结果数据
* */
QJsonObject GetReportOERData(const QString &orderId, int status, const QString &error);
private: private:
DataManger(){} DataManger(){}
DataManger(DataManger const&); DataManger(DataManger const&);
......
...@@ -263,11 +263,13 @@ void MainForm::onHideAlert() ...@@ -263,11 +263,13 @@ void MainForm::onHideAlert()
void MainForm::onShowAlert(AlertForm::Type type, const QString &msg) void MainForm::onShowAlert(AlertForm::Type type, const QString &msg)
{ {
if(!isHidden()) if(isHidden())
{ {
m_alertForm->SetContent(type, msg); emit hideFloatForm();
m_alertForm->show(); this->show();
} }
m_alertForm->SetContent(type, msg);
m_alertForm->show();
} }
void MainForm::onSetStoreInfo(const QString &storeId) void MainForm::onSetStoreInfo(const QString &storeId)
......
...@@ -103,6 +103,11 @@ signals: ...@@ -103,6 +103,11 @@ signals:
* 返回:NULL * 返回:NULL
* */ * */
void showFloatForm(); void showFloatForm();
/* 功能:通知悬浮窗隐藏
* 参数:NULL
* 返回:NULL
* */
void hideFloatForm();
/* 功能:通知悬浮窗开始提示 /* 功能:通知悬浮窗开始提示
* 参数:[1]提示类型 0新订单1退款申请 * 参数:[1]提示类型 0新订单1退款申请
* 返回:NULL * 返回:NULL
......
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