优惠券
益安
1. 创建优惠券
Description
用户创建优惠券
Method and URL Structure
| Method |
Resource URL |
| POST |
/coupon/coupons/ |
Request Parameters
| Name |
Description |
Required |
Default |
| source |
来源 |
Yes |
|
| amount |
优惠券金额 |
Yes |
|
| start_price |
起步价 |
NO |
|
| start_time |
开始时间 |
NO |
|
| end_time |
结束时间 |
NO |
|
| limit_number |
限领次数 |
NO |
1 |
source,0(直接发放)、1(点击领取)、2(抽奖发放)
| Name |
Description |
Required |
Default |
| Authorization |
Token 7309fabd207c22e0a00eada158989b89ffe839ef |
Yes |
|
*Authorization的值为登录成功后返回值
Request
{ "source":0, "amount":5, "start_price":5, "start_time":"2016-07-01 00:00:00", "end_time":"2016-07-03 00:00:00",}
cURL Example
curl -X POST -H 'Authorization: Token 610c16955313b1f1755857d44ce3a80c29f222d7' -d 'source=0&amount=5&start_price=5&start_time=2016-07-01 00:00:00&end_time=2016-07-03 00:00:00' http://127.0.0.1:8000/coupon/coupons/
JSON Response
{ "pk": 12, "owner": "root", "source": 0, "amount": 5, "start_price": 5, "start_time": "2016-07-01T00:00:00Z", "end_time": "2016-07-03T00:00:00Z", "limit_number":1,}
2. 修改优惠券信息
Description
用户修改优惠券的信息
Method and URL Structure
| Method |
Resource URL |
| PUT |
/coupon/coupons/${pk}/ |
Request Parameters
| Name |
Description |
Required |
Default |
| source |
来源 |
NO |
|
| amount |
优惠券金额 |
Yes |
|
| start_price |
起步价 |
NO |
|
| start_time |
开始时间 |
NO |
|
| end_time |
结束时间 |
NO |
|
| limit_number |
限领次数 |
NO |
1 |
| Name |
Description |
Required |
Default |
| Authorization |
Token 7309fabd207c22e0a00eada158989b89ffe839ef |
Yes |
|
*Authorization的值为登录成功后返回值
Request
{ "source": 0, "amount": 5, "start_price": 5, "start_time": "2016-07-01T00:00:00Z", "end_time": "2016-07-03T00:00:00Z"}
cURL Example
curl -X PUT -H 'Authorization: Token 610c16955313b1f1755857d44ce3a80c29f222d7' -d 'source=0&amount=5&start_price=5&start_time=2016-07-01 00:00:00&end_time=2016-07-03 00:00:00' http://127.0.0.1:8000/coupon/coupons/
JSON Response
{ "pk": 12, "owner": "root", "source": 0, "amount": 5, "start_price": 5, "start_time": "2016-07-01T00:00:00Z", "end_time": "2016-07-03T00:00:00Z", "limit_number":1,}
3. 删除优惠券
Description
用户删除试卷
Method and URL Structure
| Method |
Resource URL |
| DELETE |
/coupon/coupons/${pk}/ |
| Name |
Description |
Required |
Default |
| Authorization |
Token 7309fabd207c22e0a00eada158989b89ffe839ef |
Yes |
|
*Authorization的值为登录成功后返回值
cURL Example
curl -X DELETE -H 'Authorization: Token 610c16955313b1f1755857d44ce3a80c29f222d7' http://127.0.0.1:8000/coupon/coupons/1/
JSON Response
| Name |
Description |
Default |
| detail |
失败原因 |
Not found |
| status |
成功 |
204 |
4. 查看具体优惠券
Description
用户查询某一具体优惠券
Method and URL Structure
| Method |
Resource URL |
| GET |
/coupon/coupons/${pk}/ |
| Name |
Description |
Required |
Default |
| Authorization |
Token 7309fabd207c22e0a00eada158989b89ffe839ef |
Yes |
|
*Authorization的值为登录成功后返回值
cURL Example
curl -X GET -H 'Authorization: Token 610c16955313b1f1755857d44ce3a80c29f222d7' http://127.0.0.1:8000/coupon/coupons/1/
JSON Response
{ "pk": 1, "owner": "15670502158", "course": null, "title": "2015-2016学年初三数学期中考试", "point": 20, "credit": 50, "join_count": 0, "create_time": "2016-06-12T02:51:05.236221Z", "limit_number":1,}
5. 获取所有优惠券
Description
用户查看所有的优惠券
Method and URL Structure
| Method |
Resource URL |
| GET |
/coupon/coupons/ |
Request Parameters
默认分页取数据库中最新的10条数据
| Name |
Description |
Required |
Default |
| page |
page Number |
Yes |
1 |
| source |
优惠券来源 |
No |
|
| Name |
Description |
Required |
Default |
| Authorization |
Token 7309fabd207c22e0a00eada158989b89ffe839ef |
Yes |
|
*Authorization的值为登录成功后返回值
cURL Example
curl -X GET -H 'Authorization: Token 610c16955313b1f1755857d44ce3a80c29f222d7' http://127.0.0.1:8000/coupon/coupons/
JSON Response
{ "count": 7, "next": null, "previous": null, "results": [ { "pk": 11, "owner": "root", "source": 0, "amount": 10, "start_price": 0, "start_time": "2016-06-29T08:08:14.468451Z", "end_time": null, "limit_number":1, }, { "pk": 12, "owner": "root", "source": 0, "amount": 5, "start_price": 5, "start_time": "2016-07-01T00:00:00Z", "end_time": "2016-07-03T00:00:00Z", "limit_number":1, }, ... ]}
00. 用户领取优惠券(限总张数、限领)
Description
用户领取优惠券创建记录
Method and URL Structure
| Method |
Resource URL |
| POST |
/coupon/coupon_total_limit/ |
Request Parameters
| Name |
Description |
Required |
Default |
| coupon |
优惠券pk/id |
Yes |
|
| Name |
Description |
Required |
Default |
| Authorization |
Token 7309fabd207c22e0a00eada158989b89ffe839ef |
Yes |
|
*Authorization的值为登录成功后返回值
Request
{ "coupon":1,}
cURL Example
curl -X POST -H 'Authorization: Token 2deb42c137dbe6353d145559121bacd77fa77313cf0075c51ed608999363b1fa' -d 'coupon=1' http://127.0.0.1:8000/coupon/coupon_total_limit/
JSON Response Failure
第一种情况:{"status":-4,"message":"你已经领过了,不能再领了"}第二种情况:{"status":-4,"message":"不好意思,您来晚了。下次请早!"}
JSON Response Success
{ "pk": 1, "user": "root", "coupon": 1, "receive_time": "2016-06-30T06:48:17.240994Z", "spend_time": "2016-06-30T06:48:17.240596", "used": false, "order_no": null, "ineffect": false}
0. 用户领取优惠券(限领)
Description
用户领取优惠券创建记录
Method and URL Structure
| Method |
Resource URL |
| POST |
/coupon/coupon_limit/ |
Request Parameters
| Name |
Description |
Required |
Default |
| coupon |
优惠券pk/id |
Yes |
|
| Name |
Description |
Required |
Default |
| Authorization |
Token 7309fabd207c22e0a00eada158989b89ffe839ef |
Yes |
|
*Authorization的值为登录成功后返回值
Request
{ "coupon":1,}
cURL Example
curl -X POST -H 'Authorization: Token 610c16955313b1f1755857d44ce3a80c29f222d7' -d 'coupon=1' http://127.0.0.1:8000/coupon/coupon_limit/
JSON Response Failure
{"status":-4,"message":"你已经领过了,不能再领了!"}
JSON Response Success
{ "pk": 1, "user": "root", "coupon": 1, "receive_time": "2016-06-30T06:48:17.240994Z", "spend_time": "2016-06-30T06:48:17.240596", "used": false, "order_no": null, "ineffect": false}
1. 创建优惠券的记录
Description
用户领取优惠券创建记录
Method and URL Structure
| Method |
Resource URL |
| POST |
/coupon/coupon_records/ |
Request Parameters
| Name |
Description |
Required |
Default |
| coupon |
优惠券pk/id |
Yes |
|
| Name |
Description |
Required |
Default |
| Authorization |
Token 7309fabd207c22e0a00eada158989b89ffe839ef |
Yes |
|
*Authorization的值为登录成功后返回值
Request
{ "coupon":1,}
cURL Example
curl -X POST -H 'Authorization: Token 610c16955313b1f1755857d44ce3a80c29f222d7' -d 'coupon=1' http://127.0.0.1:8000/coupon/coupon_records/
JSON Response
{ "pk": 1, "user": "root", "coupon": 1, "receive_time": "2016-06-30T06:48:17.240994Z", "spend_time": "2016-06-30T06:48:17.240596", "used": false, "order_no": null, "ineffect": false}
2. 修改优惠券记录
Description
用户修改优惠券记录的信息
Method and URL Structure
| Method |
Resource URL |
| PUT |
/coupon/coupon_records/${pk}/ |
Request Parameters
| Name |
Description |
Required |
Default |
| coupon |
优惠券资源的pk/id |
Yes |
|
| order_no |
订单编号 |
NO |
|
| spend_time |
花费优惠券的时间 |
NO |
|
| used |
是否使用 |
NO |
|
| Name |
Description |
Required |
Default |
| Authorization |
Token 7309fabd207c22e0a00eada158989b89ffe839ef |
Yes |
|
*Authorization的值为登录成功后返回值
Request
{ "coupon":1,}
cURL Example
curl -X PUT -H 'Authorization: Token 610c16955313b1f1755857d44ce3a80c29f222d7' -d 'coupon=1' http://127.0.0.1:8000/coupon/coupon_records/1/
JSON Response
{ "pk": 1, "user": "root", "coupon": 1, "receive_time": "2016-06-30T06:48:17.240994Z", "spend_time": "2016-06-30T06:48:17.240596", "used": false, "order_no": null, "ineffect": false}
3. 删除优惠券的记录
Description
用户删除优惠卷的记录
Method and URL Structure
| Method |
Resource URL |
| DELETE |
/coupon/coupon_records/${pk}/ |
| Name |
Description |
Required |
Default |
| Authorization |
Token 7309fabd207c22e0a00eada158989b89ffe839ef |
Yes |
|
*Authorization的值为登录成功后返回值
cURL Example
curl -X DELETE -H 'Authorization: Token 610c16955313b1f1755857d44ce3a80c29f222d7' http://127.0.0.1:8000/coupon/coupon_records/1/
JSON Response
| Name |
Description |
Default |
| detail |
失败原因 |
Not found |
| status |
成功 |
204 |
4. 查看具体优惠券的记录
Description
用户查询某一具体优惠券的记录
Method and URL Structure
| Method |
Resource URL |
| GET |
/coupon/coupon_records/${pk}/ |
| Name |
Description |
Required |
Default |
| Authorization |
Token 7309fabd207c22e0a00eada158989b89ffe839ef |
Yes |
|
*Authorization的值为登录成功后返回值
cURL Example
curl -X GET -H 'Authorization: Token 610c16955313b1f1755857d44ce3a80c29f222d7' http://127.0.0.1:8000/coupon/coupon_records/1/
JSON Response
{ "pk": 1, "user": "root", "coupon": 1, "receive_time": "2016-06-30T06:48:17.240994Z", "spend_time": "2016-06-30T06:48:17.240596", "used": false, "order_no": null, "ineffect": false}
5. 获取我的优惠券
Description
用户查看所有的优惠券记录
Method and URL Structure
| Method |
Resource URL |
| GET |
/coupon/coupon_records/ |
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 610c16955313b1f1755857d44ce3a80c29f222d7' http://127.0.0.1:8000/coupon/coupon_records/
JSON Response
{ "count": 2, "next": null, "previous": null, "results": [ { "pk": 2, "user": "root", "coupon": 2, "receive_time": "2016-06-30T07:32:39.050840Z", "spend_time": "2016-06-30T07:32:25Z", "used": false, "order_no": "", "ineffect": true }, { "pk": 1, "user": "root", "coupon": 1, "receive_time": "2016-06-30T06:48:17.240994Z", "spend_time": "2016-06-30T06:48:17.240596Z", "used": false, "order_no": null, "ineffect": false } ]}
5. 获取我的优惠券总数
Description
用户查看所有的优惠券记录
Method and URL Structure
| Method |
Resource URL |
| GET |
/coupon/coupon_records/number/ |
| Name |
Description |
Required |
Default |
| Authorization |
Token 7309fabd207c22e0a00eada158989b89ffe839ef |
Yes |
|
*Authorization的值为登录成功后返回值
cURL Example
curl -X GET -H 'Authorization: Token 610c16955313b1f1755857d44ce3a80c29f222d7' http://127.0.0.1:8000/coupon/coupon_records/number/
JSON Response
{ "number": 1}