PlanLive.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <?php
  2. namespace app\extra\dyMini;
  3. use app\extra\dyLife\BasicLife;
  4. use yzh52521\EasyHttp\Http;
  5. class PlanLive extends BasicLife
  6. {
  7. /**
  8. * 发布/修改直播间定向佣金计划
  9. * @param int $planId
  10. * @param array $data
  11. * @return array
  12. */
  13. public function planData(int $planId = 0,array $data = []): array
  14. {
  15. $param = [
  16. "plan_id" => $planId, // 大于0 编辑
  17. "plan_name" => $data['name'],
  18. "merchant_phone" => $data['mobile']
  19. ];
  20. if (isset($data['star'])) {
  21. $param['douyin_id_list'] = $data['star'];
  22. }
  23. if (isset($data['goods'])) {
  24. $param['product_list'] = $data['goods'];
  25. }
  26. return $this->curlPostApi("api/match/v2/poi/save_live_oriented_plan/",$param);
  27. }
  28. /**
  29. * 取消计划
  30. * @param int $planId
  31. * @return array
  32. */
  33. public function planClose(int $planId = 0): array
  34. {
  35. $param = [
  36. "plan_update_list" => [
  37. [
  38. "plan_id" => $planId,
  39. "status" => 3
  40. ]
  41. ]
  42. ];
  43. return $this->curlPostApi("api/match/v2/poi/update_oriented_plan_status/",$param);
  44. }
  45. /**
  46. * 查下是否为cps订单
  47. * @param string $order
  48. * @return array
  49. */
  50. public function planOrder(string $order = ""): array
  51. {
  52. $param = [
  53. "order_id" => $order,
  54. ];
  55. return $this->curlPostApi("api/apps/trade/v2/order/query_cps/",$param);
  56. }
  57. /**
  58. * 修改商品佣金
  59. * @param array $data
  60. * @return array
  61. */
  62. public function setPlanGoods(array $data = []): array
  63. {
  64. $param = [
  65. "commission_rate" => $data['commission_rate'] * 100,
  66. "spu_id" => $data['goods_id'],
  67. "content_type" => 2,
  68. "plan_id" => $data['plan_id']
  69. ];
  70. echo json_encode($param)."\n";
  71. return $this->curlPostApi("api/match/v2/poi/save_common_plan/",$param);
  72. }
  73. /**
  74. * 查询定向佣金计划带货汇总数据
  75. * https://developer.open-douyin.com/docs/resource/zh-CN/mini-app/develop/server/locallife/general-ability/cps/query-oriented-plan-detail
  76. * @param array $planId
  77. * @return array
  78. */
  79. public function getPlanData(array $planId = []): array
  80. {
  81. $param = [
  82. "plan_id_list" => $planId
  83. ];
  84. echo json_encode($param)."\n";
  85. print_r([
  86. "access-token" => $this->getAccessToken(),
  87. "Rpc-Transit-Life-Account" => "7595228109947947043"
  88. ]);
  89. $result = Http::asJson()->withHeaders([
  90. "access-token" => $this->getAccessToken(),
  91. "Rpc-Transit-Life-Account" => "7595228109947947043"
  92. ])->post($this->gateway."api/match/v2/poi/oriented_plan_detail/",$param)->array();
  93. print_r($result);
  94. if(!empty($result['data']))
  95. {
  96. return $result['data'];
  97. }
  98. return [];
  99. }
  100. }