PC-202304251453\Administrator 5 kuukautta sitten
vanhempi
commit
37c1061ea3
1 muutettua tiedostoa jossa 12 lisäystä ja 5 poistoa
  1. 12 5
      app/v1/logic/advert/AgentSiteLogic.php

+ 12 - 5
app/v1/logic/advert/AgentSiteLogic.php

@@ -82,7 +82,11 @@ class AgentSiteLogic extends BaseLogic
      */
     public function getTtAccessToken($advertiserId)
     {
-        $data = Db::connect('db_advert')->table('ad_jrtt_account')->where('advertiser_id', $advertiserId)->where('status', 1)->value('access_token');
+        $data = Db::connect('db_advert')->table('ad_jrtt_account_list')->alias('a')
+            ->join('ad_jrtt_account b', 'a.pmid=b.id', 'left')
+            ->where('a.advertiser_id', $advertiserId)
+            ->value('access_token');
+
         return $data;
     }
 
@@ -116,18 +120,18 @@ class AgentSiteLogic extends BaseLogic
         $toutiaoGameData = (new GamePackageLogic())->getToutiaoGames();
 
         // 广告位ID集合
-        $siteIds = $data['site_ids'];
+        $siteIds = explode(",", $data['site_ids']);
         $gamePackageId = $data['game_package_id'];
         $fb = $data['fb']; // 分包标识
         $zh = $data['zh']; // 推送转化跟踪
         $advertiserId = $data['advertiser_id']; // 头条广告主ID
-        $gameId = $toutiaoGameData[$gamePackageId]['game_id'] ?? 0;
 
         // 检查游戏是否为头条媒体的母包
-        if(!$gamePackageId || !$toutiaoGameData[$gamePackageId]){
+        if(!$gamePackageId || empty($toutiaoGameData[$gamePackageId])){
             throw new ApiException('请选择推送的头条母包');
         }
 
+        $gameId = $toutiaoGameData[$gamePackageId]['game_id'] ?? 0;
         $appId = $toutiaoGameData[$gamePackageId]['tt_appid'] ?? 0;
         if(!$appId){
             throw new ApiException('母包管理没有设置头条APPID');
@@ -140,12 +144,14 @@ class AgentSiteLogic extends BaseLogic
 
         // 获取广告位数据
         $agentSiteMap =  $this->model->where(['id'=>$siteIds, 'media_id'=>1])->column('agent_id', 'id');
+
         if(count($agentSiteMap) != count($siteIds)){
             throw new ApiException('请选择头条媒体的广告位');
         }
 
         // 获取头条的access_token
         $accessToken = $this->getTtAccessToken($advertiserId);
+
         if(!$accessToken){
             throw new ApiException('推送头条的-access_token获取失败');
         }
@@ -296,7 +302,7 @@ class AgentSiteLogic extends BaseLogic
     protected function getTtAssetMap($advertiserId, $accessToken): array
     {
         $headers = [
-            'Access-Token: '.$accessToken,
+            'Access-Token' => $accessToken,
             'Content-Type' => 'application/json'
         ];
         $url = "https://api.oceanengine.com/open_api/2/tools/event/all_assets/list/?advertiser_id={$advertiserId}";
@@ -308,6 +314,7 @@ class AgentSiteLogic extends BaseLogic
         // 获取响应内容
         $result = $response->getBody()->getContents();
         $result = json_decode($result, true);
+
         $appMap = [];
         if($result['message']=='OK'){
             $assetIds = array_column($result['data']['asset_list'], "asset_id");