Commit ec88357c by 刘帅

加入打印小票功能

parent d305132f
{ {
...@@ -2,10 +2,9 @@ ...@@ -2,10 +2,9 @@
"business_date": "20171214", "business_date": "20171214",
"clientReqCount": 1, "clientReqCount": 1,
"operator_id": "001", "operator_id": "001",
"partnerId": "1371",
"reqtype": 72, "reqtype": 72,
"station_id": "1", "station_id": "1",
"store_id": "fm99999", "store_id": "99992",
"trans_id": "201712140003", "trans_id": "201712140003",
"transactions": [ "transactions": [
{ {
......
...@@ -79,6 +79,9 @@ bool QFmClient::Init(QString proxy_IP, unsigned short proxy_port, unsigned short ...@@ -79,6 +79,9 @@ bool QFmClient::Init(QString proxy_IP, unsigned short proxy_port, unsigned short
rlt = fscanf(cfgFile, "%u", &value); rlt = fscanf(cfgFile, "%u", &value);
_codeFlag = (char)value; _codeFlag = (char)value;
fscanf(cfgFile, "%s", _receiptPath);
qDebug()<<"_receiptPath "<<_receiptPath;
fclose(cfgFile); fclose(cfgFile);
cfgFile = 0; cfgFile = 0;
...@@ -678,6 +681,7 @@ int QFmClient::CheckRecvedData() ...@@ -678,6 +681,7 @@ int QFmClient::CheckRecvedData()
QByteArray recvdata(_recvbuf); QByteArray recvdata(_recvbuf);
QJsonParseError json_error; QJsonParseError json_error;
QJsonDocument doc = QJsonDocument::fromJson(recvdata, &json_error); QJsonDocument doc = QJsonDocument::fromJson(recvdata, &json_error);
if(json_error.error != QJsonParseError::NoError || !doc.isObject()) if(json_error.error != QJsonParseError::NoError || !doc.isObject())
...@@ -685,6 +689,27 @@ int QFmClient::CheckRecvedData() ...@@ -685,6 +689,27 @@ int QFmClient::CheckRecvedData()
qDebug() << "error request json data!\r\n"; qDebug() << "error request json data!\r\n";
return -1; return -1;
} }
QJsonObject json = doc.object();
if(json.contains("statusCode") && json["statusCode"].toInt() == 100)
{
if(json.contains("ext") && json["ext"].isObject() &&
json["ext"].toObject().contains("print") && json["ext"].toObject()["print"].isString())
{
QFile file(_receiptPath);
if(file.open(QFile::WriteOnly))
{
QString PrintInfo = json["ext"].toObject()["print"].toString();
QLOG_INFO() << "print:\r\n" <<PrintInfo << "\r\n";
file.write(PrintInfo.toUtf8());
file.close();
}
}
}
return 0; return 0;
} }
......
...@@ -60,7 +60,7 @@ private: ...@@ -60,7 +60,7 @@ private:
char _sendbuf[MAX_BUF_LEN]; char _sendbuf[MAX_BUF_LEN];
char _codeBuf[MAX_BUF_LEN]; char _codeBuf[MAX_BUF_LEN];
char _receiptPath[MAX_PATH];
unsigned char _codeKey[MAX_CODE_KEY]; unsigned char _codeKey[MAX_CODE_KEY];
//proxy IP //proxy IP
......
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