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
45a2a22f
Commit
45a2a22f
authored
Aug 28, 2017
by
NitefullWind
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'simphony' into spcc
# Conflicts: # sbkpay/control.h # sbkpay/hostwidget.cpp # sbkpay/main.cpp
parents
f70e4984
92e6a794
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
132 additions
and
53 deletions
+132
-53
sbkpay/control.cpp
+53
-15
sbkpay/control.h
+2
-0
sbkpay/hostwidget.cpp
+59
-35
sbkpay/hostwidget.h
+2
-1
sbkpay/main.cpp
+2
-1
sbkpay/requestmodel.h
+14
-1
No files found.
sbkpay/control.cpp
View file @
45a2a22f
...
...
@@ -98,20 +98,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
);
...
...
@@ -145,7 +132,7 @@ void Control::Start(const char *indata, char *outdata)
// }
// _widget->ShowWithRequest(_request);
_widget
->
ShowWithRequest
(
_posReqJsonObj
);
_widget
->
ShowWithRequest
(
_pos
Type
,
_pos
ReqJsonObj
);
loop
.
exec
();
...
...
@@ -166,6 +153,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);
...
...
@@ -635,7 +650,30 @@ void Control::Request(ReqType type, QStringList list)
QLOG_INFO
()
<<
"Sign str: "
<<
signStr
;
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 @
45a2a22f
...
...
@@ -57,6 +57,8 @@ private:
QString
GetMacString
(
bool
isSign
=
true
);
void
InitPOSReqJsonObj
(
const
char
*
indata
);
public
slots
:
void
RequestWithType
(
ReqType
type
,
QStringList
list
);
...
...
sbkpay/hostwidget.cpp
View file @
45a2a22f
...
...
@@ -282,35 +282,37 @@ 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
);
...
...
@@ -319,8 +321,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
;
...
...
@@ -630,7 +633,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
;
...
...
@@ -639,12 +656,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 @
45a2a22f
...
...
@@ -26,7 +26,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
());
...
...
@@ -114,6 +114,7 @@ private:
bool
_runing
;
POSType
_posType
;
ReqType
_type
;
};
...
...
sbkpay/main.cpp
View file @
45a2a22f
...
...
@@ -60,6 +60,7 @@ static bool CopyApiDll(QString &errorString)
return
true
;
}
BOOL
WINAPI
DllMain
(
HINSTANCE
hInstance
,
DWORD
dwReason
,
LPVOID
/*lpvReserved*/
)
{
static
bool
ownApplication
=
FALSE
;
...
...
@@ -414,7 +415,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 @
45a2a22f
...
...
@@ -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