sunhao 5 年之前
父节点
当前提交
892bf1b5fd

+ 73 - 0
app/Console/Commands/DisRoiByDay15.php

@@ -0,0 +1,73 @@
1
+<?php 
2
+namespace App\Console\Commands;
3
+
4
+use Illuminate\Console\Command;
5
+use DB;
6
+use App\AdCost;
7
+class DisRoiByDay15 extends Command {
8
+
9
+    protected $signature = 'DisRoiByDay15';
10
+
11
+    /**
12
+     * The console command description.
13
+     *
14
+     * @var string
15
+     */
16
+    protected $description = '地域15日roi';
17
+
18
+
19
+    public function handle()
20
+    {
21
+        $this->DisRoiByDay15();
22
+    }
23
+    public function DisRoiByDay15(){
24
+
25
+            $stime = date('Y-m-d', strtotime('-15 day'));   
26
+            $etime = $date = date('Y-m-d');
27
+            //计算date 15天内的roi    
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();
29
+
30
+            $result = json_decode(json_encode($result), true);           
31
+            foreach($result as $k=>&$v){
32
+                $data = array();
33
+                $data['ad_time'] = $stime;
34
+                $data['city'] = $v['city'];               
35
+                //新粉收入
36
+                //当日加粉
37
+                $city_name = str_replace('市', '', $v['city']);
38
+                $phones = DB::table('customers')->where('fanTime', $stime)->where('receiverCity','like', '%'.$city_name.'%')->lists('phone');
39
+                #当日加粉15日订单总计:
40
+                $order = DB::table('order')->select(DB::raw('sum(receivedAmount) as order_amount, count(1) as order_count'))->whereIn('receiverMobile', $phones)->where('createTime', '>=', $stime)->where('createTime', '<', $etime)->where('is_del', 0)->first();
41
+                #当日新粉成单:            
42
+                $new_order = DB::table('order')->select(DB::raw('sum(receivedAmount) as order_amount, count(1) as order_count'))->where('createTime','>=', $stime)->where('createTime','<=', $stime.' 23:59:59')->where('is_del', 0)->whereIn('receiverMobile', $phones)->first();
43
+               
44
+                // 1.当日新粉成单数
45
+                $data['new_fan_order_count'] = $new_order->order_count;
46
+                // 2.当日新粉成交额 
47
+                $data['new_fan_order_amount'] = $new_order->order_amount;
48
+                // 3.当日粉丝总成交额
49
+                $data['order_amount'] = $order->order_amount;
50
+                // 15日总单数
51
+                $data['order_count'] = $order->order_count;
52
+                //新粉roi
53
+                //$v['new_roi'] = $v['total_cost']>0 ? round($v['new_order_amount'] / $v['total_cost'], 4) * 100 .'%' : '';
54
+                //15日累计roi
55
+                //$v['total_roi'] = $v['total_cost']>0 ? round($v['order_amount'] / $v['total_cost'], 4) * 100 .'%' : '';
56
+                $data['fan_count'] = count($phones);
57
+                $data['gzh_count'] = $v['conversion_times'];
58
+                $data['cost'] = $v['total_cost'];
59
+                //插入数据
60
+                $res = $this->insertData($data);
61
+            }
62
+  
63
+    }
64
+
65
+    /**
66
+     * @param idate:统计日期 rate:成单率 date:昨日
67
+     *
68
+     */
69
+    public function insertData($data){        
70
+        return DB::table('district_roi_15')->insert($data);
71
+    }
72
+
73
+}

+ 75 - 0
app/Console/Commands/DisRoiByDay15History.php

@@ -0,0 +1,75 @@
1
+<?php 
2
+namespace App\Console\Commands;
3
+
4
+use Illuminate\Console\Command;
5
+use DB;
6
+use App\AdCost;
7
+class DisRoiByDayHistory extends Command {
8
+
9
+    protected $signature = 'DisRoiByDayHistory';
10
+
11
+    /**
12
+     * The console command description.
13
+     *
14
+     * @var string
15
+     */
16
+    protected $description = '地域15日roi';
17
+
18
+
19
+    public function handle()
20
+    {
21
+        $this->DisRoiByDayHistory();
22
+    }
23
+    public function DisRoiByDayHistory(){
24
+        for($i=41; $i>=15; $i--){
25
+            $stime = date('Y-m-d', strtotime('-'.$i.' day'));
26
+            $e = $i-15; 
27
+            $etime = $date = date('Y-m-d', strtotime('-'.$e.' day'));
28
+            //计算date 15天内的roi    
29
+            $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
+
31
+            $result = json_decode(json_encode($result), true);           
32
+            foreach($result as $k=>&$v){
33
+                $data = array();
34
+                $data['ad_time'] = $stime;
35
+                $data['city'] = $v['city'];               
36
+                //新粉收入
37
+                //当日加粉
38
+                $city_name = str_replace('市', '', $v['city']);
39
+                $phones = DB::table('customers')->where('fanTime', $stime)->where('receiverCity','like', '%'.$city_name.'%')->lists('phone');
40
+                #当日加粉15日订单总计:
41
+                $order = DB::table('order')->select(DB::raw('sum(receivedAmount) as order_amount, count(1) as order_count'))->whereIn('receiverMobile', $phones)->where('createTime', '>=', $stime)->where('createTime', '<', $etime)->where('is_del', 0)->first();
42
+                #当日新粉成单:            
43
+                $new_order = DB::table('order')->select(DB::raw('sum(receivedAmount) as order_amount, count(1) as order_count'))->where('createTime','>=', $stime)->where('createTime','<=', $stime.' 23:59:59')->where('is_del', 0)->whereIn('receiverMobile', $phones)->first();
44
+               
45
+                // 1.当日新粉成单数
46
+                $data['new_fan_order_count'] = $new_order->order_count;
47
+                // 2.当日新粉成交额 
48
+                $data['new_fan_order_amount'] = $new_order->order_amount;
49
+                // 3.当日粉丝总成交额
50
+                $data['order_amount'] = $order->order_amount;
51
+                // 15日总单数
52
+                $data['order_count'] = $order->order_count;
53
+                //新粉roi
54
+                //$v['new_roi'] = $v['total_cost']>0 ? round($v['new_order_amount'] / $v['total_cost'], 4) * 100 .'%' : '';
55
+                //15日累计roi
56
+                //$v['total_roi'] = $v['total_cost']>0 ? round($v['order_amount'] / $v['total_cost'], 4) * 100 .'%' : '';
57
+                $data['fan_count'] = count($phones);
58
+                $data['gzh_count'] = $v['conversion_times'];
59
+                $data['cost'] = $v['total_cost'];
60
+                //插入数据
61
+                $res = $this->insertData($data);
62
+            }
63
+            
64
+        }
65
+    }
66
+
67
+    /**
68
+     * @param idate:统计日期 rate:成单率 date:昨日
69
+     *
70
+     */
71
+    public function insertData($data){        
72
+        return DB::table('district_roi_15')->insert($data);
73
+    }
74
+
75
+}

+ 73 - 0
app/Console/Commands/DisRoiByDay45.php

@@ -0,0 +1,73 @@
1
+<?php 
2
+namespace App\Console\Commands;
3
+
4
+use Illuminate\Console\Command;
5
+use DB;
6
+use App\AdCost;
7
+class DisRoiByDay45 extends Command {
8
+
9
+    protected $signature = 'DisRoiByDay45';
10
+
11
+    /**
12
+     * The console command description.
13
+     *
14
+     * @var string
15
+     */
16
+    protected $description = '地域45日roi';
17
+
18
+
19
+    public function handle()
20
+    {
21
+        $this->DisRoiByDay45();
22
+    }
23
+    public function DisRoiByDay45(){
24
+
25
+            $stime = date('Y-m-d', strtotime('-45 day'));   
26
+            $etime = $date = date('Y-m-d');
27
+            //计算date 45天内的roi    
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();
29
+
30
+            $result = json_decode(json_encode($result), true);           
31
+            foreach($result as $k=>&$v){
32
+                $data = array();
33
+                $data['ad_time'] = $stime;
34
+                $data['city'] = $v['city'];               
35
+                //新粉收入
36
+                //当日加粉
37
+                $city_name = str_replace('市', '', $v['city']);
38
+                $phones = DB::table('customers')->where('fanTime', $stime)->where('receiverCity','like', '%'.$city_name.'%')->lists('phone');
39
+                #当日加粉45日订单总计:
40
+                $order = DB::table('order')->select(DB::raw('sum(receivedAmount) as order_amount, count(1) as order_count'))->whereIn('receiverMobile', $phones)->where('createTime', '>=', $stime)->where('createTime', '<', $etime)->where('is_del', 0)->first();
41
+                #当日新粉成单:            
42
+                $new_order = DB::table('order')->select(DB::raw('sum(receivedAmount) as order_amount, count(1) as order_count'))->where('createTime','>=', $stime)->where('createTime','<=', $stime.' 23:59:59')->where('is_del', 0)->whereIn('receiverMobile', $phones)->first();
43
+               
44
+                // 1.当日新粉成单数
45
+                $data['new_fan_order_count'] = $new_order->order_count;
46
+                // 2.当日新粉成交额 
47
+                $data['new_fan_order_amount'] = $new_order->order_amount;
48
+                // 3.当日粉丝总成交额
49
+                $data['order_amount'] = $order->order_amount;
50
+                // 45日总单数
51
+                $data['order_count'] = $order->order_count;
52
+                //新粉roi
53
+                //$v['new_roi'] = $v['total_cost']>0 ? round($v['new_order_amount'] / $v['total_cost'], 4) * 100 .'%' : '';
54
+                //45日累计roi
55
+                //$v['total_roi'] = $v['total_cost']>0 ? round($v['order_amount'] / $v['total_cost'], 4) * 100 .'%' : '';
56
+                $data['fan_count'] = count($phones);
57
+                $data['gzh_count'] = $v['conversion_times'];
58
+                $data['cost'] = $v['total_cost'];
59
+                //插入数据
60
+                $res = $this->insertData($data);
61
+            }
62
+  
63
+    }
64
+
65
+    /**
66
+     * @param idate:统计日期 rate:成单率 date:昨日
67
+     *
68
+     */
69
+    public function insertData($data){        
70
+        return DB::table('district_roi_45')->insert($data);
71
+    }
72
+
73
+}

