商品兑换和虚拟商品
儿童编程
商品列表
Method and URL Structure
Method |
Resource URL |
Authorization |
GET |
/program_face2face/market/exchange_products/ |
NO |
Request Data
Name |
Description |
Required |
Default |
_type |
类型: 0, 1 |
NO |
|
name |
名字: 搜索(contains) |
NO |
|
Request Parameter
{
"_type": 0,
"name": "名字"
}
cURL Example
curl -X GET
http://localhost/market/exchange_products/
Exchange Product Data
Name |
Description |
name |
名字 |
content |
描述 |
image |
图片 |
diamond |
需要的钻石 |
bought |
兑换的数量 |
product_type |
类型:实物、虚拟道具 |
product_type |
类型的文字显示 |
category_detail |
虚拟道具的类别 |
Category Detail
Name |
Description |
name |
名字 |
desc |
描述 |
style |
样式名称 |
action |
作用到:头像(avatar)、背景(background) |
JSON Response
{
"count": 2,
"next": null,
"previous": null,
"results": [
{
"pk": 2,
"name": "冰红茶",
"content": "冰红茶饮料",
"image": "http://thisisimages/",
"diamond": 100,
"bought": 0,
"product_type": 0,
"product_type_display": "实物商品",
"create_time": "2017-11-03T14:45:33.719105"
},
{
"pk": 1,
"name": "虚拟商品",
"content": "虚拟商品",
"image": "http://thisisimages/",
"diamond": 100,
"product_type": 1,
"product_type_display": "虚拟商品",
"bought": 0,
"create_time": "2017-11-03T14:44:12.099395"
"category_detail":{
"pk":1,
"name":"Avatar",
"desc":"",
"style":"avatar_2",
"action":"avatar"
}
}
]
}
商品详情
Method and Url Structure
Method |
Resource URL |
GET |
/market/exchange_products/${pk}/ |
cURL Example
curl -X GET
http://localhost/market/exchange_products/1/
JSON Response
{
"pk": 1,
"name": "乌龙茶",
"content": "乌龙茶饮料",
"image": "http://thisisimages/",
"diamond": 100,
"bought": 0,
"create_time": "2017-11-03T14:44:12.099395"
}
兑换商品
Method and Url Structure
Method |
Resource URL |
GET |
/market/exchange_products/purchase/${pk}/ |
cURL Example
curl -X GET -H 'Authorization: Token 40563641ffd7245dfe80b7a8cd000e3bebc4d194'
http://localhost:8000/market/exchange_products/purchase/1/
JSON Response
{
"message": "兑换成功"
}
订单列表
Method and Url Structure
Method |
Resource URL |
GET |
/market/exchange_product_order/ |
cURL Example
curl -X GET -H 'Authorization: Token 40563641ffd7245dfe80b7a8cd000e3bebc4d194'
http://localhost/market/exchange_product_order/
JSON Response
{
"count": 1,
"next": null,
"previous": null,
"results": [
{
"owner": "18519791946",
"exchange_product": {
"pk": 1,
"name": "乌龙茶",
"content": "乌龙茶饮料",
"image": "http://thisisimages/",
"diamond": 100,
"bought": 2,
"create_time": "2017-11-03T14:44:12.099395"
},
"order_number": "17003298818986925262490011",
"diamond": 100,
"status": 1,
"status_display": "已兑换",
"create_time": "2017-11-03T15:00:47.217734"
}
]
}
兑换商品订单详情
Method and Url Structure
Method |
Resource URL |
GET |
/market/exchange_product_order/&{order_number}/ |
cURL Example
curl -X GET -H 'Authorization: Token 40563641ffd7245dfe80b7a8cd000e3bebc4d194'
http://localhost:8000/market/exchange_product_order/17003298818986925262490011/
JSON Response
{
"owner": "18519791946",
"exchange_product": {
"pk": 1,
"name": "乌龙茶",
"content": "乌龙茶饮料",
"image": "http://thisisimages/",
"diamond": 100,
"bought": 2,
"create_time": "2017-11-03T14:44:12.099395"
"category_detail":{
"pk":1,
"name":"Avatar",
"desc":"",
"style":"avatar_2",
"action":"avatar"
}
},
"order_number": "17003298818986925262490011",
"diamond": 100,
"status": 1,
"status_display": "已兑换",
"create_time": "2017-11-03T15:00:47.217734"
}
用户的商品列表
Method and URL Structure
Method |
Resource URL |
Authorization |
GET |
/program_face2face/market/user_products/ |
YES |
Request Data
Name |
Description |
Required |
Default |
_type |
类型: 0, 1 |
NO |
|
status |
状态: 0, 1 |
NO |
|
Request Parameter
{
"_type": 1,
"status": 0
}
cURL Example
curl -X GET
http://localhost/market/user_products/
JSON Response
{
"count": 2,
"next": null,
"previous": null,
"results": [
{
"pk": 129,
"status": 0,
"status_display": "未使用",
"create_time": "2017-11-03T14:45:33.719105"
"exchange_product": {
"name": "虚拟商品2",
"content": "虚拟商品2",
"image": "http://thisisimages/",
"diamond": 100,
"bought": 0,
"product_type": 0,
"product_type_display": "虚拟商品",
"create_time": "2017-10-01T00:00:00"
"category_detail":{
"pk":1,
"name":"Avatar",
"desc":"",
"style":"avatar_2",
"action":"avatar"
}
},
},
{
"pk": 131,
"status": 0,
"status_display": "未使用",
"create_time": "2017-11-03T14:45:33.719105"
"exchange_product": {
"exchange_product": {
"name": "虚拟商品3",
"content": "虚拟商品3",
"image": "http://thisisimages/",
"diamond": 100,
"bought": 0,
"product_type": 0,
"product_type_display": "虚拟商品",
"create_time": "2017-11-01T00:00:00"
"category_detail":{
"pk":1,
"name":"Avatar",
"desc":"",
"style":"avatar_2",
"action":"avatar"
}
},
}
]
}
使用/不使用商品
Method and URL Structure
Method |
Resource URL |
Authorization |
PUT |
/program_face2face/market/use_product/{PK}/ |
YES |
PUT |
/program_face2face/market/unuse_product/{PK}/ |
YES |
Request Data
Name |
Description |
Required |
Default |
_type |
类型: 0, 1 |
NO |
|
status |
状态: 0, 1 |
NO |
|
Request Parameter
{
"_type": 1,
"status": 0
}
cURL Example
curl -X GET
http://localhost/market/use_product/129/
JSON Response
{
"pk": 129,
"status": 1,
"status_display": "使用",
"create_time": "2017-11-03T14:45:33.719105"
"exchange_product": {
"name": "虚拟商品2",
"content": "虚拟商品2",
"image": "http://thisisimages/",
"diamond": 100,
"bought": 0,
"product_type": 0,
"product_type_display": "虚拟商品",
"create_time": "2017-10-01T00:00:00"
"category_detail":{
"pk":1,
"name":"Avatar",
"desc":"",
"style":"avatar_2",
"action":"avatar"
}
},
}
UserInfo 里返回已经使用的道具
Response
{
"pk":1,
"owner":"18516271364",
"name":"赵小明",
"props":[{
"owner":1,
"exchange_product":{
"pk":26,
"name":"虚拟商品",
"content":"虚拟商品",
"image":"http://imag.example.com/1.png",
"diamond":300,
"bought":1,
"create_time":"2017-12-07T12:31:21.049329",
"product_type_display":"虚拟物品",
"product_type":1
"category_detail":{
"pk":1,
"name":"Avatar",
"desc":"",
"style":"avatar_2",
"action":"avatar"
}
},
"status":1,
"status_display":"已使用",
"create_time":"2017-12-07T12:31:21.084266",
"pk":3
}]
}