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
d14f35eb
Commit
d14f35eb
authored
Feb 13, 2019
by
guanghui.cui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加咖啡小程序订单状态,以及处理这些状态
parent
415d5e59
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
79 additions
and
24 deletions
+79
-24
base/BaseDefine.h
+6
-4
src/JsonModule.cpp
+66
-18
src/JsonModule.h
+2
-0
src/main.cpp
+5
-2
No files found.
base/BaseDefine.h
View file @
d14f35eb
...
...
@@ -43,6 +43,8 @@
//咖啡小程序 插件向ods请求码
#define PLUGIN_TO_ODS_COFFEE_REFUND 400011 //pos退款(咖啡小程序)
#define PLUGIN_TO_ODS_COFFEE_MAKEING_DONE 400010 //制作完成(咖啡小程序)
#define PLUGIN_TO_ODS_COFFEE_DONE 40007 //已完成(咖啡小程序)
//配送类型对照表
#define DELIVERY_TYPE_SELF "self" //自配送
...
...
@@ -92,7 +94,9 @@
#define OPERATION_POS_APPOINTMENT_CONFIRM 1019 //确认接单(点取分离)
#define OPERATION_POS_SCANCODE_DONE 1020 //已完成(扫码购)
#define OPERATION_POS_SCANCODE_REFUND 1021 //pos退款(扫码购)
#define OPERATION_POS_COFFEE_REFUND 1022 //pos退款(咖啡小程序)
#define OPERATION_POS_COFFEE_MAKEING_DONE 1030 //制作完成(咖啡小程序)
#define OPERATION_POS_COFFEE_DONE 1031 //已完成(咖啡小程序)
#define OPERATION_POS_COFFEE_REFUND 1032 //pos退款(咖啡小程序)
/***********************************
...
...
@@ -129,10 +133,8 @@
#define ODS_ORDERSTATUS_COFFEE_PAID 40004 //已支付(咖啡小程序)
#define ODS_ORDERSTATUS_COFFEE_REFUND_USER 40005 //用户退款申请成功(咖啡小程序)
#define ODS_ORDERSTATUS_COFFEE_CONFIRMED 40006 //已接单(咖啡小程序)
#define ODS_ORDERSTATUS_COFFEE_DONE 40007 //已完成(咖啡小程序)
#define ODS_ORDERSTATUS_COFFEE_SHIPPING 40008 //配送中(咖啡小程序)
#define ODS_ORDERSTATUS_COFFEE_MAKED 40010 //制作完成(咖啡小程序)
#define ODS_ORDERSTATUS_COFFEE_DONE 40009 //已完成(咖啡小程序)
//推送类型
#define ODS_PUSH_TYPE_HEARTBEAT 3 //心跳
...
...
src/JsonModule.cpp
View file @
d14f35eb
...
...
@@ -219,8 +219,9 @@ bool JsonModule::getPushOrders(IN const char* json,OUT orderObj &order)
if
(
orderContent_obj
.
HasMember
(
"appointmentVO"
))
{
order
.
appointmentInfo
.
appointment_time
=
GetJsonStringSafe
(
orderContent_obj
,
"appointmentTime"
);
order
.
appointmentInfo
.
is_appointment
=
GetJsonIntSafe
(
orderContent_obj
,
"isAppointment"
);
rapidjson
::
Value
&
appointment_obj
=
orderContent_obj
[
"appointmentVO"
];
order
.
appointmentInfo
.
appointment_time
=
GetJsonStringSafe
(
appointment_obj
,
"appointmentTime"
);
order
.
appointmentInfo
.
is_appointment
=
GetJsonIntSafe
(
appointment_obj
,
"isAppointment"
);
}
//自配送
...
...
@@ -731,7 +732,10 @@ bool JsonModule::getPosResponseData(const std::string &odsResponse,IN const std:
||
fm_cmd
==
OPERATION_POS_APPOINTMENT_CONFIRM
||
fm_cmd
==
OPERATION_POS_SCANCODE_DONE
||
fm_cmd
==
OPERATION_POS_SCANCODE_REFUND
||
fm_cmd
==
REQUEST_TYPE_QUERY_ORDER_STAUS
)
||
fm_cmd
==
REQUEST_TYPE_QUERY_ORDER_STAUS
||
fm_cmd
==
OPERATION_POS_COFFEE_MAKEING_DONE
||
fm_cmd
==
OPERATION_POS_COFFEE_DONE
||
fm_cmd
==
OPERATION_POS_COFFEE_REFUND
)
{
result
=
_convertToOrderOperationReponseJson
(
odsResponse
.
data
());
rlt
=
true
;
...
...
@@ -941,12 +945,16 @@ bool JsonModule::convertDataPos2Ods(const std::string &data, std::string &result
||
fm_cmd
==
OPERATION_POS_APPOINTMENT_REFUND
||
fm_cmd
==
OPERATION_POS_APPOINTMENT_CONFIRM
||
fm_cmd
==
OPERATION_POS_SCANCODE_DONE
||
fm_cmd
==
OPERATION_POS_SCANCODE_REFUND
||
fm_cmd
==
OPERATION_POS_COFFEE_REFUND
)
{
||
fm_cmd
==
OPERATION_POS_SCANCODE_REFUND
)
{
result
=
_convertToAppointmentAndScancodeReqJson
(
data
.
data
());
rlt
=
true
;
}
else
if
(
fm_cmd
==
OPERATION_POS_COFFEE_MAKEING_DONE
||
fm_cmd
==
OPERATION_POS_COFFEE_DONE
||
fm_cmd
==
OPERATION_POS_COFFEE_REFUND
)
{
result
=
_convertToCoffeeReqJson
(
data
.
data
());
rlt
=
true
;
}
return
rlt
;
}
...
...
@@ -1709,14 +1717,11 @@ int JsonModule::_getPOSOrderStatus(int status)
case
ODS_ORDERSTATUS_COFFEE_CONFIRMED
:
rltStatus
=
ORDERSTATUS_CONFIRMED
;
break
;
case
ODS_ORDERSTATUS_COFFEE_DONE
:
rltStatus
=
ORDERSTATUS_COMPLETE
;
break
;
case
ODS_ORDERSTATUS_COFFEE_SHIPPING
:
rltStatus
=
ORDERSTATUS_SHIPPING
;
break
;
case
ODS_ORDERSTATUS_COFFEE_
MAKED
:
rltStatus
=
ORDERSTATUS_CO
NFIRMED
;
case
ODS_ORDERSTATUS_COFFEE_
DONE
:
rltStatus
=
ORDERSTATUS_CO
MPLETE
;
break
;
default
:
break
;
...
...
@@ -2148,13 +2153,7 @@ std::string JsonModule::_convertToAppointmentAndScancodeReqJson(IN const char* j
writer
.
String
(
order_id
.
c_str
());
writer
.
Key
(
"orderStatus"
);
std
::
string
strType
;
if
(
reqType
==
OPERATION_POS_COFFEE_REFUND
)
{
strType
=
std
::
to_string
(
PLUGIN_TO_ODS_COFFEE_REFUND
);
}
else
{
strType
=
_getODSTypeByPOSReq
(
reqType
);
}
std
::
string
strType
=
_getODSTypeByPOSReq
(
reqType
);
writer
.
String
(
strType
.
c_str
());
...
...
@@ -2163,6 +2162,55 @@ std::string JsonModule::_convertToAppointmentAndScancodeReqJson(IN const char* j
return
buffer
.
GetString
();
}
std
::
string
JsonModule
::
_convertToCoffeeReqJson
(
IN
const
char
*
json
)
{
std
::
string
order_id
,
channel
;
rapidjson
::
Document
document
;
// 定义一个Document对象
document
.
Parse
(
json
);
// 解析,Parse()无返回值,也不会抛异常
if
(
document
.
HasParseError
())
// 通过HasParseError()来判断解析是否成功
{
LOG
(
INFO
)
<<
"JSON parse error:"
<<
document
.
GetParseError
()
<<
":"
<<
document
.
GetErrorOffset
();
LOG
(
INFO
)
<<
"JSON DATA:"
<<
json
;
return
""
;
}
int
reqType
=
GetJsonIntSafe
(
document
,
"fm_cmd"
);
channel
=
GetJsonStringSafe
(
document
,
"channel"
);
order_id
=
GetJsonStringSafe
(
document
,
"order_id"
);
rapidjson
::
StringBuffer
buffer
;
rapidjson
::
Writer
<
rapidjson
::
StringBuffer
>
writer
(
buffer
);
writer
.
StartObject
();
int
iType
=
0
;
if
(
reqType
==
OPERATION_POS_COFFEE_MAKEING_DONE
)
{
iType
=
PLUGIN_TO_ODS_COFFEE_MAKEING_DONE
;
}
else
if
(
reqType
==
OPERATION_POS_COFFEE_DONE
)
{
iType
=
PLUGIN_TO_ODS_COFFEE_DONE
;
}
else
if
(
reqType
==
OPERATION_POS_COFFEE_REFUND
)
{
iType
=
PLUGIN_TO_ODS_COFFEE_REFUND
;
}
writer
.
Key
(
"fm_cmd"
);
writer
.
Int
(
iType
);
writer
.
Key
(
"channel"
);
writer
.
String
(
channel
.
c_str
());
writer
.
Key
(
"businessId"
);
writer
.
String
(
order_id
.
c_str
());
writer
.
Key
(
"orderStatus"
);
writer
.
String
(
std
::
to_string
(
iType
).
c_str
());
writer
.
EndObject
();
return
buffer
.
GetString
();
}
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
;
...
...
src/JsonModule.h
View file @
d14f35eb
...
...
@@ -147,6 +147,8 @@ private:
std
::
string
_convertToOrderOperationReponseJson
(
IN
const
char
*
json
);
//转换为点取分离和扫码购请求
std
::
string
_convertToAppointmentAndScancodeReqJson
(
IN
const
char
*
json
);
//转换咖啡小程序请求
std
::
string
_convertToCoffeeReqJson
(
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
,
IN
const
std
::
string
&
odsData
,
OUT
std
::
string
&
result
);
...
...
src/main.cpp
View file @
d14f35eb
...
...
@@ -19,7 +19,7 @@
INITIALIZE_EASYLOGGINGPP
#define VERSION "1.0.7 beta
1
" //版本号
#define VERSION "1.0.7 beta
5
" //版本号
std
::
string
g_init_data
;
std
::
string
g_init_data_ods_back
;
...
...
@@ -160,7 +160,10 @@ void* listen_pos_func(void* arg)
||
OPERATION_POS_APPOINTMENT_CONFIRM
==
reqType
||
OPERATION_POS_SCANCODE_DONE
==
reqType
||
OPERATION_POS_SCANCODE_REFUND
==
reqType
||
REQUEST_TYPE_QUERY_ORDER_STAUS
==
reqType
)
||
REQUEST_TYPE_QUERY_ORDER_STAUS
==
reqType
||
OPERATION_POS_COFFEE_MAKEING_DONE
==
reqType
||
OPERATION_POS_COFFEE_DONE
==
reqType
||
OPERATION_POS_COFFEE_REFUND
==
reqType
)
{
LOG
(
INFO
)
<<
"REQ POS ===>> PLUGIN:"
<<
posRequestData
.
data
();
// 将POS请求数据转换为中台可接受数据格式
...
...
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