+ 75 - 0
app/Console/Commands/DisRoiByDay45History.php

@@ -0,0 +1,75 @@
1
+<?php 
2
+namespace App\Console\Commands;
3
+
4
+use Illuminate\Console\Command;
5
+use DB;
6
+use App\AdCost;
7
+class DisRoiByDayHistory extends Command {
8
+
9
+    protected $signature = 'DisRoiByDayHistory';
10
+
11
+    /**
12
+     * The console command description.
13
+     *
14
+     * @var string
15
+     */
16
+    protected $description = '地域45日roi';
17
+
18
+
19
+    public function handle()
20
+    {
21
+        $this->DisRoiByDayHistory();
22
+    }
23
+    public function DisRoiByDayHistory(){
24
+        for($i=41; $i>=45; $i--){
25
+            $stime = date('Y-m-d', strtotime('-'.$i.' day'));
26
+            $e = $i-45; 
27
+            $etime = $date = date('Y-m-d', strtotime('-'.$e.' day'));
28
+            //计算date 45天内的roi    
29
+            $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
+
31
+            $result = json_decode(json_encode($result), true);           
32
+            foreach($result as $k=>&$v){
33
+                $data = array();
34
+                $data['ad_time'] = $stime;
35
+                $data['city'] = $v['city'];               
36
+                //新粉收入
37
+                //当日加粉
38
+                $city_name = str_replace('市', '', $v['city']);
39
+                $phones = DB::table('customers')->where('fanTime', $stime)->where('receiverCity','like', '%'.$city_name.'%')->lists('phone');
40
+                #当日加粉45日订单总计:
41
+                $order = DB::table('order')->select(DB::raw('sum(receivedAmount) as order_amount, count(1) as order_count'))->whereIn('receiverMobile', $phones)->where('createTime', '>=', $stime)->where('createTime', '<', $etime)->where('is_del', 0)->first();
42
+                #当日新粉成单:            
43
+                $new_order = DB::table('order')->select(DB::raw('sum(receivedAmount) as order_amount, count(1) as order_count'))->where('createTime','>=', $stime)->where('createTime','<=', $stime.' 23:59:59')->where('is_del', 0)->whereIn('receiverMobile', $phones)->first();
44
+               
45
+                // 1.当日新粉成单数
46
+                $data['new_fan_order_count'] = $new_order->order_count;
47
+                // 2.当日新粉成交额 
48
+                $data['new_fan_order_amount'] = $new_order->order_amount;
49
+                // 3.当日粉丝总成交额
50
+                $data['order_amount'] = $order->order_amount;
51
+                // 45日总单数
52
+                $data['order_count'] = $order->order_count;
53
+                //新粉roi
54
+                //$v['new_roi'] = $v['total_cost']>0 ? round($v['new_order_amount'] / $v['total_cost'], 4) * 100 .'%' : '';
55
+                //45日累计roi
56
+                //$v['total_roi'] = $v['total_cost']>0 ? round($v['order_amount'] / $v['total_cost'], 4) * 100 .'%' : '';
57
+                $data['fan_count'] = count($phones);
58
+                $data['gzh_count'] = $v['conversion_times'];
59
+                $data['cost'] = $v['total_cost'];
60
+                //插入数据
61
+                $res = $this->insertData($data);
62
+            }
63
+            
64
+        }
65
+    }
66
+
67
+    /**
68
+     * @param idate:统计日期 rate:成单率 date:昨日
69
+     *
70
+     */
71
+    public function insertData($data){        
72
+        return DB::table('district_roi_45')->insert($data);
73
+    }
74
+
75
+}

+ 17 - 0
app/DistrictRoi15.php

@@ -0,0 +1,17 @@
1
+<?php
2
+/**
3
+ * Created by PhpStorm.
4
+ * User: Administrator
5
+ * Date: 2017/12/5
6
+ * Time: 15:07
7
+ */
8
+
9
+namespace App;
10
+use Illuminate\Database\Eloquent\Model;
11
+
12
+class DistrictRoi15 extends Model
13
+{
14
+    public $timestamps = false;
15
+    protected $table = "district_roi_15";
16
+   
17
+}

+ 17 - 0
app/DistrictRoi45.php

@@ -0,0 +1,17 @@
1
+<?php
2
+/**
3
+ * Created by PhpStorm.
4
+ * User: Administrator
5
+ * Date: 2017/12/5
6
+ * Time: 15:07
7
+ */
8
+
9
+namespace App;
10
+use Illuminate\Database\Eloquent\Model;
11
+
12
+class DistrictRoi45 extends Model
13
+{
14
+    public $timestamps = false;
15
+    protected $table = "district_roi_45";
16
+   
17
+}

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

@@ -15,6 +15,8 @@ use App\AdCost;
15 15
 use App\Order;
16 16
 use App\DistrictRoi7;
17 17
 use App\DistrictRoi30;
18
+use App\DistrictRoi15;
19
+use App\DistrictRoi45;
18 20
 use Illuminate\Http\Request;
19 21
 use Illuminate\Support\Facades\DB;
20 22
 
@@ -2835,6 +2837,354 @@ class StatisticsController extends Controller
2835 2837
     }
2836 2838
 
