[关闭]
@JackieQu 2018-06-12T17:05:47.000000Z 字数 8185 阅读 295

订单信息与商品评价

好热闹TeaShop


单一商品下单

Method and Url Structure

Method Resource URL
POST /market/product/purchase/&{pk}

Request and Parameters

Name Description Required Default
pk 商品 pk YES
quantity 商品数量 YES
address 地址 pk YES

Request

  1. {
  2. "quantity":1,
  3. "address": 3
  4. }

cURL Example

  1. curl -X GET -H 'Authorization: Token 7dccb47cbeb6a283013708ed983712fc6488aa74'
  2. http://127.0.0.1:8000/market/product/purchase/1/

JSON Response

  1. {
  2. "amount": "4.00",
  3. "channel": "alipay",
  4. "order_number": "12257268121962795696240003",
  5. "channel_display": "支付宝",
  6. "status": 0,
  7. "status_display": "待付款",
  8. "is_done": false,
  9. "bought_product_set": [
  10. {
  11. "product": {
  12. "pk": 1,
  13. "name": "青梅绿茶",
  14. "content": "绿茶配青梅还是头一回",
  15. "image": "https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=1031155128,3611764703&fm=27&gp=0.jpg",
  16. "price": "6.00",
  17. "offer_price": "4.00",
  18. "isoffer": false,
  19. "bought": 0
  20. },
  21. "quantity": 1,
  22. "amount": "4.00"
  23. }
  24. ],
  25. "address": {
  26. "pk": 3,
  27. "owner": "opSbp2JARhmzgmez9yObTt9aSybs2",
  28. "linkman": "陈浩南",
  29. "telephone": "12345678",
  30. "shipping_address": "铜锣湾",
  31. "default": true
  32. },
  33. "shipped": false,
  34. "express_name": null,
  35. "express_number": null
  36. }

购物车下单

Method and Url Structure

Method Resource URL
POST /market/cart/purchase/

Request and Parameters

Name Description Required Default
address 地址 pk YES

Request

  1. {
  2. "address":"3"
  3. }

cURL Example

  1. curl -X GET -H 'Authorization: Token 7dccb47cbeb6a283013708ed983712fc6488aa74'
  2. http://127.0.0.1:8000/market/cart/purchase/

JSON Response

  1. {
  2. "amount": "13.00",
  3. "channel": "alipay",
  4. "order_number": "12257268146003115696240003",
  5. "channel_display": "支付宝",
  6. "status": 0,
  7. "status_display": "待付款",
  8. "is_done": false,
  9. "address": {
  10. "pk": 3,
  11. "owner": "opSbp2JARhmzgmez9yObTt9aSybs2",
  12. "linkman": "陈浩南",
  13. "telephone": "12345678",
  14. "shipping_address": "铜锣湾",
  15. "default": true
  16. },
  17. "shipped": false
  18. }

订单列表

Method and Url Structure

Method Resource URL
GET /market/orders/

cURL Example

  1. curl -X PUT -H 'Authorization: Token 7dccb47cbeb6a283013708ed983712fc6488aa74'
  2. http://127.0.0.1:8000/market/orders/

JSON Response

  1. {
  2. "count": 2,
  3. "next": null,
  4. "previous": null,
  5. "results": [
  6. {
  7. "amount": "4.00",
  8. "channel": "alipay",
  9. "order_number": "12257268121962795696240003",
  10. "channel_display": "支付宝",
  11. "status": 0,
  12. "status_display": "待付款",
  13. "is_done": false,
  14. "bought_product_set": [
  15. {
  16. "product": {
  17. "pk": 1,
  18. "name": "青梅绿茶",
  19. "content": "绿茶配青梅还是头一回",
  20. "image": "https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=1031155128,3611764703&fm=27&gp=0.jpg",
  21. "price": "6.00",
  22. "offer_price": "4.00",
  23. "isoffer": false,
  24. "bought": 0
  25. },
  26. "quantity": 1,
  27. "amount": "4.00"
  28. }
  29. ],
  30. "address": {
  31. "pk": 3,
  32. "owner": "opSbp2JARhmzgmez9yObTt9aSybs2",
  33. "linkman": "陈浩南",
  34. "telephone": "12345678",
  35. "shipping_address": "铜锣湾",
  36. "default": true
  37. },
  38. "shipped": false,
  39. "express_name": null,
  40. "express_number": null
  41. },
  42. {
  43. "amount": "30.00",
  44. "channel": "alipay",
  45. "order_number": "12257268113481055696240003",
  46. "channel_display": "支付宝",
  47. "status": 0,
  48. "status_display": "待付款",
  49. "is_done": false,
  50. "bought_product_set": [
  51. {
  52. "product": {
  53. "pk": 2,
  54. "name": "冰红茶",
  55. "content": "冰力十足",
  56. "image": "https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=2077117511,2743730327&fm=200&gp=0.jpg",
  57. "price": "5.00",
  58. "offer_price": "3.00",
  59. "isoffer": false,
  60. "bought": 0
  61. },
  62. "quantity": 10,
  63. "amount": "30.00"
  64. }
  65. ],
  66. "address": {
  67. "pk": 2,
  68. "owner": "opSbp2JARhmzgmez9yObTt9aSybs2",
  69. "linkman": null,
  70. "telephone": null,
  71. "shipping_address": null,
  72. "default": false
  73. },
  74. "shipped": false,
  75. "express_name": null,
  76. "express_number": null
  77. }
  78. ]
  79. }

