Commit a9cab0e1 by NitefullWind

Merge branch 'SimphonyTest' into simphony

parents adc1a653 576ba952
...@@ -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)
{ {
QString iv = QString::number(json[JSON_KEY_PARTNERID].toInt()) + json[JSON_KEY_STOREID].toString() + json[JSON_KEY_STATIONID].toString(); QString iv = QString::number(json[JSON_KEY_PARTNERID].toInt()) + json[JSON_KEY_STOREID].toString() + json[JSON_KEY_STATIONID].toString();
QLOG_INFO() << "iv : " << iv; QLOG_INFO() << "iv : " << iv;
...@@ -199,9 +199,9 @@ bool Control::SendMessageToServer(const QJsonObject &json, QByteArray &outdata, ...@@ -199,9 +199,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) {
...@@ -224,7 +224,7 @@ bool Control::SendMessageToServer(const QJsonObject &json, QByteArray &outdata, ...@@ -224,7 +224,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;
...@@ -253,7 +253,7 @@ bool Control::SendMessageToPayMent(const QJsonObject &json, QByteArray &outdata, ...@@ -253,7 +253,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;
} }
...@@ -264,7 +264,7 @@ bool Control::SendMessageToPayMent(const QJsonObject &json, QByteArray &outdata, ...@@ -264,7 +264,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();
...@@ -322,7 +322,11 @@ bool Control::HttpPost(QString url, QByteArray &outdata, const QByteArray &indat ...@@ -322,7 +322,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;
} }
...@@ -331,7 +335,11 @@ bool Control::HttpPost(QString url, QByteArray &outdata, const QByteArray &indat ...@@ -331,7 +335,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;
} }
...@@ -403,7 +411,7 @@ bool Control::RollHttpPost(QString url, QByteArray &outdata, const QByteArray &i ...@@ -403,7 +411,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);
...@@ -426,7 +434,7 @@ bool Control::SendMessageToSBKAPI(const QJsonObject &json, QByteArray &outdata, ...@@ -426,7 +434,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
...@@ -489,13 +497,13 @@ bool Control::GetRSA(QString &error) ...@@ -489,13 +497,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;
...@@ -578,7 +586,7 @@ void Control::Request(ReqType type, QStringList list) ...@@ -578,7 +586,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);
...@@ -623,7 +631,7 @@ void Control::Request(ReqType type, QStringList list) ...@@ -623,7 +631,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 ;
} }
......
...@@ -198,10 +198,11 @@ private: ...@@ -198,10 +198,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;
} }
...@@ -219,8 +220,9 @@ private: ...@@ -219,8 +220,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);
...@@ -228,8 +230,9 @@ private: ...@@ -228,8 +230,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);
...@@ -250,8 +253,9 @@ private: ...@@ -250,8 +253,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);
...@@ -265,8 +269,9 @@ private: ...@@ -265,8 +269,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;
} }
......
...@@ -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