广州大学食品安全追溯需求
建立帐号的步骤
- 建立 group,配置商品库等
- 使用 superman 登录 station/运营管理/新建站点
- 建立广州大学站点,站点类型选「总加盟商仓」
- 建立博方站点,站点类型选「总加盟商仓」
- 使用 superman 登录 http://station.guanmai.cn/admin,选择「station管理员管理」,为上面建立的站点增加站点管理员
- 使用广州大学登录 station/商品管理/供应商管理,新建供应商
- 去 mongo station 表,将博方站点的 role 改为 8,将供应商站点的 role 改为 6
数据库
MySQL 加一个检测报告的表 tbl_food_security_report
'id': 1,
'partner_id': 12, # 加盟商id
'station_id': 'T1208', # 站点id,
'station_type': 1, # 站点类别,第三方还是供应商还是大学(1:供应商; 2:第三方; 3:大学)
'detect_date': ISODate("2016-11-15T00:00:00.000Z"), # 检测日期,精确到日
'uploader', # 上传人,当前帐号 id
'detect_sender', # 送检机构
'detect_institution': '军情六处', # 检测机构
'detector': '詹姆斯', # 检测人
'pic': "babc6b6ebc685305.png", # 图片 id
'is_deleted': false,
'create_time': ISODate("2016-11-15T12:10:46.981Z"), # 创建时间
'modify_time': ISODate("2016-11-15T12:10:46.981Z"), # 最后修改时间
tbl_food_security_report_spus
'id':
'spu_id'
'report_id'
'detect_date'
'create_time': ISODate("2016-11-15T12:10:46.981Z"), # 创建时间
'modify_time': ISODate("2016-11-15T12:10:46.981Z"), # 最后修改时间
'is_deleted'
接口
搜索检测报告 /food_security_report/list
参考分页规范 http://doc.guanmai.cn/分享培训/知识分享/分页规范
Method:get
query_type M int 检测类型(1:按照上传日期;2:按照检测日期)
begin_time M string 开始上传日期 if query_type == 1 else 开始检测日期(格式:%Y-%m-%d)
end_time M string 结束上传日期 if query_type == 1 else 结束检测日期(格式:%Y-%m-%d)
report_type M int 检测报告的类型, 6: 供应商 8: 检测机构
search_text O string 搜索文字
export O int 是否导出(默认不导出)。如果导出,不需要传和分页有关的参数
limit O int 分页相关字段
from O str 分页相关字段
reverse O bool 分页相关字段
peek O str 分页相关字段
响应
code M int 返回码,0表示成功,其他表示错误
msg M string 错误信息
data M list 检测报告们
id M string id
detect_date M string 检测日期
detect_institution M string 检测机构
detect_sender M string 送检机构
uploader M string 上传人
create_time M string 上传时间
pic_url M string 下载报告图片的链接
pagination M dict
示例:
request
TODO
response
{
code: 0,
msg: '',
data:{
list: [
{
'id': JC000001,
'detect_date': "2016-11-15T00:00:00.000Z"), # 检测日期,精确到
'uploader', # 上传人,当前帐号 id
'detect_sender', # 送检机构
'create_time': ISODate("2016-11-15T12:10:46.981Z"), # 创建时间
'detect_institution': '军情六处', # 检测机构
'pic': "http://path/babc6b6ebc685305.png", # 图片连接
},
...
],
}
pagination: {}
}
分页逻辑:
见 http://doc.guanmai.cn/分享培训/知识分享/分页规范/
检测报告详情 /food_security_report/detail
Method:get
请求:
id M string 检测报告id
响应:
code M int 返回码,0表示成功,其他表示错误
msg M string 错误信息
data M dict 详细信息
示例:
request
TODO
response
{
"code": 0,
"msg": "",
"data": {
'id': JC000001,
'detect_date': ISODate("2016-11-15T00:00:00.000Z"), # 检测日期,精确到
'uploader', # 上传人,当前帐号 id
'upload_institution', # 上传机构???
'report_type': 6, # 检测类别,第三方抽检还是供应商(6:供应商; 8:第三方抽检)
'detector': '詹姆斯', # 检测人
'detect_institution': '军情六处', # 检测机构
'pic_url': "http://url/babc6b6ebc685305.png", # 图片
'spus': [
{
"id": 48,
"spu_id": "C05662",
"report_id": "24",
"detect_date": "2017-07-15",
"is_deleted": 0,
"create_time": "2017-07-13T13:33:50",
"modify_time": "2017-07-13T13:33:50",
"name": "虫草花|湿",
"category1_name": "蔬菜",
"category2_name": "食用菌菇"
}, ..
]
}
}
图片上传 /food_security_report/image/upload
接口名 /food_security_report/image/upload
方法 POST
请求
image_file M files 图片
响应
code M int 0为成功,其它为失败
msg M string 错误提示信息
data M list 成功的返回数据
{
'image_url' M string 图片url
'img_path_id' M string 文件名
}
逻辑
上传图片到cos
添加报告 /food_security_report/create
Method:post
请求:
detect_date M string 检测日期
detect_sender M string 送检机构
detect_institution O string 检测机构
detector M string 检测人
spu_ids M list 检测商品
report_type M int 检测报告的类型, 6: 供应商 8: 检测机构
image M string /image/upload 返回的 img_path_id
replace O int 是否强制(1:不强制;2:强制)。当选择强制时,检测日期当天其他检测报告的 spu_ids 如果和传入的 spu_ids 有重合,将会删除其他检测报告中重合的 spu_ids。默认:0。
响应:
code M int 返回码,0表示成功,1表示错误,2表示「这个检测机构已经在这个检测日期检测过期中的 spu ,未能成功创建」
msg M string 错误信息
示例:
request
{
detect_date: 2017-1-1,
type: 1,
detector: 'M女士',
detect_institution: '皇家情报局',
report_type: 6,
spu_ids: []
}
response
TODO
编辑检测报告 /food_security_report/update
Method:post
请求:
id M int 43
detect_date M string 检测日期
detect_sender M string 送检机构
detect_institution O string 检测机构
detector M string 检测人
spu_ids M list 检测商品
image M string /image/upload 返回的 img_path_id
replace O bool 是否强制(0:不强制;1:强制)。当选择强制时,检测日期当天其他检测报告的 spu_ids 如果和传入的 spu_ids 有重合,将会删除其他检测报告中重合的 spu_ids。默认:0。
响应:
code M int 返回码,0表示成功,1表示错误,2表示「这个报告中,存在在检测日期已经被检测过的spu,未能成功创建」
msg M string 错误信息
示例:
request
{
report_id: 43,
detect_date: 2017-1-1,
type: 1,
detector: 'M女士',
detect_institution: '皇家情报局',
spu_ids: []
}
response
TODO
删除检测报告 /food_security_report/delete
Method:post
请求:
id M string 检测报告
响应:
code M int 返回码,0表示成功,其他表示错误
msg M string 错误信息
示例:
request
/food_security_report/delete?id=JC110
response
TODO
帐号的商品库树 /food_security_report/merchandise_tree
Method:get
请求:
无参数,只要登录了就行
响应:
code M int 返回码,0表示成功,其他表示错误
msg M string 错误信息
data M dict 这个用户的一级分类、二级分类和 spu 信息
示例:
request
/food_security_report/merchandise_tree
response
{
"code": 0,
"msg": "ok",
"data": [
{
"id": "A1659",
"name": "新鲜蔬菜",
"children": [
{
"id": "C553605",
"name": "万盛",
"upstream_id": "P207127"
},
]
},
]
}
其他注意事项: - 如果 children 中应该没有数据,那么这个 children 的值不存在
可供选择的送检机构 /food_security_report/detect_sender_list
Method:get
请求:
无参数,只要登录了就行
响应:
code M int 返回码,0表示成功,其他表示错误
msg M string 错误信息
data M list 这个用户可供选择的送检机构
示例:
request
/food_security_report/merchandise_tree
response
{
"code": 0,
"msg": "ok",
"data": [
"SZ-总仓-K10",
"K10蔬菜- 商品",
"K10-C端蔬菜",
"华农农产品供应链有限公司默认销售单"
]
}
逻辑:
博方视角:返回一个列表,包含 可选当前group下的所有供应商和正常站点 的站点名字
供应商视角:返回一个只有一个元素的列表,包含自己的站点名字
广州大学视角: 返回一个列表,包含 当前站点包含的供应商+自己 的站点名字
可供选择的检测机构 /food_security_report/detect_institution_list
Method:get
请求:
report_type M int 这个字段的值为[6:供应商; 8:第三方抽检]中的一种,代表了此时进入的入口类别
响应:
code M int 返回码,0表示成功,其他表示错误
msg M string 错误信息
data M list 这个用户可供选择的检测机构
示例:
request
/food_security_report/merchandise_tree
response
[]
逻辑:
供应商视角(供应商类型):返回空列表
博方视角(博方类型):返回一个只有一个元素的列表,包含自己的站点名字
广州大学(正常站点类型):返回一个只有一个元素的列表,包含自己的站点名字
备注
常数: g_is_report_group
bool
帐号配置
展示上的区别
供应商和博方都只能看到以及操作自己上传的报告,而广州大学可以看到并操作全部
供应商继续沿用目前的结算供应商,博方特别添加一个新的站点类型,前端对这个新类型站点做展示限制
对报告的权限,添加增删查改四个
id
广州大学食堂
浏览商品,下单
广州大学采购中心
- 商品维护:与供应商商议好商品价格后,对食堂进行定价;
- 供应商管理:维护各个供应商信息,以及维护供应商的可供应信息;
- 下单后分配供应商:当天的采购单生成后,更改供应商供应关系;
- 审核与结款:生成采购单与预入库单,确认后进入入库环节。通过“分摊“”折让“操作进行异常调整;通过进销存的结款单方式与供应商结款;
广州大学供应商
打印采购单
博方(第三方抽检方)
上传检测报告
其他工作
- 配置腾讯图片服务器新路径
http://testpic.guanmai.cn/report_pic/
时间表
时间 | 内容 | 完成情况 |
---|---|---|
6-19 ~ 6-20 | 完成并通过需求技术评审 | DONE |
6-20 ~ 6-20 | 配置站点类型 | DONE |
6-21 | /creat | DONE |
6-22 | /detail | DONE |
6-23 | /update | DONE |
6-29 ~ 6-30 | /list | DONE |
7-3 | /delete + 进入联调 | DONE |
上线前夕要做的事情
- 给线上服务器安装 sqlakeyset
- 告诉大家要以后用封装好的函数导出 excel