查看订单详情

Method and Url Structure

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

Request and Parameters

Name Description Required Default
order_number 订单号 YES

Request

  1. 12257268121962795696240003

cURL Example

  1. curl -X PUT -H 'Authorization: Token 7dccb47cbeb6a283013708ed983712fc6488aa74'
  2. http://127.0.0.1:8000/market/order/12257268121962795696240003/

JSON Response

  1. {
  2. "amount": "4.00",
  3. "channel": "alipay",
  4. "order_number": "12257268121962795696240003",
  5. "channel_display": "支付宝",
  6. "status": 0,
  7. "status_display": "待付款",
  8. "is_done": false,
  9. "bought_product_set": [
  10. {
  11. "product": {
  12. "pk": 1,
  13. "name": "青梅绿茶",
  14. "content": "绿茶配青梅还是头一回",
  15. "image": "https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=1031155128,3611764703&fm=27&gp=0.jpg",
  16. "price": "6.00",
  17. "offer_price": "4.00",
  18. "isoffer": false,
  19. "bought": 0
  20. },
  21. "quantity": 1,
  22. "amount": "4.00"
  23. }
  24. ],
  25. "address": {
  26. "pk": 3,
  27. "owner": "opSbp2JARhmzgmez9yObTt9aSybs2",
  28. "linkman": "陈浩南",
  29. "telephone": "12345678",
  30. "shipping_address": "铜锣湾",
  31. "default": true
  32. },
  33. "shipped": false,
  34. "express_name": null,
  35. "express_number": null
  36. }

订单支付

Method and Url Structure

Method Resource URL
PUT /market/order/payment/&{order_number}

Request and Parameters

Name Description Required Default
order_number 订单号 YES
channel 支付方式 YES
session 微信获取 YES

Request

  1. {
  2. "channel": "wx_small_program",
  3. "session": "751357904584"
  4. }

cURL Example

  1. curl -X PUT -H 'Authorization: Token 7dccb47cbeb6a283013708ed983712fc6488aa74'
  2. http://127.0.0.1:8000/market/order/payment/12257268125079605696240002/

JSON Response

  1. {
  2. "timeStamp": 1516331402,
  3. "nonceStr": 930736358684,
  4. "signType": "MD5",
  5. "paySign": "4767017D1643361CF3AD372C0B1444C7",
  6. "package": "prepay_id=wx201801191110027e5527e3990566770796"
  7. }

取消订单

Method and Url Structure

Method Resource URL
PUT /market/order/cancel/&{order_number}

Request and Parameters

Name Description Required Default
order_number 订单号 YES

Request

  1. 12257268113481055696240003

cURL Example

  1. curl -X PUT -H 'Authorization: Token 7dccb47cbeb6a283013708ed983712fc6488aa74'
  2. http://127.0.0.1:8000/market/order/cancel/12257268113481055696240003/

JSON Response

  1. {
  2. "amount": "30.00",
  3. "channel": "alipay",
  4. "order_number": "12257268113481055696240003",
  5. "channel_display": "支付宝",
  6. "status": 2,
  7. "status_display": "取消",
  8. "is_done": false,
  9. "bought_product_set": [
  10. {
  11. "product": {
  12. "pk": 2,
  13. "name": "冰红茶",
  14. "content": "冰力十足",
  15. "image": "https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=2077117511,2743730327&fm=200&gp=0.jpg",
  16. "price": "5.00",
  17. "offer_price": "3.00",
  18. "isoffer": false,
  19. "bought": 0
  20. },
  21. "quantity": 10,
  22. "amount": "30.00"
  23. }
  24. ],
  25. "address": {
  26. "pk": 2,
  27. "owner": "opSbp2JARhmzgmez9yObTt9aSybs2",
  28. "linkman": null,
  29. "telephone": null,
  30. "shipping_address": null,
  31. "default": false
  32. },
  33. "shipped": false,
  34. "express_name": null,
  35. "express_number": null
  36. }

