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
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
<?php
 
class msg_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);
        
    }
    /**
     * 获取求职咨询列表
     * $whereData     查询条件
     * $data         自定义处理数组
     */
     
    public function getList($whereData,$data=array()){
        
        $ListNew    =    array();
        
        $List        =    $this -> select_all('msg',$whereData);
 
        $rows        =    $this -> select_all('down_resume',array('comid'=>$whereData['job_uid']),'`uid`');
        
        $uids = array();
        foreach ($rows as $v) {
            $uids[] = $v['uid'];
        }
 
        if(!empty( $List )){
            
            if(is_array($List)&&$List){
                
                $uid =   array();
                
                foreach($List as $v){
                    
                    $uid[]    =    $v['uid'];
                }
                $resume  =  $this -> select_all('resume_expect',array('uid' => array('in', pylode(',' , $uid)),'defaults' => 1),'`id`,`uid`');
                
                $resumeList  =  $this -> select_all('resume',array('uid'=>array('in', pylode(',' , $uid))));
                foreach($resumeList as $key=>$val){
                    if(empty($val['name'])){
                        $euids[]    =    $val['uid'];
                    }
                }
                // 没有姓名的,显示用户名
                if (!empty($euids)){
                    $nameList  =  $this -> select_all('member',array('uid'=>array('in', pylode(',' , $euids))),'`uid`,`username`');
                    
                    foreach($resumeList as $key=>$val){
                        foreach($nameList as $k=>$v){
                            if($v['uid']==$val['uid']){
                                $resumeList[$key]['name']    =    $v['username'];
                            }
                        }
                    }
                }
                
                include_once('resume.model.php');
                $resumeM  =  new resume_model($this->db, $this->def);
                
                foreach($List as $key => $val){
                
                    foreach ($resume as $va){
                        
                        if($val['uid'] == $va['uid']){
                            
                            $List[$key]['eid']    =    $va['id'];
                            $List[$key]['wapexp_url'] = Url('wap',array('c'=>'resume','a'=>'show','id'=>$va['id']));
                        }
                    }
                    
                    foreach ($resumeList as $v){
                        if ($v['uid'] == $val['uid']){
                            // 已下载的,直接显示姓名
                            if(in_array($uid, $uids)){
                                
                                $List[$key]['username']  =   $v['name'];
                                
                            }else{
                                // 未下载的,对姓名进行处理
                                $nameArr = array('nametype' => $v['nametype'], 'name' => $v['name'], 'eid' => $v['def_job'], 'sex' => $v['sex']);
                                
                                $List[$key]['username']  =   $resumeM -> setUsernameShow($nameArr);
                            }
                        }
                    }
                    $List[$key]['wapcom_url'] = Url('wap',array('c'=>'company','a'=>'show','id'=>$val['job_uid']));
                    $List[$key]['content']        =    strip_tags(trim($val['content']));
                    $List[$key]['datetime_n']    =    date('Y-m-d H:i',$val['datetime']);
                      if($v['reply_time']>0){
                        $List[$key]['reply_time_n']    =    date('Y-m-d H:i',$val['reply_time']);
                      }
                }
            }
            $ListNew['list']    =    $List;
        }
        return    $ListNew;
    }
    /**
     * 获取单条求职咨询
     * $whereData     查询条件
     * $data         自定义处理数组
     */
    function getInfo($whereData,$data=array()){
        
        $field    =    empty($data['field']) ? '*' : $data['field'];
        
        if (!empty($whereData)) {
            
            $msg  =  $this -> select_once('msg',$whereData, $field);
            
            if($msg && is_array($msg)){
                
                $msg['content']         =   strip_tags($msg['content']);
                
                if (isset($msg['datetime'])){
                    $msg['datetime_n']        =    date('Y-m-d H:i',$msg['datetime']);
                }
                if (isset($msg['reply_time'])){
                    $msg['reply_time_n']    =    date('Y-m-d H:i',$msg['reply_time']);
                }
                return $msg;
            }
        }
    }
 
 
    public function statusMsg($id, $upData = array())
    {
 
        $ids    =   @explode(',', trim($id));
 
        $return =   array('msg' => '非法操作!', 'errcode' =>  8);
 
        if (!empty($id)) {
 
            $idstr      =   pylode(',', $ids);
 
            $upData     =   array(
 
                'status'     =>  intval($upData['status']),
                'statusbody'=>  trim($upData['statusbody']),
            );
            if($upData['status'] == 1){
                $upData['issys'] = 1;
            }
 
            $mbs   =   $this->getList(array('id' => array('in', $idstr)), array('field' => '`id`,`uid`,`job_uid`,`com_name`,`job_name`,`issys`'));
 
 
            $result     =   $this -> update_once('msg', $upData, array('id' => array('in', $idstr)));
 
            if ($result) {
 
                if($upData['status'] == 1 || $upData['status'] == 2){
 
                    $msg    =   array();
                    $commsg =    array();
                    $uids   =   array();
                    $job_uid=    array();
                    
 
                    foreach ($mbs["list"] as $v){
 
                        $uids[] =   $v['uid'];
                        if($v['issys']==0 && $upData['status'] == 1){
                            $job_uid[] = $v['job_uid'];
                        }
                        
                    }
 
                    foreach ($mbs["list"] as $k => $v){
 
                        $jobmsg = '';
 
                        if($v['job_name']){
                            $jobmsg = ',咨询职位:'.$v['job_name'];
                        }
                        if ($upData['status'] == 2) {
                            
                            $statusInfo         =   '您的企业咨询审核未通过,咨询企业:'.$v['com_name'].$jobmsg;
 
                            if ($upData['statusbody']) {
                                $statusInfo     .=  ',原因:'.$upData['statusbody'];
                            }
 
                            $msg[$v['uid']][]   =   $statusInfo;
 
                        }elseif ($upData['status'] == 1){
 
                            $msg[$v['uid']][]   =  '您的企业咨询审核通过,咨询企业:'.$v['com_name'].$jobmsg;
                        }
 
                        if($v['issys']==0 && $upData['status'] == 1){
                            $commsg[$v['job_uid']][]   =  '您有一个留言,请及时查看';
                        }
                    }
 
                    //发送系统通知
                    require_once 'sysmsg.model.php';
                    $sysmsgM    =   new sysmsg_model($this->db, $this->def);
                    $sysmsgM -> addInfo(array('uid' => $uids,'usertype'=>1,'content'=>$msg));
                    if(!empty($job_uid)){
                        $sysmsgM -> addInfo(array('uid' =>$job_uid,'usertype'=>2,  'content' =>$commsg));
                    }
                    
                }
                
                $return['msg']      =   '求职咨询审核成功!';
                    
                $return['errcode']  =  9;
                
            }else{
 
                $return['msg']      =  '审核咨询(ID:'.$idstr.')设置失败';
                $return['errcode']  =  8;
            }
 
        }else {
 
            $return['msg']          =   '请选择需要审核的咨询!';
            $return['errcode']      =   8;
        }
 
        return $return;
    }
    /**
     * 添加求职咨询
     * $data         自定义数组
     * 应用中使用到的添加求职咨询
     */
    public function addMsg($data = array(),$code=''){
        $res                =   array();
        $res['errorcode']   =   8;
        $res['msg']         =   '';
 
        if(empty($data)){
            $res['msg']         =   '参数错误,请重试!';
            return $res;
        }
        if(empty($data['uid']) || empty($data['username'])){
            $res['msg']        =    '请先登录!';
            return    $res;
        }
        if($data['usertype'] != 1){
            $res['msg']        =    '只有个人用户才可以留言!';
            return    $res;
        }
 
        //参数判断
        if(empty($data['content'])){
            $res['msg']            =    '留言内容不能为空!';
            return    $res;
        }
        if($code == ''){
            if(empty($data['authcode'])){
                $res['msg']            =    '验证码不能为空!';
                return    $res;
            }
            session_start();
            if(md5(strtolower($data['authcode'])) != $_SESSION['authcode'] || empty($_SESSION['authcode'])){
                $res['msg']            =    '验证码错误!';
                return    $res;
            }
        }
        
        $sql  =  array(
            'uid'       =>  $data['uid'],
            'datetime'  =>  time(),
            'content'   =>  $data['content'],
            'type'      =>  1,
            'status'    =>    isset($data['status'])?$data['status']:$this->config['user_msg_status']
        );
        if($sql['status']=='1'){
            $sql['issys'] = 1;
        }else{
            $sql['issys'] = 0;
        }
        
        if (!empty($data['jobid'])){
            
            $job  =  $this->select_once('company_job', array('id'=>$data['jobid']),'`id`,`uid`,`name`,`com_name`');
            
            $sql['jobid']     =  $job['id'];
            $sql['job_uid']   =  $job['uid'];
            $sql['com_name']  =  $job['com_name'];
            $sql['job_name']  =  $job['name'];
            
        }else if (!empty($data['job_uid'])){
            
            $com  =  $this->select_once('company', array('uid'=>$data['job_uid']),'`uid`,`name`');
            
            $sql['job_uid']   =  $com['uid'];
            $sql['com_name']  =  $com['name'];
        }
        
        //判断是否在黑名单
        include_once ('black.model.php');
        $blackM                    =   new black_model($this->db, $this->def);
        $black                    =    $blackM -> getBlackNum(array(
            'p_uid'                =>    $sql['uid'],
            'c_uid'                =>    $sql['job_uid']
        ));
        if(!empty($black)){
            $res['msg']            =    '该企业暂不接受相关咨询!';
            return    $res;            
        }
        
        $resume                    =    $this->select_once("resume",array('uid'=>$sql['uid']),"`name`");
        
        if(!empty($resume)){
            
            $sql['username']   =   $resume['name'];
            
        }
        
        $id                        =    $this -> addInfo($sql);
 
        if(!empty($id)){
 
            if($sql['status']=='1'){
                include_once ('sysmsg.model.php');
                $sysmsgM            =   new sysmsg_model($this->db, $this->def);
                $sysmsgM -> addInfo(array('uid' => $sql['job_uid'],'usertype'=>2,  'content' => '您有一个留言,请及时查看'));
            }
 
            $res['msg']            =    '留言成功,请等待回复!';
            $res['errorcode']   =   9;
            return    $res;    
        }else{
            $res['msg']            =    '留言失败!';
            return    $res;    
        }
 
    }
 
    /**
     * 添加求职咨询
     * $data         自定义数组
     */
    public function addInfo($data=array()){    
        
        return $this -> insert_into('msg', $data);        
    
    }
    /**
     * 删除求职咨询
     * $whereData     查询条件
     * $data         自定义处理数组
     */
    public function delInfo($id,$data=array()){
        
        $limit                =  'limit 1';
        
        $return['layertype']  =     0;
        
        if (!empty($id)){
            
            if(is_array($id)){
                
                $id  =  pylode(',', $id);
               
                $return['layertype']  =  1;
                
                $limit                =  '';
            }
            if($data['uid']){
                $delWhere = array('uid'=>$data['uid'],'id'=>array('in',$id));
            }else{
                $delWhere = array('id'=>array('in',$id));
            }
             
            $nid      =  $this->delete_all('msg',$delWhere,$limit);
            
            if ($nid){
                
                $this -> addMemberLog($data['uid'],$data['usertype'],'删除求职咨询',18,3);
               
                $return['msg']      =  '求职咨询(ID:'.$id.')删除成功';
                
                $return['errcode']  =  '9';
          
            }else{
               
                $return['msg']      =  '求职咨询(ID:'.$id.')删除成功';
                
                $return['errcode']  =  '8';
            
            }
        
        }else{
            
            $return['msg']      =  '请选择您要删除的求职咨询';
           
            $return['errcode']  =  '8';
        
        }
       
        return $return;
    
    }
    
    /**
     * 修改求职咨询回复
    */
    public function eidtMsg($id,$data=array()){
        if(!empty($id)){
            $data['status'] = 1;
            $nid = $this -> update_once('msg',$data,array('id'=>$id));
            if($nid){
                $return['msg'] = '修改成功!';
                $return['errcode'] = 9;
            }else{
                $return['msg'] = '修改失败!';
                $return['errcode'] = 8;
            }
        }else{
            $return['msg'] = '请选择要修改的数据';
            $return['errcode'] = 8;
        }
        return $return;
    }
    
    /**
     * 删除求职咨询
    */
    public function upInfo($whereData, $data = array()){
        
        if(!empty($whereData)) {
            if($data['usertype']=='1'){
                //个人会员提醒出来,未读状态改成已读状态
                $nid  =  $this -> update_once('msg', array('user_remind_status'=>$data['user_remind_status']),$whereData);
            }else{
                $PostData    =    array(
                    
                    'del_status'    =>    '1',
                
                );
                
                $nid  =  $this -> update_once('msg', $PostData, array('id'=>$whereData['id'],'job_uid'=>$whereData['job_uid']));
            }
        }
        
        return $nid;
    
    }
    
    /**
     * 回复状态
    */
    public function upReplyInfo($whereData, $data = array()){
        
        if(!empty($whereData)) {
            
            $PostData    =    array(
                
                'reply'                    =>$data['reply'],
                
                'reply_time'            =>$data['reply_time'],
                
                'user_remind_status'    =>$data['user_remind_status'],
            
            );
            
            $nid  =  $this -> update_once('msg', $PostData, array('id'=>$whereData['id'],'job_uid'=>$whereData['job_uid']));
        
        }
        
        return $nid;
    
    }
    
    public function delMsg($id, $data = array()){
        
        if(!empty($id)){
            
            if(is_array($id)){
                
                $ids    =    $id;
                
                $return['layertype']    =    1;
                
            }else{
                
                $ids    =   @explode(',', $id);
                
                $return['layertype']    =    0;
                
            }
            
            $id                    =   pylode(',', $ids);
 
            $return['id']        =    $this -> delete_all('msg',array('id' => array('in',$id),'job_uid'=>$data['job_uid']),'');
            
            $return['msg']        =    '求职咨询';
            
            $return['errcode']    =    $return['id'] ? '9' :'8';
           
            $return['msg']        =    $return['id'] ? $return['msg'].'删除成功!' : $return['msg'].'删除失败!';
       
        }else{
            
            $return['msg']        =    '请选择您要删除的数据!';
            
            $return['errcode']    =    8;
        
        }
        
        return    $return;
    }
    /**
     * @desc    获取职位咨询数目
     */
    function getMsgNum($WhereData = array()){
        
        $Msgnum    =    $this->select_num('msg', $WhereData);
        
        return $Msgnum;
    }
    
}
?>