Browse Source

累计roi

sunhao 5 years ago
parent
commit
ec773a144c

+ 64 - 2
app/Http/Controllers/Admin/StatisticsController.php

@@ -4597,6 +4597,32 @@ class StatisticsController extends Controller
4597 4597
             $data['fugou_order_count'] = $data['order_count'] - $data['cust_count'];
4598 4598
             //总复购率
4599 4599
             $data['fugou_rate'] = $data['cust_count']>0 ? round($data['fugou_order_count'] / $data['cust_count'], 4) : '';
4600
+
4601
+            //7 - 60 roi汇总
4602
+            $data['cost7'] = DB::table('roi_total')->where('type', 1)->sum('cost');
4603
+            $data['order_count7'] = DB::table('roi_total')->where('type', 1)->sum('order_count');
4604
+            $data['order_amount7'] = DB::table('roi_total')->where('type', 1)->sum('order_amount');
4605
+            $data['roi7'] = $data['cost7']>0?  round($data['order_amount7'] / $data['cost7'], 4) * 100 .'%' : '';
4606
+
4607
+            $data['cost15'] = DB::table('roi_total')->where('type', 2)->sum('cost');
4608
+            $data['order_count15'] = DB::table('roi_total')->where('type', 2)->sum('order_count');
4609
+            $data['order_amount15'] = DB::table('roi_total')->where('type', 2)->sum('order_amount');
4610
+            $data['roi15'] = $data['cost15']>0?  round($data['order_amount15'] / $data['cost15'], 4) * 100 .'%' : '';
4611
+
4612
+            $data['cost30'] = DB::table('roi_total')->where('type', 3)->sum('cost');
4613
+            $data['order_count30'] = DB::table('roi_total')->where('type', 3)->sum('order_count');
4614
+            $data['order_amount30'] = DB::table('roi_total')->where('type', 3)->sum('order_amount');
4615
+            $data['roi30'] = $data['cost30']>0?  round($data['order_amount30'] / $data['cost30'], 4) * 100 .'%' : '';
4616
+
4617
+            $data['cost45'] = DB::table('roi_total')->where('type', 4)->sum('cost');
4618
+            $data['order_count45'] = DB::table('roi_total')->where('type', 4)->sum('order_count');
4619
+            $data['order_amount45'] = DB::table('roi_total')->where('type', 4)->sum('order_amount');
4620
+            $data['roi45'] = $data['cost45']>0?  round($data['order_amount45'] / $data['cost45'], 4) * 100 .'%' : '';
4621
+
4622
+            $data['cost60'] = DB::table('roi_total')->where('type', 5)->sum('cost');
4623
+            $data['order_count60'] = DB::table('roi_total')->where('type', 5)->sum('order_count');
4624
+            $data['order_amount60'] = DB::table('roi_total')->where('type', 5)->sum('order_amount');
4625
+            $data['roi60'] = $data['cost60']>0?  round($data['order_amount60'] / $data['cost60'], 4) * 100 .'%' : '';
4600 4626
         }else{
4601 4627
             $offset = ($page-1) * $pageSize - 1;
4602 4628
         }
@@ -4608,6 +4634,11 @@ class StatisticsController extends Controller
4608 4634
         foreach($result as $k=>&$v){
4609 4635
             $v['roi'] = $v['throw_cost']>0 ? round($v['order_amount'] / $v['throw_cost'], 4) * 100 .'%' : '';
4610 4636
             $v['fugou_rate'] = $v['cust_count']>0 ? round($v['fugou_order_count'] / $v['cust_count'], 4) : '';
4637
+            $v['roi7'] = $v['cost7']>0?  round($v['order_amount7'] / $v['cost7'], 4) * 100 .'%' : '';
4638
+            $v['roi15'] = $v['cost15']>0?  round($v['order_amount15'] / $v['cost15'], 4) * 100 .'%' : '';
4639
+            $v['roi30'] = $v['cost30']>0?  round($v['order_amount30'] / $v['cost30'], 4) * 100 .'%' : '';
4640
+            $v['roi45'] = $v['cost45']>0?  round($v['order_amount45'] / $v['cost45'], 4) * 100 .'%' : '';
4641
+            $v['roi60'] = $v['cost60']>0?  round($v['order_amount60'] / $v['cost60'], 4) * 100 .'%' : '';
4611 4642
         }