2837 2839
     /**
2840
+     * 地域roi15日
2841
+     */
2842
+    public function districtRoi15day(Request $request){
2843
+        $page = (int)$request->input('page');
2844
+        $pageSize = 20;
2845
+        if($page<=0){
2846
+            $page = 1;
2847
+        }
2848
+
2849
+        $offset = ($page-1) * $pageSize;
2850
+        $stime = $request->input('stime');
2851
+        $etime = $request->input('etime');
2852
+        $city = $request->input('city');
2853
+
2854
+        if($city !== null){
2855
+            $city = str_replace('市', '', $city);
2856
+        }
2857
+
2858
+        $count = districtRoi15::where(function($query) use($stime, $etime, $city){    
2859
+            if($stime) $query->where('ad_time', '>=', $stime);
2860
+            if($etime) $query->where('ad_time', '<=', $etime);
2861
+            if($city) $query->where('city', 'like', '%'.$city.'%');
2862
+        })->count();
2863
+
2864
+        if ($count > 1) {
2865
+            // 总页数
2866
+            $pages = ceil($count/$pageSize);
2867
+        }else{
2868
+            // 总页数
2869
+            $pages = 1;
2870
+        }
2871
+
2872
+        $result = districtRoi15::where(function($query) use($stime, $etime, $city){    
2873
+            if($stime) $query->where('ad_time', '>=', $stime);
2874
+            if($etime) $query->where('ad_time', '<=', $etime);
2875
+            if($city) $query->where('city', 'like', '%'.$city.'%');
2876
+        })->orderBy('id', 'desc')->offset($offset)->limit($pageSize)->get();
2877
+
2878
+        $result = json_decode(json_encode($result), true);
2879
+        foreach($result as $k=>&$v){
2880
+             //新粉roi
2881
+            $v['new_roi'] = $v['cost']>0 ? round($v['new_fan_order_amount'] / $v['cost'], 4) * 100 .'%' : '';
2882
+            //累计roi
2883
+            $v['total_roi'] = $v['cost']>0 ? round($v['order_amount'] / $v['cost'], 4) * 100 .'%' : '';
2884
+        }
2885
+
2886
+        return view('statistics/districtRoi15day', ['result' =>$result,
2887
+            'page'              =>$page,
2888
+            'count'             =>$count,
2889
+            'pages'             =>$pages,                                    
2890
+            'city'             =>$city,                    
2891
+            'stime'             =>$stime,                    
2892
+            'etime'             =>$etime,                    
2893
+            ]);
2894
+
2895
+    }
2896
+
2897
+    /**
2898
+     * 地域roi15日
2899
+     */
2900
+    public function districtRoi15day_export(Request $request){
2901
+
2902
+        $stime = $request->input('stime');
2903
+        $etime = $request->input('etime');
2904
+        $city = $request->input('city');
2905
+
2906
+        if($city !== null){
2907
+            $city = str_replace('市', '', $city);
2908
+        }
2909
+
2910
+        $result = districtRoi15::where(function($query) use($stime, $etime, $city){    
2911
+            if($stime) $query->where('ad_time', '>=', $stime);
2912
+            if($etime) $query->where('ad_time', '<=', $etime);
2913
+            if($city) $query->where('city', 'like', '%'.$city.'%');
2914
+        })->orderBy('id', 'desc')->get();
2915
+
2916
+        $result = json_decode(json_encode($result), true);
2917
+        foreach($result as $k=>&$v){
2918
+             //新粉roi
2919
+            $v['new_roi'] = $v['cost']>0 ? round($v['new_fan_order_amount'] / $v['cost'], 4) * 100 .'%' : '';
2920
+            //累计roi
2921
+            $v['total_roi'] = $v['cost']>0 ? round($v['order_amount'] / $v['cost'], 4) * 100 .'%' : '';
2922
+        }
2923
+
2924
+        $indexKey = ['ad_time','city','cost','gzh_count','fan_count','new_fan_order_count','new_fan_order_amount','new_roi','order_count','order_amount','total_roi'];
2925
+        $title = ['日期', '城市', '投放成本', '加粉数', '下单人数', '新粉成单数', '新粉收入', '新粉ROI', '累计成单数', '累计收入', '累计ROI'];
2926
+        $filename = 'districtRoi15day_'.date('Y-m-d_H').'.xlsx';
2927
+        return Order::export_excel($result, $filename, $indexKey, $title);
2928
+    }
2929
+
2930
+    /**
2931
+     * 地域roi15日汇总
2932
+     */
2933
+    public function districtRoi15dayTotal(Request $request){
2934
+        $page = (int)$request->input('page');
2935
+        $pageSize = 20;
2936
+        if($page<=0){
2937
+            $page = 1;
2938
+        }
2939
+
2940
+        $offset = ($page-1) * $pageSize;
2941
+        $city = $request->input('city');
2942
+
2943
+        if($city !== null){
2944
+            $city = str_replace('市', '', $city);
2945
+        }
2946
+
2947
+        $count = districtRoi15::where(function($query) use($city){    
2948
+            if($city) $query->where('city', 'like', '%'.$city.'%');
2949
+        })->groupBy('city')->get();
2950
+
2951
+        $count = count($count);
2952
+        if ($count > 1) {
2953
+            // 总页数
2954
+            $pages = ceil($count/$pageSize);
2955
+        }else{
2956
+            // 总页数
2957
+            $pages = 1;
2958
+        }
2959
+
2960
+        $result = districtRoi15::select(DB::raw('city,sum(cost) as cost,sum(gzh_count) as gzh_count,sum(fan_count) as fan_count,sum(new_fan_order_count) as new_fan_order_count,sum(new_fan_order_amount) as new_fan_order_amount,sum(order_count) as order_count,sum(order_amount) as sum_order_amount, sum(order_amount)/sum(cost) as roi'))->where(function($query) use($city){    
2961
+            if($city) $query->where('city', 'like', '%'.$city.'%');
2962
+        })->groupBy('city')->orderBy('roi', 'desc')->offset($offset)->limit($pageSize)->get();
2963
+
2964
+        $result = json_decode(json_encode($result), true);
2965
+        foreach($result as $k=>&$v){
2966
+             //新粉roi
2967
+            $v['new_roi'] = $v['cost']>0 ? round($v['new_fan_order_amount'] / $v['cost'], 4) * 100 .'%' : '';
2968
+            //累计roi
2969
+            $v['total_roi'] = $v['cost']>0 ? round($v['sum_order_amount'] / $v['cost'], 4) * 100 .'%' : '';
2970
+            //数据格式化
2971
+            $v['order_amount'] = round($v['sum_order_amount'],2);
2972
+        }
2973
+
2974
+        return view('statistics/districtRoi15dayTotal', ['result' =>$result,
2975
+            'page'              =>$page,
2976
+            'count'             =>$count,
2977
+            'pages'             =>$pages,                                    
2978
+            'city'             =>$city,                                        
2979
+            ]);
2980
+
2981
+    }
2982
+
2983
+    /**
2984
+     * 地域roi15日
2985
+     */
2986
+    public function districtRoi15dayTotal_export(Request $request){
2987
+
2988
+        $city = $request->input('city');
2989
+        if($city !== null){
2990
+            $city = str_replace('市', '', $city);
2991
+        }
2992
+
2993
+        $result = districtRoi15::select(DB::raw('city,sum(cost) as cost,sum(gzh_count) as gzh_count,sum(fan_count) as fan_count,sum(new_fan_order_count) as new_fan_order_count,sum(new_fan_order_amount) as new_fan_order_amount,sum(order_count) as order_count,sum(order_amount) as sum_order_amount,sum(order_amount)/sum(cost) as roi'))->where(function($query) use($city){    
2994
+            if($city) $query->where('city', 'like', '%'.$city.'%');
2995
+        })->groupBy('city')->orderBy('roi', 'desc')->get();
2996
+
2997
+        $result = json_decode(json_encode($result), true);
2998
+        foreach($result as $k=>&$v){
2999
+             //新粉roi
3000
+            $v['new_roi'] = $v['cost']>0 ? round($v['new_fan_order_amount'] / $v['cost'], 4) * 100 .'%' : '';
3001
+            //累计roi
3002
+            $v['total_roi'] = $v['cost']>0 ? round($v['sum_order_amount'] / $v['cost'], 4) * 100 .'%' : '';
3003
+            //数据格式化
3004
+            $v['order_amount'] = round($v['sum_order_amount'],2);
3005
+        }
3006
+
3007
+        $indexKey = ['city','cost','gzh_count','fan_count','new_fan_order_count','new_fan_order_amount','new_roi','order_count','order_amount','total_roi'];
3008
+        $title = ['城市', '投放成本', '加粉数', '下单人数', '新粉成单数', '新粉收入', '新粉ROI', '累计成单数', '累计收入', '累计ROI'];
3009
+        $filename = 'districtRoi15day_'.date('Y-m-d_H').'.xlsx';
3010
+        return Order::export_excel($result, $filename, $indexKey, $title);
3011
+    }
3012
+
3013
+    /**
3014
+     * 地域roi45日
3015
+     */
3016
+    public function districtRoi45day(Request $request){
3017
+        $page = (int)$request->input('page');
3018
+        $pageSize = 20;
3019
+        if($page<=0){
3020
+            $page = 1;
3021
+        }
3022
+
3023
+        $offset = ($page-1) * $pageSize;
3024
+        $stime = $request->input('stime');
3025
+        $etime = $request->input('etime');
3026
+        $city = $request->input('city');
3027
+
3028
+        if($city !== null){
3029
+            $city = str_replace('市', '', $city);
3030
+        }
3031
+
3032
+        $count = districtRoi45::where(function($query) use($stime, $etime, $city){    
3033
+            if($stime) $query->where('ad_time', '>=', $stime);
3034
+            if($etime) $query->where('ad_time', '<=', $etime);
3035
+            if($city) $query->where('city', 'like', '%'.$city.'%');
3036
+        })->count();
3037
+
3038
+        if ($count > 1) {
3039
+            // 总页数
3040
+            $pages = ceil($count/$pageSize);
3041
+        }else{
3042
+            // 总页数
3043
+            $pages = 1;
3044
+        }
3045
+
3046
+        $result = districtRoi45::where(function($query) use($stime, $etime, $city){    
3047
+            if($stime) $query->where('ad_time', '>=', $stime);
3048
+            if($etime) $query->where('ad_time', '<=', $etime);
3049
+            if($city) $query->where('city', 'like', '%'.$city.'%');
3050
+        })->orderBy('id', 'desc')->offset($offset)->limit($pageSize)->get();
3051
+
3052
+        $result = json_decode(json_encode($result), true);
3053
+        foreach($result as $k=>&$v){
3054
+             //新粉roi
3055
+            $v['new_roi'] = $v['cost']>0 ? round($v['new_fan_order_amount'] / $v['cost'], 4) * 100 .'%' : '';
3056
+            //累计roi
3057
+            $v['total_roi'] = $v['cost']>0 ? round($v['order_amount'] / $v['cost'], 4) * 100 .'%' : '';
3058
+        }
3059
+
3060
+        return view('statistics/districtRoi45day', ['result' =>$result,
3061
+            'page'              =>$page,
3062
+            'count'             =>$count,
3063
+            'pages'             =>$pages,                                    
3064
+            'city'             =>$city,                    
3065
+            'stime'             =>$stime,                    
3066
+            'etime'             =>$etime,                    
3067
+            ]);
3068
+
3069
+    }
3070
+
3071
+    /**
3072
+     * 地域roi45日
3073
+     */
3074
+    public function districtRoi45day_export(Request $request){
3075
+
3076
+        $stime = $request->input('stime');
3077
+        $etime = $request->input('etime');
3078
+        $city = $request->input('city');
3079
+
3080
+        if($city !== null){
3081
+            $city = str_replace('市', '', $city);
3082
+        }
3083
+
3084
+        $result = districtRoi45::where(function($query) use($stime, $etime, $city){    
3085
+            if($stime) $query->where('ad_time', '>=', $stime);
3086
+            if($etime) $query->where('ad_time', '<=', $etime);
3087
+            if($city) $query->where('city', 'like', '%'.$city.'%');
3088
+        })->orderBy('id', 'desc')->get();
3089
+
3090
+        $result = json_decode(json_encode($result), true);
3091
+        foreach($result as $k=>&$v){
3092
+             //新粉roi
3093
+            $v['new_roi'] = $v['cost']>0 ? round($v['new_fan_order_amount'] / $v['cost'], 4) * 100 .'%' : '';
3094
+            //累计roi
3095
+            $v['total_roi'] = $v['cost']>0 ? round($v['order_amount'] / $v['cost'], 4) * 100 .'%' : '';
3096
+        }
3097
+
3098
+        $indexKey = ['ad_time','city','cost','gzh_count','fan_count','new_fan_order_count','new_fan_order_amount','new_roi','order_count','order_amount','total_roi'];
3099
+        $title = ['日期', '城市', '投放成本', '加粉数', '下单人数', '新粉成单数', '新粉收入', '新粉ROI', '累计成单数', '累计收入', '累计ROI'];
3100
+        $filename = 'districtRoi45day_'.date('Y-m-d_H').'.xlsx';
3101
+        return Order::export_excel($result, $filename, $indexKey, $title);
3102
+    }
3103
+
3104
+    /**
3105
+     * 地域roi45日汇总
3106
+     */
3107
+    public function districtRoi45dayTotal(Request $request){
3108
+        $page = (int)$request->input('page');
3109
+        $pageSize = 20;
3110
+        if($page<=0){
3111
+            $page = 1;
3112
+        }
3113
+
3114
+        $offset = ($page-1) * $pageSize;
3115
+        $city = $request->input('city');
3116
+
3117
+        if($city !== null){
3118
+            $city = str_replace('市', '', $city);
3119
+        }
3120
+
3121
+        $count = districtRoi45::where(function($query) use($city){    
3122
+            if($city) $query->where('city', 'like', '%'.$city.'%');
3123
+        })->groupBy('city')->get();
3124
+
3125
+        $count = count($count);
3126
+        if ($count > 1) {
3127
+            // 总页数
3128
+            $pages = ceil($count/$pageSize);
3129
+        }else{
3130
+            // 总页数
3131
+            $pages = 1;
3132
+        }
3133
+
3134
+        $result = districtRoi45::select(DB::raw('city,sum(cost) as cost,sum(gzh_count) as gzh_count,sum(fan_count) as fan_count,sum(new_fan_order_count) as new_fan_order_count,sum(new_fan_order_amount) as new_fan_order_amount,sum(order_count) as order_count,sum(order_amount) as sum_order_amount, sum(order_amount)/sum(cost) as roi'))->where(function($query) use($city){    
3135
+            if($city) $query->where('city', 'like', '%'.$city.'%');
3136
+        })->groupBy('city')->orderBy('roi', 'desc')->offset($offset)->limit($pageSize)->get();
3137
+
3138
+        $result = json_decode(json_encode($result), true);
3139
+        foreach($result as $k=>&$v){
3140
+             //新粉roi
3141
+            $v['new_roi'] = $v['cost']>0 ? round($v['new_fan_order_amount'] / $v['cost'], 4) * 100 .'%' : '';
3142
+            //累计roi
3143
+            $v['total_roi'] = $v['cost']>0 ? round($v['sum_order_amount'] / $v['cost'], 4) * 100 .'%' : '';
3144
+            //数据格式化
3145
+            $v['order_amount'] = round($v['sum_order_amount'],2);
3146
+        }
3147
+
3148
+        return view('statistics/districtRoi45dayTotal', ['result' =>$result,
3149
+            'page'              =>$page,
3150
+            'count'             =>$count,
3151
+            'pages'             =>$pages,                                    
3152
+            'city'             =>$city,                                        
3153
+            ]);
3154
+
3155
+    }
3156
+
3157
+    /**
3158
+     * 地域roi45日
3159
+     */
3160
+    public function districtRoi45dayTotal_export(Request $request){
3161
+
3162
+        $city = $request->input('city');
3163
+        if($city !== null){
3164
+            $city = str_replace('市', '', $city);
3165
+        }
3166
+
3167
+        $result = districtRoi45::select(DB::raw('city,sum(cost) as cost,sum(gzh_count) as gzh_count,sum(fan_count) as fan_count,sum(new_fan_order_count) as new_fan_order_count,sum(new_fan_order_amount) as new_fan_order_amount,sum(order_count) as order_count,sum(order_amount) as sum_order_amount,sum(order_amount)/sum(cost) as roi'))->where(function($query) use($city){    
3168
+            if($city) $query->where('city', 'like', '%'.$city.'%');
3169
+        })->groupBy('city')->orderBy('roi', 'desc')->get();
3170
+
3171
+        $result = json_decode(json_encode($result), true);
3172
+        foreach($result as $k=>&$v){
3173
+             //新粉roi
3174
+            $v['new_roi'] = $v['cost']>0 ? round($v['new_fan_order_amount'] / $v['cost'], 4) * 100 .'%' : '';
3175
+            //累计roi
3176
+            $v['total_roi'] = $v['cost']>0 ? round($v['sum_order_amount'] / $v['cost'], 4) * 100 .'%' : '';
3177
+            //数据格式化
3178
+            $v['order_amount'] = round($v['sum_order_amount'],2);
3179
+        }
3180
+
3181
+        $indexKey = ['city','cost','gzh_count','fan_count','new_fan_order_count','new_fan_order_amount','new_roi','order_count','order_amount','total_roi'];
3182
+        $title = ['城市', '投放成本', '加粉数', '下单人数', '新粉成单数', '新粉收入', '新粉ROI', '累计成单数', '累计收入', '累计ROI'];
3183
+        $filename = 'districtRoi45day_'.date('Y-m-d_H').'.xlsx';
3184
+        return Order::export_excel($result, $filename, $indexKey, $title);
3185
+    }
3186
+
3187
+    /**
2838 3188
      * 销售月度业绩报表
2839 3189
      */
2840 3190
     public function salerBonus(Request $request){

+ 10 - 0
app/Http/routes.php

@@ -137,6 +137,16 @@ Route::group(['prefix' => 'admin'], function(){
137 137
         Route::get('/statistics/districtRoi30day_export', 'Admin\StatisticsController@districtRoi30day_export');
138 138
         Route::get('/statistics/districtRoi30dayTotal', 'Admin\StatisticsController@districtRoi30dayTotal');
139 139
         Route::get('/statistics/districtRoi30dayTotal_export', 'Admin\StatisticsController@districtRoi30dayTotal_export');
140
+        //地域roi15日
141
+        Route::get('/statistics/districtRoi15day', 'Admin\StatisticsController@districtRoi15day');
142
+        Route::get('/statistics/districtRoi15day_export', 'Admin\StatisticsController@districtRoi15day_export');
143
+        Route::get('/statistics/districtRoi15dayTotal', 'Admin\StatisticsController@districtRoi15dayTotal');
144
+        Route::get('/statistics/districtRoi15dayTotal_export', 'Admin\StatisticsController@districtRoi15dayTotal_export');
145
+        //地域roi45日
146
+        Route::get('/statistics/districtRoi45day', 'Admin\StatisticsController@districtRoi45day');
147
+        Route::get('/statistics/districtRoi45day_export', 'Admin\StatisticsController@districtRoi45day_export');
148
+        Route::get('/statistics/districtRoi45dayTotal', 'Admin\StatisticsController@districtRoi45dayTotal');
149
+        Route::get('/statistics/districtRoi45dayTotal_export', 'Admin\StatisticsController@districtRoi45dayTotal_export');
140 150
         //团队财务报表
141 151
         Route::get('/statistics/teamFinanceList', 'Admin\StatisticsController@teamFinanceList');
142 152
         Route::get('/statistics/teamFinanceList_export', 'Admin\StatisticsController@teamFinanceList_export');

+ 17 - 1
resources/views/statistics/districtRoi.blade.php

@@ -9,8 +9,12 @@
9 9
                     <option value="0" >7日roi明细</option>                   
10 10
                     <option value="1">7日roi汇总</option>                                     
11 11
                     <option value="2" selected>每日roi明细</option> 
12
+                    <option value="5">15日roi明细</option>                                     
13
+                    <option value="6">15日roi汇总</option>                                   
12 14
                     <option value="3">30日roi明细</option>                                     
13
-                    <option value="4">30日roi汇总</option>                                    
15
+                    <option value="4">30日roi汇总</option> 
16
+                    <option value="7">45日roi明细</option>                                     
17
+                    <option value="8">45日roi汇总</option>                                    
14 18
                   
15 19
                 </select>
16 20
                 <input class="input-text" style="width:5%;text-align:center" type="text" value="所属城市"/>
@@ -154,6 +158,18 @@
154 158
             else if(date_type == 4){
155 159
                 location.href='districtRoi30dayTotal';
156 160
             }
161
+            else if(date_type == 5){
162
+                location.href='districtRoi15day';
163
+            }
164
+            else if(date_type == 6){
165
+                location.href='districtRoi15dayTotal';
166
+            }
167
+            else if(date_type == 7){
168
+                location.href='districtRoi45day';
169
+            }
170
+            else if(date_type == 8){
171
+                location.href='districtRoi45dayTotal';
172
+            }
157 173
         })
158 174
        
159 175
         /*分页*/

+ 150 - 0
resources/views/statistics/districtRoi15day.blade.php

@@ -0,0 +1,150 @@
1
+@extends('admin/master')
2
+@section('content')
3
+    <body>
4
+    <div class="page-container">
5
+        <div>
6
+            <div>   
7
+                <input class="input-text" style="width:6%;text-align:center" type="text" value="数据分类"/> 
8
+                <select style="width:10%;text-align:center" id='data_type' name="data_type">
9
+                    <option value="0">7日roi明细</option>                   
10
+                    <option value="1">7日roi汇总</option>                                     
11
+                    <option value="2">每日roi明细</option> 
12
+                    <option value="5" selected >15日roi明细</option>                                     
13
+                    <option value="6">15日roi汇总</option>                                   
14
+                    <option value="3">30日roi明细</option>                                     
15
+                    <option value="4">30日roi汇总</option> 
16
+                    <option value="7">45日roi明细</option>                                     
17
+                    <option value="8">45日roi汇总</option>                                    
18
+                  
19
+                </select> 
20
+                <input class="input-text" style="width:5%;text-align:center" type="text" value="所属城市"/>
21
+                <input id="city" type="text"  class="input-text" style="width:6%;text-align:center" name="city" value="{{$city?$city:''}}">                         
22
+                <input class="input-text" style="width:6%;text-align:center" type="text" value="开始时间"/>
23
+                <input id="stime" type="text" onfocus="WdatePicker({ dateFmt:'yyyy-MM-dd' })" class="input-text Wdate" style="width:12%;text-align:center;margin-left: -5px" name="stime" value="{{$stime?$stime:''}}">
24
+                <input class="input-text" style="width:6%;text-align:center" type="text" value="结束时间"/>
25
+                <input id="etime"type="text" onfocus="WdatePicker({ dateFmt:'yyyy-MM-dd' })" class="input-text Wdate" style="width:12%;text-align:center;margin-left: -5px" name="etime" value="{{$etime?$etime:''}}">
26
+               
27
+                
28
+                <a class="btn btn-primary radius"  style="margin-left: 5px" onclick="user_search()" href="javascript:;">搜索</a>
29
+                <a class="btn btn-primary radius" onclick="statistics_export()" href="javascript:;"><i class="Hui-iconfont"></i> 导出数据</a>
30
+                
31
+            </div>
32
+        </div>
33
+        
34
+        <div class="mt-20">
35
+            <table class="table table-border table-bordered table-bg table-hover table-sort">
36
+                <thead>
37
+                <tr class="text-c">
38
+                    <th width="5%">日期</th>
39
+                    <th width="5%">城市</th>
40
+                    <th width="5%">投放成本</th>
41
+                    <th width="5%">加粉数</th>
42
+                    <th width="5%">下单人数</th>
43
+                    <th width="5%">新粉成单数</th>
44
+                    <th width="5%">新粉收入</th>
45
+                    <th width="5%">新粉ROI</th>
46
+                    <th width="5%">15日累计成单数</th>
47
+                    <th width="5%">15日累计收入</th>
48
+                    <th width="5%">15日累计ROI</th>                                                
49
+                </tr>
50
+                </thead>
51
+                <tbody>
52
+                @if($result)
53
+                    @foreach($result as $a)
54
+                        <tr class="text-c" style=" text-align:center;">                           
55
+                            <td>{{$a['ad_time']}}</td>                                                                                         
56
+                            <td>{{$a['city']}}</td>                                                                                         
57
+                            <td>{{$a['cost']}}</td>                                                                                           
58
+                            <td>{{$a['gzh_count']}}</td>                                                                                           
59
+                            <td>{{$a['fan_count']}}</td>                                                                                           
60
+                            <td>{{$a['new_fan_order_count']}}</td>                                                                                         
61
+                            <td>{{$a['new_fan_order_amount']}}</td>                                                                                         
62
+                            <td>{{$a['new_roi']}}</td>                                                                                         
63
+                            <td>{{$a['order_count']}}</td>                                                                                         
64
+                            <td>{{$a['order_amount']}}</td>                                                                                         
65
+                            <td>{{$a['total_roi']}}</td>                                                                                         
66
+                        </tr>
67
+                    @endforeach
68
+                @endif
69
+                </tbody>
70
+            </table>
71
+        </div>
72
+        <div id="page" class="page_div"></div>
73
+    </div>
74
+    
75
+    <!--_footer 作为公共模版分离出去-->
76
+    <script type="text/javascript" src="/admin/lib/jquery/1.9.1/jquery.min.js"></script>
77
+    <script type="text/javascript" src="/admin/lib/layer/2.4/layer.js"></script>
78
+    <script type="text/javascript" src="/admin/static/h-ui/js/H-ui.min.js"></script>
79
+    <script type="text/javascript" src="/admin/static/h-ui.admin/js/H-ui.admin.js"></script>
80
+    <script type="text/javascript" src="/admin/lib/page/paging.js"></script>
81
+    <script type="text/javascript" src="/admin/lib/My97DatePicker/4.8/WdatePicker.js"></script>
82
+    <!--/_footer 作为公共模版分离出去-->
83
+    <!--/_footer 作为公共模版分离出去-->
84
+     <script type="text/javascript">
85
+        
86
+        function user_search(){
87
+            var stime = $('#stime').val();
88
+            var etime = $('#etime').val();
89
+            var city = $('#city').val();
90
+            //var page = {{$page}};
91
+            location.href = 'districtRoi15day?stime='+stime+'&etime='+etime+'&city='+city;
92
+        }
93
+        //导出
94
+        function statistics_export(){
95
+            var stime = $('#stime').val();
96
+            var etime = $('#etime').val();
97
+            var city = $('#city').val();
98
+            location.href = '/admin/statistics/districtRoi15day_export?stime='+stime+'&etime='+etime+'&city='+city;
99
+        }
100
+
101
+        $("#data_type").change(function(){
102
+            var date_type = $(this).val();
103
+            if(date_type == 0){
104
+                location.href='districtRoi7day';
105
+            }
106
+            else if(date_type == 1){
107
+                location.href='districtRoi7dayTotal';
108
+            }
109
+            else if(date_type == 2){
110
+                location.href='districtRoi';
111
+            }
112
+            else if(date_type == 3){
113
+                location.href='districtRoi30day';
114
+            }
115
+            else if(date_type == 4){
116
+                location.href='districtRoi30dayTotal';
117
+            }
118
+            else if(date_type == 5){
119
+                location.href='districtRoi15day';
120
+            }
121
+            else if(date_type == 6){
122
+                location.href='districtRoi15dayTotal';
123
+            }
124
+            else if(date_type == 7){
125
+                location.href='districtRoi45day';
126
+            }
127
+            else if(date_type == 8){
128
+                location.href='districtRoi45dayTotal';
129
+            }
130
+        })
131
+       
132
+        /*分页*/
133
+            
134
+        $("#page").paging({
135
+            pageNo:{{$page}},
136
+            totalPage: {{$pages}},
137
+            totalSize: {{$count}},
138
+            callback: function(num) {
139
+                var stime = $('#stime').val();
140
+                var etime = $('#etime').val();
141
+                var city = $('#city').val();
142
+                location.href='districtRoi15day?page='+num+'&stime='+stime+'&etime='+etime+'&city='+city;
143
+            }
144
+        })
145
+        
146
+    </script>
147
+   
148
+    </body>
149
+
150
+@endsection

+ 137 - 0
resources/views/statistics/districtRoi15dayTotal.blade.php

@@ -0,0 +1,137 @@
1
+@extends('admin/master')
2
+@section('content')
3
+    <body>
4
+    <div class="page-container">
5
+        <div>
6
+            <div>  
7
+                <input class="input-text" style="width:6%;text-align:center" type="text" value="数据分类"/> 
8
+                <select style="width:10%;text-align:center" id='data_type' name="data_type">
9
+                    <option value="0"  >7日roi明细</option>                   
10
+                    <option value="1" >7日roi汇总</option>                                     
11
+                    <option value="2" >每日roi明细</option>
12
+                    <option value="5">15日roi明细</option>                                     
13
+                    <option value="6" selected>15日roi汇总</option>                                   
14
+                    <option value="3">30日roi明细</option>                                     
15
+                    <option value="4">30日roi汇总</option> 
16
+                    <option value="7">45日roi明细</option>                                     
17
+                    <option value="8">45日roi汇总</option>                                     
18
+                  
19
+                </select>  
20
+                <input class="input-text" style="width:5%;text-align:center" type="text" value="所属城市"/>
21
+                <input id="city" type="text"  class="input-text" style="width:6%;text-align:center" name="city" value="{{$city?$city:''}}">                         
22
+                
23
+                <a class="btn btn-primary radius"  style="margin-left: 5px" onclick="user_search()" href="javascript:;">搜索</a>
24
+                <a class="btn btn-primary radius" onclick="statistics_export()" href="javascript:;"><i class="Hui-iconfont"></i> 导出数据</a>
25
+                
26
+            </div>
27
+        </div>
28
+        
29
+        <div class="mt-20">
30
+            <table class="table table-border table-bordered table-bg table-hover table-sort">
31
+                <thead>
32
+                <tr class="text-c">
33
+                    <th width="5%">城市</th>
34
+                    <th width="5%">投放成本</th>
35
+                    <th width="5%">加粉数</th>
36
+                    <th width="5%">下单人数</th>
37
+                    <th width="5%">新粉成单数</th>
38
+                    <th width="5%">新粉收入</th>
39
+                    <th width="5%">新粉ROI</th>
40
+                    <th width="5%">15日累计成单数</th>
41
+                    <th width="5%">15日累计收入</th>
42
+                    <th width="5%">15日累计ROI</th>                                                
43
+                </tr>
44
+                </thead>
45
+                <tbody>
46
+                @if($result)
47
+                    @foreach($result as $a)
48
+                        <tr class="text-c" style=" text-align:center;">                                                                                                                   
49
+                            <td>{{$a['city']}}</td>                                                                                         
50
+                            <td>{{$a['cost']}}</td>                                                                                           
51
+                            <td>{{$a['gzh_count']}}</td>                                                                                           
52
+                            <td>{{$a['fan_count']}}</td>                                                                                           
53
+                            <td>{{$a['new_fan_order_count']}}</td>                                                                                         
54
+                            <td>{{$a['new_fan_order_amount']}}</td>                                                                                         
55
+                            <td>{{$a['new_roi']}}</td>                                                                                         
56
+                            <td>{{$a['order_count']}}</td>                                                                                         
57
+                            <td>{{$a['order_amount']}}</td>                                                                                         
58
+                            <td>{{$a['total_roi']}}</td>                                                                                         
59
+                        </tr>
60
+                    @endforeach
61
+                @endif
62
+                </tbody>
63
+            </table>
64
+        </div>
65
+        <div id="page" class="page_div"></div>
66
+    </div>
67
+    
68
+    <!--_footer 作为公共模版分离出去-->
69
+    <script type="text/javascript" src="/admin/lib/jquery/1.9.1/jquery.min.js"></script>
70
+    <script type="text/javascript" src="/admin/lib/layer/2.4/layer.js"></script>
71
+    <script type="text/javascript" src="/admin/static/h-ui/js/H-ui.min.js"></script>
72
+    <script type="text/javascript" src="/admin/static/h-ui.admin/js/H-ui.admin.js"></script>
73
+    <script type="text/javascript" src="/admin/lib/page/paging.js"></script>
74
+    <script type="text/javascript" src="/admin/lib/My97DatePicker/4.8/WdatePicker.js"></script>
75
+    <!--/_footer 作为公共模版分离出去-->
76
+    <!--/_footer 作为公共模版分离出去-->
77
+     <script type="text/javascript">
78
+        
79
+        function user_search(){
80
+
81
+            var city = $('#city').val();
82
+            //var page = {{$page}};
83
+            location.href = 'districtRoi15dayTotal?city='+city;
84
+        }
85
+        //导出
86
+        function statistics_export(){
87
+            var city = $('#city').val();
88
+            location.href = '/admin/statistics/districtRoi15dayTotal_export?city='+city;
89
+        }
90
+       
91
+         $("#data_type").change(function(){
92
+            var date_type = $(this).val();
93
+            if(date_type == 0){
94
+                location.href='districtRoi7day';
95
+            }
96
+            else if(date_type == 1){
97
+                location.href='districtRoi7dayTotal';
98
+            }
99
+            else if(date_type == 2){
100
+                location.href='districtRoi';
101
+            }
102
+            else if(date_type == 3){
103
+                location.href='districtRoi30day';
104
+            }
105
+            else if(date_type == 4){
106
+                location.href='districtRoi30dayTotal';
107
+            }
108
+            else if(date_type == 5){
109
+                location.href='districtRoi15day';
110
+            }
111
+            else if(date_type == 6){
112
+                location.href='districtRoi15dayTotal';
113
+            }
114
+            else if(date_type == 7){
115
+                location.href='districtRoi45day';
116
+            }
117
+            else if(date_type == 8){
118
+                location.href='districtRoi45dayTotal';
119
+            }
120
+        })
121
+        /*分页*/
122
+            
123
+        $("#page").paging({
124
+            pageNo:{{$page}},
125
+            totalPage: {{$pages}},
126
+            totalSize: {{$count}},
127
+            callback: function(num) {
128
+                var city = $('#city').val();
129
+                location.href='districtRoi15dayTotal?page='+num+'&city='+city;
130
+            }
131
+        })
132
+        
133
+    </script>
134
+   
135
+    </body>
136
+
137
+@endsection

+ 17 - 1
resources/views/statistics/districtRoi30day.blade.php

@@ -9,8 +9,12 @@
9 9
                     <option value="0">7日roi明细</option>                   
10 10
                     <option value="1">7日roi汇总</option>                                     
11 11
                     <option value="2">每日roi明细</option>
12
+                    <option value="5">15日roi明细</option>                                     
13
+                    <option value="6" >15日roi汇总</option>                                   
12 14
                     <option value="3" selected>30日roi明细</option>                                     
13
-                    <option value="4">30日roi汇总</option>                                     
15
+                    <option value="4">30日roi汇总</option> 
16
+                    <option value="7">45日roi明细</option>                                     
17
+                    <option value="8">45日roi汇总</option>                                     
14 18
                   
15 19
                 </select> 
16 20
                 <input class="input-text" style="width:5%;text-align:center" type="text" value="所属城市"/>
@@ -111,6 +115,18 @@
111 115
             else if(date_type == 4){
112 116
                 location.href='districtRoi30dayTotal';
113 117
             }
118
+            else if(date_type == 5){
119
+                location.href='districtRoi15day';
120
+            }
121
+            else if(date_type == 6){
122
+                location.href='districtRoi15dayTotal';
123
+            }
124
+            else if(date_type == 7){
125
+                location.href='districtRoi45day';
126
+            }
127
+            else if(date_type == 8){
128
+                location.href='districtRoi45dayTotal';
129
+            }
114 130
         })
115 131
        
116 132
         /*分页*/

+ 18 - 2
resources/views/statistics/districtRoi30dayTotal.blade.php

@@ -9,8 +9,12 @@
9 9
                     <option value="0" >7日roi明细</option>                   
10 10
                     <option value="1" >7日roi汇总</option>                                     
11 11
                     <option value="2" >每日roi明细</option> 
12
-                    <option value="3">30日roi明细</option>                                     
13
-                    <option value="4" selected>30日roi汇总</option>                                    
12
+                    <option value="5">15日roi明细</option>                                     
13
+                    <option value="6" >15日roi汇总</option>                                   
14
+                    <option value="3" >30日roi明细</option>                                     
15
+                    <option value="4" selected>30日roi汇总</option> 
16
+                    <option value="7">45日roi明细</option>                                     
17
+                    <option value="8">45日roi汇总</option>                                     
14 18
                   
15 19
                 </select>  
16 20
                 <input class="input-text" style="width:5%;text-align:center" type="text" value="所属城市"/>
@@ -101,6 +105,18 @@
101 105
             else if(date_type == 4){
102 106
                 location.href='districtRoi30dayTotal';
103 107
             }
108
+            else if(date_type == 5){
109
+                location.href='districtRoi15day';
110
+            }
111
+            else if(date_type == 6){
112
+                location.href='districtRoi15dayTotal';
113
+            }
114
+            else if(date_type == 7){
115
+                location.href='districtRoi45day';
116
+            }
117
+            else if(date_type == 8){
118
+                location.href='districtRoi45dayTotal';
119
+            }
104 120
         })
