|
@@ -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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|