商品库接口
商品库接口
一级分类
/merchandise/category1/create 创建一级分类
接口名: /merchandise/category1/create
Method: POST
请求:
name M string 一级分类名
icon M string 图片名
响应:
code M int 0为成功,其它为失败
msg M string 错误提示信息
data M string 一级分类ID
逻辑:
验证分类名是否存在
创建用户所在group的一级分类
/merchandise/category1/update 修改一级分类
接口名: /merchandise/category1/update
Method: POST
请求:
id M string 一级分类ID
name O string 一级分类名
icon O string 图片ID
name icon必需二选一
响应:
code M int 0为成功,其它为失败
msg M string 错误提示信息
逻辑:
判断指定的一级分类ID是否在用户所在的group
验证待修改的一级分类名是否重复
验证待修改的图片名是否存在
修改一级分类信息
/merchandise/category1/delete 删除一级分类
接口名: /merchandise/category1/delete
Method: POST
请求:
id M string 一级分类ID
响应:
code M int 0为成功,其它为失败
msg M string 错误提示信息
逻辑:
判断指定的一级分类ID是否在用户所在的group
设置分类状态为删除
/merchandise/category1/get 获取一级分类信息
接口名: /merchandise/category1/get
Method: GET
请求:
无
响应:
code M int 0为成功,其它为失败
msg M string 错误提示信息
data M list 返回的分类信息
[{
'id' M string 分类ID
'name' M string 分类名
'icon' M int 图标ID
}]
逻辑:
获取用户所在group的一级分类
返回一级分类信息列表
/merchandise/category1/icon 获取分类图标
接口名: /merchandise/category1/icon
Method: GET
请求:
无
响应:
code M int 0为成功,其它为失败
msg M string 错误提示信息
data M list 返回的图标信息
[{
'id' M int 图标ID
'url' M string 图标文件url
}]
二级分类
/merchandise/category2/create 创建二级分类
接口名: /merchandise/category2/create
Method: POST
请求:
name M string 二级分类名
upstream_id M string 一级分类ID
响应:
code M int 0为成功,其它为失败
msg M string 错误提示信息
data M string 返回创建的二级分类ID
逻辑:
判断用户所在的group下一级分类ID是否存在
验证二级分类名是否存在
创建指定一级分类ID下的二级分类
/merchandise/category2/update 更新二级分类
接口名: /merchandise/category2/update
Method: POST
请求:
id M string 二级分类ID
name O string 二级分类名
响应:
code M int 0为成功,其它为失败
msg M string 错误提示信息
逻辑:
判断用户所在的group下二级分类ID是否存在
验证待修改的二级分类名是否重复
验证待修改的一级分类ID是否有效
更新二级分类信息
/merchandise/category2/delete 删除二级分类
接口名: /merchandise/category2/delete
Method: POST
请求:
id M string 二级分类ID
响应:
code M int 0为成功,其它为失败
msg M string 错误提示信息
逻辑:
判断用户所在的group下二级分类ID是否存在
设置二级分类状态为删除
/merchandise/category2/get 获取二级分类信息
接口名: /merchandise/category2/get
Method: GET
请求:
upstream_id O string 上游ID
响应:
code M int 0为成功,其它为失败
msg M string 错误提示信息
data M list 返回的分类信息
[{
'id' M string 分类ID
'name' M string 分类名
'upstream_id' M string 一级分类ID
}]
逻辑:
获取用户所在group的指定一级分类ID下的二级分类
返回二级分类信息列表
品类
/merchandise/pinlei/create 创建品类
接口名: /merchandise/pinlei/create
Method: POST
请求:
name M string 品类名称
upstream_id M string 二级分类ID
响应:
code M int 0为成功,其它为失败
msg M string 错误提示信息
data M string 品类ID
逻辑:
判断用户所在的group下二级分类ID是否存在
验证品类名是否重复
创建指定二级分类ID下的品类
/merchandise/pinlei/update 更新品类
接口名: /merchandise/pinlei/update
Method: POST
请求:
id M string 品类ID
name M string 品类名称
响应:
code M int 0为成功,其它为失败
msg M string 错误提示信息
逻辑:
判断用户所在的group下品类ID是否存在
验证待修改的品类名是否重复
更新品类信息
/merchandise/pinlei/delete 删除品类
接口名: /merchandise/pinlei/delete
Method: POST
请求:
id M string 品类ID
响应:
code M int 0为成功,其它为失败
msg M string 错误提示信息
逻辑:
判断用户所在的group下品类ID是否存在
设置品类状态为删除
/merchandise/pinlei/get 获取品类信息
接口名: /merchandise/pinlei/get
Method: GET
请求:
upstream_id 上游ID
响应:
code M int 0为成功,其它为失败
msg M string 错误提示信息
data M list 返回的品类信息
[{
'id' M string 分类ID
'name' M string 分类名
'upstream_id' M string 二级分类ID
}]
逻辑:
获取用户所在group的指定二级分类ID下的品类
返回二品类信息列表
/merchandise/pinlei/detail 获取品类详情
接口名: /merchandise/pinlei/detail
Method: GET
请求:
id 品类ID
响应:
code M int 0为成功,其它为失败
msg M string 错误提示信息
data M dict 返回的品类信息
{
'id' M string 分类ID
'name' M string 分类名
'category_id_2' M string 二级分类ID
'category_name_2' M string 二级分类名称
'category_id_1' M string 一级分类ID
'category_name_1' M string 一级分类名称
}
spu
/merchandise/spu/create 创建spu
接口名: /merchandise/spu/create
Method: POST
请求:
name M string spu名称
desc M string spu描述
p_type M int 类型(0:通用;1:私有)
std_unit_name M string 基本单位
image M string 图片名称
dispatch_method M int 分拣方式(1:bagua;2:union)
pinlei_id M string 品类ID
alias O list 别名列表
need_pesticide_detect` O bool 是否需要检测报告(如果用户没有 `edit_pesticidedetect` 权限,不传这字段)
响应:
code M int 0为成功,其它为失败
msg M string 错误提示信息
data M string spu ID
逻辑:
判断用户是否能创建对应类型的spu
判断品类ID是否有效
创建spu
/merchandise/spu/update 更新spu
接口名: /merchandise/spu/update
Method: POST
请求:
id M string spu ID
name O string spu名称
desc O string spu描述
p_type O int 类型(0:通用;1:私有)
std_unit_name O string 基本单位
image O string 图片名称
dispatch_method O int 分拣方式(1: bagua;2: union)
pinlei_id O string 品类ID
alias O list 别名列表
need_pesticide_detect` O bool 是否需要检测报告(如果用户没有 `edit_pesticidedetect` 权限,不传这字段; 如果户有 `edit_pesticidedetect` 权限,这个字段可传可不传)
响应:
code M int 0为成功,其它为失败
msg M string 错误提示信息
逻辑:
判断用户是否能修改对应类型的spu
判断spu ID是否有效
修改spu信息
/merchandise/spu/delete 删除spu
接口名: /merchandise/spu/delete
Method: POST
请求:
id M string spu ID
响应:
code M int 0为成功,其它为失败
msg M string 错误提示信息
逻辑:
判断用户是否能删除对应类型的spu
判断spu ID是否有效
设置spu状态为删除
/merchandise/spu/list 获取spu列表
Method: GET
请求:
pinlei_id O string 品类ID
category_id_2 O string 二级分类ID
p_type O int spu类型(0:通用;1:私有)
响应:
code M int 0为成功,其它为失败
msg M string 错误提示信息
data M list 返回的分类信息
[{
'id' M string spu ID
'name' M string spu名
'desc' M string 描述
'p_type' M int spu类型
std_unit_name M string 基本单位
}]
逻辑:
判断品类ID是否有效
获取对应品类ID下的spu信息
返回spu信息列表
/merchandise/spu/export 导出spu和分类信息
接口名: /merchandise/spu/export
Method: GET
请求:
p_type O int spu类型(0:通用;1:私有)
响应:
code M int 0为成功,其它为失败
msg M string 错误提示信息
逻辑:
导出group下的所有spu信息
/merchandise/spu/branch 获取spu分支
接口名: /merchandise/spu/branch
Method: GET
请求:
q O string spu id或spu名称
p_type O int spu类型(0:通用;1:私有)
offset O int 偏移量 默认0
limit O int 返回个数 默认10
响应:
code M int 0为成功,其它为失败
msg M string 错误提示信息
pagination M dict 分页数据
{'count': 总数, 'offset': 当前偏移, 'limit': 个数}
data M list 返回的信息列表
[{
'spu_id' M string spu ID
'spu_name' M string 商品名
'category_id_1' M string 一级分类ID
'category_name_1' M string 一级分类名称
'category_id_2' M string 二级分类ID
'category_name_2' M string 二级分类名称
'pinlei_id' M string 品类ID
'pinlei_name' M string 品类名称
'p_type' M int 商品类型(0:通用;1:私有)
'std_unit_name' M string 基本单位
'dispatch_method' M int 分拣方式(1: bagua 八卦/2: union 统配)
'current_inventory' M float 库存
}]
/merchandise/spu/details 获取spu详情
接口名: /merchandise/spu/details
Method: GET
请求:
spu_id spu ID
响应:
code M int 0为成功,其它为失败
msg M string 错误提示信息
data M dict 返回的spu信息
{
'id' M string spu ID
'name' M string spu名称
'image' M string 图片ID
'category_name_1' M string 一级分类名称
'category_name_2' M string 二级分类名称
'pinlei_name' M string 品类名称
'dispatch_method' M int 分拣方式(1: bagua 八卦/2: union 统配)
'p_type' M int 商品类型(0:通用;1:私有)
'desc' M string 描述
'alias' M list 别名 [string]
'std_unit_name' M string 基本单位
'need_pesticide_detect' O bool 是否需要检测报告(如果用户没有 `edit_pesticidedetect` 权限,不传这字段)
}
逻辑:
判断spu ID是否有效
获取spu信息
返回spu信息
/merchandise/spu/index 获取商品库索引
接口名: /merchandise/spu/index
Method: GET
请求:
category1_ids O list 一级分类ID列表
category2_ids O list 二级分类ID列表
pinlei_ids O list 品类ID列表
q O string 查询参数(按SPU别名/SKU名,SPUID/SKUID搜索)
is_active_on O int 是否显示未激活销售单商品(0:不显示;1:显示 默认不显示)
offset O int 偏移量 默认0
limit O int 返回个数 默认10
响应:
code M int 0为成功,其它为失败
msg M string 错误提示信息
pagination M dict 分页数据
{'count': 总数, 'offset': 当前偏移, 'limit': 个数}
data M list 返回的信息列表
[{
'spu_id' M string spu ID
'spu_name' M string 商品名
'category_name_1' M string 一级分类名称
'category_name_2' M string 二级分类名称
'pinlei_name' M string 品类ID
'p_type' M int 商品类型(0:通用;1:私有)
'std_unit_name' M string 基本单位
'dispatch_method' M int 分拣方式(1: bagua 八卦/2: union 统配)
'skus' M list sku信息
[{
'sku_id' M string sku id
'sku_name' M string 商品名
'salemenu_id' M string 销售单ID
'salemenu_name' M string 销售单名称
'salemenu_type' M int 销售单类型(2:代售单;4:自售单)
'salemenu_is_active' M bool 销售单激活状态
'state' M int 销售状态
'std_unit_name' M string 标准单位
'sale_unit_name' M string 售卖单位
'std_sale_price' M int 标准价(分)
'sale_price' M int 售卖价(分)
'sale_ratio' M float 售卖规格
'stocks_is_valid' M bool 是否设置库存
'stocks' M int 库存数量
'formula_status' int 是否开启公式,0:关闭,1:开启
'formula_info' dic 公式内容
{
'price_type' int 定价价格类型 0/1/2/3/4(现单价/最近询价/最近采购价/最近入库价/库存均价)默认0
'cal_type' int 计算类型 0/1/2(加/乘/除)
'cal_num' float 计算因子 加: 正负六位,小数两位; 乘: 大于0,小数两位; 除: 大于0,小数两位
}]
}]
method:
get
请求参数:
keyword: O string 商户名称
offset: O int 分页offset
limit: O int 分页limit
响应:
code M int 返回码。0为成功、其他为错误
msg M string 提示信息
data M list {
recevier_phone M 收货人电话
receiver_name M 收货人姓名
address_id M SID
resname M 店铺名
address M 地址
}
product/spu/batch_delete 批量删除spu
method
POST
request
all M int 0/1 是否修改全部sku
search_from M int 1:报价单 2:商品库
sku_list O list 当不用全部修改sku时只接收sku_list
salemenu_ids O list 销售单list
salemenu_status O int
category1_ids O list 一级分类ID列表
category2_ids O list 二级分类ID列表
pinlei_ids O list 品类ID列表
state O int 商品状态 (0:下架;1:上架)
salemenu_is_active O int 报价单状态 1已激活
formula O int 定价公式状态 0关闭,1开启
search_text O string 商品名称、sku_id或spu_id
response
async M int 0:同步,1:异步
task_url M null/str 异步返回url,同步则为null
msg M str 返回信息 比如“ok”
code M int 状态码 成功时为0
逻辑:
检查删除的spu的grouo是否正确
删除spu下的采购规格
删除spu下的sku
删除spu
/merchandise/get_tree 获取树结构分类
Method: GET
请求:
无
响应:
code M int 0为成功,其它为失败
msg M string 错误提示信息
id M string 一级分类id
name M string 一级分类名
chtree O dict 子节点树
{
id M string 二级分类id
name M string 二级分类名
upstream_id M string 上级分类id
chtree O dict 子节点树
{
id M string 品类id
name M string 品类名
upstream_id M string 上级分类id
category_id_1 M string 一级分类id
chtree O dict 子节点树
{
id M string spuID
name M string spu名
category_id_1 M string 一级分类id
category_id_2 M string 二级分类id
pinlei_id M string 品类id
}
}
}
响应示例:
"id": "A10875",
"chtree": [
{
"name": "酒",
"id": "B49646",
"chtree": [
{
"category_id_1": "A10875",
"name": "白酒",
"id": "P408382",
"chtree": [
{
"name": "五粮液",
"id": "C1738564",
"category_id_1": "A10875",
"pinlei_id": "P408382",
"category_id_2": "B49646"
},
{
"name": "22",
"id": "C1738570",
"category_id_1": "A10875",
"pinlei_id": "P408382",
"category_id_2": "B49646"
}
],
"upstream_id": "B49646"
}
],
"upstream_id": "A10875"
}
],
"name": "酒水"
}
spu/simple_search 简单查询spu
Method GET
请求:
q O string 搜索字段
响应
std_unit_name M string 基本单位
p_type M int spu类型 私有/通用
desc M string spu描述
name M string spu名字
id M string spuID
category_1_name M 一级分类名
category_2_name M 二级分类名
pinlei_name M 品类名
响应示例:
"std_unit_name": "KG",
"p_type": 0,
"desc": null,
"name": "哈密瓜",
"id": "C1975973",