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
166f20c2
Commit
166f20c2
authored
Aug 24, 2018
by
guanghui.cui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
实现接口“点取分离”和“扫码购”
parent
2e37a54c
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
148 additions
and
4 deletions
+148
-4
base/BaseDefine.h
+19
-4
base/CommonStruct.h
+8
-0
src/JsonModule.cpp
+109
-0
src/JsonModule.h
+5
-0
src/main.cpp
+7
-0
No files found.
base/BaseDefine.h
View file @
166f20c2
...
...
@@ -18,6 +18,9 @@
#define ORDERSTATUS_REFUND_PART 1021 //申请部分退款
#define ORDERSTATUS_REFUND_COMPLETE 1022 //退款完成
//#define ORDERSTATUS_LOCK 1100 //外卖-已锁定
#define ORDERSTATUS_APPOINTMENT_PAID 1030 //已支付(点取分离)
#define ORDERSTATUS_APPOINTMENT_REFUND 1031 //用户退款(点取分离)
#define ORDERSTATUS_SCANCODE_PAID 1032 //已支付(扫码购)
//请求类型对照表
#define REQUEST_TYPE_INIT 1000 //初始化
...
...
@@ -62,10 +65,18 @@
#define RESPONSE_CODE_FAILED 101 //失败
//POS操作类型
#define OPERATION_POS_CONFIRM 1011 //确认接单
#define OPERATION_POS_CANCEL 1012 //拒绝接单
#define OPERATION_POS_REFUND_AGREE 1013 //同意退款
#define OPERATION_POS_REFUND_DISAGREE 1014 //拒绝退款
#define OPERATION_POS_CONFIRM 1011 //确认接单(外卖)
#define OPERATION_POS_CANCEL 1012 //拒绝接单(外卖)
#define OPERATION_POS_REFUND_AGREE 1013 //同意退款(外卖)
#define OPERATION_POS_REFUND_DISAGREE 1014 //拒绝退款(外卖)
#define OPERATION_POS_APPOINTMENT_MAKEING 1015 //制作中(点取分离)
#define OPERATION_POS_APPOINTMENT_MAKEING_DONE 1016 //制作完成(点取分离)
#define OPERATION_POS_APPOINTMENT_DONE 1017 //已完成(点取分离)
#define OPERATION_POS_APPOINTMENT_REFUND 1018 //pos退款(点取分离)
#define OPERATION_POS_APPOINTMENT_CONFIRM 1019 //确认接单(点取分离)
#define OPERATION_POS_SCANCODE_DONE 1020 //已完成(扫码购)
#define OPERATION_POS_SCANCODE_REFUND 1021 //pos退款(扫码购)
/***********************************
ODS相关预定义变量
...
...
@@ -93,6 +104,10 @@
#define ODS_ORDERSTATUS_CANCELED_SYS 3004 //系统取消
#define ODS_ORDERSTATUS_CANCELED_OTHER 3100 //其他原因取消
#define ODS_ORDERSTATUS_LOCK -1 //已锁定
#define ODS_ORDERSTATUS_APPOINTMENT_PAID 20004 //已支付(点取分离)
#define ODS_ORDERSTATUS_APPOINTMENT_REFUND 20005 //用户退款(点取分离)
#define ODS_ORDERSTATUS_SCANCODE_PAID 30004 //已支付(扫码购)
//推送类型
#define ODS_PUSH_TYPE_HEARTBEAT 3 //心跳
...
...
base/CommonStruct.h
View file @
166f20c2
...
...
@@ -163,6 +163,13 @@ struct ecoupon
int
ecouponQty
=
0
;
//电子点标数量
};
//点取分离
struct
appointment
{
std
::
string
appointment_time
;
//预约时间
int
is_appointment
;
//是否是点取分离
};
//订单结构体
struct
orderObj
{
...
...
@@ -191,6 +198,7 @@ struct orderObj
store
storeInfo
;
//门店信息
delivery
deliveryInfo
;
//配送信息
customer
customerInfo
;
//顾客信息
appointment
appointmentInfo
;
//点取分离信息
std
::
vector
<
productAttr
>
vecProducts
;
//商品列表
payment
payInfo
;
//付款明细
std
::
vector
<
bonus
>
vecBonus
;
//消费积分
...
...
src/JsonModule.cpp
View file @
166f20c2
...
...
@@ -217,6 +217,12 @@ 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"
);
}
//自配送
if
(
"2"
==
delivery_type
){
order
.
delivery_price
=
GetJsonIntSafe
(
orderContent_obj
,
"deliveryFee"
);
...
...
@@ -875,6 +881,16 @@ bool JsonModule::convertDataPos2Ods(const std::string &data, std::string &result
result
=
_convertToQueryOrderStatusJson
(
data
.
data
());
rlt
=
true
;
}
else
if
(
fm_cmd
==
OPERATION_POS_APPOINTMENT_MAKEING
||
fm_cmd
==
OPERATION_POS_APPOINTMENT_MAKEING_DONE
||
fm_cmd
==
OPERATION_POS_APPOINTMENT_DONE
||
fm_cmd
==
OPERATION_POS_APPOINTMENT_REFUND
||
fm_cmd
==
OPERATION_POS_APPOINTMENT_CONFIRM
||
fm_cmd
==
OPERATION_POS_SCANCODE_DONE
||
fm_cmd
==
OPERATION_POS_SCANCODE_REFUND
)
{
result
=
_convertToAppointmentAndScancodeReqJson
(
data
.
data
());
rlt
=
true
;
}
return
rlt
;
...
...
@@ -1018,6 +1034,19 @@ std::string JsonModule::_convertToNewOrderJson(orderObj &obj)
writer
.
EndObject
();
//----------------配送信息 结束-----------
//----------------点取分离----------------
writer
.
Key
(
"appointment"
);
writer
.
StartObject
();
writer
.
Key
(
"appointment_time"
);
writer
.
String
(
obj
.
appointmentInfo
.
appointment_time
.
c_str
());
writer
.
Key
(
"is_appointment"
);
writer
.
Int
(
obj
.
appointmentInfo
.
is_appointment
);
writer
.
EndObject
();
//----------------点取分离 结束-----------
//----------------顾客信息----------------
writer
.
Key
(
"customer"
);
writer
.
StartObject
();
...
...
@@ -1518,6 +1547,15 @@ int JsonModule::_getPOSOrderStatus(int status)
case
ODS_ORDERSTATUS_CANCELED_OTHER
:
rltStatus
=
ORDERSTATUS_CANCELED
;
break
;
case
ODS_ORDERSTATUS_APPOINTMENT_PAID
:
rltStatus
=
ORDERSTATUS_APPOINTMENT_PAID
;
break
;
case
ODS_ORDERSTATUS_APPOINTMENT_REFUND
:
rltStatus
=
ORDERSTATUS_APPOINTMENT_REFUND
;
break
;
case
ODS_ORDERSTATUS_SCANCODE_PAID
:
rltStatus
=
ORDERSTATUS_SCANCODE_PAID
;
break
;
default
:
break
;
}
...
...
@@ -1906,6 +1944,45 @@ std::string JsonModule::_convertToQueryOrderStatusJson(IN const char* json)
return
buffer
.
GetString
();
}
std
::
string
JsonModule
::
_convertToAppointmentAndScancodeReqJson
(
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
();
writer
.
Key
(
"fm_cmd"
);
writer
.
Int
(
REQUEST_TYPE_QUERY_ORDER_STAUS
);
writer
.
Key
(
"channel"
);
writer
.
String
(
channel
.
c_str
());
writer
.
Key
(
"businessId"
);
writer
.
String
(
order_id
.
c_str
());
writer
.
Key
(
"orderStatus"
);
std
::
string
strType
=
_getODSTypeByPOSReq
(
reqType
);
writer
.
String
(
strType
.
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
;
...
...
@@ -2001,6 +2078,38 @@ int JsonModule::_getODSStatusByPOSReq(int fm_cmd)
return
rlt
;
}
std
::
string
JsonModule
::
_getODSTypeByPOSReq
(
int
type
)
{
std
::
string
rlt
=
0
;
switch
(
type
)
{
case
OPERATION_POS_APPOINTMENT_MAKEING
:
rlt
=
"20007"
;
break
;
case
OPERATION_POS_APPOINTMENT_MAKEING_DONE
:
rlt
=
"20008"
;
break
;
case
OPERATION_POS_APPOINTMENT_DONE
:
rlt
=
"20009"
;
break
;
case
OPERATION_POS_APPOINTMENT_REFUND
:
rlt
=
"200010"
;
break
;
case
OPERATION_POS_APPOINTMENT_CONFIRM
:
rlt
=
"20006"
;
break
;
case
OPERATION_POS_SCANCODE_DONE
:
rlt
=
"30005"
;
break
;
case
OPERATION_POS_SCANCODE_REFUND
:
rlt
=
"30006"
;
break
;
default
:
break
;
}
return
rlt
;
}
bool
JsonModule
::
_convertPOSReqPriorityJson
(
IN
const
std
::
string
&
posReq
,
OUT
const
std
::
string
&
odsJson
)
{
std
::
string
pos_id
;
...
...
src/JsonModule.h
View file @
166f20c2
...
...
@@ -116,6 +116,9 @@ private:
int
_getPOSOrderStatus
(
int
status
);
//POS请求类型转换为ODS需要类型
int
_getODSStatusByPOSReq
(
int
fm_cmd
);
//POS请求操作类型转换为中台需要类型
std
::
string
_getODSTypeByPOSReq
(
int
type
);
std
::
string
_getPickupCodeString
(
std
::
string
&
channel
,
std
::
string
&
pickup_code
);
//获取通用预警故障字符串
...
...
@@ -140,6 +143,8 @@ private:
std
::
string
_convertToCommonWarnJson
(
IN
const
char
*
json
);
std
::
string
_convertToQueryOrderStatusJson
(
IN
const
char
*
json
);
std
::
string
_convertToOrderOperationReponseJson
(
IN
const
char
*
json
);
//转换为点取分离和扫码购请求
std
::
string
_convertToAppointmentAndScancodeReqJson
(
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 @
166f20c2
...
...
@@ -148,6 +148,13 @@ void* listen_pos_func(void* arg)
||
OPERATION_POS_CANCEL
==
reqType
||
OPERATION_POS_REFUND_AGREE
==
reqType
||
OPERATION_POS_REFUND_DISAGREE
==
reqType
||
OPERATION_POS_APPOINTMENT_MAKEING
==
reqType
||
OPERATION_POS_APPOINTMENT_MAKEING_DONE
==
reqType
||
OPERATION_POS_APPOINTMENT_DONE
==
reqType
||
OPERATION_POS_APPOINTMENT_REFUND
==
reqType
||
OPERATION_POS_APPOINTMENT_CONFIRM
==
reqType
||
OPERATION_POS_SCANCODE_DONE
==
reqType
||
OPERATION_POS_SCANCODE_REFUND
==
reqType
||
REQUEST_TYPE_QUERY_ORDER_STAUS
==
reqType
)
{
LOG
(
INFO
)
<<
"REQ POS ===>> PLUGIN:"
<<
posRequestData
.
data
();
...
...
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