<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use App\Modules\User\Models\Xcxuser;
use App\Modules\User\Models\XcxUserStat;
use App\Modules\Subscribe\Models\Order;

use DB;
class XcxStastical extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'xcx:stats';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {

    }

    private function start(){
        $channel = DB::select('select distinct distribution_channel_id from xcx_users');
        foreach ($channel as $v){
            /*$channel_id = $v->distribution_channel_id;
            $recharge = Order::where('status','PAID')
                ->where('pay_merchant_source','XIAOCHENGXU')
                ->where('created_at','>=',date('Y-m-d',time()-86400))
                ->where('created_at','<=',date('Y-m-d',time()))
                ->where('distribution_channel_id',$channel_id)
                ->sum('price');

            $total_recharge = Order::where('status','PAID')
                ->where('pay_merchant_source','XIAOCHENGXU')
                ->where('created_at','<',date('Y-m-d'))
                ->where('distribution_channel_id',$channel_id)
                ->sum('price');

            $new_user_num = Xcxuser::where('created_at','>=',date('Y-m-d',time()-86400))
                ->where('created_at','<=',date('Y-m-d'))
                ->where('distribution_channel_id',$channel_id)
                ->count();

            $total_user_num = Xcxuser::where('created_at','<',date('Y-m-d'))
                ->where('distribution_channel_id',$channel_id)
                ->count();*/
        }

    }
}
