[关闭]
@fuyb1986 2017-12-11T03:55:31.000000Z 字数 5117 阅读 557

商品兑换和虚拟商品

program_girl


商品列表

Method and URL Structure

Method Resource URL Authorization
GET /program_girl/market/exchange_products/ NO

Request Data

Name Description Required Default
_type 类型: 0, 1 NO
name 名字: 搜索(contains) NO

Request Parameter

  1. {
  2. "_type": 0,
  3. "name": "名字"
  4. }

cURL Example

  1. curl -X GET
  2. 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

  1. {
  2. "count": 2,
  3. "next": null,
  4. "previous": null,
  5. "results": [
  6. {
  7. "pk": 2,
  8. "name": "冰红茶",
  9. "content": "冰红茶饮料",
  10. "image": "http://thisisimages/",
  11. "diamond": 100,
  12. "bought": 0,
  13. "product_type": 0,
  14. "product_type_display": "实物商品",
  15. "create_time": "2017-11-03T14:45:33.719105"
  16. },
  17. {
  18. "pk": 1,
  19. "name": "虚拟商品",
  20. "content": "虚拟商品",
  21. "image": "http://thisisimages/",
  22. "diamond": 100,
  23. "product_type": 1,
  24. "product_type_display": "虚拟商品",
  25. "bought": 0,
  26. "create_time": "2017-11-03T14:44:12.099395"
  27. "category_detail":{
  28. "pk":1,
  29. "name":"Avatar",
  30. "desc":"",
  31. "style":"avatar_2",
  32. "action":"avatar"
  33. }
  34. }
  35. ]
  36. }

商品详情

Method and Url Structure

Method Resource URL
GET /market/exchange_products/${pk}/

cURL Example

  1. curl -X GET
  2. http://localhost/market/exchange_products/1/

JSON Response

  1. {
  2. "pk": 1,
  3. "name": "乌龙茶",
  4. "content": "乌龙茶饮料",
  5. "image": "http://thisisimages/",
  6. "diamond": 100,
  7. "bought": 0,
  8. "create_time": "2017-11-03T14:44:12.099395"
  9. }

兑换商品

Method and Url Structure

Method Resource URL
GET /market/exchange_products/purchase/${pk}/

cURL Example

  1. curl -X GET -H 'Authorization: Token 40563641ffd7245dfe80b7a8cd000e3bebc4d194'
  2. http://localhost:8000/market/exchange_products/purchase/1/

JSON Response

  1. {
  2. "message": "兑换成功"
  3. }

订单列表

Method and Url Structure

Method Resource URL
GET /market/exchange_product_order/

cURL Example

  1. curl -X GET -H 'Authorization: Token 40563641ffd7245dfe80b7a8cd000e3bebc4d194'
  2. http://localhost/market/exchange_product_order/

JSON Response

  1. {
  2. "count": 1,
  3. "next": null,
  4. "previous": null,
  5. "results": [
  6. {
  7. "owner": "18519791946",
  8. "exchange_product": {
  9. "pk": 1,
  10. "name": "乌龙茶",
  11. "content": "乌龙茶饮料",
  12. "image": "http://thisisimages/",
  13. "diamond": 100,
  14. "bought": 2,
  15. "create_time": "2017-11-03T14:44:12.099395"
  16. },
  17. "order_number": "17003298818986925262490011",
  18. "diamond": 100,
  19. "status": 1,
  20. "status_display": "已兑换",
  21. "create_time": "2017-11-03T15:00:47.217734"
  22. }
  23. ]
  24. }

兑换商品订单详情

Method and Url Structure

Method Resource URL
GET /market/exchange_product_order/&{order_number}/

cURL Example

  1. curl -X GET -H 'Authorization: Token 40563641ffd7245dfe80b7a8cd000e3bebc4d194'
  2. http://localhost:8000/market/exchange_product_order/17003298818986925262490011/

JSON Response

  1. {
  2. "owner": "18519791946",
  3. "exchange_product": {
  4. "pk": 1,
  5. "name": "乌龙茶",
  6. "content": "乌龙茶饮料",
  7. "image": "http://thisisimages/",
  8. "diamond": 100,
  9. "bought": 2,
  10. "create_time": "2017-11-03T14:44:12.099395"
  11. "category_detail":{
  12. "pk":1,
  13. "name":"Avatar",
  14. "desc":"",
  15. "style":"avatar_2",
  16. "action":"avatar"
  17. }
  18. },
  19. "order_number": "17003298818986925262490011",
  20. "diamond": 100,
  21. "status": 1,
  22. "status_display": "已兑换",
  23. "create_time": "2017-11-03T15:00:47.217734"
  24. }

