Commit 5654c1f3a187e0bdb5f442fe8e9529e3584fdb44
1 parent
dfa663ca
hris v2接口
Showing
4 changed files
with
694 additions
and
4 deletions
src/ApiV2/Department.php
0 → 100644
1 | +<?php | |
2 | +/** | |
3 | + * Department.php | |
4 | + * 部门接口V2 | |
5 | + * @author Deepseath | |
6 | + * @version $Id$ | |
7 | + */ | |
8 | +namespace deepseath\hris\ApiV2; | |
9 | + | |
10 | +class Department | |
11 | +{ | |
12 | + /** | |
13 | + * 基类服务对象 | |
14 | + * @var \deepseath\hris\Hris | |
15 | + */ | |
16 | + protected $service = null; | |
17 | + | |
18 | + /** | |
19 | + * 部门删除状态:正常(未删除) | |
20 | + * @var integer | |
21 | + */ | |
22 | + const DELETE_NO = 1; | |
23 | + /** | |
24 | + * 部门删除状态:已删除 | |
25 | + * @var integer | |
26 | + */ | |
27 | + const DELETE_YES = 2; | |
28 | + | |
29 | + /** | |
30 | + * 畅移本地顶级部门(智慧零售部)的 id | |
31 | + * md5('2022-04-27 17:00:01') —— 该值没具体意义主要就是一个在hris识别“智慧零售事业部”的标识<br> | |
32 | + * 该值的来源是,首次导给 hris 全量部门数据时,以当时时间md5做顶级部门标识,方便 hris 导入处理 | |
33 | + * @var string | |
34 | + */ | |
35 | + const CY_TOP_ID = '6e691aaf7d16f7b5199cce086e781368'; | |
36 | + | |
37 | + public function __construct(\deepseath\hris\Hris $service) | |
38 | + { | |
39 | + $this->service = $service; | |
40 | + } | |
41 | + | |
42 | + /** | |
43 | + * 获取畅移在集团内的架构信息 | |
44 | + * | |
45 | + * @return array | |
46 | + */ | |
47 | + public function getCyBranch() : array | |
48 | + { | |
49 | + foreach ($this->branchList() as $branch) { | |
50 | + if (isset($branch['branchId']) && isset($branch['branchNo']) && $branch['branchNo'] == self::CY_TOP_ID) { | |
51 | + return [ | |
52 | + 'branchId' => $branch['branchId'], | |
53 | + 'branchNo' => $branch['branchNo'], | |
54 | + 'nameEN' => $branch['nameEN'], | |
55 | + 'nameZH' => $branch['nameZH'] | |
56 | + ]; | |
57 | + break; | |
58 | + } | |
59 | + } | |
60 | + | |
61 | + throw new \Exception('无法获取畅移在集团内的架构信息', 91000); | |
62 | + } | |
63 | + | |
64 | + /** | |
65 | + * 获取部门信息 | |
66 | + * @desc 获取部门及部门上下级关系 | |
67 | + * @param array $params | |
68 | + * @return array | |
69 | + */ | |
70 | + public function branchList(array $params = []) : array | |
71 | + { | |
72 | + $params = array_merge([], $params); | |
73 | + | |
74 | + $result = $this->service->apiRequest('get', 'branchTree', $params); | |
75 | + return $result['branchTree'] ?? []; | |
76 | + } | |
77 | + | |
78 | + /** | |
79 | + * 新增部门 | |
80 | + * | |
81 | + * @desc 新增部门,成功则返回 hris 该部门的 ID | |
82 | + * @param array $params | |
83 | + * <pre> | |
84 | + * branchNo 薪人薪事部门 ID | |
85 | + * parentBranchId 上级部门 ID(HRIS 部门 id) | |
86 | + * nameEN 部门英文名 | |
87 | + * nameZH 部门中文名 | |
88 | + * </pre> | |
89 | + * @return int | |
90 | + */ | |
91 | + public function branchAdd(array $params) : array | |
92 | + { | |
93 | + $params = array_merge($params, [ | |
94 | + 'deleted' => self::DELETE_NO | |
95 | + ]); | |
96 | + | |
97 | + $result = $this->service->apiRequest('post', 'branch_add_edit', $params); | |
98 | + if (is_scalar($result)) { | |
99 | + if (preg_match('/ID(\d+)/is', $result, $match)) { | |
100 | + // 新增部门ID56896新增部门 | |
101 | + $branchId = $match[1]; | |
102 | + } | |
103 | + } else { | |
104 | + $branchId = $result['branchId']; | |
105 | + } | |
106 | + return [ | |
107 | + 'branchId' => $branchId | |
108 | + ]; | |
109 | + } | |
110 | + | |
111 | + /** | |
112 | + * 编辑部门 | |
113 | + * | |
114 | + * @param array $params | |
115 | + * <pre> | |
116 | + * branchId 待编辑的部门 ID(HRIS 部门 id) | |
117 | + * branchNo 薪人薪事部门 ID | |
118 | + * parentBranchId 上级部门 ID(HRIS 部门 id) | |
119 | + * nameEN 部门英文名 | |
120 | + * nameZH 部门中文名 | |
121 | + * </pre> | |
122 | + * @return boolean | |
123 | + */ | |
124 | + public function branchEdit(array $params) : bool | |
125 | + { | |
126 | + $params = array_merge($params, [ | |
127 | + 'deleted' => self::DELETE_NO | |
128 | + ]); | |
129 | + | |
130 | + $result = $this->service->apiRequest('post', 'branch_add_edit', $params); | |
131 | + if (is_scalar($result)) { | |
132 | + return true; | |
133 | + } | |
134 | + return false; | |
135 | + } | |
136 | + | |
137 | + /** | |
138 | + * 删除部门 | |
139 | + * | |
140 | + * @param array $params | |
141 | + * <pre> | |
142 | + * branchId 待删除的部门 ID(HRIS 部门 id) | |
143 | + * branchNo 薪人薪事部门 ID | |
144 | + * parentBranchId 上级部门 ID(HRIS 部门 id) | |
145 | + * nameEN 部门英文名 | |
146 | + * nameZH 部门中文名 | |
147 | + * </pre> | |
148 | + * @return boolean | |
149 | + */ | |
150 | + public function branchDelete(array $params) : bool | |
151 | + { | |
152 | + $params = array_merge($params, [ | |
153 | + 'deleted' => self::DELETE_YES | |
154 | + ]); | |
155 | + | |
156 | + $result = $this->service->apiRequest('post', 'branch_add_edit', $params); | |
157 | + if (is_scalar($result)) { | |
158 | + return true; | |
159 | + } | |
160 | + return false; | |
161 | + } | |
162 | +} | ... | ... |
src/ApiV2/Mapping.php
0 → 100644
1 | +<?php | |
2 | +/** | |
3 | + * Mapping.php | |
4 | + * 接口字典,转义字段 v2 | |
5 | + * @author Deepseath | |
6 | + * @version $Id$ | |
7 | + */ | |
8 | +namespace deepseath\hris\ApiV2; | |
9 | + | |
10 | +class Mapping | |
11 | +{ | |
12 | + /** | |
13 | + * 基类服务对象 | |
14 | + * @var \deepseath\hris\Hris | |
15 | + */ | |
16 | + protected $service = null; | |
17 | + | |
18 | + public function __construct(\deepseath\hris\Hris $service) | |
19 | + { | |
20 | + $this->service = $service; | |
21 | + } | |
22 | + | |
23 | + | |
24 | + | |
25 | + /** | |
26 | + * 获取指定字段的字典信息 | |
27 | + * | |
28 | + * @param string $field | |
29 | + * @param boolean $force | |
30 | + * @return array | |
31 | + */ | |
32 | + public function get(string $field = null, bool $force = false) : array | |
33 | + { | |
34 | + if ($field !== null) { | |
35 | + $type = $this->types($field); | |
36 | + if (is_array($type)) { | |
37 | + return $type; | |
38 | + } | |
39 | + } | |
40 | + | |
41 | + $cache = $this->service->cache(); | |
42 | + $cachePool = $cache->getItem('mappings'); | |
43 | + if (!$cachePool->isHit() | |
44 | + || $force !== false | |
45 | + || !($mappings = $cachePool->get()) | |
46 | + || !isset($mappings['expire_at']) | |
47 | + || time() - $mappings['expire_at'] > $this->service->config['mapping_expire']) { | |
48 | + | |
49 | + $result = $this->service->apiRequest('get', 'mappingVO', []); | |
50 | + $mappings = []; | |
51 | + foreach ($result['mappings'] ?? [] as $mapping) { | |
52 | + $mappings[$mapping['mappingType']][$mapping['mappingId']] = $mapping['mappingValue']; | |
53 | + } | |
54 | + $mappings = [ | |
55 | + 'expire_at' => time(), | |
56 | + 'data' => $mappings | |
57 | + ]; | |
58 | + $cachePool->set($mappings); | |
59 | + $cachePool->expiresAfter($this->service->config['mapping_expire']); | |
60 | + $cache->save($cachePool); | |
61 | + } | |
62 | +//print_r(array_keys($mappings['data'])); | |
63 | + return $field === null ? $mappings['data'] : $mappings['data'][$type]; | |
64 | + } | |
65 | + | |
66 | + /** | |
67 | + * 列出字典字段 | |
68 | + * | |
69 | + * @param string|null $field | |
70 | + * @return mixed | |
71 | + */ | |
72 | + public function types(string $field = null) : mixed | |
73 | + { | |
74 | + $fieldMap = [ | |
75 | + 'employeeStatus' => [1 => '在职', 3 => '离职'], | |
76 | + 'entityId' => 'entityIds', | |
77 | + 'locationId' => 'locations', | |
78 | + 'jobRole' => 'jobRoles', | |
79 | + 'employeeType' => 'employeeTypes', | |
80 | + 'gradeId' => 'grades', | |
81 | + 'nation' => 'nations', | |
82 | + 'nationality' => 'nationalities', | |
83 | + 'gender' => 'genders', | |
84 | + 'certificateType' => 'certificateTypes', | |
85 | + 'maritalStatus' => 'maritalStatuses', | |
86 | + 'highestEducationId' => 'highestEducations', | |
87 | + 'residencyProvinceId' => 'provinces', | |
88 | + 'residencyCityId' => 'cities', | |
89 | + 'residencyType' => 'residencyTypes', | |
90 | + 'residencyType2' => 'residencyTypes2', | |
91 | + 'emergency.relationshipId' => 'relationshipIds', | |
92 | + 'bankId' => 'banks', | |
93 | + 'recruitment' => 'recruitments', | |
94 | + 'recruitmentHc' => 'recruitmentHcs', | |
95 | + 'esop' => 'esop', | |
96 | + 'leaveCompensate' => 'leaveCompensate', | |
97 | + ]; | |
98 | + | |
99 | + if ($field === null) { | |
100 | + return $fieldMap; | |
101 | + } | |
102 | + | |
103 | + if (!isset($fieldMap[$field])) { | |
104 | + throw new \Exception('Hris sdk error: mapping type not exists', 10009); | |
105 | + } | |
106 | + | |
107 | + return $fieldMap[$field]; | |
108 | + } | |
109 | + | |
110 | +} | ... | ... |
src/ApiV2/User.php
0 → 100644
1 | +<?php | |
2 | +/** | |
3 | + * User.php | |
4 | + * 用户接口 v2 | |
5 | + * @author Deepseath | |
6 | + * @version $Id$ | |
7 | + */ | |
8 | +namespace deepseath\hris\ApiV2; | |
9 | + | |
10 | +class User | |
11 | +{ | |
12 | + /** | |
13 | + * 基类服务对象 | |
14 | + * @var \deepseath\hris\Hris | |
15 | + */ | |
16 | + protected $service = null; | |
17 | + | |
18 | + public function __construct(\deepseath\hris\Hris $service) | |
19 | + { | |
20 | + $this->service = $service; | |
21 | + } | |
22 | + | |
23 | + /** | |
24 | + * 员工基础信息 | |
25 | + * @desc 查询 HRIS 中的员工基础信息,参数为空返回所有成员 | |
26 | + * @param array $params | |
27 | + * <pre> | |
28 | + * nameZH 按中文名模糊查询 | |
29 | + * email 按邮箱查询 | |
30 | + * </pre> | |
31 | + * @return array | |
32 | + * <pre> | |
33 | + * list | |
34 | + * employeeId | |
35 | + * nameZH | |
36 | + * nameEN | |
37 | ||
38 | + * wxUserId | |
39 | + * positionId | |
40 | + * remark1 | |
41 | + * </pre> | |
42 | + */ | |
43 | + public function list(array $params = []) : array | |
44 | + { | |
45 | + $params = array_merge([ | |
46 | + //'nameZH' => '', | |
47 | + //'email' => '' | |
48 | + ], $params); | |
49 | + | |
50 | + $result = $this->service->apiRequest('get', 'employeeList', $params); | |
51 | + return $result['employeeList'] ?? []; | |
52 | + } | |
53 | + | |
54 | + /** | |
55 | + * 新增员工 | |
56 | + * @desc 向HRIS中插入新用户 | |
57 | + * @param array $params | |
58 | + * @return mixed | |
59 | + */ | |
60 | + public function add(array $params) : mixed | |
61 | + { | |
62 | + if (!empty($params['email']) && preg_match('/@i\-click\.com$/is', $params['email'])) { | |
63 | + // 如果是 i-click.com 邮箱则不处理 | |
64 | + throw new \Exception('i-click.com mail ignore', 4013); | |
65 | + } | |
66 | + $this->_fieldCheck($params); | |
67 | + // $result; | |
68 | + return $this->service->apiRequest('post', 'add_employee', $params); | |
69 | + } | |
70 | + | |
71 | + /** | |
72 | + * 更新员工 | |
73 | + * @desc 用户修改 | |
74 | + * @param array $params | |
75 | + * @return mixed | |
76 | + */ | |
77 | + public function update(array $params) : mixed | |
78 | + { | |
79 | + if (!empty($params['email']) && preg_match('/@i\-click\.com$/is', $params['email'])) { | |
80 | + // 如果是 i-click.com 邮箱则不处理 | |
81 | + throw new \Exception('i-click.com mail ignore', 4013); | |
82 | + } | |
83 | + $this->_fieldCheck($params); | |
84 | + return $this->service->apiRequest('post', 'edit_employee', $params); | |
85 | + } | |
86 | + | |
87 | + /** | |
88 | + * 更改邮箱专用接口 | |
89 | + * | |
90 | + * @param array $params | |
91 | + * <pre> | |
92 | + * + employeeId | |
93 | ||
94 | + * + updateEmail | |
95 | + * </pre> | |
96 | + * @return mixed | |
97 | + */ | |
98 | + public function email(array $params) : mixed | |
99 | + { | |
100 | + if (!empty($params['email']) && preg_match('/@i\-click\.com$/is', $params['email'])) { | |
101 | + // 如果是 i-click.com 邮箱则不处理 | |
102 | + throw new \Exception('i-click.com mail ignore', 4013); | |
103 | + } | |
104 | + return $this->service->apiRequest('post', 'update_employee_email', $params); | |
105 | + } | |
106 | + | |
107 | + /** | |
108 | + * 员工离职 | |
109 | + * @param array $params | |
110 | + * @return mixed | |
111 | + */ | |
112 | + public function dismiss(array $params) : mixed | |
113 | + { | |
114 | + if (!empty($params['email']) && preg_match('/@i\-click\.com$/is', $params['email'])) { | |
115 | + // 如果是 i-click.com 邮箱则不处理 | |
116 | + throw new \Exception('i-click.com mail ignore', 4013); | |
117 | + } | |
118 | + if (isset($params['email']) && !preg_match('/dismiss_\d+_\d+/is', $params['email'])) { | |
119 | + // 不是离职标识邮箱,则先更改邮箱 | |
120 | + $emailParams = []; | |
121 | + if (!empty($params['email'])) { | |
122 | + $emailParams['email'] = $params['email']; | |
123 | + } | |
124 | + if (empty($params['email'])) { | |
125 | + $params['email'] = 'dismiss_'.date('Ymd') .'_' . mt_rand(100000, 999999).'@vchangyi.com'; | |
126 | + } else { | |
127 | + $params['email'] = $params['email'] . '_' . 'dismiss_'.date('Ymd') .'_' . mt_rand(100000, 999999); | |
128 | + } | |
129 | + $emailParams['updateEmail'] = $params['email']; | |
130 | + $this->email($emailParams); | |
131 | + } | |
132 | + | |
133 | + $params = array_merge($params, [ | |
134 | + 'employeeStatus' => self::STATUS_OFFLINE | |
135 | + ]); | |
136 | + return $this->service->apiRequest('post', 'edit_employee', $params); | |
137 | + } | |
138 | + | |
139 | + /** | |
140 | + * 删除成员 | |
141 | + * @param array $params | |
142 | + * @return mixed | |
143 | + */ | |
144 | + public function delete(array $params) : mixed | |
145 | + { | |
146 | + if (!empty($params['email']) && preg_match('/@i\-click\.com$/is', $params['email'])) { | |
147 | + // 如果是 i-click.com 邮箱则不处理 | |
148 | + throw new \Exception('i-click.com mail ignore', 4013); | |
149 | + } | |
150 | + if (isset($params['email']) && !preg_match('/delete_\d+_\d+/is', $params['email'])) { | |
151 | + $emailParams = []; | |
152 | + if (!empty($params['email'])) { | |
153 | + $emailParams['email'] = $params['email']; | |
154 | + } | |
155 | + | |
156 | + if (empty($params['email'])) { | |
157 | + $params['email'] = 'delete_'.date('Ymd') .'_' . mt_rand(100000, 999999).'@vchangyi.com'; | |
158 | + } else { | |
159 | + $params['email'] = $params['email'] . '_' . 'delete_'.date('Ymd') .'_' . mt_rand(100000, 999999); | |
160 | + } | |
161 | + $emailParams['updateEmail'] = $params['email']; | |
162 | + | |
163 | + $this->email($emailParams); | |
164 | + } | |
165 | + | |
166 | + $params = array_merge($params, [ | |
167 | + 'employeeStatus' => self::STATUS_OFFLINE, | |
168 | + 'deleted' => self::IS_DELETE | |
169 | + ]); | |
170 | + return $this->service->apiRequest('post', 'edit_employee', $params); | |
171 | + } | |
172 | + | |
173 | + /** | |
174 | + * 员工数据参数检查 | |
175 | + * @param array $params | |
176 | + * @throws \Exception | |
177 | + * @return bool | |
178 | + */ | |
179 | + private function _fieldCheck(array $params) : bool | |
180 | + { | |
181 | + | |
182 | + return true; | |
183 | + } | |
184 | + | |
185 | + /** | |
186 | + * 在职状态:在职 | |
187 | + */ | |
188 | + const STATUS_ON = '1'; | |
189 | + /** | |
190 | + * 在职状态:离职 | |
191 | + */ | |
192 | + const STATUS_OFFLINE = '3'; | |
193 | + | |
194 | + /** | |
195 | + * 是否删除:确认删除 | |
196 | + */ | |
197 | + const IS_DELETE = 2; | |
198 | + /** | |
199 | + * 在职状态描述映射关系 | |
200 | + * @var array | |
201 | + */ | |
202 | + const MAP_STATUS = [ | |
203 | + self::STATUS_ON => '在职', | |
204 | + self::STATUS_OFFLINE => '离职' | |
205 | + ]; | |
206 | + | |
207 | + /** | |
208 | + * 法务实体映射关系 | |
209 | + * @var array | |
210 | + */ | |
211 | + const MAP_ENTOTY = [ | |
212 | + '157' => '畅移(上海)信息科技有限公司', | |
213 | + '158' => '西安畅展信息科技有限公司', | |
214 | + ]; | |
215 | + | |
216 | + /** | |
217 | + * 工作地映射关系 | |
218 | + * @var array | |
219 | + */ | |
220 | + const MAP_LOCATION = [ | |
221 | + '65' => '上海', | |
222 | + '116' => '西安', | |
223 | + ]; | |
224 | + | |
225 | + /** | |
226 | + * 员工类型映射关系 | |
227 | + * @var array | |
228 | + */ | |
229 | + const MAP_TYPE = [ | |
230 | + '0' => '请选择', | |
231 | + '1' => 'Full Time Employee',// 全职 | |
232 | + '2' => 'Intern',// 实习生 | |
233 | + '3' => 'Consultant',// 顾问 | |
234 | + '4' => 'Others on Payroll',// 编外 | |
235 | + '5' => 'Temp',// 临时工 | |
236 | + '6' => 'Part Time Employee',// 兼职 | |
237 | + '7' => '其他', | |
238 | + ]; | |
239 | + | |
240 | + /** | |
241 | + * 职级映射关系 | |
242 | + * @var array | |
243 | + */ | |
244 | + const MAP_GRADE_ID = [ | |
245 | + '179' => ['E2', 'Sr. Executive'], | |
246 | + '181' => ['E1', 'Executive'], | |
247 | + '183' => ['M4', 'GM/VP'], | |
248 | + '187' => ['M3', 'Director'], | |
249 | + '189' => ['IC6', 'Director'], | |
250 | + '191' => ['M2', 'Sr. Manager'], | |
251 | + '193' => ['IC5', 'Sr. Manager'], | |
252 | + '195' => ['M1', 'Manager'], | |
253 | + '197' => ['IC4', 'Manager'], | |
254 | + '199' => ['IC3', 'Associate Manager'], | |
255 | + '201' => ['IC2', 'Sr. Specialist'], | |
256 | + '203' => ['IC1', 'Specialist'], | |
257 | + '205' => ['S2', 'Coordinator'], | |
258 | + '207' => ['S1', 'Assistant'], | |
259 | + '209' => ['E1', 'COO'], | |
260 | + '213' => ['IC7', 'GM/VP'], | |
261 | + '315' => ['E1', 'CFO'], | |
262 | + '316' => ['E3', 'Chairman'], | |
263 | + '319' => ['M5', 'GM/VP'] | |
264 | + ]; | |
265 | + | |
266 | + /** | |
267 | + * 身份证件类型映射关系 | |
268 | + * @var array | |
269 | + */ | |
270 | + const MP_CERTIFICATE_TYPE = [ | |
271 | + '0' => '请选择', | |
272 | + '1' => '身份证', | |
273 | + '2' => '护照', | |
274 | + '3' => '台胞证', | |
275 | + '4' => '身份证(香港)', | |
276 | + '5' => '身份证(新加坡)', | |
277 | + '6' => '港澳通行证', | |
278 | + ]; | |
279 | + | |
280 | + /** | |
281 | + * 婚姻状态映射关系 | |
282 | + * @var array | |
283 | + */ | |
284 | + const MP_MARITAL_STATUS = [ | |
285 | + '0' => '请选择', | |
286 | + '1' => '未婚', | |
287 | + '2' => '已婚', | |
288 | + ]; | |
289 | + | |
290 | + /** | |
291 | + * 最高学历映射关系 | |
292 | + * @var array | |
293 | + */ | |
294 | + const MAP_HIGHEST_EDUCATION = [ | |
295 | + '0' => ['请选择', ''], | |
296 | + '95' => ['PhD', '博士'], | |
297 | + '97' => ['Master', '硕士'], | |
298 | + '99' => ['Bachelor', '本科'], | |
299 | + '103' => ['Senior High', '高中'], | |
300 | + '105' => ['Junior High', '初中'], | |
301 | + '107' => ['Diploma', '大专'], | |
302 | + '109' => ['Associate Degree', '大学肆业'], | |
303 | + '111' => ['Advanced Diploma', '高级文凭'], | |
304 | + '113' => ['Higher Diploma', '高级文凭'], | |
305 | + '115' => ['Juris Doctor', '法学博士'], | |
306 | + '117' => ['Certificate', '证书'], | |
307 | + '119' => ['Secondary ', '中专'], | |
308 | + '121' => ['F.5', 'F.5'], | |
309 | + ]; | |
310 | + | |
311 | + /** | |
312 | + * 民族映射关系 | |
313 | + * @var array | |
314 | + */ | |
315 | + const NATION = [ | |
316 | + '0' => '请选择', | |
317 | + '1' => '汉族', | |
318 | + '10' => '瑶族', | |
319 | + '11' => '锡伯族', | |
320 | + '12' => '苗族', | |
321 | + '2' => '蒙古族', | |
322 | + '3' => '土家族', | |
323 | + '4' => '满族', | |
324 | + '5' => '壮族', | |
325 | + '6' => '仫佬族', | |
326 | + '7' => '回族', | |
327 | + '8' => '英国', | |
328 | + '9' => '维吾尔族', | |
329 | + ]; | |
330 | + | |
331 | + /** | |
332 | + * 国籍映射关系 | |
333 | + * @var array | |
334 | + */ | |
335 | + const MAP_NATION_NALITY = [ | |
336 | + '0' => '请选择', | |
337 | + '1' => '中国', | |
338 | + '2' => '美国', | |
339 | + '3' => '新加坡', | |
340 | + '5' => '加拿大', | |
341 | + '7' => '英国', | |
342 | + '9' => '泰国', | |
343 | + '11' => '日本', | |
344 | + '13' => '韩国', | |
345 | + '15' => '法国', | |
346 | + '17' => '香港', | |
347 | + '19' => '台湾', | |
348 | + '21' => '澳大利亚', | |
349 | + '23' => '菲律宾', | |
350 | + '24' => '德国', | |
351 | + '25' => '意大利', | |
352 | + '26' => '马来西亚', | |
353 | + '27' => '新西兰', | |
354 | + '28' => '西班牙', | |
355 | + '29' => '其他', | |
356 | + ]; | |
357 | + | |
358 | + /** | |
359 | + * 角色映射关系 | |
360 | + * @var array | |
361 | + */ | |
362 | + const MAP_JOB_ROLE = [ | |
363 | + '0' => '请选择', | |
364 | + '10' => 'Engineering', | |
365 | + '12' => 'Finance', | |
366 | + '14' => 'Human Resources', | |
367 | + '16' => 'Management', | |
368 | + '17' => 'Marketing', | |
369 | + '18' => 'Media', | |
370 | + '19' => 'Optimization', | |
371 | + '20' => 'Product Management', | |
372 | + '21' => 'Project Management', | |
373 | + '23' => 'Sales', | |
374 | + '28' => 'Creative Design', | |
375 | + '29' => 'Legal', | |
376 | + '3' => 'Account Management', | |
377 | + '30' => 'Product Marketing', | |
378 | + '31' => 'Product Trainer', | |
379 | + '32' => 'Sales Operations', | |
380 | + '37' => 'Solution Planning', | |
381 | + '4' => 'Accounting', | |
382 | + '40' => 'Biz Planning & Operations', | |
383 | + '41' => 'Solution Development', | |
384 | + '43' => 'Product Operations', | |
385 | + '44' => 'User Experience Design', | |
386 | + '45' => 'Public Relations', | |
387 | + '46' => 'Data Analysis', | |
388 | + '47' => 'Kol Operations', | |
389 | + '48' => 'Content Operations', | |
390 | + '49' => 'Creative', | |
391 | + '5' => 'Ad. Operations', | |
392 | + '6' => 'Administration', | |
393 | + '8' => 'Biz Development', | |
394 | + '9' => 'Biz Intelligence', | |
395 | + ]; | |
396 | + | |
397 | + /** | |
398 | + * 性别映射关系 | |
399 | + * @var array | |
400 | + */ | |
401 | + const MAP_GENDER = [ | |
402 | + '0' => '未填写', | |
403 | + '1' => '先生', | |
404 | + '2' => '女士' | |
405 | + ]; | |
406 | +} | ... | ... |
src/Hris.php
... | ... | @@ -13,7 +13,7 @@ class Hris |
13 | 13 | { |
14 | 14 | /** |
15 | 15 | * 缓存池 |
16 | - * @var object | |
16 | + * @var \Symfony\Component\Cache\Adapter\FilesystemAdapter | |
17 | 17 | */ |
18 | 18 | protected $_cache = null; |
19 | 19 | |
... | ... | @@ -43,7 +43,7 @@ class Hris |
43 | 43 | |
44 | 44 | /** |
45 | 45 | * HTTP 请求对象 |
46 | - * @var object | |
46 | + * @var \Yurun\Util\HttpRequest | |
47 | 47 | */ |
48 | 48 | protected $_http = null; |
49 | 49 | |
... | ... | @@ -95,12 +95,24 @@ class Hris |
95 | 95 | if (isset($options['debug'])) { |
96 | 96 | $this->_debug = $options['debug']; |
97 | 97 | } |
98 | + if (!isset($this->config['mapping_expire'])) { | |
99 | + $this->config['mapping_expire'] = 86400 * 7; | |
100 | + } | |
98 | 101 | |
99 | 102 | $this->_originToken= $options['originToken']; |
100 | 103 | $this->_http = \Yurun\Util\HttpRequest::newSession(); |
101 | 104 | } |
102 | 105 | |
103 | 106 | /** |
107 | + * 缓存对象 | |
108 | + * @return \Symfony\Component\Cache\Adapter\FilesystemAdapter | |
109 | + */ | |
110 | + public function cache() | |
111 | + { | |
112 | + return $this->_cache; | |
113 | + } | |
114 | + | |
115 | + /** | |
104 | 116 | * 获取 token 信息 |
105 | 117 | * @param $force bool 是否强制获取更新 token |
106 | 118 | * @return array |
... | ... | @@ -165,7 +177,7 @@ class Hris |
165 | 177 | * @param array $data 请求的数据 |
166 | 178 | * @param bool $flushToken 是否强制刷新 token |
167 | 179 | * @throws \Exception |
168 | - * @return array|string | |
180 | + * @return array | |
169 | 181 | */ |
170 | 182 | public function apiRequest($method, $path, $data, $flushToken = false) |
171 | 183 | { |
... | ... | @@ -228,7 +240,7 @@ class Hris |
228 | 240 | } |
229 | 241 | |
230 | 242 | |
231 | - return isset($result['data']) ? $result['data'] : []; | |
243 | + return isset($result['data']) ? $result['data'] : ($result['msg'] ?? []); | |
232 | 244 | } |
233 | 245 | |
234 | 246 | /** | ... | ... |