4612 4643
         if($page == 1){
4613 4644
             $result  = array_merge([$data], $result);
@@ -4663,16 +4694,47 @@ class StatisticsController extends Controller
4663 4694
         //总复购率
4664 4695
         $data['fugou_rate'] = $data['cust_count']>0 ? round($data['fugou_order_count'] / $data['cust_count'], 4) : '';
4665 4696
 
4697
+        //7 - 60 roi汇总
4698
+        $data['cost7'] = DB::table('roi_total')->where('type', 1)->sum('cost');
4699
+        $data['order_count7'] = DB::table('roi_total')->where('type', 1)->sum('order_count');
4700
+        $data['order_amount7'] = DB::table('roi_total')->where('type', 1)->sum('order_amount');
4701
+        $data['roi7'] = $data['cost7']>0?  round($data['order_amount7'] / $data['cost7'], 4) * 100 .'%' : '';
4702
+
4703
+        $data['cost15'] = DB::table('roi_total')->where('type', 2)->sum('cost');
4704
+        $data['order_count15'] = DB::table('roi_total')->where('type', 2)->sum('order_count');
4705
+        $data['order_amount15'] = DB::table('roi_total')->where('type', 2)->sum('order_amount');
4706
+        $data['roi15'] = $data['cost15']>0?  round($data['order_amount15'] / $data['cost15'], 4) * 100 .'%' : '';
4707
+
4708
+        $data['cost30'] = DB::table('roi_total')->where('type', 3)->sum('cost');
4709
+        $data['order_count30'] = DB::table('roi_total')->where('type', 3)->sum('order_count');
4710
+        $data['order_amount30'] = DB::table('roi_total')->where('type', 3)->sum('order_amount');
4711
+        $data['roi30'] = $data['cost30']>0?  round($data['order_amount30'] / $data['cost30'], 4) * 100 .'%' : '';
4712
+
4713
+        $data['cost45'] = DB::table('roi_total')->where('type', 4)->sum('cost');
4714
+        $data['order_count45'] = DB::table('roi_total')->where('type', 4)->sum('order_count');
4715
+        $data['order_amount45'] = DB::table('roi_total')->where('type', 4)->sum('order_amount');
4716
+        $data['roi45'] = $data['cost45']>0?  round($data['order_amount45'] / $data['cost45'], 4) * 100 .'%' : '';
4717
+
4718
+        $data['cost60'] = DB::table('roi_total')->where('type', 5)->sum('cost');
4719
+        $data['order_count60'] = DB::table('roi_total')->where('type', 5)->sum('order_count');
4720
+        $data['order_amount60'] = DB::table('roi_total')->where('type', 5)->sum('order_amount');
4721
+        $data['roi60'] = $data['cost60']>0?  round($data['order_amount60'] / $data['cost60'], 4) * 100 .'%' : '';
4722
+
4666 4723
         $result = DB::table('day_grand_total')->orderBy('idate', 'desc')->get();
4667 4724
         $result = json_decode(json_encode($result), true); 
4668 4725
         foreach($result as $k=>&$v){
4669 4726
             $v['roi'] = $v['throw_cost']>0 ? round($v['order_amount'] / $v['throw_cost'], 4) * 100 .'%' : '';
4670 4727
             $v['fugou_rate'] = $v['cust_count']>0 ? round($v['fugou_order_count'] / $v['cust_count'], 4) : '';
4728
+            $v['roi7'] = $v['cost7']>0?  round($v['order_amount7'] / $v['cost7'], 4) * 100 .'%' : '';
4729
+            $v['roi15'] = $v['cost15']>0?  round($v['order_amount15'] / $v['cost15'], 4) * 100 .'%' : '';
4730
+            $v['roi30'] = $v['cost30']>0?  round($v['order_amount30'] / $v['cost30'], 4) * 100 .'%' : '';
4731
+            $v['roi45'] = $v['cost45']>0?  round($v['order_amount45'] / $v['cost45'], 4) * 100 .'%' : '';
4732
+            $v['roi60'] = $v['cost60']>0?  round($v['order_amount60'] / $v['cost60'], 4) * 100 .'%' : '';
4671 4733
         }  
4672 4734
         $result  = array_merge([$data], $result);
4673 4735
 
4674
-        $indexKey = ['idate','throw_cost','cust_count','order_count','order_amount','goods_cost', 'freight_cost', 'aftersale_cost', 'refund_fee', 'profit', 'roi', 'fan_count', 'new_order_count', 'old_order_count', 'fugou_order_count', 'fugou_rate'];
4675
-        $title = ['汇总日期', '总投放', '总客户数', '总下单数', '总销售额', '总货品成本', '总运费成本', '总售后', '总退补', '总毛利', '累计ROI', '总加粉数', '总新粉单数', '总老粉单数', '总复购单数', '总复购率'];
4736
+        $indexKey = ['idate','throw_cost','cust_count','order_count','order_amount','goods_cost', 'freight_cost', 'aftersale_cost', 'refund_fee', 'profit', 'roi', 'fan_count', 'new_order_count', 'old_order_count', 'fugou_order_count', 'fugou_rate', 'roi7', 'roi15', 'roi30', 'roi45', 'roi60'];
4737
+        $title = ['汇总日期', '总投放', '总客户数', '总下单数', '总销售额', '总货品成本', '总运费成本', '总售后', '总退补', '总毛利', '累计ROI', '总加粉数', '总新粉单数', '总老粉单数', '总复购单数', '总复购率', '累计7日roi', '累计15日roi', '累计30日roi', '累计45日roi', '累计60日roi'];
4676 4738
         $filename = 'huizongshuj_'.date('Y-m-d_H').'.xlsx';
4677 4739
         return Order::export_excel($result, $filename, $indexKey, $title); 
4678 4740
     }

