<?php
/**
 * zhoulj
 * 2018-05-15
 */

namespace App\Console\Commands\CP;

use App\Modules\CP\Services\GenerateCpBookStatService;
use Illuminate\Console\Command;
use Log;

class GenerateCpBookStat extends Command
{
    /**
     * 执行命令   php artisan cp_generate_cp_book_stat
     *
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'cp_generate_cp_book_stat';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '每日CP图书订阅数据生成';

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        print_r("======每日CP图书订阅数据生成 【任务执行开始】=====" . date("y-m-d H:i:s" . "\n"));
        Log::info("======每日CP图书订阅数据生成【任务执行开始】=====" . date("y-m-d H:i:s" . "\n"));

        // 生成每日统计
        $date = date("Y-m-d", strtotime('-1 day'));
        GenerateCpBookStatService::generateCpBookDailyStat($date);
        //GenerateCpBookStatService::generateCpBookDailyStat2('2018-12-09');

        Log::info("======每日CP图书订阅数据生成 【任务执行结束】=====" . date("y-m-d H:i:s" . "\n"));
        print_r("======每日CP图书订阅数据生成 【任务执行结束】=====" . date("y-m-d H:i:s" . "\n"));
    }
}