Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
semour
/
semour_admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
ed6ee05d
authored
Nov 16, 2022
by
宁成龙
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
完善自动分配功能
parent
df6ef40a
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
209 additions
and
1 deletions
app/Admin/Service/AutoAssignCustomer.php
app/Admin/Service/UserService.php
app/Models/Cms/CmsDepartmentModel.php
app/Models/Cms/CmsUserDepartmentModel.php
app/Admin/Service/AutoAssignCustomer.php
View file @
ed6ee05d
...
@@ -46,5 +46,17 @@ class AutoAssignCustomer
...
@@ -46,5 +46,17 @@ class AutoAssignCustomer
return
\App\Models\AutoAssignCustomer
::
updateById
(
$assignInfo
[
'id'
],
[
'now_num'
=>
$nowNum
]);
return
\App\Models\AutoAssignCustomer
::
updateById
(
$assignInfo
[
'id'
],
[
'now_num'
=>
$nowNum
]);
}
}
public
static
function
updateDepartmentNum
(){
//获取自动分配部门
$assignInfo
=
\App\Models\AutoAssignCustomer
::
getNowAssignInfo
();
if
(
empty
(
$assignInfo
))
{
return
false
;
}
//获取部门人员
}
}
}
app/Admin/Service/UserService.php
View file @
ed6ee05d
...
@@ -103,9 +103,10 @@ class UserService
...
@@ -103,9 +103,10 @@ class UserService
"last_name"
=>
$params
[
"last_name"
],
"last_name"
=>
$params
[
"last_name"
],
"phone"
=>
$params
[
"phone"
],
"phone"
=>
$params
[
"phone"
],
"email"
=>
$params
[
"email"
],
"email"
=>
$params
[
"email"
],
"name"
=>
$params
[
"email"
],
"reg_source"
=>
User
::
REG_SOURCE_MANUAL
,
"reg_source"
=>
User
::
REG_SOURCE_MANUAL
,
"remark"
=>
$params
[
"remark"
]
??
""
,
"remark"
=>
$params
[
"remark"
]
??
""
,
"password"
=>
"
123456
"
,
"password"
=>
""
,
"status"
=>
User
::
STATUS_NORMAL
,
"status"
=>
User
::
STATUS_NORMAL
,
"sale_id"
=>
request
()
->
user
->
userId
??
"1000"
,
"sale_id"
=>
request
()
->
user
->
userId
??
"1000"
,
"sale_name"
=>
request
()
->
user
->
name
??
"admin"
,
"sale_name"
=>
request
()
->
user
->
name
??
"admin"
,
...
...
app/Models/Cms/CmsDepartmentModel.php
0 → 100644
View file @
ed6ee05d
<?php
namespace
App\Models\Cms
;
use
Illuminate\Database\Eloquent\Model
;
class
CmsDepartmentModel
extends
Model
{
protected
$table
=
'department'
;
public
$timestamps
=
false
;
protected
$primaryKey
=
'departmentId'
;
//采购部门的总ID
const
PURCHASE_DEPARTMENT_ID
=
8
;
//销售部门的总ID
const
SALES_DEPARTMENT_ID
=
7
;
// 获取部门人员
public
static
function
getUsersByDepartmentId
(
$departmentId
,
$status
=
''
,
$filter
=
''
)
{
$departmentIds
=
[];
self
::
getSubDepartmentId
(
$departmentId
,
$departmentIds
);
return
CmsUserInfoModel
::
whereIn
(
'department_id'
,
$departmentIds
)
->
where
(
function
(
$query
)
use
(
$status
)
{
if
(
$status
!==
''
)
{
$query
->
where
(
'status'
,
'='
,
$status
);
}
})
->
where
(
function
(
$query
)
use
(
$filter
)
{
if
(
$filter
)
{
$query
->
whereRaw
(
$filter
);
}
})
->
get
()
->
toArray
();
}
// 获取下级部门ID
public
static
function
getSubDepartmentId
(
$departmentId
,
&
$departmentIds
)
{
// 获取下级部门
$sub_department
=
CmsUserDepartmentModel
::
where
(
'parent_id'
,
$departmentId
)
->
select
([
'department_id'
,
'department_name'
])
->
get
();
if
(
$sub_department
)
{
foreach
(
$sub_department
as
$v
)
{
self
::
getSubDepartmentId
(
$v
[
'department_id'
],
$departmentIds
);
}
}
$departmentIds
[]
=
$departmentId
;
return
$departmentIds
;
}
}
app/Models/Cms/CmsUserDepartmentModel.php
0 → 100644
View file @
ed6ee05d
<?php
namespace
App\Models\Cms
;
use
Illuminate\Database\Eloquent\Model
;
class
CmsUserDepartmentModel
extends
Model
{
protected
$connection
=
'cms'
;
protected
$table
=
'user_department'
;
public
$timestamps
=
false
;
public
static
function
getDepartmentIdsParrentIds
(
$parrent_ids
=
[])
{
$res
=
self
::
whereIn
(
'parent_id'
,
$parrent_ids
)
->
pluck
(
'department_id'
);
return
(
$res
)
?
$res
->
toArray
()
:
[];
}
// 根据父ID获取指定的部门
public
static
function
getDepartmentByParentId
(
$parent_id
)
{
if
(
is_array
(
$parent_id
))
{
$list
=
self
::
whereIn
(
'parent_id'
,
$parent_id
);
}
else
{
$list
=
self
::
where
(
'parent_id'
,
$parent_id
);
}
return
$list
->
pluck
(
'department_name'
,
'department_id'
)
->
toArray
();
}
public
static
function
getDepartmentInfo
(
$department_id
)
{
$res
=
self
::
where
(
'department_id'
,
$department_id
)
->
first
();
return
(
$res
)
?
$res
->
toArray
()
:
[];
}
public
static
function
getDepartmentListByDepartmentIdArr
(
$departmentIdArr
)
{
$res
=
self
::
whereIn
(
'department_id'
,
$departmentIdArr
)
->
get
();
return
(
$res
)
?
$res
->
toArray
()
:
[];
}
public
static
function
getDepartmentList
(
$departmentName
,
$departmentIds
)
{
$res
=
self
::
select
(
'department_name'
)
->
where
(
'department_name'
,
'like'
,
'%'
.
$departmentName
.
'%'
)
->
whereIn
(
'department_id'
,
$departmentIds
)
->
get
();
return
(
$res
)
?
$res
->
toArray
()
:
[];
}
public
static
function
getDepartmentListByName
(
$departmentName
)
{
$res
=
self
::
select
(
'department_name'
)
->
distinct
(
'department_name'
)
->
where
(
'department_name'
,
'like'
,
"%
{
$departmentName
}
%"
)
->
orderByDesc
(
'department_id'
)
->
pluck
(
'department_name'
);
return
(
$res
)
?
$res
->
toArray
()
:
[];
}
// 根据部门名称获取部门ID
public
static
function
getDepartmentIdByName
(
$department_name
)
{
return
self
::
where
(
'department_name'
,
$department_name
)
->
value
(
'department_id'
);
}
public
static
function
getDepartmentId
(
$department
)
{
$res
=
self
::
select
(
'department_id'
)
->
distinct
(
'department_name'
)
->
where
(
'department_name'
,
$department
)
->
pluck
(
'department_id'
);
return
(
$res
)
?
$res
->
toArray
()
:
[];
}
// 获取部门人员
public
static
function
getUserByDepartmentId
(
$departmentId
,
$status
=
''
,
$filter
=
''
)
{
$departmentIds
=
[];
self
::
getSubDepartmentId
(
$departmentId
,
$departmentIds
);
return
CmsUserInfoModel
::
whereIn
(
'department_id'
,
$departmentIds
)
->
where
(
function
(
$query
)
use
(
$status
)
{
if
(
$status
!==
''
)
{
$query
->
where
(
'status'
,
'='
,
$status
);
}
})
->
where
(
function
(
$query
)
use
(
$filter
)
{
if
(
$filter
)
{
$query
->
whereRaw
(
$filter
);
}
})
->
select
(
'userId'
,
'name'
,
'status'
)
->
get
();
}
// 获取下级部门ID
public
static
function
getSubDepartmentId
(
$departmentId
,
&
$departmentIds
)
{
// 获取下级部门
$sub_department
=
self
::
where
(
'parent_id'
,
$departmentId
)
->
select
(
'department_id'
,
'department_name'
)
->
get
();
if
(
$sub_department
)
{
foreach
(
$sub_department
as
$v
)
{
self
::
getSubDepartmentId
(
$v
[
'department_id'
],
$departmentIds
);
}
}
$departmentIds
[]
=
$departmentId
;
return
$departmentIds
;
}
/*
* 获取上级部门,只需要往上找一层
* 比如:线上一组=》线上销售部
*/
public
static
function
getParentDepartment
(
$dep_id
)
{
$parent_id
=
self
::
where
(
"department_id"
,
intval
(
$dep_id
))
->
value
(
"parent_id"
);
if
(
!
$parent_id
){
return
[];
}
$parentInfo
=
self
::
where
(
"department_id"
,
$parent_id
)
->
select
(
"department_id"
,
"department_name"
)
->
first
();
return
$parentInfo
?
$parentInfo
->
toArray
()
:
[];
}
// 获取下级部门
public
static
function
getSubDepartmentById
(
$department_id
)
{
return
self
::
where
(
'parent_id'
,
$department_id
)
->
select
(
'department_id'
,
'department_name'
)
->
get
()
->
toArray
();
}
// 获取顶级部门名称
public
static
function
getTopDepartmentNameById
(
$department_id
)
{
return
self
::
where
(
'department_id'
,
$department_id
)
->
where
(
'parent_id'
,
0
)
->
value
(
'department_name'
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment