|
@@ -353,9 +353,6 @@ class CustomerDepositController extends Controller
|
353
|
353
|
$team_id = (int)$request->input('team_id');
|
354
|
354
|
|
355
|
355
|
$self_role = session('role_name');
|
356
|
|
- if($self_role == '销售' || $self_role == '分销销售'){
|
357
|
|
- $admin_id = session('admin_id');
|
358
|
|
- }
|
359
|
356
|
|
360
|
357
|
if($self_role == '管理员'){
|
361
|
358
|
//只能看自己团队的
|
|
@@ -428,7 +425,20 @@ class CustomerDepositController extends Controller
|
428
|
425
|
* @param Request $request
|
429
|
426
|
*/
|
430
|
427
|
public function addVipCustomer(Request $request) {
|
431
|
|
- return view('customer/vipCustomerCreate');
|
|
428
|
+ $self_role = session('role_name');
|
|
429
|
+ $team_id = null;
|
|
430
|
+ if($self_role == '管理员'){
|
|
431
|
+ //只能看自己团队的
|
|
432
|
+ $self_id = session('admin_id');
|
|
433
|
+ $team_id = DB::table('admin')->where('id', $self_id)->pluck('team_id');
|
|
434
|
+ }
|
|
435
|
+ $adminList = DB::table('admin')->select('id', 'realname', 'username')->where(function($query) use($team_id, $self_role){
|
|
436
|
+ if($self_role == '管理员') $query->where('team_id', $team_id);
|
|
437
|
+ })->where('id','>', 1)->get();
|
|
438
|
+ $adminList = json_decode(json_encode($adminList), true);
|
|
439
|
+ return view('customer/vipCustomerCreate',[
|
|
440
|
+ 'adminlist' => $adminList,
|
|
441
|
+ ]);
|
432
|
442
|
}
|
433
|
443
|
|
434
|
444
|
/**
|
|
@@ -436,7 +446,7 @@ class CustomerDepositController extends Controller
|
436
|
446
|
* @param Request $request
|
437
|
447
|
*/
|
438
|
448
|
public function storeVipCustomer(Request $request) {
|
439
|
|
- $self_id = session('admin_id');
|
|
449
|
+
|
440
|
450
|
$this->validate($request, [
|
441
|
451
|
'phone' => 'required',
|
442
|
452
|
'birthday' => 'required',
|
|
@@ -449,7 +459,7 @@ class CustomerDepositController extends Controller
|
449
|
459
|
$customerVip = new CustomerVip();
|
450
|
460
|
$customerVip->phone = $request->input('phone');
|
451
|
461
|
$customerVip->name = $request->input('name');
|
452
|
|
- $customerVip->admin_id = $self_id;
|
|
462
|
+ $customerVip->admin_id = $request->input('admin_id');
|
453
|
463
|
$customerVip->level = 1;
|
454
|
464
|
$customerVip->discount = 95;
|
455
|
465
|
$customerVip->create_time = date('Y-m-d H:i:s',time());
|
|
@@ -479,8 +489,22 @@ class CustomerDepositController extends Controller
|
479
|
489
|
*/
|
480
|
490
|
public function editVipCustomer(Request $request) {
|
481
|
491
|
$id = $request->input('id');
|
|
492
|
+ $self_role = session('role_name');
|
|
493
|
+ $team_id = null;
|
|
494
|
+ if($self_role == '管理员'){
|
|
495
|
+ //只能看自己团队的
|
|
496
|
+ $self_id = session('admin_id');
|
|
497
|
+ $team_id = DB::table('admin')->where('id', $self_id)->pluck('team_id');
|
|
498
|
+ }
|
482
|
499
|
$customer = CustomerVip::findOrFail($id);
|
483
|
|
- return view('customer/vipCustomerEdit',['info'=>$customer]);
|
|
500
|
+ $adminList = DB::table('admin')->select('id', 'realname', 'username')->where(function($query) use($team_id, $self_role){
|
|
501
|
+ if($self_role == '管理员') $query->where('team_id', $team_id);
|
|
502
|
+ })->where('id','>', 1)->get();
|
|
503
|
+ $adminList = json_decode(json_encode($adminList), true);
|
|
504
|
+ return view('customer/vipCustomerEdit',[
|
|
505
|
+ 'info'=>$customer,
|
|
506
|
+ 'adminlist' => $adminList,
|
|
507
|
+ ]);
|
484
|
508
|
}
|
485
|
509
|
|
486
|
510
|
/**
|
|
@@ -488,13 +512,13 @@ class CustomerDepositController extends Controller
|
488
|
512
|
* @param Request $request
|
489
|
513
|
*/
|
490
|
514
|
public function updateVipCustomer(Request $request) {
|
491
|
|
- $self_id = session('admin_id');
|
492
|
515
|
$id = $request->input('id');
|
493
|
516
|
|
494
|
517
|
//修改vip用户信息
|
495
|
518
|
$customerVip = CustomerVip::findOrFail($id);
|
496
|
519
|
$customerVip->name = $request->input('name');
|
497
|
520
|
$customerVip->birthday = $request->input('birthday');
|
|
521
|
+ $customerVip->admin_id = $request->input('admin_id');
|
498
|
522
|
if($customerVip->save()){
|
499
|
523
|
return redirect('/admin/customer/vipList')->with('info', '编辑成功');
|
500
|
524
|
} else {
|