增加业务强制绑定提醒
This commit is contained in:
@@ -3,8 +3,11 @@
|
||||
namespace app\common\logic;
|
||||
|
||||
use app\common\model\User;
|
||||
use app\common\model\UserGroupMembers;
|
||||
use app\common\traits\crud\CrudLogicTrait;
|
||||
use support\exception\BusinessException;
|
||||
use support\Request;
|
||||
use app\common\model\UserRoles;
|
||||
|
||||
class UserLogic
|
||||
{
|
||||
@@ -20,7 +23,7 @@ class UserLogic
|
||||
*/
|
||||
public function userInfo(int $uid)
|
||||
{
|
||||
$user = User::find($uid);
|
||||
$user = User::with('reportToInfo')->find($uid);
|
||||
|
||||
if (!$user) {
|
||||
throw new BusinessException('账户不存在', 404);
|
||||
@@ -38,6 +41,7 @@ class UserLogic
|
||||
*/
|
||||
public function edit(int $uid, array $data)
|
||||
{
|
||||
//
|
||||
$user = User::find($uid);
|
||||
|
||||
if (!$user) {
|
||||
@@ -47,6 +51,26 @@ class UserLogic
|
||||
$user->fill($data);
|
||||
$user->save();
|
||||
|
||||
// 绑定内勤 10.13 add
|
||||
if (isset($data['office_clerk_id']) && $data['office_clerk_id'] > 0) {
|
||||
$ug = UserGroupMembers::where('user_id', $uid)->where('status', 1)->first();
|
||||
if ($ug) {
|
||||
$ug->delete();
|
||||
}
|
||||
|
||||
$group = UserGroupMembers::where('user_id', $data['office_clerk_id'])->where('is_leader', 1)->where('status', 1)->first();
|
||||
if (!$group) {
|
||||
throw new BusinessException('该内勤还未创建分组', 404);
|
||||
}
|
||||
|
||||
UserGroupMembers::create([
|
||||
'user_id' => $uid,
|
||||
'group_id' => $group->group_id,
|
||||
'is_leader' => 0,
|
||||
'status' => 1
|
||||
]);
|
||||
}
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
@@ -64,9 +88,16 @@ class UserLogic
|
||||
/**
|
||||
* 获取用户列表
|
||||
*/
|
||||
public function getList()
|
||||
public function getList(Request $request)
|
||||
{
|
||||
$list = User::where('status', 1)->orderBy('id', 'desc')->get();
|
||||
$p = $request->all();
|
||||
|
||||
$user = User::where('status', 1);
|
||||
if (isset($p['role_id']) && $p['role_id'] > 0) {
|
||||
$userIds = UserRoles::where('role_id', $p['role_id'])->pluck('user_id');
|
||||
$user->whereIn('id', $userIds);
|
||||
}
|
||||
$list = $user->orderBy('id', 'desc')->get();
|
||||
$arr = [];
|
||||
foreach ($list->toArray() as $item) {
|
||||
$arr[] = [
|
||||
|
||||
Reference in New Issue
Block a user