ManageHr.php
5.8 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
<?php
namespace App\Models\Manage;
use App\Models\Base;
use Illuminate\Support\Facades\Cache;
class ManageHr extends Base
{
protected $table = 'gl_manage_hr';
const GID_ZERO = 0;//超级管理员
const STATUS_ONE = 1;
const IS_LEADER = 1;//组长
/**
* 特殊字段
* @return string[]
* @author zgj
* @date 2023/5/31
*/
public static function specieField(){
return ['photo_gallery','id_card_gallery','certificate_gallery','career_history','learning_history'];
}
/**
* 归属小组
* @return string[]
* @author zgj
* @date 2023/5/31
*/
public static function belongGroup()
{
return [
1 => 'KA组',
2 => 'A组',
3 => 'B组',
4 => 'C组',
5 => 'D组',
6 => 'E组',
7 => 'F组',
8 => 'G组',
9 => 'H组',
10 => 'GA组',
11=> 'GB组',
12 => 'GC组',
13 => '前端组',
14 => '后端组',
15 => '黑格组',
16 => '售后组',
0 => '其他',
];
}
/**
* 学历
* @return string[]
* @author zgj
* @date 2023/5/31
*/
public static function education()
{
return [
1 => '专科',
2 => '本科',
3 => '研究生及以上',
0 => '其他',
];
}
/**
* 入职岗位
* @return string[]
* @author zgj
* @date 2023/5/31
*/
public static function entryPosition()
{
return [
1 => '优化师',
2 => '优化师助理',
3 => '优化顾问',
4 => '项目经理',
5 => '平面设计',
6 => '技术经理',
7 => '技术主管',
8 => '技术总监',
9 => '渠道经理',
10 => '前端研发',
11=> '后端研发',
12 => '行政财务',
13 => '品牌营销',
14 => '销售经理',
15 => '销售主管',
16 => '售后技术',
17 => '售后服务',
18 => '外贸销售',
19 => '渠道助理',
20 => '黑格运营',
21 => '运营',
22 => '短视频剪辑师',
23 => '人事',
24 => '采购',
0 => '其他',
];
}
/**
* 级别序列
* @return string[]
* @author zgj
* @date 2023/5/31
*/
public static function pLevel()
{
return [
0 => '实习期/试用期(P0)',
1 => '初级(P1)',
2 => '初级(P2)',
3 => '初级(P3)',
4 => '中级(P4)',
5 => '中级(P5)',
6 => '中级(P6)',
7 => '高级(P7)',
8 => '高级(P8)',
9 => '高级(P9)',
10 => '高级(P10)',
11=> '职务初级(M1)',
12 => '职务初级(M2)',
13 => '职务初级(M3)',
14 => '职务中级(M4)',
15 => '职务中级(M5)',
16 => '职务中级(M6)',
17 => '职务高级(M7)',
18 => '职务高级(M8)',
19 => '职务高级(M9)',
20 => '职务高级(M10)',
];
}
/**
* 是否党员
* @return string[]
* @author zgj
* @date 2023/5/31
*/
public static function dangyuan()
{
return [
0 => '群众',
1 => '预备党员',
2 => '正式党员',
];
}
/**
* 是否有党支部
* @return string[]
* @author zgj
* @date 2023/5/31
*/
public static function dangzhibu()
{
return [
0 => '无',
1 => '是',
2 => '否',
];
}
/**
* @return \Illuminate\Database\Eloquent\Relations\HasOne
*/
public function dept()
{
return $this->hasOne(Dept::class, 'id', 'dept_id');
}
public function position()
{
return $this->hasOne(EntryPosition::class, 'id', 'entry_position');
}
public function getDeptNameAttribute()
{
return $this->dept->name;
}
/**
* @remark :获取用户名称
* @name :getName
* @author :lyh
* @method :post
* @time :2023/8/18 14:41
*/
public function getName($id){
$name = '未分配';
if(!empty($id)){
$name = Cache::get('manager_hr_'.$id);
if(empty($name)){
$info = $this->read(['id'=>$id],['id','name']);
if($info !== false){
$name = $info['name'];
Cache::put('manager_hr_'.$id,$name,24 * 3600);
}
}
}
return $name;
}
/**
* @remark :根据当前用户登录的id获取当前用户的组长
* @name :accordIdGetLeader
* @author :lyh
* @method :post
* @time :2025/7/22 9:42
* @param :id->当前用户的人事id
*/
public function accordIdGetLeader($id = 0){
if(empty($id)){
return 0;
}
//查看当前用户是否为组长
$info = $this->read(['id'=>$id],['belong_group','is_leader','dept_id']);
if($info === false){
return 0;
}
//不是组长:根据小组获取组长
if($info['is_leader'] != self::IS_LEADER){
$id = $this->getValue(['belong_group'=>$info['belong_group'],'is_leader'=> self::IS_LEADER]);
if(empty($id)){
//未获取到时,根据当前大组去随机获取一个组长
$id = $this->getValue(['dept_id'=>$info['dept_id'],'is_leader'=> self::IS_LEADER]);
}
}
return $id;
}
}