Browse Source

团队roi历史数据处理

shensong 4 years ago
parent
commit
682d3b39f9

+ 5 - 0
app/Console/Commands/DayGrandTeamTotal.php

@@ -93,6 +93,11 @@ class DayGrandTeamTotal extends Command {
93 93
             $data['cost60'] = DB::table('roi_team_total')->where('type', 5)->where('team_id', $team_id)->where('ad_time', '<', $date)->sum('cost');
94 94
             $data['order_count60'] = DB::table('roi_team_total')->where('type', 5)->where('team_id', $team_id)->where('ad_time', '<', $date)->sum('order_count');
95 95
             $data['order_amount60'] = DB::table('roi_team_total')->where('type', 5)->where('team_id', $team_id)->where('ad_time', '<', $date)->sum('order_amount');
96
+
97
+            $date = date('Y-m-d', strtotime('-90 day'));
98
+            $data['cost90'] = DB::table('roi_team_total')->where('type', 6)->where('team_id', $team_id)->where('ad_time', '<', $date)->sum('cost');
99
+            $data['order_count90'] = DB::table('roi_team_total')->where('type', 6)->where('team_id', $team_id)->where('ad_time', '<', $date)->sum('order_count');
100
+            $data['order_amount90'] = DB::table('roi_team_total')->where('type', 6)->where('team_id', $team_id)->where('ad_time', '<', $date)->sum('order_amount');
96 101
             $res = DB::table('day_grand_team_total')->insert($data);
97 102
             echo "\n日期:".$idate." 团队:".$team_id." 插入结果:".$res;
98 103
         }

+ 7 - 1
app/Console/Commands/DayGrandTeamTotalHistory.php

@@ -27,7 +27,7 @@ class DayGrandTeamTotalHistory extends Command {
27 27
     
28 28
     public function dayGrandTeamTotal(){
29 29
         $_start = '2019-09-04';
30
-        for($i=79;$i>=1;$i--){
30
+        for($i=117;$i>=1;$i--){
31 31
             $m = '-'.($i-1).' day';
32 32
             $n = '-'.$i.' day';
33 33
             $_end = date('Y-m-d', strtotime($m));
@@ -100,6 +100,12 @@ class DayGrandTeamTotalHistory extends Command {
100 100
                 $data['cost60'] = DB::table('roi_team_total')->where('type', 5)->where('team_id', $team_id)->where('ad_time', '<=', $date)->sum('cost');
101 101
                 $data['order_count60'] = DB::table('roi_team_total')->where('type', 5)->where('team_id', $team_id)->where('ad_time', '<=', $date)->sum('order_count');
102 102
                 $data['order_amount60'] = DB::table('roi_team_total')->where('type', 5)->where('team_id', $team_id)->where('ad_time', '<=', $date)->sum('order_amount');
103
+
104
+                $s90 = $idate. ' -90 day';
105
+                $date = date('Y-m-d', strtotime($s90));
106
+                $data['cost90'] = DB::table('roi_team_total')->where('type', 6)->where('team_id', $team_id)->where('ad_time', '<=', $date)->sum('cost');
107
+                $data['order_count90'] = DB::table('roi_team_total')->where('type', 6)->where('team_id', $team_id)->where('ad_time', '<=', $date)->sum('order_count');
108
+                $data['order_amount90'] = DB::table('roi_team_total')->where('type', 6)->where('team_id', $team_id)->where('ad_time', '<=', $date)->sum('order_amount');
103 109
                 $res = DB::table('day_grand_team_total')->insert($data);
104 110
                 echo "\n日期:".$idate." 团队:".$team_id." 插入结果:".$res;
105 111
             }

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

@@ -29,6 +29,7 @@ class RoiTeamTotal extends Command {
29 29
             3 => '-30 day',
30 30
             4 => '-45 day',
31 31
             5 => '-60 day',
32
+            6 => '-90 day',
32 33
         );
33 34
         //获取各个团队销售id
34 35
         $team_ids = Admin::getTeams();

+ 3 - 2
app/Console/Commands/RoiTeamTotalHistory.php

@@ -29,13 +29,14 @@ class RoiTeamTotalHistory extends Command {
29 29
             3 => '30',
30 30
             4 => '45',
31 31
             5 => '60',
32
+            6 => '90',
32 33
         );
33 34
         //获取各个团队销售id
34 35
         $team_ids = Admin::getTeams();
35 36
         $salerIds = $this->getTeamSalers($team_ids);
36
-        for($i=1;$i<6;$i++){
37
+        for($i=1;$i<7;$i++){
37 38
             $j_min = $timeArr[$i];
38
-            for($j=69; $j>=$j_min; $j--){
39
+            for($j=117; $j>=$j_min; $j--){
39 40
                 $stime = date('Y-m-d', strtotime('-'.$j.' day'));
40 41
                 $e = $j-$j_min; 
41 42
                 $etime = $date = date('Y-m-d', strtotime('-'.$e.' day'));

+ 1 - 0
app/Http/Controllers/Admin/StatisticsController.php

@@ -4982,6 +4982,7 @@ class StatisticsController extends Controller
4982 4982
             $v['roi30'] = $v['cost30']>0?  round($v['order_amount30'] / $v['cost30'], 4) * 100 .'%' : '';
4983 4983
             $v['roi45'] = $v['cost45']>0?  round($v['order_amount45'] / $v['cost45'], 4) * 100 .'%' : '';
4984 4984
             $v['roi60'] = $v['cost60']>0?  round($v['order_amount60'] / $v['cost60'], 4) * 100 .'%' : '';
4985
+            $v['roi90'] = $v['cost90']>0?  round($v['order_amount90'] / $v['cost90'], 4) * 100 .'%' : '';
4985 4986
             $v['team_name'] = $teamArr[$v['team_id']];
4986 4987
         }
4987 4988
 

+ 2 - 2
resources/views/statistics/dayGrandTeamTotal.blade.php

@@ -49,7 +49,7 @@
49 49
                     <th width="4%">累计30日roi</th>                                                                                            
50 50
                     <th width="4%">累计45日roi</th>                                                                                            
51 51
                     <th width="4%">累计60日roi</th>                                                                                            
52
-                                             
52
+                    <th width="4%">累计90日roi</th>
53 53
                 </tr>
54 54
                 </thead>
55 55
                 <tbody>
@@ -78,7 +78,7 @@
78 78
                             <td>{{$a['roi30']}}</td>                                                                                   
79 79
                             <td>{{$a['roi45']}}</td>                                                                                   
80 80
                             <td>{{$a['roi60']}}</td>                                                                                   
81
-                           
81
+                            <td>{{$a['roi90']}}</td>
82 82
                         </tr>
83 83
                     @endforeach
84 84
                 @endif