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
92e6a794
Commit
92e6a794
authored
Aug 25, 2017
by
NitefullWind
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1. Simphony与SPCC初步整合。
parent
e4c54fff
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
148 additions
and
60 deletions
+148
-60
sbkpay/control.cpp
+56
-18
sbkpay/control.h
+3
-2
sbkpay/hostwidget.cpp
+59
-35
sbkpay/hostwidget.h
+2
-1
sbkpay/main.cpp
+14
-3
sbkpay/requestmodel.h
+14
-1
No files found.
sbkpay/control.cpp
View file @
92e6a794
...
...
@@ -66,20 +66,7 @@ void Control::Start(const char *indata, char *outdata)
if
(
_widget
==
NULL
)
_widget
=
new
HostWidget
();
QJsonParseError
parseError
;
QJsonDocument
inDataDoc
=
QJsonDocument
::
fromJson
(
QString
::
fromUtf8
(
indata
).
toUtf8
(),
&
parseError
);
if
(
parseError
.
error
==
QJsonParseError
::
NoError
)
{
_posReqJsonObj
=
inDataDoc
.
object
();
int
type
=
FMTool
::
GetJsonValue
(
_posReqJsonObj
,
JSON_KEY_REQTYPE
).
toInt
(
SPCC_sign
);
_posReqJsonObj
[
JSON_KEY_REQTYPE
]
=
type
-
SPCC_sign
;
}
else
{
qDebug
()
<<
"Json parse error: "
<<
parseError
.
errorString
();
memcpy
(
&
_request
,
indata
,
sizeof
(
struct
AlipayRequest
));
ReqType
type
=
(
ReqType
)(
FMTool
::
GetString
(
_request
.
TransType
,
2
).
toInt
());
JsonFactory
::
GetJsonWithType
(
type
,
_posReqJsonObj
,
_request
);
qDebug
()
<<
_posReqJsonObj
;
}
InitPOSReqJsonObj
(
indata
);
connect
(
_widget
,
&
HostWidget
::
RequestWithType
,
this
,
&
Control
::
RequestWithType
);
...
...
@@ -113,7 +100,7 @@ void Control::Start(const char *indata, char *outdata)
// }
// _widget->ShowWithRequest(_request);
_widget
->
ShowWithRequest
(
_posReqJsonObj
);
_widget
->
ShowWithRequest
(
_pos
Type
,
_pos
ReqJsonObj
);
loop
.
exec
();
...
...
@@ -134,6 +121,34 @@ void Control::Start(const char *indata, char *outdata)
QLOG_INFO
()
<<
"return data to pos : "
<<
QString
::
fromLocal8Bit
(
outdata
);
}
void
Control
::
InitPOSReqJsonObj
(
const
char
*
indata
)
{
QJsonParseError
parseError
;
QJsonDocument
inDataDoc
=
QJsonDocument
::
fromJson
(
QString
::
fromUtf8
(
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
]
=
type
-
SPCC_sign
;
_posType
=
SPCC
;
}
else
if
(
type
>=
SIMPHONY_sign
&&
type
<=
SIMPHONY_finds
)
{
_posReqJsonObj
[
JSON_KEY_REQTYPE
]
=
type
-
SIMPHONY_sign
;
_posType
=
SIMPHONY
;
}
else
{
// TODO: Other type.
}
}
else
{
qDebug
()
<<
"Json parse error: "
<<
parseError
.
errorString
();
memcpy
(
&
_request
,
indata
,
sizeof
(
struct
AlipayRequest
));
ReqType
type
=
(
ReqType
)(
FMTool
::
GetString
(
_request
.
TransType
,
2
).
toInt
());
JsonFactory
::
GetJsonWithType
(
type
,
_posReqJsonObj
,
_request
);
qDebug
()
<<
_posReqJsonObj
;
_posType
=
RES
;
}
}
void
Control
::
SetResPonseWithMessage
(
QString
code
,
const
QString
&
message
)
{
// FMTool::SetString(_response.ResponseCode, 3, code);
...
...
@@ -271,10 +286,10 @@ bool Control::SendMessageToSBKAPI(const QJsonObject &json, QByteArray &outdata,
#ifdef MOCK
QLOG_DEBUG
()
<<
"=========================================== Read debug data. ========================================"
;
QLOG_DEBUG
()
<<
"Test req type: "
<<
type
;
QFile
f
(
qApp
->
applicationDirPath
()
+
QString
(
"/test/%1.txt"
).
arg
(
type
));
QFile
f
(
qApp
->
applicationDirPath
()
+
QString
(
"/test
_spcc
/%1.txt"
).
arg
(
type
));
f
.
open
(
QIODevice
::
ReadOnly
);
strcpy
(
out
,
f
.
readAll
().
data
());
Sleep
(
1000
*
10
);
//
Sleep(1000*10);
QLOG_DEBUG
()
<<
"=========================================== End read debug data. ===================================="
;
int
result
=
0
;
...
...
@@ -552,7 +567,30 @@ void Control::Request(ReqType type, QStringList list)
QLOG_INFO
()
<<
"Sign str: "
<<
signStr
;
rlt
=
SendMessageToSBKAPI
(
json
,
outdata
,
error
);
switch
(
_posType
)
{
case
SPCC
:
rlt
=
SendMessageToSBKAPI
(
json
,
outdata
,
error
);
break
;
case
SIMPHONY
:
{
#ifdef MOCK
QLOG_DEBUG
()
<<
"=========================================== Read debug data. ========================================"
;
int
st
=
FMTool
::
GetJsonValue
(
json
,
JSON_KEY_REQTYPE
).
toInt
(
sign
);
QLOG_DEBUG
()
<<
"Test req type: "
<<
st
;
QFile
f
(
qApp
->
applicationDirPath
()
+
QString
(
"/test_simphony/%1.txt"
).
arg
(
st
));
f
.
open
(
QIODevice
::
ReadOnly
);
outdata
=
QString
::
fromLocal8Bit
(
f
.
readAll
()).
toUtf8
();
QLOG_DEBUG
()
<<
"=========================================== End read debug data. ===================================="
;
rlt
=
true
;
#else
rlt
=
SendMessageToPayMent
(
json
,
outdata
,
error
);
#endif //! End def MOCK
break
;
}
default
:
// TODO: Other type.
break
;
}
}
if
(
rlt
)
...
...
sbkpay/control.h
View file @
92e6a794
...
...
@@ -50,6 +50,8 @@ private:
QString
GetMacString
(
bool
isSign
=
true
);
void
InitPOSReqJsonObj
(
const
char
*
indata
);
public
slots
:
void
RequestWithType
(
ReqType
type
,
QStringList
list
);
...
...
@@ -68,8 +70,7 @@ private:
QString
_fmId
;
POSType
_posType
;
};
...
...
sbkpay/hostwidget.cpp
View file @
92e6a794
...
...
@@ -267,36 +267,38 @@ void HostWidget::ShowWiteJson(bool flag, QJsonObject object, QString error)
QWidget
*
pWdg
=
new
QWidget
(
ui
->
tableWidget
);
QHBoxLayout
*
hLayout
=
new
QHBoxLayout
(
pWdg
);
QPushButton
*
pBtn
=
new
QPushButton
(
pWdg
);
pBtn
->
setFixedSize
(
70
,
30
);
pBtn
->
setFocusPolicy
(
Qt
::
NoFocus
);
pBtn
->
setProperty
(
"orderId"
,
tmp
[
JSON_KEY_FMID
].
toString
());
pBtn
->
setText
(
QString
::
fromLocal8Bit
(
"打印"
));
hLayout
->
addWidget
(
pBtn
);
hLayout
->
setMargin
(
0
);
pWdg
->
setLayout
(
hLayout
);
ui
->
tableWidget
->
setCellWidget
(
0
,
4
,
pWdg
);
// 操作按钮
pBtn
->
setStyleSheet
(
"border:0px;border-radius:2px;background-color: rgb(0, 179, 238);font: 75 20px
\"
Microsoft YaHei UI Light
\"
;"
);
qDebug
()
<<
"********************-----------*******************"
<<
tmp
;
if
(
tmp
[
JSON_KEYT_STATE
].
toString
().
toInt
()
!=
1
)
{
pBtn
->
setEnabled
(
false
);
pBtn
->
setStyleSheet
(
"border:0px;border-radius:2px;background-color: rgb(208, 208, 208);font: 75 20px
\"
Microsoft YaHei UI Light
\"
;"
);
if
(
_posType
!=
SPCC
)
{
QWidget
*
pWdg
=
new
QWidget
(
ui
->
tableWidget
);
QHBoxLayout
*
hLayout
=
new
QHBoxLayout
(
pWdg
);
QPushButton
*
pBtn
=
new
QPushButton
(
pWdg
);
pBtn
->
setFixedSize
(
70
,
30
);
pBtn
->
setFocusPolicy
(
Qt
::
NoFocus
);
pBtn
->
setProperty
(
"orderId"
,
tmp
[
JSON_KEY_FMID
].
toString
());
pBtn
->
setText
(
QString
::
fromLocal8Bit
(
"打印"
));
hLayout
->
addWidget
(
pBtn
);
hLayout
->
setMargin
(
0
);
pWdg
->
setLayout
(
hLayout
);
ui
->
tableWidget
->
setCellWidget
(
0
,
4
,
pWdg
);
// 操作按钮
pBtn
->
setStyleSheet
(
"border:0px;border-radius:2px;background-color: rgb(0, 179, 238);font: 75 20px
\"
Microsoft YaHei UI Light
\"
;"
);
qDebug
()
<<
"********************-----------*******************"
<<
tmp
;
if
(
tmp
[
JSON_KEYT_STATE
].
toString
().
toInt
()
!=
1
)
{
pBtn
->
setEnabled
(
false
);
pBtn
->
setStyleSheet
(
"border:0px;border-radius:2px;background-color: rgb(208, 208, 208);font: 75 20px
\"
Microsoft YaHei UI Light
\"
;"
);
}
connect
(
pBtn
,
&
QPushButton
::
clicked
,
this
,
[
this
,
pBtn
]()
{
QStringList
list
;
list
.
append
(
pBtn
->
property
(
"orderId"
).
toString
());
on_btn_printagain_clicked
();
emit
RequestWithType
(
againprint
,
list
);
});
}
connect
(
pBtn
,
&
QPushButton
::
clicked
,
this
,
[
this
,
pBtn
]()
{
QStringList
list
;
list
.
append
(
pBtn
->
property
(
"orderId"
).
toString
());
on_btn_printagain_clicked
();
emit
RequestWithType
(
againprint
,
list
);
});
}
ui
->
tableWidget
->
sortByColumn
(
2
,
Qt
::
DescendingOrder
);
ui
->
tableWidget
->
show
();
...
...
@@ -304,8 +306,9 @@ void HostWidget::ShowWiteJson(bool flag, QJsonObject object, QString error)
}
}
void
HostWidget
::
ShowWithRequest
(
QJsonObject
requestObj
)
void
HostWidget
::
ShowWithRequest
(
POSType
posType
,
QJsonObject
requestObj
)
{
_posType
=
posType
;
_type
=
(
ReqType
)
FMTool
::
GetJsonValue
(
requestObj
,
JSON_KEY_REQTYPE
).
toInt
();
_posReqJsonObj
=
requestObj
;
...
...
@@ -613,7 +616,21 @@ void HostWidget::on_btn_find_check_clicked()
ui
->
tableWidget
->
clear
();
QStringList
headerString
;
headerString
<<
QString
::
fromLocal8Bit
(
"订单编号"
)
<<
QString
::
fromLocal8Bit
(
"订单金额"
)
<<
QString
::
fromLocal8Bit
(
"订单时间"
)
<<
QString
::
fromLocal8Bit
(
"支付状态"
)
/*<<QString::fromLocal8Bit("操作")*/
;
QList
<
double
>
widthScale
;
headerString
<<
QString
::
fromLocal8Bit
(
"订单编号"
)
<<
QString
::
fromLocal8Bit
(
"订单金额"
)
<<
QString
::
fromLocal8Bit
(
"订单时间"
)
<<
QString
::
fromLocal8Bit
(
"支付状态"
);
if
(
_posType
==
SIMPHONY
)
{
headerString
<<
QString
::
fromLocal8Bit
(
"操作"
);
}
switch
(
headerString
.
length
())
{
case
4
:
widthScale
<<
0.39
<<
0.18
<<
0.25
<<
0.18
;
break
;
case
5
:
widthScale
<<
0.35
<<
0.15
<<
0.21
<<
0.15
<<
0.14
;
default
:
break
;
}
int
width
=
ui
->
widget_find_main
->
width
()
-
4
;
...
...
@@ -622,12 +639,19 @@ void HostWidget::on_btn_find_check_clicked()
//ui->tableWidget->setColumnWidth(0,1/10.0*width);
ui
->
tableWidget
->
horizontalHeader
()
->
setStyleSheet
(
"QHeaderView::section{border: 0px;font: 75 18px
\"
Microsoft YaHei UI Light
\"
;}"
);
ui
->
tableWidget
->
horizontalHeader
()
->
setFixedHeight
(
25
);
//设置表头的高度
ui
->
tableWidget
->
setHorizontalHeaderLabels
(
headerString
);
ui
->
tableWidget
->
setColumnWidth
(
0
,
5
/
14.0
*
width
);
ui
->
tableWidget
->
setColumnWidth
(
1
,
2
/
14.0
*
width
);
ui
->
tableWidget
->
setColumnWidth
(
2
,
3
/
14.0
*
width
);
ui
->
tableWidget
->
setColumnWidth
(
3
,
2
/
14.0
*
width
);
ui
->
tableWidget
->
setColumnCount
(
headerString
.
length
());
for
(
int
i
=
0
;
i
<
headerString
.
length
();
i
++
)
{
ui
->
tableWidget
->
setColumnWidth
(
i
,
widthScale
[
i
]
*
width
);
}
// ui->tableWidget->setColumnWidth(0,5/14.0*width);
// ui->tableWidget->setColumnWidth(1,2/14.0*width);
// ui->tableWidget->setColumnWidth(2,3/14.0*width);
// ui->tableWidget->setColumnWidth(3,2/14.0*width);
ui
->
tableWidget
->
setHorizontalHeaderLabels
(
headerString
);
ui
->
frame
->
hide
();
ui
->
widget_check_load
->
show
();
...
...
sbkpay/hostwidget.h
View file @
92e6a794
...
...
@@ -25,7 +25,7 @@ public:
~
HostWidget
();
void
ShowWithRequest
(
AlipayRequest
request
);
void
ShowWithRequest
(
QJsonObject
requestObj
);
void
ShowWithRequest
(
POSType
posType
,
QJsonObject
requestObj
);
void
ShowWiteMGS
(
ReqType
type
,
bool
flag
,
QString
message
=
QString
());
...
...
@@ -106,6 +106,7 @@ private:
bool
_runing
;
POSType
_posType
;
ReqType
_type
;
};
...
...
sbkpay/main.cpp
View file @
92e6a794
...
...
@@ -14,11 +14,19 @@
EXTERN_C
IMAGE_DOS_HEADER
__ImageBase
;
static
int
count
=
0
;
static
void
Count
()
{
printf
(
"Call times: %d
\n
"
,
count
);
count
++
;
}
BOOL
WINAPI
DllMain
(
HINSTANCE
hInstance
,
DWORD
dwReason
,
LPVOID
/*lpvReserved*/
)
{
static
bool
ownApplication
=
FALSE
;
if
(
dwReason
==
DLL_PROCESS_ATTACH
)
{
printf
(
"Dll is start.
\n
"
);
char
mod
[
MAX_PATH
]
=
{
0
};
GetModuleFileNameA
((
HMODULE
)
&
__ImageBase
,
mod
,
MAX_PATH
);
char
*
ch
=
strrchr
(
mod
,
'\\'
);
...
...
@@ -29,14 +37,17 @@ BOOL WINAPI DllMain( HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpvReserved*/
QApplication
::
addLibraryPath
(
path
);
ownApplication
=
QMfcApp
::
pluginInstance
(
hInstance
);
}
if
(
dwReason
==
DLL_PROCESS_DETACH
&&
ownApplication
)
delete
qApp
;
if
(
dwReason
==
DLL_PROCESS_DETACH
&&
ownApplication
)
{
printf
(
"Dll is stop.
\n
"
);
delete
qApp
;
}
return
TRUE
;
}
extern
"C"
__declspec
(
dllexport
)
void
Start
(
const
char
*
indata
,
char
*
outdata
)
{
Count
();
HWND
parent
=
GetDesktopWindow
();
QWinWidget
win
(
parent
);
...
...
@@ -353,7 +364,7 @@ int main(int argc, char *argv[])
// control.Start(as, b);
char
spccIn
[
MAX_BUF_LEN
]
=
"{
\"
fmId
\"
:
\"
0123456789012345678
\"
,
\"
reqType
\"
:
3
51,
\"
storeId
\"
:
\"
1713
\"
,
\"
stationId
\"
:
\"
1
\"
,
\"
partnerId
\"
:1443,
\"
operatorId
\"
:
\"
sssaw
\"
,
\"
transId
\"
:
\"
52342342323806
\"
,
\"
transAmount
\"
:8000,
\"
partnerOrderId
\"
:
\"
909911039993720192019
\"
,
\"
businessDate
\"
:
\"
20170508
\"
,
\"
products
\"
:[{
\"
pid
\"
:
\"
123
\"
,
\"
name
\"
:
\"
中杯拿铁
\"
,
\"
price
\"
:321,
\"
salesType
\"
:
\"
NORMAL
\"
}]}"
;
char
spccIn
[
MAX_BUF_LEN
]
=
"{
\"
fmId
\"
:
\"
0123456789012345678
\"
,
\"
reqType
\"
:
4
51,
\"
storeId
\"
:
\"
1713
\"
,
\"
stationId
\"
:
\"
1
\"
,
\"
partnerId
\"
:1443,
\"
operatorId
\"
:
\"
sssaw
\"
,
\"
transId
\"
:
\"
52342342323806
\"
,
\"
transAmount
\"
:8000,
\"
partnerOrderId
\"
:
\"
909911039993720192019
\"
,
\"
businessDate
\"
:
\"
20170508
\"
,
\"
products
\"
:[{
\"
pid
\"
:
\"
123
\"
,
\"
name
\"
:
\"
中杯拿铁
\"
,
\"
price
\"
:321,
\"
salesType
\"
:
\"
NORMAL
\"
}]}"
;
control
.
Start
(
spccIn
,
b
);
return
a
.
exec
();
...
...
sbkpay/requestmodel.h
View file @
92e6a794
...
...
@@ -3,6 +3,13 @@
typedef
enum
{
RES
,
SPCC
,
SIMPHONY
}
POSType
;
typedef
enum
{
sign
,
manage
,
pay
,
...
...
@@ -17,7 +24,13 @@ typedef enum
SPCC_manage
,
SPCC_pay
,
SPCC_refund
,
SPCC_finds
SPCC_finds
,
SIMPHONY_sign
=
450
,
SIMPHONY_manage
,
SIMPHONY_pay
,
SIMPHONY_refund
,
SIMPHONY_finds
}
ReqType
;
struct
EFTItem
...
...
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