+ 26 - 16
resources/views/statistics/dayGrandTotal.blade.php

@@ -15,22 +15,27 @@
15 15
             <table class="table table-border table-bordered table-bg table-hover table-sort">
16 16
                 <thead>
17 17
                 <tr class="text-c">
18
-                    <th width="5%">汇总日期</th>
19
-                    <th width="5%">总投放</th>
20
-                    <th width="5%">总客户数</th>
21
-                    <th width="5%">总下单数</th>                  
22
-                    <th width="5%">总销售额</th>
23
-                    <th width="5%">总货品成本</th>                                                
24
-                    <th width="5%">总运费成本</th>                                                
25
-                    <th width="5%">总售后</th>  
26
-                    <th width="5%">总退补</th>  
27
-                    <th width="5%">总毛利</th>                                                                                            
28
-                    <th width="5%">累计roi</th>                                                                                            
29
-                    <th width="5%">总加粉数</th>                                                                                            
30
-                    <th width="5%">总新粉下单</th>                                                                                            
31
-                    <th width="5%">总老粉下单</th>                                                                                            
32
-                    <th width="5%">总复购单数</th>                                                                                            
33
-                    <th width="5%">总复购率</th>                                                                                            
18
+                    <th width="4%">汇总日期</th>
19
+                    <th width="4%">总投放</th>
20
+                    <th width="4%">总客户数</th>
21
+                    <th width="4%">总下单数</th>                  
22
+                    <th width="4%">总销售额</th>
23
+                    <th width="4%">总货品成本</th>                                                
24
+                    <th width="4%">总运费成本</th>                                                
25
+                    <th width="4%">总售后</th>  
26
+                    <th width="4%">总退补</th>  
27
+                    <th width="4%">总毛利</th>                                                                                            
28
+                    <th width="4%">累计roi</th>                                                                                            
29
+                    <th width="4%">总加粉数</th>                                                                                            
30
+                    <th width="4%">总新粉下单</th>                                                                                            
31
+                    <th width="4%">总老粉下单</th>                                                                                            
32
+                    <th width="4%">总复购单数</th>                                                                                            
33
+                    <th width="4%">总复购率</th>                                                                                            
34
+                    <th width="4%">累计7日roi</th>                                                                                            
35
+                    <th width="4%">累计15日roi</th>                                                                                            
36
+                    <th width="4%">累计30日roi</th>                                                                                            
37
+                    <th width="4%">累计45日roi</th>                                                                                            
38
+                    <th width="4%">累计60日roi</th>                                                                                            
34 39
                                              
35 40
                 </tr>
36 41
                 </thead>
@@ -54,6 +59,11 @@
54 59
                             <td>{{$a['old_order_count']}}</td>                                                                                   
55 60
                             <td>{{$a['fugou_order_count']}}</td>                                                                                   
56 61
                             <td>{{$a['fugou_rate']}}</td>                                                                                   
62
+                            <td>{{$a['roi7']}}</td>                                                                                   
63
+                            <td>{{$a['roi15']}}</td>                                                                                   
64
+                            <td>{{$a['roi30']}}</td>                                                                                   
65
+                            <td>{{$a['roi45']}}</td>                                                                                   
66
+                            <td>{{$a['roi60']}}</td>                                                                                   
57 67
                            
58 68
                         </tr>
59 69
                     @endforeach