Browse Source

7日地域数据

sunhao 5 years ago
parent
commit
eb085b7e50

+ 4 - 6
app/Console/Commands/DisRoiByDay.php

@@ -21,10 +21,9 @@ class DisRoiByDay extends Command {
21 21
         $this->DisRoiByDay();
22 22
     }
23 23
     public function DisRoiByDay(){
24
-        for($i=23; $i>=7; $i--){
25
-            $stime = date('Y-m-d', strtotime('-'.$i.' day'));
26
-            $e = $i-7; 
27
-            $etime = $date = date('Y-m-d', strtotime('-'.$e.' day'));
24
+
25
+            $stime = date('Y-m-d', strtotime('-7 day'));   
26
+            $etime = $date = date('Y-m-d');
28 27
             //计算date 7天内的roi    
29 28
             $result = AdCost::select(DB::raw('sum(cost) as total_cost, sum(conversion_times) as conversion_times, city'))->where('ad_time', $stime)->groupBy('city')->get();
30 29
 
@@ -60,8 +59,7 @@ class DisRoiByDay extends Command {
60 59
                 //插入数据
61 60
                 $res = $this->insertData($data);
62 61
             }
63
-            
64
-        }
62
+  
65 63
     }
66 64
 
67 65
     /**

+ 1 - 0
app/Console/Commands/DisRoiByDayHistory.php

@@ -56,6 +56,7 @@ class DisRoiByDayHistory extends Command {
56 56
                 //$v['total_roi'] = $v['total_cost']>0 ? round($v['order_amount'] / $v['total_cost'], 4) * 100 .'%' : '';
57 57
                 $data['fan_count'] = count($phones);
58 58
                 $data['gzh_count'] = $v['conversion_times'];
59
+                $data['cost'] = $v['total_cost'];
59 60
                 //插入数据
60 61
                 $res = $this->insertData($data);
61 62
             }