Commit 576ba952 by NitefullWind

1. 修改Simphony网络异常时的提示信息。 2. 将服务端返回的数据直接作为返回给POS的数据。

parent fd3097fa
...@@ -185,7 +185,7 @@ void Control::InitModel() ...@@ -185,7 +185,7 @@ void Control::InitModel()
_responseJsonObj = QJsonObject(); _responseJsonObj = QJsonObject();
} }
bool Control::SendMessageToServer(const QJsonObject &json, QByteArray &outdata, QString &error) bool Control::SendMessageToServer(const QJsonObject &json, QByteArray &outdata, QString &error, ReqType reqType)
{ {
QJsonObject tmpjson = json; QJsonObject tmpjson = json;
tmpjson[JSON_KEY_VER] = DEFAULT_JSON_VER_VALUE; tmpjson[JSON_KEY_VER] = DEFAULT_JSON_VER_VALUE;
...@@ -197,9 +197,9 @@ bool Control::SendMessageToServer(const QJsonObject &json, QByteArray &outdata, ...@@ -197,9 +197,9 @@ bool Control::SendMessageToServer(const QJsonObject &json, QByteArray &outdata,
bool isOk = false; bool isOk = false;
if(_posType==SPCC) { if(_posType==SPCC) {
int timeout = _setting.GetValue(CONFIG_OLTP_TIMEOUT, 60).toInt(); int timeout = _setting.GetValue(CONFIG_OLTP_TIMEOUT, 60).toInt();
isOk = SendMessageToSBKAPI(tmpjson, outdata, error, timeout); isOk = SendMessageToSBKAPI(tmpjson, outdata, error, timeout, reqType);
} else { } else {
isOk = SendMessageToPayMent(tmpjson, outdata, error); isOk = SendMessageToPayMent(tmpjson, outdata, error, reqType);
} }
if(!_isinterrupt && !isOk) { if(!_isinterrupt && !isOk) {
...@@ -222,7 +222,7 @@ bool Control::SendMessageToServer(const QJsonObject &json, QByteArray &outdata, ...@@ -222,7 +222,7 @@ bool Control::SendMessageToServer(const QJsonObject &json, QByteArray &outdata,
return isOk; return isOk;
} }
bool Control::SendMessageToPayMent(const QJsonObject &json, QByteArray &outdata, QString &error) bool Control::SendMessageToPayMent(const QJsonObject &json, QByteArray &outdata, QString &error, ReqType reqType)
{ {
QByteArray array; QByteArray array;
...@@ -251,7 +251,7 @@ bool Control::SendMessageToPayMent(const QJsonObject &json, QByteArray &outdata, ...@@ -251,7 +251,7 @@ bool Control::SendMessageToPayMent(const QJsonObject &json, QByteArray &outdata,
loop.exec(); loop.exec();
#else #else
if(!Control::HttpPost(url, array, data, "application/json;charset=utf-8", "application/json", error, 60)) if(!Control::HttpPost(url, array, data, "application/json;charset=utf-8", "application/json", error, 60, reqType))
{ {
return false; return false;
} }
...@@ -262,7 +262,7 @@ bool Control::SendMessageToPayMent(const QJsonObject &json, QByteArray &outdata, ...@@ -262,7 +262,7 @@ bool Control::SendMessageToPayMent(const QJsonObject &json, QByteArray &outdata,
return true; return true;
} }
bool Control::HttpPost(QString url, QByteArray &outdata, const QByteArray &indata, QString content, QString accept, QString &error, int timeout) bool Control::HttpPost(QString url, QByteArray &outdata, const QByteArray &indata, QString content, QString accept, QString &error, int timeout, ReqType reqType)
{ {
QString host = _setting.GetValue(VALUE_HOST, "").toString(); QString host = _setting.GetValue(VALUE_HOST, "").toString();
...@@ -320,7 +320,11 @@ bool Control::HttpPost(QString url, QByteArray &outdata, const QByteArray &indat ...@@ -320,7 +320,11 @@ bool Control::HttpPost(QString url, QByteArray &outdata, const QByteArray &indat
if(reply->error() != QNetworkReply::NoError) if(reply->error() != QNetworkReply::NoError)
{ {
error = QString::fromLocal8Bit("网络异常,获取服务端返回数据失败"); if(_posType != SPCC && (reqType == pay || reqType == refund)) {
error = QString::fromLocal8Bit("网络异常.交易失败.如已扣款将会自动返还");
} else {
error = QString::fromLocal8Bit("网络异常,获取服务端返回数据失败");
}
QLOG_INFO() << reply->errorString() << "Contents: " << reply->readAll(); QLOG_INFO() << reply->errorString() << "Contents: " << reply->readAll();
return false; return false;
} }
...@@ -329,7 +333,11 @@ bool Control::HttpPost(QString url, QByteArray &outdata, const QByteArray &indat ...@@ -329,7 +333,11 @@ bool Control::HttpPost(QString url, QByteArray &outdata, const QByteArray &indat
if(outdata.isEmpty()) if(outdata.isEmpty())
{ {
error = QString::fromLocal8Bit("网络异常,获取服务端返回数据为空"); if(_posType != SPCC && (reqType == pay || reqType == refund)) {
error = QString::fromLocal8Bit("网络异常.交易失败.如已扣款将会自动返还");
} else {
error = QString::fromLocal8Bit("网络异常,获取服务端返回数据为空");
}
QLOG_INFO() << reply->errorString() << "Contents: " << reply->readAll(); QLOG_INFO() << reply->errorString() << "Contents: " << reply->readAll();
return false; return false;
} }
...@@ -401,7 +409,7 @@ bool Control::RollHttpPost(QString url, QByteArray &outdata, const QByteArray &i ...@@ -401,7 +409,7 @@ bool Control::RollHttpPost(QString url, QByteArray &outdata, const QByteArray &i
return true; return true;
} }
bool Control::SendMessageToSBKAPI(const QJsonObject &json, QByteArray &outdata, QString &error, int timeout, bool isReversal) bool Control::SendMessageToSBKAPI(const QJsonObject &json, QByteArray &outdata, QString &error, int timeout, ReqType reqType, bool isReversal)
{ {
QByteArray reqXmlData = FMNetWork::CreateOLTPXML(json); QByteArray reqXmlData = FMNetWork::CreateOLTPXML(json);
...@@ -424,7 +432,7 @@ bool Control::SendMessageToSBKAPI(const QJsonObject &json, QByteArray &outdata, ...@@ -424,7 +432,7 @@ bool Control::SendMessageToSBKAPI(const QJsonObject &json, QByteArray &outdata,
if(isReversal) { if(isReversal) {
httpIsOk = RollHttpPost(url, outdata, reqXmlData, "application/soap+xml; charset=utf-8", uuid, error, timeout); httpIsOk = RollHttpPost(url, outdata, reqXmlData, "application/soap+xml; charset=utf-8", uuid, error, timeout);
} else { } else {
httpIsOk = HttpPost(url, outdata, reqXmlData, "application/soap+xml; charset=utf-8", uuid, error, timeout); httpIsOk = HttpPost(url, outdata, reqXmlData, "application/soap+xml; charset=utf-8", uuid, error, timeout, reqType);
} }
#endif //! End def MOCK #endif //! End def MOCK
...@@ -482,13 +490,13 @@ bool Control::GetRSA(QString &error) ...@@ -482,13 +490,13 @@ bool Control::GetRSA(QString &error)
if(_posType == SPCC) if(_posType == SPCC)
{ {
if(!SendMessageToSBKAPI(json, array, error, 60)) if(!SendMessageToSBKAPI(json, array, error, 60, sign))
{ {
QLOG_ERROR() << "SendMessageToSBKAPI error: " << error; QLOG_ERROR() << "SendMessageToSBKAPI error: " << error;
return false; return false;
} }
} else { } else {
if(!Control::HttpPost(url, array, data,"application/json;charset=utf-8", "application/json", error, 60)) if(!Control::HttpPost(url, array, data,"application/json;charset=utf-8", "application/json", error, 60, sign))
{ {
QLOG_ERROR() << "httppos error :" << error; QLOG_ERROR() << "httppos error :" << error;
return false; return false;
...@@ -571,7 +579,7 @@ void Control::Request(ReqType type, QStringList list) ...@@ -571,7 +579,7 @@ void Control::Request(ReqType type, QStringList list)
QJsonDocument(json).toJson(QJsonDocument::Compact); QJsonDocument(json).toJson(QJsonDocument::Compact);
bool rlt = SendMessageToServer(json, outdata, error); bool rlt = SendMessageToServer(json, outdata, error, type);
if(rlt) if(rlt)
rlt = Control::GetJson(type, rtjson, outdata, error); rlt = Control::GetJson(type, rtjson, outdata, error);
...@@ -612,7 +620,7 @@ void Control::Request(ReqType type, QStringList list) ...@@ -612,7 +620,7 @@ void Control::Request(ReqType type, QStringList list)
while(i < 3) while(i < 3)
{ {
if(_posType == SPCC) { if(_posType == SPCC) {
if((tmpflag = SendMessageToSBKAPI(tmpjson, tmparray, tmperror, 19, true)) == true) { if((tmpflag = SendMessageToSBKAPI(tmpjson, tmparray, tmperror, 19, type, true)) == true) {
break; break;
} }
} else { } else {
......
...@@ -39,11 +39,11 @@ private: ...@@ -39,11 +39,11 @@ private:
void InitModel(); void InitModel();
bool SendMessageToServer(const QJsonObject &json, QByteArray &outdata, QString &error); bool SendMessageToServer(const QJsonObject &json, QByteArray &outdata, QString &error, ReqType reqType);
bool SendMessageToPayMent(const QJsonObject &json, QByteArray &outdata, QString &error); bool SendMessageToPayMent(const QJsonObject &json, QByteArray &outdata, QString &error, ReqType reqType);
bool SendMessageToSBKAPI(const QJsonObject &json, QByteArray &outdata, QString &error, int timeout, bool isReversal=false); bool SendMessageToSBKAPI(const QJsonObject &json, QByteArray &outdata, QString &error, int timeout, ReqType reqType, bool isReversal=false);
void SetResPonseWithMessage(QString code, const QString &message); void SetResPonseWithMessage(QString code, const QString &message);
...@@ -57,7 +57,7 @@ private: ...@@ -57,7 +57,7 @@ private:
bool GetJson(ReqType type, QJsonObject &json, const QByteArray array, QString &error); bool GetJson(ReqType type, QJsonObject &json, const QByteArray array, QString &error);
bool HttpPost(QString url, QByteArray &outdata, const QByteArray &indata, QString content, QString accept, QString &error, int timeout); bool HttpPost(QString url, QByteArray &outdata, const QByteArray &indata, QString content, QString accept, QString &error, int timeout, ReqType reqType);
bool RollHttpPost(QString url, QByteArray &outdata, const QByteArray &indata, QString content, QString accept, QString &error, int timeout); bool RollHttpPost(QString url, QByteArray &outdata, const QByteArray &indata, QString content, QString accept, QString &error, int timeout);
......
...@@ -434,8 +434,12 @@ void HostWidget::ShowWiteMGS(ReqType type, bool flag, QString message) ...@@ -434,8 +434,12 @@ void HostWidget::ShowWiteMGS(ReqType type, bool flag, QString message)
ui->label_pay_title->setText(QString::fromLocal8Bit("支付成功")); ui->label_pay_title->setText(QString::fromLocal8Bit("支付成功"));
ui->label_pay_time->setPixmap(QPixmap(":res/success.png")); ui->label_pay_time->setPixmap(QPixmap(":res/success.png"));
} else { } else {
ui->label_pay_title->setText(QString::fromLocal8Bit("支付失败")); if(_posType == SPCC) {
ui->label_pay_time->setPixmap(QPixmap(":res/warning.png")); ui->label_pay_title->setText(QString::fromLocal8Bit("支付失败"));
ui->label_pay_time->setPixmap(QPixmap(":res/warning.png"));
} else {
Exits();
}
} }
return ; return ;
} }
...@@ -457,8 +461,12 @@ void HostWidget::ShowWiteMGS(ReqType type, bool flag, QString message) ...@@ -457,8 +461,12 @@ void HostWidget::ShowWiteMGS(ReqType type, bool flag, QString message)
ui->label_pay_title->setText(QString::fromLocal8Bit("退款成功")); ui->label_pay_title->setText(QString::fromLocal8Bit("退款成功"));
ui->label_pay_time->setPixmap(QPixmap(":res/success.png")); ui->label_pay_time->setPixmap(QPixmap(":res/success.png"));
} else { } else {
ui->label_pay_title->setText(QString::fromLocal8Bit("退款失败")); if(_posType == SPCC) {
ui->label_pay_time->setPixmap(QPixmap(":res/warning.png")); ui->label_pay_title->setText(QString::fromLocal8Bit("退款失败"));
ui->label_pay_time->setPixmap(QPixmap(":res/warning.png"));
} else {
Exits();
}
} }
return ; return ;
} }
......
...@@ -197,10 +197,11 @@ private: ...@@ -197,10 +197,11 @@ private:
static bool GetRefundResponse(QJsonObject &response, const QJsonObject &json) static bool GetRefundResponse(QJsonObject &response, const QJsonObject &json)
{ {
response[JSON_KEY_STATUSCODE] = FMTool::GetJsonValue(json, JSON_KEY_STATUSCODE).toInt(); // response[JSON_KEY_STATUSCODE] = FMTool::GetJsonValue(json, JSON_KEY_STATUSCODE).toInt();
response[JSON_KEY_MESSAGE] = FMTool::GetJsonValue(json, JSON_KEY_MESSAGE).toString(); // response[JSON_KEY_MESSAGE] = FMTool::GetJsonValue(json, JSON_KEY_MESSAGE).toString();
response[JSON_KEY_EXT] = FMTool::GetJsonValue(json, JSON_KEY_EXT).toObject(); // response[JSON_KEY_EXT] = FMTool::GetJsonValue(json, JSON_KEY_EXT).toObject();
response[JSON_KEY_FMID] = FMTool::GetJsonValue(json, JSON_KEY_FMID).toString(); // response[JSON_KEY_FMID] = FMTool::GetJsonValue(json, JSON_KEY_FMID).toString();
response = json;
return true; return true;
} }
...@@ -218,8 +219,9 @@ private: ...@@ -218,8 +219,9 @@ private:
static bool GetEndDayResponse(QJsonObject &response, const QJsonObject &json) static bool GetEndDayResponse(QJsonObject &response, const QJsonObject &json)
{ {
response[JSON_KEY_STATUSCODE] = json[JSON_KEY_STATUSCODE]; // response[JSON_KEY_STATUSCODE] = json[JSON_KEY_STATUSCODE];
response[JSON_KEY_MESSAGE] = json[JSON_KEY_MESSAGE]; // response[JSON_KEY_MESSAGE] = json[JSON_KEY_MESSAGE];
response = json;
if(json[JSON_KEY_STATUSCODE].toInt() == 100) if(json[JSON_KEY_STATUSCODE].toInt() == 100)
return SetPinter(response, json, CONFIG_PRINT_ENDDAY_NAME); return SetPinter(response, json, CONFIG_PRINT_ENDDAY_NAME);
...@@ -227,8 +229,9 @@ private: ...@@ -227,8 +229,9 @@ private:
} }
static bool GetShiftResponse(QJsonObject &response, const QJsonObject &json) static bool GetShiftResponse(QJsonObject &response, const QJsonObject &json)
{ {
response[JSON_KEY_STATUSCODE] = json[JSON_KEY_STATUSCODE]; // response[JSON_KEY_STATUSCODE] = json[JSON_KEY_STATUSCODE];
response[JSON_KEY_MESSAGE] = json[JSON_KEY_MESSAGE]; // response[JSON_KEY_MESSAGE] = json[JSON_KEY_MESSAGE];
response = json;
if(json[JSON_KEY_STATUSCODE].toInt() == 100) if(json[JSON_KEY_STATUSCODE].toInt() == 100)
return SetPinter(response, json, CONFIG_PRINT_SHIFT_NAME); return SetPinter(response, json, CONFIG_PRINT_SHIFT_NAME);
...@@ -249,8 +252,9 @@ private: ...@@ -249,8 +252,9 @@ private:
static bool GetAgainPrinteResponse(QJsonObject &response, const QJsonObject &json) static bool GetAgainPrinteResponse(QJsonObject &response, const QJsonObject &json)
{ {
response[JSON_KEY_STATUSCODE] = json[JSON_KEY_STATUSCODE]; // response[JSON_KEY_STATUSCODE] = json[JSON_KEY_STATUSCODE];
response[JSON_KEY_MESSAGE] = json[JSON_KEY_MESSAGE]; // response[JSON_KEY_MESSAGE] = json[JSON_KEY_MESSAGE];
response = json;
if(json[JSON_KEY_STATUSCODE].toInt() == 100) if(json[JSON_KEY_STATUSCODE].toInt() == 100)
return SetPinter(response, json, CONFIG_PRINT_AGAIN_NAME); return SetPinter(response, json, CONFIG_PRINT_AGAIN_NAME);
...@@ -264,8 +268,9 @@ private: ...@@ -264,8 +268,9 @@ private:
static bool GetFindResponse(QJsonObject &response, const QJsonObject &json) static bool GetFindResponse(QJsonObject &response, const QJsonObject &json)
{ {
response[JSON_KEY_STATUSCODE] = json[JSON_KEY_STATUSCODE]; // response[JSON_KEY_STATUSCODE] = json[JSON_KEY_STATUSCODE];
response[JSON_KEY_MESSAGE] = json[JSON_KEY_MESSAGE]; // response[JSON_KEY_MESSAGE] = json[JSON_KEY_MESSAGE];
response = json;
return true; return true;
} }
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
#define VER_MAJOR 0 #define VER_MAJOR 0
#define VER_MINOR 2 #define VER_MINOR 2
#define VER_REVISION 0 #define VER_REVISION 1
#define VER_BUILD 1 #define VER_BUILD 0
//! Convert version numbers to string //! Convert version numbers to string
#define _STR(S) #S #define _STR(S) #S
......
...@@ -163,7 +163,7 @@ void TestSimphony::test_InitPOSReqJsonObj() ...@@ -163,7 +163,7 @@ void TestSimphony::test_InitPOSReqJsonObj()
} }
resultJson = control._responseJsonObj; resultJson = control._responseJsonObj;
} else { } else {
isOk = control.SendMessageToServer(json, serverRetData, error); isOk = control.SendMessageToServer(json, serverRetData, error, (ReqType)reqType);
if(isOk) { if(isOk) {
if(reqType==finds||reqType==endday) { if(reqType==finds||reqType==endday) {
resultJson = QJsonDocument::fromJson(serverRetData).object(); resultJson = QJsonDocument::fromJson(serverRetData).object();
......
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