OrderData.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?php
  2. namespace app\extra\dyLife\data;
  3. use app\extra\dyLife\BasicLife;
  4. /**
  5. * 订单相关
  6. */
  7. class OrderData extends BasicLife
  8. {
  9. /**
  10. * 通过订单ID获取 encrypted_code
  11. * https://developer.open-douyin.com/docs/resource/zh-CN/local-life/develop/OpenAPI/general-capabilities/life.capacity.fulfilment/certificate.query
  12. * @param string $orderId
  13. * @param string $accountId
  14. * data['certificates'][0]['encrypted_code']
  15. * @return array
  16. */
  17. public function getCertificate(string $orderId = "",string $accountId = ""): array
  18. {
  19. $param = [
  20. "account_id" => $accountId,
  21. "order_id" => $orderId
  22. ];
  23. return $this->curlPostApi("goodlife/v1/fulfilment/certificate/query/",$param);
  24. }
  25. /**
  26. * 查询订单详情
  27. * @param string $orderId
  28. * @return array
  29. */
  30. public function getOrderData(string $orderId = ""): array
  31. {
  32. $param = [
  33. "account_id" => $this->baseAccountId,
  34. "order_id" => $orderId,
  35. "page_num" => 1,
  36. "page_size" => 10
  37. ];
  38. return $this->curlPostApi("goodlife/v1/trade/order/query/",$param);
  39. }
  40. /**
  41. * 发起核销
  42. * https://developer.open-douyin.com/docs/resource/zh-CN/local-life/develop/OpenAPI/general-capabilities/life.capacity.fulfilment/certificate.verify
  43. * @param array $data
  44. * data['verify_results'][0]
  45. * certificate_id、verify_id
  46. * @return array
  47. */
  48. public function verifyCertificate(array $data = []): array
  49. {
  50. $param = [
  51. "account_id" => $data['account_id'],
  52. "verify_token" => $data['pay_sn'],
  53. "encrypted_codes" => $data['encrypted_code'],
  54. "order_id" => $data['order_id'],
  55. "poi_id" => $data['poi_id']
  56. ];
  57. return $this->curlPostApi("goodlife/v1/fulfilment/certificate/verify/",$param);
  58. }
  59. /**
  60. * 撤销核销
  61. * https://developer.open-douyin.com/docs/resource/zh-CN/local-life/develop/OpenAPI/general-capabilities/life.capacity.fulfilment/certificate.cancel
  62. * @param array $data
  63. * data['cancel_results'][0]
  64. * result_code
  65. * @return array
  66. */
  67. public function cancelCertificate(array $data = []): array
  68. {
  69. $param = [
  70. "certificate_id" => $data['certificate_id'],
  71. "verify_id" => $data['verify_id'],
  72. "account_id" => $data['account_id']
  73. ];
  74. return $this->curlPostApi("goodlife/v1/fulfilment/certificate/verify/",$param);
  75. }
  76. /**
  77. * 订单退款
  78. * https://developer.open-douyin.com/docs/resource/zh-CN/local-life/develop/OpenAPI/general-capabilities/groupon-refund/order-refund-apply
  79. * @param string $orderId
  80. * @param array $codeList
  81. * @return array
  82. */
  83. public function cancelOrder(string $orderId = "",array $codeList = []): array
  84. {
  85. $param = [
  86. "refund_reason_code" => [305],
  87. "order_id" => $orderId,
  88. "certificate_id_list" => $codeList,
  89. "account_id" => $this->baseAccountId
  90. ];
  91. echo "手动退款参数\n";
  92. print_r($param);
  93. return $this->curlPostApi("goodlife/v1/groupon/order/refund/apply/",$param);
  94. }
  95. }