用户的商品列表

Method and URL Structure

Method Resource URL Authorization
GET /program_girl/market/user_products/ YES

Request Data

Name Description Required Default
_type 类型: 0, 1 NO
status 状态: 0, 1 NO

Request Parameter

  1. {
  2. "_type": 1,
  3. "status": 0
  4. }

cURL Example

  1. curl -X GET
  2. http://localhost/market/user_products/

JSON Response

  1. {
  2. "count": 2,
  3. "next": null,
  4. "previous": null,
  5. "results": [
  6. {
  7. "pk": 129,
  8. "status": 0,
  9. "status_display": "未使用",
  10. "create_time": "2017-11-03T14:45:33.719105"
  11. "exchange_product": {
  12. "name": "虚拟商品2",
  13. "content": "虚拟商品2",
  14. "image": "http://thisisimages/",
  15. "diamond": 100,
  16. "bought": 0,
  17. "product_type": 0,
  18. "product_type_display": "虚拟商品",
  19. "create_time": "2017-10-01T00:00:00"
  20. "category_detail":{
  21. "pk":1,
  22. "name":"Avatar",
  23. "desc":"",
  24. "style":"avatar_2",
  25. "action":"avatar"
  26. }
  27. },
  28. },
  29. {
  30. "pk": 131,
  31. "status": 0,
  32. "status_display": "未使用",
  33. "create_time": "2017-11-03T14:45:33.719105"
  34. "exchange_product": {
  35. "exchange_product": {
  36. "name": "虚拟商品3",
  37. "content": "虚拟商品3",
  38. "image": "http://thisisimages/",
  39. "diamond": 100,
  40. "bought": 0,
  41. "product_type": 0,
  42. "product_type_display": "虚拟商品",
  43. "create_time": "2017-11-01T00:00:00"
  44. "category_detail":{
  45. "pk":1,
  46. "name":"Avatar",
  47. "desc":"",
  48. "style":"avatar_2",
  49. "action":"avatar"
  50. }
  51. },
  52. }
  53. ]
  54. }

使用/不使用商品i

Method and URL Structure

Method Resource URL Authorization
PUT /program_girl/market/use_product/{PK}/ YES
PUT /program_girl/market/unuse_product/{PK}/ YES

Request Data

Name Description Required Default
_type 类型: 0, 1 NO
status 状态: 0, 1 NO

Request Parameter

  1. {
  2. "_type": 1,
  3. "status": 0
  4. }

cURL Example

  1. curl -X GET
  2. http://localhost/market/use_product/129/

JSON Response

  1. {
  2. "pk": 129,
  3. "status": 1,
  4. "status_display": "使用",
  5. "create_time": "2017-11-03T14:45:33.719105"
  6. "exchange_product": {
  7. "name": "虚拟商品2",
  8. "content": "虚拟商品2",
  9. "image": "http://thisisimages/",
  10. "diamond": 100,
  11. "bought": 0,
  12. "product_type": 0,
  13. "product_type_display": "虚拟商品",
  14. "create_time": "2017-10-01T00:00:00"
  15. "category_detail":{
  16. "pk":1,
  17. "name":"Avatar",
  18. "desc":"",
  19. "style":"avatar_2",
  20. "action":"avatar"
  21. }
  22. },
  23. }

UserInfo 里返回已经使用的道具

Response

  1. {
  2. "pk":1,
  3. "owner":"18516271364",
  4. "name":"赵小明",
  5. "props":[{
  6. "owner":1,
  7. "exchange_product":{
  8. "pk":26,
  9. "name":"虚拟商品",
  10. "content":"虚拟商品",
  11. "image":"http://imag.example.com/1.png",
  12. "diamond":300,
  13. "bought":1,
  14. "create_time":"2017-12-07T12:31:21.049329",
  15. "product_type_display":"虚拟物品",
  16. "product_type":1
  17. "category_detail":{
  18. "pk":1,
  19. "name":"Avatar",
  20. "desc":"",
  21. "style":"avatar_2",
  22. "action":"avatar"
  23. }
  24. },
  25. "status":1,
  26. "status_display":"已使用",
  27. "create_time":"2017-12-07T12:31:21.084266",
  28. "pk":3
  29. }]
  30. }
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注