Commit 1c5be854 by shangshang.dai

新增

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