Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
朱继来
/
后台订单管理
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
263b6b0b
authored
May 12, 2020
by
朱继来
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
调整订单权限
parent
b28228ce
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
181 additions
and
203 deletions
app/Http/Controllers/OrderController.php
app/Http/Controllers/PermController.php
config/perm_args.php
resources/views/detail/changeOrder.blade.php
resources/views/detail/content.blade.php
resources/views/orderlist/content.blade.php
app/Http/Controllers/OrderController.php
View file @
263b6b0b
...
...
@@ -397,11 +397,6 @@ Class OrderController extends Controller
$info
=
$this
->
getOrderInfo
(
$request
,
1
);
$info
[
'title'
]
=
'订单列表'
;
// 若为京东自营、自营客服等角色,则跳转到自营列表
if
(
in_array
(
$info
[
'role'
],
Config
(
'perm_args.self_roles'
)))
{
return
redirect
(
'self_order'
);
}
return
view
(
'orderlist'
,
$info
);
}
...
...
@@ -447,51 +442,31 @@ Class OrderController extends Controller
$map
[
'sale_id'
]
=
$map
[
'order_send'
];
// 订单查看权限
if
(
strpos
(
$info
[
'role'
],
','
)
!==
false
)
{
// 多角色情况下
$res
=
$perm
->
checkUserRoles
(
$request
,
$info
[
'role'
]);
$info
[
'role'
]
=
$res
[
'role_id'
];
if
(
$info
[
'role'
]
==
2
)
{
$sale_ids
=
$perm
->
getSubSaleId
(
$request
->
user
->
userId
);
// 获取下级人员
// 若无指定客服,则返回客服组里的所有订单
if
(
!
$map
[
'order_send'
])
{
$map
[
'sale_id'
]
=
$res
[
'sale_id'
];
}
else
if
(
!
in_array
(
$map
[
'order_send'
],
$res
[
'sale_id'
]))
{
// 若指定客服不存在与客服组,则不能筛选
$map
[
'sale_id'
]
=
-
1
;
}
else
{
$map
[
'sale_id'
]
=
$map
[
'order_send'
];
}
}
else
if
(
in_array
(
$info
[
'role'
],
Config
(
'perm_args.kefu_order'
)))
{
// 交易员、联营客服(线销一组、二组、三组客服)、自营客服、自营内部采购
$map
[
'sale_id'
]
=
$request
->
user
->
userId
;
// 筛选自己的订单
}
else
if
(
in_array
(
$info
[
'role'
],
Config
(
'perm_args.manager_order'
)))
{
// 线销一组、二组、三组主管、交易主管(查看自己及其下组员的订单)
$sale_ids
=
$perm
->
getGroupSalesId
(
$request
,
$info
[
'role'
]);
// 若无指定客服,则返回客服组里的所有订单
// 若无指定客服,则返回下级的所有订单
if
(
!
$map
[
'order_send'
])
{
$map
[
'sale_id'
]
=
$sale_ids
;
}
else
if
(
!
in_array
(
$map
[
'order_send'
],
$sale_ids
))
{
// 若指定客服不存在与
客服组
,则不能筛选
}
else
if
(
!
in_array
(
$map
[
'order_send'
],
$sale_ids
))
{
// 若指定客服不存在与
下级人员
,则不能筛选
$map
[
'sale_id'
]
=
-
1
;
}
else
{
$map
[
'sale_id'
]
=
$map
[
'order_send'
];
}
}
// 自营客服权限
if
(
$tid
==
2
&&
$info
[
'role'
]
==
6
)
{
$map
[
'check_jd_order'
]
=
1
;
// 只允许查看京东自营订单
}
else
if
(
$info
[
'role'
]
==
3
)
{
$map
[
'sale_id'
]
=
$request
->
user
->
userId
;
// 筛选自己的订单
}
// 非尽调账号显示真实数据
if
(
$
info
[
'role'
]
!=
13
)
{
if
(
$
request
->
user
->
email
!=
'vpadmin@ichunt.com'
)
{
$map
[
'is_fake'
]
=
0
;
}
else
{
// $map['vp_time_set'] = strtotime(Config('website.vp_time_set')); // 竞调账号根据时间展示订单
}
$map
[
'order_goods_type'
]
=
$tid
;
$size
=
10
;
if
(
$tid
==
1
)
{
$map
[
'order_type_filter'
]
=
in_array
(
$
info
[
'role'
],
[
1
,
13
])
?
[
1
,
2
,
3
,
4
]
:
[
1
,
4
];
// 管理员和尽调账号可以查看平台、ERP、京东订单
$map
[
'order_type_filter'
]
=
in_array
(
$
request
->
user
->
email
,
[
'admin@ichunt.com'
,
'vpadmin@ichunt.com'
])
?
[
1
,
2
,
3
,
4
]
:
[
1
,
4
];
// 管理员和尽调账号可以查看平台、ERP、京东订单
}
else
if
(
$tid
==
2
)
{
$size
=
20
;
$map
[
'order_type_filter'
]
=
[
1
,
3
,
4
];
// 1.网站 3.京东 4.象牙宝
...
...
@@ -511,53 +486,8 @@ Class OrderController extends Controller
{
$info
=
$this
->
_search
(
$request
,
$tid
);
$key
=
Config
(
'perm_args.redis_search_sales'
)[
$tid
];
$redis
=
Redis
::
connection
(
'read'
);
$sale_list
=
$redis
->
get
(
$key
);
if
(
!
$sale_list
)
{
// 获取所有的业务员 (包括经理、交易员、客服、测试)
$perm
=
new
PermController
;
$sale_list
=
[];
if
(
$tid
==
1
)
{
$search_sales
=
Config
(
'perm_args.search_joint_sales'
);
}
else
{
$search_sales
=
Config
(
'perm_args.search_self_sales'
);
$sale_list
[]
=
(
object
)
array
(
'userId'
=>
1000
,
'name'
=>
'admin'
,
'status'
=>
0
);
}
if
(
$search_sales
)
{
foreach
(
$search_sales
as
$v
)
{
$role_name
=
array_keys
(
Config
(
'perm_args.roles'
),
$v
);
$temp
=
$perm
->
getRoleUsers
(
$request
,
$role_name
[
0
]);
$sale_list
=
array_merge
(
$sale_list
,
$temp
);
}
}
$sale_list
=
$this
->
assoc_unique
(
$sale_list
);
$expire
=
Config
(
'perm_args.redis_search_sales_expire'
);
// 缓存两小时
Redis
::
setex
(
$key
,
$expire
,
json_encode
(
$sale_list
));
}
else
{
$sale_list
=
json_decode
(
$sale_list
);
}
// if ($tid == 1) {
// $manager = $perm->getRoleUsers($request, '经理');
// $test = $perm->getRoleUsers($request, '测试');
// $sales = $perm->getRoleUsers($request, '交易员');
// $kefu = $perm->getRoleUsers($request, '客服');
// $sale_list = array_merge($manager, $sales, $test, $kefu);
// } else if ($tid == 2) {
// $manager = $perm->getRoleUsers($request, '自营客服主管');
// $test = $perm->getRoleUsers($request, '测试');
// $assistant = $perm->getRoleUsers($request, '自营客服主管助理');
// $purchase = $perm->getRoleUsers($request, '自营内部采购');
// $kefu = $perm->getRoleUsers($request, '自营客服');
// $sale_list = array_merge($manager, $test, $assistant, $purchase, $kefu);
// }
$sale_list
=
$perm
->
getUserByPositionId
([
62
,
63
,
64
,
65
]);
// 获取所有的销售
//获取订单列表
$url
=
Config
(
'website.api_domain'
)
.
'order/getAllOrder'
;
...
...
@@ -756,11 +686,10 @@ Class OrderController extends Controller
}
}
else
{
$perm
=
new
PermController
;
$info
[
'buyers'
]
=
$perm
->
get
RoleUsers
(
$request
,
'采购员'
);
$info
[
'buyers'
]
=
$perm
->
get
UserByPositionId
(
39
);
// 获取采购员, ID - 39
$key
=
Config
(
'perm_args.redis_search_sales'
)[
1
];
$redis
=
Redis
::
connection
(
'read'
);
$sale_list
=
json_decode
(
$redis
->
get
(
$key
));
$perm
=
new
PermController
;
$sale_list
=
$perm
->
getUserByPositionId
([
62
,
63
,
64
,
65
],
0
);
// 获取所有的销售 (过滤已离职的)
$info
[
'cc_sales'
]
=
$sale_list
?
array_merge
(
$info
[
'buyers'
],
$sale_list
)
:
$info
[
'buyers'
];
}
...
...
@@ -782,8 +711,6 @@ Class OrderController extends Controller
}
$CmsModel
=
new
CmsModel
();
$name_data
=
$CmsModel
->
getBatchUserName
(
$data
);
...
...
app/Http/Controllers/PermController.php
View file @
263b6b0b
...
...
@@ -263,43 +263,43 @@
}
// 获取主管及其下对应组员的sale_id
public
function
getGroupSalesId
(
$request
,
$role_id
)
{
$sale_id
=
[];
//
public function getGroupSalesId($request, $role_id)
//
{
//
$sale_id = [];
// 主管ID
$manager_role_name
=
array_keys
(
Config
(
'perm_args.roles'
),
$role_id
);
//
// 主管ID
//
$manager_role_name = array_keys(Config('perm_args.roles'), $role_id);
if
(
$manager_role_name
)
{
$manager_sales
=
$this
->
getRoleUsers
(
$request
,
$manager_role_name
[
0
]);
//
if ($manager_role_name) {
//
$manager_sales = $this->getRoleUsers($request, $manager_role_name[0]);
if
(
$manager_sales
)
{
foreach
(
$manager_sales
as
$v
)
{
$sale_id
[]
=
$v
->
userId
;
}
}
}
//
if ($manager_sales) {
//
foreach ($manager_sales as $v) {
//
$sale_id[] = $v->userId;
//
}
//
}
//
}
// 线销主管对应的客服
$manager_to_kefu
=
Config
(
'perm_args.manager_to_kefu'
);
//
// 线销主管对应的客服
//
$manager_to_kefu = Config('perm_args.manager_to_kefu');
if
(
!
in_array
(
$role_id
,
array_keys
(
$manager_to_kefu
)))
return
0
;
//
if (!in_array($role_id, array_keys($manager_to_kefu))) return 0;
$sub_id
=
$manager_to_kefu
[
$role_id
];
$role_name
=
array_keys
(
Config
(
'perm_args.roles'
),
$sub_id
);
//
$sub_id = $manager_to_kefu[$role_id];
//
$role_name = array_keys(Config('perm_args.roles'), $sub_id);
if
(
!
$role_name
)
return
0
;
//
if (!$role_name) return 0;
$sales
=
$this
->
getRoleUsers
(
$request
,
$role_name
[
0
]);
//
$sales = $this->getRoleUsers($request, $role_name[0]);
if
(
$sales
)
{
foreach
(
$sales
as
$v
)
{
$sale_id
[]
=
$v
->
userId
;
}
}
//
if ($sales) {
//
foreach ($sales as $v) {
//
$sale_id[] = $v->userId;
//
}
//
}
return
$sale_id
;
}
//
return $sale_id;
//
}
/**
* 多角色情况下
...
...
@@ -310,38 +310,38 @@
* @param [type] $role_id [description]
* @return [type] [description]
*/
public
function
checkUserRoles
(
$request
,
$role_id
)
{
$roles
=
explode
(
','
,
$role_id
);
//
public function checkUserRoles($request, $role_id)
//
{
//
$roles = explode(',', $role_id);
$data
=
[];
$data
[
'role_id'
]
=
min
(
$roles
);
// 默认最小值
$data
[
'sale_id'
]
=
$request
->
user
->
userId
;
// 默认只能查看自己的订单数据
//
$data = [];
//
$data['role_id'] = min($roles); // 默认最小值
//
$data['sale_id'] = $request->user->userId; // 默认只能查看自己的订单数据
$master
=
array_intersect
(
$roles
,
Config
(
'perm_args.check_all_order'
));
// 交集,是否能查看所有订单
//
$master = array_intersect($roles, Config('perm_args.check_all_order')); // 交集,是否能查看所有订单
if
(
$master
)
{
$data
[
'role_id'
]
=
min
(
$master
);
// 设置最小值的角色 (因为系统页面都是单角色判断)
$data
[
'sale_id'
]
=
0
;
//
if ($master) {
//
$data['role_id'] = min($master); // 设置最小值的角色 (因为系统页面都是单角色判断)
//
$data['sale_id'] = 0;
return
$data
;
}
//
return $data;
//
}
$intersect
=
array_intersect
(
$roles
,
Config
(
'perm_args.manager_order'
));
// 交集,获取线销主管
//
$intersect = array_intersect($roles, Config('perm_args.manager_order')); // 交集,获取线销主管
if
(
$intersect
)
{
$data
[
'role_id'
]
=
min
(
$intersect
);
// 设置最小值的角色
//
if ($intersect) {
//
$data['role_id'] = min($intersect); // 设置最小值的角色
foreach
(
$intersect
as
$v
)
{
$sale_ids
[]
=
$this
->
getGroupSalesId
(
$request
,
$v
);
}
//
foreach ($intersect as $v) {
//
$sale_ids[] = $this->getGroupSalesId($request, $v);
//
}
$arr
=
array_reduce
(
$sale_ids
,
'array_merge'
,
array
());
// 转一维数组
$data
[
'sale_id'
]
=
array_merge
(
array_unique
(
$arr
));
// 去重后,再重新索引
}
//
$arr = array_reduce($sale_ids, 'array_merge', array()); // 转一维数组
//
$data['sale_id'] = array_merge(array_unique($arr)); // 去重后,再重新索引
//
}
return
$data
;
}
//
return $data;
//
}
// 获取角色对应的主管邮箱
public
function
getManager
(
$request
)
...
...
@@ -369,4 +369,59 @@
return
$email
;
}
/* 订单系统权限调整 --- 20200511 */
// 获取指定职位的用户ID
public
function
getUserByPositionId
(
$position_id
,
$status
=
''
)
{
$map
=
[];
if
(
is_array
(
$position_id
))
{
// 数组
// $map[] = ['in' => ['position_id' => $position_id]];
$str
=
implode
(
','
,
$position_id
);
$map
[]
=
[
DB
::
raw
(
"position_id in (
{
$str
}
)"
),
'1'
];
}
else
{
$map
[
'position_id'
]
=
$position_id
;
}
$status
!==
''
&&
$map
[
'status'
]
=
$status
;
// 0-在职用户,1-离职用户
return
DB
::
table
(
'user_info'
)
->
where
(
$map
)
->
select
(
'userId'
,
'name'
,
'position_id'
,
'position_name'
,
'department_id'
,
'department_name'
,
'status'
)
->
get
();
}
// 获取下级所有人员
public
function
getSubSaleId
(
$userId
)
{
$sale_ids
=
[];
array_unshift
(
$sale_ids
,
$userId
);
// 将当前用户添加到数组
$user_info
=
DB
::
table
(
'user_info'
)
->
where
(
'userId'
,
$userId
)
->
select
(
'department_id'
)
->
first
();
// 用户信息
if
(
!
$user_info
->
department_id
)
return
$sale_ids
;
// 获取当前用户下级部门
$department
=
DB
::
table
(
'user_department'
)
->
where
(
'parent_id'
,
$user_info
->
department_id
)
->
select
(
'department_id'
,
'department_name'
)
->
get
();
if
(
!
$department
)
{
$tmp
=
DB
::
table
(
'user_info'
)
->
where
(
'department_id'
,
$user_info
->
department_id
)
->
lists
(
'userId'
);
$sale_ids
=
array_merge
(
$sale_ids
,
$tmp
);
}
else
{
// 获取下级部门的人员
foreach
(
$department
as
$v
)
{
$tmp
=
DB
::
table
(
'user_info'
)
->
where
(
'department_id'
,
$v
->
department_id
)
->
lists
(
'userId'
);
$sale_ids
=
array_merge
(
$sale_ids
,
$tmp
);
}
}
return
array_unique
(
$sale_ids
);
// 去重返回
}
}
\ No newline at end of file
config/perm_args.php
View file @
263b6b0b
<?php
return
[
// 用户角色
'roles'
=>
[
'管理员'
=>
1
,
'经理'
=>
2
,
'交易员'
=>
3
,
// '客服' => 4,
'测试'
=>
5
,
'京东自营'
=>
6
,
'自营客服'
=>
7
,
'运营助理'
=>
8
,
'财务'
=>
9
,
'自营客服主管'
=>
10
,
'自营客服主管助理'
=>
11
,
'自营内部采购'
=>
12
,
'尽调'
=>
13
,
'线销一组主管'
=>
14
,
'线销一组客服'
=>
15
,
'线销二组主管'
=>
16
,
'线销二组客服'
=>
17
,
'线销三组主管'
=>
18
,
'线销三组客服'
=>
19
,
'运营'
=>
20
,
'产品'
=>
21
,
'交易主管'
=>
22
,
],
//
'roles' => [
//
'管理员' => 1,
//
'经理' => 2,
//
'交易员' => 3,
//
// '客服' => 4,
//
'测试' => 5,
//
'京东自营' => 6,
//
'自营客服' => 7,
//
'运营助理' => 8,
//
'财务' => 9,
//
'自营客服主管' => 10,
//
'自营客服主管助理' => 11,
//
'自营内部采购' => 12,
//
'尽调' => 13,
//
'线销一组主管' => 14,
//
'线销一组客服' => 15,
//
'线销二组主管' => 16,
//
'线销二组客服' => 17,
//
'线销三组主管' => 18,
//
'线销三组客服' => 19,
//
'运营' => 20,
//
'产品' => 21,
//
'交易主管' => 22,
//
],
// 线销主管 =》 线销客服
'manager_to_kefu'
=>
[
14
=>
15
,
16
=>
17
,
18
=>
19
,
22
=>
3
,
],
//
'manager_to_kefu' => [
//
14 => 15,
//
16 => 17,
//
18 => 19,
//
22 => 3,
//
],
// 筛选自己的订单
'kefu_order'
=>
[
3
,
7
,
12
,
15
,
17
,
19
],
//
'kefu_order' => [3, 7, 12, 15, 17, 19],
// 主管角色,查看自己及其组员订单
'manager_order'
=>
[
14
,
16
,
18
,
22
],
//
'manager_order' => [14, 16, 18, 22],
// 查看所有订单角色
'check_all_order'
=>
[
1
,
2
,
5
,
20
,
21
],
//
'check_all_order' => [1, 2, 5, 20, 21],
// 审单时权限 (用于调价权限 changeOrder.blade.php)
'is_manager_perm'
=>
[
1
,
2
,
10
,
11
,
14
,
16
,
18
,
22
],
//
'is_manager_perm' => [1, 2, 10, 11, 14, 16, 18, 22],
// 筛选业务员 -- 联营列表
'search_joint_sales'
=>
[
3
,
5
,
14
,
15
,
16
,
17
,
18
,
19
,
22
],
//
//
筛选业务员 -- 联营列表
//
'search_joint_sales' => [3, 5, 14, 15, 16, 17, 18, 19, 22],
// 筛选业务员 -- 自营列表 (包含联营、自营客服、交易员、主管)
'search_self_sales'
=>
[
3
,
5
,
7
,
10
,
11
,
12
,
14
,
15
,
16
,
17
,
18
,
19
,
22
],
//
//
筛选业务员 -- 自营列表 (包含联营、自营客服、交易员、主管)
//
'search_self_sales' => [3, 5, 7, 10, 11, 12, 14, 15, 16, 17, 18, 19, 22],
// 缓存筛选业务员
'redis_search_sales'
=>
[
1
=>
'search_joint_sales'
,
2
=>
'search_self_sales'
,
],
//
//
缓存筛选业务员
//
'redis_search_sales' => [
//
1 => 'search_joint_sales',
//
2 => 'search_self_sales',
//
],
'redis_search_sales_expire'
=>
7200
,
// 缓存两小时
//
'redis_search_sales_expire' => 7200, // 缓存两小时
// 客服经理 (固定,用于推送业务员页面)
'kefu_manager'
=>
[
(
object
)[
'userId'
=>
1445
,
'name'
=>
'张娟'
,
'status'
=>
0
],
// (object)['userId'=>1582, 'name'=>'滕欢欢', 'status'=>0],
],
//
'kefu_manager' => [
//
(object)['userId'=>1445, 'name'=>'张娟', 'status'=>0],
//
// (object)['userId'=>1582, 'name'=>'滕欢欢', 'status'=>0],
//
],
// 自营角色 无法查看联营订单
'self_roles'
=>
[
6
,
7
,
10
,
11
,
12
],
//
'self_roles' => [6, 7, 10, 11, 12],
// 菜单key
'perm_menus_data'
=>
'order_menus_href_data'
,
'perm_menus_data_expire'
=>
7200
,
// 用户角色
'roles'
=>
[
'管理员'
=>
1
,
'查看下级'
=>
2
,
'查看自己'
=>
3
,
'查看订单'
=>
4
,
],
];
resources/views/detail/changeOrder.blade.php
View file @
263b6b0b
...
...
@@ -568,7 +568,7 @@
@include('detail.addGoodsNoSkuid')
<script>
var
is_manager
=
"{{ in_array($role,
Config('perm_args.is_manager_perm')
) ? true : false }}"
;
var
is_manager
=
"{{ in_array($role,
[1, 2]
) ? true : false }}"
;
var
isNewClient
=
"{{isset($isNewClient) ? $isNewClient : 0}}"
;
// var order_amount = "{{$order_info['order_amount']}}";
...
...
resources/views/detail/content.blade.php
View file @
263b6b0b
...
...
@@ -633,21 +633,21 @@
@if ($order_info['order_remark'])
<tr>
<td>
订单备注信息:
</td>
<td
colspan=
"1
7
"
>
{{$order_info['order_remark']}}
</td>
<td
colspan=
"1
8
"
>
{{$order_info['order_remark']}}
</td>
</tr>
@endif
@if ($order_temp_info['kefu_remark'])
<tr>
<td>
客服备注信息:
</td>
<td
colspan=
"1
6
"
>
{{$order_temp_info['kefu_remark']}}
</td>
<td
colspan=
"1
8
"
>
{{$order_temp_info['kefu_remark']}}
</td>
</tr>
@endif
@if ($order_info['order_goods_type'] == 2
&&
$order_temp_info['business_type'] == 1)
<tr>
<td>
项目需求描述:
</td>
<td
colspan=
"1
6
"
>
{{$order_temp_info['sample_demand_desc']}}
</td>
<td
colspan=
"1
8
"
>
{{$order_temp_info['sample_demand_desc']}}
</td>
</tr>
@endif
</tfoot>
...
...
resources/views/orderlist/content.blade.php
View file @
263b6b0b
...
...
@@ -143,7 +143,8 @@
</dl>
@endif
@if (!in_array($role, [7, 15, 17, 19]))
<!-- 非'查看自己'权限展示 -->
@if (!in_array($role, [3]))
<dl>
<dt>
推送业务员:
</dt>
<dd>
...
...
@@ -223,20 +224,6 @@
</dl>
@endif
</td>
<!-- <td width="15%">
<dl>
<dt class="search-btn">
<button class="nbtn searchOrder">搜索</button>
</dt>
@if (in_array('export', $userPerms))
<dt>
<button class="nbtn exportExcel" style="background: #23c6c8 !important;">导出</button>
</dt>
@endif
</dl>
</td> -->
</tr>
</table>
...
...
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