Commit e44d14b0 by ss.dai

Fix 1: 修复写销售单Retry时间过短(5秒),改为2分钟;

parent 734bebeb
......@@ -65,7 +65,7 @@ bool HTTP::post(const QNetworkRequest &request, const QByteArray &appendData, QB
},
[ &eventLoop , this](const QNetworkReply::NetworkError &error)
{
this->error_ = QString::number(error);
this->error_ = QString::number((int)error);
eventLoop.exit( false );
},
[ &failFlag, &eventLoop, this ]()
......@@ -216,8 +216,10 @@ bool FmPlugin::GetOnDutyCashiers(QList<CashierObject> &cashiersList, QString &er
return true;
}
bool FmPlugin::DoOrderEntry(const OrderObject *orderObject, const QString &cashierId, const QString &cashierName, const QString &shiftId, const QString &shiftName, QString &error)
bool FmPlugin::DoOrderEntry(const OrderObject *orderObject, const QString &cashierId, const QString &cashierName, QString &bill_data, QString &fee_data, QString &error)
{
Q_UNUSED(cashierId)Q_UNUSED(cashierName)
QString apppath=QCoreApplication::applicationDirPath();
// 检查这单之前是否写过
QString remark_file_path = QString("%1/orders/%2/%3_%4").arg(apppath, QDateTime::fromTime_t(orderObject->create_time).toString("yyyy-MM-dd"), orderObject->channel ,orderObject->order_id);
......@@ -230,59 +232,78 @@ bool FmPlugin::DoOrderEntry(const OrderObject *orderObject, const QString &cashi
QString inipath=apppath+QString("/config.ini");
QSettings set(inipath, QSettings::IniFormat);
QUrl url, url_fee;
url = set.value("HdServer/url").toUrl();
url_fee = set.value("HdServer/url1").toUrl();
QUrl url_bill, url_fee, url_vip;
url_bill = set.value("HdServer/url_bill").toUrl();
url_fee = set.value("HdServer/url_fee").toUrl();
url_vip = set.value("HdServer/url_vip").toUrl();
HTTP http;
QByteArray recvArray;
QNetworkRequest qRequset;
qRequset.setUrl(url);
qRequset.setRawHeader("Content-Type","application/json;charset=utf-8");
qRequset.setRawHeader("Accept", "application/json;charset=utf-8");
error = _GetOrderEntryData(orderObject);
QNetworkRequest request_vip ,requset_bill, request_fee;
request_vip.setUrl(url_vip);
request_vip.setRawHeader("Content-Type","application/json;charset=utf-8");
request_vip.setRawHeader("Accept", "application/json;charset=utf-8");
QString authorData = "Basic " + QString("admin:www.hd123.com").toLocal8Bit().toBase64();
request_vip.setRawHeader("Authorization", authorData.toLocal8Bit());
requset_bill.setUrl(url_bill);
requset_bill.setRawHeader("Content-Type","application/json;charset=utf-8");
requset_bill.setRawHeader("Accept", "application/json;charset=utf-8");
request_fee.setUrl(url_fee);
request_fee.setRawHeader("Content-Type","application/json;charset=utf-8");
request_fee.setRawHeader("Accept", "application/json;charset=utf-8");
if(http.post(qRequset, _GetOrderEntryData(orderObject), recvArray, 15000))
// 查询会员号
QString memberCode("");
if(http.post(request_vip, _GetVipQueryData(orderObject->phone, QDateTime::fromTime_t(orderObject->create_time).toString("yyyy-MM-ddThh:mm:ss.zzz+0800")), recvArray, 10000))
{
QJsonObject recvJson;
recvJson = QJsonDocument::fromJson(recvArray).object();
memberCode = recvJson["response"].toObject()["member"].toObject()["id"].toString();
}
qDebug() << "写销售单获取到的返回数据" << recvJson;
// 写入销售单
bill_data = _GetOrderEntryData(orderObject, memberCode);
if(http.post(requset_bill, _GetOrderEntryData(orderObject, memberCode), recvArray, 20000))
{
QJsonObject recvJson;
recvJson = QJsonDocument::fromJson(recvArray).object();
QString uuid = recvJson["uuid"].toString();
if(uuid.isEmpty())
{
error.append(recvJson["echoMessage"].toString());
error = recvJson["echoMessage"].toString();
return false;
}
recvArray.clear();
QNetworkRequest qRequset1;
qRequset1.setUrl(url_fee);
qRequset1.setRawHeader("Content-Type","application/json;charset=utf-8");
qRequset1.setRawHeader("Accept", "application/json;charset=utf-8");
error.append("配送费:"+_GetFeeData(orderObject, uuid));
if(http.post(qRequset1, _GetFeeData(orderObject, uuid), recvArray, 15000))
// 写入配送费&服务费
fee_data = _GetFeeData(orderObject, uuid);
if(http.post(request_fee, _GetFeeData(orderObject, uuid), recvArray, 20000))
{
QJsonObject recvJson;
recvJson = QJsonDocument::fromJson(recvArray).object();
qDebug() << "记配送费获取到的返回数据" << recvJson;
if(recvJson["echoCode"].toString() != "0")
{
error = recvJson["echoMessage"].toString();
return false;
}
}
QDir().mkpath(remark_file_path.mid(0,remark_file_path.lastIndexOf("/")));
file.open(QFile::WriteOnly);
file.close();
return true;
// 记录为文件形式下次直接跳过
QDir().mkpath(remark_file_path.mid(0, remark_file_path.lastIndexOf("/")));
file.open(QFile::WriteOnly);
file.close();
return true;
}else
{
error = "配送费服务器,连接出错";
}
}else
{
error = "销售单服务器,连接出错";
}
error = http.error();
return false;
}
......@@ -471,7 +492,24 @@ double FmPlugin::_Penny2Dollar(int penny)
return dollar;
}
QByteArray FmPlugin::_GetOrderEntryData(const OrderObject *orderObject)
QByteArray FmPlugin::_GetVipQueryData(const QString &phone, const QString &time)
{
QJsonObject rObj , cObj, cObj1 , ccObj;
ccObj.insert("namespace", "");
ccObj.insert("id", "");
ccObj.insert("fullName", "");
cObj.insert("time", time);
cObj.insert("operator", ccObj);
cObj.insert("terminalId", "");
cObj.insert("store", "FM001");
cObj1.insert("type", "mobile");
cObj1.insert("id", phone);
rObj.insert("operCtx", cObj);
rObj.insert("accout", cObj1);
return QJsonDocument(rObj).toJson(QJsonDocument::Compact);
}
QByteArray FmPlugin::_GetOrderEntryData(const OrderObject *orderObject, const QString &memberCode)
{
QJsonObject rObj;
rObj.insert("uuid", orderObject->order_view_id.isEmpty()?orderObject->order_id:orderObject->order_view_id);
......@@ -495,6 +533,7 @@ QByteArray FmPlugin::_GetOrderEntryData(const OrderObject *orderObject)
rObj.insert("deliverAddress", orderObject->address);
rObj.insert("remark", serviceFee);
rObj.insert("ocrDate", QDateTime::fromTime_t(orderObject->create_time).toString("yyyy-MM-ddThh:mm:ss.zzz+0800"));
rObj.insert("membercode", memberCode);
rObj.insert("filler", "*");
rObj.insert("seller", "*");
rObj.insert("souceOrderCls", "");
......
......@@ -57,7 +57,8 @@ public slots:
* 返回:是否成功
* */
bool DoOrderEntry(OrderObject const *orderObject, const QString& cashierId, const QString& cashierName,
const QString& shiftId, const QString& shiftName, QString& error);
QString& bill_data, QString& fee_data, QString& error);
/* 功能:获取库存信息
* 参数:[1]_out库存信息
* 返回:是否成功
......@@ -118,11 +119,18 @@ private:
* 返回:元
* */
double _Penny2Dollar(int penny);
/* 功能:获取写销售单的数据
* 参数:[1]订单对象
* 返回:销售单数据
* */
QByteArray _GetVipQueryData(const QString& phone, const QString& time);
/* 功能:获取写销售单的数据
* 参数:[1]订单对象
* 返回:销售单数据
* */
QByteArray _GetOrderEntryData(const OrderObject*);
QByteArray _GetOrderEntryData(const OrderObject*, const QString& memberCode);
/* 功能:获取写配送费的数据
* 参数:[1]订单对象
* 返回:销售单数据
......
......@@ -250,22 +250,28 @@ bool FlowControl::_PullOrder()
{
QLOG_INFO() << QString("will entry %1").arg(orderObject->order_id);
//QTimer::singleShot(1000*60*120, [orderObject, this](){
QTimer::singleShot(1000*20, [orderObject,this](){
QTimer::singleShot(1000*10, [orderObject,this](){
if(orderObject->status == 6 || orderObject->status == 200)
{
QString error;
QString error, bill_data, fee_data;
for(int i=0; i<5; i++)
{
if(FmPlugin::GetInstance().DoOrderEntry(orderObject,"","","","",error))
QLOG_INFO() << QString("第%1次尝试写入订单%2").arg(i+1).arg(orderObject->order_id);
if(FmPlugin::GetInstance().DoOrderEntry(orderObject,"","",bill_data, fee_data,error))
{
QLOG_INFO() << QString("销售单数据%1 配送费数据%2").arg(bill_data,fee_data);
QLOG_INFO() << QString("_PullOrder DoOrderEntry successful %1 %2").arg(orderObject->order_id).arg(error);
this->_ReportBillEntryResult(orderObject->order_id, 1, QString("成功"));
break;
}else
{
QLOG_INFO() << QString("销售单数据%1 配送费数据%2").arg(bill_data,fee_data);
QLOG_INFO() << QString("_PullOrder DoOrderEntry failed %1 %2").arg(orderObject->order_id, error);
this->_ReportBillEntryResult(orderObject->order_id, 0, error);
}
QEventLoop loop;
QTimer::singleShot(1000*60*2, &loop, &QEventLoop::quit);
loop.exec();
}
}else
{
......
......@@ -313,31 +313,23 @@ void MainForm::onSetNetStatus(const QString &status)
void MainForm::onChangeOrderStatus(OrderObject *orderObject, int oldStatus)
{
qDebug() << "--------状态------" << oldStatus;
_SetTablesSortEnable(false);
QTableWidget *table;
QPushButton *tabBtn;
// 非首次收到的订单需要现在原先表中删除
if(oldStatus != -100)
{
// if(orderObject->delivery_status==2)
// {
// tabBtn = ui->mainBtnOur;
// }else
// {
// tabBtn = _GetTabBtnByOrderStatus(oldStatus);
// }
// table = findChild<QTableWidget*>(tabBtn->property("tableName").toString());
qDebug() << "--------状态------" << orderObject->curt_table_btn->property("tableName").toString();
QTableWidget* table = findChild<QTableWidget*>(orderObject->curt_table_btn->property("tableName").toString());
qDebug() << "--------状态------" << table->objectName();
for(int i=0; i<table->rowCount(); i++)
{
qDebug() << "数字"<< i << table->item(i, 1)->text() << orderObject->order_view_id;
if(!table->item(i, 1)->text().compare(orderObject->order_view_id.isEmpty()?orderObject->order_id:orderObject->order_view_id))
{
qDebug() << "移除";
table->removeRow(i);
QString btnText(orderObject->curt_table_btn->property("name").toString());
if(table->rowCount() != 0)
......
......@@ -5,8 +5,7 @@ url1=http://123.207.193.166/api
[RefundListener]
port=34953
;url为销售单写入地址
;url1为服务费&配送费写入地址
[HdServer]
url=http://101.71.13.138:7782/h4rest2/rest/h5rest-server/core/wholesaleservice/wholesale
url1=http://60.12.240.242:8980/h4rest-server/rest/h5rest-server/core/feeservice/fee/savenew
\ No newline at end of file
url_bill=http://192.168.1.60:7782/h4rest2/rest/h5rest-server/core/wholesaleservice/wholesale
url_fee=http://192.168.1.60:7782/h4rest2/rest/h5rest-server/core/feeservice/fee/savenew
url_vip=http://122.224.171.126:8880/jcrm-server-card/rest/account/check
\ No newline at end of file
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