1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- <?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)?'zw001':$item->channel;
- if($channels->isNotEmpty()){
- foreach ($channels as $channel) {
- Redis::hset('channel:setting:'.$channel->id,'cpc_channel',$code);
- }
- }
- }
- }
- }
|