|
|
@@ -3,7 +3,6 @@
|
|
|
namespace app\v1\logic\tool\advertCost;
|
|
|
|
|
|
use app\v1\logic\advert\AgentSiteLogic;
|
|
|
-use GuzzleHttp\Client;
|
|
|
use plugin\saiadmin\app\model\system\SystemUser;
|
|
|
use support\think\Db;
|
|
|
|
|
|
@@ -24,7 +23,7 @@ abstract class BaseAdvertLogic
|
|
|
|
|
|
protected array $siteMap=[];
|
|
|
|
|
|
- protected int $apiId=0;
|
|
|
+ protected int $pmid=0;
|
|
|
private array $adminUserMap=[];
|
|
|
|
|
|
public function run($params=[])
|
|
|
@@ -48,8 +47,8 @@ abstract class BaseAdvertLogic
|
|
|
}
|
|
|
|
|
|
// 重跑用,传int
|
|
|
- if(!empty($params['api_id'])){
|
|
|
- $this->apiId = $params['api_id'];
|
|
|
+ if(!empty($params['pmid'])){
|
|
|
+ $this->pmid = $params['pmid'];
|
|
|
}
|
|
|
|
|
|
$this->siteMap = (new AgentSiteLogic())->getSiteAuth();
|
|
|
@@ -114,67 +113,31 @@ abstract class BaseAdvertLogic
|
|
|
}
|
|
|
|
|
|
// 获取需要拉取消耗的媒体账户
|
|
|
- protected function getTtAccountList(): array
|
|
|
+ protected function getAdvertiserMap($mediaId): array
|
|
|
{
|
|
|
- $table = "ad_jrtt_account_list";
|
|
|
- $where = [
|
|
|
- "status" => 1
|
|
|
- ];
|
|
|
-
|
|
|
- if($this->advertiserIds){
|
|
|
- $where['advertiser_id'] = $this->advertiserIds;
|
|
|
- }
|
|
|
-
|
|
|
- return Db::connect('db_advert')
|
|
|
- ->table($table)
|
|
|
- ->where($where)
|
|
|
- ->column("pmid, advertiser_id, advertiser_name, son_fandian");
|
|
|
- }
|
|
|
+ $advertiserListTable = "ad_advertiser_list"; // 子账户列表
|
|
|
+ $advertiserPmTable = "ad_advertiser_pm"; // 管家户,包含token
|
|
|
|
|
|
- protected function getTtTokenMap(): array
|
|
|
- {
|
|
|
- $table = "ad_jrtt_account";
|
|
|
$where = [
|
|
|
- "status" => 1
|
|
|
- ];
|
|
|
-
|
|
|
- if($this->apiId){
|
|
|
- $where['id'] = $this->apiId;
|
|
|
- }
|
|
|
-
|
|
|
- return Db::connect('db_advert')->table($table)->where($where)->column("access_token", "id");
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- // 获取需要拉取消耗的媒体账户
|
|
|
- protected function getGdtAccountList(): array
|
|
|
- {
|
|
|
- $table = "ad_gdt_account_list";
|
|
|
- $where = [
|
|
|
- "status" => 1
|
|
|
+ "a.status" => 1,
|
|
|
+ "b.status" => 1,
|
|
|
+ "a.media_id" => $mediaId
|
|
|
];
|
|
|
|
|
|
if($this->advertiserIds){
|
|
|
- $where['advertiser_id'] = $this->advertiserIds;
|
|
|
+ $where['a.advertiser_id'] = $this->advertiserIds;
|
|
|
}
|
|
|
|
|
|
- return Db::connect('db_advert')
|
|
|
- ->table($table)
|
|
|
- ->where($where)
|
|
|
- ->column("pmid, advertiser_id, advertiser_name, son_fandian");
|
|
|
- }
|
|
|
-
|
|
|
- protected function getGdtTokenMap(): array
|
|
|
- {
|
|
|
- $table = "ad_gdt_account";
|
|
|
- $where = [
|
|
|
- "status" => 1
|
|
|
- ];
|
|
|
-
|
|
|
- if($this->apiId){
|
|
|
- $where['id'] = $this->apiId;
|
|
|
+ if($this->pmid){
|
|
|
+ $where['a.pmid'] = $this->pmid;
|
|
|
}
|
|
|
|
|
|
- return Db::connect('db_advert')->table($table)->where($where)->column("access_token", "id");
|
|
|
+ $list = Db::connect('db_advert')
|
|
|
+ ->table($advertiserListTable)->alias("a")
|
|
|
+ ->join("{$advertiserPmTable} b", "a.pmid=b.id")
|
|
|
+ ->field("a.*, b.app_id, b.access_token, b.fandian")
|
|
|
+ ->where($where)->select()->toArray();
|
|
|
+
|
|
|
+ return $list ? array_column($list, null, "advertiser_id") : [];
|
|
|
}
|
|
|
}
|