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
<?php
 
class admin_sync_controller extends adminCommon{
    function index_action(){
        //查询可同步有效用户数据
        $resumeM        =    $this -> MODEL('resume');
        $resumeCount    =    $resumeM -> getExpectNum(array('defaults'=>1,'status'=>1,'r_status'=>1));
        $jobM            =    $this -> MODEL('job');
        $jobCount        =    $jobM -> getJobNum(array('state'=>1,'r_status'=>1,'status'=>0));
        $this->yunset("resCount",$resumeCount);
        $this->yunset("jobCount",$jobCount);
        $this->yunset('syncsign',time().rand(1000,9999));
        $this->yuntpl(array('admin/admin_sync'));
    }
    function save_action(){
         if($_POST['config']){
            unset($_POST['config']);
            
            $this -> MODEL('config') -> setConfig($_POST);
            
            $this->web_config();
            
            $this->ACT_layer_msg("数据同步设置修改成功!",9,1,2,1);
        }
    }
    
    //用户同步传输
    function resume_action(){
        if (!$this->config['yptuser'] && !$this->config['yptkey']){
            $this->layer_msg('请先设置云平台同步账号信息',8);
        }
        if($_POST['count'] && $_POST['limit']){
            $page = ceil($_POST['count']/$_POST['limit']);
            if(!$_POST['page']){
                $_POST['page'] = 0;
            }
            //$_POST['limit'] = 1;
            $pageSize    =    intval($_POST['page'])*intval($_POST['limit']);
            //查询符合条件的数据
            $resumeM    =    $this -> MODEL('resume');
            $expectAll    =    $resumeM -> getSimpleList(array('defaults'=>1,'status'=>1,'r_status'=>1,'limit'=>array($pageSize,$_POST['limit']),'orderby'=>'id,desc'));
            //清除用户UID
            if(is_array($expectAll)){
                foreach($expectAll as $key=>$value){
                    $uid[]    = $value['uid'];
                    $exceptList[$value['uid']] = $value;
                    $expectid[] = $value['id'];
                    
                }
                $uids = array_unique($uid);
                //查询关联企业信息
                $rwhere['uid']    =    array('in',pylode(',',$uids));
                
                $resumeList        =    $resumeM->getResumeList($rwhere);
                
                $where['eid']    =    array('in',pylode(',',$expectid));
                
                //查询关联工作经历
                $workList        =    $resumeM -> getResumeWorks($where);
                //教育经历
                $eduList        =    $resumeM -> getResumeEdus($where);
                //培训经历
                $trainList        =    $resumeM -> getResumeTrains($where);
                //职业技能
                $skillList        =    $resumeM -> getResumeSkills($where);
                //项目经历
                $projectList    =    $resumeM -> getResumeProjects($where);
                //其他
                $otherList        =    $resumeM -> getResumeOthers($where);
            }
            
            if(is_array($resumeList)){
                include PLUS_PATH."/job.cache.php";
                include PLUS_PATH."/user.cache.php";
                include PLUS_PATH."/city.cache.php";
                
                $cacheM=$this->MODEL('cache');
                $cacheList=$cacheM->GetCache('user');
 
                foreach($resumeList as $key=>$value){
                    $jsonvalue = array();
                    $jsonvalue['uid']             =    $value['uid'];//原始UID
                    $jsonvalue['uname']            =    $value['name'];//用户姓名
                    $jsonvalue['address']        =    $value['address'];//现居住地址
                    $jsonvalue['birthday']        =    $value['birthday'];//生日
                    $jsonvalue['height']        =    $value['height'];//身高
                    $jsonvalue['weight']        =    $value['weight'];//体重
                    $jsonvalue['idcard']        =    $value['idcard'];//身份证
                    $jsonvalue['nationality']    =    $value['nationality'];//民族
                    $jsonvalue['description']    =    $value['description'];//个人简介
                    $jsonvalue['living']        =    $value['living'];//现居住地
                    $jsonvalue['domicile']        =    $value['domicile'];//户籍地址
                    $jsonvalue['telphone']        =    $value['telphone'];//联系电话
                    $jsonvalue['telhome']        =    $value['telhome'];//家庭电话
                    $jsonvalue['email']            =    $value['email'];//联系邮件
                    $jsonvalue['homepage']        =    $value['homepage'];//个人主页
                    $jsonvalue['sex']            =    $cacheList['user_sex'][$value['sex']];//性别
                    $jsonvalue['marriage']        =    $userclass_name[$value['marriage']];//婚姻
                    $jsonvalue['edu']            =    $userclass_name[$value['edu']];//学历
                    $jsonvalue['exp']            =    $userclass_name[$value['exp']];//工作经验
                    
                    /****************************求职意向*******************************/
                    $exceptValue                =    $exceptList[$value['uid']];
                    $resumevalue                =    array();
                    $resumevalue['id']            =    $exceptValue['id'];
                    $resumevalue['name']        =    $exceptValue['name'];//简历名称
                    if($exceptValue['job_classid']){
                        $jobclassid_name=array();
                        foreach(@explode(',',$exceptValue['job_classid']) as $k=>$v){
                            $jobclassid_name[]    =    $job_name[$v];
                        }
                        $resumevalue['job_classid'] = @implode(',',$classid_name);
                    }
                    if($exceptValue['city_classid']){
                        $cityclassid_name=array();
                        foreach(@explode(',',$exceptValue['city_classid']) as $k=>$v){
                            $cityclassid_name[]    =    $city_name[$v];
                        }
                        $resumevalue['city_classid'] = @implode(',',$cityclassid_name);
                    }
                    if ($exceptValue['minsalary']>0 || $exceptValue['maxsalary']>0){
                        $resumevalue['salary']    =    $exceptValue['minsalary'].'-'.$exceptValue['maxsalary'];//薪资待遇
                    }
                    $resumevalue['jobstatus']    =    $userclass_name[$exceptValue['jobstatus']];//求职状态
                    $resumevalue['type']        =    $userclass_name[$exceptValue['type']];//工作性质
                    $resumevalue['exp']            =    $userclass_name[$exceptValue['exp']];//工作经验
                    $resumevalue['edu']            =    $userclass_name[$exceptValue['edu']];//最高学历
                    $resumevalue['report']        =    $userclass_name[$exceptValue['report']];//到岗时间
                    $resumevalue['lastupdate']    =    $exceptValue['lastupdate'];//更新日期
                    $jsonvalue['expect']        =    $resumevalue;
                    
                    
                    /*************************************工作经历**************************************/
                    $jsonvalue['worklist']        =    $workList[$exceptValue['id']];
                    $jsonvalue['edulist']        =    $eduList[$exceptValue['id']];
                    $jsonvalue['projectlist']    =    $projectList[$exceptValue['id']];
                    $jsonvalue['otherlist']        =    $otherList[$exceptValue['id']];
                    $jsonvalue['trainlist']        =    $trainList[$exceptValue['id']];
                    
                    $Arr[] = $jsonvalue;
                }
                //转化JSON
                $Crmjson['syncjson']    =    $Arr;
                $Crmjson['yptuser']        =    $this->config['yptuser'];
                $Crmjson['yptkey']        =    $this->config['yptkey'];
                $Crmjson['syncsign']    =    $_POST['syncsign'];
                //CURL POST 数据
                $url         =    'http://api.ypt.com/sync/?c=resume';//接收地址
                
                $return        =    CurlPost($url,json_encode($Crmjson));
                
                $response    =    json_decode($return);
                
                if($response->state == '1'){
                    if($response->uids){
                        $ewhere['id']    =    array('in',$response->uids);
                        $resumeM -> upInfo($ewhere,array('eData'=>array('sync'=>'1')));
                        $nowcount         =    count(explode(',',$response->uids));
                    }
                    
                    if(($_POST['page']+1)>=$page){//转换结束
                        echo json_encode(array('error'=>'2'));
                    }else{
                        //当前批次结束 继续下一批次转换
                        echo json_encode(array('error'=>'1','readynum'=>$response->readynum,'page'=>($_POST['page']+1),'count'=>($_POST['page']+1)*$_POST['limit']));
                    }
                    die;
                }else{
                    echo json_encode(array('error'=>'0','msg'=>$response->errmsg));
                }
            }
        }else{
            echo json_encode(array('error'=>'0'));
        }
    }
    function job_action(){
        set_time_limit(0);
        if($_POST['count'] && $_POST['limit']){
            $page = ceil($_POST['count']/$_POST['limit']);
            if(!$_POST['page']){
                
                $_POST['page'] = 0;
            }
            //$_POST['limit'] = 10;
            $pageSize    =    intval($_POST['page'])*intval($_POST['limit']);
            //查询符合条件的数据
            $jobM        =    $this -> MODEL('job');
            $joblist    =    $jobM -> getList(array('state'=>1,'r_status'=>1,'status'=>0,'limit'=>array($pageSize,$_POST['limit']),'orderby'=>'id,desc'));
            $jobAll=$joblist['list'];
            //清除企业UID
            if(is_array($jobAll)){
                foreach($jobAll as $key=>$value){
                    $uid[] = $value['uid'];
                    $jobList[$value['uid']][] = $value;
                }
                $uids = array_unique($uid);
                //查询关联企业信息
                $comM            =    $this -> MODEL('company');
                $comwhere['uid']=    array('IN',pylode(',',$uids));
                $comList        =    $comM -> getList($comwhere);
                
            }
            if(is_array($comList)){
                include PLUS_PATH."/job.cache.php";
                include PLUS_PATH."/com.cache.php";
                include PLUS_PATH."/city.cache.php";
                include PLUS_PATH."/industry.cache.php";
                $cacheM=$this->MODEL('cache');
                $cacheList=$cacheM->GetCache('user');
                foreach($comList as $key=>$value){
                    $jsonvalue = array();
                    $jsonvalue['uid']            =    $value['uid'];//原始UID
                    $jsonvalue['name']            =    $value['name'];//企业名称
                    $jsonvalue['hy']            =    $industry_name[$value['hy']];//企业行业
                    $jsonvalue['comnum']        =    $comclass_name[$value['mun']];//企业规模
                    $jsonvalue['province']        =    $city_name[$value['provinceid']];//所在地区
                    $jsonvalue['city']            =    $city_name[$value['cityid']];//所在地区
                    $jsonvalue['three_city']    =    $city_name[$value['three_cityid']];//所在地区
                    $jsonvalue['address']        =    $value['address'];
                    $jsonvalue['website']        =    $value['website'];//企业网址
                    $jsonvalue['sdate']            =    $value['sdate'];//企业注册日期
                    $jsonvalue['linkman']        =    $value['linkman'];//联系人
                    $jsonvalue['content']        =    $value['content'];//联系人
                    $jsonvalue['x']                =    $value['x'];//企业地图标注
                    $jsonvalue['y']                =    $value['y'];//企业地图标注
                    $jsonvalue['bustops']        =    $value['bustops'];//公交路线
                    $jsonvalue['linktel']        =    $value['linktel'];//联系电话
                    $jsonvalue['linkphone']        =    $value['linkphone'];//固定电话
                    $jsonvalue['linkmail']        =    $value['linkmail'];//联系邮件
                    $jsonvalue['welfare']        =    $value['welfare'];//福利待遇
                    //企业职位
                    if(is_array($jobList[$value['uid']])){
                        foreach($jobList[$value['uid']] as $k=>$v){
                            $jobvalue                    =    array();
                            $jobvalue['id']                =    $v['id'];
                            $jobvalue['name']            =    $v['name'];//职位名称
                            
                            $jobvalue['job1']            =    $job_name[$v['job1']];
                            $jobvalue['job1_son']        =    $job_name[$v['job1_son']];
                            $jobvalue['job_post']        =    $job_name[$v['job_post']];
                            $jobvalue['province']        =    $city_name[$v['provinceid']];//所在地区
                            $jobvalue['cityid']            =    $city_name[$v['cityid']];//所在地区
                            $jobvalue['three_cityid']    =    $city_name[$v['three_cityid']];//所在地区
                            
                            $jobvalue['salary']            =    $v['minsalary'].'-'.$v['maxsalary'];//薪资待遇
                            $jobvalue['number']            =    $comclass_name[$v['number']];//类型
                            $jobvalue['exp']            =    $comclass_name[$v['exp']];//工作经验
                            $jobvalue['report']            =    $comclass_name[$v['report']];//到岗时间
                            $jobvalue['sex']            =    $cacheList['user_sex'][$v['sex']];//性别
                            $jobvalue['edu']            =    $comclass_name[$v['edu']];//学历
                            $jobvalue['marriage']        =    $comclass_name[$v['marriage']];//婚姻
                            $jobvalue['description']    =    $v['description'];//岗位要求
                            $jobvalue['sdate']            =    $v['sdate'];//发布日期
                            $jobvalue['lastupdate']        =    $v['lastupdate'];//发布日期
                            if($v['lang']){
                                $langList                =    array();
                                $lang                    =    @explode(',',$v['lang']);
                                foreach($lang as $lv){
                                    $langList[]            =    $comclass_name[$lv];
                                }
                                $jobvalue['lang']        =    @implode(',',$langList);//语言要求
                            }
                            $jsonvalue['joblist'][]        =    $jobvalue;
                        }
                    }
                    $Arr[] = $jsonvalue;
                }
                //转化JSON
                $Crmjson['syncjson']    =    $Arr;
                $Crmjson['yptuser']        =    $this->config['yptuser'];
                $Crmjson['yptkey']        =    $this->config['yptkey'];
                $Crmjson['syncsign']    =    $_POST['syncsign'];
                //CURL POST 数据
                $url        =    'http://api.ypt.com/sync/?c=job';//接收地址
                
                $return        =    CurlPost($url,json_encode($Crmjson));
                
                $response    =    json_decode($return);
                
                if($response->state == '1'){
                    if($response->uids){
                        $jobM -> upInfo(array('sync'=>'1'), array('uid' => array('in', $response->uids)));
                        $nowcount = count(explode(',',$response->uids));
                    }
                    
                    if(($_POST['page']+1)>=$page){//转换结束
                        echo json_encode(array('error'=>'2'));
                    }else{
                        //当前批次结束 继续下一批次转换
                        echo json_encode(array('error'=>'1','readynum'=>$response->readynum,'page'=>($_POST['page']+1),'count'=>($_POST['page']+1)*$_POST['limit']));
                    }
                    die;
                }else{
                    echo json_encode(array('error'=>'0','msg'=>$response->errmsg));
                }
            }
        }else{
            echo json_encode(array('error'=>'0'));
        }
    }
    function getList($table,$expectid){
        $List = $this->MODEL('resume')->getFbList($table,array('eid'=>array('in',pylode(',',$expectid))));
        if(is_array($List)){
            foreach($List as $key=>$value){
                if(is_array($value)){
                    foreach($value as $k=>$v){
                        $value[$k] = $v;
                    }
                }
                $newkList[$value['eid']][] = $value;
            }
        }
        return $newkList;
    }
}
 
?>