chengkun
2025-05-26 8f3df543230cd4403368b39b9bbe5726d11a0284
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
<?php
 
 
class map_controller extends common
{
 
    function index_action()
    {
        $this -> get_moblie();
        
        if ($_GET['x'] && $_GET['y']){
            
            $this->yunset(array('mapx'=>$_GET['x'],'mapy'=>$_GET['y']));
            
        }else{
            
            $user_agent = (!isset($_SERVER['HTTP_USER_AGENT'])) ? FALSE : $_SERVER['HTTP_USER_AGENT'];
            
            if (($_COOKIE['mapx'] && $_COOKIE['mapx']>0) && ($_COOKIE['mapy'] && $_COOKIE['mapy']>0) && strpos($user_agent, 'Android') && is_weixin()){
                
                $this->yunset(array('mapx'=>$_COOKIE['mapx'],'mapy'=>$_COOKIE['mapy']));
                
            }else{
                
                $this->yunset(array('mapx'=>0,'mapy'=>0));
            }
        }
        $this -> seo('map');
        $this -> yunset('headertitle', '附近职位');
        $this -> yuntpl(array('wap/map'));
    }
 
    function maplist_action()
    {
        $this -> get_moblie();
        
        if ($_GET['x'] && $_GET['y']){
            
            $this->yunset(array('mapx'=>$_GET['x'],'mapy'=>$_GET['y']));
            
        }else{
            $user_agent = (!isset($_SERVER['HTTP_USER_AGENT'])) ? FALSE : $_SERVER['HTTP_USER_AGENT'];
            
            if (($_COOKIE['mapx'] && $_COOKIE['mapx']>0) && ($_COOKIE['mapy'] && $_COOKIE['mapy']>0) && strpos($user_agent, 'Android') && is_weixin()){
                
                $this->yunset(array('mapx'=>$_COOKIE['mapx'],'mapy'=>$_COOKIE['mapy']));
            }else{
                
                $this->yunset(array('mapx'=>0,'mapy'=>0));
            }
        }
        $this -> seo('map');
        $this -> yunset('headertitle', '附近职位');
        $this -> yuntpl(array('wap/maplist'));
    }
 
