zz 6 年 前
コミット
d98e7c5279

+ 59 - 0
app/Console/Commands/channelCpcCode.php

@@ -0,0 +1,59 @@
+<?php
+
+namespace App\Console\Commands;
+
+use App\Modules\Channel\Services\ChannelService;
+use App\Modules\Channel\Services\CompanyService;
+use Illuminate\Console\Command;
+use Redis;
+
+class channelCpcCode extends Command
+{
+    /**
+     * The name and signature of the console command.
+     *
+     * @var string
+     */
+    protected $signature = 'channel:cpccode';
+
+    /**
+     * The console command description.
+     *
+     * @var string
+     */
+    protected $description = 'reset cpc code';
+
+    /**
+     * Create a new command instance.
+     *
+     * @return void
+     */
+    public function __construct()
+    {
+        parent::__construct();
+    }
+
+    /**
+     * Execute the console command.
+     *
+     * @return mixed
+     */
+    public function handle()
+    {
+        $this->start();
+    }
+
+    private function start()
+    {
+        $result = CompanyService::getAllCompanyCpcCode();
+        foreach ($result as $item){
+           $channels = ChannelService::getByChannelUserId($item->id);
+            $code = empty($item->channel)?'zw015':$item->channel;
+           if($channels->isNotEmpty()){
+               foreach ($channels as $channel) {
+                   Redis::hset('channel:setting:'.$channel->id,'cpc_channel',$code);
+               }
+           } 
+        }
+    }
+}

+ 2 - 1
app/Console/Kernel.php

@@ -21,7 +21,8 @@ class Kernel extends ConsoleKernel
         Commands\BookTest::class,
         Commands\BookAfterSpider::class,
         Commands\BookAttr::class,
-        Commands\YqBook::class
+        Commands\YqBook::class,
+        Commands\channelCpcCode::class
     ];
 
     /**

+ 8 - 0
app/Modules/Channel/Services/CompanyService.php

@@ -160,4 +160,12 @@ class CompanyService
             ->where('companies.id', $company_id)
             ->get();
     }
+
+    public static function getAllCompanyCpcCode()
+    {
+        return Company::leftJoin('cpcad_company_channels','cpcad_company_channels.company_id','=','companies.id')
+            ->select('cpcad_company_channels.channel','companies.id')
+            ->where('cpcad_company_channels.is_enabled','=',1)
+            ->get();
+    }
 }

+ 1 - 1
resources/views/wap/index.blade.php

@@ -32,7 +32,7 @@
     })();</script>
 <script id=options>window.options = {!! $options!!};</script>
 <script type=text/javascript
-        src=https://cdn-novel.iycdm.com/static2019-5-8/js/manifest.d1bb638f8238efae59ce.js></script>
+        src=https://cdn-novel.iycdm.com/static2019-5-8/js/manifest.0d7bf8f8d5f3da824718.js></script>
 <script type=text/javascript src=https://cdn-novel.iycdm.com/static2019-5-8/js/vendor.171a7cafc999efe6724c.js></script>
 <script type=text/javascript src=https://cdn-novel.iycdm.com/static2019-5-8/js/app.70a8d49eb429c9f6f58c.js></script>
 </body>