chengkun
2025-05-26 4462855c0033970c39ac8d0da704b7dc41eabbfe
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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
<?php
 
class lookresume_model extends model{
    /**
     * @desc   引用log类,添加用户日志
     */
    private function addMemberLog($uid,$usertype,$content,$opera='',$type='') {
        require_once ('log.model.php');
        $LogM = new log_model($this->db, $this->def);
        return  $LogM -> addMemberLog($uid,$usertype,$content,$opera='',$type='');
    }
    //获取简历信息列表resume
    private function getResumeList($whereData, $data = array()){
 
        require_once ('resume.model.php');
 
        $resumeM    =   new resume_model($this->db, $this->def);
 
        return  $resumeM   ->  getResumeList($whereData , $data);
    }
    /**
     * 获取浏览简历列表
     * $whereData     查询条件
     * $data         自定义处理数组 utype:admin后台;  uid; usertype
     */
 
    public function getList($whereData,$data=array()){
        $ListNew    =    array();
        
        $List        =    $this -> select_all('look_resume',$whereData);
 
        if(!empty( $List )){
 
            $List  =  $this -> getDataList($List,$data);
 
            $ListNew['list']    =    $List;
 
        }
 
        return    $ListNew;
    }
    /**
     * 获取浏览简历详情
     * $whereData     查询条件
     * $data         自定义处理数组
     */
    public function getInfo($whereData,$data=array()){
        $data['field']        =    empty($data['field']) ? '*' : $data['field'];
        $resumeInfo            =   $this -> select_once('look_resume', $whereData, $data['field']);
        return $resumeInfo;
    }
 
 
    /**
     * 修改浏览简历详情
     * $whereData     查询条件
     * $data         自定义处理数组
     */
    function upInfo($where = array(),$upData = array()){
 
        $nid    =   $this -> update_once('look_resume', $upData, $where);
 
        return $nid;
    }
 
    /**
     * @desc     新增浏览简历记录
     * @param    array $data
     * @return   $return
     */
    function addInfo($data = array()){
        return $this->insert_into('look_resume', $data);
    }
 
    /**
     * 删除浏览简历
     * $whereData     查询条件
     * $data         自定义处理数组
     */
    public function delInfo($where){
 
        $limit                =  'limit 1';
        $return['layertype']  =     0;
 
        if (!empty($where['id'])){
 
            $id  =  $where['id'];
            if(is_array($id)){
 
                $id  =  pylode(',', $id);
                $return['layertype']  =  1;
                $limit                =  '';
            }else{
                $return['layertype']  =  0;
            }
            if($where['usertype']==1){
                // 个人操作
                $nid  =  $this -> update_once("look_resume",array('status'=>1),array('uid'=>$where['uid'],'id'=>array('in',$id)));
            }elseif($where['usertype']==2 || $where['usertype']==3){
                // 企业、猎头操作
                $nid  =  $this -> update_once("look_resume",array('com_status'=>1),array('com_id'=>$where['uid'],'id'=>array('in',$id)));
            }else{
                // 管理员操作
                $nid  =  $this -> delete_all('look_resume',array('id'=>array('in',$id)),$limit);
            }
            if ($nid){
                if (!empty($where['usertype']) && !empty($where['uid'])){
 
                    $this->addMemberLog($where['uid'], $where['usertype'], '删除浏览过的简历',26,3);
                }
                $return['msg']      =  '简历浏览记录(ID:'.$id.')删除成功';
                $return['errcode']  =  '9';
 
            }else{
                $return['msg']      =  '简历浏览记录(ID:'.$id.')删除失败';
                $return['errcode']  =  '8';
 
            }
        }elseif($where['where']){
 
            $newwhere    =    $where['where'];
 
            if($where['norecycle'] == '1'){    //    数据库清理,不插入回收站
 
                $nid  =  $this -> delete_all('look_resume', $newwhere, '', '', '1');
            }else{
 
                $nid  =  $this -> delete_all('look_resume', $newwhere, '');
            }
 
            return $nid;
        }else{
 
            $return['msg']      =  '请选择您要删除的简历浏览';
            $return['errcode']  =  '8';
        }
        return $return;
    }
 
