<?php

namespace App\Http\Controllers\Wechat\Statistic;

use App\Http\Requests;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use EasyWeChat\Foundation\Application;
use EasyWeChat\Message\News;

/**
 * 公众号统计信息
 * @author zhoulingjie
 *
 */
class StatisticsController
{
    
    public function __construct($_param)
    {
    	$this->param = $_param;
		$this->app = $_param['app'];
    }
    
    /**
     * 得到公众号统计信息
     * @param Request $request
     */
    public function get_gzh_statistics($from_date,$to_date,$gzh_app_id)
    {
    	$result = array('code'=>1,'msg'=>'','data'=>array());
    	try{
    		$result['data']['user_cumulate'] = $this->app->stats->userCumulate($from_date, $to_date);//获取累计用户数据, 最大时间跨度:7;
    		$result['data']['user_summary'] = $this->app->stats->userSummary($from_date, $to_date);//获取用户增减数据, 最大时间跨度:7;
    		v($result);
    	}
    	// 加上\ 全局抓取
    	catch(\Exception $e){
    		$result['code'] = 0;
    		$result['msg'] = $e->getMessage();
    		v('get_gzh_statistics_ept:'.$gzh_app_id.' info:'.$e->getMessage());
    	}
    	
    	return $result;
    }
    
}