|
@@ -22,11 +22,16 @@ class CustomerDepositController extends Controller
|
22
|
22
|
*/
|
23
|
23
|
public function customerList(Request $request)
|
24
|
24
|
{
|
|
25
|
+ $admin_id = (int)$request->input('admin_id');
|
25
|
26
|
$self_role = session('role_name');
|
26
|
|
- $admin_id = session('admin_id');
|
27
|
|
- if($self_role == '超级管理员' || $self_role == '售后管理员'){
|
28
|
|
- $admin_id=null;
|
|
27
|
+ $self_id = session('admin_id');
|
|
28
|
+
|
|
29
|
+ $saler_ids = null;
|
|
30
|
+ if($self_role == '管理员'){
|
|
31
|
+ $team_id = DB::table('admin')->where('id', $self_id)->pluck('team_id');
|
|
32
|
+ $saler_ids = DB::table('admin')->where('team_id', $team_id)->lists('id');
|
29
|
33
|
}
|
|
34
|
+
|
30
|
35
|
$phone = trim( $request->input('phone') );
|
31
|
36
|
$name = trim( $request->input('name') );
|
32
|
37
|
$page = (int)$request->input('page');
|
|
@@ -37,10 +42,11 @@ class CustomerDepositController extends Controller
|
37
|
42
|
|
38
|
43
|
$offset = ($page-1) * $pageSize;
|
39
|
44
|
|
40
|
|
- $count = CustomerInfo::where(function($query) use($phone, $name, $admin_id){
|
|
45
|
+ $count = CustomerInfo::where(function($query) use($phone, $name, $admin_id, $saler_ids){
|
41
|
46
|
if($phone) $query->where('phone', $phone);
|
42
|
47
|
if($name) $query->where('name', 'like', '%'. $name. '%');
|
43
|
48
|
if($admin_id) $query->where('admin_id', $admin_id);
|
|
49
|
+ if( !empty($saler_ids) ) $query->whereIn('admin_id', $saler_ids);
|
44
|
50
|
})->count();
|
45
|
51
|
if ($count > 1) {
|
46
|
52
|
// 总页数
|
|
@@ -50,10 +56,11 @@ class CustomerDepositController extends Controller
|
50
|
56
|
$pages = 1;
|
51
|
57
|
}
|
52
|
58
|
|
53
|
|
- $result = CustomerInfo::where(function($query) use($phone, $name, $admin_id){
|
|
59
|
+ $result = CustomerInfo::where(function($query) use($phone, $name, $admin_id, $saler_ids){
|
54
|
60
|
if($phone) $query->where('phone', $phone);
|
55
|
61
|
if($name) $query->where('name', 'like', '%'. $name. '%');
|
56
|
62
|
if($admin_id) $query->where('admin_id', $admin_id);
|
|
63
|
+ if( !empty($saler_ids) ) $query->whereIn('admin_id', $saler_ids);
|
57
|
64
|
})->orderBy('id', 'desc')->offset($offset)->limit($pageSize)->get();
|
58
|
65
|
$result = json_decode(json_encode($result),true);
|
59
|
66
|
foreach($result as $k=>&$v){
|
|
@@ -118,7 +125,19 @@ class CustomerDepositController extends Controller
|
118
|
125
|
//查询套餐
|
119
|
126
|
$packages = CustomerDepositPackages::where('is_del', 0)->orderBy('pay_amount', 'asc')->get();
|
120
|
127
|
$phonei = substr($phone,0,3).'****'.substr($phone,7);
|
121
|
|
- return view('deposit/create', ['packages'=>$packages, 'phone'=>$phone, 'phonei'=>$phonei]);
|
|
128
|
+
|
|
129
|
+ $self_role = session('role_name');
|
|
130
|
+ $team_id = null;
|
|
131
|
+ if($self_role == '管理员'){
|
|
132
|
+ $admin_id = session('admin_id');
|
|
133
|
+ $team_id = DB::table('admin')->where('id', $admin_id)->pluck('team_id');
|
|
134
|
+ }
|
|
135
|
+ $adminList = DB::table('admin')->select('id', 'realname', 'username')->where(function($query) use($team_id){
|
|
136
|
+ if($team_id>0) $query->where('team_id', $team_id);
|
|
137
|
+ })->where('id','>', 1)->get();
|
|
138
|
+ $adminList = json_decode(json_encode($adminList), true);
|
|
139
|
+
|
|
140
|
+ return view('deposit/create', ['packages'=>$packages, 'phone'=>$phone, 'phonei'=>$phonei, 'adminlist'=>$adminList, 'self_role'=>$self_role]);
|
122
|
141
|
}
|
123
|
142
|
|
124
|
143
|
/**
|
|
@@ -143,7 +162,8 @@ class CustomerDepositController extends Controller
|
143
|
162
|
'pay_time.required' => '充值时间必须选择',
|
144
|
163
|
|
145
|
164
|
]);
|
146
|
|
- $admin_id = session('admin_id');
|
|
165
|
+ $admin_id = (int)$request->input('admin_id');
|
|
166
|
+ if(!$admin_id) $admin_id = session('admin_id');
|
147
|
167
|
|
148
|
168
|
$deposit = new CustomerDeposit();
|
149
|
169
|
$deposit->phone = $request->input('phone');
|