AbstractController.class.php
1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
/**
* AbstractController.class.php
* 基类
* @author : zhoutao
* @version : $Id$
* @copyright: vchangyi.com
*/
namespace Api\Controller\Mall;
use Common\Common\Department;
use Common\Model\PrizeModel;
abstract class AbstractController extends \Api\Controller\AbstractController
{
public function before_action($action = '')
{
if (!parent::before_action($action)) {
return false;
}
return true;
}
public function after_action($action = '')
{
return parent::after_action();
}
/**
* 判断可见范围
* @param array $prizeData 奖品数据
* @return bool
*/
protected function verifyArea($prizeData)
{
// 如果是全公司
if ($prizeData['is_all'] == PrizeModel::IS_ALL) {
return true;
}
// 在人员所属部门
if (!empty($prizeData['range_mem']) && in_array($this->uid, explode(',', $prizeData['range_mem']))) {
return true;
}
if (!empty($prizeData['range_dep'])) {
// 部门范围限制
$depUtil = new Department();
$depArr = explode(',', $prizeData['range_dep']);
$depArea = $depUtil->list_childrens_by_cdid($depArr, true);
// 当前人员的所属部门
$userDep = $depUtil->list_dpId_by_uid($this->uid, true);
$userDepArr = [];
foreach ($userDep as $dep) {
$userDepArr = array_merge($userDepArr, $dep);
}
// 是否有交集
$intersect = array_intersect($depArea, array_values($userDepArr));
if (!empty($intersect)) {
return true;
}
}
return false;
}
}