sunhao 5 lat temu
rodzic
commit
d502fe988f

+ 4 - 3
app/Http/Controllers/Admin/StatisticsController.php

@@ -1497,7 +1497,7 @@ class StatisticsController extends Controller
1497 1497
         $result = AdCost::select(DB::raw('sum(cost) as total_cost, city, ad_time'))->where(function($query) use($stime, $etime, $city){    
1498 1498
             if($stime) $query->where('ad_time', '>=', $stime);
1499 1499
             if($etime) $query->where('ad_time', '<=', $etime);
1500
-            if($city) $query->where('city', 'like', $city.'%');
1500
+            if($city) $query->where('city', 'like', '%'.$city.'%');
1501 1501
         })->groupBy('ad_time')->groupBy('city')->orderBy('ad_time', 'desc')->offset($offset)->limit($pageSize)->get();
1502 1502
 
1503 1503
         $result = json_decode(json_encode($result), true);
@@ -1505,11 +1505,11 @@ class StatisticsController extends Controller
1505 1505
             //新粉收入
1506 1506
             //当日加粉
1507 1507
             $city_name = str_replace('市', '', $v['city']);
1508
-            $phones = DB::table('customers')->where('fanTime', $v['ad_time'])->where('receiverCity', $city_name)->lists('phone');
1508
+            $phones = DB::table('customers')->where('fanTime', $v['ad_time'])->where('receiverCity','like', '%'.$city_name.'%')->lists('phone');
1509 1509
             #当日加粉订单总计:
1510 1510
             $order = DB::table('order')->select(DB::raw('sum(receivedAmount) as order_amount, count(1) as order_count'))->whereIn('receiverMobile', $phones)->where('is_del', 0)->first();
1511 1511
             #当日新粉成单:            
1512
-            $new_order = DB::table('order')->select(DB::raw('sum(receivedAmount) as order_amount, count(1) as order_count'))->where('createTime','>=', $v['ad_time'])->where('createTime','<', $v['ad_time'].' 23:59:59')->where('is_del', 0)->whereIn('receiverMobile', $phones)->first();
1512
+            $new_order = DB::table('order')->select(DB::raw('sum(receivedAmount) as order_amount, count(1) as order_count'))->where('createTime','>=', $v['ad_time'])->where('createTime','<=', $v['ad_time'].' 23:59:59')->where('is_del', 0)->whereIn('receiverMobile', $phones)->first();
1513 1513
             // 1.当日新粉成单数
1514 1514
             $v['new_order_count'] = $new_order->order_count;
1515 1515
             // 2.当日新粉成交额 
@@ -1522,6 +1522,7 @@ class StatisticsController extends Controller
1522 1522
             $v['new_roi'] = $v['total_cost']>0 ? round($v['new_order_amount'] / $v['total_cost'], 4) * 100 .'%' : '';
1523 1523
             //累计roi
1524 1524
             $v['total_roi'] = $v['total_cost']>0 ? round($v['order_amount'] / $v['total_cost'], 4) * 100 .'%' : '';
1525
+            $v['new_fan_count'] = count($phones);
1525 1526
         }
1526 1527
 
1527 1528
         return view('statistics/districtRoi', ['result' =>$result,

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

@@ -25,6 +25,7 @@
25 25
                     <th width="5%">日期</th>
26 26
                     <th width="5%">城市</th>
27 27
                     <th width="5%">投放成本</th>
28
+                    <th width="5%">新粉数量</th>
28 29
                     <th width="5%">新粉成单数</th>
29 30
                     <th width="5%">新粉收入</th>
30 31
                     <th width="5%">新粉ROI</th>
@@ -39,7 +40,8 @@
39 40
                         <tr class="text-c" style=" text-align:center;">                           
40 41
                             <td>{{$a['ad_time']}}</td>                                                                                         
41 42
                             <td>{{$a['city']}}</td>                                                                                         
42
-                            <td>{{$a['total_cost']}}</td>                                                                                         
43
+                            <td>{{$a['total_cost']}}</td>                                                                                           
44
+                            <td>{{$a['new_fan_count']}}</td>                                                                                           
43 45
                             <td>{{$a['new_order_count']}}</td>                                                                                         
44 46
                             <td>{{$a['new_order_amount']}}</td>                                                                                         
45 47
                             <td>{{$a['new_roi']}}</td>