<?php /** * Created by PhpStorm. * User: tandunzhao * Date: 2017/11/20 * Time: 下午5:26 */ namespace App\Console\Commands; use App\Modules\Channel\Services\ChannelService; use App\Modules\User\Services\UserSubscribeBehaviorStatsService; use Log; use Illuminate\Console\Command; use DB; class fansMaximumNotice extends Command { /** * 执行命令 php artisan force_user_active * * The name and signature of the console command. * * @var string */ protected $signature = 'addFansMaximumNotice'; /** * The console command description. * * @var string */ protected $description = '渠道阈值提醒'; /** * Execute the console command. * * @return mixed */ public function handle() { /*$channels = ChannelService::getAllChannels(); foreach ($channels as $channel) { $item = DB::table('official_accounts') ->where([ ['distribution_channel_id','=',$channel->id], ['subscribe_day_maximum','=',0], ['is_enabled','=',1] ]) ->first(); }*/ $res = DB::select("select official_accounts.* from distribution_channels left join official_accounts on official_accounts.distribution_channel_id=distribution_channels.id where official_accounts.subscribe_day_maximum=0 and official_accounts.is_enabled=1 and not exists( select fln.id from fans_limit_notice as fln where fln.distribution_channel_id=official_accounts.distribution_channel_id and fln.date='".date('Y-m-d')."' and fln.appid=official_accounts.appid)"); $data = []; foreach ($res as $item){ $data[] = array( 'distribution_channel_id'=>$item->distribution_channel_id, 'appid'=>$item->appid, 'title'=>'阈值提醒', 'account_nickname'=>$item->nickname, 'is_read'=>0, 'date'=>date('Y-m-d'), 'created_at'=>date('Y-m-d H:i:s'), 'updated_at'=>date('Y-m-d H:i:s') ); } $inserted = DB::table('fans_limit_notice')->insert($data); } }