<?php
/**
 * Created by PhpStorm.
 * User: leo
 * Date: 2018/2/24
 * Time: 下午12:48
 */
namespace backendApi\modules\v1\controllers;

use common\helpers\Bonus;
use common\helpers\ChartData;
use common\helpers\Date;
use common\helpers\Form;
use common\models\FlowBonus;
use common\models\Period;
use common\models\UserInfo;

class DashboardController extends BaseController
{
    public $modelClass = FlowBonus::class;
    public function behaviors() {
        $behaviors = parent::behaviors();
        //$behaviors['contentNegotiator']['formats']['text/html'] = Response::FORMAT_JSON;
        return $behaviors;
    }

    /**
     * 控制台首页
     * @return mixed
     * @throws \yii\web\HttpException
     */
    public function actionIndex(){
//        print_r(\Yii::$app->user->validateAdminAction($this->id, $this->action->id));
        $nowTime = Date::nowTime();
        $period = Period::instance();
        $periodNum = $period->getNowPeriodNum();
        return static::notice([
            'nowTime' => $nowTime,
            'periodNum' => $periodNum,
        ]);
    }

    /**
     * 总累计的项目
     * @return array
     */
    public function actionTotalItem(){
        // $chart = ChartData::instance();
        // return [
        //     'totalBonus' => $chart->totalBonus(),
        //     'totalPerf' => $chart->totalPerf(),
        //     'totalWithdraw' => $chart->totalWithdraw(),
        //     'totalUser' => $chart->totalUser(),
        // ];

        return [];
    }

    /**
     * 会员注册量
     * @return mixed
     * @throws \yii\web\HttpException
     */
    public function actionRegNum(){
        $chartData = ChartData::instance();
        //$data = $chartData->getUserData();
        $data = [];
        return static::notice($data);
    }

    /**
     * 奖金量
     * @return mixed
     * @throws \yii\web\HttpException
     */
    public function actionBonusNum(){
        $chartData = ChartData::instance();
        // $data = $chartData->getBonusData();
        $data = [];
        return static::notice($data);
    }

    /**
     * 提现量
     * @return mixed
     * @throws \yii\web\HttpException
     */
    public function actionWithdrawNum(){
        $chartData = ChartData::instance();
        // $data = $chartData->getWithdrawData();
        $data = [];
        return static::notice($data);
    }
}