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
<?php
 
 
 
/**
 * (email、手机短信)消息发送类 天眼查数据获取
 */
class privacy_model extends model
{
 
    function getList($whereData, $data = array())
    {
        $ListNew = array();
        $List = $this->select_all('privacy_log', $whereData);
 
        if (!empty($List)) {
            $cuid = array();
            $uid = array();
            foreach ($List as $k => $v) {
                if ($v['comid'] && $v['comid'] > 0) {
                    $cuid[] = $v['comid'];
                }
                if ($v['uid'] && $v['uid'] > 0) {
                    $uid[] = $v['uid'];
                }
            }
            $alluids = array_merge($cuid, $uid);
            $alluids = array_unique($alluids);
 
            require_once('userinfo.model.php');
            $userinfoM = new userinfo_model($this->db, $this->def);
 
            $namelists = $userinfoM->getUserList(array('uid' => array('in', pylode(',', $alluids))));
 
            foreach ($namelists as $nk => $nv) {
                $names[$nv['uid']] = $nv['name'];
            }
 
            foreach ($List as $lk => $lv) {
 
                $List[$lk]['fname'] = $lv['comid'] ? $names[$lv['comid']] : '管理员';
 
                if ($lv['uid'] > 0) {
 
                    $List[$lk]['sname'] = $names[$lv['uid']];
 
                } else {
 
                    $List[$lk]['sname'] = '';
 
                }
            }
 
            $ListNew['list'] = $List;
        }
 
        return $ListNew;
    }
 
    function delMoblieMsg($whereData, $data)
    {
 
        if ($data['type'] == 'one') {//单个删除
 
            $limit = 'limit 1';
 
        }
 
        if ($data['type'] == 'all') {//多个删除
 
            $limit = '';
 
        }
 
        if ($data['norecycle'] == '1') {    //    数据库清理,不插入回收站
 
            $result = $this->delete_all('privacy_log', $whereData, $limit, '', '1');
        } else {
 
            $result = $this->delete_all('privacy_log', $whereData, $limit);
        }
 
        return $result;
 
    }
 
    
    //$bindNumberA, $bindNumberB,$comid,$jobid, $uid, $eid, $type
    function setPrivacy($data)
    {
 
        
        $privacy = 0;
        
        $bindNumberA        = $data['NumberA'];
        $bindNumberB        = $data['NumberB'];
 
        $logData['comid']        = $data['comid'];
        $logData['uid']            = $data['uid'];
        
        $logData['bindnumber'] = $bindNumberA;
        $logData['bindnumberB'] = $bindNumberB;
        
        $logData['ctime']    = time();
        
        //简历隐私号
        if($data['type'] == '1' && $this->config['sy_privacy_open'] == '1'){
            
            $logData['type']    = '1';//简历电话
            $logData['eid']        = $data['eid'];
            $privacy            =    1;
 
        
        //企业隐私号
        }elseif($data['type'] == '2' && $this->config['sy_comprivacy_open'] == '1'){
            
 
            $logData['type']    = '2';//job
            $logData['jobid']    = $data['jobid'];
            $privacy            =    2;
 
        }
 
        
        
        //开启隐私号
        if($privacy>0){
 
            if (CheckMobile($bindNumberA) && CheckMobile($bindNumberB)) {
 
                //组装API必需参数
                $appid = $this->config['sy_privacy_appid'];
 
                $token = $this->config['sy_privacy_token'];
                $time = microtime();
                $sign = md5($appid . $token . $time);
                $header = array(
                    'Content-Type: application/json',
                    'Authorization:' . base64_encode($appid . ":" . $time)
                );
                //查询当前是否有绑定小号 有绑定并且过期时间大于10秒的直接返回
 
                $this->config['sy_privacy_time']    =    $this->config['sy_privacy_time'] ? $this->config['sy_privacy_time'] : 60;
 
                $bindTime    =    time() - ($this->config['sy_privacy_time']);
                $isBind        =    $this -> select_once('privacy_log',array('result'=>1,'bindnumber'=>$bindNumberA,'bindnumberB'=>$bindNumberB,'ctime'=>array('>=',$bindTime),'orderby'=>'id,desc'));
 
                
                //当前如果有绑定小号的情况下 需要先解除绑定 重置生效时间
                if (!empty($isBind)) {
                    
                    $reTime    =    $isBind['ctime'] + $this->config['sy_privacy_time'] -     time();
 
                    //有效期低于10秒直接解绑换新号
                    if($reTime < 10){
                        $unbindurl = "https://101.37.133.245:11008/voice/1.0.0/middleNumberUnbind/$appid/$sign";
 
                        $unbinddata['middleNumber'] = $isBind['middlenumber'];
                        $unbinddata['bindNumberA'] = $isBind['bindnumber'];
                        $unbinddata['bindNumberB'] = $isBind['bindnumberB'];
                        $unbinddata['mode'] = 0;
 
                        CurlPost($unbindurl, json_encode($unbinddata), 1, $header);
                    }else{
                        $result['middleNumber']        =    $isBind['middlenumber'];
                        $result['prvtime']            =    $reTime;
                    }
                }
 
                
                
                if(!$result['middleNumber']){
                    
                    $data['bindNumberA']    = $bindNumberA;
                    $data['bindNumberB']    = $bindNumberB;
 
                    $data['calleeName']        = $this->config['sy_privacy_uname'];
 
                    $data['calleeId']        = $this->config['sy_privacy_idcard'];
 
                    $data['callRec']        = $this->config['sy_privacy_callrec'];
 
                    $data['callbackUrl']    = $this->config['sy_privacy_callrec'];
 
                    $data['maxBindingTime'] = $this->config['sy_privacy_time'];
 
                    //$data['callbackUrl']    = $this->config['sy_weburl'].'/job/?c=acceptprv';
 
                    $data['mode']            = 1;
 
 
                    $url = "https://101.37.133.245:11008/voice/1.0.0/middleNumberAXB/$appid/$sign";
 
                    $return = CurlPost($url, json_encode($data), 1, $header);
                    
                    
                    $result = json_decode($return, true);
                
                    if ($result['result'] == '000000') {
 
                        $logData['middlenumber'] = $result['middleNumber'];
 
                        $logData['result'] = 1;
 
                        $result['prvtime']    =    $this->config['sy_privacy_time'];
 
 
                    } else {
                        $logData['result'] = $result['result'];
                        $logData['message'] = $result['message'];
                    }
                    
                    $this->insert_into('privacy_log', $logData);
 
 
                } 
            }else {
 
                $logData['result'] = 0;
                $logData['message'] = '手机号格式错误';
 
                //记录隐私号绑定日志
                $this->insert_into('privacy_log', $logData);
            }
 
 
        }
 
        
 
        if($result['middleNumber']){
            
            return array('middleNumber'=>$result['middleNumber'],'prvtime'=>$result['prvtime']);
        }
        
    }
 
    
}
 
?>