购物车/订单文档
益安
1. 将商品添加到购物车
Description
用户向购物车中添加课程
Method and URL Structure
| Method |
Resource URL |
| POST |
/market/shop_detail/ |
Request Parameters
| Name |
Description |
Required |
Default |
| item_id |
课程或考试id |
Yes |
|
| item_type |
类型(course/examRule) |
Yes |
|
| Name |
Description |
Required |
Default |
| Authorization |
Token 7309fabd207c22e0a00eada158989b89ffe839ef |
Yes |
|
*Authorization的值为登录成功后返回值
cURL Example
curl -X POST -H 'Authorization: Token 7309fabd207c22e0a00eada158989b89ffe839ef' -d 'item_id=2&item_type=course' http://127.0.0.1:8000/market/shop_detail/
JSON Response
{ "pk": 1, "owner": "teacher", "course": { "pk": 1, "owner": "teacher", "category": null, "name": "数学", "description": "math", "click": 0, "payment_count": 0, "create_time": "2016-04-11T07:42:40.097367Z" }, "create_time": "2016-04-22T15:10:02.774016Z"}### or{ "pk": 5, "owner": "admin", "item_type": "examRule", "course": null, "examRule": { "pk": 2, "title": "python2考", "description": "python2考python2考python2考python2考python2考python2考python2考", "point": 2, "picture": "http://baidu.com", "price": "0.00", "exercise_number": 1 }, "create_time": "2016-06-28T07:08:34.991000Z"}
Error json Response
//商品不存在情况{"detail": "Not found."}//购物车已存在情况{"message": "你已经添加过该商品到购物车, 不要重复此操作."}
2. 获取购物车中所有商品信息
Description
用户查找自己购物车所有商品
Method and URL Structure
| Method |
Resource URL |
| GET |
/market/shop_list/ |
Request Parameters
默认分页取数据库中最新的10条数据
| Name |
Description |
Required |
Default |
| page |
page Number |
Yes |
1 |
| Name |
Description |
Required |
Default |
| Authorization |
Token 7309fabd207c22e0a00eada158989b89ffe839ef |
Yes |
|
*Authorization的值为登录成功后返回值
cURL Example
curl -X GET -H 'Authorization: Token 7309fabd207c22e0a00eada158989b89ffe839ef' http://127.0.0.1:8000/market/shop_list/?page=1
JSON Response
{ "count": 3, "next": null, "previous": null, "results": [ { "pk": 5, "owner": "admin", "item_type": "examRule", "course": null, "examRule": { "pk": 2, "title": "python2考", "description": "python2考python2考python2考python2考python2考python2考python2考", "point": 2, "picture": "http://baidu.com", "price": "0.00", "exercise_number": 1 }, "create_time": "2016-06-28T07:08:34.991000Z" }, { "pk": 2, "owner": "admin", "item_type": "examRule", "course": null, "examRule": { "pk": 1, "title": "python轻松一考", "description": "这是一个很不错的,能巩固python基础的考试", "point": 1, "picture": "http://pic22.nipic.com/20120801/6608733_154516839000_2.jpg", "price": "0.00", "exercise_number": 10 }, "create_time": "2016-06-28T05:59:08.431000Z" }, { "pk": 1, "owner": "admin", "item_type": "course", "course": { "pk": 1, "owner": "admin", "name": "python测试课程", "description": "bbbbc", "picture": "http://baidu.com", "amount": "0.00", "grade": "junior", "pay_course": "recommend", "pay_course_display": "recommend", "click": 0, "payment_count": 1, "create_time": "2016-06-22T10:09:10.753000Z", "category": { "pk": 1, "name": "python", "parent": -1 }, "course_type": "develop", "course_type_display": "开发", "authenticated": false, "support_exam": false, "excellent": false, "recommend": false, "videos": [], "examRule": [ { "pk": 1, "title": "python轻松一考", "description": "这是一个很不错的,能巩固python基础的考试", "point": 1, "picture": "http://pic22.nipic.com/20120801/6608733_154516839000_2.jpg", "price": "0.00", "exercise_number": 10 }, { "pk": 2, "title": "python2考", "description": "python2考python2考python2考python2考python2考python2考python2考", "point": 2, "picture": "http://baidu.com", "price": "0.00", "exercise_number": 1 } ] }, "examRule": null, "create_time": "2016-06-28T05:56:51.008000Z" } ]}
3. 删除购物车商品
Description
用户删除购物车商品
Method and URL Structure
| Method |
Resource URL |
| DELETE |
/market/shop_detail/ |
Request Parameters
| Name |
Description |
Required |
Default |
| item_id |
课程id/考试id |
Yes |
|
| item_type |
类型 |
Yes |
course/examRule |
| Name |
Description |
Required |
Default |
| Authorization |
Token 7309fabd207c22e0a00eada158989b89ffe839ef |
Yes |
|
*Authorization的值为登录成功后返回值
cURL Example
curl -X DELETE -H 'Authorization: Token 7309fabd207c22e0a00eada158989b89ffe839ef' -d 'item_id=1&item_type=2' http://127.0.0.1:8000/market/shop_detail/
JSON Response
| Name |
Description |
Default |
| detail |
失败原因 |
Not found |
| status |
成功 |
204 |
1. 创建订单
Description
用户创建订单
Method and URL Structure
| Method |
Resource URL |
| POST |
/market/order_create/ |
Request Parameters
| Name |
Description |
Required |
Default |
| courses |
课程编号或id |
Yes |
|
| exams |
考试编号或id(多个,分割) |
Yes |
|
| flag |
直接购买或者购物车购买 |
Yes |
0 |
| status |
订单状态 |
No |
0 |
| channel |
支付方式 |
No |
alipay |
| point |
安盾值 |
No |
|
| coupon |
优惠券的pk/id |
NO |
|
- status 订单状态分为三种:待付款(0)、已付款(1)、取消(2)
- channel 支付方式分为两种:微信支付(wx)、支付宝支付(alipay)
- flag 分两种:0代表直接购买,1代表通过购物车购买
JSON Request
{ "courses":"1,2", "flag":1,}
| Name |
Description |
Required |
Default |
| Authorization |
Token 7309fabd207c22e0a00eada158989b89ffe839ef |
Yes |
|
*Authorization的值为登录成功后返回值
cURL Example
curl -X POST -H 'Authorization: Token 7309fabd207c22e0a00eada158989b89ffe839ef' -d 'courses=1,2&flag=1&point=10' http://127.0.0.1:8000/market/order_create/
JSON Response
{ "pk": 4, "buyer": "admin", "order_no": "12134676924116330001", "courses": "1", "names": "python测试课程,python2016年度基础考试", "count": 2, "amount": "0.00", "status": 0, "flag": 1, "channel": "balance", "create_time": "2016-06-29T03:30:55.350000Z", "profile": { "pk": 1, "username": "admin", "nickname": "yinjj", "location": "1", "avatar_url": "http://baidu.com", "website": "http://baidu.com", "point": 12, "birthday": "2016-06-29", "level": "fresh", "level_display": "益安新人", "credit": 0, "credit_level": "fresh", "credit_level_display": "益安新生", "account": "0.00" }}
2. 查看订单详情
Description
用户查看具体订单
Method and URL Structure
| Method |
Resource URL |
| GET |
/market/order_detail/${pk}/ |
| Name |
Description |
Required |
Default |
| Authorization |
Token 7309fabd207c22e0a00eada158989b89ffe839ef |
Yes |
|
*Authorization的值为登录成功后返回值
cURL Example
curl -X GET -H 'Authorization: Token 7309fabd207c22e0a00eada158989b89ffe839ef' http://127.0.0.1:8000/market/order_detail/1/
JSON Response
{ "pk":1, "buyer":"student", "order_no":"12134676894811030002", "courses":"1,2", "names":"英语,物理", "count":2, "amount":"100.00", "status":0, "flag":1, "channel":"alipay", "create_time":"2016-04-23T09:11:13.065911Z"}
2. 取消订单
Description
用户取消具体订单
Method and URL Structure
| Method |
Resource URL |
| GET |
/market/order_detail/${pk}/ |
Request Parameters
| Name |
Description |
Required |
Default |
| status |
订单状态 |
Yes |
|
| Name |
Description |
Required |
Default |
| Authorization |
Token 7309fabd207c22e0a00eada158989b89ffe839ef |
Yes |
|
*Authorization的值为登录成功后返回值
cURL Example
curl -X PUT -H 'Authorization: Token 7309fabd207c22e0a00eada158989b89ffe839ef' http://127.0.0.1:8000/market/order_detail/1/ -d 'status=2'
JSON Response
{ "pk":1, "buyer":"student", "order_no":"12134676894811030002", "courses":"1,2", "amount":"100.00", "names":"英语,物理", "count":2, "status":2, "flag":1, "channel":"alipay", "create_time":"2016-04-23T09:11:13.065911Z"}
3. 删除订单
Description
用户删除具体订单
Method and URL Structure
| Method |
Resource URL |
| DELETE |
/market/order_detail/${pk}/ |
| Name |
Description |
Required |
Default |
| Authorization |
Token 7309fabd207c22e0a00eada158989b89ffe839ef |
Yes |
|
*Authorization的值为登录成功后返回值
cURL Example
curl -X DELETE -H 'Authorization: Token 7309fabd207c22e0a00eada158989b89ffe839ef' http://127.0.0.1:8000/market/order_detail/1/
JSON Response
| Name |
Description |
Default |
| detail |
失败原因 |
Not found |
| status |
成功 |
204 |
4. 用户查看自己订单
Description
用户查看自己的订单
Method and URL Structure
| Method |
Resource URL |
| GET |
/market/order-list/ |
Request Parameters
默认分页取数据库中最新的10条数据
| Name |
Description |
Required |
Default |
| page |
page Number |
Yes |
1 |
| Name |
Description |
Required |
Default |
| Authorization |
Token 7309fabd207c22e0a00eada158989b89ffe839ef |
Yes |
|
*Authorization的值为登录成功后返回值
cURL Example
curl -X GET -H 'Authorization: Token 7309fabd207c22e0a00eada158989b89ffe839ef' http://127.0.0.1:8000/market/order_list/?page=1
JSON Response
{ "count": 9, "next": null, "previous": null, "results": [ { "pk": 9, "buyer": "admin", "order_no": "12134676978762830001", "courses": "", "examRules": "1", "names": "python2016年度基础考试", "count": 1, "amount": "0.00", "status": 0, "flag": 1, "channel": "balance", "create_time": "2016-06-29T05:37:01.002000Z", "profile": { "pk": 1, "username": "admin", "nickname": "yinjj", "location": "1", "avatar_url": "http://baidu.com", "website": "http://baidu.com", "point": 12, "birthday": "2016-06-29", "level": "fresh", "level_display": "益安新人", "credit": 0, "credit_level": "fresh", "credit_level_display": "益安新生", "account": "0.00" } }, { "pk": 8, "buyer": "admin", "order_no": "12134676966364380001", "courses": "", "examRules": "1", "names": "python2016年度基础考试", "count": 1, "amount": "0.00", "status": 0, "flag": 1, "channel": "balance", "create_time": "2016-06-29T05:36:55.198000Z", "profile": { "pk": 1, "username": "admin", "nickname": "yinjj", "location": "1", "avatar_url": "http://baidu.com", "website": "http://baidu.com", "point": 12, "birthday": "2016-06-29", "level": "fresh", "level_display": "益安新人", "credit": 0, "credit_level": "fresh", "credit_level_display": "益安新生", "account": "0.00" } } ]}