    //职位列表
    function joblist_action()
    {
        $this->get_moblie();
 
        $jobM   =   $this->MODEL('job');
        $select =   "`id`,`uid`,`name`,`minsalary`,`maxsalary`,`lastupdate`,`provinceid`,`cityid`,`edu`,`exp`,`welfare`,`is_link`, 6371 * acos(cos(radians(" . $_POST['y'] . ")) * cos(radians(`y`)) * cos(radians(`x`) - radians(" . $_POST['x'] . ")) + sin(radians(" . $_POST['y'] . ")) * sin(radians(`y`))) AS `distance`";
        $page   =   $_POST['page'] ? $_POST['page'] : 1;
        $limit  =   $_POST['limit'] ? $_POST['limit'] : 10;
        $pagenav=   ($page - 1) * $limit;
        $limit  =   array($pagenav, $limit);
        $where  =   array('state' => 1, 'r_status' => 1, 'status' => 0, 'x' => array('>', 0), 'y' => array('>', 0), 'orderby' => 'distance, asc', 'limit' => $limit);
 
        if ($this->config['did'] > 0) {
 
            $where['did']               =   $this->config['did'];
        } else {
 
            $where['PHPYUNBTWSTART']    =   '';
            $where['did'][]             =   array('isnull');
            $where['did'][]             =   array('=', '0', 'OR');
            $where['PHPYUNBTWEND']      =   '';
        }
 
        $jobListA   =   $jobM->getList($where, array('field' => $select, 'link' => 'yes', 'from' => 'wap_map'));
 
        $rows       =   $jobListA['list'];
 
        if (!empty($rows)) {
 
            $uids   =   array();
 
            foreach ($rows as $v) {
 
                $uids[] =   $v['uid'];
            }
 
            $comM   =   $this->MODEL('company');
 
            $comListA   =   $comM->getList(array('uid' => array('in', pylode(',', $uids))), array('field' => '`uid`,`logo`,`logo_status`,`name`,`shortname`,`address`','logo'=>1));
 
            $list   =   array();
 
            foreach ($rows as $k => $v) {
 
                $list[$k]['id'] = $v['id'];
                $list[$k]['name'] = mb_substr($v['name'], 0, 16, 'utf-8');
                $list[$k]['salary_n'] = $v['job_salary'];
 
                $list[$k]['job_city_one'] = $v['job_city_one'];
                $list[$k]['job_city_two'] = $v['job_city_two'];
                $list[$k]['job_edu'] = $v['job_edu'];
                $list[$k]['job_exp'] = $v['job_exp'];
 
                if (!empty($v['address'])) {
                    $list[$k]['address'] = $v['address'];
                }
 
                if ($v['welfare_n']) {
                    $list[$k]['welfare'] = $v['welfare_n'];
                }
                if ($v['distance'] <= 1) {
                    $list[$k]['dis'] = ceil($v['distance'] * 1000) . 'm';
                } else {
                    $list[$k]['dis'] = round($v['distance'], 2) . 'km';
                }
 
                $list[$k]['joburl'] = Url('wap', array('c' => 'job', 'a' => 'comapply', 'id' => $v['id']));
                $list[$k]['comurl'] = Url('wap', array('c' => 'company', 'a' => 'show', 'id' => $v['uid']));
                $list[$k]['addressurl'] = Url('wap', array('c' => 'map', 'a' => 'jobmap', 'id' => $v['uid']));
 
                foreach ($comListA['list'] as $val) {
 
                    if ($val['uid'] == $v['uid']) {
 
                        if ($v['shortname']) {
 
                            $list[$k]['com_name'] = mb_substr($val['shortname'], 0, 16, 'utf-8');
                        } else {
 
                            $list[$k]['com_name'] = mb_substr($val['name'], 0, 16, 'utf-8');
                        }
                        if (empty($v['address'])) {
 
                            $list[$k]['address'] = $val['address'];
                        }
                        $list[$k]['logo'] = $val['logo'];
                    }
                }
            }
        }
 
        $numWhere   =   array('state' => 1, 'r_status' => 1, 'status' => 0, 'x' => array('>', 0), 'y' => array('>', 0));
 
        if ($this->config['did'] > 0) {
 
            $numWhere['did']    =   $this->config['did'];
        } else {
 
            $numWhere['PHPYUNBTWSTART'] =   '';
            $numWhere['did'][]          =   array('isnull');
            $numWhere['did'][]          =   array('=', '0', 'OR');
            $numWhere['PHPYUNBTWEND']   =   '';
        }
 
        // 计算总条数,并计算分页
        $jobNum         =   $jobM->getJobNum($numWhere);
        $data['total']  =   $jobNum;
        $data['list']   =   count($list) > 0 ? $list : array();
        $data['error']  =   0;
        echo json_encode($data);
        die();
    }
 
