chengkun
2025-05-23 a6f7b382623096b6a00924f418447cf5204e825e
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
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
<?php
 
class once_model extends model{
    private function getClass($options){
        if (!empty($options)){
            include_once('cache.model.php');
            $cacheM            =   new cache_model($this->db,$this->def);
            $cache             =   $cacheM -> GetCache($options);
            return $cache;
        }
    }
    /**
      * 查询全部信息
      * @param 表:once_job
      * @param 功能说明:获取once_job表里面所有店铺信息
      * @param 引用字段:$whereData:条件  2:$data:查询字段
      *
     */
    public function getOnceList($whereData,$data=array()){
      $OnceNew    =   array();
      $field      =   $data['field'] ? $data['field'] : '*';
      $List   =   $this   ->  select_all('once_job',$whereData,$field);
      $cache   =   $this -> getClass(array('city'));
        if(!empty($List) && $List){
            foreach($List  as $k=>$v){
                $List[$k]['ctime_n']      =      date("Y-m-d",$v['ctime']);
                $List[$k]['linkman']      =      mb_substr($v['linkman'], 0,5,'utf-8');
                if($v['edate']  <  time()){
                    $List[$k]['status']   =   2;
                }
                if($v['provinceid']){
                    $List[$k]['city_n']    =      $cache['city_name'][$v['provinceid']];
                }
                if($v['cityid']){
                    $List[$k]['city_n'].=      '-'.$cache['city_name'][$v['cityid']];
                }
                if($v['three_cityid']){
                    $List[$k]['city_n'].=      '-'.$cache['city_name'][$v['three_cityid']];
                }
                //图片显示
                $List[$k]['pic_n']  = checkpic($v['pic'],$this->config['sy_once_icon']);
            }
        }
        return $List;
    }
    /**
      * 查询单条信息
      * @param 查询表:once_job
      * @param 功能说明:根据条$id 获取once_job表里面 单条信息
      * @param 引用字段:$id :条件 2:$data:查询字段
      *
     */
    public function getOnceInfo($where,$data=array())
    {
        $select     =   $data['field'] ? $data['field'] : '*'; 
        $Info    =   $this -> select_once('once_job', $where, $select);
 
        if($Info && is_array($Info)){
            $cache  =  $this -> getClass(array('city'));
            
            if (!empty($Info['pic'])){
                $Info['pic_n']  =  checkpic($Info['pic'],$this->config['sy_once_icon']);
            }
            if($Info['require']){
                $Info['require_n']     =     str_replace("\r\n","<br>",$Info['require']);
                $Info['require_n']     =     str_replace("\n","<br>",$Info['require_n']);
            }
            if($Info['ctime']){
                $Info['ctime_n']    =    date("Y-m-d",$Info['ctime']);
            }
            if($Info['edate']){
                //有效期天数
                if($Info['edate']>time()){
                    $Info['day_n']  =   ceil(($Info['edate']-time())/86400);
                }
                $Info['edate_n']    =    date("Y-m-d",$Info['edate']);
            }
         
            if($Info['provinceid']){
                $Info['city_n']    =      $cache['city_name'][$Info['provinceid']];
            }
            if($Info['cityid']){
                $Info['city_n'].=      '-'.$cache['city_name'][$Info['cityid']];
            }
            if($Info['three_cityid']){
                $Info['city_n'].=      '-'.$cache['city_name'][$Info['three_cityid']];
            }
        }
        return $Info;
    }
    
    /**
     * @desc    查询店铺招聘数目
     * @param array $where
     * @return boolean|string|void
     */
    public function getOnceNum($where = array()) {
        
        return $this -> select_num('once_job', $where);
        
    }
    
      /**
      * 删除信息
      * @param  表:once_job
      * @param 功能说明:根据条件$id 删除once_job表里面信息
      * @param 引用字段:$id :条件 2:$data:字段
      *
     */
    
