chengkun
2025-04-29 ab5d7bddae4557b9d56d17f21fc8ca232d7d8693
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
<?php
 
class map_controller extends wxapp_controller{
    //附近职位列表
    function list_action(){
        $coordinates    =    $this->Convert_GCJ02_To_BD09($_POST['x'],$_POST['y']);
        $x    =    $coordinates['lng'];
        $y    =    $coordinates['lat'];
        // 根据sql距离计算公式计算距离并排序
        $select =   "`id`,`uid`,`name`,`x`,`y`,`provinceid`,`cityid`,`com_logo`,`exp`,`edu`,`minsalary`,`maxsalary`,`welfare`,`lastupdate`, `is_link`, 6371 * acos(cos(radians(" . $y . ")) * cos(radians(`y`)) * cos(radians(`x`) - radians(" . $x . ")) + sin(radians(" . $y . ")) * sin(radians(`y`))) AS `distance`";
        
        $page   =   $_POST['page'] ? $_POST['page'] : 1;
 
        if ($this->config['sy_indexpage']) {
            $indexPageNum   =   ceil($this->config['sy_indexpage'] / 10);
            
            if ($page > $indexPageNum) {
                $page   =   $indexPageNum;
            }
        }
        
 
        $pagenav    =   ($page - 1) * 10;
        
        $limit      =   array($pagenav,10);
 
        $where      =   array(
            
            'state'     =>  1,
            'r_status'  =>  1,
            'status'    =>  0,
            'x'         =>  array('>', 0),
            'y'         =>  array('>', 0),
            'orderby'   =>  'distance, asc',
            'limit'     =>  $limit
        );
        if(!empty($_POST['did'])){
            
            $where['did']    =    $_POST['did'];
        }else{
            $where['PHPYUNBTWSTART']    =    '';
            
            $where['did'][]    =    array('isnull');
            
            $where['did'][]    =    array('=','0','OR');
            
            $where['PHPYUNBTWEND']    =    '';
        }
        $jobM   =   $this->MODEL('job');
        $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`,`name`,`shortname`,`address`'));
 
            $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_edu'] = $v['job_edu'];
                $list[$k]['job_exp'] = $v['job_exp'];
                if(!empty($v['citystr'])) {
                    $list[$k]['citystr'] = $v['citystr'];
                }
                if(!empty($v['address'])){
                    $list[$k]['address']  =  $v['address'];
                }
 
                $list[$k]['comlogo'] = $v['com_logo_n'];
 
                $newxy  =  $this->Convert_BD09_To_GCJ02($v['x'], $v['y']);
                $list[$k]['x']          =  $newxy['lng'];
                $list[$k]['y']          =  $newxy['lat'];
                
                if ($v['welfare_n']) {
                    $list[$k]['welfare_n']=   $v['welfare_n'];
                }
                if ($v['distance'] <= 1) {
                    $list[$k]['dis']    =   ceil($v['distance'] * 1000) . 'm';
                } else {
                    $list[$k]['dis']    =   round($v['distance'], 2) . 'km';
                }
                
                
                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'];
                        }
                    }
                }
            }
        }
        $data['list']   =   count($list) > 0 ? $list : array();
        // 小程序用seo
        if (isset($_POST['provider'])){
            if ($_POST['provider'] == 'baidu' || $_POST['provider'] == 'weixin' || $_POST['provider'] == 'toutiao'){
                $seo            =  $this->seo('map','','','',false, true);
                $data['seo']    =  $seo;
            }
        }
        
        $this->render_json(0,'ok',$data);
    }
    // 静态图
    function staticMap_action(){
        
        if (!empty($this->config['sy_chat_mapkey'])){
            $center = $_POST['lng'] . ',' . $_POST['lat'];  // lng,lat
            // 高德
            $url = 'https://restapi.amap.com/v3/staticmap';
            
            $params = array(
                'location' => $center,
                'zoom'     => 14,
                'scale'    => 2,
                'size'     => '320*130',
                'markers'  => 'large,0xFF0000,:'.$center,
                'key'      => $this->config['sy_chat_mapkey']
            );
            $preSignStr = $this->getSignContent($params);
            
            $url = $url . "?" . $preSignStr;
            
            $back = CurlGet($url);
            $json = json_encode($back, true);
            
            if (! $json){
                
                // 重新定义文件名称 图片一律用 jpeg
                $filename  =  time().rand(1000,9999).'.png';
                //自定义目录名称
                $dirName = APP_PATH . 'data/upload/chat/' . date('Ymd');
                //定义新名称以及目录
                if (!file_exists($dirName)){
                    mkdir($dirName, 0777, true);
                }
                $res = fopen($dirName . '/' . $filename, 'a');
                fwrite($res, $back);
                fclose($res);
                
                if($this->config['sy_oss'] == 1){
                    
                    include_once(LIB_PATH.'oss/ossupload.class.php');
                    $ossUpload  =  new ossUpload();
                    $pic        =  $ossUpload -> uploadLocalImg($dirName . '/' . $filename);
                    
                    $picUrl  =  $pic['picurl'];
                }else{
                    
                    $picUrl =    str_replace(APP_PATH.'data', './data', $dirName . '/' . $filename);
                }
                $this->render_json(0, 'ok', array('url'=>checkpic($picUrl)));
            }else{
                // 高德
                $msg = isset($json['info']) ? $json['info'] : '静态图生成失败';
                $this->render_json(-1, $msg);
            }
        }else {
            $this->render_json(-1, '地图key未配置');
        }
    }
    function getSignContent($params){
        
        ksort($params);
        
        $stringToBeSigned = "";
        $i = 0;
        foreach ($params as $k => $v) {
            if ($this->checkEmpty($v) === false && substr($v, 0, 1) != "@") {
                
                if ($i == 0) {
                    $stringToBeSigned .= "$k" . "=" . "$v";
                } else {
                    $stringToBeSigned .= "&" . "$k" . "=" . "$v";
                }
                $i++;
            }
        }
        unset ($k, $v);
        
        return $stringToBeSigned;
    }
    function checkEmpty($value) {
        if (!isset($value)){
            return true;
        }
        if ($value === null){
            return true;
        }
        if (trim($value) === ""){
            return true;
        }
        return false;
    }
}
?>