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
4a97cd48
Commit
4a97cd48
authored
Aug 29, 2017
by
NitefullWind
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1. 不再使用dll提供的发送、签名、获取mac地址等函数。
parent
45a2a22f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
222 deletions
+52
-222
sbkpay/control.cpp
+48
-217
sbkpay/control.h
+3
-5
sbkpay/hostwidget.cpp
+1
-0
No files found.
sbkpay/control.cpp
View file @
4a97cd48
...
@@ -26,31 +26,7 @@
...
@@ -26,31 +26,7 @@
EXTERN_C
IMAGE_DOS_HEADER
__ImageBase
;
EXTERN_C
IMAGE_DOS_HEADER
__ImageBase
;
typedef
int
(
__stdcall
*
GetValue
)
(
char
*
,
char
*
);
typedef
int
(
__stdcall
*
GetRSACret
)(
int
,
const
char
*
,
const
char
*
);
typedef
int
(
__stdcall
*
SKBAPISend
)(
const
char
*
indata
,
const
char
*
guid
,
char
*
outdata
,
char
*
errMsg
,
const
char
*
mode
);
typedef
int
(
__stdcall
*
SKBAPISend
)(
const
char
*
indata
,
const
char
*
guid
,
char
*
outdata
,
char
*
errMsg
,
const
char
*
mode
);
typedef
int
(
__stdcall
*
AddSign
)(
char
*
,
char
*
);
typedef
int
(
__stdcall
*
GetMac
)(
char
*
);
typedef
int
(
__stdcall
*
GetRealMac
)(
char
*
);
typedef
int
(
__stdcall
*
SetRSACret
)(
char
*
);
//void Control::GetProcPath(char * pathBuf)
//{
// int curPos;
// GetModuleFileNameA((HMODULE)&__ImageBase, pathBuf, MAX_PATH);
// curPos = strlen(pathBuf) - 1;
// while('\\' != pathBuf[curPos])
// {
// curPos--;
// }
// curPos++;
// pathBuf[curPos] = '\0';
//}
Control
::
Control
(
QObject
*
parent
)
:
QObject
(
parent
),
_widget
(
NULL
)
Control
::
Control
(
QObject
*
parent
)
:
QObject
(
parent
),
_widget
(
NULL
)
{
{
...
@@ -156,7 +132,7 @@ void Control::Start(const char *indata, char *outdata)
...
@@ -156,7 +132,7 @@ void Control::Start(const char *indata, char *outdata)
void
Control
::
InitPOSReqJsonObj
(
const
char
*
indata
)
void
Control
::
InitPOSReqJsonObj
(
const
char
*
indata
)
{
{
QJsonParseError
parseError
;
QJsonParseError
parseError
;
QJsonDocument
inDataDoc
=
QJsonDocument
::
fromJson
(
QString
::
from
Utf8
(
indata
).
toUtf8
(),
&
parseError
);
QJsonDocument
inDataDoc
=
QJsonDocument
::
fromJson
(
QString
::
from
Local8Bit
(
indata
).
toUtf8
(),
&
parseError
);
if
(
parseError
.
error
==
QJsonParseError
::
NoError
)
{
if
(
parseError
.
error
==
QJsonParseError
::
NoError
)
{
_posReqJsonObj
=
inDataDoc
.
object
();
_posReqJsonObj
=
inDataDoc
.
object
();
...
@@ -197,6 +173,23 @@ void Control::InitModel()
...
@@ -197,6 +173,23 @@ void Control::InitModel()
_responseJsonObj
=
QJsonObject
();
_responseJsonObj
=
QJsonObject
();
}
}
bool
Control
::
SendMessageToServer
(
const
QJsonObject
&
json
,
QByteArray
&
outdata
,
QString
&
error
)
{
QJsonObject
tmpjson
=
json
;
tmpjson
[
JSON_KEY_VER
]
=
DEFAULT_JSON_VER_VALUE
;
CretOperate
::
GetMAC
(
tmpjson
);
CretOperate
::
GetSign
(
tmpjson
);
QLOG_INFO
()
<<
"send json to payment: "
<<
tmpjson
;
if
(
_posType
==
SPCC
)
{
return
SendMessageToSBKAPI
(
tmpjson
,
outdata
,
error
);
}
else
{
return
SendMessageToPayMent
(
tmpjson
,
outdata
,
error
);
}
return
false
;
}
bool
Control
::
SendMessageToPayMent
(
const
QJsonObject
&
json
,
QByteArray
&
outdata
,
QString
&
error
)
bool
Control
::
SendMessageToPayMent
(
const
QJsonObject
&
json
,
QByteArray
&
outdata
,
QString
&
error
)
{
{
QByteArray
array
;
QByteArray
array
;
...
@@ -204,13 +197,9 @@ bool Control::SendMessageToPayMent(const QJsonObject &json, QByteArray &outdata,
...
@@ -204,13 +197,9 @@ bool Control::SendMessageToPayMent(const QJsonObject &json, QByteArray &outdata,
ToolS
::
GetPath
(
path
);
ToolS
::
GetPath
(
path
);
QString
url
=
QSettings
(
path
+
"
\\
"
+
USERCONFIG_NAME
,
QSettings
::
IniFormat
).
value
(
VALUE_URL
).
toString
();
QString
url
=
QSettings
(
path
+
"
\\
"
+
USERCONFIG_NAME
,
QSettings
::
IniFormat
).
value
(
VALUE_URL
).
toString
();
QJsonObject
tmpjson
=
json
;
QLOG_INFO
()
<<
"send json to payment: "
<<
json
;
CretOperate
::
GetMAC
(
tmpjson
);
CretOperate
::
GetSign
(
tmpjson
);
QLOG_INFO
()
<<
"send json to payment: "
<<
tmpjson
;
QByteArray
data
=
QJsonDocument
(
json
).
toJson
(
QJsonDocument
::
Compact
);
QByteArray
data
=
QJsonDocument
(
tmpjson
).
toJson
(
QJsonDocument
::
Compact
);
if
(
!
Control
::
HttpPost
(
url
,
array
,
data
,
"application/json;charset=utf-8"
,
"application/json"
,
error
,
60
))
if
(
!
Control
::
HttpPost
(
url
,
array
,
data
,
"application/json;charset=utf-8"
,
"application/json"
,
error
,
60
))
{
{
...
@@ -438,131 +427,46 @@ bool Control::SendMessageToSBKAPI(const QJsonObject &json, QByteArray &outdata,
...
@@ -438,131 +427,46 @@ bool Control::SendMessageToSBKAPI(const QJsonObject &json, QByteArray &outdata,
bool
Control
::
GetRSA
(
QString
&
error
)
bool
Control
::
GetRSA
(
QString
&
error
)
{
{
// QJsonObject json;
// 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));
// CretOperate::GetDES3MAC(json);
// QByteArray array;
// QLOG_INFO() << "get mac sign request : " << json;
// 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);
// if(!Control::HttpPost(url, array, data,"application/json;charset=utf-8", "application/json", error, 60))
// {
// QLOG_ERROR() << "httppos error :" << error;
// return false;
// }
// if(CretOperate::SetRSACret(array) == 0)
// {
// error = QString::fromLocal8Bit("签名失败,请重新获取签名");
// return false;
// }
// return true;
QJsonObject
json
;
QJsonObject
json
;
JsonFactory
::
GetJsonWithType
(
sign
,
json
,
_posReqJsonObj
,
QStringList
());
char
mod
[
MAX_PATH
]
=
{
0
};
json
.
insert
(
JSON_KEY_VER
,
1
);
json
.
insert
(
JSON_KEY_REQTYPE
,
99
);
json
.
insert
(
JSON_KEY_STOREID
,
FMTool
::
GetJsonValue
(
_posReqJsonObj
,
JSON_KEY_STOREID
).
toString
());
json
.
insert
(
JSON_KEY_STATIONID
,
FMTool
::
GetJsonValue
(
_posReqJsonObj
,
JSON_KEY_STATIONID
).
toString
());
json
.
insert
(
JSON_KEY_PARTNERID
,
QString
::
number
(
FMTool
::
GetJsonValue
(
_posReqJsonObj
,
JSON_KEY_PARTNERID
).
toInt
()));
ToolS
::
GetProcPath
(
mod
);
CretOperate
::
GetDES3MAC
(
json
);
QByteArray
array
;
QLibrary
lib
(
QString
(
mod
)
+
"
\\
"
+
"FreemudWrapper.dll"
);
QLOG_INFO
()
<<
"get mac sign request : "
<<
json
;
int
rlt
=
0
;
error
.
clear
();
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
);
if
(
lib
.
load
()
)
if
(
_posType
==
SPCC
)
{
{
json
[
"mac"
]
=
GetMacString
();
if
(
!
SendMessageToSBKAPI
(
json
,
array
,
error
))
{
QByteArray
out
;
QLOG_ERROR
()
<<
"SendMessageToSBKAPI error: "
<<
error
;
if
(
!
SendMessageToSBKAPI
(
json
,
out
,
error
))
{
QLOG_ERROR
()
<<
"GetRSA error: "
<<
error
;
return
false
;
return
false
;
}
}
}
else
{
SetRSACret
setRsaCret
=
(
SetRSACret
)
lib
.
resolve
(
"SetRSACret"
);
if
(
!
Control
::
HttpPost
(
url
,
array
,
data
,
"application/json;charset=utf-8"
,
"application/json"
,
error
,
60
))
if
(
setRsaCret
!=
NULL
)
{
{
rlt
=
setRsaCret
(
out
.
data
());
QLOG_ERROR
()
<<
"httppos error :"
<<
error
;
if
(
rlt
)
{
return
false
;
QLOG_INFO
()
<<
"setRSACret return success. "
;
}
else
{
error
=
QString
::
fromLocal8Bit
(
"保存文件签名失败"
);
QLOG_ERROR
()
<<
error
;
}
}
else
{
QLOG_ERROR
()
<<
"get function (SetRSACret) failed"
;
error
=
QString
::
fromLocal8Bit
(
"加载基础组件(fun)失败"
);
}
}
}
}
else
{
QLOG_ERROR
()
<<
"load dll failed"
;
error
=
QString
::
fromLocal8Bit
(
"加载基础组件(dll)失败"
);
}
return
(
rlt
==
1
);
}
QString
Control
::
GetMacString
(
bool
isSign
)
if
(
CretOperate
::
SetRSACret
(
array
)
==
0
)
{
char
mod
[
MAX_PATH
]
=
{
0
};
ToolS
::
GetProcPath
(
mod
);
QLibrary
lib
(
QString
(
mod
)
+
"
\\
"
+
"FreemudWrapper.dll"
);
if
(
lib
.
load
())
{
{
if
(
isSign
)
{
error
=
QString
::
fromLocal8Bit
(
"签名失败,请重新获取签名"
);
GetMac
getMac
=
(
GetMac
)
lib
.
resolve
(
"GetMac"
);
return
false
;
if
(
getMac
!=
NULL
)
{
char
mac
[
128
]
=
{
0
};
if
(
getMac
(
mac
)
==
1
)
{
QString
macStr
=
QString
::
fromUtf8
(
mac
);
QLOG_INFO
()
<<
"Get mac success: "
<<
macStr
;
return
macStr
;
}
else
{
QLOG_ERROR
()
<<
"Get mac failed."
;
}
}
else
{
QLOG_ERROR
()
<<
"get function (GetMac) failed"
;
}
}
else
{
GetRealMac
getMac
=
(
GetRealMac
)
lib
.
resolve
(
"GetRealMac"
);
if
(
getMac
!=
NULL
)
{
char
mac
[
128
]
=
{
0
};
if
(
getMac
(
mac
)
==
1
)
{
QString
macStr
=
QString
::
fromUtf8
(
mac
);
QLOG_INFO
()
<<
"Get mac success: "
<<
macStr
;
return
macStr
;
}
else
{
QLOG_ERROR
()
<<
"Get real mac failed."
;
}
}
else
{
QLOG_ERROR
()
<<
"get function (GetRealMac) failed"
;
}
}
}
else
{
QLOG_ERROR
()
<<
"load dll failed"
;
}
}
return
""
;
return
true
;
}
}
void
Control
::
RequestSign
()
void
Control
::
RequestSign
()
...
@@ -625,56 +529,14 @@ void Control::Request(ReqType type, QStringList list)
...
@@ -625,56 +529,14 @@ void Control::Request(ReqType type, QStringList list)
QString
error
;
QString
error
;
QByteArray
outdata
;
QByteArray
outdata
;
// JsonFactory::GetJsonWithType(type, json, _request, list);
if
(
type
==
againprint
)
if
(
type
==
againprint
)
_fmId
=
list
[
0
];
_fmId
=
list
[
0
];
// bool rlt = SendMessageToPayMent(json, outdata, error);
JsonFactory
::
GetJsonWithType
(
type
,
json
,
_posReqJsonObj
,
list
);
JsonFactory
::
GetJsonWithType
(
type
,
json
,
_posReqJsonObj
,
list
);
json
[
"ver"
]
=
1
;
json
[
"mac"
]
=
GetMacString
(
false
);
QByteArray
jsonArray
=
QJsonDocument
(
json
).
toJson
(
QJsonDocument
::
Compact
);
char
signStr
[
MAX_BUF_LEN
]
=
{
0
};
bool
rlt
=
false
;
#ifdef MOCK
#else
if
((
rlt
=
GetSPCCSign
(
jsonArray
.
data
(),
signStr
,
error
)))
#endif
{
json
[
"sign"
]
=
QString
::
fromLocal8Bit
(
signStr
);
QLOG_INFO
()
<<
"Sign str: "
<<
signStr
;
QJsonDocument
(
json
).
toJson
(
QJsonDocument
::
Compact
)
;
switch
(
_posType
)
{
bool
rlt
=
SendMessageToServer
(
json
,
outdata
,
error
);
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
)
if
(
rlt
)
rlt
=
Control
::
GetJson
(
type
,
rtjson
,
outdata
,
error
);
rlt
=
Control
::
GetJson
(
type
,
rtjson
,
outdata
,
error
);
...
@@ -707,34 +569,3 @@ void Control::setIsinterrupt(bool isinterrupt)
...
@@ -707,34 +569,3 @@ void Control::setIsinterrupt(bool isinterrupt)
{
{
_isinterrupt
=
isinterrupt
;
_isinterrupt
=
isinterrupt
;
}
}
bool
Control
::
GetSPCCSign
(
char
*
in
,
char
*
out
,
QString
&
error
)
{
char
mod
[
MAX_PATH
]
=
{
0
};
ToolS
::
GetProcPath
(
mod
);
QLibrary
lib
(
QString
(
mod
)
+
"
\\
"
+
"FreemudWrapper.dll"
);
if
(
lib
.
load
())
{
AddSign
addsign
=
(
AddSign
)
lib
.
resolve
(
"AddSign"
);
if
(
addsign
!=
NULL
)
{
if
(
addsign
(
in
,
out
))
{
return
true
;
}
else
{
error
=
QString
::
fromLocal8Bit
(
"获取签名失败."
);
QLOG_ERROR
()
<<
error
;
}
}
else
{
error
=
QString
::
fromLocal8Bit
(
"加载函数(AddSign)失败"
);
QLOG_ERROR
()
<<
error
;
}
}
else
{
error
=
QString
::
fromLocal8Bit
(
"加载基础组件(FreemudWrapper)失败"
);
QLOG_ERROR
()
<<
error
;
}
return
false
;
}
sbkpay/control.h
View file @
4a97cd48
...
@@ -21,7 +21,6 @@ public:
...
@@ -21,7 +21,6 @@ public:
void
Start
(
const
char
*
indata
,
char
*
outdata
);
void
Start
(
const
char
*
indata
,
char
*
outdata
);
//static void GetProcPath(char *pathBuf);
void
setIsinterrupt
(
bool
isinterrupt
);
void
setIsinterrupt
(
bool
isinterrupt
);
signals
:
signals
:
...
@@ -35,6 +34,8 @@ private:
...
@@ -35,6 +34,8 @@ private:
void
InitModel
();
void
InitModel
();
bool
SendMessageToServer
(
const
QJsonObject
&
json
,
QByteArray
&
outdata
,
QString
&
error
);
bool
SendMessageToPayMent
(
const
QJsonObject
&
json
,
QByteArray
&
outdata
,
QString
&
error
);
bool
SendMessageToPayMent
(
const
QJsonObject
&
json
,
QByteArray
&
outdata
,
QString
&
error
);
bool
SendMessageToSBKAPI
(
const
QJsonObject
&
json
,
QByteArray
&
outdata
,
QString
&
error
);
bool
SendMessageToSBKAPI
(
const
QJsonObject
&
json
,
QByteArray
&
outdata
,
QString
&
error
);
...
@@ -53,10 +54,6 @@ private:
...
@@ -53,10 +54,6 @@ private:
bool
HttpPost
(
QString
url
,
QByteArray
&
outdata
,
const
QByteArray
&
indata
,
QString
content
,
QString
accept
,
QString
&
error
,
int
timeout
);
bool
HttpPost
(
QString
url
,
QByteArray
&
outdata
,
const
QByteArray
&
indata
,
QString
content
,
QString
accept
,
QString
&
error
,
int
timeout
);
bool
GetSPCCSign
(
char
*
in
,
char
*
out
,
QString
&
error
);
QString
GetMacString
(
bool
isSign
=
true
);
void
InitPOSReqJsonObj
(
const
char
*
indata
);
void
InitPOSReqJsonObj
(
const
char
*
indata
);
public
slots
:
public
slots
:
...
@@ -79,6 +76,7 @@ private:
...
@@ -79,6 +76,7 @@ private:
FMPDataBase
*
_db
;
FMPDataBase
*
_db
;
POSType
_posType
;
};
};
#endif // CONTROL_H
#endif // CONTROL_H
sbkpay/hostwidget.cpp
View file @
4a97cd48
...
@@ -531,6 +531,7 @@ void HostWidget::on_btn_mananger_register_clicked()
...
@@ -531,6 +531,7 @@ void HostWidget::on_btn_mananger_register_clicked()
void
HostWidget
::
on_btn_mananger_check_clicked
()
void
HostWidget
::
on_btn_mananger_check_clicked
()
{
{
_type
=
finds
;
_type
=
finds
;
ui
->
label_find_title
->
setText
(
QString
::
fromLocal8Bit
(
"门店%1交易流水查询"
).
arg
(
FMTool
::
GetJsonValue
(
_posReqJsonObj
,
JSON_KEY_STOREID
).
toString
()));
ui
->
label_find_msg
->
clear
();
ui
->
label_find_msg
->
clear
();
ui
->
dateEdit_find_begin
->
setDisplayFormat
(
"yyyy-MM-dd"
);
ui
->
dateEdit_find_begin
->
setDisplayFormat
(
"yyyy-MM-dd"
);
ui
->
dateEdit_find_end
->
setDisplayFormat
(
"yyyy-MM-dd"
);
ui
->
dateEdit_find_end
->
setDisplayFormat
(
"yyyy-MM-dd"
);
...
...
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