105 121
         /*分页*/
106 122
             

+ 150 - 0
resources/views/statistics/districtRoi45day.blade.php

@@ -0,0 +1,150 @@
1
+@extends('admin/master')
2
+@section('content')
3
+    <body>
4
+    <div class="page-container">
5
+        <div>
6
+            <div>   
7
+                <input class="input-text" style="width:6%;text-align:center" type="text" value="数据分类"/> 
8
+                <select style="width:10%;text-align:center" id='data_type' name="data_type">
9
+                    <option value="0">7日roi明细</option>                   
10
+                    <option value="1">7日roi汇总</option>                                     
11
+                    <option value="2">每日roi明细</option>
12
+                    <option value="5">15日roi明细</option>                                     
13
+                    <option value="6" >15日roi汇总</option>                                   
14
+                    <option value="3">30日roi明细</option>                                     
15
+                    <option value="4">30日roi汇总</option> 
16
+                    <option value="7"  selected>45日roi明细</option>                                     
17
+                    <option value="8">45日roi汇总</option>                                      
18
+                  
19
+                </select> 
20
+                <input class="input-text" style="width:5%;text-align:center" type="text" value="所属城市"/>
21
+                <input id="city" type="text"  class="input-text" style="width:6%;text-align:center" name="city" value="{{$city?$city:''}}">                         
22
+                <input class="input-text" style="width:6%;text-align:center" type="text" value="开始时间"/>
23
+                <input id="stime" type="text" onfocus="WdatePicker({ dateFmt:'yyyy-MM-dd' })" class="input-text Wdate" style="width:12%;text-align:center;margin-left: -5px" name="stime" value="{{$stime?$stime:''}}">
24
+                <input class="input-text" style="width:6%;text-align:center" type="text" value="结束时间"/>
25
+                <input id="etime"type="text" onfocus="WdatePicker({ dateFmt:'yyyy-MM-dd' })" class="input-text Wdate" style="width:12%;text-align:center;margin-left: -5px" name="etime" value="{{$etime?$etime:''}}">
26
+               
27
+                
28
+                <a class="btn btn-primary radius"  style="margin-left: 5px" onclick="user_search()" href="javascript:;">搜索</a>
29
+                <a class="btn btn-primary radius" onclick="statistics_export()" href="javascript:;"><i class="Hui-iconfont"></i> 导出数据</a>
30
+                
31
+            </div>
32
+        </div>
33
+        
34
+        <div class="mt-20">
35
+            <table class="table table-border table-bordered table-bg table-hover table-sort">
36
+                <thead>
37
+                <tr class="text-c">
38
+                    <th width="5%">日期</th>
39
+                    <th width="5%">城市</th>
40
+                    <th width="5%">投放成本</th>
41
+                    <th width="5%">加粉数</th>
42
+                    <th width="5%">下单人数</th>
43
+                    <th width="5%">新粉成单数</th>
44
+                    <th width="5%">新粉收入</th>
45
+                    <th width="5%">新粉ROI</th>
46
+                    <th width="5%">45日累计成单数</th>
47
+                    <th width="5%">45日累计收入</th>
48
+                    <th width="5%">45日累计ROI</th>                                                
49
+                </tr>
50
+                </thead>
51
+                <tbody>
52
+                @if($result)
53
+                    @foreach($result as $a)
54
+                        <tr class="text-c" style=" text-align:center;">                           
55
+                            <td>{{$a['ad_time']}}</td>                                                                                         
56
+                            <td>{{$a['city']}}</td>                                                                                         
57
+                            <td>{{$a['cost']}}</td>                                                                                           
58
+                            <td>{{$a['gzh_count']}}</td>                                                                                           
59
+                            <td>{{$a['fan_count']}}</td>                                                                                           
60
+                            <td>{{$a['new_fan_order_count']}}</td>                                                                                         
61
+                            <td>{{$a['new_fan_order_amount']}}</td>                                                                                         
62
+                            <td>{{$a['new_roi']}}</td>                                                                                         
63
+                            <td>{{$a['order_count']}}</td>                                                                                         
64
+                            <td>{{$a['order_amount']}}</td>                                                                                         
65
+                            <td>{{$a['total_roi']}}</td>                                                                                         
66
+                        </tr>
67
+                    @endforeach
68
+                @endif
69
+                </tbody>
70
+            </table>
71
+        </div>
72
+        <div id="page" class="page_div"></div>
73
+    </div>
74
+    
75
+    <!--_footer 作为公共模版分离出去-->
76
+    <script type="text/javascript" src="/admin/lib/jquery/1.9.1/jquery.min.js"></script>
77
+    <script type="text/javascript" src="/admin/lib/layer/2.4/layer.js"></script>
78
+    <script type="text/javascript" src="/admin/static/h-ui/js/H-ui.min.js"></script>
79
+    <script type="text/javascript" src="/admin/static/h-ui.admin/js/H-ui.admin.js"></script>
80
+    <script type="text/javascript" src="/admin/lib/page/paging.js"></script>
81
+    <script type="text/javascript" src="/admin/lib/My97DatePicker/4.8/WdatePicker.js"></script>
82
+    <!--/_footer 作为公共模版分离出去-->
83
+    <!--/_footer 作为公共模版分离出去-->
84
+     <script type="text/javascript">
85
+        
86
+        function user_search(){
87
+            var stime = $('#stime').val();
88
+            var etime = $('#etime').val();
89
+            var city = $('#city').val();
90
+            //var page = {{$page}};
91
+            location.href = 'districtRoi45day?stime='+stime+'&etime='+etime+'&city='+city;
92
+        }
93
+        //导出
94
+        function statistics_export(){
95
+            var stime = $('#stime').val();
96
+            var etime = $('#etime').val();
97
+            var city = $('#city').val();
98
+            location.href = '/admin/statistics/districtRoi45day_export?stime='+stime+'&etime='+etime+'&city='+city;
99
+        }
100
+
101
+        $("#data_type").change(function(){
102
+            var date_type = $(this).val();
103
+            if(date_type == 0){
104
+                location.href='districtRoi7day';
105
+            }
106
+            else if(date_type == 1){
107
+                location.href='districtRoi7dayTotal';
108
+            }
109
+            else if(date_type == 2){
110
+                location.href='districtRoi';
111
+            }
112
+            else if(date_type == 3){
113
+                location.href='districtRoi30day';
114
+            }
115
+            else if(date_type == 4){
116
+                location.href='districtRoi30dayTotal';
117
+            }
118
+            else if(date_type == 5){
119
+                location.href='districtRoi15day';
120
+            }
121
+            else if(date_type == 6){
122
+                location.href='districtRoi15dayTotal';
123
+            }
124
+            else if(date_type == 7){
125
+                location.href='districtRoi45day';
126
+            }
127
+            else if(date_type == 8){
128
+                location.href='districtRoi45dayTotal';
129
+            }
130
+        })
131
+       
132
+        /*分页*/
133
+            
134
+        $("#page").paging({
135
+            pageNo:{{$page}},
136
+            totalPage: {{$pages}},
137
+            totalSize: {{$count}},
138
+            callback: function(num) {
139
+                var stime = $('#stime').val();
140
+                var etime = $('#etime').val();
141
+                var city = $('#city').val();
142
+                location.href='districtRoi45day?page='+num+'&stime='+stime+'&etime='+etime+'&city='+city;
143
+            }
144
+        })
145
+        
146
+    </script>
147
+   
148
+    </body>
149
+
150
+@endsection

