Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
familyMart_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
guanghui.cui
familyMart_takeaway
Commits
f4550690
Commit
f4550690
authored
Apr 02, 2018
by
guanghui.cui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加pk_id字段
parent
d72cfedf
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
6 deletions
+23
-6
src/JsonModule.cpp
+22
-5
src/JsonModule.h
+1
-1
No files found.
src/JsonModule.cpp
View file @
f4550690
...
...
@@ -852,7 +852,7 @@ bool JsonModule::getOdsResponseData(int status_code, const std::string &msg, std
LOG
(
INFO
)
<<
"fm_cmd:"
<<
fm_cmd
;
bool
rlt
=
false
;
if
(
fm_cmd
==
REQUEST_TYPE_NEWORDER_PUSH
){
rlt
=
_getOrderResponseJson
(
posResponse
,
orderData
,
result
);
rlt
=
_getOrderResponseJson
(
posResponse
,
orderData
,
odsData
,
result
);
}
else
if
(
fm_cmd
==
REQUEST_TYPE_STOCK_WARN
){
rlt
=
_getStockWarnResponseJson
(
posResponse
,
orderData
,
odsData
,
result
);
...
...
@@ -1785,11 +1785,12 @@ int JsonModule::getPushType(IN const char* data)
return
0
;
}
bool
JsonModule
::
_getOrderResponseJson
(
IN
const
std
::
string
&
posResponse
,
IN
const
std
::
string
&
orderData
,
OUT
std
::
string
&
result
)
bool
JsonModule
::
_getOrderResponseJson
(
IN
const
std
::
string
&
posResponse
,
IN
const
std
::
string
&
orderData
,
IN
const
std
::
string
&
odsData
,
OUT
std
::
string
&
result
)
{
rapidjson
::
Document
document
,
document1
;
rapidjson
::
Document
document
,
document1
,
document2
;
document
.
Parse
(
posResponse
.
c_str
());
document1
.
Parse
(
orderData
.
c_str
());
document2
.
Parse
(
odsData
.
c_str
());
if
(
!
document
.
HasMember
(
"status_code"
)
||
!
document1
.
HasMember
(
"order_id"
)
...
...
@@ -1807,6 +1808,8 @@ bool JsonModule::_getOrderResponseJson(IN const std::string& posResponse, IN con
int
status
=
document1
[
"ods_status"
].
GetInt
();
std
::
string
channel
=
document1
[
"channel"
].
GetString
();
int
pk_id
=
GetJsonIntSafe
(
document2
,
"pk_id"
);
rapidjson
::
StringBuffer
buffer
;
rapidjson
::
Writer
<
rapidjson
::
StringBuffer
>
writer
(
buffer
);
writer
.
StartObject
();
...
...
@@ -1829,6 +1832,9 @@ bool JsonModule::_getOrderResponseJson(IN const std::string& posResponse, IN con
writer
.
Key
(
"msg"
);
writer
.
String
(
msg
.
c_str
());
writer
.
Key
(
"pk_id"
);
writer
.
Int
(
pk_id
);
writer
.
EndObject
();
result
=
buffer
.
GetString
();
...
...
@@ -1843,7 +1849,10 @@ bool JsonModule::_getStockWarnResponseJson(IN const std::string& posResponse, IN
document1
.
Parse
(
orderData
.
c_str
());
document2
.
Parse
(
odsData
.
c_str
());
if
(
!
document
.
HasMember
(
"status_code"
)
||
!
document2
.
HasMember
(
"channel"
)
||
!
document2
.
HasMember
(
"alertTime"
)
||
!
document2
.
HasMember
(
"storeId"
))
if
(
!
document
.
HasMember
(
"status_code"
)
||
!
document2
.
HasMember
(
"channel"
)
||
!
document2
.
HasMember
(
"alertTime"
)
||
!
document2
.
HasMember
(
"storeId"
))
{
LOG
(
INFO
)
<<
"Don't have needed parames"
;
return
false
;
...
...
@@ -1856,6 +1865,7 @@ bool JsonModule::_getStockWarnResponseJson(IN const std::string& posResponse, IN
std
::
string
channel
=
document2
[
"channel"
].
GetString
();
int64_t
alertTime
=
document2
[
"alertTime"
].
GetInt64
();
std
::
string
storeId
=
document2
[
"storeId"
].
GetString
();
int
pk_id
=
GetJsonIntSafe
(
document2
,
"pk_id"
);
rapidjson
::
StringBuffer
buffer
;
rapidjson
::
Writer
<
rapidjson
::
StringBuffer
>
writer
(
buffer
);
...
...
@@ -1876,6 +1886,9 @@ bool JsonModule::_getStockWarnResponseJson(IN const std::string& posResponse, IN
writer
.
Key
(
"status_code"
);
writer
.
Int
(
status_code
);
writer
.
Key
(
"pk_id"
);
writer
.
Int
(
pk_id
);
writer
.
EndObject
();
result
=
buffer
.
GetString
();
...
...
@@ -1949,7 +1962,7 @@ std::string JsonModule::_convertToCommonWarnJson(IN const char* json)
bool
JsonModule
::
_getCommonWarnResponseJson
(
IN
const
std
::
string
&
posResponse
,
IN
const
std
::
string
&
orderData
,
IN
const
std
::
string
&
odsData
,
OUT
std
::
string
&
result
)
{
std
::
string
notifyDate
,
rackNo
,
storeId
,
terminalNo
;
int64_t
iDatetime
=
0
;
int64_t
iDatetime
=
0
,
pk_id
;
rapidjson
::
Document
document
,
document1
;
// 定义一个Document对象
document1
.
Parse
(
odsData
.
data
());
// 解析,Parse()无返回值,也不会抛异常
if
(
document1
.
HasParseError
())
// 通过HasParseError()来判断解析是否成功
...
...
@@ -1968,6 +1981,7 @@ bool JsonModule::_getCommonWarnResponseJson(IN const std::string& posResponse, I
rackNo
=
vRackNo
.
GetString
();
storeId
=
vStoreId
.
GetString
();
terminalNo
=
vTerminalNo
.
GetString
();
pk_id
=
GetJsonIntSafe
(
document1
,
"pk_id"
);
}
document
.
Parse
(
posResponse
.
c_str
());
if
(
document
.
HasParseError
())
// 通过HasParseError()来判断解析是否成功
...
...
@@ -2000,6 +2014,9 @@ bool JsonModule::_getCommonWarnResponseJson(IN const std::string& posResponse, I
writer
.
Key
(
"status_code"
);
writer
.
Int
(
status_code
);
writer
.
Key
(
"pk_id"
);
writer
.
Int
(
pk_id
);
writer
.
EndObject
();
result
=
buffer
.
GetString
();
...
...
src/JsonModule.h
View file @
f4550690
...
...
@@ -132,7 +132,7 @@ private:
std
::
string
_convertToOrderOperationReponseJson
(
IN
const
char
*
json
);
bool
_convertPOSReqPriorityJson
(
IN
const
std
::
string
&
posReq
,
OUT
const
std
::
string
&
odsJson
);
bool
_getOrderResponseJson
(
IN
const
std
::
string
&
posResponse
,
IN
const
std
::
string
&
orderData
,
OUT
std
::
string
&
result
);
bool
_getOrderResponseJson
(
IN
const
std
::
string
&
posResponse
,
IN
const
std
::
string
&
orderData
,
IN
const
std
::
string
&
odsData
,
OUT
std
::
string
&
result
);
bool
_getStockWarnResponseJson
(
IN
const
std
::
string
&
posResponse
,
IN
const
std
::
string
&
orderData
,
IN
const
std
::
string
&
odsData
,
OUT
std
::
string
&
result
);
bool
_getCommonWarnResponseJson
(
IN
const
std
::
string
&
posResponse
,
IN
const
std
::
string
&
orderData
,
IN
const
std
::
string
&
odsData
,
OUT
std
::
string
&
result
);
...
...
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