Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
takeout_sbk
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
yunpeng.song
takeout_sbk
Commits
a0fce148
Commit
a0fce148
authored
Jul 24, 2018
by
wuyang.zou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix bug: 修复部分重要bug
parent
c424f3f8
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
187 additions
and
66 deletions
+187
-66
fmTakeout/Control/flowControl.cpp
+161
-43
fmTakeout/Control/flowControl.h
+10
-7
fmTakeout/LocalServer/loaclHttpServer.cpp
+15
-15
fmTakeout/detailForm.cpp
+1
-1
No files found.
fmTakeout/Control/flowControl.cpp
View file @
a0fce148
...
...
@@ -41,14 +41,15 @@ FlowControl::FlowControl()
m_clearTimer
=
new
QTimer
(
this
);
m_heartTimer
=
new
QTimer
(
this
);
m_pullTimer
=
new
QTimer
(
this
);
m_pullTimer
->
setSingleShot
(
true
);
m_loginTimer
=
new
QTimer
(
this
);
m_notifySimPullTimer
=
new
QTimer
(
this
);
connect
(
m_loginTimer
,
&
QTimer
::
timeout
,
this
,
&
FlowControl
::
_ClickToLogin
);
connect
(
m_pullTimer
,
&
QTimer
::
timeout
,
this
,
&
FlowControl
::
_PullOrder
);
connect
(
m_notifySimPullTimer
,
&
QTimer
::
timeout
,
this
,
&
FlowControl
::
_ClickToNotifySimPullOrder
);
connect
(
m_pullTimer
,
&
QTimer
::
timeout
,
this
,
&
FlowControl
::
_PullOrderData
);
connect
(
m_clearTimer
,
&
QTimer
::
timeout
,
this
,
&
FlowControl
::
_CrondClearExpireOrder
);
connect
(
m_heartTimer
,
&
QTimer
::
timeout
,
this
,
&
FlowControl
::
_SendHeart
);
connect
(
this
,
&
FlowControl
::
doPullOrder
,
this
,
&
FlowControl
::
_GetOrder
);
connect
(
this
,
&
FlowControl
::
doPullOrder
,
this
,
&
FlowControl
::
_Get
ReadyForPull
Order
);
connect
(
this
,
&
FlowControl
::
doConfirmOrder
,
this
,
&
FlowControl
::
_ConfirmOrder
,
Qt
::
BlockingQueuedConnection
);
connect
(
this
,
&
FlowControl
::
doRefundOrder
,
this
,
&
FlowControl
::
_RefundOrder
,
Qt
::
BlockingQueuedConnection
);
...
...
@@ -65,9 +66,74 @@ FlowControl::FlowControl()
/*** 启动Http服务:用来响应Simphony_Script获取订单的请求***/
loaclHttpServer
=
new
LoaclHttpServer
();
loaclHttpServer
->
run
();
_ClickOMSAssignArea
();
m_loginTimer
->
start
(
10
*
1000
);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*
//启动Http服务:用来响应 Http 获取订单的请求
JQHttpServer::TcpServerManage* m_tcpServerManage = new JQHttpServer::TcpServerManage(10);
m_tcpServerManage->setHttpAcceptedCallback( [this]( const QPointer< JQHttpServer::Session > &session )
{
QLOG_INFO()<< "[<<<<---FlowControl::Receive Http Request:currentThreadId:--->>>>]" << QThread::currentThreadId();
// 回调发生在新的线程内;
//解析FM外卖插件HTTP服务 与 Http 请求的会话连接是否断开: 会话连接未断开
if(!session.isNull())
{
QString recvData = QString::fromUtf8(session->requestRawData());
QLOG_INFO() << QString::fromLocal8Bit("[<<<<---FlowControl::Receive Http Request recvData: %1--->>>>]").arg(recvData);
QJsonParseError jsonError;
QJsonObject recvObject;
QJsonObject replyObject;
int status; //解析json结果
QString msg;
QJsonObject data; //回复的内容json
int iscontinue =0;
recvObject = QJsonDocument::fromJson(recvData.toUtf8(), &jsonError).object();
//解析Http Request json格式: 解析失败
if(jsonError.error != QJsonParseError::NoError)
{
status = 0;
msg = jsonError.errorString();
}
//解析Http Request json格式: 解析成功
else {
//解析:FM外卖插件为响应Simphony请求准备返回数据:准备返回数据成功
if(_ResponseHttpRequest(recvObject,data, msg))
{
status = 100;
}
//解析:FM外卖插件为响应Http请求准备返回数据:准备返回数据失败
else{
status = 0;
}
//解析:等待Http获取的有效订单列表是否为空: sim有效订单列表不为空
if(!_SimValidOrdersListIsEmpty())
{
iscontinue=1;
}
}
//将FM外卖插件中的合法有效数据返回给上面Http发过来的请求
replyObject = _PackHttpReplyJson(status, msg, data,iscontinue);
QLOG_INFO() << QString::fromLocal8Bit("[<<<<---FM插件回应Http拉单请求后的返回结果:--->>>>]") << replyObject;
session->replyJsonObject(replyObject);
}
//解析FM外卖插件HTTP服务 与 Http 请求的会话连接是否断开: 会话连接断开//
else{
QLOG_INFO() << QString::fromLocal8Bit("[<<<<---FM外卖插件Http服务与Http请求会话断开连接:--->>>>]");
}
} );
//FM外卖插件绑定启动HTTP服务的端口
int port = ConfigManger::GetInstance().GetHttpServerPort();
QLOG_INFO() << QString::fromLocal8Bit("[<<<<---FM外卖插件Http服务监听端口:%1 :--->>>>]").arg(port);
if(m_tcpServerManage->listen( QHostAddress::Any, port))
{
QLOG_INFO() << QString::fromLocal8Bit("[<<<<---FM外卖插件Http服务 绑定端口成功:--->>>>]");
}else{
QLOG_INFO() << QString::fromLocal8Bit("[<<<<---FM外卖插件Http服务 绑定端口失败:--->>>>]");
}
*/
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
_ClickOMSAssignArea
();
m_loginTimer
->
start
(
10
*
1000
);
}
...
...
@@ -93,21 +159,24 @@ QString FlowControl::_GetIpAddress()
void
FlowControl
::
_AddOrderPull
(
const
QString
&
orderId
,
const
QString
&
channel
,
const
int
&
pageNumber
,
const
int
&
pageSize
)
{
m_PullOrderDataMutex
.
lock
();
/***组装从FM外卖service端的拉单请求参数***/
PullOrderInfo
orderPull
;
orderPull
.
orderId
=
orderId
;
orderPull
.
channel
=
channel
;
orderPull
.
pageNumber
=
pageNumber
;
orderPull
.
pageSize
=
pageSize
;
PullOrderInfo
*
orderPull
=
new
PullOrderInfo
();
orderPull
->
orderId
=
orderId
;
orderPull
->
channel
=
channel
;
orderPull
->
pageNumber
=
pageNumber
;
orderPull
->
pageSize
=
pageSize
;
QLOG_INFO
()
<<
QString
::
fromLocal8Bit
(
"[<<<<---FlowControl::_AddOrderPull orderId:%1--->>>>]"
).
arg
(
orderId
);
m_orderPullList
.
append
(
orderPull
);
m_PullOrderDataMutex
.
unlock
();
}
void
FlowControl
::
_GetOrder
(
const
QString
&
orderId
,
const
QString
&
channel
)
void
FlowControl
::
_GetReadyForPullOrder
(
const
QString
&
orderId
,
const
QString
&
channel
)
{
/
***组装从FM外卖service端的拉单请求参数***
/
/
//组装从FM外卖service端的拉单请求参数/
/
_AddOrderPull
(
orderId
,
channel
);
/***开始拉单***/
_PullOrder
();
///////不能上来就拉单,只能通过定时器来触发拉单动作////// //_PullOrderData();
}
void
FlowControl
::
_ClickOMSAssignArea
()
...
...
@@ -121,14 +190,30 @@ void FlowControl::_ClickOMSAssignArea()
void
FlowControl
::
_ClickToLogin
()
{
QLOG_INFO
()
<<
QString
::
fromLocal8Bit
(
"[<<<<---触发按钮点击事件:_ClickToLogin: m_bLoginResult:%1
m_simValidOrdersList.isEmpty():%2--->>>>>]"
).
arg
(
m_bLoginResult
).
arg
(
m_simValidOrdersList
.
isEmpty
()
);
if
(
!
m_bLoginResult
||!
m_simValidOrdersList
.
isEmpty
()
)
QLOG_INFO
()
<<
QString
::
fromLocal8Bit
(
"[<<<<---触发按钮点击事件:_ClickToLogin: m_bLoginResult:%1
--->>>>>]"
).
arg
(
m_bLoginResult
);
if
(
!
m_bLoginResult
)
{
QLOG_INFO
()
<<
QString
::
fromLocal8Bit
(
"[<<<<---触发按钮点击事件:FM外卖插件
2
0s后再次尝试登陆--->>>>]"
);
QLOG_INFO
()
<<
QString
::
fromLocal8Bit
(
"[<<<<---触发按钮点击事件:FM外卖插件
1
0s后再次尝试登陆--->>>>]"
);
_ClickOMSAssignArea
();
}
else
{
m_loginTimer
->
start
(
1000
*
60
);
}
}
void
FlowControl
::
_ClickToNotifySimPullOrder
()
{
QLOG_INFO
()
<<
QString
::
fromLocal8Bit
(
"[<<<<---触发按钮点击事件:_ClickToNotifySimPullOrder: m_simValidOrdersList.isEmpty():%2--->>>>>]"
).
arg
(
m_simValidOrdersList
.
isEmpty
());
if
(
!
m_simValidOrdersList
.
isEmpty
())
{
m_notifySimPullTimer
->
start
(
1000
*
10
);
QLOG_INFO
()
<<
QString
::
fromLocal8Bit
(
"[<<<<---FM外卖插件通知 Simphony 获取订单数据--->>>>]"
);
_ClickOMSAssignArea
();
}
else
{
m_notifySimPullTimer
->
start
(
1000
*
50
);
}
}
void
FlowControl
::
_OrderAnalysis
(
const
QJsonObject
&
jsonObject
)
{
OrderObject
*
orderObject
=
NULL
;
...
...
@@ -353,9 +438,10 @@ bool FlowControl::_Login()
emit
setStoreInfo
(
m_storeId
);
emit
setCashierInfo
(
m_cashierId
);
m_bLoginResult
=
true
;
m_clearTimer
->
start
(
1000
*
60
*
6
0
);
// 一小时执行一次:清理两天前的插件订单;
m_clearTimer
->
start
(
1000
*
60
*
3
0
);
// 一小时执行一次:清理两天前的插件订单;
m_heartTimer
->
start
(
1000
*
60
*
5
);
m_pullTimer
->
start
(
1000
*
10
);
m_pullTimer
->
start
(
1000
*
2
);
m_notifySimPullTimer
->
start
(
10
*
1000
);
emit
doPullOrder
(
QString
(),
QString
());
}
}
...
...
@@ -368,20 +454,42 @@ bool FlowControl::_Login()
return
result
;
}
void
FlowControl
::
_PullOrder
()
void
FlowControl
::
_PullOrder
Data
()
{
QLOG_INFO
()
<<
"[<<<<----FlowControl::_PullOrderData ---->>>>>]"
;
if
(
m_orderPullList
.
isEmpty
())
return
;
emit
hideAlert
();
PullOrderInfo
info
=
m_orderPullList
.
takeFirst
();
if
(
info
.
orderId
.
isEmpty
())
m_PullOrderDataMutex
.
lock
();
PullOrderInfo
*
info
=
m_orderPullList
.
takeFirst
();
if
(
info
->
orderId
.
isEmpty
())
{
_PullOrderList
(
info
.
pageSize
,
info
.
pageNumber
);
if
(
_PullOrderList
(
info
->
pageSize
,
info
->
pageNumber
)
){
QLOG_INFO
()
<<
"[<<<<----FlowControl::_PullOrderData _PullOrderList successful---->>>>>]"
;
m_orderPullList
.
removeOne
(
info
);
delete
info
;
}
else
{
QLOG_INFO
()
<<
"[<<<<----FlowControl::_PullOrderData _PullOrderList successful failed---->>>>>]"
;
m_orderPullList
.
removeOne
(
info
);
m_orderPullList
.
append
(
info
);
}
}
else
{
_PullOrderDetail
(
info
.
orderId
);
if
(
_PullOrderDetail
(
info
->
orderId
)
){
QLOG_INFO
()
<<
"[<<<<----FlowControl::_PullOrderData _PullOrderDetail successful---->>>>>]"
;
m_orderPullList
.
removeOne
(
info
);
delete
info
;
}
else
{
QLOG_INFO
()
<<
"[<<<<----FlowControl::_PullOrderData _PullOrderDetail fail---->>>>>]"
;
m_orderPullList
.
removeOne
(
info
);
m_orderPullList
.
append
(
info
);
}
}
m_PullOrderDataMutex
.
unlock
();
return
;
}
...
...
@@ -396,10 +504,10 @@ bool FlowControl::_PullOrderDetail(const QString& orderId)
if
(
ConfigManger
::
GetInstance
().
GetOrderSslConfig
())
{
m_pullOrderSocket
->
SetSslConfig
();
QLOG_INFO
()
<<
"load ssl"
;
QLOG_INFO
()
<<
"
FlowControl::_PullOrderDetai
load ssl"
;
}
else
{
QLOG_INFO
()
<<
"load not ssl"
;
QLOG_INFO
()
<<
"
FlowControl::_PullOrderDetai
load not ssl"
;
}
QString
url
=
ConfigManger
::
GetInstance
().
GetOrderServerUrl
()
+
ConfigManger
::
GetInstance
().
GetInterfaceName
(
INI_INTERFACE_PULLORDER
);
...
...
@@ -432,11 +540,13 @@ bool FlowControl::_PullOrderDetail(const QString& orderId)
}
}
/*解析json数据失败则10秒后重新拉单*/
/*
if(!result)
{
m_pullTimer->start(1000*10);
_AddOrderPull(orderId);
}
*/
qDebug
()
<<
"[<<<<---Pull Order Detail Result--->>>>]"
<<
result
;
return
result
;
}
...
...
@@ -458,10 +568,10 @@ bool FlowControl::_PullOrderList(const int &pageSize, const int &pageNo)
if
(
ConfigManger
::
GetInstance
().
GetOrderSslConfig
())
{
m_pullOrderSocket
->
SetSslConfig
();
QLOG_INFO
()
<<
"load ssl"
;
QLOG_INFO
()
<<
"
FlowControl::_PullOrderList
load ssl"
;
}
else
{
QLOG_INFO
()
<<
"load not ssl"
;
QLOG_INFO
()
<<
"
FlowControl::_PullOrderList
load not ssl"
;
}
m_pullOrderListSocket
->
SetUrl
(
QUrl
(
ConfigManger
::
GetInstance
().
GetOrderServerUrl
()
+
ConfigManger
::
GetInstance
().
GetInterfaceName
(
INI_INTERFACE_PULLORDERLIST
)));
...
...
@@ -498,15 +608,17 @@ bool FlowControl::_PullOrderList(const int &pageSize, const int &pageNo)
if
(
m_orderCount
<
ordertotalSum
)
{
_AddOrderPull
(
QString
(),
QString
(),
pageNo
+
1
,
pageSize
);
_PullOrder
();
_PullOrder
Data
();
}
}
}
/*
if(!result)
{
m_pullTimer->start(1000*10);
_AddOrderPull(QString(),QString(),pageNo,pageSize);
}
*/
qDebug
()
<<
"[<<<<---Pull Order List Result--->>>>]"
<<
result
;
return
result
;
}
...
...
@@ -1111,13 +1223,16 @@ void FlowControl::onDailyReport()
void
FlowControl
::
_CrondClearExpireOrder
()
{
QDateTime
currentDateTime
=
QDateTime
::
currentDateTime
();
//QDateTime currentDateTime= QDateTime::currentDateTime();
QDate
currentDate
=
QDate
::
currentDate
();
OrderObject
*
order
=
NULL
;
m_OrderEntryMutex
.
lock
();
foreach
(
order
,
m_FmOrdersMap
.
values
())
{
QDateTime
createDateTime
=
QDateTime
::
fromTime_t
(
order
->
updateTime
);
qint64
days
=
createDateTime
.
daysTo
(
currentDateTime
);
if
(
days
>=
2
)
//QDateTime createDateTime=QDateTime::fromString(order->createTime,"yyyyMMdd 00:00:00");
QDate
createDate
=
QDate
::
fromString
(
order
->
createTime
,
"yyyyMMdd"
);
//qint64 days=createDateTime.daysTo(currentDateTime);
qint64
days
=
createDate
.
daysTo
(
currentDate
);
if
(
days
>=
1
)
{
QLOG_INFO
()
<<
QString
(
"[<<<<---Crond Clear Expire Order: orderID:%1--->>>>]"
).
arg
(
order
->
id
);
emit
clearorder
(
order
->
id
,
order
->
orderStatus
);
...
...
@@ -1130,17 +1245,17 @@ void FlowControl::_CrondClearExpireOrder()
SimProcOrderDB
::
getInstance
().
deleteOrderRecord
(
QDate
::
currentDate
().
addMonths
(
-
1
).
toString
(
"yyyyMMdd"
));
}
bool
FlowControl
::
_Response
Simphony
Request
(
const
QJsonObject
&
content
,
QJsonObject
&
data
,
QString
&
error
)
bool
FlowControl
::
_Response
Http
Request
(
const
QJsonObject
&
content
,
QJsonObject
&
data
,
QString
&
error
)
{
QLOG_INFO
()
<<
__FUNCTION__
;
bool
result
=
true
;
/****校验
Simphony_Script
请求参数有效性: 校验参数->actionId不存在****/
/****校验
Http
请求参数有效性: 校验参数->actionId不存在****/
if
(
!
content
.
contains
(
"actionId"
))
{
error
=
QString
::
fromLocal8Bit
(
"解析
Simphony_Script
请求参数:参数中没有actionId"
);
error
=
QString
::
fromLocal8Bit
(
"解析
Http
请求参数:参数中没有actionId"
);
result
=
false
;
}
/****校验
Simphony_Script
请求参数有效性: 校验参数->actionId存在****/
/****校验
Http
请求参数有效性: 校验参数->actionId存在****/
else
{
int
actionId
;
if
(
content
[
"actionId"
].
isString
())
...
...
@@ -1150,6 +1265,7 @@ bool FlowControl::_ResponseSimphonyRequest(const QJsonObject &content,QJsonObjec
else
{
actionId
=
content
[
"actionId"
].
toInt
();
}
QLOG_INFO
()
<<
QString
::
fromLocal8Bit
(
"[<<<<---Http请求[action:%1] --->>>>]"
).
arg
(
actionId
);
/****校验请求参数actionId的具体数值:****/
switch
(
actionId
)
{
case
1
:
//simphony拉取订单
...
...
@@ -1167,14 +1283,14 @@ bool FlowControl::_ResponseSimphonyRequest(const QJsonObject &content,QJsonObjec
case
5
:
//simphony更新订单数据到POS本地数据库以便POS打印小票及汇总单信息 回复
result
=
_ResponseSimphony05Request
(
content
,
data
,
error
);
break
;
case
11
:
//推送订单
result
=
_Response
Simphony
11Request
(
content
,
data
,
error
);
case
11
:
//
FM OMS
推送订单
result
=
_Response
OMS
11Request
(
content
,
data
,
error
);
break
;
case
12
:
//推送门店营业状态
result
=
_ResponseSimphony12Request
(
content
,
data
,
error
);
break
;
default
:
error
=
QString
::
fromLocal8Bit
(
"解析
Simphony_Script
请求actionId值不在规定的接口文档内"
);
error
=
QString
::
fromLocal8Bit
(
"解析
Http
请求actionId值不在规定的接口文档内"
);
result
=
false
;
break
;
}
...
...
@@ -1451,7 +1567,7 @@ bool FlowControl::_ResponseSimphony05Request(const QJsonObject &content, QJsonOb
}
bool
FlowControl
::
_Response
Simphony
11Request
(
const
QJsonObject
&
content
,
QJsonObject
&
data
,
QString
&
error
)
bool
FlowControl
::
_Response
OMS
11Request
(
const
QJsonObject
&
content
,
QJsonObject
&
data
,
QString
&
error
)
{
QLOG_INFO
()
<<
__FUNCTION__
;
bool
result
=
true
;
...
...
@@ -1465,7 +1581,9 @@ bool FlowControl::_ResponseSimphony11Request(const QJsonObject &content, QJsonOb
error
=
QString
::
fromLocal8Bit
(
"订单号不能为空"
);
return
false
;
}
emit
doPullOrder
(
content
[
JSON_ORDER_ID
].
toString
(),
content
[
JSON_CHANNEL
].
toString
());
// 接受到非码oms插过来的订单,进行向队列中进行添加;
_AddOrderPull
(
content
[
JSON_ORDER_ID
].
toString
(),
content
[
JSON_CHANNEL
].
toString
());
/***组装从FM外卖service端的拉单请求参数***/
error
=
QString
(
"success"
);
result
=
true
;
}
...
...
fmTakeout/Control/flowControl.h
View file @
a0fce148
...
...
@@ -75,6 +75,7 @@ private:
QTimer
*
m_heartTimer
;
QTimer
*
m_pullTimer
;
QTimer
*
m_loginTimer
;
QTimer
*
m_notifySimPullTimer
;
// 网络通信
BillSocket
*
m_loginSocket
;
BillSocket
*
m_pullOrderSocket
;
...
...
@@ -99,7 +100,8 @@ private:
//记录当前订单操作
QMap
<
QString
,
int
>
m_orderOperatePair
;
//订单拉取记录
QList
<
PullOrderInfo
>
m_orderPullList
;
QList
<
PullOrderInfo
*>
m_orderPullList
;
QMutex
m_PullOrderDataMutex
;
//订单操作互斥信号
//QSemaphore semaphore;
...
...
@@ -202,7 +204,7 @@ private slots:
* 参数:[1]订单编号
* 返回:是否成功
* */
void
_PullOrder
();
void
_PullOrder
Data
();
/* 功能:拉取指定订单
* 参数:[1]订单编号
* 返回:是否成功
...
...
@@ -270,7 +272,7 @@ private slots:
*参数:1、请求json参数;2、准备返回请求数据的Buff;3、返回错误信息;
*返回:是否准备成功;
**/
//bool _Response
Simphony
Request(const QJsonObject &content, QJsonObject &data,QString &error);
//bool _Response
Http
Request(const QJsonObject &content, QJsonObject &data,QString &error);
/**
*功能:FM外卖插件为响应Simphony请求[action:01 -> 拉取订单]准备返回数据
...
...
@@ -312,7 +314,7 @@ private slots:
*参数:1、请求json参数;2、准备返回请求数据的Buff;3、返回错误信息;
*返回:是否准备成功;
**/
//bool _Response
Simphony
11Request(const QJsonObject &content, QJsonObject &data,QString &error);
//bool _Response
OMS
11Request(const QJsonObject &content, QJsonObject &data,QString &error);
/**
*功能:FM外卖插件为响应Simphony请求[action:12 -> Sim/POS推送门店营业状态]准备返回数据
...
...
@@ -340,10 +342,11 @@ private slots:
QString
_GetIpAddress
();
void
_AddOrderPull
(
const
QString
&
orderId
=
0
,
const
QString
&
channel
=
0
,
const
int
&
pageNumber
=
1
,
const
int
&
pageSize
=
100
);
void
_GetOrder
(
const
QString
&
orderId
,
const
QString
&
channel
);
void
_Get
ReadyForPull
Order
(
const
QString
&
orderId
,
const
QString
&
channel
);
//点击屏幕指定区域
void
_ClickOMSAssignArea
();
void
_ClickToLogin
();
void
_ClickToNotifySimPullOrder
();
void
_OrderAnalysis
(
const
QJsonObject
&
jsonObject
);
...
...
@@ -417,7 +420,7 @@ public slots:
*参数:1、请求json参数;2、准备返回请求数据的Buff;3、返回错误信息;
*返回:是否准备成功;
**/
bool
_Response
Simphony
Request
(
const
QJsonObject
&
content
,
QJsonObject
&
data
,
QString
&
error
);
bool
_Response
Http
Request
(
const
QJsonObject
&
content
,
QJsonObject
&
data
,
QString
&
error
);
/**
*功能:FM外卖插件为响应Simphony请求[action:01 -> 拉取订单]准备返回数据
...
...
@@ -459,7 +462,7 @@ public slots:
*参数:1、请求json参数;2、准备返回请求数据的Buff;3、返回错误信息;
*返回:是否准备成功;
**/
bool
_Response
Simphony
11Request
(
const
QJsonObject
&
content
,
QJsonObject
&
data
,
QString
&
error
);
bool
_Response
OMS
11Request
(
const
QJsonObject
&
content
,
QJsonObject
&
data
,
QString
&
error
);
/**
*功能:FM外卖插件为响应Simphony请求[action:12 -> Sim/POS推送门店营业状态]准备返回数据
...
...
fmTakeout/LocalServer/loaclHttpServer.cpp
View file @
a0fce148
...
...
@@ -12,17 +12,17 @@ LoaclHttpServer::LoaclHttpServer()
void
LoaclHttpServer
::
run
()
{
/*** 启动Http服务:用来响应
Simphony_Script
获取订单的请求***/
QLOG_INFO
()
<<
"[<<<<---LoaclHttpServer::Receive
Simphony_Script
Request:m_tcpServerManage:--->>>>]"
<<
m_tcpServerManage
;
/*** 启动Http服务:用来响应
Http
获取订单的请求***/
QLOG_INFO
()
<<
"[<<<<---LoaclHttpServer::Receive
Http
Request:m_tcpServerManage:--->>>>]"
<<
m_tcpServerManage
;
m_tcpServerManage
->
setHttpAcceptedCallback
(
[
this
](
const
QPointer
<
JQHttpServer
::
Session
>
&
session
)
{
QLOG_INFO
()
<<
"[<<<<---LoaclHttpServer::Receive
Simphony_Script
Request:currentThreadId:--->>>>]"
<<
QThread
::
currentThreadId
();
QLOG_INFO
()
<<
"[<<<<---LoaclHttpServer::Receive
Http
Request:currentThreadId:--->>>>]"
<<
QThread
::
currentThreadId
();
// 回调发生在新的线程内;
/***解析FM外卖插件HTTP服务与
Simphony_Script
请求的会话连接是否断开: 会话连接未断开***/
/***解析FM外卖插件HTTP服务与
Http
请求的会话连接是否断开: 会话连接未断开***/
if
(
!
session
.
isNull
())
{
QString
recvData
=
QString
::
fromUtf8
(
session
->
requestRawData
());
QLOG_INFO
()
<<
QString
::
fromLocal8Bit
(
"[<<<<---Receive
Simphony_Script
Request recvData: %1--->>>>]"
).
arg
(
recvData
);
QLOG_INFO
()
<<
QString
::
fromLocal8Bit
(
"[<<<<---Receive
Http
Request recvData: %1--->>>>]"
).
arg
(
recvData
);
QJsonParseError
jsonError
;
QJsonObject
recvObject
;
QJsonObject
replyObject
;
...
...
@@ -31,37 +31,37 @@ void LoaclHttpServer::run()
QJsonObject
data
;
//回复的内容json
int
iscontinue
=
0
;
recvObject
=
QJsonDocument
::
fromJson
(
recvData
.
toUtf8
(),
&
jsonError
).
object
();
/***解析
Simphony_Script
Request json格式: 解析失败***/
/***解析
Http
Request json格式: 解析失败***/
if
(
jsonError
.
error
!=
QJsonParseError
::
NoError
)
{
status
=
0
;
msg
=
jsonError
.
errorString
();
}
/***解析
Simphony_Script
Request json格式: 解析成功***/
/***解析
Http
Request json格式: 解析成功***/
else
{
/***解析:FM外卖插件为响应
Simphony
请求准备返回数据:准备返回数据成功***/
if
(
FlowControl
::
GetInstance
().
_Response
Simphony
Request
(
recvObject
,
data
,
msg
))
/***解析:FM外卖插件为响应
http
请求准备返回数据:准备返回数据成功***/
if
(
FlowControl
::
GetInstance
().
_Response
Http
Request
(
recvObject
,
data
,
msg
))
{
status
=
100
;
}
/***解析:FM外卖插件为响应
Simphony
请求准备返回数据:准备返回数据失败***/
/***解析:FM外卖插件为响应
Http
请求准备返回数据:准备返回数据失败***/
else
{
status
=
0
;
}
/***解析:等待
Simphony
获取的有效订单列表是否为空: sim有效订单列表不为空***/
/***解析:等待
Http
获取的有效订单列表是否为空: sim有效订单列表不为空***/
if
(
!
FlowControl
::
GetInstance
().
_SimValidOrdersListIsEmpty
())
{
iscontinue
=
1
;
}
}
/***将FM外卖插件中的合法有效数据返回给上面
Simphony_Script
发过来的请求***/
/***将FM外卖插件中的合法有效数据返回给上面
Http
发过来的请求***/
replyObject
=
FlowControl
::
GetInstance
().
_PackHttpReplyJson
(
status
,
msg
,
data
,
iscontinue
);
QLOG_INFO
()
<<
QString
::
fromLocal8Bit
(
"[<<<<---FM外卖插件回应
Simphony_Script
拉单请求后的返回结果:--->>>>]"
)
<<
replyObject
;
QLOG_INFO
()
<<
QString
::
fromLocal8Bit
(
"[<<<<---FM外卖插件回应
Http
拉单请求后的返回结果:--->>>>]"
)
<<
replyObject
;
session
->
replyJsonObject
(
replyObject
);
}
/***解析FM外卖插件HTTP服务与
Simphony_Script
请求的会话连接是否断开: 会话连接断开***/
/***解析FM外卖插件HTTP服务与
Http
请求的会话连接是否断开: 会话连接断开***/
else
{
QLOG_INFO
()
<<
QString
::
fromLocal8Bit
(
"[<<<<---FM外卖插件Http服务与
Simphony_Script请求会话断开连接:
--->>>>]"
);
QLOG_INFO
()
<<
QString
::
fromLocal8Bit
(
"[<<<<---FM外卖插件Http服务与
Http请求会话断开链接
--->>>>]"
);
}
}
);
...
...
fmTakeout/detailForm.cpp
View file @
a0fce148
...
...
@@ -39,7 +39,7 @@ void DetailForm::InitData(OrderObject *orderObject)
ui
->
detailLab0
->
setText
(
QString
(
"[%1 # %2][%3][%4]"
).
arg
(
QString
::
number
(
orderObject
->
orderIndex
),
orderObject
->
getChannelName
(),
orderObject
->
getOrderStatusDec
(),
orderObject
->
id
));
ui
->
detailLab1
->
setText
(
QString
(
"%1:%2"
).
arg
(
orderObject
->
c
ustomerName
,
orderObject
->
p
hone
));
ui
->
detailLab1
->
setText
(
QString
(
"%1:%2"
).
arg
(
orderObject
->
c
onsigneeName
,
orderObject
->
consigneeP
hone
));
ui
->
detailLab2
->
setText
(
orderObject
->
deliveryTime
.
isEmpty
()
?
QString
::
fromLocal8Bit
(
"立即送出"
)
:
orderObject
->
deliveryTime
);
ui
->
detailLab3
->
setText
(
orderObject
->
riderName
.
isEmpty
()
?
QString
::
fromLocal8Bit
(
"暂未指定"
)
:
QString
::
fromLocal8Bit
(
"[姓名]%1 [电话]%2"
)
.
arg
(
orderObject
->
riderName
,
orderObject
->
riderPhone
));
...
...
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