Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
takeaway
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
shuai.liu
takeaway
Commits
3ef5b009
Commit
3ef5b009
authored
Aug 30, 2018
by
刘帅
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1. 合并,是否有TCP header进行配置
2. 部分退款,打印出退款商品和数量
parent
d924bdf0
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
98 additions
and
13 deletions
+98
-13
fmTakeaway/controls/flowControl.cpp
+63
-3
fmTakeaway/controls/flowControl.h
+3
-1
fmTakeaway/detailform.cpp
+17
-1
fmTakeaway/detailform.h
+1
-1
fmTakeaway/mainwindow.cpp
+1
-1
fmTakeaway/printLib/printDocument.cpp
+7
-3
fmTakeaway/tools/configManage.h
+6
-0
takeaway_component.pro
+0
-3
No files found.
fmTakeaway/controls/flowControl.cpp
View file @
3ef5b009
...
@@ -41,7 +41,67 @@ FlowControl::FlowControl()
...
@@ -41,7 +41,67 @@ FlowControl::FlowControl()
connect
(
socket
,
&
QTcpSocket
::
readyRead
,
[
socket
,
this
]()
connect
(
socket
,
&
QTcpSocket
::
readyRead
,
[
socket
,
this
]()
{
{
QString
recvData
;
QString
recvData
;
recvData
=
QString
::
fromUtf8
(
socket
->
readAll
()).
simplified
();
if
(
ConfigManage
::
Instance
().
tcpHeader
())
{
QByteArray
byteArray
;
int
rcvedLength
=
0
;
int
rcvFlag
=
0
;
//firstly, to rcv header
int
needLength
=
sizeof
(
FMSOCKEHEADER
);
int
rlt
=
0
;
FMSOCKEHEADER
headx
;
char
*
pcRcvBufer
=
(
char
*
)(
&
headx
);
while
(
0
<
needLength
)
{
socket
->
waitForReadyRead
(
1000
);
int
length
=
socket
->
read
(
pcRcvBufer
+
rcvedLength
,
needLength
);
qDebug
()
<<
"need "
<<
needLength
;
if
(
0
<
length
)
{
needLength
-=
length
;
rcvedLength
+=
length
;
if
(
0
==
needLength
)
{
if
(
0
==
rcvFlag
)
{
//header rcved complete
rcvFlag
=
1
;
//to rcv payload
//need to check payloadLength is valid or not
needLength
=
headx
.
len
;
if
(
needLength
>
81920
||
needLength
<
1
)
{
QLOG_ERROR
()
<<
"TCP data invalid length:"
<<
needLength
;
break
;
}
byteArray
.
resize
(
headx
.
len
);
pcRcvBufer
=
byteArray
.
data
();
rcvedLength
=
0
;
continue
;
}
else
{
//payload rcved complete
rlt
=
rcvedLength
;
break
;
}
}
}
else
if
(
length
==
0
)
{
byteArray
+=
'\0'
;
break
;
}
else
{
}
}
recvData
=
QString
(
byteArray
);
}
else
{
recvData
=
QString
::
fromUtf8
(
socket
->
readAll
()).
simplified
();
}
QLOG_INFO
()
<<
QString
(
"收到数据: %1"
).
arg
(
recvData
);
QLOG_INFO
()
<<
QString
(
"收到数据: %1"
).
arg
(
recvData
);
QJsonObject
recvObj
;
QJsonObject
recvObj
;
QJsonParseError
jsonError
;
QJsonParseError
jsonError
;
...
@@ -446,10 +506,10 @@ void FlowControl::requestPartialRefundDetail(QString order_id)
...
@@ -446,10 +506,10 @@ void FlowControl::requestPartialRefundDetail(QString order_id)
{
{
QByteArray
appendData
=
DataManage
::
getRefundDetail
(
m_token
,
order_id
);
QByteArray
appendData
=
DataManage
::
getRefundDetail
(
m_token
,
order_id
);
m_http
.
Post
(
appendData
m_http
.
Post
(
appendData
,[
this
](
const
QByteArray
&
data
)
,[
this
,
order_id
](
const
QByteArray
&
data
)
{
{
QLOG_INFO
()
<<
QString
(
"退款详情: %1"
).
arg
(
QString
(
data
).
simplified
());
QLOG_INFO
()
<<
QString
(
"退款详情: %1"
).
arg
(
QString
(
data
).
simplified
());
emit
partialRefundDetail
(
data
);
emit
partialRefundDetail
(
order_id
,
data
);
}
}
,[
this
](
const
QNetworkReply
::
NetworkError
&
error
)
,[
this
](
const
QNetworkReply
::
NetworkError
&
error
)
{
{
...
...
fmTakeaway/controls/flowControl.h
View file @
3ef5b009
...
@@ -69,6 +69,8 @@ private:
...
@@ -69,6 +69,8 @@ private:
// 用于和服务端通信的本地数据
// 用于和服务端通信的本地数据
QString
m_token
;
QString
m_token
;
QString
m_timestamp
;
QString
m_timestamp
;
public
:
// 用于存储订单信息<订单ID, 订单对象>
// 用于存储订单信息<订单ID, 订单对象>
QMap
<
QString
,
OrderObject
*>
m_ordersMap
;
QMap
<
QString
,
OrderObject
*>
m_ordersMap
;
...
@@ -167,7 +169,7 @@ signals:
...
@@ -167,7 +169,7 @@ signals:
* 参数:[1]获取退款详情接口返回
* 参数:[1]获取退款详情接口返回
* 返回:NULL
* 返回:NULL
* */
* */
void
partialRefundDetail
(
QByteArray
detail
);
void
partialRefundDetail
(
Q
String
order_id
,
Q
ByteArray
detail
);
};
};
#endif // FLOWCONTROL_H
#endif // FLOWCONTROL_H
fmTakeaway/detailform.cpp
View file @
3ef5b009
...
@@ -211,7 +211,7 @@ void DetailForm::on_detail_btnReprint_clicked()
...
@@ -211,7 +211,7 @@ void DetailForm::on_detail_btnReprint_clicked()
* 参数:[1]获取退款详情接口返回
* 参数:[1]获取退款详情接口返回
* 返回:NULL
* 返回:NULL
* */
* */
void
DetailForm
::
partialRefundDetail
(
QByteArray
detail
)
void
DetailForm
::
partialRefundDetail
(
Q
String
order_id
,
Q
ByteArray
detail
)
{
{
QJsonParseError
json_error
;
QJsonParseError
json_error
;
QJsonDocument
doc
=
QJsonDocument
::
fromJson
(
detail
,
&
json_error
);
QJsonDocument
doc
=
QJsonDocument
::
fromJson
(
detail
,
&
json_error
);
...
@@ -227,6 +227,22 @@ void DetailForm::partialRefundDetail(QByteArray detail)
...
@@ -227,6 +227,22 @@ void DetailForm::partialRefundDetail(QByteArray detail)
QVariantMap
detailMap
=
doc
.
toVariant
().
toMap
();
QVariantMap
detailMap
=
doc
.
toVariant
().
toMap
();
QVariantMap
infoMap
=
detailMap
[
"refund_info"
].
toMap
();
QVariantMap
infoMap
=
detailMap
[
"refund_info"
].
toMap
();
QStringList
list
;
QMap
<
QString
,
int
>
productDetail
;
foreach
(
QVariant
variant
,
infoMap
[
"refund_items"
].
toList
())
{
QVariantMap
product
=
variant
.
toMap
();
list
<<
product
[
"name"
].
toString
();
productDetail
[
product
[
"name"
].
toString
()]
=
product
[
"product_amount"
].
toInt
();
}
OrderObject
*
orderObj
=
FlowControl
::
Instance
().
m_ordersMap
.
value
(
order_id
);
foreach
(
DishObject
*
item
,
orderObj
->
products
)
{
if
(
list
.
contains
(
item
->
name
))
item
->
name
=
item
->
name
+
QString
(
"( 退x%1 )"
).
arg
(
productDetail
[
item
->
name
]);
}
QTreeWidgetItem
*
partialProducts
=
new
QTreeWidgetItem
(
QStringList
()
<<
QString
(
"退款商品"
));
QTreeWidgetItem
*
partialProducts
=
new
QTreeWidgetItem
(
QStringList
()
<<
QString
(
"退款商品"
));
ui
->
detail_tree
->
addTopLevelItem
(
partialProducts
);
ui
->
detail_tree
->
addTopLevelItem
(
partialProducts
);
...
...
fmTakeaway/detailform.h
View file @
3ef5b009
...
@@ -36,7 +36,7 @@ public slots:
...
@@ -36,7 +36,7 @@ public slots:
* 参数:[1]获取退款详情接口返回
* 参数:[1]获取退款详情接口返回
* 返回:NULL
* 返回:NULL
* */
* */
void
partialRefundDetail
(
QByteArray
detail
);
void
partialRefundDetail
(
Q
String
order_id
,
Q
ByteArray
detail
);
private
:
private
:
Ui
::
DetailForm
*
ui
;
Ui
::
DetailForm
*
ui
;
...
...
fmTakeaway/mainwindow.cpp
View file @
3ef5b009
...
@@ -95,6 +95,7 @@ MainWindow::MainWindow(QWidget *parent) :
...
@@ -95,6 +95,7 @@ MainWindow::MainWindow(QWidget *parent) :
this
->
ui
->
main_btnSPGL
->
setEnabled
(
true
);
this
->
ui
->
main_btnSPGL
->
setEnabled
(
true
);
});
});
FlowControl
::
Instance
().
_onGetMenu
();
FlowControl
::
Instance
().
_onGetMenu
();
on_main_btnHide_clicked
();
});
});
connect
(
&
FlowControl
::
Instance
(),
&
FlowControl
::
showDailyForm
,
[
this
](
QList
<
DailyInfo
>
infos
)
connect
(
&
FlowControl
::
Instance
(),
&
FlowControl
::
showDailyForm
,
[
this
](
QList
<
DailyInfo
>
infos
)
...
@@ -188,7 +189,6 @@ MainWindow::MainWindow(QWidget *parent) :
...
@@ -188,7 +189,6 @@ MainWindow::MainWindow(QWidget *parent) :
ui
->
main_btnDCL
->
click
();
ui
->
main_btnDCL
->
click
();
connect
(
m_detailForm
,
&
DetailForm
::
requestDetail
,
&
FlowControl
::
Instance
(),
&
FlowControl
::
requestPartialRefundDetail
);
connect
(
m_detailForm
,
&
DetailForm
::
requestDetail
,
&
FlowControl
::
Instance
(),
&
FlowControl
::
requestPartialRefundDetail
);
connect
(
&
FlowControl
::
Instance
(),
&
FlowControl
::
partialRefundDetail
,
m_detailForm
,
&
DetailForm
::
partialRefundDetail
);
connect
(
&
FlowControl
::
Instance
(),
&
FlowControl
::
partialRefundDetail
,
m_detailForm
,
&
DetailForm
::
partialRefundDetail
);
}
}
MainWindow
::~
MainWindow
()
MainWindow
::~
MainWindow
()
...
...
fmTakeaway/printLib/printDocument.cpp
View file @
3ef5b009
...
@@ -34,12 +34,16 @@ PrintDocument PrintDocument::ParseToDocument(const QByteArray &content, bool res
...
@@ -34,12 +34,16 @@ PrintDocument PrintDocument::ParseToDocument(const QByteArray &content, bool res
int
indexForword
=
0
,
indexBack
=
0
;
int
indexForword
=
0
,
indexBack
=
0
;
while
(
indexBack
!=
(
content
.
length
()
-
1
)
&&
indexBack
!=-
1
&&
indexForword
!=-
1
)
while
(
indexBack
!=
(
content
.
length
()
-
1
)
&&
indexBack
!=-
1
&&
indexForword
!=-
1
)
{
{
indexForword
=
content
.
indexOf
(
'<'
,
0
);
indexForword
=
content
.
indexOf
(
'<'
,
indexBack
);
indexBack
=
content
.
indexOf
(
'>'
,
0
);
indexBack
=
content
.
indexOf
(
'>'
,
indexForword
);
if
(
indexBack
!=-
1
&&
indexForword
!=-
1
)
if
(
indexBack
!=-
1
&&
indexForword
!=-
1
)
{
{
QString
printLine
=
content
.
mid
(
indexForword
+
1
,
indexBack
-
indexForword
-
2
);
QString
printLine
=
content
.
mid
(
indexForword
+
1
,
indexBack
-
indexForword
-
1
);
LineNode
*
node
=
new
LineNode
(
printLine
,
&
doc
);
LineNode
*
node
=
new
LineNode
(
printLine
,
&
doc
);
if
(
!
node
->
nodeName
.
compare
(
"product"
))
{
doc
.
_productNodeIndexList
.
append
(
doc
.
_nodeList
.
size
());
}
doc
.
_nodeList
.
append
(
node
);
doc
.
_nodeList
.
append
(
node
);
}
}
else
else
...
...
fmTakeaway/tools/configManage.h
View file @
3ef5b009
...
@@ -73,6 +73,12 @@ public:
...
@@ -73,6 +73,12 @@ public:
return
m_clientIni
->
value
(
"net/tcpListenPort"
).
toInt
();
return
m_clientIni
->
value
(
"net/tcpListenPort"
).
toInt
();
}
}
// TCP 通信是否添加包头
inline
bool
tcpHeader
()
{
return
m_clientIni
->
value
(
"net/tcpHeader"
).
toBool
();
}
/* 功能:获取非码服务器地址
/* 功能:获取非码服务器地址
* 参数:NULL
* 参数:NULL
* 返回:服务器地址
* 返回:服务器地址
...
...
takeaway_component.pro
View file @
3ef5b009
TEMPLATE
=
subdirs
TEMPLATE
=
subdirs
SUBDIRS
+=
\
SUBDIRS
+=
\
component
SUBDIRS
+=
\
fmTakeaway
fmTakeaway
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