sunhao 5 years ago
parent
commit
e80da8ae2f
1 changed files with 9 additions and 2 deletions
  1. 9 2
      app/Http/Controllers/Admin/TemplateController.php

+ 9 - 2
app/Http/Controllers/Admin/TemplateController.php

@@ -314,7 +314,7 @@ class TemplateController extends Controller
314 314
             $pages = 1;
315 315
         }
316 316
 
317
-        $result = TemplatesLog::select(DB::raw('idate,admin_id,count(1) as tcount, count(if(type=1,true,null)) as pv_count'))->where(function($query) use($admin_id, $stime, $etime, $sale_ids){
317
+        $result = TemplatesLog::select(DB::raw('idate,admin_id,count(1) as tcount'))->where(function($query) use($admin_id, $stime, $etime, $sale_ids){
318 318
             if($admin_id>0) $query->where('admin_id', $admin_id);
319 319
             if($stime) $query->where('idate', '>=', $stime);
320 320
             if($etime) $query->where('idate', '<=', $etime);
@@ -337,6 +337,9 @@ class TemplateController extends Controller
337 337
                 $v['new_consult'] = '';
338 338
                 $v['admin_name'] = DB::table('admin')->where('id', $v['admin_id'])->pluck('realname');
339 339
             }
340
+            //pv_count
341
+            $pv_count = TemplatesLog::where('idate', $v['idate'])->where('admin_id', $v['admin_id'])->where('type', 1)->count();
342
+            $v['pv_count'] = $pv_count;
340 343
             $v['long_count'] = $v['tcount'] - $v['pv_count'];
341 344
 
342 345
             //点击率
@@ -393,7 +396,7 @@ class TemplateController extends Controller
393 396
             $sale_ids = DB::table('admin')->where('team_id', $team_id)->lists('id');
394 397
         }
395 398
 
396
-        $result = TemplatesLog::select(DB::raw('idate,admin_id,count(1) as tcount, count(if(type=1,true,null)) as pv_count'))->where(function($query) use($admin_id, $stime, $etime, $sale_ids){
399
+        $result = TemplatesLog::select(DB::raw('idate,admin_id,count(1) as tcount'))->where(function($query) use($admin_id, $stime, $etime, $sale_ids){
397 400
             if($admin_id>0) $query->where('admin_id', $admin_id);
398 401
             if($stime) $query->where('idate', '>=', $stime);
399 402
             if($etime) $query->where('idate', '<=', $etime);
@@ -416,6 +419,10 @@ class TemplateController extends Controller
416 419
                 $v['new_consult'] = '';
417 420
                 $v['admin_name'] = DB::table('admin')->where('id', $v['admin_id'])->pluck('realname');
418 421
             }
422
+
423
+            //pv_count
424
+            $pv_count = TemplatesLog::where('idate', $v['idate'])->where('admin_id', $v['admin_id'])->where('type', 1)->count();
425
+            $v['pv_count'] = $pv_count;
419 426
             $v['long_count'] = $v['tcount'] - $v['pv_count'];
420 427
 
421 428
             //点击率