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
06a214d3
Commit
06a214d3
authored
Feb 01, 2018
by
guanghui.cui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
基础数据结构定义
parent
42048091
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
313 additions
and
10 deletions
+313
-10
base/BaseDefine.h
+52
-0
base/CommonStruct.h
+172
-0
src/JsonModule.cpp
+56
-0
src/JsonModule.h
+25
-5
src/main.cpp
+8
-5
No files found.
base/BaseDefine.h
0 → 100644
View file @
06a214d3
#ifndef BASE_DEFINE_H
#define BASE_DEFINE_H
//订单状态对照表
#define ORDERSTATUS_NEW 1001 //新生成
#define ORDERSTATUS_CONFIRMED 1002 //已确定
#define ORDERSTATUS_CANCELED 1003 //已取消
#define ORDERSTATUS_SHIPPING 1004 //配送中
#define ORDERSTATUS_COMPLETE 1006 //已完成(已核销)
#define ORDERSTATUS_REFUND_FULL 1020 //申请全额退款
#define ORDERSTATUS_REFUND_PART 1021 //申请部分退款
#define ORDERSTATUS_REFUND_COMPLETE 1022 //退款完成
//请求类型对照表
#define REQUEST_TYPE_INIT 1000 //初始化
#define REQUEST_TYPE_NEWORDER_PUSH 1001 //新订单推送
#define REQUEST_TYPE_STATUS_CHANGE 1002 //订单状态变更通知
#define REQUEST_TYPE_REFUND 1003 //订单退款
#define REQUEST_TYPE_GOODS_CHANGE 1004 //商品更换
#define REQUEST_TYPE_POS_PRIORITY 1005 //设置POS优先级
#define REQUEST_TYPE_STOCK_WARN 1006 //库存预警通知
//配送类型对照表
#define DELIVERY_TYPE_SELF "self" //自配送
#define DELIVERY_TYPE_PLATFORM "platform" //平台配送
#define DELIVERY_TYPE_THRID "thrid" //第三方配送
//配送状态对照表
#define DELIVERY_STATUS_WAIT 0 //等待配送
#define DELIVERY_STATUS_CONFIRMED 1 //配送单已确认
#define DELIVERY_STATUS_CANCELED 2 //配送单已取消
#define DELIVERY_STATUS_SHIPPING 3 //配送中
#define DELIVERY_STATUS_COMPLETE 4 //配送完成
//平台代码对照表
#define PLANTFORM_CODE_OFFLINE_COMMON 101 //线下普通单
#define PLANTFORM_CODE_OFFLINE_YIGUO_DISTRIBUTION 102 //线下易果分销
#define PLANTFORM_CODE_ONLINE_AUTO_MACHINE 201 //线上自动贩卖机
#define PLANTFORM_CODE_ONLINE_AUTO_WASHER 202 //线上自动洗衣机
#define PLANTFORM_CODE_ONLINE_QR_CODE 203 //线上QR扫码购
#define PLANTFORM_CODE_ONLINE_YIGUO_TO_QUANJIA_DISTRIBUTION 204 //线上易果给全家分销
#define PLANTFORM_CODE_ONLINE_MEITUAN 205 //线上美团外卖
#define PLANTFORM_CODE_ONLINE_BAIDU 206 //线上百度外卖
#define PLANTFORM_CODE_ONLINE_ELEMA 207 //线上饿了吗外卖
#define PLANTFORM_CODE_ONLINE_JINGDONG 208 //线上京东外卖
//响应状态对照表
#define RESPONSE_CODE_SUCCESS 100 //成功
#define RESPONSE_CODE_FAILED 101 //失败
#endif
\ No newline at end of file
base/CommonStruct.h
0 → 100644
View file @
06a214d3
#ifndef COMMON_STRUCT_H
#define COMMON_STRUCT_H
#include <iostream>
#include <vector>
//商品
struct
product
{
std
::
string
source
;
//商品来源
std
::
string
attributes
;
//商品属性
std
::
string
combo_id
;
//商品组合ID
std
::
string
bom_id
;
//商品分组组合ID
std
::
string
bag_id
;
//商品口袋ID
std
::
string
name
;
//商品名称
int
price
=
0
;
//商品价格
int
qty
=
0
;
//商品数量(商品使用)
std
::
string
sku
;
//商品SKU
int
stock
=
0
;
//商品当前库存(库存预警使用)
};
//商品规格
struct
productSpec
{
std
::
string
name
;
//规格名称
int
price
=
0
;
//规格价格
int
qty
=
0
;
//规格数量
std
::
string
sku
;
//规格SKU
};
//商品属性
struct
productAttr
{
product
pro
;
//商品
std
::
vector
<
productSpec
>
vecSpec
;
//商品规格
};
//付款明细
struct
paymentDetail
{
int
amount
=
0
;
//支付金额
int
type
=
0
;
//支付类型
std
::
string
trans_id
;
//支付交易号
};
//支付信息
struct
payment
{
std
::
string
summary
;
//支付明细汇总
std
::
vector
<
paymentDetail
>
vecDetail
;
//付款明细数组
};
//订单积分详情
struct
bonusDetail
{
int
type
=
0
;
//积分类型
std
::
string
desc
;
//积分奖励描述
int
point
=
0
;
//积分奖励数值
std
::
string
sku
;
//积分商品
};
//订单积分
struct
bonus
{
std
::
string
summary
;
//积分奖励总和
std
::
vector
<
bonusDetail
>
vecDetail
;
//付款明细数组
};
//促销明细
struct
promotionsDetail
{
int
type
=
0
;
//促销类型
std
::
string
desc
;
//促销描述
int
offer
=
0
;
//促销金额
std
::
string
sku
;
//促销商品
};
//促销
struct
promotions
{
std
::
string
summary
;
//促销金额总和
std
::
vector
<
promotionsDetail
>
vecDetail
;
//付款明细数组
};
//响应结果
struct
responseRlt
{
int
status_code
=
0
;
//响应状态码
std
::
string
msg
;
//响应提示信息
};
//门店信息
struct
store
{
std
::
string
store_id
;
//门店号
std
::
string
pos_id
;
//订单推送 POS 编号
std
::
string
vem_id
;
//自助终端编号
std
::
string
vem_shelf
;
//自助终端货架号
};
//配送信息
struct
delivery
{
std
::
string
type
;
//配送类型
int
status
=
0
;
//配送状态
std
::
string
status_desc
;
//配送状态描述
std
::
string
driver_name
;
//外送骑手姓名
std
::
string
driver_phone
;
//骑手电话
};
//顾客信息
struct
customer
{
std
::
string
name
;
//顾客姓名
std
::
string
phone
;
//顾客电话
std
::
string
address
;
//顾客地址
std
::
string
account
;
//顾客账号
int
account_type
=
0
;
//顾客账号类型
std
::
string
account_level
;
//顾客账号等级
};
//订单结构体
struct
orderObj
{
int
fm_cmd
=
0
;
//请求类型
std
::
string
channel
;
//订单渠道
int
order_no
=
0
;
//订单序号
std
::
string
order_id
;
//订单标识号
std
::
string
create_time
;
//订单创建时间
std
::
string
delivery_time
;
//订单期望送达时间
int
status
=
0
;
//订单状态
std
::
string
status_desc
;
//订单状态描述
int
total_price
=
0
;
//订单总价
int
delivery_price
=
0
;
//配送费
int
reduced_price
=
0
;
//折扣总金额
std
::
string
pickup_code
;
//自取订单取餐码
std
::
string
pickup_point
;
//自取订单取餐处
store
storeInfo
;
//门店信息
delivery
deliveryInfo
;
//配送信息
customer
customerInfo
;
//顾客信息
std
::
vector
<
productAttr
>
vecProducts
;
//商品列表
payment
payInfo
;
//付款明细
bonus
bonusInfo
;
//消费积分
promotions
promotionInfo
;
//促销列表
};
//订单状态
struct
orderStatusObj
{
int
fm_cmd
=
0
;
//请求类型
std
::
string
order_id
;
//订单编号
int
order_status
=
0
;
//订单状态
int
delivery_status
=
0
;
//配送状态
};
struct
refundObj
{
int
fm_cmd
=
0
;
//请求类型(1003)
std
::
string
channel
;
//订单渠道
std
::
string
order_id
;
//订单编号
int
refund_amount
=
0
;
//退款总金额
std
::
vector
<
productAttr
>
vecProducts
;
//商品数组
};
struct
stockWarnObj
{
int
fm_cmd
=
0
;
//请求类型(1006)
std
::
vector
<
product
>
vecProducts
;
//商品数组
};
#endif
\ No newline at end of file
src/JsonModule.cpp
View file @
06a214d3
...
...
@@ -56,3 +56,58 @@ void parseJson(const char* json)
}
}
JsonModule
::
JsonModule
()
{
}
JsonModule
::~
JsonModule
()
{
}
orderObj
JsonModule
::
convertToOrderObj
(
const
char
*
json
)
{
orderObj
obj
;
return
obj
;
}
std
::
string
JsonModule
::
convertToOrderJson
(
orderObj
&
obj
)
{
return
""
;
}
orderStatusObj
JsonModule
::
convertToOrderStatusObj
(
const
char
*
json
)
{
orderStatusObj
obj
;
return
obj
;
}
std
::
string
JsonModule
::
convertToOrderStatusJson
(
orderStatusObj
&
obj
)
{
return
""
;
}
refundObj
JsonModule
::
convertToRefundObj
(
const
char
*
json
)
{
LOG
(
INFO
)
<<
"refundObj start"
;
refundObj
obj
;
LOG
(
INFO
)
<<
"refundObj define"
;
return
obj
;
}
std
::
string
JsonModule
::
convertToRefundJson
(
refundObj
&
obj
)
{
return
""
;
}
stockWarnObj
JsonModule
::
convertToStockWarnObj
(
const
char
*
json
)
{
stockWarnObj
obj
;
return
obj
;
}
std
::
string
JsonModule
::
convertToStockWarnJson
(
stockWarnObj
&
obj
)
{
return
""
;
}
\ No newline at end of file
src/JsonModule.h
View file @
06a214d3
#ifndef JSON_H
#define JSON_H
#include <iostream>
std
::
string
GetTestJson
(
const
int
statuscode
,
const
char
*
msg
,
const
char
*
orderid
);
#ifndef JSON_MODULE_H
#define JSON_MODULE_H
#include "../base/CommonStruct.h"
//std::string GetTestJson(const int statuscode,const char* msg,const char* orderid);
//void parseJson(const char* json);
class
JsonModule
{
public
:
JsonModule
();
~
JsonModule
();
orderObj
convertToOrderObj
(
const
char
*
json
);
std
::
string
convertToOrderJson
(
orderObj
&
obj
);
orderStatusObj
convertToOrderStatusObj
(
const
char
*
json
);
std
::
string
convertToOrderStatusJson
(
orderStatusObj
&
obj
);
refundObj
convertToRefundObj
(
const
char
*
json
);
std
::
string
convertToRefundJson
(
refundObj
&
obj
);
stockWarnObj
convertToStockWarnObj
(
const
char
*
json
);
std
::
string
convertToStockWarnJson
(
stockWarnObj
&
obj
);
};
void
parseJson
(
const
char
*
json
);
#endif
src/main.cpp
View file @
06a214d3
...
...
@@ -24,6 +24,7 @@ void logRolloutHandler(const char* filename, std::size_t size)
system
(
ss
.
str
().
c_str
());
}
int
main
()
{
el
::
Loggers
::
addFlag
(
el
::
LoggingFlag
::
StrictLogFileSizeCheck
);
...
...
@@ -46,15 +47,17 @@ int main()
//------------end---------------
//---------- json test----------
std
::
string
json
=
GetTestJson
(
100
,
"test data"
,
"123456789"
);
LOG
(
INFO
)
<<
"生成JSON"
<<
json
.
data
();
//
std::string json = GetTestJson(100,"test data","123456789");
//
LOG(INFO)<<"生成JSON" <<json.data();
LOG
(
INFO
)
<<
"JSON解析"
;
parseJson
(
json
.
data
());
// LOG(INFO)<<"JSON解析";
// parseJson(json.data());
JsonModule
jsonMod
;
jsonMod
.
convertToRefundObj
(
""
);
//------------end---------------
//---------- pthread test ---------
LOG
(
INFO
)
<<
"启动
打印
线程"
;
LOG
(
INFO
)
<<
"启动
SOCKET
线程"
;
pthread_t
printId
;
int
ret
=
pthread_create
(
&
printId
,
NULL
,
FunSocketServer
,
NULL
);
//---------- end ------------------
...
...
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