PC-202304251453\Administrator il y a 5 mois
Parent
commit
a0b964dbd3

+ 16 - 0
app/process/advert/TtCostHour.php

@@ -0,0 +1,16 @@
+<?php
+
+namespace app\process\advert;
+use Workerman\Crontab\Crontab;
+use app\v1\logic\tool\advertCost\TtCostHourLogic;
+
+class TtCostHour
+{
+    public function onWorkerStart(): void
+    {
+        // 每 10分钟执行一次
+        new Crontab('0 */10 * * * *', function() {
+            (new TtCostHourLogic())->run();
+        });
+    }
+}

+ 7 - 2
app/v1/controller/advert/AgentSiteController.php

@@ -56,9 +56,14 @@ class AgentSiteController extends BaseController
         ]);
 
         if(!empty($where['agent_name'])){
-            $where['agent_id'] = $this->agentListLogic->where([
+            $agentIds = $this->agentListLogic->where([
                 ['name', 'like', '%'.$where['agent_name'].'%']
-            ])->value('id');
+            ])->column('id');
+
+            if($agentIds){
+                $where['agent_id'] = $agentIds;
+            }
+
             unset($where['agent_name']);
         }
 

+ 8 - 0
app/v1/model/advert/AgentSite.php

@@ -39,4 +39,12 @@ class AgentSite extends BaseNormalModel
         $query->where('name', 'like', '%'.$value.'%');
     }
 
+    /**
+     * agent_id 搜索
+     */
+    public function searchAgentIdAttr($query, $value)
+    {
+        $query->where('agent_id', 'in', $value);
+    }
+
 }

+ 4 - 0
config/process.php

@@ -78,4 +78,8 @@ return [
     'gdt_cost' =>  [
         'handler' => \app\process\advert\GdtCostHour::class,
     ],
+    // gdt 获取广告消耗
+    'tt_cost' =>  [
+        'handler' => \app\process\advert\TtCostHour::class,
+    ],
 ];