删除订单

Method and Url Structure

Method Resource URL
DELETE /market/order/delete/&{order_number}

Request

  1. 12257268113481055696240003

cURL Example

  1. curl -X PUT -H 'Authorization: Token 7dccb47cbeb6a283013708ed983712fc6488aa74'
  2. http://127.0.0.1:8000/market/order/delete/12257268113481055696240003/

确认订单

Method and Url Structure

Method Resource URL
PUT /market/order/confirm/&{order_number}

Request and Parameters

Name Description Required Default
order_number 订单号 YES

Request

  1. 12257268111142305696240003

cURL Example

  1. curl -X PUT -H 'Authorization: Token 7dccb47cbeb6a283013708ed983712fc6488aa74'
  2. http://127.0.0.1:8000/market/order/confirm/12257268111142305696240003/

JSON Response

  1. {
  2. "amount": "30.00",
  3. "channel": "alipay",
  4. "order_number": "12257268111142305696240003",
  5. "channel_display": "支付宝",
  6. "status": 5,
  7. "status_display": "确认完成",
  8. "is_done": true,
  9. "bought_product_set": [
  10. {
  11. "product": {
  12. "pk": 1,
  13. "name": "冰红茶",
  14. "content": "冰力十足",
  15. "image": "https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=2077117511,2743730327&fm=200&gp=0.jpg",
  16. "price": "6.00",
  17. "offer_price": "3.00",
  18. "isoffer": false,
  19. "bought": 0
  20. },
  21. "quantity": 10,
  22. "amount": "30.00"
  23. }
  24. ],
  25. "address": {
  26. "pk": 3,
  27. "owner": "opSbp2JARhmzgmez9yObTt9aSybs2",
  28. "linkman": "陈浩南",
  29. "telephone": "12345678",
  30. "shipping_address": "铜锣湾",
  31. "default": true
  32. },
  33. "shipped": false,
  34. "express_name": null,
  35. "express_number": null
  36. }

订单评价

Method and Url Structure

Method Resource URL
PUT /market/order/evaluate/&{order_number}

Request and Parameters

Name Description Required Default
order_number 订单号 YES
product 订单中商品 pk YES
image 图片 NO
content 评论 NO
scores 评分 YES

Request

  1. [
  2. {
  3. "product":2,
  4. "image": "http://img.tuku.cn/file_thumb/201709/m2017092708563243.jpg",
  5. "content":"哈哈哈哈哈哈哈哈啊哈",
  6. "scores":5
  7. }
  8. ]

cURL Example

  1. curl -X PUT -H 'Authorization: Token 7dccb47cbeb6a283013708ed983712fc6488aa74'
  2. http://127.0.0.1:8000/market/order/evaluate/12257268122989705696240003/

JSON Response

  1. [
  2. {
  3. "pk": 2,
  4. "userinfo": {
  5. "owner": "opSbp2JARhmzgmez9yObTt9aSybs2",
  6. "name": "昵称",
  7. "avatar": "https://static1.bcjiaoyu.com/head7@3x.png"
  8. },
  9. "product": 2,
  10. "image": "http://img.tuku.cn/file_thumb/201709/m2017092708563243.jpg",
  11. "content": "哈哈哈哈哈哈哈哈啊哈",
  12. "scores": 5,
  13. "scores_display": "五星"
  14. }
  15. ]

查看商品评价

Method and Url Structure

Method Resource URL
GET /market/product/evaluations/&{pk}

Request and Parameters

Name Description Required Default
pk 商品 pk YES

Request

  1. 2

cURL Example

  1. curl -X PUT -H 'Authorization: Token 7dccb47cbeb6a283013708ed983712fc6488aa74'
  2. http://127.0.0.1:8000/market/product/evaluations/2/

JSON Response

  1. {
  2. "count": 1,
  3. "next": null,
  4. "previous": null,
  5. "results": [
  6. {
  7. "pk": 2,
  8. "userinfo": {
  9. "owner": "opSbp2JARhmzgmez9yObTt9aSybs2",
  10. "name": "昵称",
  11. "avatar": "https://static1.bcjiaoyu.com/head7@3x.png"
  12. },
  13. "product": 2,
  14. "image": "http://img.tuku.cn/file_thumb/201709/m2017092708563243.jpg",
  15. "content": "哈哈哈哈哈哈哈哈啊哈",
  16. "scores": 5,
  17. "scores_display": "五星"
  18. }
  19. ]
  20. }
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注