    /**
     * @desc 简历浏览列表处理数据
     */
    private function getDataList($List = array(), $data = array()){
 
        $uid       =   isset($data['uid']) ? intval($data['uid']) : 0;
        $usertype  =   isset($data['usertype']) ? intval($data['usertype']) : 0;
 
        foreach($List as $v){
            $eid[]     =   $v['resume_id'];
 
            if($v['usertype']==3){
 
                $ltid[]  =   $v['com_id'];
            }else{
 
                $comid[] =   $v['com_id'];
 
            }
        }
        include_once('resume.model.php');
        $resumeM  =  new resume_model($this->db, $this->def);
        // 查询个人简历
        $reWhere['id']     =   array('in', pylode(',', $eid));
        $reData['utype']   =   'user';
        $reData['field']   =   '`id`,`uid`,`name`,`job_classid`,`minsalary`,`maxsalary`,`height_status`,`exp`,`city_classid`,`hy`,`lastupdate`,`edu`,`birthday`,`sex`,`uname`,`photo`';
        $expect               =   $resumeM -> getList($reWhere, $reData);
        if (!empty($expect['list']) && is_array($expect['list'])) {
            foreach ($expect['list'] as $ev) {
                $userid[$ev['uid']]    =   $ev['uid']; // 个人UID
            }
        }
 
        if ($usertype == 1 || $data['utype'] == 'admin') {
            
            $com    =    $this -> select_all('company',array('uid'=>array('in',pylode(',', $comid))),'`uid`,`name`,`pr`,`mun`,`sdate`,`linkman`,`linkjob`,`hy`,`logo_status`,`logo`, `provinceid`, `cityid`, `three_cityid`');
            $comJob    =   $this -> select_all('company_job',array('uid'=>array('in',pylode(',',$comid)), 'state' => '1', 'r_status' => '1', 'status' => '0'),'`uid`,`name`');
 
            $lt     =    $this -> select_all('lt_info',array('uid'=>array('in',pylode(',', $ltid))),'`uid`,`realname`,`title`,`exp`,`rz_time`,`photo_big`,`photo_status`');
            $ltJob    =   $this -> select_all('lt_job',array('uid'=>array('in',pylode(',', $ltid)), 'status' => '1', 'r_status' => '1', 'zp_status' => '0'),'`uid`,`job_name`');
            
            include_once ('cache.model.php');
            $cacheM   =      new cache_model($this->db, $this->def);
            $cache    =      $cacheM -> GetCache(array('lt','com','city'));
        }
        $downArr = array();
        if ($usertype == 2) {
 
            $userid_msg   =      $this -> select_all('userid_msg',array('fid' => $uid,'isdel'=>9,'uid'=>array('in',pylode(",",$userid))),'`uid`');
            $userid_job   =   $this -> select_all('userid_job',array('com_id' => $uid,'isdel'=>9,'uid'=>array('in',pylode(',',$userid))),'`uid`,`is_browse`');
            
            $downList      =   $this -> select_all('down_resume', array('comid' => $data['uid'], 'uid'=>array('in',pylode(',', $userid))), '`uid`,`eid`');
            foreach ($downList as $val){
                $downArr[] = $v['uid'];
            }
        }
 
        foreach($List as $k=>$v){
 
            $List[$k]['datetime_n']  =  timeForYear($v['datetime']);
            $List[$k]['wapurl']      =  Url('wap', array('c'=>'resume','a'=>'show','id'=>$v['resume_id']));
            
            if (!empty($com)){
                foreach($com as $val){
                    
                    if($v['com_id'] == $val['uid']){
                        
                        $List[$k]['com_name']    =    $val['name'];
                        $List[$k]['linkman']    =    $val['linkman'];
                        $List[$k]['linkjob']    =    $val['linkjob'];
                        $List[$k]['hy']            =    $val['hy'];
                        $List[$k]['pr_n']        =    $cache['comclass_name'][$val['pr']];
                        $List[$k]['mun_n']        =    $cache['comclass_name'][$val['mun']];
                        $sdate                    =    explode('-',$val['sdate']);
                        $List[$k]['sdate']        =    $sdate[0];
                        if(empty($val['logo']) || $val['logo_status']==1){
                            
                            $List[$k]['logo_n'] =  checkpic($this->config['sy_unit_icon']);
                        }else{
                            $List[$k]['logo_n']    =  checkpic($val['logo']);
                        }
                        
                        if ($val['three_cityid']){
                            
                            $List[$k]['city_n'] =   $cache['city_name'][$val['three_cityid']];
                        }elseif ($val['cityid']){
                            
                            $List[$k]['city_n'] =   $cache['city_name'][$val['cityid']];
                        }elseif ($val['provinceid']){
                            
                            $List[$k]['city_n'] =   $cache['city_name'][$val['provinceid']];
                        }
                        $List[$k]['wapcom_url'] = Url('wap',array('c'=>'company','a'=>'show','id'=>$v['com_id']));
                    }
                }
            }
            if (!empty($comJob)){
                $num=0;
                if($comJob) {
                    foreach($comJob as $cv){
                        
                        if($v['com_id'] == $cv['uid']){
                            if(!$List[$k]['com_job']){
                                $List[$k]['com_job']    =    $cv['name'];
                            }else{
                                $List[$k]['com_job']    =    $List[$k]['com_job'].','.$cv['name'];
                            }
                            $num += 1;
                        }
                    }
                    $List[$k]['com_job_num'] = $num;
                }
            }
            if (!empty($lt)){
                foreach($lt as $val){
                    
                    if($v['com_id'] == $val['uid']){
                        
                        $List[$k]['com_name']    =    $val['realname'];
                        $List[$k]['title_n']    =    $cache['ltclass_name'][$val['title']];
                        $List[$k]['lt_exp']        =    $cache['ltclass_name'][$val['exp']];
                        $List[$k]['time']        =    $val['rz_time']?date('Y',$val['rz_time']):'';
                        
                        if (!empty($val['photo_big'])  && $val['photo_status']==0){
                            $List[$k]['logo_n']    =    checkpic($val['photo_big'] , $this->config['sy_lt_icon']);
                        }else{
                            $List[$k]['logo_n']    =    checkpic($this->config['sy_lt_icon']);
                        }
                    }
                }
            }
            if (!empty($ltJob)){
                if($ltJob) {
                    foreach($ltJob as $lv){
                        if($v['com_id'] == $lv['uid']){
                            if(!$List[$k]['com_job']){
                                $List[$k]['com_job']    =    $lv['job_name'];
                            }else{
                                $List[$k]['com_job']    =    $List[$k]['com_job'].','.$lv['job_name'];
                            }
                        }
                    }
                }
            }
            foreach($expect['list'] as $val){
 
                if( $v['resume_id'] == $val['id']){
                    $List[$k]['age']            =    $val['age_n'];
                    $List[$k]['exp']            =    $val['exp_n'];
                    $List[$k]['edu']            =    $val['edu_n'];
                    $List[$k]['sex']            =    $val['sex_n'];
                    $List[$k]['salary']            =    $val['salary'];
                    $List[$k]['photo']          =   $val['photo_n'];
                    if ($val['job_classid'] != "") {
                        $List[$k]['jobname']    = $val['job_classname'];
                    }
                    $List[$k]['resume_name']    =  $val['name'];
                    
                    if ($data['utype'] == 'admin'){
                        // 后台直接展示姓名
                        $List[$k]['username']  =  $val['uname'];
                    }else{
                        if (in_array($v['uid'], $downArr)){
                            $List[$k]['username']  =  $val['uname'];
                        }else{
                            $nameArr               =  array('nametype'=>$this->config['user_name'], 'name' => $val['uname'], 'eid' => $val['id'], 'sex' => $val['sex']);
                            $List[$k]['username']  =  $resumeM -> setUsernameShow($nameArr);
                        }
                    }
                }
            }
 
            if($usertype == 3){
                foreach($expect['list'] as $val){
 
                    if( $v['resume_id'] == $val['id']){
 
                        $List[$k]['height_status']    =    $val['height_status'];
                        $List[$k]['hy']                =    $val['hy_n'];
                        if ($val['city_classid'] != "") {
                            $List[$k]['cityname']   =   $val['city_classname'];
                        }
                        $List[$k]['lastupdate']        =  $val['lastupdate'];
                    }
                }
            }
 
            if ($usertype == 2) {
 
                foreach($userid_msg as $val){
                    if($v['uid']==$val['uid']){
                        $List[$k]['userid_msg']        =    1;
                    }
                }
                foreach($userid_job as $val){
 
                    if($v['uid']==$val['uid']){
                        $List[$k]['is_browse']        =    $val['is_browse'];
                    }
                }
            }
        }
 
        return $List;
    }
    //  浏览简历数目
    function getLookNum($Where = array()){
 
        return $this->select_num('look_resume', $Where);
 
    }
 
 
    /**
     * 应用浏览简历
     * $data
     * uid => 浏览人uid
     * 返回参数暂时没做特殊处理
     */
    public function browseResume($data = array()){
        if(empty($data['eid'])){
            return false;
        }
        if(!in_array($data['usertype'], array(2, 3))){
            return false;
        }
 
        //简历浏览记录
        $look_resume                    =    $this -> getInfo(array('com_id' => $data['uid'], 'resume_id' => $data['eid'], 'usertype' => $data['usertype']));
 
        if(!empty($look_resume)){
 
            $this -> upInfo(array('resume_id' => $data['eid'], 'com_id' => $data['uid']), array('datetime' => time()));
 
        }else{
            // 企业、猎头基本信息没有完善的,不记录浏览记录
            if ($data['usertype'] == 2){
                
                $row  =  $this->select_once('company',array('uid'=>$data['uid']),'`name`');
                
            }elseif ($data['usertype'] == 3){
                
                $row  =  $this->select_once('lt_info',array('uid'=>$data['uid']),'`realname` AS `name`');
                
            }
 
            if (empty($row['name'])){
                return false;
            }
            $lookData                    =    array();
            $lookData['uid']            =    $data['euid'];
            $lookData['resume_id']        =    $data['eid'];
            $lookData['com_id']            =    $data['uid'];
            $lookData['did']            =    $data['did'];
            $lookData['usertype']        =    $data['usertype'];
            $lookData['datetime']        =    time();
            $this -> addInfo($lookData);
 
            require_once ('history.model.php');
            $historyM                    =    new history_model($this->db, $this->def);
            $historyM -> addHistory('lookresume', $data['eid']);
 
            if($data['usertype'] == 2){
                //增加系统记录
                $company                    =    $this -> select_once('company', array('uid' => $data['uid']), '`name`');
                require_once ('sysmsg.model.php');
                $sysmsgM                    =    new sysmsg_model($this->db, $this->def);
                $sysmsgM -> addInfo(array('uid' => $data['euid'],'usertype'=>1,'content' => '企业 <a href="comtpl,'.$data['uid'].'">'.$company['name'].'</a> 查看了您的简历'));
            }
        }
        
        require_once ('job.model.php');
        $JobM = new job_model($this->db, $this->def);
        
        //登录的企业,查看简历,设置为已查看
        $userIdWhere                    =    array(
            'com_id'                    =>    $data['uid'],
            'eid'                        =>    $data['eid'],
            // 'is_browse'                    =>    1
        );
 
        $uijInfo = $JobM->getSqJobInfo($userIdWhere, ['field' => 'is_browse']);
        if($uijInfo && $uijInfo['is_browse'] == 1){ // 存在记录并且是未查看才标记为已查看
            $JobM -> updSqJob($userIdWhere, array('is_browse' => 2));
        }
        
        return true;
    }
}
?>