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
f39d547f
Commit
f39d547f
authored
Mar 30, 2018
by
guanghui.cui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加订单备注字段
parent
1753cf58
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
12 deletions
+26
-12
base/CommonStruct.h
+2
-1
src/JsonModule.cpp
+18
-5
src/main.cpp
+6
-6
No files found.
base/CommonStruct.h
View file @
f39d547f
...
...
@@ -130,7 +130,7 @@ struct promotions
std
::
string
sku
;
//商品编号
int
originalPrice
=
0
;
//原始价格
int
discount
=
0
;
//折扣
int
prmotionPrice
=
0
;
//优惠价格
int
pr
o
motionPrice
=
0
;
//优惠价格
std
::
string
giftSku
;
//赠品的编码
int
giftQty
=
0
;
//赠品的数量
};
...
...
@@ -173,6 +173,7 @@ struct orderObj
int
status
=
0
;
//订单状态
int
ods_status
=
0
;
//ods订单状态
std
::
string
status_desc
;
//订单状态描述
std
::
string
remark
;
//订单备注
int
total_price
=
0
;
//订单总价
int
delivery_price
=
0
;
//配送费
int
reduced_price
=
0
;
//折扣总金额
...
...
src/JsonModule.cpp
View file @
f39d547f
...
...
@@ -232,11 +232,17 @@ bool JsonModule::getPushOrders(IN const char* json,OUT orderObj &order)
order
.
pickup_code
=
_getPickupCodeString
(
order
.
channel
,
pickupcode
);
order
.
pickup_point
=
GetJsonStringSafe
(
orders_obj
,
"pickupPoint"
);
GetJsonStringSafe
(
orders_obj
,
"remark"
);
order
.
remark
=
GetJsonStringSafe
(
orders_obj
,
"remark"
);
order
.
status
=
atoi
(
GetJsonStringSafe
(
orders_obj
,
"status"
));
order
.
ods_status
=
order
.
status
;
// int iCancelStatus = atoi(GetJsonStringSafe(orders_obj,"cancelStatus"));
// if(ODS_ORDERSTATUS_REFUND_FULL==iCancelStatus||ODS_ORDERSTATUS_REFUND_AGREE==iCancelStatus||ODS_ORDERSTATUS_REFUND_DISAGREE==iCancelStatus){
// order.status=iCancelStatus;
// order.ods_status=order.status;
// }
order
.
status_desc
=
GetJsonStringSafe
(
orders_obj
,
"statusDesc"
);
//订单商品
...
...
@@ -296,6 +302,10 @@ bool JsonModule::getPushOrders(IN const char* json,OUT orderObj &order)
paymentDetail
detail
;
detail
.
amount
=
GetJsonIntSafe
(
payInfos_obj
,
"amount"
);
//非自配送,第一种支付方式减去配送费
if
(
"2"
!=
delivery_type
&&
0
==
i
){
detail
.
amount
=
GetJsonIntSafe
(
payInfos_obj
,
"amount"
)
-
GetJsonIntSafe
(
orderContent_obj
,
"deliveryFee"
);
}
//支付类型需要拼接 channel+payType
std
::
string
_strType
=
order
.
channel
+
GetJsonStringSafe
(
payInfos_obj
,
"payType"
);
...
...
@@ -318,7 +328,7 @@ bool JsonModule::getPushOrders(IN const char* json,OUT orderObj &order)
{
GetJsonIntSafe
(
promotions_obj
,
"totalDiscount"
);
GetJsonIntSafe
(
promotions_obj
,
"totalOriginalPrice"
);
GetJsonIntSafe
(
promotions_obj
,
"totalPrmotionPrice"
);
GetJsonIntSafe
(
promotions_obj
,
"totalPr
o
motionPrice"
);
//优惠信息详情
if
(
promotions_obj
.
HasMember
(
"promtionDetails"
))
...
...
@@ -335,7 +345,7 @@ bool JsonModule::getPushOrders(IN const char* json,OUT orderObj &order)
detail
.
desc
=
GetJsonStringSafe
(
promtionDetails_obj
,
"desc"
);
detail
.
sku
=
GetJsonStringSafe
(
promtionDetails_obj
,
"sku"
);
detail
.
originalPrice
=
GetJsonIntSafe
(
promtionDetails_obj
,
"originalPrice"
);
detail
.
pr
motionPrice
=
GetJsonIntSafe
(
promtionDetails_obj
,
"pr
motionPrice"
);
detail
.
pr
omotionPrice
=
GetJsonIntSafe
(
promtionDetails_obj
,
"pro
motionPrice"
);
detail
.
discount
=
GetJsonIntSafe
(
promtionDetails_obj
,
"discount"
);
if
(
promtionDetails_obj
.
HasMember
(
"gifts"
)){
rapidjson
::
Value
&
gifts_obj
=
orderContent_obj
[
"gifts"
];
...
...
@@ -962,6 +972,9 @@ std::string JsonModule::_convertToNewOrderJson(orderObj &obj)
writer
.
Key
(
"status_desc"
);
writer
.
String
(
obj
.
status_desc
.
c_str
());
writer
.
Key
(
"remark"
);
writer
.
String
(
obj
.
remark
.
c_str
());
writer
.
Key
(
"total_price"
);
writer
.
Int
(
obj
.
total_price
);
...
...
@@ -1220,8 +1233,8 @@ std::string JsonModule::_convertToNewOrderJson(orderObj &obj)
writer
.
Key
(
"discount"
);
writer
.
Int
(
obj
.
vecPromotions
[
i
].
discount
);
writer
.
Key
(
"prmotionPrice"
);
writer
.
Int
(
obj
.
vecPromotions
[
i
].
prmotionPrice
);
writer
.
Key
(
"pr
o
motionPrice"
);
writer
.
Int
(
obj
.
vecPromotions
[
i
].
pr
o
motionPrice
);
writer
.
Key
(
"giftSku"
);
writer
.
String
(
obj
.
vecPromotions
[
i
].
giftSku
.
c_str
());
...
...
src/main.cpp
View file @
f39d547f
...
...
@@ -85,10 +85,10 @@ void* listen_pos_func(void* arg)
{
g_init_data_ods_back
.
clear
();
// g_init_data = posRequestData;
LOG
(
INFO
)
<<
"POS req data
.
:"
<<
posRequestData
.
c_str
();
LOG
(
INFO
)
<<
"POS req data:"
<<
posRequestData
.
c_str
();
jsonTool
.
convertInitDataPos2Ods
(
posRequestData
,
g_init_data
);
//jsonTool.getPosResponseData(100, "successful!", responseData);
LOG
(
INFO
)
<<
"POS init data
.
:"
<<
g_init_data
.
c_str
();
LOG
(
INFO
)
<<
"POS init data:"
<<
g_init_data
.
c_str
();
//等待ods返回初始化结果
while
(
true
){
if
(
!
g_init_data_ods_back
.
empty
()){
...
...
@@ -360,12 +360,12 @@ int main()
if
(
ods
.
receive
(
odsPushData
)
)
{
LOG
(
INFO
)
<<
"----------------
recved ODS data---
---------------."
;
LOG
(
INFO
)
<<
"----------------
ODS ===>> PLUGIN
---------------."
;
LOG
(
INFO
)
<<
odsPushData
;
if
(
!
jsonTool
.
isHeartbeatData
(
odsPushData
.
data
())){
if
(
jsonTool
.
convertDataOds2Pos
(
odsPushData
,
pushPosData
)
)
{
LOG
(
INFO
)
<<
"
********convert data to pos************
"
;
LOG
(
INFO
)
<<
"
----------- PLUGIN ===>> POS ------------
"
;
LOG
(
INFO
)
<<
pushPosData
;
if
(
!
order_send_to_pos
(
pushPosData
,
odsPushData
,
responseData
)){
write_failed_order
(
odsPushData
);
...
...
@@ -382,7 +382,7 @@ int main()
}
// TODO待加入重试机制
LOG
(
INFO
)
<<
"
pos response data convert to
ODS:"
<<
responseData
.
data
();
LOG
(
INFO
)
<<
"
PLUGIN ===>>
ODS:"
<<
responseData
.
data
();
//test
//responseData="{\"fm_cmd\": 2,\"order_id\" : \"1234\",\"status\" : 1,\"channel\" : \"1234\",\"status_code\" : 100,\"msg\" : \"\"}";
...
...
@@ -421,7 +421,7 @@ bool order_send_to_pos(IN std::string &order_json,IN std::string &ods_json,OUT s
char
tmpBuf
[
BUF_SIZE
]
=
{
0
};
if
(
pos
.
read
(
tmpBuf
,
sizeof
(
tmpBuf
))
)
{
LOG
(
INFO
)
<<
"
pos response data
:"
<<
tmpBuf
;
LOG
(
INFO
)
<<
"
POS ===>> PLUGIN
:"
<<
tmpBuf
;
tmp
=
tmpBuf
;
//pos发送过来的数据为gb2312编码,需要转换为utf8
//std::string tmpUtf8= charset_g2u(tmp);
...
...
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