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
5e7e920b
Commit
5e7e920b
authored
Aug 11, 2017
by
李定达
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.添加请求道response的转换
parent
a0e84269
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
239 additions
and
4 deletions
+239
-4
.gitignore
+1
-0
sbkpay/fmtool.h
+20
-0
sbkpay/global.h
+9
-0
sbkpay/jsonfactory.h
+1
-0
sbkpay/main.cpp
+73
-0
sbkpay/requestmodel.h
+2
-2
sbkpay/rspfactory.h
+130
-0
sbkpay/sbkpay.pro
+2
-1
sbkpay/sbkpay.pro.user
+1
-1
No files found.
.gitignore
View file @
5e7e920b
build-sbkpay-Desktop_Qt_5_5_1_MinGW_32bit-Debug/
build-sbkpay-Desktop_Qt_5_5_1_MSVC2010_32bit-Debug/
sbkpay/fmtool.h
View file @
5e7e920b
...
...
@@ -126,6 +126,26 @@ public:
}
static
void
SetString
(
void
*
beginptr
,
int
size
,
const
QString
&
in
)
{
char
buf
[
MAX_CHILED_LEN
]
=
{
0
};
char
tmpbuf
[
MAX_CHILED_LEN
]
=
{
0
};
memset
(
beginptr
,
' '
,
size
);
if
(
in
.
isEmpty
())
return
;
strcpy
(
buf
,
in
.
toUtf8
().
data
());
int
len
=
UTF8ToGBK
((
unsigned
char
*
)
buf
,
(
unsigned
char
*
)
tmpbuf
,
MAX_CHILED_LEN
);
strncpy
((
char
*
)
beginptr
,
tmpbuf
,
len
-
1
);
qDebug
()
<<
tmpbuf
;
}
};
...
...
sbkpay/global.h
View file @
5e7e920b
...
...
@@ -3,7 +3,9 @@
#define MAX_BUF_LEN 25600
#define MAX_CHILED_LEN 256
#define MAX_PRINT_LEN 4096
#define PRINT_FILE_NAME "print.txt"
#define USERCONFIG_NAME "config.ini"
#define ENCODE_FIRST "encode/first"
...
...
@@ -23,6 +25,13 @@
#define JSON_KEY_TRANSAMOUNT "transAmount"
#define JSON_KEY_REFUNDAMOUT "refundAmount"
//response
#define JSON_KEY_MESSAGE "message"
#define JSON_KEY_STATUSCODE "statusCode"
#define JSON_KEY_FMID "fmId"
#define JSON_KEY_EXT "ext"
#define JSON_KEY_PRINT "print"
#define JSON_KEY_UNAMOUNT "undiscountAmount"
//array products
...
...
sbkpay/jsonfactory.h
View file @
5e7e920b
...
...
@@ -10,6 +10,7 @@
#include <QJsonParseError>
#include <QJsonDocument>
//接受pos的请求转化为json
class
JsonFactory
{
public
:
...
...
sbkpay/main.cpp
View file @
5e7e920b
...
...
@@ -4,9 +4,70 @@
#include "control.h"
#include "global.h"
#include "QsLog.h"
#include "requestmodel.h"
#include "fmtool.h"
#include "rspfactory.h"
#include <QDir>
#include <QApplication>
void
TestSetString
()
{
AlipayResponse
repon
;
FMTool
::
SetString
(
repon
.
ResponseMsg
,
40
,
QString
(
"傻逼"
));
}
void
TestSetPinter
()
{
AlipayResponse
repon
;
QJsonObject
obj
,
json
;
obj
.
insert
(
"print"
,
"为了宽宏大量分开打女生短发设计开发"
);
json
.
insert
(
"ext"
,
obj
);
RspFactory
::
SetPinter
(
repon
,
json
);
qDebug
()
<<
"lalal"
;
}
void
TestGetResPonseJson
()
{
AlipayResponse
repon
;
QJsonObject
obj
,
json
;
obj
.
insert
(
"print"
,
"为了宽宏大量分开打女生短发设计开发"
);
json
.
insert
(
"ext"
,
obj
);
json
.
insert
(
"fmId"
,
"asdashdgajshdg11111111111111111"
);
json
.
insert
(
"statusCode"
,
100
);
json
.
insert
(
"message"
,
"哇哈哈"
);
RspFactory
::
GetResPonseJson
(
pay
,
repon
,
json
);
qDebug
()
<<
"lalal"
;
json
.
insert
(
"statusCode"
,
204
);
json
.
insert
(
"message"
,
"哇哈哈有毒"
);
RspFactory
::
GetResPonseJson
(
refund
,
repon
,
json
);
qDebug
()
<<
"lalal"
;
}
void
TestGetResPonseWithError
()
{
AlipayResponse
repon
;
RspFactory
::
GetResPonseWithError
(
repon
,
"201"
,
"山茶花"
);
qDebug
()
<<
"lalal"
;
}
int
main
(
int
argc
,
char
*
argv
[])
{
...
...
@@ -28,8 +89,20 @@ int main(int argc, char *argv[])
QsLogging
::
DestinationPtr
consleDest
(
QsLogging
::
DestinationFactory
::
MakeDebugOutputDestination
());
logger
.
addDestination
(
consleDest
);
//pass
TestSetString
();
//pass
TestGetResPonseWithError
();
//pass
TestSetPinter
();
//pass
TestGetResPonseJson
();
Control
control
;
char
as
[]
=
"ak10dh171300000000000 *#dhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh"
;
char
b
[
MAX_BUF_LEN
]
=
{
0
};
...
...
sbkpay/requestmodel.h
View file @
5e7e920b
...
...
@@ -23,7 +23,7 @@ struct EFTItem
struct
AlipayResponse
{
char
ResponseCode
[
2
];
//返回码。
char
ResponseCode
[
3
];
//返回码
char
ResponseMsg
[
40
];
//返回文字信息
char
Amount
[
12
];
//订单金额(与wxpayRequest.Amount一致)
char
SettleNum
[
6
];
//
...
...
@@ -31,7 +31,7 @@ struct AlipayResponse
char
TerminalID
[
8
];
//
char
TransDate
[
8
];
//交易日期
char
TransTime
[
6
];
//交易时间
char
CardTraceNo
[
64
];
//订单号
char
CardTraceNo
[
64
];
//订单号
(非码交易号)
char
NeedPrint
[
2
];
//是否打印小票. 00:表示打印小票, 01:表示不打印小票
char
EFTprintFileName
[
200
];
//打印文件路径.
char
MD5_CHECK_CODE
[
32
];
//
...
...
sbkpay/rspfactory.h
0 → 100644
View file @
5e7e920b
#ifndef RSPFACTORY
#define RSPFACTORY
#include "requestmodel.h"
#include "global.h"
#include "fmtool.h"
#include <QFile>
#include <QJsonObject>
#include <QApplication>
class
RspFactory
{
public
:
static
bool
GetResPonseJson
(
ReqType
type
,
AlipayResponse
&
response
,
const
QJsonObject
&
json
)
{
if
(
json
.
isEmpty
())
return
false
;
memset
(
&
response
,
' '
,
sizeof
(
response
));
if
(
type
==
pay
)
return
GetPayResponse
(
response
,
json
);
if
(
type
==
refund
)
return
GetRefundResponse
(
response
,
json
);
if
(
type
==
endday
)
return
GetDayEndResponse
(
response
,
json
);
if
(
type
==
againprint
)
return
GetAgainPrinteResponse
(
response
,
json
);
if
(
type
==
find
)
return
GetFindResponse
(
response
,
json
);
return
false
;
}
static
bool
GetResPonseWithError
(
AlipayResponse
&
response
,
QString
errorcode
,
QString
message
)
{
if
(
errorcode
.
isEmpty
()
||
message
.
isEmpty
())
return
false
;
memset
(
&
response
,
' '
,
sizeof
(
response
));
FMTool
::
SetString
(
response
.
ResponseCode
,
3
,
errorcode
);
FMTool
::
SetString
(
response
.
ResponseMsg
,
3
,
message
);
return
true
;
}
#ifndef FM_TEST
private
:
#endif
static
bool
GetPayResponse
(
AlipayResponse
&
response
,
const
QJsonObject
&
json
)
{
FMTool
::
SetString
(
response
.
ResponseCode
,
3
,
QString
::
number
(
json
[
JSON_KEY_STATUSCODE
].
toInt
()));
FMTool
::
SetString
(
response
.
ResponseMsg
,
40
,
json
[
JSON_KEY_MESSAGE
].
toString
());
FMTool
::
SetString
(
response
.
CardTraceNo
,
40
,
json
[
JSON_KEY_FMID
].
toString
());
FMTool
::
SetString
(
response
.
NeedPrint
,
2
,
QString
(
"01"
));
if
(
json
[
JSON_KEY_STATUSCODE
].
toInt
()
==
100
)
return
SetPinter
(
response
,
json
);
return
true
;
}
static
bool
GetRefundResponse
(
AlipayResponse
&
response
,
const
QJsonObject
&
json
)
{
FMTool
::
SetString
(
response
.
ResponseCode
,
3
,
QString
::
number
(
json
[
JSON_KEY_STATUSCODE
].
toInt
()));
FMTool
::
SetString
(
response
.
ResponseMsg
,
40
,
json
[
JSON_KEY_MESSAGE
].
toString
());
FMTool
::
SetString
(
response
.
CardTraceNo
,
40
,
json
[
JSON_KEY_FMID
].
toString
());
FMTool
::
SetString
(
response
.
NeedPrint
,
2
,
QString
(
"01"
));
if
(
json
[
JSON_KEY_STATUSCODE
].
toInt
()
==
100
)
return
SetPinter
(
response
,
json
);
return
true
;
}
static
bool
GetDayEndResponse
(
AlipayResponse
&
response
,
const
QJsonObject
&
json
)
{
return
false
;
}
static
bool
GetAgainPrinteResponse
(
AlipayResponse
&
response
,
const
QJsonObject
&
json
)
{
return
false
;
}
static
bool
GetFindResponse
(
AlipayResponse
&
response
,
const
QJsonObject
&
json
)
{
return
false
;
}
static
bool
SetPinter
(
AlipayResponse
&
response
,
const
QJsonObject
&
json
)
{
if
(
!
json
.
contains
(
JSON_KEY_EXT
)
||
!
json
[
JSON_KEY_EXT
].
isObject
())
return
false
;
FMTool
::
SetString
(
response
.
NeedPrint
,
2
,
QString
(
"01"
));
QJsonObject
obj
=
json
[
JSON_KEY_EXT
].
toObject
();
QString
str
=
obj
[
JSON_KEY_PRINT
].
toString
();
QFile
file
(
qApp
->
applicationDirPath
()
+
"/"
+
PRINT_FILE_NAME
);
FMTool
::
SetString
(
response
.
EFTprintFileName
,
200
,
QString
(
qApp
->
applicationDirPath
()
+
"/"
+
PRINT_FILE_NAME
));
file
.
open
(
QFile
::
WriteOnly
);
if
(
!
file
.
isOpen
())
return
false
;
char
buf
[
MAX_PRINT_LEN
]
=
{
0
};
FMTool
::
SetString
(
buf
,
str
.
toUtf8
().
length
(),
str
);
file
.
write
(
buf
);
file
.
flush
();
file
.
close
();
return
true
;
}
};
#endif // RSPFACTORY
sbkpay/sbkpay.pro
View file @
5e7e920b
...
...
@@ -31,7 +31,8 @@ HEADERS += hostwidget.h \
fmerror
.
h
\
fmtool
.
h
\
jsonfactory
.
h
\
labelstimer
.
h
labelstimer
.
h
\
rspfactory
.
h
FORMS
+=
hostwidget
.
ui
...
...
sbkpay/sbkpay.pro.user
View file @
5e7e920b
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 3.5.1, 2017-08-1
0T10:02:51
. -->
<!-- Written by QtCreator 3.5.1, 2017-08-1
1T14:08:55
. -->
<qtcreator>
<data>
<variable>
EnvironmentId
</variable>
...
...
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