chengwl 4 years ago
parent
commit
34f1b255ee
1 changed files with 21 additions and 3 deletions
  1. 21 3
      controllers/IndexController.php

+ 21 - 3
controllers/IndexController.php

@@ -315,9 +315,27 @@ class IndexController extends \app\controllers\HomeController
       if(!$productName||!$store){
          $this->json(0,[],'参数错误');
       }
-      $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));
-      $productInfo=$ga->productInfo($productName,$store,$start_day,$end_day);
+      $storeConfig=[
+        'dp'=>$store,
+        'dimensionArr'=>[
+          'productSku'=>"ga:productSku",
+        ],
+        'metricArr'=>[
+          'itemRevenue'=>"ga:itemRevenue",
+          'uniquePurchases'=>"ga:uniquePurchases",
+          'itemQuantity'=>"ga:itemQuantity",
+          'ga:revenuePerTransaction'=>"ga:ga:revenuePerTransaction",
+        ],
+        'SegmentDimensionFilters'=>[
+          [
+            'name'=>'ga:productName',
+            'operator'=>'EXACT',
+            'expression'=>[$productName]
+          ]
+        ],
+        'date'=>['start_at'=>$start_day,'end_at'=>$end_day]
+      ];
+      $productInfo=$ga->productInfo($storeConfig);
       $this->json(1,$productInfo);      
     }