Commit 87e74ab2 by 杨树贤

查看账号权限修改基础逻辑

parent e78f1734
...@@ -18,7 +18,7 @@ class SupplierAccountFilter ...@@ -18,7 +18,7 @@ class SupplierAccountFilter
$map = $request->all(); $map = $request->all();
$model = new SupplierAccountModel(); $model = new SupplierAccountModel();
$query = $model->with('supplier')->where('parent_id', 0)->orderBy('id', 'desc'); $query = $model->with('supplier')->where('parent_id', 0)->orderBy('id', 'desc');
$codeId = $request->user->codeId;
if (!checkPerm('ViewAllSupplierAccount')) { if (!checkPerm('ViewAllSupplierAccount')) {
if (checkPerm('ViewSubSupplierAccount')) { if (checkPerm('ViewSubSupplierAccount')) {
$departmentService = new DepartmentService(); $departmentService = new DepartmentService();
...@@ -27,11 +27,12 @@ class SupplierAccountFilter ...@@ -27,11 +27,12 @@ class SupplierAccountFilter
$adminUserService = new AdminUserService(); $adminUserService = new AdminUserService();
$subordinateCodeIds = $adminUserService->getCodeIdsByUserIds($subordinateUserIds); $subordinateCodeIds = $adminUserService->getCodeIdsByUserIds($subordinateUserIds);
$subordinateCodeIds = $subordinateCodeIds->toArray(); $subordinateCodeIds = $subordinateCodeIds->toArray();
$supplierIds = SupplierChannelModel::whereIn('yunxin_channel_uid', $subordinateCodeIds)->pluck('supplier_id')->toArray(); $likeSqlRaw = implode('|', $subordinateCodeIds);
$supplierIds = SupplierChannelModel::whereRaw(DB::raw("(channel_uid REGEXP '$likeSqlRaw')"))->pluck('supplier_id')->toArray();
$query->whereIn('supplier_id', $supplierIds); $query->whereIn('supplier_id', $supplierIds);
} else { } else {
//否则只能查看自己的 //否则只能查看自己的
$supplierIds = SupplierChannelModel::where('yunxin_channel_uid', $request->user->codeId)->pluck('supplier_id')->toArray(); $supplierIds = SupplierChannelModel::whereRaw(DB::raw("(yunxin_channel_uid REGEXP '$codeId')"))->pluck('supplier_id')->toArray();
$query->whereIn('supplier_id', $supplierIds); $query->whereIn('supplier_id', $supplierIds);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment