| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- <?php
- namespace app\extra\dyMini;
- use app\extra\dyLife\BasicLife;
- use yzh52521\EasyHttp\Http;
- class PlanLive extends BasicLife
- {
- /**
- * 发布/修改直播间定向佣金计划
- * @param int $planId
- * @param array $data
- * @return array
- */
- public function planData(int $planId = 0,array $data = []): array
- {
- $param = [
- "plan_id" => $planId, // 大于0 编辑
- "plan_name" => $data['name'],
- "merchant_phone" => $data['mobile']
- ];
- if (isset($data['star'])) {
- $param['douyin_id_list'] = $data['star'];
- }
- if (isset($data['goods'])) {
- $param['product_list'] = $data['goods'];
- }
- return $this->curlPostApi("api/match/v2/poi/save_live_oriented_plan/",$param);
- }
- /**
- * 取消计划
- * @param int $planId
- * @return array
- */
- public function planClose(int $planId = 0): array
- {
- $param = [
- "plan_update_list" => [
- [
- "plan_id" => $planId,
- "status" => 3
- ]
- ]
- ];
- return $this->curlPostApi("api/match/v2/poi/update_oriented_plan_status/",$param);
- }
- /**
- * 查下是否为cps订单
- * @param string $order
- * @return array
- */
- public function planOrder(string $order = ""): array
- {
- $param = [
- "order_id" => $order,
- ];
- return $this->curlPostApi("api/apps/trade/v2/order/query_cps/",$param);
- }
- /**
- * 修改商品佣金
- * @param array $data
- * @return array
- */
- public function setPlanGoods(array $data = []): array
- {
- $param = [
- "commission_rate" => $data['commission_rate'] * 100,
- "spu_id" => $data['goods_id'],
- "content_type" => 2,
- "plan_id" => $data['plan_id']
- ];
- echo json_encode($param)."\n";
- return $this->curlPostApi("api/match/v2/poi/save_common_plan/",$param);
- }
- /**
- * 查询定向佣金计划带货汇总数据
- * https://developer.open-douyin.com/docs/resource/zh-CN/mini-app/develop/server/locallife/general-ability/cps/query-oriented-plan-detail
- * @param array $planId
- * @return array
- */
- public function getPlanData(array $planId = []): array
- {
- $param = [
- "plan_id_list" => $planId
- ];
- echo json_encode($param)."\n";
- print_r([
- "access-token" => $this->getAccessToken(),
- "Rpc-Transit-Life-Account" => "7595228109947947043"
- ]);
- $result = Http::asJson()->withHeaders([
- "access-token" => $this->getAccessToken(),
- "Rpc-Transit-Life-Account" => "7595228109947947043"
- ])->post($this->gateway."api/match/v2/poi/oriented_plan_detail/",$param)->array();
- print_r($result);
- if(!empty($result['data']))
- {
- return $result['data'];
- }
- return [];
- }
- }
|