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
154a1ec4
Commit
154a1ec4
authored
Sep 03, 2021
by
shuai.liu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加获取平台渠道接口
parent
f7bcafcd
Pipeline
#36748
failed with stage
in 20 seconds
Changes
4
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
56 additions
and
15 deletions
+56
-15
fmTakeaway/controls/flowControl.cpp
+46
-15
fmTakeaway/controls/flowControl.h
+1
-0
fmTakeaway/tools/dataManage.cpp
+8
-0
fmTakeaway/tools/dataManage.h
+1
-0
No files found.
fmTakeaway/controls/flowControl.cpp
View file @
154a1ec4
...
@@ -415,14 +415,41 @@ void FlowControl::_onGetCode()
...
@@ -415,14 +415,41 @@ void FlowControl::_onGetCode()
void
FlowControl
::
_onGetMenu
()
void
FlowControl
::
_onGetMenu
()
{
{
QByteArray
request
=
DataManage
::
getMenuData
(
m_token
);
QByteArray
request
=
DataManage
::
getChannels
(
m_token
);
m_http
.
Post
(
request
QByteArray
channelReply
;
,[
this
](
const
QByteArray
&
data
)
QStringList
channelList
;
QString
defaultChannel
(
"eleme2"
);
m_http
.
Post
(
request
,
channelReply
,
10000
);
QLOG_INFO
()
<<
QString
(
"门店平台列表: %1"
).
arg
(
QString
(
channelReply
).
simplified
());
if
(
channelReply
.
isEmpty
())
{
{
QLOG_INFO
()
<<
QString
(
"获取菜单返回数据: %1"
).
arg
(
QString
(
data
).
simplified
());
QLOG_ERROR
()
<<
QString
(
"门店平台列表接口调用失败,使用默认渠道 %1"
).
arg
(
defaultChannel
);
QJsonObject
recvObj
=
QJsonDocument
::
fromJson
(
data
).
object
();
channelList
.
push_back
(
defaultChannel
);
}
else
{
QJsonObject
recvObj
=
QJsonDocument
::
fromJson
(
channelReply
).
object
();
if
(
recvObj
[
"statusCode"
].
toInt
()
==
100
)
if
(
recvObj
[
"statusCode"
].
toInt
()
==
100
)
{
{
for
(
auto
item
:
recvObj
[
"channels"
].
toArray
())
{
QJsonObject
channelObj
=
item
.
toObject
();
QString
code
=
channelObj
[
"code"
].
toString
();
channelList
.
push_back
(
code
);
}
}
else
{
QLOG_ERROR
()
<<
QString
(
"门店平台列表接口返回错误: %1,使用默认渠道 %2"
).
arg
(
recvObj
[
"statusCode"
].
toInt
()).
arg
(
defaultChannel
);
channelList
.
push_back
(
defaultChannel
);
}
}
for
(
auto
item
:
channelList
)
{
QByteArray
menuReply
;
if
(
getChannelMenu
(
item
,
menuReply
))
{
QTcpSocket
*
socket
=
new
QTcpSocket
();
QTcpSocket
*
socket
=
new
QTcpSocket
();
socket
->
connectToHost
(
"127.0.0.1"
,
34956
);
socket
->
connectToHost
(
"127.0.0.1"
,
34956
);
if
(
!
socket
->
waitForConnected
(
LOCAL_SOCKET_TIMEOUT
))
if
(
!
socket
->
waitForConnected
(
LOCAL_SOCKET_TIMEOUT
))
...
@@ -430,22 +457,26 @@ void FlowControl::_onGetMenu()
...
@@ -430,22 +457,26 @@ void FlowControl::_onGetMenu()
QLOG_ERROR
()
<<
"connect takeaway component failed!"
;
QLOG_ERROR
()
<<
"connect takeaway component failed!"
;
return
;
return
;
}
}
QByteArray
byteArray
=
QJsonDocument
(
recvObj
).
toJson
(
QJsonDocument
::
Compact
);
sendTcpData
(
socket
,
menuReply
);
sendTcpData
(
socket
,
byteArray
);
socket
->
disconnectFromHost
();
socket
->
disconnectFromHost
();
if
(
socket
->
state
()
==
QAbstractSocket
::
UnconnectedState
||
if
(
socket
->
state
()
==
QAbstractSocket
::
UnconnectedState
||
socket
->
waitForDisconnected
(
1000
))
socket
->
waitForDisconnected
(
1000
))
delete
socket
;
delete
socket
;
}
else
break
;
{
QLOG_ERROR
()
<<
QString
(
"菜单接口返回错误: %1"
).
arg
(
recvObj
[
"msg"
].
toString
());
}
}
}
,[
this
](
const
QNetworkReply
::
NetworkError
&
error
)
{
QLOG_ERROR
()
<<
QString
(
"获取菜单失败: %1"
).
arg
(
error
);
}
}
);
}
bool
FlowControl
::
getChannelMenu
(
QString
channel
,
QByteArray
&
menuReply
)
{
QByteArray
request
=
DataManage
::
getMenuData
(
m_token
,
channel
);
m_http
.
Post
(
request
,
menuReply
,
10000
);
QLOG_INFO
()
<<
QString
(
"%1获取菜单返回数据: %2"
).
arg
(
channel
).
arg
(
QString
(
menuReply
).
simplified
());
QJsonObject
recvObj
=
QJsonDocument
::
fromJson
(
menuReply
).
object
();
if
(
recvObj
[
"statusCode"
].
toInt
()
==
100
&&
!
recvObj
[
"categories"
].
toArray
().
isEmpty
())
return
true
;
else
return
false
;
}
}
//TODO 转发组件请求
//TODO 转发组件请求
...
...
fmTakeaway/controls/flowControl.h
View file @
154a1ec4
...
@@ -80,6 +80,7 @@ public slots:
...
@@ -80,6 +80,7 @@ public slots:
* 返回:NULL
* 返回:NULL
* */
* */
void
_onGetMenu
();
void
_onGetMenu
();
bool
getChannelMenu
(
QString
channel
,
QByteArray
&
menuReply
);
private
slots
:
private
slots
:
/* 功能:登录
/* 功能:登录
...
...
fmTakeaway/tools/dataManage.cpp
View file @
154a1ec4
...
@@ -165,6 +165,14 @@ QByteArray DataManage::getMenuData(const QString &token)
...
@@ -165,6 +165,14 @@ QByteArray DataManage::getMenuData(const QString &token)
return
QJsonDocument
(
json
).
toJson
().
simplified
();
return
QJsonDocument
(
json
).
toJson
().
simplified
();
}
}
QByteArray
DataManage
::
getChannels
(
const
QString
&
token
)
{
QJsonObject
json
;
json
.
insert
(
"reqtype"
,
28
);
json
.
insert
(
"token"
,
token
);
return
QJsonDocument
(
json
).
toJson
().
simplified
();
}
QByteArray
DataManage
::
getRefundDetail
(
const
QString
&
token
,
const
QString
&
orderId
)
QByteArray
DataManage
::
getRefundDetail
(
const
QString
&
token
,
const
QString
&
orderId
)
{
{
QJsonObject
json
,
order
;
QJsonObject
json
,
order
;
...
...
fmTakeaway/tools/dataManage.h
View file @
154a1ec4
...
@@ -24,6 +24,7 @@ public:
...
@@ -24,6 +24,7 @@ public:
static
QByteArray
getMenuData
(
const
QString
&
token
,
const
QString
&
channel
);
static
QByteArray
getMenuData
(
const
QString
&
token
,
const
QString
&
channel
);
static
QByteArray
getCodeData
(
const
QString
&
token
);
static
QByteArray
getCodeData
(
const
QString
&
token
);
static
QByteArray
getMenuData
(
const
QString
&
token
);
static
QByteArray
getMenuData
(
const
QString
&
token
);
static
QByteArray
getChannels
(
const
QString
&
token
);
static
QByteArray
getRefundDetail
(
const
QString
&
token
,
const
QString
&
orderId
);
static
QByteArray
getRefundDetail
(
const
QString
&
token
,
const
QString
&
orderId
);
};
};
...
...
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