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
ec2a5c39
Commit
ec2a5c39
authored
Sep 01, 2017
by
NitefullWind
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1. 打印文件路径和名称可配置。 2. 实现重新打印。 3. 支付、退款失败时直接返回错误信息不弹窗。
parent
ea4053dc
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
83 additions
and
31 deletions
+83
-31
sbkpay/control.cpp
+9
-15
sbkpay/global.h
+5
-0
sbkpay/hostwidget.cpp
+20
-7
sbkpay/jsonfactory.h
+18
-0
sbkpay/main.cpp
+3
-2
sbkpay/rspfactory.h
+28
-7
No files found.
sbkpay/control.cpp
View file @
ec2a5c39
...
...
@@ -102,26 +102,20 @@ void Control::Start(const char *indata, char *outdata)
loop
.
exit
();
});
// QString reqtype;
// reqtype.append(_request.TransType[0]).append(_request.TransType[1]);
ReqType
reqType
=
(
ReqType
)
FMTool
::
GetJsonValue
(
_posReqJsonObj
,
JSON_KEY_REQTYPE
).
toInt
();
// _widget->ShowWithRequest(_request);
// if(reqtype.compare("40") != 0)
// {
// loop.exec();
// }else
// {
// if(reqtype.compare("40") == 0 && refundflag == false)
// loop.exec();
// }
// _widget->ShowWithRequest(_request);
_widget
->
ShowWithRequest
(
_posType
,
_posReqJsonObj
);
loop
.
exec
();
if
(
reqType
!=
refund
)
{
loop
.
exec
();
}
else
{
if
(
refundflag
==
false
)
loop
.
exec
();
}
_lock
.
lock
();
delete
_widget
;
...
...
sbkpay/global.h
View file @
ec2a5c39
...
...
@@ -10,6 +10,7 @@
#define PRINT_FILE_PATH "C:/Freemud/fmClient/Prints/"
#define PRINT_ENDDAY_FILE_NAME "EndDayPrint.txt"
#define PRINT_SHIFT_FILE_NAME "ShiftPrint.txt"
#define PRINT_AGAIN_FILE_NAME "AgainPrint.txt"
#define PRINT_FILE_NAME "print.txt"
...
...
@@ -99,6 +100,10 @@
#define CONFIG_OLTP_STATCODE "OLTP/STATCODE"
#define CONFIG_OLTP_MODE "OLTP/MODE"
#define CONFIG_OLTP_OPERATION "OLTP/OPERATION"
#define CONFIG_PRINT_PATH "PRINT/PATH"
#define CONFIG_PRINT_ENDDAY_NAME "PRINT/EDNDAYNAME"
#define CONFIG_PRINT_SHIFT_NAME "PRINT/SHIFTNAME"
#define CONFIG_PRINT_AGAIN_NAME "PRINT/AGAINNAME"
#endif // GLOBAL
sbkpay/hostwidget.cpp
View file @
ec2a5c39
...
...
@@ -374,13 +374,26 @@ void HostWidget::ShowWithRequest(POSType posType, QJsonObject requestObj)
case
refund
:
{
ShowWidget
(
ui
->
pay
);
_curr_show_widget
=
ui
->
pay
;
double
Amount
=
FMTool
::
GetJsonValue
(
requestObj
,
JSON_KEY_TRANSAMOUNT
).
toInt
()
/
100.0
;
QString
FmId
=
FMTool
::
GetJsonValue
(
requestObj
,
JSON_KEY_FMID
).
toString
();
ui
->
label_pay_title
->
setText
(
QString
::
fromLocal8Bit
(
"请扫描退款凭证号"
));
ui
->
btn_pay_exit
->
setText
(
QString
::
fromLocal8Bit
(
"取消退款"
));
ui
->
label_pay_money
->
setText
(
QString
::
fromLocal8Bit
(
"退款 ¥ %1"
).
arg
(
Amount
));
ui
->
lineEdit_pay_code
->
setText
(
FmId
);
ShowPayWidget
();
// double Amount = FMTool::GetJsonValue(requestObj, JSON_KEY_TRANSAMOUNT).toInt()/100.0;
// QString FmId = FMTool::GetJsonValue(requestObj, JSON_KEY_FMID).toString();
// ui->label_pay_title->setText(QString::fromLocal8Bit("请扫描退款凭证号"));
// ui->btn_pay_exit->setText(QString::fromLocal8Bit("取消退款"));
// ui->label_pay_money->setText(QString::fromLocal8Bit("退款 ¥ %1").arg(Amount));
// ui->lineEdit_pay_code->setText(FmId);
// ShowPayWidget();
ui
->
btn_pay_exit
->
hide
();
ui
->
label_pay_money
->
hide
();
//_refundamout = FMTool::GetString(_data.Amount, 12).toInt();
_label_pay_timer
->
start
(
60
,
QString
::
fromLocal8Bit
(
"%1 秒"
));
QStringList
list
;
list
.
append
(
FMTool
::
GetJsonValue
(
requestObj
,
JSON_KEY_FMID
).
toString
());
ui
->
label_pay_title
->
setText
(
QString
::
fromLocal8Bit
(
"支付宝退款中..."
));
emit
RequestWithType
(
refund
,
list
);
break
;
}
default
:
...
...
sbkpay/jsonfactory.h
View file @
ec2a5c39
...
...
@@ -45,6 +45,8 @@ public:
return
GetShiftJson
(
json
,
reqJson
,
list
);
case
finds
:
return
GetFindJson
(
json
,
reqJson
,
list
);
case
againprint
:
return
GetAgainPrinteJson
(
json
,
reqJson
,
list
);
default
:
json
=
reqJson
;
break
;
...
...
@@ -231,6 +233,22 @@ private:
return
true
;
}
static
bool
GetAgainPrinteJson
(
QJsonObject
&
json
,
const
QJsonObject
&
request
,
QStringList
list
)
{
if
(
!
list
.
isEmpty
()
&&
list
[
0
].
isEmpty
())
return
false
;
json
.
insert
(
JSON_KEY_VER
,
DEFAULT_JSON_VER_VALUE
);
json
.
insert
(
JSON_KEY_REQTYPE
,
JSON_REQTYPE_PRINTER
);
json
.
insert
(
JSON_KEY_PARTNERID
,
FMTool
::
GetJsonValue
(
request
,
JSON_KEY_PARTNERID
));
json
.
insert
(
JSON_KEY_STOREID
,
FMTool
::
GetJsonValue
(
request
,
JSON_KEY_STOREID
));
json
.
insert
(
JSON_KEY_STATIONID
,
FMTool
::
GetJsonValue
(
request
,
JSON_KEY_STATIONID
));
json
.
insert
(
JSON_KEY_OPERATORID
,
FMTool
::
GetJsonValue
(
request
,
JSON_KEY_OPERATORID
));
json
.
insert
(
JSON_KEY_FMID
,
list
[
0
]);
json
.
insert
(
JSON_KEY_PRINTACTION
,
QString
(
"103"
));
return
true
;
}
//查询流水
static
bool
GetFindJson
(
QJsonObject
&
json
,
const
AlipayRequest
&
request
,
QStringList
list
)
{
...
...
sbkpay/main.cpp
View file @
ec2a5c39
...
...
@@ -427,8 +427,9 @@ int main(int argc, char *argv[])
// control.Start(as, b);
// char spccIn[MAX_BUF_LEN] = "{\"fmId\":\"37941708301000003002\",\"reqType\":451,\"storeId\":\"17607\",\"stationId\":\"1\",\"partnerId\":1443,\"operatorId\":\"0123\",\"transId\":301439,\"transAmount\":1,\"partnerOrderId\":\"909911039990170830002\",\"businessDate\":\"20170508\",\"products\":[{\"pid\":\"123\",\"name\":\"中杯拿铁\",\"price\":321,\"salesType\":\"NORMAL\"}]}";
char
spccIn
[
MAX_BUF_LEN
]
=
"{
\"
reqType
\"
:452,
\"
storeId
\"
:
\"
17607
\"
,
\"
stationId
\"
:
\"
1
\"
,
\"
partnerId
\"
:1443,
\"
operatorId
\"
:
\"
0123
\"
,
\"
transId
\"
:301439,
\"
transAmount
\"
:1,
\"
partnerOrderId
\"
:
\"
1365670843098735301654
\"
,
\"
businessDate
\"
:
\"
20170830
\"
}"
;
char
spccIn
[
MAX_BUF_LEN
]
=
"{
\"
fmId
\"
:
\"
11971709011000000002
\"
,
\"
reqType
\"
:451,
\"
storeId
\"
:
\"
17607
\"
,
\"
stationId
\"
:
\"
1
\"
,
\"
partnerId
\"
:1443,
\"
operatorId
\"
:
\"
0123
\"
,
\"
transId
\"
:301439,
\"
transAmount
\"
:1,
\"
partnerOrderId
\"
:
\"
909911039990170830002
\"
,
\"
businessDate
\"
:
\"
20170508
\"
,
\"
products
\"
:[{
\"
pid
\"
:
\"
123
\"
,
\"
name
\"
:
\"
中杯拿铁
\"
,
\"
price
\"
:321,
\"
salesType
\"
:
\"
NORMAL
\"
}]}"
;
// char spccIn[MAX_BUF_LEN] = "{\"reqType\":452,\"storeId\":\"17607\",\"stationId\":\"1\",\"partnerId\":1443,\"operatorId\":\"0123\",\"transId\":301439,\"transAmount\":1,\"partnerOrderId\":\"1365670843098735011753\",\"businessDate\":\"20170830\"}";
// char spccIn[MAX_BUF_LEN] = "{\"fmId\":\"64761709011000001002\",\"reqType\":453,\"storeId\":\"17607\",\"stationId\":\"1\",\"partnerId\":1443,\"operatorId\":\"0123\",\"transId\":301439,\"transAmount\":1,\"partnerOrderId\":\"1365670843098735011754\",\"businessDate\":\"20170830\"}";
control
.
Start
(
spccIn
,
b
);
return
a
.
exec
();
...
...
sbkpay/rspfactory.h
View file @
ec2a5c39
...
...
@@ -5,6 +5,8 @@
#include "global.h"
#include "fmtool.h"
#include "QsLog.h"
#include "fmp_settings.h"
#include "tools.h"
#include <QFile>
#include <QDir>
...
...
@@ -54,6 +56,8 @@ public:
return
GetShiftResponse
(
response
,
json
);
if
(
type
==
finds
)
return
GetFindResponse
(
response
,
json
);
if
(
type
==
againprint
)
return
GetAgainPrinteResponse
(
response
,
json
);
return
false
;
}
...
...
@@ -218,7 +222,7 @@ private:
response
[
JSON_KEY_MESSAGE
]
=
json
[
JSON_KEY_MESSAGE
];
if
(
json
[
JSON_KEY_STATUSCODE
].
toInt
()
==
100
)
return
SetPinter
(
response
,
json
,
PRINT_ENDDAY_FILE
_NAME
);
return
SetPinter
(
response
,
json
,
CONFIG_PRINT_ENDDAY
_NAME
);
return
true
;
}
static
bool
GetShiftResponse
(
QJsonObject
&
response
,
const
QJsonObject
&
json
)
...
...
@@ -227,7 +231,7 @@ private:
response
[
JSON_KEY_MESSAGE
]
=
json
[
JSON_KEY_MESSAGE
];
if
(
json
[
JSON_KEY_STATUSCODE
].
toInt
()
==
100
)
return
SetPinter
(
response
,
json
,
PRINT_SHIFT_FILE
_NAME
);
return
SetPinter
(
response
,
json
,
CONFIG_PRINT_SHIFT
_NAME
);
return
true
;
}
...
...
@@ -243,6 +247,16 @@ private:
return
true
;
}
static
bool
GetAgainPrinteResponse
(
QJsonObject
&
response
,
const
QJsonObject
&
json
)
{
response
[
JSON_KEY_STATUSCODE
]
=
json
[
JSON_KEY_STATUSCODE
];
response
[
JSON_KEY_MESSAGE
]
=
json
[
JSON_KEY_MESSAGE
];
if
(
json
[
JSON_KEY_STATUSCODE
].
toInt
()
==
100
)
return
SetPinter
(
response
,
json
,
CONFIG_PRINT_AGAIN_NAME
);
return
true
;
}
static
bool
GetFindResponse
(
AlipayResponse
&
response
,
const
QJsonObject
&
json
)
{
return
false
;
...
...
@@ -329,7 +343,7 @@ private:
return
true
;
}
static
bool
SetPinter
(
QJsonObject
&
response
,
const
QJsonObject
&
json
,
QString
fileName
=
PRINT_ENDDAY_FILE
_NAME
)
static
bool
SetPinter
(
QJsonObject
&
response
,
const
QJsonObject
&
json
,
QString
configKey
=
CONFIG_PRINT_ENDDAY
_NAME
)
{
if
(
!
json
.
contains
(
JSON_KEY_EXT
)
||
!
json
[
JSON_KEY_EXT
].
isObject
())
return
false
;
...
...
@@ -337,13 +351,20 @@ private:
QJsonObject
obj
=
json
[
JSON_KEY_EXT
].
toObject
();
QString
str
=
obj
[
JSON_KEY_PRINT
].
toString
();
QDir
dir
(
PRINT_FILE_PATH
);
QString
path
;
ToolS
::
GetPath
(
path
);
FMPSettings
setting
;
path
=
setting
.
GetValue
(
CONFIG_PRINT_PATH
,
path
).
toString
();
QDir
dir
(
path
);
if
(
!
dir
.
exists
())
{
bool
isOk
=
dir
.
mkpath
(
PRINT_FILE_PATH
);
QLOG_INFO
()
<<
"Make path: "
<<
PRINT_FILE_PATH
<<
(
isOk
?
" Success."
:
" Fail."
);
bool
isOk
=
dir
.
mkpath
(
path
);
QLOG_INFO
()
<<
"Make path: "
<<
path
<<
(
isOk
?
" Success."
:
" Fail."
);
}
QString
filePath
=
PRINT_FILE_PATH
+
fileName
;
QString
printFileName
=
setting
.
GetValue
(
configKey
,
PRINT_FILE_NAME
).
toString
();
QString
filePath
=
path
+
"/"
+
printFileName
;
response
[
JSON_KEY_PRINTPATH
]
=
filePath
;
QFile
file
(
filePath
);
...
...
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