pad称重方案
DB
order_new
# order_new
_id
details
id
quantity
weighting_quantity 称重数量【新增】
out_of_stock 缺货标记【新增】
real_quantity
accept_quantity
...
...
weighting_lastest 【新增】
# sku_latest_weight 【新增】
_id
order_id
sku_id
quantity # 下单数
weighting_quantity # 记重数,非称重商品实际重量
real_quantity # 出库数
create_time
modify_time
weighting_op_log 【操作日志】
station_id
user_id
user_name
op
data
create_time
weighting_spu_group 【新增】
# spu_group
_id
station_id
name
spus
id
接口
导出接口
GET weight/skus/export
请求参数:
time_config_id str M 运营时间配置id
date str M 日期,形如 2017-08-01
export int M 1:导出已称重商品,2:导出缺货商品。
返回数据:
{
"code": 0,
"msg": "",
"data": {
"蔬菜": [
{
"resname": "商户名称A",
"category1_name": "蔬菜",
"category2_name": "叶菜",
"order_id": "PL1050756",
"sort_id": 1, # 分拣号
"spu_id": "C115348",
"id": "D1475919",
"name": "菜心|小条",
"is_weight": true, # 是否称重商品
"quantity": "3.00斤", # 下单数
"real_quantity": "3.50斤", # 出库数
"driver_name": null, # 司机
"user_name": "ceshik10admin", # 用户名
"employee_number": "1", # 工号
"operate_time": "2018-01-12 14:47:04" # 操作时间
}
],
"鲜肉": [
{
"resname": "商户名称B",
"category1_name": "鲜肉",
"category2_name": "鲜猪肉",
"order_id": "PL1050858",
"sort_id": 8,
"spu_id": "C369772",
"id": "D1898180",
"name": "肠",
"is_weight": false,
"quantity": "1.00斤",
"real_quantity": "1.00斤",
"driver_name": null,
"user_name": "ceshik10admin", # 用户名
"employee_number": "1",
"operate_time": "2018-01-12 15:55:19"
}
]
}
}
获取称重分拣数据
POST weight/skus
请求参数:
time_config_id str M 运营时间配置id
date str M 周期日期
order_search str O 订单号/序号/用户名
sku_search str O 商品名搜索
is_weight int o 是否称重商品,1:是 0:否
has_weight int O 是否已称重,1:是 0:否
category1_ids list O 一级分类列表
category2_ids list O 二级分类列表
spu_ids list O spu列表
group_ids list O 分组列表
out_of_group int O 按未分组的spu筛选 1:是 0:否
diff str O 差异商品,all:全部 weight:重量变化 new:新商品 remove:删除商品
next str O 分页id
返回参数:
{
"skus": [{
"id": "",
"spu_id": "", # spu_id
"last_print_time":"", 无值是null
"name": "",
"remark": "",
"order_id": "",
"source_order_od":"", #上游订单id
"is_weight": 1,
"has_weight": 1,
"quantity": 10, # 下单数
"weight_quantity": 12, # 称重数
"real_quantity": 10, # 出库数
"out_of_group": ture, # 缺货标记
"sale_ratio": 1,
"std_unit_name": "斤",
"std_sale_price": 1,
"sale_unit_name": "包",
"sale_unit_price": 1357,
"category_id_1": "A102", # 一级分类id
"category1_name": "鲜肉", # 一级分类名
"category_id_2": "B111", # 二级分类id
"category2_name": "鲜猪肉", # 二级分类id
"diff": "new" # 当查询diff时候返回,对应每一个diff的类型, new/weight/remove
}],
"orders": {
"PL00001":{
"batch_remark": "",
"sort_id": 1,
"address_name": ""
}
},
"pagination": {
"next": ""
}
}
拉取有下单的商品分类
GET weight/category/tree
请求参数:
time_config_id str O 运营时间配置id
date str O 日期,形如 2017-08-01
is_weight bool O 筛选记重或者不记重商品 1:记重 0:不记重
# 不传以上参数代表返回全部商品分类
返回数据:
[{
"id": "A001",
"name": "蔬菜",
"sub": [{
"id": "B001",
"name": "白菜",
"sub": [{
"id": "D000001"
"name": "白菜菜"
}]
}]
}]
拉取某sku的打印数据
GET weight/sku/print/infos
请求参数:
skus list M sku id列表,形如 [{"order_id":"","sku_id":"","source_order_id":""}] source_order_id可选
返回数据:
[{
"id": "",
"name": "",
"phone":"",
"remark": "",
"order_id": "",
"is_weight": 1,
"has_weight": 1,
"quantity": 10, # 下单数
"weight_quantity": 12, # 称重数
"real_quantity": 10, # 出库数
"out_of_group": ture, # 缺货标记
"sale_ratio": 1,
"std_unit_name": "斤",
"std_sale_price": 1,
"sale_unit_name": "包",
"order": {
"id": "LK629854",
"batch_remark": "",
"receiver_name": "叶海舰",
"address_id": "T012",
"station_id": "T002",
"station_name": "SZ-总仓-K10",
"address_name": "SZ-阿米巴53号-前海",
"source_address_id": "",
"source_address_name": "",
"sort_id": 18,
"source_sort_id": 1
},
"driver": {
"name": "**53前海",
"source_driver_name": ""
}
}]
设置称重数
POST weight/sku/set_weight
请求参数:
weights list M 称重列表 形如 [{"sku_id":"D00001", "order_id": "PL0001","source_order_id":"","weight": 10,"set_weight": 10}] source_order_id可选
返回数据:
# 请求成功
{
"code": 0
}
# sku weight未更新,返回sku最新的数据
{
"D00001": {
"id": "",
"is_weight": 1,
"has_weight": 1,
"quantity": 10, # 下单数
"weight_quantity": 12, # 称重数
"real_quantity": 10, # 出库数
}
}
标记缺货
POST weight/sku/out_of_stock
请求参数:
skus list M sku id [{"order_id":"","sku_id":"","source_order_id":""}] source_order_id可选
返回数据:
{
"code": 0
}
sku打印通知
POST weight/sku/print
请求参数:
skus list M sku的数组,形如 [{"order_id":"","sku_id":""}]
返回数据:
{
"code": 0
}
设置工号
POST weight/employee/set
请求参数:
number str M 工号
返回数据:
{
"code": 0
}
获取分组列表
GET weight/group/list
请求参数:
无
返回数据:
[{
"id": "",
"name": ""
}]
获取分组详情
GET weight/group/detail
请求参数:
id
返回数据:
{
"code": 0,
"msg": "ok",
"data": {
"id": "GROUP0014",
"name": "分组1",
"spus": [
{
"id": "C966266",
"category1_id": "A231",
"name": "菜心叶八卦",
"category2_id": "B414"
}
]
}
}
获取未分组的商品分类tree
GET weight/category/ungroup_tree
请求参数:
返回数据:
[{
"id": "A001",
"name": "蔬菜",
"sub": [{
"id": "B001",
"name": "白菜",
"sub": [{
"id": "D000001"
"name": "白菜菜"
}]
}]
}]
删除分组
POST weight/group/remove
请求参数:
id
返回数据:
{
"code": 0
}
下面两个接口,需要防止多个人同时请求的时候,两边都处理得到了未分组的数据(有相同值), 然后都添加到数据库,这时,数据就有问题了,一个spu,同属于两个组。
所以下面设计到增加和更新操作 就采用了锁住这个接口的方式,当一个请求过来的时候,根据站点获取锁,其他这个站点的请求的时候就无法获取锁,提示有其他pad正在操作,保证只有一个接口在执行。锁放在redis,设过期时间5s,这个请求结束都会释放锁。
更新分组spu
POST weight/group/update
请求参数:
group_id str M group id
spu_ids list M spu列表
返回数据:
{
"code": 0,
"msg": "ok",
"data": {}
}
不是0出现
{
"code": 6,
"msg": "存在已经分组过得spu",
"data": {
"cannot_update_spus": [ # 无法添加到分组的
"C01416"
]
}
}
创建分组
POST weight/group/create
请求参数
name str M 分组名 长度限制到了50
spu_ids list M spu列表
返回数据:
{
"code": 0,
"msg": "ok",
"data": {
"id": "5993f2f1499ac0beeca2f09f"
}
}
不是0出现
{
"code": 6,
"msg": "存在已经分组过得spu",
"data": {
"cannot_update_spus": [ # 无法添加到分组的
"C01416"
]
}
}