<?php
/**
维护关注维护的redis数据格式
 */

namespace App\Console\Commands\Tool;

use Log;
use Illuminate\Console\Command;
use App\Modules\OfficialAccount\Models\TempForceSubscribeUsers;
use App\Modules\OfficialAccount\Services\MsgService;
use App\Modules\Channel\Models\Channel;
use DB;

class MaintainSubscribeReplyRedisData extends Command
{
    /**
     * 执行命令  MaintainSubscribeReplyRedisData
     *
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'MaintainSubscribeReplyRedisData {channel_id}';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '维护关注维护的redis数据格式';

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        ini_set('memory_limit', '1024M');
        print_r('memory_used:'.memory_get_usage()."\n");
        print_r("======维护关注维护的redis数据格式【任务执行开始】=====".date("y-m-d H:i:s"."\n"));
        $distribution_channel_id = $this->argument('channel_id');
        if($distribution_channel_id != 'all'){
        	\Log::info('start_one_initOriginReply:'.$distribution_channel_id);
        	MsgService::initOriginReply($distribution_channel_id);
        }else{
        	$distribution_channels = Channel::getAllChannels();
        	// 渠道列表
        	foreach($distribution_channels as $distribution_channel){
        		$distribution_channel_id = $distribution_channel->id;
        		\Log::info('start_initOriginReply:'.$distribution_channel_id);
        		MsgService::initOriginReply($distribution_channel_id);
        	}
        }
       
        
        print_r("======维护关注维护的redis数据格式 【任务执行结束】=====".date("y-m-d H:i:s"."\n"));
        print_r('memory_used:'.memory_get_usage()."\n");
    }
}