|
@@ -185,22 +185,27 @@ class IndexController extends \app\controllers\HomeController
|
|
|
public function actionStatistic(){
|
|
|
$ga=new GA();
|
|
|
$request = Yii::$app->request;
|
|
|
- $store=$request->get('store',"supernova");
|
|
|
+ $store=$request->get('store');
|
|
|
$start_day=$request->get('start', date('Y-m-d',time()-3600*24*8));
|
|
|
$end_day = $request->get('end', date('Y-m-d',time()-3600*24));
|
|
|
+ if(!$store){
|
|
|
+ $this->json(0,[],"缺少参数");
|
|
|
+ }
|
|
|
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
|
|
|
//销量
|
|
|
- $sells=$ga->visitors_geo($store,$start_day,$end_day);
|
|
|
- $product=$ga->product($store,$start_day,$end_day);
|
|
|
- $visitors=$ga->visitors_type($store,$start_day,$end_day);
|
|
|
- return [
|
|
|
- 'status'=>1,
|
|
|
- 'data'=>[
|
|
|
- 'sell'=>$sells,
|
|
|
- 'product'=>$product,
|
|
|
- 'visitor'=>$visitors,
|
|
|
- ],
|
|
|
+ try{
|
|
|
+ $sells=$ga->visitors_geo($store,$start_day,$end_day);
|
|
|
+ $product=$ga->product($store,$start_day,$end_day);
|
|
|
+ $visitors=$ga->visitors_type($store,$start_day,$end_day);
|
|
|
+ }catch(\Exception $e){
|
|
|
+ $this->json(0,[],$e->getMessage());
|
|
|
+ }
|
|
|
+ $data=[
|
|
|
+ 'sell'=>$sells,
|
|
|
+ 'product'=>$product,
|
|
|
+ 'visitor'=>$visitors,
|
|
|
];
|
|
|
+ $this->json(1,$data);
|
|
|
}
|
|
|
public function actionProductinfo(){
|
|
|
$ga=new GA();
|