    public function delOnce($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('once_job',array('id' => array('in',$id)),'');
            
            if($return['id']){
 
                $return['msg']      =  '店铺招聘(ID:'.$id.')删除成功';
                $return['errcode']  =  '9';
            }else{
                
                $return['msg']      =  '店铺招聘(ID:'.$id.')删除失败';
                $return['errcode']  =  '8';
            }
        }else{
            
            $return['msg']          =  '系统繁忙';
            $return['errcode']      =  '8';
            $return['layertype']    =    0;
        }
 
        return $return;
  }
  
    /**
      * 审核信息
      * @param  表:once_job
      * @param 功能说明:根据条件$id 审核once_job表里面信息
      * @param 引用字段:$id :条件 2:$data['status']:审核状态
      *
     */
    public  function setOnceStatus($id,$data = array()){
        
        if(!empty($id)){
 
            $where['id']    =   array('in',pylode(',',$id));
            $updata          = array(
                'status' =>  $data['status']==2?1:$data['status'],
            );
            if($data['status']==2){
                $this -> update_once('company_order',array('order_state'=>2),array('once_id'=>array('in',pylode(",",$id)),'order_state'=>1));
                $this -> update_once('once_job',array('pay'=>'2'),array('id'=>array('in',pylode(",",$id)),'pay'=>1));
            }
            $wfpay    =    $this->select_all('once_job',array('id'=>array('in',pylode(",",$id)),'pay'=>'1'));
            if($wfpay){
                $return['status']    =    3;   
            }else{
                $nid    =    $this -> update_once('once_job',$updata,$where);
                if($nid){
                    $return['status']    =    $data['status']==2?1:$data['status']; 
                }
            }
            if($nid){
                include_once('log.model.php');
                $logM        =    new log_model($this->db, $this->def);
                $logM->addAdminLog('店铺(ID:'.$id.')审核成功');
            }
            return $return;
        }
    }
    /**
      * 更新信息
      * @param  表:once_job
      *
     */
    public function upOnce($upData = array(),$whereData = array()){
    
        return $this -> update_once('once_job',$upData,$whereData);
    }
   /**
      * 添加、更新信息
      * @param  表:once_job
      * @param 功能说明:根据条件$id 修改once_job表里面信息
      * @param 引用字段:$id :条件 2:$data:引用字段名称
      * @param  $data['password'] :密码是否修改
      *
     */
  
    public function addOnceInfo($data = array(),$type=''){
 
        $post    =    $data['post'];
        $id        =    intval($data['id']);
        include_once ('cache.model.php');
        
        $cacheM     =   new cache_model($this->db, $this->def);
        
        $cache      =   $cacheM -> GetCache('city');
        $citymsg     =     false;
        if(!empty($cache['city_type'])){
            if($post['cityid']==''){
                $citymsg = true;
            }
        }else{
            if($post['provinceid']==''){
                $citymsg = true;
            }
        }
        if($post['title']==''){
            return array('msg'=>'请填写职位名称!','errcode'=>8);
        }
        if ($post['title'] && mb_strlen($post['title'],'utf8')>30){
            return array('msg'=>'我想招聘标题最多30个字!','errcode'=>8);
        }
        if($post['salary']==''){
            return array('msg'=>'请填写工资!','errcode'=>8);
        }
        if($post['edate']==''){
            return array('msg'=>'请填写有效期!','errcode'=>8);
        }
        if($citymsg){
            return array('msg'=>'请选择工作地区!','errcode'=>8);
        }
        if($post['address']==''){
            return array('msg'=>'请选择工作地点!','errcode'=>8);
        }
        if($post['require']==''){
            return array('msg'=>'请填写招聘要求!','errcode'=>8);
        }
        if($post['companyname']==''){
            return array('msg'=>'请填写店铺名称!','errcode'=>8);
        }
        if($post['phone']==''){
            return array('msg'=>'请填写联系电话!','errcode'=>8);
        }
        if($post['linkman']==''){
            return array('msg'=>'请填写联系人!','errcode'=>8);
        }
        include_once ('notice.model.php');
        $noticeM        =        new notice_model($this->db, $this->def);
        //短信验证
        if ($this->config['sy_msg_isopen']==1) {
 
            if (isset($data['moblie_code']) && !empty($data['moblie_code'])) {
                $companywhere['check'] = $post['phone'];
                $companywhere['type'] = 2;
                $companywhere['orderby'] = array('ctime,desc');
                include_once('company.model.php');
                $CompanyM = new company_model($this->db, $this->def);
                $cert_arr = $CompanyM->getCertInfo($companywhere);
                if (is_array($cert_arr)) {
                    $checkTime = $noticeM->checkTime($cert_arr['ctime']);
                    if ($checkTime) {
                        $res = $data['moblie_code'] == $cert_arr['check2'] ? true : false;
                        if ($res == false) {
                            return array('msg' => '短信验证码错误!', 'errcode' => '8');
                        }
                    } else {
                        return array('msg' => '验证码验证超时,请重新点击发送验证码!', 'errcode' => '8');
                    }
                } else {
                    return array('msg' => '验证码发送不成功,请重新点击发送短信验证码!', 'errcode' => '8');
                }
            }
        }else{
            if($type!='admin' && $type!='wxapp'){
                if ($this->config['code_kind'] ==1) {
                    $result = $noticeM->jycheck($_POST['authcode'], '店铺招聘');
 
                    if (!empty($result)) {
                        return array('msg' => $result['msg'], 'errcode' => 8);
                    }
                }
            }
        }
        if($post['password']){
            $post['password']    =    md5($post['password']);
        }else{
            unset($post['password']);
        }
 
        if($post['file']['tmp_name'] || $post['base']){
            
            $upArr    =  array(
                'file'      =>  $post['file'],
                'dir'       =>  'once',
                'base'      =>  $post['base'],
                'preview'   =>  $post['preview']
            );
            
            $result  =  $this -> upload($upArr);
        
            if (!empty($result['msg'])){
 
                $return['msg']        =    $result['msg'];
                $return['errcode']    =    8;
                return $return;
                
            }elseif (!empty($result['picurl'])){
 
                $pictures     =      $result['picurl'];
 
            }
 
        }
 
        unset($post['file']);
        unset($post['base']);
        unset($post['preview']);
        if(isset($pictures)){
 
            $post['pic']    =    $pictures;
 
        }
        
        if(!empty($id)){
            if($type!='admin'){
                
                $arr            =    $this->getOnceInfo(array('id'=>$id,'password'=>$post['password']));
                
                if(empty($arr)){
                    if($data['utype']=='wap'){
                        $return['url']    =    Url('wap',array('c'=>'once','a'=>'show','id'=>$id));
                    }
                    $return['msg']        =    '密码不正确';
                    $return['errcode']    =    8;
                    return $return;
                }
            }
            $nid    =   $this ->  update_once('once_job',$post,array('id'=>$id));
            
            if($nid){
                if($this->config['com_fast_status']=="0" && $type !='admin'){
                    require_once('admin.model.php');
                    $adminM = new admin_model($this->db,$this->def);
                    $adminM->sendAdminMsg(array('first'=>'有新的店铺招聘《'.$post['title'].'》需要审核','type'=>17));
                    $msg="修改成功,等待审核!";
                }else{
                    $msg="修改成功!";
                }
                if($data['utype']=='wap'){
                    $return['url']=Url('wap',array('c'=>'once'));
                }else{
                    $return['url']=Url('once');
                }
                $return['msg']        =    $msg;
                $return['errcode']    =    9;
            }else{
                $return['msg']        =    '修改失败!';
                $return['errcode']    =    8;
            }
        }else{
            if($this->config['once_pay_price'] != "0" && $this->config['once_pay_price'] != "" && $type != 'admin'){
                $post['pay']        =   '1';
            }else{
                $post['pay']        =   '2';
            }
            $s_time        =    strtotime(date('Y-m-d 00:00:00')); //今天开始时间
            $m_once        =    $this->getOnceNum(array('login_ip' => fun_ip_get(),'ctime'=>array('>',$s_time)));
            $totalMessNum = $this->getOnceNum(array('ctime'=>array('>',$s_time)));//当天总的已发布量
            if($this->config['sy_once_totalnum'] == 0 || ($this->config['sy_once_totalnum'] > $totalMessNum)) {
                if ($this->config['sy_once'] > $m_once || $this->config['sy_once'] < 1) {
                    $nid = $this->insert_into('once_job', $post);
                    $return['id'] = $nid;
                    if ($nid) {
 
                        $oldorder = $this->select_once("company_order", array('order_state' => 1, 'type' => 25, 'fast' => $data['fast']));
 
                        if (is_array($oldorder)) {
 
                            $this->delete_all('once_job', array('id' => $oldorder['once_id'], 'status' => 0, 'pay' => 1));
                            $this->delete_all('company_order', array('order_state' => 1, 'type' => 25, 'fast' => $data['fast']));
                        }
 
                        if ($this->config['once_pay_price'] != "0" && $this->config['once_pay_price'] != "" && $type != 'admin') {
                            $return['msg'] = '发布信息添加完成,请付款';
                            $return['errcode'] = 10;
 
                            if ($data['utype'] == 'wap') {
                                $return['url'] = Url('wap', array('c' => 'once', 'a' => 'pay', 'id' => $nid, 'price' => $this->config['once_pay_price'] * $post['edate1']));
                            } else {//pc
 
                                $return['url'] = $nid;
                            }
                        } else {
                            if ($this->config['com_fast_status'] == "0" && $type != 'admin') {
                                require_once('admin.model.php');
                                $adminM = new admin_model($this->db, $this->def);
                                $adminM->sendAdminMsg(array('first' =>'有新的店铺招聘《'.$post['title'].'》需要审核', 'type' => 17));
                                $msg = "发布成功,等待审核!";
 
                            } else {
                                $msg = "发布成功!";
                            }
                            if ($data['utype'] == 'wap') {
                                $return['url'] = Url('wap', array('c' => 'once'));
                            } else {
                                $return['url'] = Url('once');
                            }
                            $return['msg'] = $msg;
                            $return['errcode'] = 9;
                        }
                    } else {
                        $return['msg'] = '发布失败!';
                        $return['errcode'] = 8;
                    }
                } else {
                    $return['msg'] = '一天内只能发布' . $this->config['sy_once'] . '次!';
                    $return['errcode'] = 8;
                    if ($data['utype'] == 'wap') {
                        $return['url'] = Url('wap', array('c' => 'once'));
                    }
                }
            }else{
                $return['msg'] = '网站发布店铺招聘本日已到上限,如有急需,请联系网站客服!';
                $return['errcode'] = 8;
            }
        }
        
        return $return;
    }
     /**
   * 处理单个图片上传
   * @param file/需上传文件; dir/上传目录; type/上传图片类型; base/需上传base64; preview/pc预览即上传
   */
    private function upload($data = array('file'=>null,'dir'=>null,'type'=>null,'base'=>null,'preview'=>null)){
      
        include_once('upload.model.php');
      
        $UploadM  =  new upload_model($this->db, $this->def);
      
        $upArr  =  array(
            'file'     =>  $data['file'],
            'dir'      =>  $data['dir'],
            'type'     =>  $data['type'],
            'base'     =>  $data['base'],
            'preview'  =>  $data['preview']
        );
        $return  =  $UploadM -> newUpload($upArr);
      
        return $return;
    }
   /**
      * 批量延迟店铺时间
      * @param  表:once_job
      * @param 功能说明:根据条件$id
      * @param 引用字段:$id :条件 2:$data['edate']:延迟时间
      *
     */
    public  function setOnceCtime($id,$data = array()){
        
        $ids        =    @explode(',',$id);
        
        if(is_array($ids)){
            
            $posttime       =   $data['endtime'] * 86400;
            
            $where['id']    =   array('in',pylode(',',$ids));
            $rows           =   $this  ->  getOnceList($where,array('field'=>'`id`,`edate`'));
            
            foreach($rows as $value){
                
                if($value['edate'] < time()){
                    
                    $time            =    time()+$posttime;
                }else{
                    $time            =    $value['edate']+$posttime;
                }
                
                $return['id']        =    $this -> update_once("once_job",array('edate'=>$time),array('id'=>$value['id']));
            }
            if($return['id']){
                $return['msg']        =    '店铺招聘延期(ID:'.implode(',', $id).')设置成功!';
                $return['errcode']    =    9;
            }else{
                $return['msg']        =    '店铺招聘延期(ID:'.implode(',', $id).')设置失败!';
                $return['errcode']    =    8;
            }
        }else{
            $return['msg']            =    '请选择要延期的店铺招聘!';
            $return['errcode']        =    8;
        }
        return $return;
    }
    //发布店铺招聘付款
    public function payOnce($data=array('from'=>'')){
        
        $id    =    intval($data['id']);
        if(!empty($id)){
            
            $ordernum     =     $this -> select_num('company_order',array('once_id'=>$id,'order_state'=>1));
            if($ordernum){
                $this -> delete_all('company_order',array('once_id'=>$id),'');
            }
            $row    =    $this->getOnceInfo(array('id'=>$id,'pay'=>1));
            if(is_array($row)){
                
                //生成相关订单
                $dingdan  =  time().rand(10000,99999);
                $fast     =  time().rand(10000,99999);
                
                $orderData=array(
                    'type'            =>    25,
                    'order_id'        =>    $dingdan,
                    'order_price'    =>    $data['once_price'],
                    'order_time'    =>    time(),
                    'order_type'    =>    $data['pay_type'],
                    'order_state'    =>    1,
                    'order_remark'    =>    '店铺招聘收费',
                    'did'            =>    $data['did'],
                    'once_id'        =>    $id,
                    'fast'            =>    $fast
                );
                $nid    =    $this -> insert_into("company_order",$orderData);
                
                if($nid && $dingdan){
                    if($data['from']  !=  'wxapp'){
                        include_once('cookie.model.php');
                        $cookieM     =   new cookie_model($this->db, $this->def);
                        $cookieM->SetCookie("fast",$fast,time() + 86400);
                    }
                    //订单生成成功
                    return array('error'=>0,'oid'=>$nid,'orderid'=>$dingdan,'id'=>$id,'fast'=>$fast);
                }else{
                    //生成失败 返回具体原因
                    return array('error'=>1,'msg'=>"下单失败");
                }
            }else{
                return array('error'=>1,'msg'=>"店铺数据不存在");
            }
        }
    }
    //管理信息:刷新、修改、删除
    public function setOncePassword($data = array()){
        session_start();
        
        if (!empty($data['code'])){
            if(md5(strtolower($data['code'])) != $_SESSION['authcode'] || empty($_SESSION['authcode'])){//验证码错误
                unset($_SESSION['authcode']);
                return array('msg'=>'验证码错误!','errcode'=>8,'type'=>1);
            }
        }
        
        $jobinfo    =    $this->getOnceInfo(array('id'=>(int)$data['id'],'password'=>md5($data['password'])));
        
        if(!is_array($jobinfo) || empty($jobinfo)){
            return array('msg'=>'密码错误!','errcode'=>8,'type'=>2);
        }else{
            $_SESSION['oncepass'] = md5($data['password']);
        }
        if($data['type']==1){//刷新
            if($this->config['com_xin']>$jobinfo['sxnumber']){
                
                $this->upOnce(array('ctime'=>time(),'sxtime'=>time(),'sxnumber'=>$jobinfo['sxnumber']+1),array('id'=>(int)$jobinfo['id']));
                
                return array('msg'=>'刷新成功','errcode'=>9,'type'=>3);
            }else{
                return array('msg'=>'对不起你已达到一天最多刷新次数!','errcode'=>8,'type'=>5);
            }
            
        }elseif($data['type']==3){//删除
            
            $this -> delOnce((int)$jobinfo['id']);
            return array('msg'=>'删除成功!','errcode'=>9,'type'=>4);
            
        }else{//修改
            if($data['utype']=='pc'){
                $url    =    Url('once',array('c'=>'add','id'=>(int)$jobinfo['id']));
                return array('url'=>$url);
            }elseif($data['utype']=='wap'){
                $url    =    Url('wap',array('c'=>'once','a'=>'add','id'=>(int)$jobinfo['id']));
                return array('url'=>$url);
            }else{
                return array('msg'=>'密码正确!','errcode'=>9,'type'=>2);
            }
            
        }
    }
}
?>