    //附近公司职位列表
    function comlist_action()
    {
        // where语句中HAVING `distance`<20 20是20km范围内的
        // SQL 语句 HAVING 一般和 GROUP BY 一起使用
        $select =   "`uid`,`name`,`shortname`,`x`,`y`,6371 * acos(cos(radians(" . $_POST['y'] . ")) * cos(radians(`y`)) * cos(radians(`x`) - radians(" . $_POST['x'] . ")) + sin(radians(" . $_POST['y'] . ")) * sin(radians(`y`))) AS `distance`";
        
        $page   =   $_POST['page'] ? $_POST['page'] : 1;
        
        $pagenav    =   ($page - 1) * 10;
        
        $limit      =   array($pagenav,10);
        
        $comM       =   $this->MODEL('company');
        
        $where      =   array(
            
            'name'      =>  array('<>', ''),
            'hy'        =>  array('<>', ''),
            'r_status'  =>  1,
            'orderby'   =>  'distance, asc',
            'groupby'   =>  'uid',
            'having'    =>  array(
                'distance' => array('<', 20, '')
            )
        );
        if($this->config['did']>0){
            
            $where['did']    =    $this->config['did'];
        }else{
            $where['PHPYUNBTWSTART']    =    '';
            
            $where['did'][]    =    array('isnull');
          
              $where['did'][]    =    array('=','0','OR');
            
            $where['PHPYUNBTWEND']    =    '';
        }
        $comWhere   =   array_merge($where, array('limit' => $limit));
        
        $comListA   =   $comM -> getList($comWhere, array('field' => $select));
        
        if (!empty($comListA['list'])) {
            
            $comListAllA    =   $comM -> getList($where, array('field' => $select));
            
            $pageCount      =   ceil(count($comListAllA['list']) / 10);
            
            $uids           =   array();
            
            foreach ($comListA['list'] as $v) {
                
                $uids[]     =   $v['uid'];
            }
            
            $jobM           =   $this->MODEL('job');
            
            $jobListA       =   $jobM -> getList(array('r_status' => 1, 'status' => 0, 'state' => 1, 'uid' => array('in', pylode(',', $uids))), array('field' => '`id`, `uid`, `name`'));
            
            if (!empty($jobListA['list'])) {
                
                $list       =   array();
                
                foreach ($comListA['list'] as $k => $v) {
                    
                    if ($v['shortname']) {
                        
                        $list[$k]['com_name']   =   mb_substr($v['shortname'], 0, 16, 'utf-8');
                    } else {
                        
                        $list[$k]['com_name']   =   mb_substr($v['name'], 0, 16, 'utf-8');
                    }
                    
                    $list[$k]['comurl']         =   Url('wap', array('c' => 'company', 'a' => 'show', 'id' => $v['uid']));
                    $list[$k]['x']              =   $v['x'];
                    $list[$k]['y']              =   $v['y'];
                    
                    $list[$k]['joblist']        =   array();
                    
                    foreach ($jobListA['list'] as $val) {
                        
                        if ($val['uid'] == $v['uid']) {
                            
                            $val['joburl']          =   Url('wap', array('c' => 'job', 'a' => 'comapply', 'id' => $val['id']));
                            $list[$k]['joblist'][]  =   $val;
                        }
                    }
                }
                
                // 去掉没有职位的企业
                foreach ($list as $k => $v) {
                    if (count($list[$k]['joblist']) < 0) {
                        
                        unset($list[$k]);
                    }
                }
            }
        }
        
        $data               =   array();
        $data['list']       =   count($list) > 0 ? $list : array();
        $data['pagecount']  =   $pageCount ? $pageCount : 0;
        $data['error']      =   0;
        
        echo json_encode($data);
        die();
    }
 
    function jobmap_action()
    {
        $this -> get_moblie();
        $this -> yunset('headertitle', '企业位置');
        
        $comid  =   intval($_GET['id']);
        
        $comM   =   $this -> MODEL('company');
        $comA   =   $comM -> getInfo($comid, array('field' => '`uid`, `name`, `cityid`, `address`, `x`, `y`'));
        
        $CacheM =   $this->MODEL('cache');
        $CacheArr   =   $CacheM->GetCache(array('city'));
        
        $cityName   =   $CacheArr['city_name'][$comA['cityid']];
        
        $this->yunset('cityname', $cityName);
        
        $this->yunset('com', $comA);
        
        $user_agent =   (! isset($_SERVER['HTTP_USER_AGENT'])) ? FALSE : $_SERVER['HTTP_USER_AGENT'];
        
        if ($_COOKIE['mapx'] > 0 && $_COOKIE['mapy'] > 0 && strpos($user_agent, 'Android')) {
            
            $this->yunset(array('mapx' => $_COOKIE['mapx'], 'mapy' => $_COOKIE['mapy']));
        } else {
            
            $this->yunset(array('mapx' => 0, 'mapy' => 0));
        }
        $this -> seo('map');
        $this->yuntpl(array('wap/job_map'));
    }
}
?>