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
352b79c1
Commit
352b79c1
authored
Aug 26, 2017
by
李定达
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.将签名和加密完全移植到QT;2.增加中断机制,允许请求发送中中断请求;3.支付中界面添加交易撤销按钮;4.利用生产者消费者实现异步冲正
parent
1ac81a9b
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
301 additions
and
134 deletions
+301
-134
sbkpay/DataProcess/DataProcess.pri
+1
-2
sbkpay/DataProcess/cretopt.h
+19
-5
sbkpay/DataProcess/fmglobal.h
+2
-0
sbkpay/DataProcess/fmnetwork.cpp
+10
-9
sbkpay/DataProcess/fmnetwork.h
+2
-1
sbkpay/DataProcess/fmp_database.cpp
+2
-2
sbkpay/DataProcess/rollback.cpp
+18
-8
sbkpay/control.cpp
+131
-86
sbkpay/control.h
+9
-3
sbkpay/hostwidget.cpp
+21
-2
sbkpay/hostwidget.h
+6
-0
sbkpay/hostwidget.ui
+68
-12
sbkpay/main.cpp
+9
-3
sbkpay/sbkpay.pro
+2
-0
sbkpay/sbkpay.pro.user
+1
-1
No files found.
sbkpay/DataProcess/DataProcess.pri
View file @
352b79c1
LIBS += -L"C:/openssl/openssl-1.0.1s/out32dll" -llibeay32
LIBS += -L"C:/openssl/openssl-1.0.1s/out32dll" -lssleay32
LIBS += -lIPHLPAPI
INCLUDEPATH += $$quote(C:/openssl/openssl-1.0.1s/inc32/)
...
...
sbkpay/DataProcess/cretopt.h
View file @
352b79c1
...
...
@@ -93,15 +93,16 @@ public:
sign
=
QString
(
tmp
);
json
.
insert
(
JSON_KEY_SIGN
,
sign
);
return
fals
e
;
return
tru
e
;
}
static
bool
SetRSACret
(
Q
String
&
des3text
)
static
bool
SetRSACret
(
Q
ByteArray
&
des3text
)
{
QByteArray
array
=
des3text
.
toUtf8
()
;
QByteArray
array
=
des3text
;
char
rps
[
MAX_BUF_LEN
]
=
{
0
};
char
*
buf
=
(
char
*
)
calloc
(
array
.
size
()
+
100
,
sizeof
(
char
));
strcpy
(
buf
,
array
.
data
());
if
(
DataProcess
::
DES3Decode
((
const
unsigned
char
*
)
DES3_KEY
,
buf
,
strlen
(
buf
),
(
unsigned
char
*
)
rps
,
MAX_BUF_LEN
)
==
0
)
{
...
...
@@ -125,6 +126,19 @@ public:
return
false
;
}
//验证证书合法性在此添加
QByteArray
data
=
QJsonDocument
(
json
).
toJson
(
QJsonDocument
::
Compact
);
char
prtrps
[
MAX_BUF_LEN
]
=
{
0
};
if
(
DataProcess
::
DES3Encode
((
const
unsigned
char
*
)
DES3_KEY_PRT
,
data
.
data
(),
strlen
(
data
.
data
()),
(
unsigned
char
*
)
prtrps
,
MAX_BUF_LEN
)
==
0
)
{
QLOG_ERROR
()
<<
"3des private client.p12 file:"
<<
json
;
return
false
;
}
char
path
[
MAX_PATH
]
=
{
0
};
ToolS
::
GetProcPath
(
path
);
...
...
@@ -141,7 +155,7 @@ public:
return
false
;
}
file
.
write
(
array
);
file
.
write
(
prtrps
);
file
.
flush
();
file
.
close
();
...
...
@@ -177,7 +191,7 @@ private:
strcpy
(
buf
,
array
.
data
());
if
(
DataProcess
::
DES3Decode
((
const
unsigned
char
*
)
DES3_KEY
,
buf
,
strlen
(
buf
),
(
unsigned
char
*
)
rps
,
MAX_BUF_LEN
)
==
0
)
if
(
DataProcess
::
DES3Decode
((
const
unsigned
char
*
)
DES3_KEY
_PRT
,
buf
,
strlen
(
buf
),
(
unsigned
char
*
)
rps
,
MAX_BUF_LEN
)
==
0
)
{
QLOG_ERROR
()
<<
"DES3Decode Client.p12 Failed"
;
return
false
;
...
...
sbkpay/DataProcess/fmglobal.h
View file @
352b79c1
...
...
@@ -12,6 +12,7 @@
#define RBG_FILE_NAME "fmclient.rbk"
#define DES3_KEY "ABCD@#9876DFSAAWKLDEOPDD"
#define DES3_KEY_PRT "1JG23G12Y12V123G123F1DI1"
#define CRET_FILE_NAME "client.p12"
#define JSON_KEY_ONLY "partnerOrderId"
#define JSON_KEY_MAC "mac"
...
...
@@ -23,6 +24,7 @@
#define JSON_KEY_REQTYPE "reqType"
#define VALUE_URL "all/url"
#define VALUE_URL_CRET "all/creturl"
#define VALUE_HOST "all/host"
#define VALUE_TIMEOUT "all/timeout"
...
...
sbkpay/DataProcess/fmnetwork.cpp
View file @
352b79c1
...
...
@@ -2,6 +2,7 @@
#include <QTimer>
#include <QSettings>
#include <QEventLoop>
#include <QSslSocket>
#include <QSslConfiguration>
#include <QNetworkAccessManager>
#include <QNetworkReply>
...
...
@@ -17,7 +18,7 @@ FMNetWork::FMNetWork(QObject *parent) : QObject(parent)
}
bool
FMNetWork
::
HttpPost
(
QString
url
,
QByteArray
outdata
,
const
ByteArray
&
indata
,
QString
content
,
QString
accept
,
int
timeout
)
bool
FMNetWork
::
HttpPost
(
QString
url
,
QByteArray
outdata
,
const
QByteArray
&
indata
,
QString
content
,
QString
accept
,
QString
&
error
,
int
timeout
)
{
QString
path
;
ToolS
::
GetPath
(
path
);
...
...
@@ -28,18 +29,18 @@ bool FMNetWork::HttpPost(QString url, QByteArray outdata, const ByteArray &indat
QEventLoop
loop
;
QTimer
timer
;
QSslConfiguration
config
;
config
.
setPeerVerifyMode
(
QSslSocket
::
VerifyNone
);
config
.
setProtocol
(
QSsl
::
SslV3
);
//
QSslConfiguration config;
//
config.setPeerVerifyMode(QSslSocket::VerifyNone);
//
config.setProtocol(QSsl::SslV3);
QNetworkAccessManager
manger
;
QNetworkRequest
request
(
url
);
request
.
setSslConfiguration
(
config
);
//
request.setSslConfiguration(config);
request
.
setRawHeader
(
"Content-Type"
,
content
);
request
.
setRawHeader
(
"Accept"
,
accept
);
request
.
setRawHeader
(
"host"
,
host
);
request
.
setRawHeader
(
"Content-Type"
,
content
.
toUtf8
()
);
request
.
setRawHeader
(
"Accept"
,
accept
.
toUtf8
()
);
request
.
setRawHeader
(
"host"
,
host
.
toUtf8
()
);
request
.
setRawHeader
(
"Authorization"
,
"Basic dXBzLWNsaWVudDo2VGk4TjBXNzRyb1A="
);
...
...
@@ -68,7 +69,7 @@ bool FMNetWork::HttpPost(QString url, QByteArray outdata, const ByteArray &indat
return
false
;
}
QLOG_INFO
()
<<
outdata
;
QLOG_INFO
()
<<
outdata
.
data
()
;
return
true
;
}
sbkpay/DataProcess/fmnetwork.h
View file @
352b79c1
...
...
@@ -2,6 +2,7 @@
#define FMNETWORK_H
#include <QObject>
#include <QByteArray>
class
FMNetWork
:
public
QObject
{
...
...
@@ -9,7 +10,7 @@ class FMNetWork : public QObject
public
:
explicit
FMNetWork
(
QObject
*
parent
=
0
);
static
bool
HttpPost
(
QString
url
,
QByteArray
outdata
,
const
ByteArray
&
indata
,
QString
content
,
QString
accept
,
int
timeout
=
60
);
static
bool
HttpPost
(
QString
url
,
QByteArray
outdata
,
const
QByteArray
&
indata
,
QString
content
,
QString
accept
,
QString
&
error
=
QString
()
,
int
timeout
=
60
);
};
...
...
sbkpay/DataProcess/fmp_database.cpp
View file @
352b79c1
...
...
@@ -42,6 +42,8 @@ bool FMPDataBase::dlt(QString table, QString condition)
QString
sql
=
QString
(
"delete from %1 where %2"
).
arg
(
table
,
condition
);
qDebug
()
<<
"55555555555555555555555555555"
<<
sql
;
QSqlQuery
query
(
_db
);
bool
flag
=
query
.
exec
(
sql
);
...
...
@@ -63,7 +65,6 @@ bool FMPDataBase::insert(QString table, QVariantHash data)
if
(
!
getSql
(
table
,
data
,
columnnamelist
,
columnvaluelist
))
{
_db
.
close
();
return
false
;
}
...
...
@@ -92,7 +93,6 @@ bool FMPDataBase::update(QString table, QVariantHash data, QString condition)
if
(
!
getSql
(
table
,
data
,
sql
))
{
_db
.
close
();
return
false
;
}
...
...
sbkpay/DataProcess/rollback.cpp
View file @
352b79c1
...
...
@@ -14,7 +14,12 @@
RollBack
::
RollBack
(
QObject
*
parent
)
:
QThread
(
parent
)
{
_db
=
new
FMPDataBase
(
DB_ORDER
,
QString
(
"rollback"
));
QString
path
;
ToolS
::
GetPath
(
path
);
qDebug
()
<<
"++++++++++++++++++++++++++++"
<<
path
;
_db
=
new
FMPDataBase
(
path
+
DB_ORDER
,
QString
(
"rollback"
));
_spr
.
release
(
10
);
}
...
...
@@ -42,7 +47,7 @@ void RollBack::RollWiteQuery(QSqlQuery &query)
if
(
jsonDocument
.
isNull
()
)
{
QLOG_ERROR
()
<<
"content not json:"
<<
rps
;
QLOG_ERROR
()
<<
"content not json:"
<<
content
;
_db
->
dlt
(
DB_TABLE_NAME
,
QString
(
"%1='%2'"
).
arg
(
SQL_KEY_ORDERID
).
arg
(
parnetid
));
}
...
...
@@ -67,15 +72,18 @@ void RollBack::RollWiteQuery(QSqlQuery &query)
QByteArray
array
;
QString
path
;
QString
error
;
ToolS
::
GetPath
(
path
);
qDebug
()
<<
"*****************************"
<<
path
;
QString
url
=
QSettings
(
path
+
"
\\
"
+
USERCONFIG_NAME
,
QSettings
::
IniFormat
).
value
(
VALUE_URL
).
toString
();
if
(
FMNetWork
::
HttpPost
(
url
,
array
,
data
,
"application/json;charset=utf-8"
,
"application/json"
,
25
))
if
(
FMNetWork
::
HttpPost
(
url
,
array
,
data
,
"application/json;charset=utf-8"
,
"application/json"
,
error
,
25
))
{
FMPDataBase
db
(
DB_ORDER
,
QString
(
"curr"
)
+
QString
::
number
(
QThread
::
currentThreadId
()));
QString
path
;
ToolS
::
GetPath
(
path
);
FMPDataBase
db
(
path
+
"
\\
"
+
DB_ORDER
,
QString
(
"curr"
)
+
QString
::
number
((
int
)
QThread
::
currentThreadId
()));
db
.
dlt
(
DB_TABLE_NAME
,
QString
(
"%1='%2'"
).
arg
(
SQL_KEY_ORDERID
).
arg
(
parnetid
));
}
...
...
@@ -88,13 +96,15 @@ void RollBack::RollWiteQuery(QSqlQuery &query)
void
RollBack
::
run
()
{
while
(
isInterruptionRequested
())
while
(
!
isInterruptionRequested
())
{
QString
path
;
ToolS
::
GetPath
(
path
);
int
timeout
=
QSettings
(
path
+
"
\\
"
+
USERCONFIG_NAME
,
QSettings
::
IniFormat
).
value
(
VALUE_HOST
).
toInt
();
qDebug
()
<<
"======================"
<<
path
;
int
timeout
=
QSettings
(
path
+
"
\\
"
+
USERCONFIG_NAME
,
QSettings
::
IniFormat
).
value
(
VALUE_TIMEOUT
).
toInt
();
do
{
...
...
sbkpay/control.cpp
View file @
352b79c1
...
...
@@ -5,7 +5,7 @@
#include "QsLog.h"
#include "jsonfactory.h"
#include "rspfactory.h"
#include <QSemaphore>
#include <QtConcurrent>
#include <QSettings>
#include <QJsonObject>
...
...
@@ -13,36 +13,44 @@
#include <QFont>
#include <QFontDatabase>
#include <QApplication>
#include <QSslSocket>
#include <QSslConfiguration>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QNetworkRequest>
#include <QJsonDocument>
#include <Windows.h>
#include "DataProcess/tools.h"
#include "DataProcess/cretopt.h"
#include "DataProcess/fmnetwork.h"
//EXTERN_C IMAGE_DOS_HEADER __ImageBase;
typedef
int
(
__stdcall
*
GetValue
)
(
char
*
,
char
*
);
typedef
int
(
__stdcall
*
GetRSACret
)(
int
,
const
char
*
,
const
char
*
);
//void Control::GetProcPath(char * pathBuf)
//{
// int curPos;
Control
::
Control
(
QObject
*
parent
)
:
QObject
(
parent
),
_widget
(
NULL
)
{
QString
path
;
ToolS
::
GetPath
(
path
);
// GetModuleFileNameA((HMODULE)&__ImageBase, pathBuf, MAX_PATH);
_isinterrupt
=
false
;
_db
=
new
FMPDataBase
(
path
+
DB_ORDER
,
QString
(
"writeorder"
));
// curPos = strlen(pathBuf) - 1;
QString
sql
=
QString
(
"create table "
)
+
DB_TABLE_NAME
+
" ("
"orderid varchar(60) primary key, "
"content text"
")"
;
// while('\\' != pathBuf[curPos])
// {
// curPos--;
// }
QLOG_INFO
()
<<
"creat table : "
<<
sql
;
// curPos++
;
_db
->
creat
(
sql
)
;
// pathBuf[curPos] = '\0'
;
//
}
InitModel
()
;
}
Control
::
Control
(
QObject
*
parent
)
:
QObject
(
parent
),
_widget
(
NULL
)
Control
::
~
Control
(
)
{
InitModel
();
if
(
_db
!=
NULL
)
{
delete
_db
;
_db
=
NULL
;
}
}
void
Control
::
Start
(
const
char
*
indata
,
char
*
outdata
)
...
...
@@ -64,6 +72,10 @@ void Control::Start(const char *indata, char *outdata)
memcpy
(
&
_request
,
indata
,
sizeof
(
struct
AlipayRequest
));
connect
(
_widget
,
&
HostWidget
::
Interrupt
,
this
,
[
this
](){
_isinterrupt
=
true
;
});
connect
(
_widget
,
&
HostWidget
::
RequestWithType
,
this
,
&
Control
::
RequestWithType
);
connect
(
_widget
,
&
HostWidget
::
Exits
,
this
,
[
&
loop
,
&
refundflag
]
()
...
...
@@ -95,8 +107,6 @@ void Control::Start(const char *indata, char *outdata)
loop
.
exec
();
}
_lock
.
lock
();
delete
_widget
;
_widget
=
NULL
;
...
...
@@ -122,108 +132,138 @@ void Control::InitModel()
bool
Control
::
SendMessageToPayMent
(
const
QJsonObject
&
json
,
QByteArray
&
outdata
,
QString
&
error
)
{
QByteArray
array
;
QString
path
;
ToolS
::
GetPath
(
path
);
QString
url
=
QSettings
(
path
+
"
\\
"
+
USERCONFIG_NAME
,
QSettings
::
IniFormat
).
value
(
VALUE_URL
).
toString
();
char
mod
[
MAX_PATH
]
=
{
0
}
;
ToolS
::
GetProcPath
(
mod
);
QJsonObject
tmpjson
=
json
;
CretOperate
::
GetMAC
(
tmpjson
);
CretOperate
::
GetSign
(
tmpjson
);
QL
ibrary
lib
(
QString
(
mod
)
+
"
\\
"
+
"FreemudWrapper.dll"
)
;
QL
OG_INFO
()
<<
"send json to payment: "
<<
tmpjson
;
Q
LOG_INFO
()
<<
QString
(
mod
)
+
"
\\
"
+
"FreemudWrapper.dll"
;
Q
ByteArray
data
=
QJsonDocument
(
tmpjson
).
toJson
(
QJsonDocument
::
Compact
)
;
if
(
lib
.
load
(
))
if
(
!
Control
::
HttpPost
(
url
,
array
,
data
,
"application/json;charset=utf-8"
,
"application/json"
,
error
,
60
))
{
GetValue
getvalue
=
(
GetValue
)
lib
.
resolve
(
"_GetValue@8"
);
if
(
getvalue
!=
NULL
)
if
(
json
.
contains
(
JSON_KEY_PARTORDERID
)
&&
!
json
[
JSON_KEY_PARTORDERID
].
toString
().
isEmpty
())
{
QVariantHash
hash
;
hash
.
insert
(
SQL_KEY_ORDERID
,
json
[
JSON_KEY_PARTORDERID
].
toString
());
hash
.
insert
(
SQL_KET_CONTENT
,
QString
(
data
));
_db
->
insert
(
DB_TABLE_NAME
,
hash
);
}
return
false
;
}
outdata
=
array
;
return
true
;
}
bool
Control
::
HttpPost
(
QString
url
,
QByteArray
&
outdata
,
const
QByteArray
&
indata
,
QString
content
,
QString
accept
,
QString
&
error
,
int
timeout
)
{
QString
path
;
ToolS
::
GetPath
(
path
);
QString
host
=
QSettings
(
path
+
"
\\
"
+
USERCONFIG_NAME
,
QSettings
::
IniFormat
).
value
(
VALUE_HOST
).
toString
();
QEventLoop
loop
;
QTimer
timer
;
connect
(
_widget
,
&
HostWidget
::
Interrupt
,
&
loop
,
&
QEventLoop
::
quit
);
// QSslConfiguration config;
// config.setPeerVerifyMode(QSslSocket::VerifyNone);
// config.setProtocol(QSsl::SslV3);
QFuture
<
QByteArray
>
future
=
QtConcurrent
::
run
(
[
this
,
&
loop
,
json
,
getvalue
]()
->
QByteArray
{
char
in
[
MAX_BUF_LEN
]
=
{
0
};
char
out
[
MAX_BUF_LEN
]
=
{
0
};
QNetworkAccessManager
manger
;
QNetworkRequest
request
(
url
);
QByteArray
array
=
QJsonDocument
(
json
).
toJson
(
QJsonDocument
::
Compact
);
strcpy
(
in
,
array
);
//request.setSslConfiguration(config);
getvalue
(
in
,
out
);
request
.
setRawHeader
(
"Content-Type"
,
content
.
toUtf8
());
request
.
setRawHeader
(
"Accept"
,
accept
.
toUtf8
());
request
.
setRawHeader
(
"host"
,
host
.
toUtf8
());
request
.
setRawHeader
(
"Authorization"
,
"Basic dXBzLWNsaWVudDo2VGk4TjBXNzRyb1A="
);
return
QByteArray
(
out
);
});
QFutureWatcher
<
QByteArray
>
watcher
;
watcher
.
setFuture
(
future
);
connect
(
&
watcher
,
SIGNAL
(
finished
()),
&
loop
,
SLOT
(
quit
()));
QNetworkReply
*
reply
=
manger
.
post
(
request
,
indata
);
connect
(
&
timer
,
&
QTimer
::
timeout
,
&
loop
,
&
QEventLoop
::
quit
);
connect
(
&
manger
,
&
QNetworkAccessManager
::
finished
,
&
loop
,
&
QEventLoop
::
quit
);
connect
(
_widget
,
&
HostWidget
::
Interrupt
,
&
loop
,
&
QEventLoop
::
quit
);
connect
(
reply
,
static_cast
<
void
(
QNetworkReply
::*
)(
QNetworkReply
::
NetworkError
)
>
(
&
QNetworkReply
::
error
),
&
loop
,
&
QEventLoop
::
quit
);
timer
.
start
(
timeout
*
1000
);
loop
.
exec
();
outdata
=
watcher
.
result
();
return
true
;
}
else
reply
->
deleteLater
();
if
(
_isinterrupt
)
{
QLOG_ERROR
()
<<
"get function (GetRSACret) failed"
;
error
=
QString
::
fromLocal8Bit
(
"加载基础组件(fun)失败"
)
;
error
=
QString
::
fromLocal8Bit
(
"交易或操作被撤销"
)
;
return
false
;
}
}
else
if
(
reply
->
error
()
!=
QNetworkReply
::
NoError
)
{
QLOG_ERROR
()
<<
"load dll failed"
;
error
=
QString
::
fromLocal8Bit
(
"加载基础组件(dll)失败"
)
;
error
=
QString
::
fromLocal8Bit
(
"网络异常,无法获取签名"
)
;
return
false
;
}
outdata
=
reply
->
readAll
();
if
(
outdata
.
isEmpty
())
{
error
=
QString
::
fromLocal8Bit
(
"网络异常,无法获取签名"
);
return
false
;
}
QLOG_INFO
()
<<
outdata
.
data
();
return
true
;
}
bool
Control
::
GetRSA
(
QString
&
error
)
{
char
mod
[
MAX_PATH
]
=
{
0
};
ToolS
::
GetProcPath
(
mod
);
QLibrary
lib
(
QString
(
mod
)
+
"
\\
"
+
"FreemudWrapper.dll"
);
int
rlt
=
0
;
QJsonObject
json
;
error
.
clear
();
json
.
insert
(
JSON_KEY_VER
,
1
);
json
.
insert
(
JSON_KEY_REQTYPE
,
99
);
json
.
insert
(
JSON_KEY_STOREID
,
FMTool
::
GetString
(
_request
.
StoreNo
,
20
));
json
.
insert
(
JSON_KEY_STATIONID
,
FMTool
::
GetString
(
_request
.
DeviceNo
,
6
));
json
.
insert
(
JSON_KEY_PARTNERID
,
FMTool
::
GetString
(
_request
.
PlatNo
,
4
));
if
(
lib
.
load
())
{
CretOperate
::
GetDES3MAC
(
json
);
QByteArray
array
;
GetRSACret
getrsacret
=
(
GetRSACret
)
lib
.
resolve
(
"_GetRSACret@12"
)
;
QLOG_INFO
()
<<
"get mac sign request : "
<<
json
;
if
(
getrsacret
!=
NULL
)
{
QEventLoop
loop
;
QtConcurrent
::
run
(
[
this
,
&
loop
,
&
rlt
,
&
error
,
getrsacret
]()
{
int
i
=
FMTool
::
GetString
(
_request
.
PlatNo
,
4
).
toInt
();
QString
storeID
=
FMTool
::
GetString
(
_request
.
StoreNo
,
20
);
QString
PosNO
=
FMTool
::
GetString
(
_request
.
DeviceNo
,
6
);
rlt
=
getrsacret
(
i
,
storeID
.
toLatin1
().
data
(),
PosNO
.
toLatin1
().
data
());
if
(
!
rlt
)
error
=
QString
::
fromLocal8Bit
(
"获取服务端返回数据失败"
);
loop
.
exit
();
});
QString
path
;
ToolS
::
GetPath
(
path
);
QString
url
=
QSettings
(
path
+
"
\\
"
+
USERCONFIG_NAME
,
QSettings
::
IniFormat
).
value
(
VALUE_URL_CRET
).
toString
();
QByteArray
data
=
QJsonDocument
(
json
).
toJson
(
QJsonDocument
::
Compact
);
loop
.
exec
();
}
else
if
(
!
Control
::
HttpPost
(
url
,
array
,
data
,
"application/json;charset=utf-8"
,
"application/json"
,
error
,
60
))
{
QLOG_ERROR
()
<<
"get function (GetRSACret) failed"
;
error
=
QString
::
fromLocal8Bit
(
"加载基础组件(fun)失败"
)
;
QLOG_ERROR
()
<<
"httppos error :"
<<
error
;
return
false
;
}
}
else
if
(
CretOperate
::
SetRSACret
(
array
)
==
0
)
{
QLOG_ERROR
()
<<
"load dll failed"
;
error
=
QString
::
fromLocal8Bit
(
"加载基础组件(dll)失败"
)
;
error
=
QString
::
fromLocal8Bit
(
"签名失败,请重新获取签名"
)
;
return
false
;
}
return
rlt
;
return
true
;
}
void
Control
::
RequestSign
()
...
...
@@ -317,3 +357,8 @@ void Control::RequestWithType(ReqType type, QStringList list)
}
Request
(
type
,
list
);
}
void
Control
::
setIsinterrupt
(
bool
isinterrupt
)
{
_isinterrupt
=
isinterrupt
;
}
sbkpay/control.h
View file @
352b79c1
...
...
@@ -3,6 +3,7 @@
#include "requestmodel.h"
#include "hostwidget.h"
#include "DataProcess/fmp_database.h"
#include <QObject>
#include <QApplication>
#include <QLibrary>
...
...
@@ -16,9 +17,13 @@ public:
explicit
Control
(
QObject
*
parent
=
0
);
~
Control
();
void
Start
(
const
char
*
indata
,
char
*
outdata
);
//static void GetProcPath(char *pathBuf);
void
setIsinterrupt
(
bool
isinterrupt
);
signals
:
void
Exits
();
...
...
@@ -44,12 +49,12 @@ private:
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
);
public
slots
:
void
RequestWithType
(
ReqType
type
,
QStringList
list
);
private
:
struct
AlipayRequest
_request
;
struct
AlipayResponse
_response
;
...
...
@@ -59,8 +64,9 @@ private:
QString
_fmId
;
bool
_isinterrupt
;
FMPDataBase
*
_db
;
};
...
...
sbkpay/hostwidget.cpp
View file @
352b79c1
...
...
@@ -31,10 +31,19 @@ HostWidget::HostWidget(QWidget *parent) :
InitWidget
();
connect
(
&
_intertime
,
&
QTimer
::
timeout
,
this
,
[
this
](){
if
(
!
_need_exit
)
{
ui
->
btn_pay_exitint
->
show
();
}
});
_label_pay_timer
=
new
LabelsTimer
(
ui
->
label_pay_time
,
60
,
QString
::
fromLocal8Bit
(
"%1 秒"
));
_label_find_timer
=
new
LabelsTimer
(
ui
->
label_check_timer
,
60
,
QString
::
fromLocal8Bit
(
"%1 秒"
));
connect
(
_label_pay_timer
,
&
LabelsTimer
::
timeout
,
this
,
&
HostWidget
::
on_TimeOut
);
connect
(
_label_find_timer
,
&
LabelsTimer
::
timeout
,
this
,
&
HostWidget
::
on_TimeOut
);
...
...
@@ -56,6 +65,7 @@ void HostWidget::ShowWidget(QWidget *showwidget)
if
(
showwidget
==
ui
->
pay
)
{
ui
->
lineEdit_pay_code
->
clear
();
ui
->
btn_pay_exitint
->
hide
();
ui
->
lineEdit_pay_code
->
setWindowOpacity
(
0
);
ui
->
lineEdit_pay_code
->
setFocus
();
ui
->
label_pay_msg_time
->
setVisible
(
false
);
...
...
@@ -73,8 +83,11 @@ void HostWidget::ShowWidget(QWidget *showwidget)
}
_widgetlist
.
at
(
i
)
->
hide
();
}
//this->show();
this
->
showFullScreen
();
this
->
show
();
this
->
move
(
1200
,
500
);
//this->showFullScreen();
}
void
HostWidget
::
InitWidget
()
...
...
@@ -119,6 +132,7 @@ void HostWidget::keyPressEvent(QKeyEvent *ke)
if
(
_type
==
pay
)
{
ui
->
label_pay_title
->
setText
(
QString
::
fromLocal8Bit
(
"支付宝支付中..."
));
_intertime
.
start
(
2
*
1000
);
emit
RequestWithType
(
pay
,
list
);
}
else
...
...
@@ -573,3 +587,8 @@ void HostWidget::on_btn_find_up_clicked()
}
on_btn_find_check_clicked
();
}
void
HostWidget
::
on_btn_pay_exitint_clicked
()
{
emit
Interrupt
();
}
sbkpay/hostwidget.h
View file @
352b79c1
...
...
@@ -5,6 +5,7 @@
#include "requestmodel.h"
#include <QWidget>
#include <QList>
#include <QTimer>
#include <QStringList>
class
LabelsTimer
;
...
...
@@ -39,6 +40,7 @@ signals:
void
Exits
();
//中断网络请求
void
Interrupt
();
protected
:
...
...
@@ -71,6 +73,8 @@ private slots:
void
on_btn_find_up_clicked
();
void
on_btn_pay_exitint_clicked
();
private
:
void
ShowWidget
(
QWidget
*
showwidget
);
...
...
@@ -89,6 +93,8 @@ private:
LabelsTimer
*
_label_find_timer
;
QTimer
_intertime
;
QMovie
*
_label_pay_movie
;
int
_line
;
...
...
sbkpay/hostwidget.ui
View file @
352b79c1
...
...
@@ -1459,12 +1459,12 @@ QHeaderView::section{
</spacer>
</item>
<item>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout_1
0
"
>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout_1
3
"
>
<property
name=
"spacing"
>
<number>
0
</number>
</property>
<item>
<spacer
name=
"horizontalSpacer_
15
"
>
<spacer
name=
"horizontalSpacer_
34
"
>
<property
name=
"orientation"
>
<enum>
Qt::Horizontal
</enum>
</property>
...
...
@@ -1477,7 +1477,7 @@ QHeaderView::section{
</spacer>
</item>
<item>
<widget
class=
"QPushButton"
name=
"btn_pay_exit"
>
<widget
class=
"QPushButton"
name=
"btn_pay_exit
int
"
>
<property
name=
"minimumSize"
>
<size>
<width>
340
</width>
...
...
@@ -1485,7 +1485,7 @@ QHeaderView::section{
</size>
</property>
<property
name=
"styleSheet"
>
<string
notr=
"true"
>
#btn_pay_exit
<string
notr=
"true"
>
#btn_pay_exit
int
{
border:0px;
border-radius:3px;
...
...
@@ -1495,12 +1495,12 @@ QHeaderView::section{
}
</string>
</property>
<property
name=
"text"
>
<string>
取消付款
</string>
<string>
撤销交易
</string>
</property>
</widget>
</item>
<item>
<spacer
name=
"horizontalSpacer_
16
"
>
<spacer
name=
"horizontalSpacer_
35
"
>
<property
name=
"orientation"
>
<enum>
Qt::Horizontal
</enum>
</property>
...
...
@@ -1515,19 +1515,62 @@ QHeaderView::section{
</layout>
</item>
<item>
<widget
class=
"QLineEdit"
name=
"lineEdit_pay_code"
>
<property
name=
"maximumSize"
>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout_10"
>
<property
name=
"spacing"
>
<number>
0
</number>
</property>
<item>
<spacer
name=
"horizontalSpacer_15"
>
<property
name=
"orientation"
>
<enum>
Qt::Horizontal
</enum>
</property>
<property
name=
"sizeHint"
stdset=
"0"
>
<size>
<width>
0
</width>
<height>
0
</height>
<width>
4
0
</width>
<height>
2
0
</height>
</size>
</property>
<property
name=
"focusPolicy"
>
<enum>
Qt::NoFocus
</enum>
</spacer>
</item>
<item>
<widget
class=
"QPushButton"
name=
"btn_pay_exit"
>
<property
name=
"minimumSize"
>
<size>
<width>
340
</width>
<height>
40
</height>
</size>
</property>
<property
name=
"styleSheet"
>
<string
notr=
"true"
>
#btn_pay_exit
{
border:0px;
border-radius:3px;
background-color: rgb(128, 134, 143);
font: 75 20px
"
Microsoft YaHei UI Light
"
;
color: rgb(255, 255, 255);
}
</string>
</property>
<property
name=
"text"
>
<string>
取消付款
</string>
</property>
</widget>
</item>
<item>
<spacer
name=
"horizontalSpacer_16"
>
<property
name=
"orientation"
>
<enum>
Qt::Horizontal
</enum>
</property>
<property
name=
"sizeHint"
stdset=
"0"
>
<size>
<width>
40
</width>
<height>
20
</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer
name=
"verticalSpacer_7"
>
<property
name=
"orientation"
>
<enum>
Qt::Vertical
</enum>
...
...
@@ -1543,6 +1586,19 @@ QHeaderView::section{
</property>
</spacer>
</item>
<item>
<widget
class=
"QLineEdit"
name=
"lineEdit_pay_code"
>
<property
name=
"maximumSize"
>
<size>
<width>
0
</width>
<height>
0
</height>
</size>
</property>
<property
name=
"focusPolicy"
>
<enum>
Qt::NoFocus
</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
...
...
sbkpay/main.cpp
View file @
352b79c1
...
...
@@ -77,10 +77,14 @@ extern "C" __declspec(dllexport) void Start(const char *indata, char *outdata)
#include "rspfactory.h"
#include <QDir>
#include <QApplication>
#include "DataProcess/rollback.h"
#include <QStringList>
#include "DataProcess/dataprocess.h"
#include "DataProcess/cretopt.h"
static
RollBack
rollback
;
void
TestSetString
()
{
AlipayResponse
repon
;
...
...
@@ -257,6 +261,8 @@ void TestCret()
qDebug
()
<<
json
;
}
int
main
(
int
argc
,
char
*
argv
[])
{
...
...
@@ -301,7 +307,7 @@ int main(int argc, char *argv[])
AlipayRequest
req
;
FMTool
::
SetString
(
req
.
BusinessDay
,
8
,
QString
(
"20170909"
));
FMTool
::
SetString
(
req
.
TransType
,
2
,
QString
(
"
1
0"
));
FMTool
::
SetString
(
req
.
TransType
,
2
,
QString
(
"
3
0"
));
FMTool
::
SetString
(
req
.
PlatNo
,
4
,
QString
(
"1443"
));
FMTool
::
SetString
(
req
.
TransTime
,
6
,
QString
(
"130301"
));
FMTool
::
SetString
(
req
.
StoreNo
,
20
,
QString
(
"17607"
));
...
...
@@ -346,12 +352,12 @@ int main(int argc, char *argv[])
Control
control
;
rollback
.
start
();
//char as[] = "ak10dh171300000000000 *#dhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh";
char
b
[
MAX_BUF_LEN
]
=
{
0
};
//
control.Start(as, b);
control
.
Start
(
as
,
b
);
return
a
.
exec
();
}
...
...
sbkpay/sbkpay.pro
View file @
352b79c1
...
...
@@ -13,6 +13,8 @@ TARGET = sbkpay
include
(
"./QsLog/QsLog.pri"
)
include
(
"./DataProcess/DataProcess.pri"
)
LIBS
+=
-
L
"C:/openssl/openssl-1.0.1s/out32dll"
-
llibeay32
LIBS
+=
-
L
"C:/openssl/openssl-1.0.1s/out32dll"
-
lssleay32
CONFIG
+=
C
++
11
...
...
sbkpay/sbkpay.pro.user
View file @
352b79c1
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 3.5.1, 2017-08-2
5T18:48:34
. -->
<!-- Written by QtCreator 3.5.1, 2017-08-2
6T17:02:37
. -->
<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