Browse Source

修复报错

1. 修复Bark通知,会出现code找不到的报错;
2. 修改邮箱与推送重复的问题;
3. 修复服务监视ServiceTimer报错的问题;
4. 修复不发使用用户编辑页面的问题;
5. 修复订单回调处理出错的问题
兔姬桑 5 years ago
parent
commit
07df6c542d

+ 12 - 8
app/Components/PushNotification.php

@@ -3,7 +3,6 @@
 
 namespace App\Components;
 
-
 use Exception;
 use Log;
 use stdClass;
@@ -13,14 +12,16 @@ class PushNotification
 	public static function send($title, $content)
 	{
 		switch(Helpers::systemConfig()['is_notification']){
-			case 1:
+			case 'serverChan':
 				return self::ServerChan($title, $content);
 				break;
-			case 2:
+			case 'bark':
 				return self::Bark($title, $content);
 				break;
 			default:
 		}
+
+		return FALSE;
 	}
 
 	/**
@@ -33,7 +34,7 @@ class PushNotification
 	 */
 	private static function ServerChan($title, $content)
 	{
-
+		$result = FALSE;
 		try{
 			// TODO:一天仅可发送不超过500条
 			$url = 'https://sc.ftqq.com/'.Helpers::systemConfig()['server_chan_key'].'.send?text='.$title.'&desp='.urlencode($content);
@@ -66,13 +67,16 @@ class PushNotification
 	 */
 	private static function Bark($title, $content)
 	{
+		$result = FALSE;
 		try{
 			$url = 'https://api.day.app/'.Helpers::systemConfig()['bark_key'].'/'.$title.'/'.$content;
 			$result = json_decode(Curl::send($url));
-			if($result->code == 200){
-				Helpers::addNotificationLog($title, $content, 3);
-			}else{
-				Helpers::addNotificationLog($title, $content, 3, 'admin', $result->message);
+			if($result){
+				if($result->code == 200){
+					Helpers::addNotificationLog($title, $content, 3);
+				}else{
+					Helpers::addNotificationLog($title, $content, 3, 'admin', $result->message);
+				}
 			}
 		} catch(Exception $e){
 			Log::error('Bark消息推送异常:'.$e);

+ 5 - 5
app/Console/Commands/NodeBlockedDetection.php

@@ -62,7 +62,7 @@ class NodeBlockedDetection extends Command
 					$node->ip = $ip;
 				}else{
 					Log::warning("【节点阻断检测】检测".$node->server."时,IP获取失败".$ip." | ".$node->server);
-					$this->notifyMaster("{$node->name}动态IP获取失败", "节点**{$node->name}**:** IP获取失败 **");
+					$this->notifyMaster("{$node->name}动态IP获取失败", "节点 {$node->name} : IP获取失败 ");
 				}
 			}
 			if($node->detectionType != 1){
@@ -100,7 +100,7 @@ class NodeBlockedDetection extends Command
 					}else{
 						Cache::forget($cacheKey);
 						SsNode::query()->where('id', $node->id)->update(['status' => 0]);
-						$additionalMessage .= "\r\n**节点【{$node->name}】自动进入维护状态**\r\n";
+						$additionalMessage .= "\r\n节点【{$node->name}】自动进入维护状态\r\n";
 					}
 				}
 			}
@@ -108,7 +108,7 @@ class NodeBlockedDetection extends Command
 
 		//只有在出现阻断线路时,才会发出警报
 		if($sendText){
-			$this->notifyMaster("节点阻断警告", "**阻断日志**: \r\n\r\n".$message.$additionalMessage);
+			$this->notifyMaster("节点阻断警告", "阻断日志: \r\n\r\n".$message.$additionalMessage);
 			Log::info("阻断日志: \r\n".$message.$additionalMessage);
 		}
 
@@ -125,10 +125,10 @@ class NodeBlockedDetection extends Command
 	 */
 	private function notifyMaster($title, $content)
 	{
-		if(self::$systemConfig['webmaster_email']){
+		$result = PushNotification::send($title, $content);
+		if(!$result && self::$systemConfig['webmaster_email']){
 			$logId = Helpers::addNotificationLog($title, $content, 1, self::$systemConfig['webmaster_email']);
 			Mail::to(self::$systemConfig['webmaster_email'])->send(new nodeCrashWarning($logId));
 		}
-		PushNotification::send($title, $content);
 	}
 }

+ 1 - 0
app/Console/Commands/ServiceTimer.php

@@ -2,6 +2,7 @@
 
 namespace App\Console\Commands;
 
+use App\Components\Helpers;
 use App\Http\Controllers\ServiceController;
 use App\Http\Models\Order;
 use App\Http\Models\User;

+ 5 - 2
app/Http/Controllers/AdminController.php

@@ -2044,15 +2044,18 @@ EOF;
 	{
 		if(self::$systemConfig['is_notification']){
 			$result = PushNotification::send('这是测试的标题', 'SSRPanel_OM测试内容');
+			if($result == FALSE){
+				return Response::json(['status' => 'fail', 'message' => '发送失败,请重新尝试!']);
+			}
 			switch(self::$systemConfig['is_notification']){
-				case 1:
+				case 'serverChan':
 					if(!$result->errno){
 						return Response::json(['status' => 'success', 'message' => '发送成功,请查看手机是否收到推送消息']);
 					}else{
 						return Response::json(['status' => 'fail', 'message' => $result? $result->errmsg : '未知']);
 					}
 					break;
-				case 2:
+				case 'bark':
 					if($result->code == 200){
 						return Response::json(['status' => 'success', 'message' => '发送成功,请查看手机是否收到推送消息']);
 					}else{

+ 4 - 1
app/Mail/nodeCrashWarning.php

@@ -18,11 +18,14 @@ class nodeCrashWarning extends Mailable implements ShouldQueue
 	public function __construct($id)
 	{
 		$this->id = $id;
+
 	}
 
 	public function build()
 	{
-		return $this->view('emails.nodeCrashWarning')->subject('节点离线警告');
+		$view['content'] = NotificationLog::query()->where('id', $this->id)->first()->content;
+
+		return $this->view('emails.nodeCrashWarning', $view)->subject('节点阻断警告');
 	}
 
 	// 发件失败处理

+ 41 - 38
composer.lock

@@ -779,16 +779,16 @@
         },
         {
             "name": "doctrine/dbal",
-            "version": "v2.10.1",
+            "version": "2.10.2",
             "source": {
                 "type": "git",
                 "url": "https://github.com/doctrine/dbal.git",
-                "reference": "c2b8e6e82732a64ecde1cddf9e1e06cb8556e3d8"
+                "reference": "aab745e7b6b2de3b47019da81e7225e14dcfdac8"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/doctrine/dbal/zipball/c2b8e6e82732a64ecde1cddf9e1e06cb8556e3d8",
-                "reference": "c2b8e6e82732a64ecde1cddf9e1e06cb8556e3d8",
+                "url": "https://api.github.com/repos/doctrine/dbal/zipball/aab745e7b6b2de3b47019da81e7225e14dcfdac8",
+                "reference": "aab745e7b6b2de3b47019da81e7225e14dcfdac8",
                 "shasum": "",
                 "mirrors": [
                     {
@@ -806,9 +806,11 @@
             "require-dev": {
                 "doctrine/coding-standard": "^6.0",
                 "jetbrains/phpstorm-stubs": "^2019.1",
-                "phpstan/phpstan": "^0.11.3",
+                "nikic/php-parser": "^4.4",
+                "phpstan/phpstan": "^0.12",
                 "phpunit/phpunit": "^8.4.1",
-                "symfony/console": "^2.0.5|^3.0|^4.0|^5.0"
+                "symfony/console": "^2.0.5|^3.0|^4.0|^5.0",
+                "vimeo/psalm": "^3.11"
             },
             "suggest": {
                 "symfony/console": "For helpful console commands such as SQL execution and import of files."
@@ -873,7 +875,7 @@
                 "sqlserver",
                 "sqlsrv"
             ],
-            "time": "2020-01-04T12:56:21+00:00"
+            "time": "2020-04-20T17:19:26+00:00"
         },
         {
             "name": "doctrine/event-manager",
@@ -1389,16 +1391,16 @@
         },
         {
             "name": "guzzlehttp/guzzle",
-            "version": "6.5.2",
+            "version": "6.5.3",
             "source": {
                 "type": "git",
                 "url": "https://github.com/guzzle/guzzle.git",
-                "reference": "43ece0e75098b7ecd8d13918293029e555a50f82"
+                "reference": "aab4ebd862aa7d04f01a4b51849d657db56d882e"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/guzzle/guzzle/zipball/43ece0e75098b7ecd8d13918293029e555a50f82",
-                "reference": "43ece0e75098b7ecd8d13918293029e555a50f82",
+                "url": "https://api.github.com/repos/guzzle/guzzle/zipball/aab4ebd862aa7d04f01a4b51849d657db56d882e",
+                "reference": "aab4ebd862aa7d04f01a4b51849d657db56d882e",
                 "shasum": "",
                 "mirrors": [
                     {
@@ -1411,7 +1413,8 @@
                 "ext-json": "*",
                 "guzzlehttp/promises": "^1.0",
                 "guzzlehttp/psr7": "^1.6.1",
-                "php": ">=5.5"
+                "php": ">=5.5",
+                "symfony/polyfill-intl-idn": "^1.11"
             },
             "require-dev": {
                 "ext-curl": "*",
@@ -1419,7 +1422,6 @@
                 "psr/log": "^1.1"
             },
             "suggest": {
-                "ext-intl": "Required for Internationalized Domain Name (IDN) support",
                 "psr/log": "Required for using the Log middleware"
             },
             "type": "library",
@@ -1458,7 +1460,7 @@
                 "rest",
                 "web service"
             ],
-            "time": "2019-12-23T11:57:10+00:00"
+            "time": "2020-04-18T10:38:46+00:00"
         },
         {
             "name": "guzzlehttp/promises",
@@ -2697,16 +2699,16 @@
         },
         {
             "name": "maximebf/debugbar",
-            "version": "v1.16.1",
+            "version": "v1.16.2",
             "source": {
                 "type": "git",
                 "url": "https://github.com/maximebf/php-debugbar.git",
-                "reference": "58998b818c6567fac01e35b8a4b70c1a64530556"
+                "reference": "40f375504a4dd8e59f779c3f3cac524777ddcde5"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/58998b818c6567fac01e35b8a4b70c1a64530556",
-                "reference": "58998b818c6567fac01e35b8a4b70c1a64530556",
+                "url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/40f375504a4dd8e59f779c3f3cac524777ddcde5",
+                "reference": "40f375504a4dd8e59f779c3f3cac524777ddcde5",
                 "shasum": "",
                 "mirrors": [
                     {
@@ -2760,7 +2762,7 @@
                 "debug",
                 "debugbar"
             ],
-            "time": "2019-11-24T09:46:11+00:00"
+            "time": "2020-04-16T09:05:52+00:00"
         },
         {
             "name": "mews/captcha",
@@ -3400,16 +3402,16 @@
         },
         {
             "name": "omnipay/common",
-            "version": "v3.0.2",
+            "version": "v3.0.3",
             "source": {
                 "type": "git",
                 "url": "https://github.com/thephpleague/omnipay-common.git",
-                "reference": "66b7934abd2d54cde8b24c5d0b1a5e733339a7e9"
+                "reference": "24ea70aa6e0f76d8b85d7a35d8a6560c746f566f"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/thephpleague/omnipay-common/zipball/66b7934abd2d54cde8b24c5d0b1a5e733339a7e9",
-                "reference": "66b7934abd2d54cde8b24c5d0b1a5e733339a7e9",
+                "url": "https://api.github.com/repos/thephpleague/omnipay-common/zipball/24ea70aa6e0f76d8b85d7a35d8a6560c746f566f",
+                "reference": "24ea70aa6e0f76d8b85d7a35d8a6560c746f566f",
                 "shasum": "",
                 "mirrors": [
                     {
@@ -3424,13 +3426,13 @@
                 "php-http/client-implementation": "^1",
                 "php-http/discovery": "^1.2.1",
                 "php-http/message": "^1.5",
-                "symfony/http-foundation": "^2.1|^3|^4"
+                "symfony/http-foundation": "^2.1|^3|^4|^5"
             },
             "require-dev": {
                 "omnipay/tests": "^3",
                 "php-http/mock-client": "^1",
                 "phpro/grumphp": "^0.14",
-                "squizlabs/php_codesniffer": "^3"
+                "squizlabs/php_codesniffer": "^3.5"
             },
             "suggest": {
                 "league/omnipay": "The default Omnipay package provides a default HTTP Adapter."
@@ -3462,16 +3464,16 @@
                     "name": "Barry vd. Heuvel",
                     "email": "barryvdh@gmail.com"
                 },
-                {
-                    "name": "Omnipay Contributors",
-                    "homepage": "https://github.com/thephpleague/omnipay-common/contributors"
-                },
                 {
                     "name": "Jason Judge",
                     "email": "jason.judge@consil.co.uk"
                 },
                 {
                     "name": "Del"
+                },
+                {
+                    "name": "Omnipay Contributors",
+                    "homepage": "https://github.com/thephpleague/omnipay-common/contributors"
                 }
             ],
             "description": "Common components for Omnipay payment processing library",
@@ -3484,7 +3486,7 @@
                 "payment",
                 "purchase"
             ],
-            "time": "2018-05-15T08:36:43+00:00"
+            "time": "2020-02-12T12:28:23+00:00"
         },
         {
             "name": "openlss/lib-array2xml",
@@ -5060,12 +5062,12 @@
             "version": "2.0",
             "source": {
                 "type": "git",
-                "url": "https://github.com/ssrpanel/hcaptcha.git",
+                "url": "https://github.com/Scyllaly/hcaptcha.git",
                 "reference": "3536768d467270f95054375554060cf75c7b9198"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/ssrpanel/hcaptcha/zipball/3536768d467270f95054375554060cf75c7b9198",
+                "url": "https://api.github.com/repos/Scyllaly/hcaptcha/zipball/3536768d467270f95054375554060cf75c7b9198",
                 "reference": "3536768d467270f95054375554060cf75c7b9198",
                 "shasum": "",
                 "mirrors": [
@@ -5107,6 +5109,7 @@
                 "laravel5",
                 "ssrpanel"
             ],
+            "abandoned": "scyllaly/hcaptcha",
             "time": "2020-04-13T16:54:55+00:00"
         },
         {
@@ -8790,16 +8793,16 @@
         },
         {
             "name": "webmozart/assert",
-            "version": "1.7.0",
+            "version": "1.8.0",
             "source": {
                 "type": "git",
                 "url": "https://github.com/webmozart/assert.git",
-                "reference": "aed98a490f9a8f78468232db345ab9cf606cf598"
+                "reference": "ab2cb0b3b559010b75981b1bdce728da3ee90ad6"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/webmozart/assert/zipball/aed98a490f9a8f78468232db345ab9cf606cf598",
-                "reference": "aed98a490f9a8f78468232db345ab9cf606cf598",
+                "url": "https://api.github.com/repos/webmozart/assert/zipball/ab2cb0b3b559010b75981b1bdce728da3ee90ad6",
+                "reference": "ab2cb0b3b559010b75981b1bdce728da3ee90ad6",
                 "shasum": "",
                 "mirrors": [
                     {
@@ -8813,7 +8816,7 @@
                 "symfony/polyfill-ctype": "^1.8"
             },
             "conflict": {
-                "vimeo/psalm": "<3.6.0"
+                "vimeo/psalm": "<3.9.1"
             },
             "require-dev": {
                 "phpunit/phpunit": "^4.8.36 || ^7.5.13"
@@ -8840,7 +8843,7 @@
                 "check",
                 "validate"
             ],
-            "time": "2020-02-14T12:15:55+00:00"
+            "time": "2020-04-18T12:12:48+00:00"
         }
     ],
     "aliases": [],

+ 2 - 2
resources/views/admin/system.blade.php

@@ -781,8 +781,8 @@
 											<label class="col-md-3 col-form-label" for="is_notification">推送通知</label>
 											<select class="col-md-5" id="is_notification" data-plugin="selectpicker" data-style="btn-outline btn-primary" onchange="updateFromOther('select','is_notification')">
 												<option value="0">关闭</option>
-												<option value="1">ServerChan</option>
-												<option value="2">Bark</option>
+												<option value="serverChan">ServerChan</option>
+												<option value="bark">Bark</option>
 											</select>
 											<span class="text-help offset-md-3"> 推送节点离线提醒、用户流量异常警告、节点使用报告(<a href="javascript:sendTestNotification();">发送测试消息</a>)</span>
 										</div>

+ 2 - 2
resources/views/emails/nodeCrashWarning.blade.php

@@ -47,7 +47,7 @@
 												<th style="Margin:0;color:#333;font-family:Helvetica,Arial,sans-serif;font-size:16px;font-weight:400;line-height:19px;margin:0;padding:0;text-align:left">
 													<h6 style="Margin:0;Margin-bottom:10px;color:#f3f3f3;font-family:Helvetica,Arial,sans-serif;font-size:18px;font-weight:400;line-height:1.3;margin:0;margin-bottom:8px;margin-top:8px;padding:0;text-align:left;word-wrap:normal">
 														<a href="#" style="Margin:0;color:#f3f3f3;font-family:Helvetica,Arial,sans-serif;font-weight:400;line-height:1.3;margin:0;padding:0;text-align:left;text-decoration:none" target="_blank">
-															节点离线警告
+															节点阻断警告
 														</a>
 													</h6>
 												</th>
@@ -68,7 +68,7 @@
 								<tr style="padding:0;text-align:left;vertical-align:top">
 									<th style="Margin:0;color:#333;font-family:Helvetica,Arial,sans-serif;font-size:16px;font-weight:400;line-height:19px;margin:0;padding:0;text-align:left">
 										<div class="release" style="padding-top:5px;padding-left:20px;padding-bottom:20px;">
-											<p>节点【{{$nodeName}}】({{$nodeServer}})离线,请及时检查。</p>
+											<p>{{$content}}</p>
 										</div>
 									</th>
 									<th class="expander" style="Margin:0;color:#333;font-family:Helvetica,Arial,sans-serif;font-size:16px;font-weight:400;line-height:19px;margin:0;padding:0!important;text-align:left;visibility:hidden;width:0"></th>

+ 2 - 6
routes/web.php

@@ -24,7 +24,7 @@ Route::group(['middleware' => ['isForbidden','isAdminLogin', 'isAdmin']], functi
 		Route::get('', 'AdminController@index'); // 后台首页
 		Route::get('userList', 'AdminController@userList'); // 账号列表
 		Route::any('addUser', 'AdminController@addUser'); // 添加账号
-		Route::any('aeditUser/{id}', 'AdminController@editUser'); // 编辑账号
+		Route::any('editUser/{id}', 'AdminController@editUser'); // 编辑账号
 		Route::post('delUser', 'AdminController@delUser'); // 删除账号
 		Route::post('batchAddUsers', 'AdminController@batchAddUsers'); // 批量生成账号
 		Route::get('exportSSJson', 'AdminController@exportSSJson'); // 导出原版SS的json配置信息
@@ -161,12 +161,8 @@ Route::group(['middleware' => ['isForbidden', 'isMaintenance', 'isLogin']], func
 
 	Route::group(['prefix' => 'payment'], function(){
 		Route::post('purchase', 'PaymentController@purchase'); // 创建支付
+		Route::any('notify', 'PaymentController@notify'); //支付回调
 		Route::get('getStatus', 'PaymentController@getStatus'); // 获取支付单状态
 		Route::get('{sn}', 'PaymentController@detail'); // 支付单详情
 	});
 });
-
-// 第三方回调接口
-Route::group(['namespace' => 'Callback', 'prefix' => 'callback', 'middleware' => ['callback']], function(){
-	Route::any('payment', 'PaymentController@notify');
-});

+ 5 - 1
sql/mod/20200415.sql

@@ -1,8 +1,12 @@
+-- 添加码支付配置
 update `config` SET `name` = 'codepay_url', `value` = 'https://codepay.fateqq.com/creat_order/?' where `config`.`id` = 43;
 update `config` SET `name` = 'codepay_id', `value` = '' where `config`.`id` = 44;
 update `config` SET `name` = 'codepay_key', `value` = '' where `config`.`id` = 45;
+
+-- 添加 支付回调链接自定义
 update `config` SET `name` = 'website_callback_url', `value` = '' where `config`.`id` = 50;
 
+-- 在线支付数据库 简化
 alter table `payment`
   drop `order_sn`,
   drop `pay_way`,
@@ -11,7 +15,7 @@ alter table `payment`
   drop `qr_code`,
   drop `qr_local_url`;
 
-drop table `order_goods`
+drop table `order_goods`;
 
 ALTER TABLE `payment`
     ADD COLUMN `qr_code` text COLLATE utf8mb4_unicode_ci COMMENT '支付二维码' AFTER `amount`;

+ 3 - 0
sql/mod/20200419.sql

@@ -1,4 +1,7 @@
+-- 添加各类支付方式首选项
 update `config` SET `name` = 'is_AliPay', `value` = '' where `config`.`id` = 78;
 update `config` SET `name` = 'is_QQPay', `value` = '' where `config`.`id` = 79;
 update `config` SET `name` = 'is_WeChatPay', `value` = '' where `config`.`id` = 80;
+
+-- 添加 支付订单命称
 update `config` SET `name` = 'subject_name' where `config`.`id` = 91;

+ 3 - 0
sql/mod/20200420.sql

@@ -1,2 +1,5 @@
+-- 添加各类支付方式首选项
 update `config` SET `name` = 'is_otherPay', `value` = '' where `config`.`id` = 81;
+
+-- 添加麻瓜宝配置
 update `config` SET `name` = 'bitpay_secret', `value` = '' where `config`.`id` = 86;

+ 2 - 0
sql/mod/20200422.sql

@@ -0,0 +1,2 @@
+-- ÍÆËÍ֪ͨ ·½Ê½ÖØÖÃ
+update `config` SET `name` = 'is_notification', `value` = '0' where `config`.`id` = 39;