|
@@ -326,23 +326,42 @@ class custReportController extends Controller
|
326
|
326
|
}
|
327
|
327
|
|
328
|
328
|
$offset = ($page-1) * $pageSize;
|
329
|
|
-
|
|
329
|
+ $team_id = (int)$request->input('team_id');
|
|
330
|
+ $admin_id = (int)$request->input('admin_id');
|
|
331
|
+
|
|
332
|
+ $search_admin = 1;
|
|
333
|
+ #只能看自己团队的
|
330
|
334
|
$self_role = session('role_name');
|
331
|
|
- if($self_role == '超级管理员' || $self_role == '团队主管' || $self_role == '运营投放' || $self_role == '售后管理员'){
|
332
|
|
- $admin_id = $request->input('admin_id');
|
333
|
|
- $search_admin = 1;
|
334
|
|
- }else{
|
335
|
|
- $admin_id = session('admin_id');
|
|
335
|
+ if($self_role != '超级管理员' && $self_role != '售后管理员'){
|
|
336
|
+ $self_id = session('admin_id');
|
|
337
|
+ $team_id = DB::table('admin')->where('id', $self_id)->pluck('team_id');
|
|
338
|
+ }
|
|
339
|
+
|
|
340
|
+ if($admin_id>0 && !$team_id){
|
|
341
|
+ $team_id = DB::table('admin')->where('id', $admin_id)->pluck('team_id');
|
|
342
|
+ }
|
|
343
|
+
|
|
344
|
+ if($self_role == '销售'){
|
336
|
345
|
$search_admin = 0;
|
|
346
|
+ $admin_id = $self_id;
|
|
347
|
+ }
|
|
348
|
+
|
|
349
|
+ //假如有团队筛选,检索销售队员
|
|
350
|
+ $sale_ids = null;
|
|
351
|
+ if($team_id>0 && !$admin_id){
|
|
352
|
+ $sale_ids = DB::table('admin')->where('team_id', $team_id)->lists('id');
|
337
|
353
|
}
|
338
|
354
|
|
|
355
|
+
|
|
356
|
+
|
339
|
357
|
$stime = $request->input('stime');
|
340
|
358
|
$etime = $request->input('etime');
|
341
|
359
|
|
342
|
|
- $count = CustDetail::where(function($query) use($admin_id, $stime, $etime){
|
|
360
|
+ $count = CustDetail::where(function($query) use($admin_id, $stime, $etime, $sale_ids){
|
343
|
361
|
if($admin_id) $query->where('admin_id', $admin_id);
|
344
|
362
|
if($stime) $query->where('dtime', '>=', $stime);
|
345
|
363
|
if($etime) $query->where('dtime', '<=', $etime);
|
|
364
|
+ if($sale_ids) $query->whereIn('admin_id', $sale_ids);
|
346
|
365
|
})->where('is_del',0)->count();
|
347
|
366
|
if ($count > 1) {
|
348
|
367
|
// 总页数
|
|
@@ -352,14 +371,21 @@ class custReportController extends Controller
|
352
|
371
|
$pages = 1;
|
353
|
372
|
}
|
354
|
373
|
|
355
|
|
- $result = CustDetail::where(function($query) use($admin_id, $stime, $etime){
|
|
374
|
+ $result = CustDetail::where(function($query) use($admin_id, $stime, $etime, $sale_ids){
|
356
|
375
|
if($admin_id) $query->where('admin_id', $admin_id);
|
357
|
376
|
if($stime) $query->where('dtime', '>=', $stime);
|
358
|
377
|
if($etime) $query->where('dtime', '<=', $etime);
|
|
378
|
+ if($sale_ids) $query->whereIn('admin_id', $sale_ids);
|
359
|
379
|
})->where('is_del',0)->orderBy('id', 'desc')->offset($offset)->limit($pageSize)->get();
|
360
|
380
|
$result = json_decode(json_encode($result),true);
|
361
|
381
|
|
362
|
|
- $adminList = DB::table('admin')->select('id', 'realname', 'username')->where('id','>', 1)->get();
|
|
382
|
+ $teamList = DB::table('teams')->select('id', 'name')->where(function($query) use($self_role, $team_id){
|
|
383
|
+ if($team_id>0 && $self_role != '超级管理员' && $self_role != '售后管理员') $query->where('id', $team_id);
|
|
384
|
+ })->get();
|
|
385
|
+ $teamList = json_decode(json_encode($teamList), true);
|
|
386
|
+ $adminList = DB::table('admin')->select('id', 'realname', 'username')->where('id','>', 1)->where(function($query) use($self_role, $team_id){
|
|
387
|
+ if($team_id>0 && $self_role != '超级管理员' && $self_role != '售后管理员') $query->where('team_id', $team_id);
|
|
388
|
+ })->get();
|
363
|
389
|
$adminList = json_decode(json_encode($adminList), true);
|
364
|
390
|
|
365
|
391
|
//未上报数据销售
|
|
@@ -373,8 +399,10 @@ class custReportController extends Controller
|
373
|
399
|
'stime' =>$stime,
|
374
|
400
|
'etime' =>$etime,
|
375
|
401
|
'admin_id' =>$admin_id,
|
|
402
|
+ 'team_id' =>$team_id,
|
376
|
403
|
'search_admin' =>$search_admin,
|
377
|
404
|
'adminlist' =>$adminList,
|
|
405
|
+ 'teamlist' =>$teamList,
|
378
|
406
|
'noReportSaler' =>$noReportSaler,
|
379
|
407
|
'no_height' =>$no_height,
|
380
|
408
|
]);
|