@tenlee
2016-03-16T14:19:05.000000Z
字数 4829
阅读 1977
SmartShop
这是智能购物系统商家端API接口的设计文档。
本系统的数据库设计以及用户端API设计戳此
声明:所有的接口都在服务器端使用了Session,所以调用的API都需要保存会话,每个POST或GET都必须包含正确的Cookie
说明:返回数据格式均为json,编码均为utf-8
token,请妥善保存此token,当需要登陆权限才能申请的数据时,如果时GET方法请带此token,POST方法也一样带上,token有效期为30天,过期返回userid invalid/api/v1/b/register POSTuser_id, user_password,busi_name,busi_tel, busi_addressuser_name, user_email, user_sex, user_age, user_tel, user_address
{"state": ["tel error","user_email error"]}
state有 OK, id register, password short,user_email error, tel error, user_age error
注: user_age格式为 YYYYMMDD,例如20150102
用户注册密码最少6位
商家注册密码最少6位
商家注册密码最少6位
/api/v1/b/login/POST,
{"state": "OK"}
State 有 OK,password error, not register
/api/v1/b/updateinfo POSTtoken,user_password,busi_name,busi_tel, busi_address, user_name, user_email, user_sex, user_age, user_tel, user_address
{"state": ["tel error","user_email error"]}
state有 OK, id register, password short,user_email error, tel error, user_age erro
/api/v1/b/getbusiinfo POSTtoken,
{"user_id": "testbusi", "busi_register": "20151212121212", "user_email": "", "busi_other": "", "user_register": "20151212121212", "busi_tel": "110", "user_age": "", "user_sex": "male", "busi_name": "北京华联航空港店", "state": "OK", "store_name": "", "user_address": "", "user_tel": "", "user_name": "", "busi_address": "China"}
详细字段说明见数据库设计文档
/api/v1/b/logout/GET,
{"state": "OK"}
/api/v1/b/getorderGET/api/v1/b/getorder?status=1,就是返回所有状态为的订单,即
{"orderlist":[{"address": "China", "order_status": 1, "total": 100.0, "send_time": "", "busi_id": "testbusi", "user_id": "testuser", "pay_time": "", "order_id": "20160101010203001", "submit_time": "20160218232206"}],"state": "OK"}
说明:根据订单状态即status进行筛选,其中返回的数据为数据库的字段,详细解释见数据库Order表设计,这里不在累赘。
如果没有订单,那么"orderlist"数组(JSON格式的数据)是空的。
状态state有OK,not login, status wrong, error.
submit_time,send_time,pay_time格式为年年年年月月日日时时分分秒秒
##### 3.8 查看订单详情
- 地址: /api/v1/b/getorderdetail/
- 方法:GET
- 必选参数: order_id
- 例如:
/api/v1/b/getorderdetail?order_id=20150102202122001
返回数据
{"state”: “OK”,"order": {"order_id": "20150102202122001", "user_id": "test","busi_id":"testbusi", "order_status": 1,"total":100.0, "address":"China","submit_time":"20150102202122","pay_time":"","send_time":""}"detail":[{"order_id":"20150102202122001","qcode":"1223234","num":4,"total_price”:5.0}{"order_id":"20150102202122001","qcode":"122355666","num":1,"total_price”:6.0}]}
state 有OK,error,not login
/api/v1/b/confirmpaymentGETorder_id订单号, token /api/v1/b/confirmpayment?order_id=20160101010203001&token=afasdfasdf,就是将20160101010203001的订单确认支付返回确认支付的结果
{"state":"OK"}
state有OK, `not login未登陆, orderid error订单号错误, completed已完成,
error其他错误
/api/v1/b/confirsendGETorderid订单号,token /api/v1/b/confirmsend?orderid=20160101010203001,就是将20160101010203001的订单确认正在打包派送返回确认的结果
{"state":"OK"}
state有OK成功, not login未登陆, orderid error订单号错误, completed已完成,
not pay未支付,error其他错误
/api/v1/b/goodsGETqcode,若有此参数则返回相应的一个商品信息,若无则返回全部商品信息返回该商家的所有商品的信息
例如没有参数,返回的信息,
{"goods": [{"price": 100.0, "qcode": "9787115373991", "good_name": "Flask web开发", "good_des": "Flask web开发", "busi_id": "testbusi", "rest": 100.0},{"price": 5.0, "qcode": "6901028164542", "good_name": "红旗渠银河之光", "good_des": "红旗渠银河之光", "busi_id": "testbusi", "rest": 100.0}], "state": "OK}
例如/api/v1/b/goods/?token=f5228a9ed14edefa057f060d14cf7c40&qcode=9787115373991返回为
{"good": {"good_name": "Flask web开发", "good_des": "Flask web开发", "busi_id": "testbusi", "price": 100.0, "qcode": "9787115373991", "rest": 100.0}, "state": "OK"}
注意:没有参数情况下,json数据是goods数组,有参数情况下是good的object
当然,你也可以使用下面的/api/v1/getgoodprice/链接获取商品信息,区别时一个需要登陆,一个不需要登陆。
state为OK, not login, error
/api/v1/getgoodprice/GETqcode商品条形码, busi_id 商家id /api/v1/getgoodprice?qcode=**&busi_id=**
{"state": "OK", "good_des": "Flask入门", "qcode": "9787115373991", "price": 59.0, "good_name": "FlaskWeb开发"}
| 字段 | 字段说明 |
|---|---|
| state | 状态,服务器返回的状态,有 OK, error, not found |
| qcode | 商品条形码 |
| good_name | 商品名称 |
| price | 商品价格 |
| good_des | 商品描述 |
/api/v1/b/changegoodPOSToperate操作, qcode商品条码,其中operate必须为delete/api/v1/b/changegood,其中POST参数operate=delete以及 qcode=123表示要删除123商品 state有OK, not login,qcode error条形码错误,error其他错误/api/v1/b/changegoodPOSToperate,qcode,good_name,good_des,price,rest,其中operate参数必须为addorchange
{"state":"OK"}
state有OK, not login, qcode error, error其他错误,
备注:数据的格式验证,比如价格须为实数,库存rest须为整数等格式在客户端验证,如果错误则统一返回为error
/api/v1/b/changegoodPOSToperate,qcode,good_name,good_des,price,rest,其中operate参数必须为addorchangerest必须为正整数, price必须为正实数,请在客户端验证,否则返回errorstate有OK, error, not login
/api/v1/b/changeallorderGETtoken,status 必须有,且必须为正数,status即为你要更改成的状态/api/v1/b/changeallorder?status=1&token=asdfadf
{"state":"OK"}
OK, error, not login以下暂且没写