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
<?php
 
class integral_model extends model{    
 
    /**
     * 会员积分/金额操作
     * @param string $uid              操作UID
     * @param string $integral         积分数量
     * @param string $auto             true 加  false 减
     * @param string $name             用途
     * @param string $pay              是否入库
     * @param number $pay_state        是否已支付
     * @param string $type             integral 积分操作  packpay 金额退回  yhq 优惠券
     * @param string $pay_type         支付类型
     * 1-支付佣金; 2-购买积分; 4-购买广告位; 9-报名专题招聘; 12-购买增值包; 14-使用优惠券和积分抵扣; 15-购买简历模板; 20-上传头像; 21-身份认证; 22-会员登录;
     *  23-注册/邀请注册; 24-积分兑换; 25-首次填写基本资料; 27-积分抵扣; 37-购买子账号; 66-取消订单返还积分; 100-悬赏赏金
     * @param string $eid              下载简历id
     * @param string $coupon_id        使用优惠券id
     */
    function company_invtal($uid, $usertype, $integral, $auto=true, $name='', $pay=true, $pay_state=2, $type='integral', $pay_type='',$eid = null, $coupon_id = null){
        
        if( $pay && $integral!='0'){
            
            $integral = abs($integral);
        
            $member=$this->select_once('member',array('uid'=>$uid),'`did`');
            
            if($usertype=='1'){
                
                $table='member_statis';
            }elseif($usertype=='2'){
                
                $table='company_statis';
            }elseif($usertype=='3'){
                
                $table='lt_statis';
            }elseif($usertype=='4'){
                
                $table='px_train_statis';
            }
            
            if($type != 'yhq'){  //  优惠券记录,不进行 statis 表数据修改
                
                if($auto){
                    
                    $nid        =    $this    ->    update_once($table,array($type=>array('+',$integral)),array('uid'=>$uid));
                }else{
                    
                    $nid        =    $this     ->    update_once($table,array($type=>array('-',$integral)),array('uid'=>$uid));
                    
                    $integral    =   '-'.$integral;
                }
            }
            
            $dingdan             =   time().rand(10000,99999);
            
            $data                =   array();
            
            $data['order_id']    =   $dingdan;
            $data['did']         =   $member['did'];
            $data['com_id']      =   $uid;
            $data['usertype']    =   $usertype;
            $data['pay_remark']  =   $name;
            $data['pay_state']   =   $pay_state;
            $data['pay_time']    =   time();
            $data['order_price'] =   $integral;
            $data['pay_type']    =   $pay_type;
            $data['eid']         =   $eid;
            $data['coupon_id']   =   $coupon_id;
            
            if($type=='integral'){
            
                $data['type']=1;
                
            }else if($type=='yhq'){
                
                $data['type']=3;
            }else{
                
                $data['type']=2;
            }
            
            $this->insert_into('company_pay',$data);
            
            return $nid;
        }else{
            return true;
        }
    }
    /**
     * 统一判断加积分还是减积分整合函数
     */
    function invtalCheck($uid,$usertype, $type, $msg, $pay_type = '')
    {
 
        $return    =    $this    ->    checkOnceIntegral($uid, $type, $msg);
        
        if($return){
            if($this->config[$type.'_type'] == '1'){
 
                $auto  =  true;
 
            }else{
 
                $auto  =  false;
 
            }
 
            $this -> company_invtal($uid,$usertype, $this->config[$type], $auto, $msg, true, 2, 'integral', $pay_type);
        }
    }
    /**
     * 判断是否是一个账号只能获取一次的积分
     */
    private function checkOnceIntegral($uid, $type, $msg)
    {
        $onceitg    =    array(
            'integral_reg',//注册
            'integral_userinfo',//完善基本资料
            'integral_emailcert',//邮箱认证
            'integral_mobliecert',//手机认证
            'integral_avatar',//上传头像
            'integral_add_resume',//个人-发布简历
            'integral_identity',//个人-上传身份验证
            'integral_map',//企业-设置地图
            'integral_banner',//企业-上传企业横幅
            'integral_comcert',//企业-认证企业资质
            'integral_ltcert',//猎头-认证执照
            'integral_px_banner',//培训-上传横幅
        );
 
        if(in_array($type,$onceitg)){
            $compay    =    $this    ->    getInfo(array('com_id'=>$uid,'pay_remark'=>$msg));
            if(!empty($compay)){
                return false;
            }else{
                return true;
            }
        }else{
            return true;
        }
    }
    function insert_company_pay($integral, $pay_state, $uid,$usertype, $msg, $type, $pay_type = '', $ptype = false){
 
        if($integral!='0'){
            
            $pay  =   array();
 
            if($ptype){
 
                $pay['order_price'] =   $integral;
 
            }else{
 
                $pay['order_price'] =   '-'.$integral;
 
            }
 
            $pay['order_id']     =   time().rand(10000,99999);
            $pay['pay_time']     =   time();
            $pay['pay_state']    =   $pay_state;
            $pay['com_id']       =   $uid;
            $pay['usertype']     =   $usertype;
            $pay['pay_remark']   =   $msg;
            $pay['type']         =   $type;
            $pay['pay_type']     =   $pay_type;
            $pay['did']          =   $this->config['did'];
 
            return $this->insert_into('company_pay',$pay);
 
        }else{
 
            return false;
        }
    }
    /**
    *积分任务页面的积分状态
    *$data 必传参数 type 类型(com:商家)
    *                uid 
    *                uidtype 
    */
    function integralMission($data=array()){
 
        $baseInfo            = false;    //基本资料是否已填写,企业名、行业等等
        $logo                = false;    //logo是否上传
        $photo                = false;    //是否上传头像
        $signin                = false;    //是否签到
        $emailChecked        = false;    //email是否验证
        $phoneChecked        = false;    //手机号是否验证
        $pay_remark         = false;
        $question            = false;    //发布问题
        $answer               = false;    //回答问题
        $answerpl           = false;    //评论回答
        $identification     = false;    //身份认证
        $map                = false;    //企业地图
        $banner                = false;    //企业横幅
        $yyzz                = false;    //企业资质
        if($data['type']=='com'){
            $row    =    $this    ->    select_once("company",array('uid'=>$data['uid']),'name,hy,logo,email_status,moblie_status,x,y,firmpic,yyzz_status');
            $ban    =    $this    ->    select_once("banner",array('uid'=>$data['uid']),'pic');
            $row['firmpic']=$ban['pic'];
            if(is_array($row) && !empty($row)){
                if($row['name'] != '' && $row['hy'] != '' ){
                    $baseInfo = true;
                }
                if($row['logo'] != ''){ 
                    $logo = true;
                }
                if($row['email_status'] != 0){
                    $emailChecked = true;
                }
                if($row['moblie_status'] != 0){
                    $phoneChecked = true;
                }
                if($row['x'] != 0 && $row['y'] != 0){
                    $map = true;
                }
                if($row['firmpic'] != ''){
                    $banner = true;
                }
                if($row['yyzz_status'] != 0){
                    $yyzz = true;
                }
            }
        }
        if($data['type']=='lietou'){
            $row        =    $this->select_once('lt_info',array('uid'=>$data['uid']),'`realname`,`com_name`,`photo_big`,`email_status`,`moblie_status`,`yyzz_status`');
            if(is_array($row) && !empty($row)){
                if($row['realname'] != '' && $row['com_name'] != '' ){
                    $baseInfo         =    true;
                }
                
                if($row['photo_big'] != ''){
                    $photo             =    true;
                }    
                
                if($row['email_status'] != 0){
                    $emailChecked     =    true;
                }
                    
                if($row['moblie_status'] != 0){
                    $phoneChecked     =    true;
                }                
                    
                if($row['yyzz_status'] != 0){
                    $yyzz             =    true;
                }
            }
        }
        if($data['type']=='train'){
            $row    =    $this->select_once('px_train',array('uid'=>$data['uid']),'name,sid,logo,email_status,moblie_status');
            $ban    =    $this->select_once('px_banner',array('uid'=>$data['uid']),'pic');
            $row['firmpic']=$ban['pic'];
            if(is_array($row) && !empty($row)){
                if($row['name'] != '' && $row['sid'] != '' ){
                    $baseInfo        =    true;
                }
                if($row['logo'] != ''){
                    $logo            =    true;
                } 
                if($row['email_status'] != 0){
                    $emailChecked    =    true;
                } 
                if($row['moblie_status'] != 0){
                    $phoneChecked    =    true;
                }
                if($row['firmpic'] != ''){
                    $banner         =    true;
                }
            }
        }
        if($data['type']=='member'){
            $row        =    $this->select_once('resume',array('uid'=>$data['uid']),'`name`,`sex`,`birthday`,`telphone`,`email`,`edu`,`exp`,`living`,`photo`,`defphoto`,`email_status`,`moblie_status`,`idcard_status`');
            if(is_array($row) && !empty($row)){
                if($row['name'] != '' && $row['sex'] != '' && $row['birthday'] != '' && $row['telphone'] != '' && $row['edu'] != '' && $row['exp'] != '' && $row['living'] != ''){
                    $baseInfo         =    true;
                }
                
                if($row['photo'] != '' && $row['defphoto']==1){
                    $photo             =    true;
                }    
                
                if($row['email_status'] != 0){
                    $emailChecked     =    true;
                }
                    
                if($row['moblie_status'] != 0){
                    $phoneChecked     =    true;
                }                
                    
                if($row['idcard_status'] != 0){
                    $identification =    true;
                }
            }
        }
        
        $date    =    date("Ymd");
        $reg    =    $this    ->    select_once("member_reg",array('uid'=>$data['uid'],'usertype'=>$data['usertype'],'date'=>$date));
        if($reg['id']){
            $signin = true;
        }
 
        $question    =    $this->max_time('发布问题',$data['uid'],$data['usertype']);
        $answer        =    $this->max_time('回答问题',$data['uid'],$data['usertype']);
        $answerpl    =    $this->max_time('评论问答',$data['uid'],$data['usertype']); 
 
        $statusList = array(
            'baseInfo'        =>     $baseInfo,
            'logo'            =>     $logo,
            'signin'        =>     $signin,
            'emailChecked'    =>     $emailChecked,
            'phoneChecked'    =>     $phoneChecked,
            'question'        =>     $question,
            'answer'        =>     $answer,
            'answerpl'        =>     $answerpl,
            'photo'            =>    $photo,            
            'pay_remark'    =>    $pay_remark,
            'identification'=>    $identification,    //身份证    
            'map'            =>     $map,                //企业地图
            'banner'        =>    $banner,            //企业横幅
            'yyzz'            =>    $yyzz                //企业资质
        );
            
        return $statusList;
    }
 