+ 137 - 0
resources/views/statistics/districtRoi45dayTotal.blade.php

@@ -0,0 +1,137 @@
1
+@extends('admin/master')
2
+@section('content')
3
+    <body>
4
+    <div class="page-container">
5
+        <div>
6
+            <div>  
7
+                <input class="input-text" style="width:6%;text-align:center" type="text" value="数据分类"/> 
8
+                <select style="width:10%;text-align:center" id='data_type' name="data_type">
9
+                    <option value="0" >7日roi明细</option>                   
10
+                    <option value="1" >7日roi汇总</option>                                     
11
+                    <option value="2" >每日roi明细</option> 
12
+                    <option value="5">15日roi明细</option>                                     
13
+                    <option value="6" >15日roi汇总</option>                                   
14
+                    <option value="3" >30日roi明细</option>                                     
15
+                    <option value="4">30日roi汇总</option> 
16
+                    <option value="7">45日roi明细</option>                                     
17
+                    <option value="8" selected>45日roi汇总</option>                                     
18
+                  
19
+                </select>  
20
+                <input class="input-text" style="width:5%;text-align:center" type="text" value="所属城市"/>
21
+                <input id="city" type="text"  class="input-text" style="width:6%;text-align:center" name="city" value="{{$city?$city:''}}">                         
22
+                
23
+                <a class="btn btn-primary radius"  style="margin-left: 5px" onclick="user_search()" href="javascript:;">搜索</a>
24
+                <a class="btn btn-primary radius" onclick="statistics_export()" href="javascript:;"><i class="Hui-iconfont"></i> 导出数据</a>
25
+                
26
+            </div>
27
+        </div>
28
+        
29
+        <div class="mt-20">
30
+            <table class="table table-border table-bordered table-bg table-hover table-sort">
31
+                <thead>
32
+                <tr class="text-c">
33
+                    <th width="5%">城市</th>
34
+                    <th width="5%">投放成本</th>
35
+                    <th width="5%">加粉数</th>
36
+                    <th width="5%">下单人数</th>
37
+                    <th width="5%">新粉成单数</th>
38
+                    <th width="5%">新粉收入</th>
39
+                    <th width="5%">新粉ROI</th>
40
+                    <th width="5%">45日累计成单数</th>
41
+                    <th width="5%">45日累计收入</th>
42
+                    <th width="5%">45日累计ROI</th>                                                
43
+                </tr>
44
+                </thead>
45
+                <tbody>
46
+                @if($result)
47
+                    @foreach($result as $a)
48
+                        <tr class="text-c" style=" text-align:center;">                                                                                                                   
49
+                            <td>{{$a['city']}}</td>                                                                                         
50
+                            <td>{{$a['cost']}}</td>                                                                                           
51
+                            <td>{{$a['gzh_count']}}</td>                                                                                           
52
+                            <td>{{$a['fan_count']}}</td>                                                                                           
53
+                            <td>{{$a['new_fan_order_count']}}</td>                                                                                         
54
+                            <td>{{$a['new_fan_order_amount']}}</td>                                                                                         
55
+                            <td>{{$a['new_roi']}}</td>                                                                                         
56
+                            <td>{{$a['order_count']}}</td>                                                                                         
57
+                            <td>{{$a['order_amount']}}</td>                                                                                         
58
+                            <td>{{$a['total_roi']}}</td>                                                                                         
59
+                        </tr>
60
+                    @endforeach
61
+                @endif
62
+                </tbody>
63
+            </table>
64
+        </div>
65
+        <div id="page" class="page_div"></div>
66
+    </div>
67
+    
68
+    <!--_footer 作为公共模版分离出去-->
69
+    <script type="text/javascript" src="/admin/lib/jquery/1.9.1/jquery.min.js"></script>
70
+    <script type="text/javascript" src="/admin/lib/layer/2.4/layer.js"></script>
71
+    <script type="text/javascript" src="/admin/static/h-ui/js/H-ui.min.js"></script>
72
+    <script type="text/javascript" src="/admin/static/h-ui.admin/js/H-ui.admin.js"></script>
73
+    <script type="text/javascript" src="/admin/lib/page/paging.js"></script>
74
+    <script type="text/javascript" src="/admin/lib/My97DatePicker/4.8/WdatePicker.js"></script>
75
+    <!--/_footer 作为公共模版分离出去-->
76
+    <!--/_footer 作为公共模版分离出去-->
77
+     <script type="text/javascript">
78
+        
79
+        function user_search(){
80
+
81
+            var city = $('#city').val();
82
+            //var page = {{$page}};
83
+            location.href = 'districtRoi45dayTotal?city='+city;
84
+        }
85
+        //导出
86
+        function statistics_export(){
87
+            var city = $('#city').val();
88
+            location.href = '/admin/statistics/districtRoi45dayTotal_export?city='+city;
89
+        }
90
+       
91
+        $("#data_type").change(function(){
92
+            var date_type = $(this).val();
93
+            if(date_type == 0){
94
+                location.href='districtRoi7day';
95
+            }
96
+            else if(date_type == 1){
97
+                location.href='districtRoi7dayTotal';
98
+            }
99
+            else if(date_type == 2){
100
+                location.href='districtRoi';
101
+            }
102
+            else if(date_type == 3){
103
+                location.href='districtRoi30day';
104
+            }
105
+            else if(date_type == 4){
106
+                location.href='districtRoi30dayTotal';
107
+            }
108
+            else if(date_type == 5){
109
+                location.href='districtRoi15day';
110
+            }
111
+            else if(date_type == 6){
112
+                location.href='districtRoi15dayTotal';
113
+            }
114
+            else if(date_type == 7){
115
+                location.href='districtRoi45day';
116
+            }
117
+            else if(date_type == 8){
118
+                location.href='districtRoi45dayTotal';
119
+            }
120
+        })
121
+        /*分页*/
122
+            
123
+        $("#page").paging({
124
+            pageNo:{{$page}},
125
+            totalPage: {{$pages}},
126
+            totalSize: {{$count}},
127
+            callback: function(num) {
128
+                var city = $('#city').val();
129
+                location.href='districtRoi45dayTotal?page='+num+'&city='+city;
130
+            }
131
+        })
132
+        
133
+    </script>
134
+   
135
+    </body>
136
+
137
+@endsection

