diff --git a/Application/Admin/View/ApiManage/index.html b/Application/Admin/View/ApiManage/index.html index e4ad516..8b50e13 100644 --- a/Application/Admin/View/ApiManage/index.html +++ b/Application/Admin/View/ApiManage/index.html @@ -22,7 +22,7 @@ {$i} {$vo['apiName']} - {$vo['hash']} + {$vo['hash']} 生效 diff --git a/Application/Home/ORG/ApiLog.class.php b/Application/Home/ORG/ApiLog.class.php index 2bbca22..6f25db3 100644 --- a/Application/Home/ORG/ApiLog.class.php +++ b/Application/Home/ORG/ApiLog.class.php @@ -9,12 +9,13 @@ namespace Home\ORG; class ApiLog { - private static $appInfo = null; - private static $apiInfo = null; - private static $request = null; - private static $requestAfterFilter = null; - private static $response = null; - private static $header = null; + private static $appInfo = 'null'; + private static $apiInfo = 'null'; + private static $request = 'null'; + private static $requestAfterFilter = 'null'; + private static $response = 'null'; + private static $header = 'null'; + private static $userInfo = 'null'; public static function setAppInfo($data) { self::$appInfo = $data['app_id'] . "({$data['app_name']}) {$data['device_id']}"; @@ -30,6 +31,13 @@ class ApiLog { self::$apiInfo = $data['apiName'] . ' ' . $data['hash']; } + public static function setUserInfo($data) { + if (is_array($data)) { + $data = json_encode($data); + } + self::$userInfo = $data; + } + public static function setRequest($data) { if (is_array($data)) { $data = json_encode($data); @@ -54,7 +62,7 @@ class ApiLog { public static function save() { $logPath = APP_PATH . '/ApiLog/' . date('YmdH') . '.log'; $logStr = self::$apiInfo . ' ' . date('H:i:s') . ' ' . self::$request . ' ' . self::$header . ' ' - . self::$response . ' ' . self::$requestAfterFilter . ' ' . self::$appInfo."\n"; + . self::$response . ' ' . self::$requestAfterFilter . ' ' . self::$appInfo.' '.self::$userInfo."\n"; @file_put_contents($logPath, $logStr, FILE_APPEND); } diff --git a/Application/Home/ORG/JPush/Push.class.php b/Application/Home/ORG/JPush/Push.class.php index 75782d1..90c0753 100644 --- a/Application/Home/ORG/JPush/Push.class.php +++ b/Application/Home/ORG/JPush/Push.class.php @@ -221,9 +221,11 @@ class Push { * @author zhaoxiang * @return $this */ - public function iosNotification($alert, $notification = array()) { + public function iosNotification($alert = null, $notification = array()) { $ios = array(); - $ios['alert'] = (is_string($alert) || is_array($alert)) ? $alert : ''; + if (!is_null($alert)) { + $ios['alert'] = (is_string($alert) || is_array($alert)) ? $alert : ''; + } if (!empty($notification)) { if (isset($notification['sound']) && is_string($notification['sound'])) { $ios['sound'] = $notification['sound']; @@ -262,9 +264,11 @@ class Push { * @author zhaoxiang * @return $this */ - public function androidNotification($alert, array $notification = array()) { + public function androidNotification($alert = null, array $notification = array()) { $android = array(); - $android['alert'] = is_string($alert) ? $alert : ''; + if (!is_null($alert)) { + $android['alert'] = is_string($alert) ? $alert : ''; + } if (!empty($notification)) { if (isset($notification['title']) && is_string($notification['title'])) { $android['title'] = $notification['title']; @@ -394,43 +398,39 @@ class Push { if (is_null($this->androidNotification['alert'])) { if (is_null($this->notificationAlert)) { Response::error(ReturnCode::EXCEPTION, 'Android alert can not be null'); - } else { - $notification['android']['alert'] = $this->notificationAlert; } - } - } else { - if (!is_null($this->extras)) { - $notification['android']['extras'] = $this->extras; + } else { + $notification['android']['alert'] = $this->androidNotification['alert']; } } + if (!is_null($this->extras)) { + $notification['android']['extras'] = $this->extras; + } + if (!is_null($this->iosNotification)) { $notification['ios'] = $this->iosNotification; if (is_null($this->iosNotification['alert'])) { if (is_null($this->notificationAlert)) { Response::error(ReturnCode::EXCEPTION, 'iOS alert can not be null'); - } else { - $notification['ios']['alert'] = $this->notificationAlert; } + } else { + $notification['ios']['alert'] = $this->iosNotification['alert']; } - } else { - if (!is_null($this->extras)) { - $notification['ios']['extras'] = $this->extras; - } + } + if (!is_null($this->extras)) { + $notification['ios']['extras'] = $this->extras; } if (count($notification) > 0) { $payload['notification'] = $notification; } - if (count($this->message) > 0) { $payload['message'] = $this->message; } - if (!array_key_exists('notification', $payload) && !array_key_exists('message', $payload)) { Response::error(ReturnCode::EXCEPTION, 'notification and message can not all be null'); } - if (!is_null($this->options)) { $payload['options'] = $this->options; }