    function max_time($remark,$uid,$usertype){
       //查询当天是否有相关类型积分记录
        $stime    =    strtotime(date('Ymd'));
        $etime    =    strtotime(date('Ymd'))+ 86400;
        // $where    =    array(
            // 'com_id'        =>    $uid,
            // 'pay_remark'    =>    trim($remark),
            // 'pay_time'        =>    array('between',array($stime,$etime)),
        // );
        $where['com_id']                =    $uid;
        $where['usertype']                =    $usertype;
        $where['pay_remark']            =    $remark;
        $where['PHPYUNBTWSTART_A']      =   '';
        $where['pay_time'][]            =   array('>', $stime, 'AND');
        $where['pay_time'][]            =   array('<', $etime,'AND');    
        $where['PHPYUNBTWEND_A']        =   '';
        $num    =    $this -> select_num("company_pay",$where);
        if($num>0){
            return false;
        }else{
            return true;
        }
    }
    /**
     * @desc 查询company_pay记录
     */
    function getInfo($where = array(), $data = array()) {
        
        $field     =    empty($data['field']) ? '*' : $data['field'];
       
        $info      =    $this -> select_once('company_pay',$where, $field);
       
        return $info;
    }
    /**
     * @desc 修改admin_integralclass记录
     */
    function upIntClass($where = array(), $data = array()) {
        
        if(!empty($where)){
            
            $nid      =        $this -> update_once('admin_integralclass',$data, $where);
        
        }
        return $nid;
    }
    
    /**
     * @desc 查询admin_integralclass记录
     */
    function getIntClass($where = array(), $data = array()) {
        
        if(!empty($where)){
            
            $field         =        empty($data['field']) ? '*' : $data['field'];
            
            $List          =        $this -> select_all('admin_integralclass',$where, $field);
        
        }
        return $List;
    }
    
    /**
     * @desc 添加admin_integralclass记录
     */
    function addIntClass($data = array()) {
        
        if(!empty($data)){
            
            $nid          =        $this -> insert_into('admin_integralclass',$data);
        
        }
        return $nid;
    }
    
    /**
     * @desc  删除admin_integralclass记录
     */
    function delIntClass($ids){
        
        if(!empty($ids)){
             
            $result    =    $this    ->    delete_all('admin_integralclass',array('id' => array('in', pylode(',', $ids))), '');
        }
        return    $result;
    }
    
    
    function getList($whereData=array(), $data = array()){
        
        if(!empty($whereData)){
            
            $field         =        empty($data['field']) ? '*' : $data['field'];
            
            $List          =        $this -> select_all('company_pay',$whereData, $field);
        
        }
        return $List;
        
    }
    
    
}
?>