<?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\Finance\Models\BillPayMerchant;
use App\Modules\Finance\Services\BillPayMerchantService;
use App\Modules\Finance\Services\BillService;
use App\Modules\Finance\Services\FinanceService;
use Log;
use Illuminate\Console\Command;

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

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '每日生成结算单生成';

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        print_r("======每日生成结算单生成 【任务执行开始】=====".date("y-m-d H:i:s"."\n"));
        Log::info("======每日生成结算单生成 【任务执行开始】=====".date("y-m-d H:i:s"."\n"));
        FinanceService::makeDayDataStatistics();
        Log::info("======每日生成结算单生成 【任务执行结束】=====".date("y-m-d H:i:s"."\n"));
        print_r("======每日生成结算单生成 【任务执行结束】=====".date("y-m-d H:i:s"."\n"));
    }

    private function updateBranchAccount() {
        $channels = ChannelService::getAllChannels();
        foreach ($channels as $channel) {
            BillPayMerchant::where('distribution_channel');
        }
    }
}