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
a1552011
Commit
a1552011
authored
Aug 21, 2017
by
NitefullWind
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1. 对接日结单打印、交班单打印功能。 2. 修复乱码问题。
parent
566f0949
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
163 additions
and
19 deletions
+163
-19
sbkpay/control.cpp
+8
-7
sbkpay/global.h
+7
-0
sbkpay/hostwidget.cpp
+14
-0
sbkpay/hostwidget.h
+2
-0
sbkpay/hostwidget.ui
+42
-0
sbkpay/jsonfactory.h
+28
-0
sbkpay/main.cpp
+1
-1
sbkpay/requestmodel.h
+1
-0
sbkpay/rspfactory.h
+52
-0
sbkpay/sbkpay.pro
+1
-1
sbkpay/sbkpay.pro.user
+7
-10
No files found.
sbkpay/control.cpp
View file @
a1552011
...
...
@@ -54,7 +54,7 @@ void Control::Start(const char *indata, char *outdata)
if
(
_widget
==
NULL
)
_widget
=
new
HostWidget
();
QLOG_INFO
()
<<
"In data: "
<<
QString
::
from
Utf8
(
indata
);
QLOG_INFO
()
<<
"In data: "
<<
QString
::
from
Local8Bit
(
indata
);
QJsonParseError
parseError
;
QJsonDocument
inDataDoc
=
QJsonDocument
::
fromJson
(
QString
::
fromUtf8
(
indata
).
toUtf8
(),
&
parseError
);
...
...
@@ -107,10 +107,13 @@ void Control::Start(const char *indata, char *outdata)
// memcpy(outdata, (char *)(&_response), sizeof(struct AlipayResponse));
// outdata[sizeof(struct AlipayResponse)] = 0;
QByteArray
responseArray
=
QJsonDocument
(
_responseJsonObj
).
toJson
(
QJsonDocument
::
Compact
);
memcpy
(
outdata
,
responseArray
.
data
(),
responseArray
.
size
());
char
*
rspData
=
responseArray
.
data
();
char
tmpbuf
[
MAX_BUF_LEN
]
=
{
0
};
int
len
=
FMTool
::
UTF8ToGBK
((
unsigned
char
*
)
rspData
,
(
unsigned
char
*
)
tmpbuf
,
MAX_PRINT_LEN
);
memcpy
((
char
*
)
outdata
,
tmpbuf
,
len
);
QLOG_INFO
()
<<
"return data to pos : "
<<
outdata
;
QLOG_INFO
()
<<
"return data to pos : "
<<
QString
::
fromLocal8Bit
(
outdata
)
;
}
void
Control
::
SetResPonseWithMessage
(
QString
code
,
const
QString
&
message
)
...
...
@@ -247,7 +250,6 @@ bool Control::SendMessageToSBKAPI(const QJsonObject &json, QByteArray &outdata,
strcpy
(
in
,
reqXmlStr
.
toUtf8
().
data
());
QLOG_INFO
()
<<
"Request StarbucksAPI XML data: "
<<
in
;
#define SBKTEST
#ifdef SBKTEST
int
result
=
skbSend
(
in
,
guid
,
out
,
errMsg
,
mode
);
...
...
@@ -260,15 +262,14 @@ bool Control::SendMessageToSBKAPI(const QJsonObject &json, QByteArray &outdata,
int
result
=
0
;
#endif //! End def SBKTEST
QLOG_DEBUG
()
<<
"StarbucksAPI return to UTF-8: "
<<
QString
::
fromUtf8
(
out
);
QLOG_DEBUG
()
<<
"StarbucksAPI return to GBK: "
<<
QString
::
fromLocal8Bit
(
out
);
QString
outXMlString
=
QString
::
from
Utf8
(
out
);
QString
outXMlString
=
QString
::
from
Local8Bit
(
out
);
QLOG_INFO
()
<<
"OLTP return: "
<<
result
<<
" data: "
<<
outXMlString
;
if
(
result
!=
0
)
{
error
=
"OLTP return error:
\n
"
+
QString
::
from
Utf8
(
errMsg
);
error
=
"OLTP return error:
\n
"
+
QString
::
from
Local8Bit
(
errMsg
);
QLOG_ERROR
()
<<
error
;
return
QByteArray
();
}
else
{
...
...
sbkpay/global.h
View file @
a1552011
...
...
@@ -5,6 +5,10 @@
#define MAX_CHILED_LEN 256
#define MAX_PRINT_LEN 4096
#define PRINT_FILE_PATH "C:/Freemud/fmClient/Prints/"
#define PRINT_ENDDAY_FILE_NAME "EndDayPrint.txt"
#define PRINT_SHIFT_FILE_NAME "ShiftPrint.txt"
#define PRINT_FILE_NAME "print.txt"
#define USERCONFIG_NAME "config.ini"
...
...
@@ -25,6 +29,8 @@
#define JSON_KEY_TRANSAMOUNT "transAmount"
#define JSON_KEY_REFUNDAMOUT "refundAmount"
#define JSON_KEY_ENDTIME "endTime"
#define JSON_KEY_REFUNDID "refundId"
#define JSON_KEY_PRINTACTION "printAction"
//response
#define JSON_KEY_MESSAGE "message"
...
...
@@ -32,6 +38,7 @@
#define JSON_KEY_FMID "fmId"
#define JSON_KEY_EXT "ext"
#define JSON_KEY_PRINT "print"
#define JSON_KEY_PRINTPATH "path"
#define JSON_KEY_UNAMOUNT "undiscountAmount"
#define JSON_KEY_PARTORDERID "partnerOrderId"
...
...
sbkpay/hostwidget.cpp
View file @
a1552011
...
...
@@ -299,6 +299,12 @@ void HostWidget::ShowWiteMGS(ReqType type, bool flag, QString message)
return
;
}
if
(
type
==
shift
)
{
emit
Exits
();
return
;
}
}
void
HostWidget
::
on_btn_mananger_register_clicked
()
...
...
@@ -373,3 +379,11 @@ void HostWidget::on_btn_sign_sign_clicked()
ui
->
btn_sign_sign
->
hide
();
emit
RequestWithType
(
sign
,
list
);
}
void
HostWidget
::
on_btn_mananger_print_shift_clicked
()
{
QStringList
list
;
this
->
hide
();
emit
RequestWithType
(
shift
,
list
);
}
sbkpay/hostwidget.h
View file @
a1552011
...
...
@@ -59,6 +59,8 @@ private slots:
void
on_TimeOut
();
void
on_btn_mananger_print_shift_clicked
();
private
:
void
ShowWidget
(
QWidget
*
showwidget
);
...
...
sbkpay/hostwidget.ui
View file @
a1552011
...
...
@@ -228,6 +228,48 @@
</widget>
</item>
<item>
<spacer
name=
"horizontalSpacer_31"
>
<property
name=
"orientation"
>
<enum>
Qt::Horizontal
</enum>
</property>
<property
name=
"sizeHint"
stdset=
"0"
>
<size>
<width>
40
</width>
<height>
20
</height>
</size>
</property>
</spacer>
</item>
<item>
<widget
class=
"QPushButton"
name=
"btn_mananger_print_shift"
>
<property
name=
"minimumSize"
>
<size>
<width>
90
</width>
<height>
90
</height>
</size>
</property>
<property
name=
"maximumSize"
>
<size>
<width>
90
</width>
<height>
89
</height>
</size>
</property>
<property
name=
"styleSheet"
>
<string
notr=
"true"
>
#btn_mananger_print_shift
{
border:0px;
border-radius:6px;
background-color: rgb(0, 179, 238);
font: 75 18px
"
Microsoft YaHei UI Light
"
;
color: rgb(255, 255, 255);
}
</string>
</property>
<property
name=
"text"
>
<string>
打印交班单
</string>
</property>
</widget>
</item>
<item>
<spacer
name=
"horizontalSpacer_5"
>
<property
name=
"orientation"
>
<enum>
Qt::Horizontal
</enum>
...
...
sbkpay/jsonfactory.h
View file @
a1552011
...
...
@@ -9,6 +9,7 @@
#include <QStringList>
#include <QJsonParseError>
#include <QJsonDocument>
#include <QDateTime>
//接受pos的请求转化为json
class
JsonFactory
...
...
@@ -38,6 +39,10 @@ public:
return
GetPayJson
(
json
,
reqJson
,
list
);
case
refund
:
return
GetRefundJosn
(
json
,
reqJson
,
list
);
case
endday
:
return
GetEnddayJson
(
json
,
reqJson
,
list
);
case
shift
:
return
GetShiftJson
(
json
,
reqJson
,
list
);
default
:
json
=
reqJson
;
break
;
...
...
@@ -164,6 +169,9 @@ private:
return
false
;
json
=
reqJson
;
json
.
insert
(
JSON_KEY_FMID
,
list
[
0
]);
json
[
JSON_KEY_REFUNDAMOUT
]
=
reqJson
[
JSON_KEY_TRANSAMOUNT
];
json
[
JSON_KEY_REFUNDID
]
=
reqJson
[
JSON_KEY_TRANSID
];
json
.
remove
(
JSON_KEY_TRANSAMOUNT
);
return
true
;
}
...
...
@@ -180,6 +188,26 @@ private:
return
true
;
}
static
bool
GetEnddayJson
(
QJsonObject
&
json
,
const
QJsonObject
&
request
,
QStringList
list
)
{
Q_UNUSED
(
list
)
json
=
request
;
json
[
JSON_KEY_VER
]
=
DEFAULT_JSON_VER_VALUE
;
json
[
JSON_KEY_REQTYPE
]
=
JSON_REQTYPE_ENDDAY
;
json
[
JSON_KEY_ENDTIME
]
=
QDateTime
::
currentDateTime
().
toString
(
"yyyyMMddhhmmss"
);
json
[
JSON_KEY_PRINTACTION
]
=
"101"
;
return
true
;
}
static
bool
GetShiftJson
(
QJsonObject
&
json
,
const
QJsonObject
&
request
,
QStringList
list
)
{
Q_UNUSED
(
list
)
json
=
request
;
json
[
JSON_KEY_VER
]
=
DEFAULT_JSON_VER_VALUE
;
json
[
JSON_KEY_REQTYPE
]
=
JSON_REQTYPE_ENDDAY
;
json
[
JSON_KEY_ENDTIME
]
=
QDateTime
::
currentDateTime
().
toString
(
"yyyyMMddhhmmss"
);
json
[
JSON_KEY_PRINTACTION
]
=
"102"
;
return
true
;
}
//重打小票
static
bool
GetAgainPrinteJson
(
QJsonObject
&
json
,
const
AlipayRequest
&
request
,
QStringList
list
)
{
...
...
sbkpay/main.cpp
View file @
a1552011
...
...
@@ -288,7 +288,7 @@ int main(int argc, char *argv[])
// control.Start(as, b);
char
spccIn
[
MAX_BUF_LEN
]
=
"{
\"
fmId
\"
:
\"
0123456789012345678
\"
,
\"
reqType
\"
:35
3
,
\"
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
\"
:35
1
,
\"
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 @
a1552011
...
...
@@ -7,6 +7,7 @@ typedef enum
pay
=
30
,
refund
=
40
,
endday
,
shift
,
againprint
,
find
=
80
,
sign
=
90
,
...
...
sbkpay/rspfactory.h
View file @
a1552011
...
...
@@ -46,6 +46,10 @@ public:
return
GetPayResponse
(
response
,
json
);
if
(
type
==
refund
)
return
GetRefundResponse
(
response
,
json
);
if
(
type
==
endday
)
return
GetEndDayResponse
(
response
,
json
);
if
(
type
==
shift
)
return
GetShiftResponse
(
response
,
json
);
return
false
;
}
...
...
@@ -138,6 +142,25 @@ private:
return
true
;
}
static
bool
GetEndDayResponse
(
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
,
PRINT_ENDDAY_FILE_NAME
);
return
true
;
}
static
bool
GetShiftResponse
(
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
,
PRINT_SHIFT_FILE_NAME
);
return
true
;
}
static
bool
GetAgainPrinteResponse
(
AlipayResponse
&
response
,
const
QJsonObject
&
json
)
{
return
false
;
...
...
@@ -181,6 +204,35 @@ private:
return
true
;
}
static
bool
SetPinter
(
QJsonObject
&
response
,
const
QJsonObject
&
json
,
QString
fileName
=
PRINT_ENDDAY_FILE_NAME
)
{
if
(
!
json
.
contains
(
JSON_KEY_EXT
)
||
!
json
[
JSON_KEY_EXT
].
isObject
())
return
false
;
QJsonObject
obj
=
json
[
JSON_KEY_EXT
].
toObject
();
QString
str
=
obj
[
JSON_KEY_PRINT
].
toString
();
QString
filePath
=
PRINT_FILE_PATH
+
fileName
;
response
[
JSON_KEY_PRINTPATH
]
=
filePath
;
QFile
file
(
filePath
);
file
.
open
(
QFile
::
WriteOnly
);
if
(
!
file
.
isOpen
())
return
false
;
char
buf
[
MAX_PRINT_LEN
]
=
{
0
};
FMTool
::
SetString
(
buf
,
str
.
toUtf8
().
length
(),
str
);
file
.
write
(
buf
);
file
.
flush
();
file
.
close
();
return
true
;
}
};
#endif // RSPFACTORY
...
...
sbkpay/sbkpay.pro
View file @
a1552011
...
...
@@ -15,7 +15,7 @@ include("./QsLog/QsLog.pri")
CONFIG
+=
C
++
11
#CONFIG += SBKTEST
#
CONFIG += SBKDLL
CONFIG
+=
SBKDLL
include
(
$$
PWD
/
qtwinmigrate
/
src
/
qtwinmigrate
.
pri
)
...
...
sbkpay/sbkpay.pro.user
View file @
a1552011
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.3.1, 2017-08-
19T15:59:53
. -->
<!-- Written by QtCreator 4.3.1, 2017-08-
20T19:33:06
. -->
<qtcreator>
<data>
<variable>
EnvironmentId
</variable>
...
...
@@ -62,7 +62,7 @@
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.DefaultDisplayName"
>
Qt5.5.1 MSVC2010
</value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.DisplayName"
>
Qt5.5.1 MSVC2010
</value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.Id"
>
{373b91dc-3ee0-4b8c-ab5f-13bc6628cb59}
</value>
<value
type=
"int"
key=
"ProjectExplorer.Target.ActiveBuildConfiguration"
>
0
</value>
<value
type=
"int"
key=
"ProjectExplorer.Target.ActiveBuildConfiguration"
>
1
</value>
<value
type=
"int"
key=
"ProjectExplorer.Target.ActiveDeployConfiguration"
>
0
</value>
<value
type=
"int"
key=
"ProjectExplorer.Target.ActiveRunConfiguration"
>
0
</value>
<valuemap
type=
"QVariantMap"
key=
"ProjectExplorer.Target.BuildConfiguration.0"
>
...
...
@@ -284,15 +284,12 @@
</valuelist>
<value
type=
"int"
key=
"PE.EnvironmentAspect.Base"
>
2
</value>
<valuelist
type=
"QVariantList"
key=
"PE.EnvironmentAspect.Changes"
/>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.DefaultDisplayName"
>
sbkpay
</value>
<value
type=
"QString"
key=
"ProjectExplorer.CustomExecutableRunConfiguration.Arguments"
></value>
<value
type=
"QString"
key=
"ProjectExplorer.CustomExecutableRunConfiguration.Executable"
></value>
<value
type=
"QString"
key=
"ProjectExplorer.CustomExecutableRunConfiguration.WorkingDirectory"
>
%{buildDir}
</value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.DefaultDisplayName"
>
Custom Executable
</value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.DisplayName"
></value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.Id"
>
Qt4ProjectManager.Qt4RunConfiguration:E:/Qt/sbkpay/sbkpay/sbkpay.pro
</value>
<value
type=
"bool"
key=
"QmakeProjectManager.QmakeRunConfiguration.UseLibrarySearchPath"
>
true
</value>
<value
type=
"QString"
key=
"Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"
></value>
<value
type=
"QString"
key=
"Qt4ProjectManager.Qt4RunConfiguration.ProFile"
>
sbkpay.pro
</value>
<value
type=
"bool"
key=
"Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix"
>
false
</value>
<value
type=
"QString"
key=
"Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"
></value>
<value
type=
"QString"
key=
"Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory.default"
>
E:/Qt/sbkpay/build-sbkpay-Qt5_5_1_MSVC2010-Debug
</value>
<value
type=
"QString"
key=
"ProjectExplorer.ProjectConfiguration.Id"
>
ProjectExplorer.CustomExecutableRunConfiguration
</value>
<value
type=
"uint"
key=
"RunConfiguration.QmlDebugServerPort"
>
3768
</value>
<value
type=
"bool"
key=
"RunConfiguration.UseCppDebugger"
>
false
</value>
<value
type=
"bool"
key=
"RunConfiguration.UseCppDebuggerAuto"
>
true
</value>
...
...
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