+ 18 - 2
resources/views/statistics/districtRoi7day.blade.php

@@ -9,8 +9,12 @@
9 9
                     <option value="0" selected >7日roi明细</option>                   
10 10
                     <option value="1">7日roi汇总</option>                                     
11 11
                     <option value="2">每日roi明细</option>                                     
12
-                    <option value="3">30日roi明细</option>                                     
13
-                    <option value="4">30日roi汇总</option>                                     
12
+                    <option value="5">15日roi明细</option>                                     
13
+                    <option value="6" >15日roi汇总</option>                                   
14
+                    <option value="3" >30日roi明细</option>                                     
15
+                    <option value="4">30日roi汇总</option> 
16
+                    <option value="7">45日roi明细</option>                                     
17
+                    <option value="8">45日roi汇总</option>                                      
14 18
                   
15 19
                 </select> 
16 20
                 <input class="input-text" style="width:5%;text-align:center" type="text" value="所属城市"/>
@@ -111,6 +115,18 @@
111 115
             else if(date_type == 4){
112 116
                 location.href='districtRoi30dayTotal';
113 117
             }
118
+            else if(date_type == 5){
119
+                location.href='districtRoi15day';
120
+            }
121
+            else if(date_type == 6){
122
+                location.href='districtRoi15dayTotal';
123
+            }
124
+            else if(date_type == 7){
125
+                location.href='districtRoi45day';
126
+            }
127
+            else if(date_type == 8){
128
+                location.href='districtRoi45dayTotal';
129
+            }
114 130
         })
115 131
        
116 132
         /*分页*/

+ 19 - 3
resources/views/statistics/districtRoi7dayTotal.blade.php

@@ -9,8 +9,12 @@
9 9
                     <option value="0"  >7日roi明细</option>                   
10 10
                     <option value="1" selected>7日roi汇总</option>                                     
11 11
                     <option value="2" >每日roi明细</option>
12
-                    <option value="3">30日roi明细</option>                                     
13
-                    <option value="4">30日roi汇总</option>                                     
12
+                    <option value="5">15日roi明细</option>                                     
13
+                    <option value="6" >15日roi汇总</option>                                   
14
+                    <option value="3" >30日roi明细</option>                                     
15
+                    <option value="4">30日roi汇总</option> 
16
+                    <option value="7">45日roi明细</option>                                     
17
+                    <option value="8">45日roi汇总</option>                                      
14 18
                   
15 19
                 </select>  
16 20
                 <input class="input-text" style="width:5%;text-align:center" type="text" value="所属城市"/>
@@ -84,7 +88,7 @@
84 88
             location.href = '/admin/statistics/districtRoi7dayTotal_export?city='+city;
85 89
         }
86 90
        
87
-         $("#data_type").change(function(){
91
+        $("#data_type").change(function(){
88 92
             var date_type = $(this).val();
89 93
             if(date_type == 0){
90 94
                 location.href='districtRoi7day';
@@ -101,6 +105,18 @@
101 105
             else if(date_type == 4){
102 106
                 location.href='districtRoi30dayTotal';
103 107
             }
108
+            else if(date_type == 5){
109
+                location.href='districtRoi15day';
110
+            }
111
+            else if(date_type == 6){
112
+                location.href='districtRoi15dayTotal';
113
+            }
114
+            else if(date_type == 7){
115
+                location.href='districtRoi45day';
116
+            }
117
+            else if(date_type == 8){
118
+                location.href='districtRoi45dayTotal';
119
+            }
104 120
         })
105 121
         /*分页*/
106 122