|
@@ -196,33 +196,86 @@ if (!function_exists('build_heading')) { |
|
@@ -196,33 +196,86 @@ if (!function_exists('build_heading')) { |
|
196
|
}
|
196
|
}
|
|
197
|
|
197
|
|
|
198
|
|
198
|
|
|
199
|
- /**
|
|
|
|
200
|
- * 微信公众号
|
|
|
|
201
|
- * 经纪人审核 消息推送
|
|
|
|
202
|
- */
|
|
|
|
203
|
- function sendAstuWxMsgToAgent($info, $openid, $tourl, $appid, $secret, $ywt_appid, $pagepath)
|
|
|
|
204
|
- {
|
|
|
|
205
|
- $myurl = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" . $appid . "&secret=" . $secret;
|
|
|
|
206
|
- $json_token = http_request($myurl);
|
|
|
|
207
|
- $access_tokens = json_decode($json_token, true);
|
|
|
|
208
|
- $access_token = $access_tokens['access_token'];
|
|
|
|
209
|
-
|
|
|
|
210
|
- $template = array(
|
|
|
|
211
|
- 'touser' => $openid, //
|
|
|
|
212
|
- 'template_id' => 'zQaLnhEOQxdGOKJlDUAfEoNY4NTmNWy9a9vYzkZjGn8', //模板消息id 必须修改
|
|
|
|
213
|
- 'url' => $tourl, //点击链接
|
|
|
|
214
|
- "miniprogram" => [
|
|
|
|
215
|
- "appid" => $ywt_appid,
|
|
|
|
216
|
- "pagepath" => $pagepath
|
|
|
|
217
|
- ],
|
|
|
|
218
|
- 'topcolor' => "#173177",
|
|
|
|
219
|
- 'data' => $info
|
|
|
|
220
|
- );
|
|
|
|
221
|
-
|
|
|
|
222
|
- $json_template = json_encode($template);
|
|
|
|
223
|
- $url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" . $access_token;
|
|
|
|
224
|
- $json = http_request($url, urldecode($json_template));
|
|
|
|
225
|
- $rs = json_decode($json, true);
|
|
|
|
226
|
- return $rs;
|
199
|
+
|
|
|
|
200
|
+}
|
|
|
|
201
|
+if (!function_exists('sendAstuWxMsgToAgent')) {
|
|
|
|
202
|
+
|
|
|
|
203
|
+/**
|
|
|
|
204
|
+ * 微信公众号
|
|
|
|
205
|
+ * 经纪人审核 消息推送
|
|
|
|
206
|
+ */
|
|
|
|
207
|
+function sendAstuWxMsgToAgent($info, $openid, $tourl, $appid, $secret, $ywt_appid, $pagepath)
|
|
|
|
208
|
+{
|
|
|
|
209
|
+ $myurl = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" . $appid . "&secret=" . $secret;
|
|
|
|
210
|
+ $json_token = http_request($myurl);
|
|
|
|
211
|
+ $access_tokens = json_decode($json_token, true);
|
|
|
|
212
|
+ $access_token = $access_tokens['access_token'];
|
|
|
|
213
|
+
|
|
|
|
214
|
+ $template = array(
|
|
|
|
215
|
+ 'touser' => $openid, //
|
|
|
|
216
|
+ 'template_id' => 'zQaLnhEOQxdGOKJlDUAfEoNY4NTmNWy9a9vYzkZjGn8', //模板消息id 必须修改
|
|
|
|
217
|
+ 'url' => $tourl, //点击链接
|
|
|
|
218
|
+ "miniprogram" => [
|
|
|
|
219
|
+ "appid" => $ywt_appid,
|
|
|
|
220
|
+ "pagepath" => $pagepath
|
|
|
|
221
|
+ ],
|
|
|
|
222
|
+ 'topcolor' => "#173177",
|
|
|
|
223
|
+ 'data' => $info
|
|
|
|
224
|
+ );
|
|
|
|
225
|
+
|
|
|
|
226
|
+ $json_template = json_encode($template);
|
|
|
|
227
|
+ $url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" . $access_token;
|
|
|
|
228
|
+ $json = http_request($url, urldecode($json_template));
|
|
|
|
229
|
+ $rs = json_decode($json, true);
|
|
|
|
230
|
+ return $rs;
|
|
|
|
231
|
+}
|
|
|
|
232
|
+}
|
|
|
|
233
|
+
|
|
|
|
234
|
+if (!function_exists('senWxmsgToAgentUser')) {
|
|
|
|
235
|
+
|
|
|
|
236
|
+/***
|
|
|
|
237
|
+ * 公众号推送审核信息给经纪人
|
|
|
|
238
|
+ */
|
|
|
|
239
|
+ function senWxmsgToAgentUser($order_id)
|
|
|
|
240
|
+{
|
|
|
|
241
|
+ $order=Db::name("order")->find($order_id);
|
|
|
|
242
|
+ if($order['driver_id']){
|
|
|
|
243
|
+ $user=Db::name("user")->find($order['driver_id']);
|
|
|
|
244
|
+ $wct_user=Db::name("wct_user")->where("unionid",$user['unionid'])->find();
|
|
|
|
245
|
+ $wxopenid=$wct_user['wx_openid'];
|
|
|
|
246
|
+ $sendInfo = array(
|
|
|
|
247
|
+ 'first' => array('value' => "汽车票出票状态通知", 'color' => "#743A3A"),
|
|
|
|
248
|
+ 'thing2' => array('value' => "{$order['starting_point']}-{$order['end_point']}", 'color' => '#173177'),
|
|
|
|
249
|
+ 'time3' => array('value' =>urlencode(date('Y-m-d H:i:s', $order['reservation_time'])), 'color' => '#173177'),
|
|
|
|
250
|
+ 'thing7' => array('value' =>"{$order['starting_point']}", 'color' => '#173177'),
|
|
|
|
251
|
+ 'phone_number5' => array('value' => "{$order['phone']}", 'color' => '#173177'),
|
|
|
|
252
|
+ );
|
|
|
|
253
|
+ if ($wxopenid) {
|
|
|
|
254
|
+ $config = get_addon_config('wechat');
|
|
|
|
255
|
+ $tourl = '';
|
|
|
|
256
|
+ $ywt_appid = 'wxb7dd0c03865a94e0';
|
|
|
|
257
|
+ $pagepath = '';
|
|
|
|
258
|
+ $res = sendAstuWxMsgToAgent($sendInfo, $wxopenid, $tourl, $config['app_id'], $config['secret'], $ywt_appid, $pagepath);
|
|
|
|
259
|
+ print_r($res);return;
|
|
|
|
260
|
+ //file_put_contents("pcl_wct_send.log", date("Y-m-d H:i:s") . "1-2-" . json_encode($res, JSON_UNESCAPED_UNICODE) . PHP_EOL, FILE_APPEND);
|
|
227
|
}
|
261
|
}
|
|
|
|
262
|
+ }
|
|
|
|
263
|
+}
|
|
|
|
264
|
+}
|
|
|
|
265
|
+if (!function_exists('http_request')) {
|
|
|
|
266
|
+function http_request($url, $data = array())
|
|
|
|
267
|
+{
|
|
|
|
268
|
+ $ch = curl_init();
|
|
|
|
269
|
+ curl_setopt($ch, CURLOPT_URL, $url);
|
|
|
|
270
|
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
|
|
|
271
|
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
|
|
|
|
272
|
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
|
|
|
|
273
|
+ // 我们在POST数据哦!
|
|
|
|
274
|
+ curl_setopt($ch, CURLOPT_POST, 1);
|
|
|
|
275
|
+ // 把post的变量加上
|
|
|
|
276
|
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
|
|
|
277
|
+ $output = curl_exec($ch);
|
|
|
|
278
|
+ curl_close($ch);
|
|
|
|
279
|
+ return $output;
|
|
|
|
280
|
+}
|
|
228
|
} |
281
|
} |