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
5c90a39c
Commit
5c90a39c
authored
Mar 12, 2021
by
wuyang.zou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New Feature: 新增动态扩展字段: extendedAttributes, 以后新增独立意义的字段时,将不需要再升级程序;
Version: 1.2.6 Rc git commit -m
parent
15320fc4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
75 additions
and
1 deletions
+75
-1
base/CommonStruct.h
+9
-0
src/JsonModule.cpp
+62
-0
src/JsonModule.h
+1
-1
src/main.cpp
+3
-0
No files found.
base/CommonStruct.h
View file @
5c90a39c
...
@@ -43,6 +43,8 @@ struct paymentDetail
...
@@ -43,6 +43,8 @@ struct paymentDetail
std
::
string
trans_id
;
//支付交易号
std
::
string
trans_id
;
//支付交易号
std
::
string
account_id
;
//支付账户号
std
::
string
account_id
;
//支付账户号
std
::
string
pay_code
;
//支付码
std
::
string
pay_code
;
//支付码
int
platformServiceFee
;
//平台服务费 单位:分
int
performanceServiceFee
;
//履约服务费 单位 : 分
};
};
//支付信息
//支付信息
...
@@ -218,6 +220,13 @@ struct orderObj
...
@@ -218,6 +220,13 @@ struct orderObj
std
::
vector
<
promotions
>
vecPromotions
;
//促销列表
std
::
vector
<
promotions
>
vecPromotions
;
//促销列表
std
::
vector
<
ecoupon
>
vecEcoupon
;
//电子点标
std
::
vector
<
ecoupon
>
vecEcoupon
;
//电子点标
std
::
vector
<
orderCoupon
>
vecOrderCoupons
;
//订单优惠券信息
std
::
vector
<
orderCoupon
>
vecOrderCoupons
;
//订单优惠券信息
std
::
string
extendedAttributes
;
//订单扩展属性: 存放Json对象对应的字符串;
// extendedAttributes.discountAmount 会员⽇促销折扣总额单位:分
// extendedAttributes.discountThreshold 折扣门槛金额 单位:分
// extendedAttributes.discountMax 最大折扣额度 单位:分
// extendedAttributes.discountRate 折扣率(10-100)例:10:一折,100:不打折
// extendedAttributes.memberDay 是否是会员日 0:不是 1:是
};
};
//订单状态
//订单状态
...
...
src/JsonModule.cpp
View file @
5c90a39c
...
@@ -277,6 +277,8 @@ bool JsonModule::getPushOrders(IN const char* json,OUT orderObj &order)
...
@@ -277,6 +277,8 @@ bool JsonModule::getPushOrders(IN const char* json,OUT orderObj &order)
detail
.
trans_id
=
GetJsonStringSafe
(
payInfos_obj
,
"transNum"
);
detail
.
trans_id
=
GetJsonStringSafe
(
payInfos_obj
,
"transNum"
);
detail
.
account_id
=
GetJsonStringSafe
(
payInfos_obj
,
"accountId"
);
detail
.
account_id
=
GetJsonStringSafe
(
payInfos_obj
,
"accountId"
);
detail
.
pay_code
=
GetJsonStringSafe
(
payInfos_obj
,
"payCode"
);
detail
.
pay_code
=
GetJsonStringSafe
(
payInfos_obj
,
"payCode"
);
detail
.
platformServiceFee
=
GetJsonIntSafe
(
payInfos_obj
,
"platformServiceFee"
);
detail
.
performanceServiceFee
=
GetJsonIntSafe
(
payInfos_obj
,
"performanceServiceFee"
);
order
.
payInfo
.
vecDetail
.
push_back
(
detail
);
order
.
payInfo
.
vecDetail
.
push_back
(
detail
);
}
}
...
@@ -421,6 +423,15 @@ bool JsonModule::getPushOrders(IN const char* json,OUT orderObj &order)
...
@@ -421,6 +423,15 @@ bool JsonModule::getPushOrders(IN const char* json,OUT orderObj &order)
}
}
}
}
//订单扩展属性信息
if
(
orderContent_obj
.
HasMember
(
"extendedAttributes"
))
{
rapidjson
::
Value
&
extAttributes
=
orderContent_obj
[
"extendedAttributes"
];
rapidjson
::
StringBuffer
subBuff
;
rapidjson
::
Writer
<
rapidjson
::
StringBuffer
>
jWriter
(
subBuff
);
extAttributes
.
Accept
(
jWriter
);
order
.
extendedAttributes
=
subBuff
.
GetString
();
}
}
}
//第三方商户信息
//第三方商户信息
if
(
document
.
HasMember
(
"sellerInfo"
)
)
{
if
(
document
.
HasMember
(
"sellerInfo"
)
)
{
...
@@ -934,6 +945,7 @@ std::string JsonModule::_convertToNewOrderJson(orderObj &obj)
...
@@ -934,6 +945,7 @@ std::string JsonModule::_convertToNewOrderJson(orderObj &obj)
rapidjson
::
Writer
<
rapidjson
::
StringBuffer
>
writer
(
buffer
);
rapidjson
::
Writer
<
rapidjson
::
StringBuffer
>
writer
(
buffer
);
writer
.
StartObject
();
writer
.
StartObject
();
{
writer
.
Key
(
"fm_cmd"
);
writer
.
Key
(
"fm_cmd"
);
writer
.
Int
(
REQUEST_TYPE_NEWORDER_PUSH
);
writer
.
Int
(
REQUEST_TYPE_NEWORDER_PUSH
);
writer
.
Key
(
"channel"
);
writer
.
Key
(
"channel"
);
...
@@ -982,8 +994,10 @@ std::string JsonModule::_convertToNewOrderJson(orderObj &obj)
...
@@ -982,8 +994,10 @@ std::string JsonModule::_convertToNewOrderJson(orderObj &obj)
writer
.
Int
(
obj
.
totalCouponDiscount
);
writer
.
Int
(
obj
.
totalCouponDiscount
);
writer
.
Key
(
"totalExcessiveCharge"
);
writer
.
Key
(
"totalExcessiveCharge"
);
writer
.
Int
(
obj
.
totalExcessiveCharge
);
writer
.
Int
(
obj
.
totalExcessiveCharge
);
}
//----------------门店信息----------------
//----------------门店信息----------------
{
writer
.
Key
(
"store"
);
writer
.
Key
(
"store"
);
writer
.
StartObject
();
writer
.
StartObject
();
writer
.
Key
(
"store_id"
);
writer
.
Key
(
"store_id"
);
...
@@ -1000,9 +1014,11 @@ std::string JsonModule::_convertToNewOrderJson(orderObj &obj)
...
@@ -1000,9 +1014,11 @@ std::string JsonModule::_convertToNewOrderJson(orderObj &obj)
writer
.
String
(
obj
.
storeInfo
.
child_store_id
.
c_str
());
writer
.
String
(
obj
.
storeInfo
.
child_store_id
.
c_str
());
writer
.
EndObject
();
writer
.
EndObject
();
}
//----------------门店信息 结束-----------
//----------------门店信息 结束-----------
//----------------配送信息----------------
//----------------配送信息----------------
{
writer
.
Key
(
"delivery"
);
writer
.
Key
(
"delivery"
);
writer
.
StartObject
();
writer
.
StartObject
();
...
@@ -1018,9 +1034,11 @@ std::string JsonModule::_convertToNewOrderJson(orderObj &obj)
...
@@ -1018,9 +1034,11 @@ std::string JsonModule::_convertToNewOrderJson(orderObj &obj)
writer
.
String
(
obj
.
deliveryInfo
.
driver_phone
.
c_str
());
writer
.
String
(
obj
.
deliveryInfo
.
driver_phone
.
c_str
());
writer
.
EndObject
();
writer
.
EndObject
();
}
//----------------配送信息 结束-----------
//----------------配送信息 结束-----------
//----------------点取分离----------------
//----------------点取分离----------------
{
writer
.
Key
(
"appointment"
);
writer
.
Key
(
"appointment"
);
writer
.
StartObject
();
writer
.
StartObject
();
...
@@ -1030,9 +1048,11 @@ std::string JsonModule::_convertToNewOrderJson(orderObj &obj)
...
@@ -1030,9 +1048,11 @@ std::string JsonModule::_convertToNewOrderJson(orderObj &obj)
writer
.
Int
(
obj
.
appointmentInfo
.
is_appointment
);
writer
.
Int
(
obj
.
appointmentInfo
.
is_appointment
);
writer
.
EndObject
();
writer
.
EndObject
();
}
//----------------点取分离 结束-----------
//----------------点取分离 结束-----------
//----------------顾客信息----------------
//----------------顾客信息----------------
{
writer
.
Key
(
"customer"
);
writer
.
Key
(
"customer"
);
writer
.
StartObject
();
writer
.
StartObject
();
...
@@ -1052,9 +1072,11 @@ std::string JsonModule::_convertToNewOrderJson(orderObj &obj)
...
@@ -1052,9 +1072,11 @@ std::string JsonModule::_convertToNewOrderJson(orderObj &obj)
writer
.
String
(
obj
.
customerInfo
.
card_no
.
c_str
());
writer
.
String
(
obj
.
customerInfo
.
card_no
.
c_str
());
writer
.
EndObject
();
writer
.
EndObject
();
}
//----------------顾客信息 结束-----------
//----------------顾客信息 结束-----------
//----------------商品信息----------------
//----------------商品信息----------------
{
writer
.
Key
(
"products"
);
writer
.
Key
(
"products"
);
writer
.
StartArray
();
writer
.
StartArray
();
...
@@ -1109,9 +1131,11 @@ std::string JsonModule::_convertToNewOrderJson(orderObj &obj)
...
@@ -1109,9 +1131,11 @@ std::string JsonModule::_convertToNewOrderJson(orderObj &obj)
}
}
writer
.
EndArray
();
writer
.
EndArray
();
}
//----------------商品信息 结束-----------
//----------------商品信息 结束-----------
//----------------付款明细----------------
//----------------付款明细----------------
{
writer
.
Key
(
"payment"
);
writer
.
Key
(
"payment"
);
writer
.
StartObject
();
writer
.
StartObject
();
...
@@ -1134,15 +1158,21 @@ std::string JsonModule::_convertToNewOrderJson(orderObj &obj)
...
@@ -1134,15 +1158,21 @@ std::string JsonModule::_convertToNewOrderJson(orderObj &obj)
writer
.
String
(
obj
.
payInfo
.
vecDetail
[
i
].
account_id
.
c_str
());
writer
.
String
(
obj
.
payInfo
.
vecDetail
[
i
].
account_id
.
c_str
());
writer
.
Key
(
"pay_code"
);
writer
.
Key
(
"pay_code"
);
writer
.
String
(
obj
.
payInfo
.
vecDetail
[
i
].
pay_code
.
c_str
());
writer
.
String
(
obj
.
payInfo
.
vecDetail
[
i
].
pay_code
.
c_str
());
writer
.
Key
(
"platformServiceFee"
);
writer
.
Int
(
obj
.
payInfo
.
vecDetail
[
i
].
platformServiceFee
);
writer
.
Key
(
"performanceServiceFee"
);
writer
.
Int
(
obj
.
payInfo
.
vecDetail
[
i
].
performanceServiceFee
);
writer
.
EndObject
();
writer
.
EndObject
();
}
}
writer
.
EndArray
();
writer
.
EndArray
();
//-----------------end 付款详情--------------------
//-----------------end 付款详情--------------------
writer
.
EndObject
();
writer
.
EndObject
();
}
//----------------付款明细 结束-----------
//----------------付款明细 结束-----------
//----------------消费积分----------------
//----------------消费积分----------------
{
writer
.
Key
(
"bonusBasic"
);
writer
.
Key
(
"bonusBasic"
);
writer
.
Int
(
obj
.
bonus_basic
);
writer
.
Int
(
obj
.
bonus_basic
);
writer
.
Key
(
"bonusExtra"
);
writer
.
Key
(
"bonusExtra"
);
...
@@ -1193,9 +1223,11 @@ std::string JsonModule::_convertToNewOrderJson(orderObj &obj)
...
@@ -1193,9 +1223,11 @@ std::string JsonModule::_convertToNewOrderJson(orderObj &obj)
writer
.
EndObject
();
writer
.
EndObject
();
}
}
writer
.
EndArray
();
writer
.
EndArray
();
}
//----------------消费积分 结束-----------
//----------------消费积分 结束-----------
//----------------促销----------------
//----------------促销----------------
{
writer
.
Key
(
"promotions"
);
writer
.
Key
(
"promotions"
);
writer
.
StartArray
();
writer
.
StartArray
();
for
(
unsigned
int
i
=
0
;
i
<
obj
.
vecPromotions
.
size
();
i
++
)
{
for
(
unsigned
int
i
=
0
;
i
<
obj
.
vecPromotions
.
size
();
i
++
)
{
...
@@ -1229,9 +1261,11 @@ std::string JsonModule::_convertToNewOrderJson(orderObj &obj)
...
@@ -1229,9 +1261,11 @@ std::string JsonModule::_convertToNewOrderJson(orderObj &obj)
writer
.
EndObject
();
writer
.
EndObject
();
}
}
writer
.
EndArray
();
writer
.
EndArray
();
}
//----------------促销 结束-----------
//----------------促销 结束-----------
//----------------电子点标----------------
//----------------电子点标----------------
{
writer
.
Key
(
"ecoupon"
);
writer
.
Key
(
"ecoupon"
);
writer
.
StartArray
();
writer
.
StartArray
();
for
(
unsigned
int
i
=
0
;
i
<
obj
.
vecEcoupon
.
size
();
i
++
)
{
for
(
unsigned
int
i
=
0
;
i
<
obj
.
vecEcoupon
.
size
();
i
++
)
{
...
@@ -1257,9 +1291,11 @@ std::string JsonModule::_convertToNewOrderJson(orderObj &obj)
...
@@ -1257,9 +1291,11 @@ std::string JsonModule::_convertToNewOrderJson(orderObj &obj)
writer
.
EndObject
();
writer
.
EndObject
();
}
}
writer
.
EndArray
();
writer
.
EndArray
();
}
//----------------电子点标 结束-----------
//----------------电子点标 结束-----------
//----------------订单优惠券信息-----------
//----------------订单优惠券信息-----------
{
writer
.
Key
(
"orderCoupons"
);
writer
.
Key
(
"orderCoupons"
);
writer
.
StartArray
();
writer
.
StartArray
();
for
(
unsigned
int
i
=
0
;
i
<
obj
.
vecOrderCoupons
.
size
();
i
++
)
{
for
(
unsigned
int
i
=
0
;
i
<
obj
.
vecOrderCoupons
.
size
();
i
++
)
{
...
@@ -1303,10 +1339,36 @@ std::string JsonModule::_convertToNewOrderJson(orderObj &obj)
...
@@ -1303,10 +1339,36 @@ std::string JsonModule::_convertToNewOrderJson(orderObj &obj)
writer
.
EndObject
();
writer
.
EndObject
();
}
}
writer
.
EndArray
();
writer
.
EndArray
();
}
//----------------订单优惠券信息 结束----
//----------------订单优惠券信息 结束----
writer
.
EndObject
();
writer
.
EndObject
();
//----------------订单扩展信息----------------
if
(
obj
.
extendedAttributes
.
length
())
{
rapidjson
::
Document
extAttributesDoc
;
extAttributesDoc
.
Parse
(
obj
.
extendedAttributes
.
c_str
());
if
(
extAttributesDoc
.
HasParseError
())
{
// 通过HasParseError()来判断解析是否成功
LOG
(
ERROR
)
<<
"obj.extendedAttributes parse error:"
<<
extAttributesDoc
.
GetParseError
()
<<
":"
<<
extAttributesDoc
.
GetErrorOffset
();
}
else
{
rapidjson
::
Document
orderConvertedDoc
;
orderConvertedDoc
.
Parse
(
buffer
.
GetString
());
if
(
extAttributesDoc
.
HasParseError
())
{
LOG
(
ERROR
)
<<
" Origin Order Buffer parse error:"
<<
orderConvertedDoc
.
GetParseError
()
<<
":"
<<
orderConvertedDoc
.
GetErrorOffset
();
}
else
{
orderConvertedDoc
.
AddMember
(
"extendedAttributes"
,
extAttributesDoc
,
orderConvertedDoc
.
GetAllocator
());
rapidjson
::
StringBuffer
bufferConvert
;
rapidjson
::
Writer
<
rapidjson
::
StringBuffer
>
writerConvert
(
bufferConvert
);
orderConvertedDoc
.
Accept
(
writerConvert
);
return
bufferConvert
.
GetString
();
}
}
}
//----------------订单扩展信息 结束----
return
buffer
.
GetString
();
return
buffer
.
GetString
();
}
}
...
...
src/JsonModule.h
View file @
5c90a39c
...
@@ -12,7 +12,7 @@ extern std::string g_pos_id;
...
@@ -12,7 +12,7 @@ extern std::string g_pos_id;
extern
bool
g_pos_ismaster
;
extern
bool
g_pos_ismaster
;
#define VERSION "1.2.
4
RC" //版本号;
#define VERSION "1.2.
6
RC" //版本号;
class
JsonModule
class
JsonModule
...
...
src/main.cpp
View file @
5c90a39c
...
@@ -314,10 +314,13 @@ int main(int argc,char *argv[])
...
@@ -314,10 +314,13 @@ int main(int argc,char *argv[])
#ifdef WIN32
#ifdef WIN32
// Test Add New Feature Convert Result: Column Field
// Test Add New Feature Convert Result: Column Field
std
::
string
testOrderJson
=
jsonToolTemp
.
getTestOrderJson
();
std
::
string
testOrderJson
=
jsonToolTemp
.
getTestOrderJson
();
LOG
(
INFO
)
<<
"----------- Plugin Read Local Test Order File Success ------------"
<<
testOrderJson
<<
'\n'
;
std
::
string
convertTestOrderJson
=
jsonToolTemp
.
getConvertOrderJson
(
testOrderJson
);
std
::
string
convertTestOrderJson
=
jsonToolTemp
.
getConvertOrderJson
(
testOrderJson
);
if
(
testOrderJson
.
length
()
&&
convertTestOrderJson
.
length
()
)
{
if
(
testOrderJson
.
length
()
&&
convertTestOrderJson
.
length
()
)
{
LOG
(
INFO
)
<<
"----------- Plugin Read&Convert Local Test Order File Success ------------"
;
LOG
(
INFO
)
<<
"----------- Plugin Read&Convert Local Test Order File Success ------------"
;
LOG
(
INFO
)
<<
charset_u2g
(
convertTestOrderJson
);
LOG
(
INFO
)
<<
charset_u2g
(
convertTestOrderJson
);
LOG
(
INFO
)
<<
"----------No charset_u2g(*)-------------"
;
LOG
(
INFO
)
<<
convertTestOrderJson
;
}
else
{
}
else
{
LOG
(
INFO
)
<<
"----------- Plugin Read&Convert Local Test Order File Failed------------"
;
LOG
(
INFO
)
<<
"----------- Plugin Read&Convert Local Test Order File Failed------------"
;
}
}
...
...
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