Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
sbkpay
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhenfei.zhang
sbkpay
Commits
6b0c543f
Commit
6b0c543f
authored
Jan 04, 2018
by
NitefullWind
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1. 请求Json解析失败后打印Log并返回给POS错误信息。 2. 修改版本号。
parent
9d49528e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
29 deletions
+38
-29
sbkpay/control.cpp
+35
-26
sbkpay/control.h
+1
-1
sbkpay/version.h
+2
-2
No files found.
sbkpay/control.cpp
View file @
6b0c543f
...
...
@@ -94,7 +94,6 @@ void Control::Start(const char *indata, char *outdata)
if
(
_widget
==
NULL
)
_widget
=
new
HostWidget
();
InitPOSReqJsonObj
(
indata
);
connect
(
_widget
,
&
HostWidget
::
Interrupt
,
this
,
&
Control
::
OnInterrupt
);
...
...
@@ -113,19 +112,22 @@ void Control::Start(const char *indata, char *outdata)
loop
.
exit
();
});
ReqType
reqType
=
(
ReqType
)
FMTool
::
GetJsonValue
(
_posReqJsonObj
,
JSON_KEY_REQTYPE
).
toInt
();
if
(
InitPOSReqJsonObj
(
indata
))
{
ReqType
reqType
=
(
ReqType
)
FMTool
::
GetJsonValue
(
_posReqJsonObj
,
JSON_KEY_REQTYPE
).
toInt
();
// _widget->ShowWithRequest(_request);
// _widget->ShowWithRequest(_request);
_widget
->
ShowWithRequest
(
_posReqJsonObj
);
_widget
->
ShowWithRequest
(
_posReqJsonObj
);
if
(
reqType
!=
refund
&&
reqType
!=
pay
)
{
loop
.
exec
();
}
else
{
if
(
refundflag
==
false
)
if
(
reqType
!=
refund
&&
reqType
!=
pay
)
{
loop
.
exec
();
}
else
{
if
(
refundflag
==
false
)
loop
.
exec
();
}
}
_lock
.
lock
();
...
...
@@ -145,28 +147,35 @@ void Control::Start(const char *indata, char *outdata)
QLOG_INFO
()
<<
"return data to pos : "
<<
QString
::
fromLocal8Bit
(
outdata
);
}
void
Control
::
InitPOSReqJsonObj
(
const
char
*
indata
)
bool
Control
::
InitPOSReqJsonObj
(
const
char
*
indata
)
{
QJsonParseError
parseError
;
QJsonDocument
inDataDoc
=
QJsonDocument
::
fromJson
(
QString
::
fromLocal8Bit
(
indata
).
toUtf8
(),
&
parseError
);
if
(
parseError
.
error
==
QJsonParseError
::
NoError
)
{
_posReqJsonObj
=
inDataDoc
.
object
();
int
type
=
FMTool
::
GetJsonValue
(
_posReqJsonObj
,
JSON_KEY_REQTYPE
).
toInt
(
SPCC_sign
);
if
(
type
<
SPCC_sign
||
type
>
SPCC_finds
)
{
_posReqJsonObj
[
JSON_KEY_REQTYPE
]
=
SPCC_sign
;
}
else
{
_posReqJsonObj
[
JSON_KEY_REQTYPE
]
=
type
-
SPCC_sign
;
}
}
else
{
qDebug
()
<<
"Json parse error: "
<<
parseError
.
errorString
();
if
(
_posType
==
RES
)
{
memcpy
(
&
_request
,
indata
,
sizeof
(
struct
AlipayRequest
));
ReqType
type
=
(
ReqType
)(
FMTool
::
GetString
(
_request
.
TransType
,
2
).
toInt
());
JsonFactory
::
GetJsonWithType
(
type
,
_posReqJsonObj
,
_request
);
qDebug
()
<<
_posReqJsonObj
;
// _posType = RES;
}
else
{
QJsonParseError
parseError
;
QJsonDocument
inDataDoc
=
QJsonDocument
::
fromJson
(
QString
::
fromLocal8Bit
(
indata
).
toUtf8
(),
&
parseError
);
if
(
parseError
.
error
==
QJsonParseError
::
NoError
)
{
_posReqJsonObj
=
inDataDoc
.
object
();
int
type
=
FMTool
::
GetJsonValue
(
_posReqJsonObj
,
JSON_KEY_REQTYPE
).
toInt
(
SPCC_sign
);
if
(
type
<
SPCC_sign
||
type
>
SPCC_finds
)
{
_posReqJsonObj
[
JSON_KEY_REQTYPE
]
=
SPCC_sign
;
}
else
{
_posReqJsonObj
[
JSON_KEY_REQTYPE
]
=
type
-
SPCC_sign
;
}
}
else
{
QString
error
=
QString
::
fromLocal8Bit
(
"请求解析失败:%1"
).
arg
(
parseError
.
errorString
());
QLOG_ERROR
()
<<
error
;
SetResPonseWithMessage
(
"23"
,
error
);
return
false
;
}
}
return
true
;
}
void
Control
::
SetResPonseWithMessage
(
QString
code
,
const
QString
&
message
)
...
...
sbkpay/control.h
View file @
6b0c543f
...
...
@@ -61,7 +61,7 @@ private:
bool
RollHttpPost
(
QString
url
,
QByteArray
&
outdata
,
const
QByteArray
&
indata
,
QString
content
,
QString
accept
,
QString
&
error
,
int
timeout
);
void
InitPOSReqJsonObj
(
const
char
*
indata
);
bool
InitPOSReqJsonObj
(
const
char
*
indata
);
static
bool
IsValidCode
(
const
QString
&
code
);
...
...
sbkpay/version.h
View file @
6b0c543f
...
...
@@ -3,9 +3,9 @@
#define VER_MAJOR 0
#define VER_MINOR 2
#define VER_REVISION
5
#define VER_REVISION
7
#define VER_BUILD
2
#define VER_BUILD
0
//! Convert version numbers to string
#define _STR(S) #S
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment