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
2a952a5e
Commit
2a952a5e
authored
Feb 26, 2018
by
guanghui.cui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
getOrder数据字段更新
parent
55b0bee9
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
309 additions
and
48 deletions
+309
-48
src/JsonModule.cpp
+309
-48
No files found.
src/JsonModule.cpp
View file @
2a952a5e
...
...
@@ -84,76 +84,337 @@ bool JsonModule::getPushOrders(IN const char* json,OUT orderObj &order)
rapidjson
::
Value
&
channel
=
document
[
"channel"
];
order
.
channel
=
channel
.
GetString
();
rapidjson
::
Value
&
order_id
=
document
[
"order_id
"
];
order
.
order_id
=
order_id
.
GetString
();
rapidjson
::
Value
&
token
=
document
[
"token
"
];
token
.
GetString
();
rapidjson
::
Value
&
create_time
=
document
[
"create_time
"
];
order
.
create_time
=
create_time
.
GetString
();
rapidjson
::
Value
&
ver
=
document
[
"ver
"
];
ver
.
GetInt
();
rapidjson
::
Value
&
delivery_time
=
document
[
"delivery_time"
];
order
.
delivery_time
=
delivery_time
.
GetString
();
//配送信息
{
rapidjson
::
Value
&
status
=
document
[
"status"
];
order
.
status
=
_getPOSOrderStatus
(
status
.
GetInt
());
rapidjson
::
Value
&
delivery_obj
=
document
[
"delivery"
];
rapidjson
::
Value
&
customerAddress
=
delivery_obj
[
"customerAddress"
];
order
.
customerInfo
.
address
=
customerAddress
.
GetString
();
rapidjson
::
Value
&
customerName
=
delivery_obj
[
"customerName"
];
order
.
customerInfo
.
name
=
customerName
.
GetString
();
rapidjson
::
Value
&
customerPhone
=
delivery_obj
[
"customerPhone"
];
order
.
customerInfo
.
phone
=
customerPhone
.
GetString
();
rapidjson
::
Value
&
deliveryTime
=
delivery_obj
[
"deliveryTime"
];
order
.
delivery_time
=
deliveryTime
.
GetString
();
rapidjson
::
Value
&
name
=
delivery_obj
[
"name"
];
order
.
deliveryInfo
.
driver_name
=
name
.
GetString
();
rapidjson
::
Value
&
phone
=
delivery_obj
[
"phone"
];
order
.
deliveryInfo
.
driver_phone
=
phone
.
GetString
();
rapidjson
::
Value
&
type
=
delivery_obj
[
"type"
];
order
.
deliveryInfo
.
type
=
type
.
GetString
();
}
rapidjson
::
Value
&
status_desc
=
document
[
"status_desc"
];
order
.
status_desc
=
status_desc
.
GetString
();
//发票信息
{
rapidjson
::
Value
&
invoice_obj
=
document
[
"invoice"
];
rapidjson
::
Value
&
companyName
=
invoice_obj
[
"companyName"
];
companyName
.
GetString
();
rapidjson
::
Value
&
invoiceType
=
invoice_obj
[
"invoiceType"
];
invoiceType
.
GetInt
();
rapidjson
::
Value
&
taxNum
=
invoice_obj
[
"taxNum"
];
taxNum
.
GetString
();
rapidjson
::
Value
&
title
=
invoice_obj
[
"title"
];
title
.
GetString
();
rapidjson
::
Value
&
transNum
=
invoice_obj
[
"transNum"
];
transNum
.
GetString
();
}
rapidjson
::
Value
&
total_fee
=
document
[
"total_fee"
];
order
.
total_price
=
total_fee
.
GetInt
();
//订单内容
{
rapidjson
::
Value
&
orderContent_obj
=
document
[
"orderContent"
];
rapidjson
::
Value
&
send_fee
=
document
[
"send_fe
e"
];
order
.
delivery_price
=
send_fee
.
GetInt
();
rapidjson
::
Value
&
createTime
=
orderContent_obj
[
"createTim
e"
];
order
.
create_time
=
createTime
.
GetString
();
rapidjson
::
Value
&
discount_fee
=
document
[
"discount_fee"
];
order
.
reduced_price
=
discount_fee
.
GetInt
();
//用户信息
rapidjson
::
Value
&
customer_array
=
orderContent_obj
[
"customer"
];
if
(
customer_array
.
IsArray
())
{
for
(
unsigned
int
i
=
0
;
i
<
customer_array
.
Size
();
i
++
){
rapidjson
::
Value
&
customer_obj
=
customer_array
[
i
];
//配送
rapidjson
::
Value
&
delivery_type
=
document
[
"delivery_type"
];
order
.
deliveryInfo
.
type
=
_getDeliveryTypeString
(
delivery_type
.
GetInt
());
rapidjson
::
Value
&
accountId
=
customer_obj
[
"accountId"
];
order
.
customerInfo
.
account
=
accountId
.
GetString
();
rapidjson
::
Value
&
delivery_status
=
document
[
"delivery_status
"
];
order
.
deliveryInfo
.
status
=
delivery_status
.
GetInt
(
);
rapidjson
::
Value
&
accountType
=
customer_obj
[
"accountType
"
];
order
.
customerInfo
.
account_type
=
atoi
(
accountType
.
GetString
().
data
()
);
rapidjson
::
Value
&
courier_name
=
document
[
"courier_name
"
];
order
.
deliveryInfo
.
driver_name
=
courier_name
.
GetString
();
rapidjson
::
Value
&
level
=
customer_obj
[
"level
"
];
order
.
customerInfo
.
account_level
=
level
.
GetString
();
rapidjson
::
Value
&
courier_phone
=
document
[
"courier_phone"
];
order
.
deliveryInfo
.
driver_phone
=
courier_phone
.
GetString
();
}
}
//顾客信息
rapidjson
::
Value
&
customer
=
document
[
"customer"
];
order
.
customerInfo
.
name
=
customer
.
GetString
();
rapidjson
::
Value
&
deliveryFee
=
orderContent_obj
[
"deliveryFee"
];
order
.
delivery_price
=
deliveryFee
.
GetInt
();
rapidjson
::
Value
&
phone
=
document
[
"phone"
];
order
.
customerInfo
.
phone
=
phone
.
GetString
();
//订单信息
{
rapidjson
::
Value
&
orders_obj
=
orderContent_obj
[
"orders"
];
rapidjson
::
Value
&
deliveryStatus
=
orders_obj
[
"deliveryStatus"
];
order
.
deliveryInfo
.
status
=
atoi
(
deliveryStatus
.
GetString
().
data
());
rapidjson
::
Value
&
deliveryStatusDesc
=
orders_obj
[
"deliveryStatusDesc"
];
order
.
deliveryInfo
.
status_desc
=
deliveryStatusDesc
.
GetString
();
rapidjson
::
Value
&
orderId
=
orders_obj
[
"orderId"
];
order
.
order_id
=
orderId
.
GetString
();
rapidjson
::
Value
&
pickupCode
=
orders_obj
[
"pickupCode"
];
order
.
pickup_code
=
pickupCode
.
GetString
();
rapidjson
::
Value
&
pickupPoint
=
orders_obj
[
"pickupPoint"
];
order
.
pickup_point
=
pickupPoint
.
GetString
();
rapidjson
::
Value
&
remark
=
orders_obj
[
"remark"
];
remark
.
GetString
();
rapidjson
::
Value
&
status
=
orders_obj
[
"status"
];
order
.
status
=
atoi
(
status
.
GetString
().
data
());
rapidjson
::
Value
&
statusDesc
=
orders_obj
[
"statusDesc"
];
order
.
status_desc
=
statusDesc
.
GetString
();
//订单商品
{
rapidjson
::
Value
&
products_array
=
orders_obj
[
"products"
];
if
(
products_array
.
IsArray
())
{
for
(
unsigned
int
i
=
0
;
i
<
products_array
.
Size
();
i
++
){
rapidjson
::
Value
&
product_obj
=
products_array
[
i
];
rapidjson
::
Value
&
address
=
document
[
"address"
];
order
.
customerInfo
.
address
=
address
.
GetString
();
productAttr
structProduct
;
//商品列表
rapidjson
::
Value
&
products_array
=
document
[
"products"
];
if
(
products_array
.
IsArray
()){
for
(
unsigned
int
i
=
0
;
i
<
products_array
.
Size
();
i
++
){
productAttr
proAttr
;
rapidjson
::
Value
&
objProductValue
=
products_array
[
i
];
rapidjson
::
Value
&
attributes
=
product_obj
[
"attributes"
];
structProduct
.
pro
.
attributes
=
attributes
.
GetString
();
rapidjson
::
Value
&
catgId
=
product_obj
[
"catgId"
];
structProduct
.
pro
.
combo_id
=
catgId
.
GetString
();
rapidjson
::
Value
&
groupIndex
=
product_obj
[
"groupIndex"
];
structProduct
.
pro
.
bom_id
=
groupIndex
.
GetString
();
rapidjson
::
Value
&
name
=
product_obj
[
"name"
];
structProduct
.
pro
.
name
=
name
.
GetString
();
rapidjson
::
Value
&
price
=
product_obj
[
"price"
];
structProduct
.
pro
.
price
=
price
.
GetInt
();
rapidjson
::
Value
&
productType
=
product_obj
[
"productType"
];
productType
.
GetString
();
rapidjson
::
Value
&
qty
=
product_obj
[
"qty"
];
structProduct
.
pro
.
qty
=
qty
.
GetInt
();
rapidjson
::
Value
&
sku
=
product_obj
[
"sku"
];
structProduct
.
pro
.
sku
=
sku
.
GetString
();
rapidjson
::
Value
&
source
=
product_obj
[
"source"
];
structProduct
.
pro
.
source
=
source
.
GetString
();
//子商品信息
{
rapidjson
::
Value
&
specs_array
=
product_obj
[
"specs"
];
if
(
specs_array
.
IsArray
())
{
for
(
unsigned
int
i
=
0
;
i
<
specs_array
.
Size
();
i
++
){
rapidjson
::
Value
&
specs_obj
=
specs_array
[
i
];
productSpec
structProductSpec
;
rapidjson
::
Value
&
name
=
specs_obj
[
"name"
];
structProductSpec
.
name
=
name
.
GetString
();
rapidjson
::
Value
&
name
=
objProductValue
[
"nam
e"
];
proAttr
.
pro
.
name
=
name
.
GetString
();
rapidjson
::
Value
&
price
=
specs_obj
[
"pric
e"
];
structProductSpec
.
price
=
price
.
GetInt
();
rapidjson
::
Value
&
pid
=
objProductValue
[
"pid
"
];
proAttr
.
pro
.
sku
=
pid
.
GetString
();
rapidjson
::
Value
&
qty
=
specs_obj
[
"qty
"
];
structProductSpec
.
qty
=
qty
.
GetInt
();
rapidjson
::
Value
&
price
=
objProductValue
[
"price"
];
proAttr
.
pro
.
price
=
price
.
GetInt
();
rapidjson
::
Value
&
sku
=
specs_obj
[
"sku"
];
structProductSpec
.
sku
=
sku
.
GetString
();
structProduct
.
vecSpec
.
push_back
(
structProductSpec
);
}
}
}
order
.
vecProducts
.
push_back
(
structProduct
);
}
}
}
}
rapidjson
::
Value
&
productAmount
=
objProductValue
[
"productAmount"
];
proAttr
.
pro
.
qty
=
atoi
(
productAmount
.
GetString
());
//支付信息
{
//TODO
//sumary未映射字段值
rapidjson
::
Value
&
payInfos_array
=
orderContent_obj
[
"payInfos"
];
if
(
payInfos_array
.
IsArray
())
{
for
(
unsigned
int
i
=
0
;
i
<
payInfos_array
.
Size
();
i
++
){
rapidjson
::
Value
&
payInfos_obj
=
payInfos_array
[
i
];
paymentDetail
detail
;
order
.
vecProducts
.
push_back
(
proAttr
);
rapidjson
::
Value
&
amount
=
payInfos_obj
[
"amount"
];
detail
.
amount
=
amount
.
GetInt
();
rapidjson
::
Value
&
payType
=
payInfos_obj
[
"payType"
];
detail
.
type
=
atoi
(
payType
.
GetString
().
data
());
rapidjson
::
Value
&
transNum
=
payInfos_obj
[
"transNum"
];
detail
.
trans_id
=
transNum
.
GetString
();
order
.
payInfo
.
vecDetail
.
push_back
(
detail
);
}
}
}
rapidjson
::
Value
&
payType
=
orderContent_obj
[
"payType"
];
payType
.
GetString
();
//积分信息
{
rapidjson
::
Value
&
points_obj
=
orderContent_obj
[
"points"
];
rapidjson
::
Value
&
totalPoint
=
points_obj
[
"totalPoint"
];
char
temp
[
20
]
=
{
0
};
int
iPoint
=
totalPoint
.
GetInt
();
itoa
(
iPoint
,
temp
,
10
);
order
.
bonusInfo
.
summary
=
temp
;
//积分信息详情
{
rapidjson
::
Value
&
pointDetails_array
=
points_obj
[
"pointDetails"
];
if
(
pointDetails_array
.
IsArray
())
{
for
(
unsigned
int
i
=
0
;
i
<
pointDetails_array
.
Size
();
i
++
){
rapidjson
::
Value
&
pointDetails_obj
=
pointDetails_array
[
i
];
bonusDetail
detail
;
rapidjson
::
Value
&
bomId
=
pointDetails_obj
[
"bomId"
];
bomId
.
GetString
();
rapidjson
::
Value
&
comboId
=
pointDetails_obj
[
"comboId"
];
comboId
.
GetString
();
rapidjson
::
Value
&
desc
=
pointDetails_obj
[
"desc"
];
detail
.
desc
=
desc
.
GetString
();
rapidjson
::
Value
&
groupId
=
pointDetails_obj
[
"groupId"
];
groupId
.
GetString
();
rapidjson
::
Value
&
point
=
pointDetails_obj
[
"point"
];
detail
.
point
=
point
.
GetInt
();
rapidjson
::
Value
&
sku
=
pointDetails_obj
[
"sku"
];
detail
.
sku
=
sku
.
GetString
();
rapidjson
::
Value
&
type
=
pointDetails_obj
[
"type"
];
detail
.
type
=
atoi
(
type
.
GetString
().
data
());
order
.
bonusInfo
.
vecDetail
.
push_back
(
detail
);
}
}
}
}
//优惠信息
{
rapidjson
::
Value
&
promotions_obj
=
orderContent_obj
[
"promotions"
];
rapidjson
::
Value
&
totalDiscount
=
promotions_obj
[
"totalDiscount"
];
totalDiscount
.
GetInt
();
rapidjson
::
Value
&
totalOriginalPrice
=
promotions_obj
[
"totalOriginalPrice"
];
totalOriginalPrice
.
GetInt
();
rapidjson
::
Value
&
totalPrmotionPrice
=
promotions_obj
[
"totalPrmotionPrice"
];
totalPrmotionPrice
.
GetInt
();
//优惠信息详情
{
rapidjson
::
Value
&
promtionDetails_array
=
promotions_obj
[
"promtionDetails"
];
if
(
promtionDetails_array
.
IsArray
())
{
for
(
unsigned
int
i
=
0
;
i
<
promtionDetails_array
.
Size
();
i
++
){
rapidjson
::
Value
&
promtionDetails_obj
=
promtionDetails_array
[
i
];
rapidjson
::
Value
&
bomId
=
promtionDetails_obj
[
"bomId"
];
bomId
.
GetString
();
rapidjson
::
Value
&
comboId
=
promtionDetails_obj
[
"comboId"
];
comboId
.
GetString
();
rapidjson
::
Value
&
desc
=
promtionDetails_obj
[
"desc"
];
desc
.
GetString
();
rapidjson
::
Value
&
discount
=
promtionDetails_obj
[
"discount"
];
discount
.
GetInt
();
rapidjson
::
Value
&
groupId
=
promtionDetails_obj
[
"groupId"
];
groupId
.
GetString
();
rapidjson
::
Value
&
originalPrice
=
promtionDetails_obj
[
"originalPrice"
];
originalPrice
.
GetInt
();
rapidjson
::
Value
&
pcode
=
promtionDetails_obj
[
"pcode"
];
pcode
.
GetString
();
rapidjson
::
Value
&
prmotionPrice
=
promtionDetails_obj
[
"prmotionPrice"
];
prmotionPrice
.
GetInt
();
rapidjson
::
Value
&
sku
=
promtionDetails_obj
[
"sku"
];
sku
.
GetString
();
rapidjson
::
Value
&
type
=
promtionDetails_obj
[
"type"
];
type
.
GetString
();
}
}
}
}
rapidjson
::
Value
&
sessionId
=
orderContent_obj
[
"sessionId"
];
sessionId
.
GetString
();
rapidjson
::
Value
&
totalAmount
=
orderContent_obj
[
"totalAmount"
];
order
.
total_price
=
totalAmount
.
GetInt
();
rapidjson
::
Value
&
totalDiscount
=
orderContent_obj
[
"totalDiscount"
];
order
.
reduced_price
=
totalDiscount
.
GetInt
();
}
//第三方商户信息
{
rapidjson
::
Value
&
sellerInfo_obj
=
document
[
"sellerInfo"
];
rapidjson
::
Value
&
sellerId
=
sellerInfo_obj
[
"sellerId"
];
sellerId
.
GetString
();
rapidjson
::
Value
&
sellerName
=
sellerInfo_obj
[
"sellerName"
];
sellerName
.
GetString
();
}
//门店信息
{
rapidjson
::
Value
&
shopInfo_obj
=
document
[
"shopInfo"
];
rapidjson
::
Value
&
barCounter
=
shopInfo_obj
[
"barCounter"
];
barCounter
.
GetString
();
rapidjson
::
Value
&
vOperator
=
shopInfo_obj
[
"operator"
];
vOperator
.
GetString
();
rapidjson
::
Value
&
posId
=
shopInfo_obj
[
"posId"
];
order
.
storeInfo
.
pos_id
=
posId
.
GetString
();
rapidjson
::
Value
&
storeId
=
shopInfo_obj
[
"storeId"
];
order
.
storeInfo
.
store_id
=
storeId
.
GetString
();
//自助机信息
rapidjson
::
Value
&
selfHelpMac_obj
=
shopInfo_obj
[
"selfHelpMac"
];
rapidjson
::
Value
&
id
=
selfHelpMac_obj
[
"id"
];
order
.
storeInfo
.
vem_id
=
id
.
GetString
();
rapidjson
::
Value
&
shelf
=
selfHelpMac_obj
[
"shelf"
];
order
.
storeInfo
.
vem_shelf
=
shelf
.
GetString
();
}
}
return
true
;
}
...
...
@@ -323,7 +584,7 @@ bool JsonModule::convertDataOds2Pos(const std::string &data, std::string &result
if
(
ORDERSTATUS_NEW
==
order
.
status
){
result
=
_convertToNewOrderJson
(
order
);
}
else
if
(
ORDERSTATUS_CONFIRMED
==
order
.
status
||
ORDERSTATUS_CANCELED
==
order
.
status
||
ORDERSTATUS_SHIPPING
==
order
.
status
||
ORDERSTATUS_COMPLETE
==
order
.
status
||
ORDERSTATUS_REFUND_COMPLETE
){
else
if
(
ORDERSTATUS_CONFIRMED
==
order
.
status
||
ORDERSTATUS_CANCELED
==
order
.
status
||
ORDERSTATUS_SHIPPING
==
order
.
status
||
ORDERSTATUS_COMPLETE
==
order
.
status
){
orderStatusObj
statusObj
;
_getStatusObj
(
order
,
statusObj
);
result
=
_convertToOrderStatusJson
(
statusObj
);
...
...
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