option('get'); if($options){ $this->fetchtoDB(); }else{ $this->start(); } } private function start() { $result = CompanyService::getAllCompanyCpcCode(); //$result = DB::table('') foreach ($result as $item){ $channel_user = DB::table('channel_users')->where('company_id',$item->id)->select('id')->get(); if($channel_user->isNotEmpty()){ foreach ($channel_user as $channel_user_id_info) { $channels = ChannelService::getByChannelUserId($channel_user_id_info->id); $code = empty($item->channel)?'zw001':$item->channel; if($channels->isNotEmpty()){ foreach ($channels as $channel) { Redis::hset('channel:setting:'.$channel->id,'cpc_channel',$code); } } } } } } private function fetchtoDB() { DB::select( 'truncate table cpc_channel_temp'); for ($i = 1;$i<7000;$i++){ //Redis::hset('channel:setting:'.$channel->id,'cpc_channel',$code); $c = \Redis::hget('channel:setting:'.$i,'cpc_channel'); if ($c) { \DB::table('cpc_channel_temp')->inset([ 'distribution_channel_id'=>$i, 'channel'=>$c, 'created_at'=>date('Y-m-d H:i:s') ]); } } } }