|
@@ -1,6 +1,46 @@
|
|
|
<?php
|
|
|
// 接口公共方法
|
|
|
use think\Db;
|
|
|
+use JPush\Client;
|
|
|
+require_once env('root_path').'vendor/jpush/jpush/autoload.php';
|
|
|
+function Jpush($user_id = 0,$alert = ''){
|
|
|
+ if(empty($user_id)) return false;
|
|
|
+ $appKey = '02a7faefd91c8a6a446a6a14';
|
|
|
+ $masterSecret = 'ba2e100db997024d9b6e5d35';
|
|
|
+ $client = new Client($appKey, $masterSecret,null);
|
|
|
+ $push_payload = $client->push()
|
|
|
+ ->setPlatform(array('ios', 'android'))
|
|
|
+ ->addAlias(strval($user_id))
|
|
|
+ ->iosNotification($alert, array(
|
|
|
+ 'badge' => '+1',
|
|
|
+ 'content-available' => true,
|
|
|
+ 'mutable-content' => true,
|
|
|
+ 'category' => 'jiguang',
|
|
|
+ 'extras' => array(
|
|
|
+ 'key' => 'value',
|
|
|
+ 'jiguang'
|
|
|
+ ),
|
|
|
+ ))->androidNotification($alert, array(
|
|
|
+ 'title' => '消息通知',
|
|
|
+ // 'builder_id' => 2,
|
|
|
+ 'extras' => array(
|
|
|
+ 'key' => 'value',
|
|
|
+ 'jiguang'
|
|
|
+ ),
|
|
|
+ ))->options(array(
|
|
|
+ 'apns_production' => True,
|
|
|
+ ));
|
|
|
+ try {
|
|
|
+ $response = $push_payload->send();
|
|
|
+ return $response;
|
|
|
+ } catch (\JPush\Exceptions\APIConnectionException $e) {
|
|
|
+ return $e;
|
|
|
+ } catch (\JPush\Exceptions\APIRequestException $e) {
|
|
|
+ return $e;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
function get_order_sn(){
|
|
|
$order_id_main = date('YmdHis') . rand(10000000,99999999);
|
|
|
$order_id_len = strlen($order_id_main);
|