兔姬桑 5 жил өмнө
parent
commit
8ae52d8a2f
100 өөрчлөгдсөн 1958 нэмэгдсэн , 2011 устгасан
  1. 5 9
      app/Components/CaptchaVerify.php
  2. 8 10
      app/Components/Curl.php
  3. 47 64
      app/Components/Helpers.php
  4. 4 6
      app/Components/IPIP.php
  5. 18 21
      app/Components/Namesilo.php
  6. 17 20
      app/Components/NetworkDetection.php
  7. 16 20
      app/Components/PushNotification.php
  8. 13 17
      app/Components/QQInfo.php
  9. 4 6
      app/Components/QQWry.php
  10. 19 15
      app/Console/Commands/AutoClearLog.php
  11. 77 43
      app/Console/Commands/AutoJob.php
  12. 7 11
      app/Console/Commands/AutoPingNode.php
  13. 10 13
      app/Console/Commands/AutoReportNode.php
  14. 8 12
      app/Console/Commands/AutoStatisticsNodeDailyTraffic.php
  15. 8 12
      app/Console/Commands/AutoStatisticsNodeHourlyTraffic.php
  16. 8 12
      app/Console/Commands/AutoStatisticsUserDailyTraffic.php
  17. 8 12
      app/Console/Commands/AutoStatisticsUserHourlyTraffic.php
  18. 70 59
      app/Console/Commands/DailyJob.php
  19. 21 26
      app/Console/Commands/NodeBlockedDetection.php
  20. 31 22
      app/Console/Commands/ServiceTimer.php
  21. 9 13
      app/Console/Commands/UserExpireAutoWarning.php
  22. 21 14
      app/Console/Commands/UserTrafficAbnormalAutoWarning.php
  23. 9 13
      app/Console/Commands/UserTrafficAutoWarning.php
  24. 7 11
      app/Console/Commands/updateUserName.php
  25. 8 11
      app/Console/Commands/upgradeUserResetTime.php
  26. 4 7
      app/Console/Kernel.php
  27. 3 6
      app/Events/Event.php
  28. 23 16
      app/Exceptions/Handler.php
  29. 15 17
      app/Http/Controllers/Admin/AffiliateController.php
  30. 47 43
      app/Http/Controllers/Admin/CouponController.php
  31. 14 14
      app/Http/Controllers/Admin/MarketingController.php
  32. 12 12
      app/Http/Controllers/Admin/SensitiveWordsController.php
  33. 28 14
      app/Http/Controllers/Admin/ShopController.php
  34. 8 15
      app/Http/Controllers/Admin/SubscribeController.php
  35. 10 13
      app/Http/Controllers/Admin/TicketController.php
  36. 251 190
      app/Http/Controllers/AdminController.php
  37. 13 16
      app/Http/Controllers/Api/LoginController.php
  38. 3 5
      app/Http/Controllers/Api/PingController.php
  39. 110 101
      app/Http/Controllers/AuthController.php
  40. 38 55
      app/Http/Controllers/Controller.php
  41. 69 49
      app/Http/Controllers/Gateway/AbstractPayment.php
  42. 25 30
      app/Http/Controllers/Gateway/BitpayX.php
  43. 8 13
      app/Http/Controllers/Gateway/CodePay.php
  44. 15 19
      app/Http/Controllers/Gateway/F2Fpay.php
  45. 9 13
      app/Http/Controllers/Gateway/Local.php
  46. 13 19
      app/Http/Controllers/Gateway/PayJs.php
  47. 18 25
      app/Http/Controllers/Gateway/PayPal.php
  48. 23 26
      app/Http/Controllers/PaymentController.php
  49. 29 13
      app/Http/Controllers/ServiceController.php
  50. 26 16
      app/Http/Controllers/User/AffiliateController.php
  51. 21 18
      app/Http/Controllers/User/SubscribeController.php
  52. 168 97
      app/Http/Controllers/UserController.php
  53. 1 2
      app/Http/Kernel.php
  54. 4 6
      app/Http/Middleware/Affiliate.php
  55. 2 4
      app/Http/Middleware/CheckForMaintenanceMode.php
  56. 2 4
      app/Http/Middleware/EncryptCookies.php
  57. 5 7
      app/Http/Middleware/RedirectIfAuthenticated.php
  58. 5 7
      app/Http/Middleware/SetLocale.php
  59. 1 2
      app/Http/Middleware/TrimStrings.php
  60. 1 2
      app/Http/Middleware/TrustProxies.php
  61. 1 2
      app/Http/Middleware/VerifyCsrfToken.php
  62. 47 0
      app/Http/Middleware/WebApi.php
  63. 4 6
      app/Http/Middleware/isAdmin.php
  64. 4 6
      app/Http/Middleware/isAdminlogin.php
  65. 14 11
      app/Http/Middleware/isForbidden.php
  66. 4 6
      app/Http/Middleware/isLogin.php
  67. 9 8
      app/Http/Middleware/isMaintenance.php
  68. 7 7
      app/Http/Middleware/isSecurity.php
  69. 5 11
      app/Http/Models/Article.php
  70. 4 7
      app/Http/Models/Config.php
  71. 4 7
      app/Http/Models/Country.php
  72. 18 30
      app/Http/Models/Coupon.php
  73. 10 13
      app/Http/Models/CouponLog.php
  74. 6 23
      app/Http/Models/Device.php
  75. 16 28
      app/Http/Models/Goods.php
  76. 6 16
      app/Http/Models/GoodsLabel.php
  77. 19 28
      app/Http/Models/Invite.php
  78. 4 7
      app/Http/Models/Label.php
  79. 4 13
      app/Http/Models/Level.php
  80. 5 9
      app/Http/Models/Marketing.php
  81. 5 7
      app/Http/Models/NotificationLog.php
  82. 37 53
      app/Http/Models/Order.php
  83. 17 25
      app/Http/Models/Payment.php
  84. 12 32
      app/Http/Models/PaymentCallback.php
  85. 27 38
      app/Http/Models/ReferralApply.php
  86. 27 38
      app/Http/Models/ReferralLog.php
  87. 4 7
      app/Http/Models/SensitiveWords.php
  88. 6 11
      app/Http/Models/SsConfig.php
  89. 4 9
      app/Http/Models/SsGroup.php
  90. 4 7
      app/Http/Models/SsGroupNode.php
  91. 60 54
      app/Http/Models/SsNode.php
  92. 4 7
      app/Http/Models/SsNodeInfo.php
  93. 5 10
      app/Http/Models/SsNodeIp.php
  94. 9 13
      app/Http/Models/SsNodeLabel.php
  95. 4 7
      app/Http/Models/SsNodeOnlineLog.php
  96. 13 17
      app/Http/Models/SsNodePing.php
  97. 13 17
      app/Http/Models/SsNodeTrafficDaily.php
  98. 13 17
      app/Http/Models/SsNodeTrafficHourly.php
  99. 15 21
      app/Http/Models/Ticket.php
  100. 11 15
      app/Http/Models/TicketReply.php

+ 5 - 9
app/Components/CaptchaVerify.php

@@ -7,11 +7,9 @@ namespace App\Components;
  *
  * @package App\Components
  */
-class CaptchaVerify
-{
+class CaptchaVerify {
 	//从后台获取 hcaptcha_sitekey 和 hcaptcha_secret
-	public static function hCaptchaGetConfig()
-	{
+	public static function hCaptchaGetConfig() {
 		return [
 			"sitekey" => Helpers::systemConfig()["hcaptcha_sitekey"],
 			"secret"  => Helpers::systemConfig()["hcaptcha_secret"],
@@ -20,8 +18,7 @@ class CaptchaVerify
 	}
 
 	//从后台获取 Geetest_id 和 Geetest_key
-	public static function geetestCaptchaGetConfig()
-	{
+	public static function geetestCaptchaGetConfig() {
 		return [
 			"geetest_id"  => Helpers::systemConfig()["geetest_id"],
 			"geetest_key" => Helpers::systemConfig()["geetest_key"]
@@ -29,8 +26,7 @@ class CaptchaVerify
 	}
 
 	//从后台获取 google_captcha_sitekey 和 google_captcha_secret
-	public static function googleCaptchaGetConfig()
-	{
+	public static function googleCaptchaGetConfig() {
 		return [
 			"sitekey" => Helpers::systemConfig()["google_captcha_sitekey"],
 			"secret"  => Helpers::systemConfig()["google_captcha_secret"],
@@ -39,4 +35,4 @@ class CaptchaVerify
 	}
 }
 
-?>
+?>

+ 8 - 10
app/Components/Curl.php

@@ -2,21 +2,19 @@
 
 namespace App\Components;
 
-class Curl
-{
+class Curl {
 	/**
-	 * @param string $url  请求地址
-	 * @param array  $data 数据,如果有数据则用POST请求
+	 * @param  string  $url   请求地址
+	 * @param  array   $data  数据,如果有数据则用POST请求
 	 *
 	 * @return mixed
 	 */
-	public static function send($url, $data = [])
-	{
+	public static function send($url, $data = []) {
 		$ch = curl_init();
-		curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
+		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
 		curl_setopt($ch, CURLOPT_TIMEOUT, 60);
-		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
-		curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
+		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
+		curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
 		curl_setopt($ch, CURLOPT_URL, $url);
 
 		if($data){
@@ -29,4 +27,4 @@ class Curl
 
 		return $result;
 	}
-}
+}

+ 47 - 64
app/Components/Helpers.php

@@ -12,8 +12,7 @@ use App\Http\Models\UserBalanceLog;
 use App\Http\Models\UserSubscribe;
 use App\Http\Models\UserTrafficModifyLog;
 
-class Helpers
-{
+class Helpers {
 	// 不生成的端口
 	private static $denyPorts = [
 		1068, 1109, 1434, 3127, 3128,
@@ -24,32 +23,27 @@ class Helpers
 	];
 
 	// 加密方式
-	public static function methodList()
-	{
+	public static function methodList() {
 		return SsConfig::type(1)->get();
 	}
 
 	// 协议
-	public static function protocolList()
-	{
+	public static function protocolList() {
 		return SsConfig::type(2)->get();
 	}
 
 	// 混淆
-	public static function obfsList()
-	{
+	public static function obfsList() {
 		return SsConfig::type(3)->get();
 	}
 
 	// 等级
-	public static function levelList()
-	{
+	public static function levelList() {
 		return Level::query()->get()->sortBy('level');
 	}
 
 	// 生成用户的订阅码
-	public static function makeSubscribeCode()
-	{
+	public static function makeSubscribeCode() {
 		$code = makeRandStr(5);
 		if(UserSubscribe::query()->whereCode($code)->exists()){
 			$code = self::makeSubscribeCode();
@@ -61,16 +55,15 @@ class Helpers
 	/**
 	 * 添加用户
 	 *
-	 * @param string $email           用户邮箱
-	 * @param string $password        用户密码
-	 * @param string $transfer_enable 可用流量
-	 * @param int    $data            可使用天数
-	 * @param int    $referral_uid    邀请人
+	 * @param  string  $email            用户邮箱
+	 * @param  string  $password         用户密码
+	 * @param  string  $transfer_enable  可用流量
+	 * @param  int     $data             可使用天数
+	 * @param  int     $referral_uid     邀请人
 	 *
 	 * @return int
 	 */
-	public static function addUser($email, $password, $transfer_enable, $data, $referral_uid = 0)
-	{
+	public static function addUser($email, $password, $transfer_enable, $data, $referral_uid = 0) {
 		$user = new User();
 		$user->username = $email;
 		$user->email = $email;
@@ -91,7 +84,7 @@ class Helpers
 		$user->expire_time = date('Y-m-d', strtotime("+".$data." days"));
 		$user->reg_ip = getClientIp();
 		$user->referral_uid = $referral_uid;
-		$user->reset_time = NULL;
+		$user->reset_time = null;
 		$user->status = 0;
 		$user->save();
 
@@ -99,22 +92,20 @@ class Helpers
 	}
 
 	// 获取系统配置
-	public static function systemConfig()
-	{
+	public static function systemConfig() {
 		$config = Config::query()->get();
 		$data = [];
 		foreach($config as $vo){
 			$data[$vo->name] = $vo->value;
 		}
 
-		$data['is_onlinePay'] = ($data['is_AliPay'] || $data['is_QQPay'] || $data['is_WeChatPay'] || $data['is_otherPay'])? : 0;
+		$data['is_onlinePay'] = ($data['is_AliPay'] || $data['is_QQPay'] || $data['is_WeChatPay'] || $data['is_otherPay'])?: 0;
 
 		return $data;
 	}
 
 	// 获取一个随机端口
-	public static function getRandPort()
-	{
+	public static function getRandPort() {
 		$config = self::systemConfig();
 		$port = mt_rand($config['min_port'], $config['max_port']);
 
@@ -127,38 +118,34 @@ class Helpers
 	}
 
 	// 获取一个随机端口
-	public static function getOnlyPort()
-	{
+	public static function getOnlyPort() {
 		$config = self::systemConfig();
 		$port = $config['min_port'];
 
 		$exists_port = User::query()->where('port', '>=', $port)->pluck('port')->toArray();
 		while(in_array($port, $exists_port) || in_array($port, self::$denyPorts)){
-			$port = $port+1;
+			$port = $port + 1;
 		}
 
 		return $port;
 	}
 
 	// 获取默认加密方式
-	public static function getDefaultMethod()
-	{
+	public static function getDefaultMethod() {
 		$config = SsConfig::default()->type(1)->first();
 
 		return $config? $config->name : 'aes-256-cfb';
 	}
 
 	// 获取默认协议
-	public static function getDefaultProtocol()
-	{
+	public static function getDefaultProtocol() {
 		$config = SsConfig::default()->type(2)->first();
 
 		return $config? $config->name : 'origin';
 	}
 
 	// 获取默认混淆
-	public static function getDefaultObfs()
-	{
+	public static function getDefaultObfs() {
 		$config = SsConfig::default()->type(3)->first();
 
 		return $config? $config->name : 'plain';
@@ -167,17 +154,16 @@ class Helpers
 	/**
 	 * 添加通知推送日志
 	 *
-	 * @param string $title   标题
-	 * @param string $content 内容
-	 * @param int    $type    发送类型
-	 * @param string $address 收信方
-	 * @param int    $status  投递状态
-	 * @param string $error   投递失败时记录的异常信息
+	 * @param  string  $title    标题
+	 * @param  string  $content  内容
+	 * @param  int     $type     发送类型
+	 * @param  string  $address  收信方
+	 * @param  int     $status   投递状态
+	 * @param  string  $error    投递失败时记录的异常信息
 	 *
 	 * @return int
 	 */
-	public static function addNotificationLog($title, $content, $type, $address = 'admin', $status = 1, $error = '')
-	{
+	public static function addNotificationLog($title, $content, $type, $address = 'admin', $status = 1, $error = '') {
 		$log = new NotificationLog();
 		$log->type = $type;
 		$log->address = $address;
@@ -193,15 +179,14 @@ class Helpers
 	/**
 	 * 添加优惠券操作日志
 	 *
-	 * @param int    $couponId 优惠券ID
-	 * @param int    $goodsId  商品ID
-	 * @param int    $orderId  订单ID
-	 * @param string $desc     备注
+	 * @param  int     $couponId  优惠券ID
+	 * @param  int     $goodsId   商品ID
+	 * @param  int     $orderId   订单ID
+	 * @param  string  $desc      备注
 	 *
 	 * @return int
 	 */
-	public static function addCouponLog($couponId, $goodsId, $orderId, $desc = '')
-	{
+	public static function addCouponLog($couponId, $goodsId, $orderId, $desc = '') {
 		$log = new CouponLog();
 		$log->coupon_id = $couponId;
 		$log->goods_id = $goodsId;
@@ -214,17 +199,16 @@ class Helpers
 	/**
 	 * 记录余额操作日志
 	 *
-	 * @param int    $userId 用户ID
-	 * @param string $oid    订单ID
-	 * @param int    $before 记录前余额
-	 * @param int    $after  记录后余额
-	 * @param int    $amount 发生金额
-	 * @param string $desc   描述
+	 * @param  int     $userId  用户ID
+	 * @param  string  $oid     订单ID
+	 * @param  int     $before  记录前余额
+	 * @param  int     $after   记录后余额
+	 * @param  int     $amount  发生金额
+	 * @param  string  $desc    描述
 	 *
 	 * @return int
 	 */
-	public static function addUserBalanceLog($userId, $oid, $before, $after, $amount, $desc = '')
-	{
+	public static function addUserBalanceLog($userId, $oid, $before, $after, $amount, $desc = '') {
 		$log = new UserBalanceLog();
 		$log->user_id = $userId;
 		$log->order_id = $oid;
@@ -240,16 +224,15 @@ class Helpers
 	/**
 	 * 记录流量变动日志
 	 *
-	 * @param int    $userId 用户ID
-	 * @param string $oid    订单ID
-	 * @param int    $before 记录前的值
-	 * @param int    $after  记录后的值
-	 * @param string $desc   描述
+	 * @param  int     $userId  用户ID
+	 * @param  string  $oid     订单ID
+	 * @param  int     $before  记录前的值
+	 * @param  int     $after   记录后的值
+	 * @param  string  $desc    描述
 	 *
 	 * @return int
 	 */
-	public static function addUserTrafficModifyLog($userId, $oid, $before, $after, $desc = '')
-	{
+	public static function addUserTrafficModifyLog($userId, $oid, $before, $after, $desc = '') {
 		$log = new UserTrafficModifyLog();
 		$log->user_id = $userId;
 		$log->order_id = $oid;
@@ -259,4 +242,4 @@ class Helpers
 
 		return $log->save();
 	}
-}
+}

+ 4 - 6
app/Components/IPIP.php

@@ -4,20 +4,18 @@ namespace App\Components;
 
 use ipip\db\City;
 
-class IPIP
-{
+class IPIP {
 	/**
 	 * 查询IP地址的详细信息
 	 *
-	 * @param string $ip IPv4
+	 * @param  string  $ip  IPv4
 	 *
 	 * @return array|null
 	 */
-	public static function ip($ip)
-	{
+	public static function ip($ip) {
 		$filePath = public_path('ipip.ipdb');
 		$loc = new City($filePath);
 
 		return $loc->findMap($ip, 'CN');
 	}
-}
+}

+ 18 - 21
app/Components/Namesilo.php

@@ -6,26 +6,22 @@ use Exception;
 use Log;
 use LSS\XML2Array;
 
-class Namesilo
-{
+class Namesilo {
 	protected static $host;
 	protected static $systemConfig;
 
-	function __construct()
-	{
+	function __construct() {
 		self::$host = 'https://www.namesilo.com/api/';
 		self::$systemConfig = Helpers::systemConfig();
 	}
 
 	// 列出账号下所有域名
-	public function listDomains()
-	{
+	public function listDomains() {
 		return $this->send('listDomains');
 	}
 
 	// 发送请求
-	private function send($operation, $data = [])
-	{
+	private function send($operation, $data = []) {
 		$params = [
 			'version' => 1,
 			'type'    => 'xml',
@@ -41,23 +37,27 @@ class Namesilo
 
 			// 出错
 			if(empty($result['namesilo']) || $result['namesilo']['reply']['code'] != 300 || $result['namesilo']['reply']['detail'] != 'success'){
-				Helpers::addNotificationLog('[Namesilo API] - ['.$operation.']', $content, 1, self::$systemConfig['webmaster_email'], 0, $result['namesilo']['reply']['detail']);
+				Helpers::addNotificationLog('[Namesilo API] - ['.$operation.']', $content, 1,
+				                            self::$systemConfig['webmaster_email'], 0,
+				                            $result['namesilo']['reply']['detail']);
 			}else{
-				Helpers::addNotificationLog('[Namesilo API] - ['.$operation.']', $content, 1, self::$systemConfig['webmaster_email'], 1, $result['namesilo']['reply']['detail']);
+				Helpers::addNotificationLog('[Namesilo API] - ['.$operation.']', $content, 1,
+				                            self::$systemConfig['webmaster_email'], 1,
+				                            $result['namesilo']['reply']['detail']);
 			}
 
 			return $result['namesilo']['reply'];
 		}catch(Exception $e){
 			Log::error('CURL请求失败:'.$e->getMessage().' --- '.$e->getLine());
-			Helpers::addNotificationLog('[Namesilo API] - ['.$operation.']', $content, 1, self::$systemConfig['webmaster_email'], 0, $e->getMessage());
+			Helpers::addNotificationLog('[Namesilo API] - ['.$operation.']', $content, 1,
+			                            self::$systemConfig['webmaster_email'], 0, $e->getMessage());
 
-			return FALSE;
+			return false;
 		}
 	}
 
 	// 列出指定域名的所有DNS记录
-	public function dnsListRecords($domain)
-	{
+	public function dnsListRecords($domain) {
 		$query = [
 			'domain' => $domain
 		];
@@ -66,8 +66,7 @@ class Namesilo
 	}
 
 	// 为指定域名添加DNS记录
-	public function dnsAddRecord($domain, $host, $value, $type = 'A', $ttl = 7207)
-	{
+	public function dnsAddRecord($domain, $host, $value, $type = 'A', $ttl = 7207) {
 		$query = [
 			'domain'  => $domain,
 			'rrtype'  => $type,
@@ -80,8 +79,7 @@ class Namesilo
 	}
 
 	// 更新DNS记录
-	public function dnsUpdateRecord($domain, $id, $host, $value, $ttl = 7207)
-	{
+	public function dnsUpdateRecord($domain, $id, $host, $value, $ttl = 7207) {
 		$query = [
 			'domain'  => $domain,
 			'rrid'    => $id,
@@ -94,8 +92,7 @@ class Namesilo
 	}
 
 	// 删除DNS记录
-	public function dnsDeleteRecord($domain, $id)
-	{
+	public function dnsDeleteRecord($domain, $id) {
 		$data = [
 			'domain' => $domain,
 			'rrid'   => $id
@@ -103,4 +100,4 @@ class Namesilo
 
 		return $this->send('dnsDeleteRecord', $data);
 	}
-}
+}

+ 17 - 20
app/Components/NetworkDetection.php

@@ -5,45 +5,43 @@ namespace App\Components;
 use Exception;
 use Log;
 
-class NetworkDetection
-{
+class NetworkDetection {
 	/**
 	 * 用api.50network.com进行节点阻断检测
 	 *
-	 * @param string  $ip   被检测的IP
-	 * @param boolean $type TRUE 为ICMP,FALSE 为tcp
-	 * @param int     $port 检测端口,默认为空
+	 * @param  string   $ip    被检测的IP
+	 * @param  boolean  $type  TRUE 为ICMP,FALSE 为tcp
+	 * @param  int      $port  检测端口,默认为空
 	 *
 	 * @return bool|string
 	 */
-	public static function networkCheck($ip, $type, $port = NULL)
-	{
+	public static function networkCheck($ip, $type, $port = null) {
 		$url = 'https://api.50network.com/china-firewall/check/ip/'.($type? 'icmp/' : ($port? 'tcp_port/' : 'tcp_ack/')).$ip.($port? '/'.$port : '');
 		$checkName = $type? 'ICMP' : 'TCP';
 
 		try{
-			$ret = json_decode(Curl::send($url), TRUE);
+			$ret = json_decode(Curl::send($url), true);
 			if(!$ret){
 				Log::warning("【".$checkName."阻断检测】检测".$ip."时,接口返回异常访问链接:".$url);
 
-				return FALSE;
+				return false;
 			}elseif(!$ret['success']){
 				if($ret['error'] == "execute timeout (3s)"){
 					sleep(10);
 
 					return self::networkCheck($ip, $type, $port);
 				}else{
-					Log::warning("【".$checkName."阻断检测】检测".$ip.($port? : '')."时,返回".json_encode($ret));
+					Log::warning("【".$checkName."阻断检测】检测".$ip.($port?: '')."时,返回".json_encode($ret));
 
 				}
 
 
-				return FALSE;
+				return false;
 			}
 		}catch(Exception $e){
 			Log::warning("【".$checkName."阻断检测】检测".$ip."时,接口请求超时".$e);
 
-			return FALSE;
+			return false;
 		}
 
 		if($ret['firewall-enable'] && $ret['firewall-disable']){
@@ -60,33 +58,32 @@ class NetworkDetection
 	/**
 	 * 用api.iiwl.cc进行Ping检测
 	 *
-	 * @param string $ip 被检测的IP或者域名
+	 * @param  string  $ip  被检测的IP或者域名
 	 *
 	 * @return bool|array
 	 */
-	public static function ping($ip)
-	{
+	public static function ping($ip) {
 		$url = 'https://api.iiwl.cc/api/ping.php?url='.$ip;
 
 		try{
-			$ret = json_decode(Curl::send($url), TRUE);
+			$ret = json_decode(Curl::send($url), true);
 			if(!$ret){
 				Log::warning("【PING】检测".$ip."时,接口返回异常访问链接:".$url);
 
-				return FALSE;
+				return false;
 			}elseif($ret['code'] != 1 || $ret['msg'] != "检测成功!"){
 				Log::warning("【PING】检测".$ip."时,返回".json_encode($ret));
 
-				return FALSE;
+				return false;
 			}
 		}catch(Exception $e){
 			Log::warning("【Ping】检测".$ip."时,接口请求超时".$e);
 
-			return FALSE;
+			return false;
 		}
 
 		return $ret['data']; // 服务器宕机
 	}
 }
 
-?>
+?>

+ 16 - 20
app/Components/PushNotification.php

@@ -7,10 +7,8 @@ use Exception;
 use Log;
 use stdClass;
 
-class PushNotification
-{
-	public static function send($title, $content)
-	{
+class PushNotification {
+	public static function send($title, $content) {
 		switch(Helpers::systemConfig()['is_notification']){
 			case 'serverChan':
 				return self::ServerChan($title, $content);
@@ -19,33 +17,32 @@ class PushNotification
 				return self::Bark($title, $content);
 				break;
 			default:
-				return FALSE;
+				return false;
 		}
 	}
 
 	/**
 	 * ServerChan推送消息
 	 *
-	 * @param string $title   消息标题
-	 * @param string $content 消息内容
+	 * @param  string  $title    消息标题
+	 * @param  string  $content  消息内容
 	 *
 	 * @return mixed
 	 */
-	private static function ServerChan($title, $content)
-	{
-		$ret = FALSE;
+	private static function ServerChan($title, $content) {
+		$ret = false;
 		try{
 			// TODO:一天仅可发送不超过500条
 			$url = 'https://sc.ftqq.com/'.Helpers::systemConfig()['server_chan_key'].'.send?text='.$title.'&desp='.urlencode($content);
 			$result = json_decode(Curl::send($url));
 			if(empty(Helpers::systemConfig()['server_chan_key'])){
 				$result = new stdClass();
-				$result->errno = TRUE;
+				$result->errno = true;
 				$result->errmsg = "未正确配置ServerChan";
 			}
-			if($result != NULL && !$result->errno){
+			if($result != null && !$result->errno){
 				Helpers::addNotificationLog($title, $content, 2);
-				$ret = TRUE;
+				$ret = true;
 			}else{
 				Helpers::addNotificationLog($title, $content, 2, 'admin', 1, $result? $result->errmsg : '未知');
 			}
@@ -60,21 +57,20 @@ class PushNotification
 	/**
 	 * Bark推送消息
 	 *
-	 * @param string $title   消息标题
-	 * @param string $content 消息内容
+	 * @param  string  $title    消息标题
+	 * @param  string  $content  消息内容
 	 *
 	 * @return mixed
 	 */
-	private static function Bark($title, $content)
-	{
-		$ret = FALSE;
+	private static function Bark($title, $content) {
+		$ret = false;
 		try{
 			$url = 'https://api.day.app/'.Helpers::systemConfig()['bark_key'].'/'.$title.'/'.$content;
 			$result = json_decode(Curl::send($url));
 			if($result){
 				if($result->code == 200){
 					Helpers::addNotificationLog($title, $content, 3);
-					$ret = TRUE;
+					$ret = true;
 				}else{
 					Helpers::addNotificationLog($title, $content, 3, 'admin', $result->message);
 				}
@@ -85,4 +81,4 @@ class PushNotification
 
 		return $ret;
 	}
-}
+}

+ 13 - 17
app/Components/QQInfo.php

@@ -2,41 +2,38 @@
 
 namespace App\Components;
 
-class QQInfo
-{
+class QQInfo {
 	/**
 	 * 通过QQ号查询头像与昵称信息
 	 *
-	 * @param string $qq QQ号
+	 * @param  string  $qq  QQ号
 	 *
 	 * @return string
 	 */
-	public static function getName($qq)
-	{
+	public static function getName($qq) {
 
 		//向接口发起请求获取json数据
 		$url = 'https://r.qzone.qq.com/fcg-bin/cgi_get_portrait.fcg?get_nick=1&uins='.$qq;
 		$ret = mb_convert_encoding(Curl::send($url), "UTF-8", "GBK");
 		// 接口是否异常
 		//echo $ret;
-		if(strpos($ret, $qq) !== FALSE){
+		if(strpos($ret, $qq) !== false){
 			//对获取的json数据进行截取并解析成数组
-			$ret = json_decode(substr($ret, 17, -1), TRUE);
+			$ret = json_decode(substr($ret, 17, -1), true);
 
 			return stripslashes($ret[$qq][6]);
 		}
 
 		echo $qq.PHP_EOL;
 
-		return FALSE;
+		return false;
 	}
 
-	public static function getName2($qq)
-	{
+	public static function getName2($qq) {
 
 		//向接口发起请求获取json数据
 		$url = 'https://api.toubiec.cn/qq?qq='.$qq.'&size=100';
-		$ret = json_decode(Curl::send($url), TRUE);
+		$ret = json_decode(Curl::send($url), true);
 		// 接口是否异常
 		if($ret){
 			if($ret['code'] == 200){
@@ -46,14 +43,13 @@ class QQInfo
 
 		echo $qq.PHP_EOL;
 
-		return FALSE;
+		return false;
 	}
 
-	public static function getName3($qq)
-	{
+	public static function getName3($qq) {
 		//向接口发起请求获取json数据
 		$url = 'https://api.unipay.qq.com/v1/r/1450000186/wechat_query?cmd=1&pf=mds_storeopen_qb-__mds_qqclub_tab_-html5&pfkey=pfkey&from_h5=1&from_https=1&openid=openid&openkey=openkey&session_id=hy_gameid&session_type=st_dummy&qq_appid=&offerId=1450000186&sandbox=&provide_uin='.$qq;
-		$ret = json_decode(Curl::send($url), TRUE);
+		$ret = json_decode(Curl::send($url), true);
 		// 接口是否异常
 		if($ret){
 			if($ret['ret'] == 0){
@@ -63,6 +59,6 @@ class QQInfo
 
 		echo $qq.PHP_EOL;
 
-		return FALSE;
+		return false;
 	}
-}
+}

+ 4 - 6
app/Components/QQWry.php

@@ -4,19 +4,17 @@ namespace App\Components;
 
 use itbdw\Ip\IpLocation;
 
-class QQWry
-{
+class QQWry {
 	/**
 	 * 查询IP地址的详细信息
 	 *
-	 * @param string $ip IPv4
+	 * @param  string  $ip  IPv4
 	 *
 	 * @return array
 	 */
-	public static function ip($ip)
-	{
+	public static function ip($ip) {
 		$filePath = public_path('qqwry.dat');
 
 		return IpLocation::getLocation($ip, $filePath);
 	}
-}
+}

+ 19 - 15
app/Console/Commands/AutoClearLog.php

@@ -18,34 +18,30 @@ use Exception;
 use Illuminate\Console\Command;
 use Log;
 
-class AutoClearLog extends Command
-{
+class AutoClearLog extends Command {
 	protected $signature = 'autoClearLog';
 	protected $description = '自动清除日志';
 
-	public function __construct()
-	{
+	public function __construct() {
 		parent::__construct();
 	}
 
-	public function handle()
-	{
-		$jobStartTime = microtime(TRUE);
+	public function handle() {
+		$jobStartTime = microtime(true);
 
 		// 清除日志
 		if(Helpers::systemConfig()['is_clear_log']){
 			$this->clearLog();
 		}
 
-		$jobEndTime = microtime(TRUE);
-		$jobUsedTime = round(($jobEndTime-$jobStartTime), 4);
+		$jobEndTime = microtime(true);
+		$jobUsedTime = round(($jobEndTime - $jobStartTime), 4);
 
 		Log::info('---【'.$this->description.'】完成---,耗时'.$jobUsedTime.'秒');
 	}
 
 	// 清除日志
-	private function clearLog()
-	{
+	private function clearLog() {
 		// 自动清除30分钟以前的节点负载信息日志
 		try{
 			SsNodeInfo::query()->where('log_time', '<=', strtotime("-30 minutes"))->delete();
@@ -60,13 +56,19 @@ class AutoClearLog extends Command
 			UserTrafficHourly::query()->where('created_at', '<=', date('Y-m-d H:i:s', strtotime('-3 days')))->delete();
 
 			// 自动清除1个月以前的用户每天流量数据日志
-			UserTrafficDaily::query()->where('created_at', '<=', date('Y-m-d H:i:s', strtotime('-1 month 5 days')))->delete();
+			UserTrafficDaily::query()
+			                ->where('created_at', '<=', date('Y-m-d H:i:s', strtotime('-1 month 5 days')))
+			                ->delete();
 
 			// 自动清除2个月以前的节点每小时流量数据日志
-			SsNodeTrafficHourly::query()->where('created_at', '<=', date('Y-m-d H:i:s', strtotime('-2 month')))->delete();
+			SsNodeTrafficHourly::query()
+			                   ->where('created_at', '<=', date('Y-m-d H:i:s', strtotime('-2 month')))
+			                   ->delete();
 
 			// 自动清除3个月以前的节点每天流量数据日志
-			SsNodeTrafficDaily::query()->where('created_at', '<=', date('Y-m-d H:i:s', strtotime('-3 month')))->delete();
+			SsNodeTrafficDaily::query()
+			                  ->where('created_at', '<=', date('Y-m-d H:i:s', strtotime('-3 month')))
+			                  ->delete();
 
 			// 自动清除30天以前用户封禁日志
 			UserBanLog::query()->where('created_at', '<=', date('Y-m-d H:i:s', strtotime("-1 month")))->delete();
@@ -78,7 +80,9 @@ class AutoClearLog extends Command
 			UserLoginLog::query()->where('created_at', '<=', date('Y-m-d H:i:s', strtotime("-3 month")))->delete();
 
 			// 自动清除1个月前的用户订阅记录
-			UserSubscribeLog::query()->where('request_time', '<=', date('Y-m-d H:i:s', strtotime("-1 month")))->delete();
+			UserSubscribeLog::query()
+			                ->where('request_time', '<=', date('Y-m-d H:i:s', strtotime("-1 month")))
+			                ->delete();
 		}catch(Exception $e){
 			Log::error('【清理日志】错误: '.$e->getMessage());
 		}

+ 77 - 43
app/Console/Commands/AutoJob.php

@@ -23,14 +23,12 @@ use Exception;
 use Illuminate\Console\Command;
 use Log;
 
-class AutoJob extends Command
-{
+class AutoJob extends Command {
 	protected static $systemConfig;
 	protected $signature = 'autoJob';
 	protected $description = '自动化任务';
 
-	public function __construct()
-	{
+	public function __construct() {
 		parent::__construct();
 		self::$systemConfig = Helpers::systemConfig();
 	}
@@ -38,9 +36,8 @@ class AutoJob extends Command
 	/*
 	 * 警告:除非熟悉业务流程,否则不推荐更改以下执行顺序,随意变更以下顺序可能导致系统异常
 	 */
-	public function handle()
-	{
-		$jobStartTime = microtime(TRUE);
+	public function handle() {
+		$jobStartTime = microtime(true);
 
 		// 关闭超时未支付在线订单
 		$this->closePayments();
@@ -74,17 +71,19 @@ class AutoJob extends Command
 			}
 		}
 
-		$jobEndTime = microtime(TRUE);
-		$jobUsedTime = round(($jobEndTime-$jobStartTime), 4);
+		$jobEndTime = microtime(true);
+		$jobUsedTime = round(($jobEndTime - $jobStartTime), 4);
 
 		Log::info('---【'.$this->description.'】完成---,耗时'.$jobUsedTime.'秒');
 	}
 
 	// 关闭超时未在线支付订单
-	private function closePayments()
-	{
+	private function closePayments() {
 		// 关闭超时未支付的在线支付订单(在线支付收款二维码超过30分钟自动关闭,关闭后无法再支付,所以我们限制15分钟内必须付款)
-		$paymentList = Payment::query()->whereStatus(0)->where('created_at', '<=', date("Y-m-d H:i:s", strtotime("-15 minutes")))->get();
+		$paymentList = Payment::query()
+		                      ->whereStatus(0)
+		                      ->where('created_at', '<=', date("Y-m-d H:i:s", strtotime("-15 minutes")))
+		                      ->get();
 		if($paymentList->isNotEmpty()){
 			DB::beginTransaction();
 			try{
@@ -99,7 +98,8 @@ class AutoJob extends Command
 					if($payment->order->coupon_id){
 						Coupon::query()->whereId($payment->order->coupon_id)->update(['status' => 0]);
 
-						Helpers::addCouponLog($payment->order->coupon_id, $payment->order->goods_id, $payment->oid, '在线订单超时未支付,自动退回');
+						Helpers::addCouponLog($payment->order->coupon_id, $payment->order->goods_id, $payment->oid,
+						                      '在线订单超时未支付,自动退回');
 					}
 				}
 
@@ -113,10 +113,12 @@ class AutoJob extends Command
 	}
 
 	// 关闭超时未支付订单
-	private function closeOrders()
-	{
+	private function closeOrders() {
 		// 关闭超时未支付的在线支付订单(在线支付收款二维码超过30分钟自动关闭,关闭后无法再支付,所以我们限制15分钟内必须付款)
-		$orderList = Order::query()->whereStatus(0)->where('created_at', '<=', date("Y-m-d H:i:s", strtotime("-30 minutes")))->get();
+		$orderList = Order::query()
+		                  ->whereStatus(0)
+		                  ->where('created_at', '<=', date("Y-m-d H:i:s", strtotime("-30 minutes")))
+		                  ->get();
 		if($orderList->isNotEmpty()){
 			DB::beginTransaction();
 			try{
@@ -142,10 +144,12 @@ class AutoJob extends Command
 	}
 
 	// 注册验证码自动置无效
-	private function expireCode()
-	{
+	private function expireCode() {
 		// 注册验证码自动置无效
-		VerifyCode::query()->whereStatus(0)->where('created_at', '<=', date('Y-m-d H:i:s', strtotime("-10 minutes")))->update(['status' => 2]);
+		VerifyCode::query()
+		          ->whereStatus(0)
+		          ->where('created_at', '<=', date('Y-m-d H:i:s', strtotime("-10 minutes")))
+		          ->update(['status' => 2]);
 
 		// 优惠券到期自动置无效
 		Coupon::query()->whereStatus(0)->where('available_end', '<=', time())->update(['status' => 2]);
@@ -155,17 +159,25 @@ class AutoJob extends Command
 	}
 
 	// 封禁访问异常的订阅链接
-	private function blockSubscribe()
-	{
+	private function blockSubscribe() {
 		if(self::$systemConfig['is_subscribe_ban']){
 			$userList = User::query()->where('status', '>=', 0)->whereEnable(1)->get();
 			foreach($userList as $user){
 				$subscribe = UserSubscribe::query()->whereUserId($user->id)->first();
 				if($subscribe){
 					// 24小时内不同IP的请求次数
-					$request_times = UserSubscribeLog::query()->whereSid($subscribe->id)->where('request_time', '>=', date("Y-m-d H:i:s", strtotime("-24 hours")))->distinct('request_ip')->count('request_ip');
+					$request_times = UserSubscribeLog::query()
+					                                 ->whereSid($subscribe->id)
+					                                 ->where('request_time', '>=',
+					                                         date("Y-m-d H:i:s", strtotime("-24 hours")))
+					                                 ->distinct('request_ip')
+					                                 ->count('request_ip');
 					if($request_times >= self::$systemConfig['subscribe_ban_times']){
-						UserSubscribe::query()->whereId($subscribe->id)->update(['status' => 0, 'ban_time' => time(), 'ban_desc' => '存在异常,自动封禁']);
+						UserSubscribe::query()->whereId($subscribe->id)->update([
+							                                                        'status'   => 0,
+							                                                        'ban_time' => time(),
+							                                                        'ban_desc' => '存在异常,自动封禁'
+						                                                        ]);
 
 						// 记录封禁日志
 						$this->addUserBanLog($subscribe->user_id, 0, '【完全封禁订阅】-订阅24小时内请求异常');
@@ -178,12 +190,11 @@ class AutoJob extends Command
 	/**
 	 * 添加用户封禁日志
 	 *
-	 * @param int    $userId  用户ID
-	 * @param int    $minutes 封禁时长,单位分钟
-	 * @param string $desc    封禁理由
+	 * @param  int     $userId   用户ID
+	 * @param  int     $minutes  封禁时长,单位分钟
+	 * @param  string  $desc     封禁理由
 	 */
-	private function addUserBanLog($userId, $minutes, $desc)
-	{
+	private function addUserBanLog($userId, $minutes, $desc) {
 		$log = new UserBanLog();
 		$log->user_id = $userId;
 		$log->minutes = $minutes;
@@ -192,8 +203,7 @@ class AutoJob extends Command
 	}
 
 	// 封禁账号
-	private function blockUsers()
-	{
+	private function blockUsers() {
 		// 封禁1小时内流量异常账号
 		if(self::$systemConfig['is_traffic_ban']){
 			$userList = User::query()->whereEnable(1)->where('status', '>=', 0)->whereBanTime(0)->get();
@@ -204,9 +214,17 @@ class AutoJob extends Command
 				}
 
 				// 多往前取5分钟,防止数据统计任务执行时间过长导致没有数据
-				$totalTraffic = UserTrafficHourly::query()->whereUserId($user->id)->whereNodeId(0)->where('created_at', '>=', date('Y-m-d H:i:s', time()-3900))->sum('total');
-				if($totalTraffic >= (self::$systemConfig['traffic_ban_value']*1073741824)){
-					User::query()->whereId($user->id)->update(['enable' => 0, 'ban_time' => strtotime(date('Y-m-d H:i:s', strtotime("+".self::$systemConfig['traffic_ban_time']." minutes")))]);
+				$totalTraffic = UserTrafficHourly::query()
+				                                 ->whereUserId($user->id)
+				                                 ->whereNodeId(0)
+				                                 ->where('created_at', '>=', date('Y-m-d H:i:s', time() - 3900))
+				                                 ->sum('total');
+				if($totalTraffic >= (self::$systemConfig['traffic_ban_value'] * 1073741824)){
+					User::query()->whereId($user->id)->update([
+						                                          'enable'   => 0,
+						                                          'ban_time' => strtotime(date('Y-m-d H:i:s',
+						                                                                       strtotime("+".self::$systemConfig['traffic_ban_time']." minutes")))
+					                                          ]);
 
 					// 写入日志
 					$this->addUserBanLog($user->id, self::$systemConfig['traffic_ban_time'], '【临时封禁代理】-1小时内流量异常');
@@ -215,7 +233,12 @@ class AutoJob extends Command
 		}
 
 		// 禁用流量超限用户
-		$userList = User::query()->whereEnable(1)->where('status', '>=', 0)->whereBanTime(0)->whereRaw("u + d >= transfer_enable")->get();
+		$userList = User::query()
+		                ->whereEnable(1)
+		                ->where('status', '>=', 0)
+		                ->whereBanTime(0)
+		                ->whereRaw("u + d >= transfer_enable")
+		                ->get();
 		foreach($userList as $user){
 			User::query()->whereId($user->id)->update(['enable' => 0]);
 
@@ -225,8 +248,7 @@ class AutoJob extends Command
 	}
 
 	// 解封被临时封禁的账号
-	private function unblockUsers()
-	{
+	private function unblockUsers() {
 		// 解封被临时封禁的账号
 		$userList = User::query()->whereEnable(0)->where('status', '>=', 0)->where('ban_time', '>', 0)->get();
 		foreach($userList as $user){
@@ -239,7 +261,13 @@ class AutoJob extends Command
 		}
 
 		// 可用流量大于已用流量也解封(比如:邀请返利自动加了流量)
-		$userList = User::query()->whereEnable(0)->where('status', '>=', 0)->whereBanTime(0)->where('expire_time', '>=', date('Y-m-d'))->whereRaw("u + d < transfer_enable")->get();
+		$userList = User::query()
+		                ->whereEnable(0)
+		                ->where('status', '>=', 0)
+		                ->whereBanTime(0)
+		                ->where('expire_time', '>=', date('Y-m-d'))
+		                ->whereRaw("u + d < transfer_enable")
+		                ->get();
 		foreach($userList as $user){
 			User::query()->whereId($user->id)->update(['enable' => 1]);
 
@@ -249,8 +277,7 @@ class AutoJob extends Command
 	}
 
 	// 端口回收与分配
-	private function dispatchPort()
-	{
+	private function dispatchPort() {
 		if(self::$systemConfig['auto_release_port']){
 			## 自动分配端口
 			$userList = User::query()->whereEnable(1)->where('status', '>=', 0)->wherePort(0)->get();
@@ -264,18 +291,25 @@ class AutoJob extends Command
 			User::query()->whereEnable(0)->whereStatus(-1)->where('port', '!=', 0)->update(['port' => 0]);
 
 			## 过期一个月的账户自动释放端口
-			User::query()->whereEnable(0)->where('port', '!=', 0)->where('expire_time', '<=', date("Y-m-d", strtotime("-30 days")))->update(['port' => 0]);
+			User::query()
+			    ->whereEnable(0)
+			    ->where('port', '!=', 0)
+			    ->where('expire_time', '<=', date("Y-m-d", strtotime("-30 days")))
+			    ->update(['port' => 0]);
 		}
 	}
 
 	// 检测节点是否离线
-	private function checkNodeStatus()
-	{
+	private function checkNodeStatus() {
 		if(self::$systemConfig['is_node_offline']){
 			$nodeList = SsNode::query()->whereIsTransit(0)->whereStatus(1)->get();
 			foreach($nodeList as $node){
 				// 10分钟内无节点负载信息则认为是后端炸了
-				$nodeTTL = SsNodeInfo::query()->whereNodeId($node->id)->where('log_time', '>=', strtotime("-10 minutes"))->orderBy('id', 'desc')->doesntExist();
+				$nodeTTL = SsNodeInfo::query()
+				                     ->whereNodeId($node->id)
+				                     ->where('log_time', '>=', strtotime("-10 minutes"))
+				                     ->orderBy('id', 'desc')
+				                     ->doesntExist();
 				if($nodeTTL){
 					if(self::$systemConfig['offline_check_times']){
 						// 已通知次数

+ 7 - 11
app/Console/Commands/AutoPingNode.php

@@ -8,34 +8,30 @@ use App\Http\Models\SsNodePing;
 use Illuminate\Console\Command;
 use Log;
 
-class AutoPingNode extends Command
-{
+class AutoPingNode extends Command {
 	protected $signature = 'autoPingNode';
 	protected $description = '节点定时Ping测速';
 
-	public function __construct()
-	{
+	public function __construct() {
 		parent::__construct();
 	}
 
-	public function handle()
-	{
-		$jobStartTime = microtime(TRUE);
+	public function handle() {
+		$jobStartTime = microtime(true);
 
 		$nodeList = SsNode::query()->whereIsTransit(0)->whereStatus(1)->get();
 		foreach($nodeList as $node){
 			$this->pingNode($node->id, $node->is_ddns? $node->server : $node->ip);
 		}
 
-		$jobEndTime = microtime(TRUE);
-		$jobUsedTime = round(($jobEndTime-$jobStartTime), 4);
+		$jobEndTime = microtime(true);
+		$jobUsedTime = round(($jobEndTime - $jobStartTime), 4);
 
 		Log::info('---【'.$this->description.'】完成---,耗时'.$jobUsedTime.'秒');
 	}
 
 	// 节点Ping测速
-	private function pingNode($nodeId, $ip)
-	{
+	private function pingNode($nodeId, $ip) {
 		$result = NetworkDetection::ping($ip);
 
 		if($result){

+ 10 - 13
app/Console/Commands/AutoReportNode.php

@@ -9,19 +9,16 @@ use App\Http\Models\SsNodeTrafficDaily;
 use Illuminate\Console\Command;
 use Log;
 
-class AutoReportNode extends Command
-{
+class AutoReportNode extends Command {
 	protected $signature = 'autoReportNode';
 	protected $description = '自动报告节点昨日使用情况';
 
-	public function __construct()
-	{
+	public function __construct() {
 		parent::__construct();
 	}
 
-	public function handle()
-	{
-		$jobStartTime = microtime(TRUE);
+	public function handle() {
+		$jobStartTime = microtime(true);
 
 		if(Helpers::systemConfig()['node_daily_report']){
 			$nodeList = SsNode::query()->whereStatus(1)->get();
@@ -29,10 +26,10 @@ class AutoReportNode extends Command
 				$msg = "|节点|上行流量|下行流量|合计|\r\n| :------ | :------ | :------ |\r\n";
 				foreach($nodeList as $node){
 					$log = SsNodeTrafficDaily::query()
-						->whereNodeId($node->id)
-						->where('created_at', '>=', date('Y-m-d 00:00:00', strtotime("-1 day")))
-						->where('created_at', '<=', date('Y-m-d 23:59:59', strtotime("-1 day")))
-						->first();
+					                         ->whereNodeId($node->id)
+					                         ->where('created_at', '>=', date('Y-m-d 00:00:00', strtotime("-1 day")))
+					                         ->where('created_at', '<=', date('Y-m-d 23:59:59', strtotime("-1 day")))
+					                         ->first();
 
 					if($log){
 						$msg .= '|'.$node->name.'|'.flowAutoShow($log->u).'|'.flowAutoShow($log->d).'|'.$log->traffic."\r\n";
@@ -45,8 +42,8 @@ class AutoReportNode extends Command
 			}
 		}
 
-		$jobEndTime = microtime(TRUE);
-		$jobUsedTime = round(($jobEndTime-$jobStartTime), 4);
+		$jobEndTime = microtime(true);
+		$jobUsedTime = round(($jobEndTime - $jobStartTime), 4);
 
 		Log::info('---【'.$this->description.'】完成---,耗时'.$jobUsedTime.'秒');
 	}

+ 8 - 12
app/Console/Commands/AutoStatisticsNodeDailyTraffic.php

@@ -8,33 +8,29 @@ use App\Http\Models\UserTrafficLog;
 use Illuminate\Console\Command;
 use Log;
 
-class AutoStatisticsNodeDailyTraffic extends Command
-{
+class AutoStatisticsNodeDailyTraffic extends Command {
 	protected $signature = 'autoStatisticsNodeDailyTraffic';
 	protected $description = '自动统计节点每日流量';
 
-	public function __construct()
-	{
+	public function __construct() {
 		parent::__construct();
 	}
 
-	public function handle()
-	{
-		$jobStartTime = microtime(TRUE);
+	public function handle() {
+		$jobStartTime = microtime(true);
 
 		$nodeList = SsNode::query()->whereStatus(1)->orderBy('id', 'asc')->get();
 		foreach($nodeList as $node){
 			$this->statisticsByNode($node->id);
 		}
 
-		$jobEndTime = microtime(TRUE);
-		$jobUsedTime = round(($jobEndTime-$jobStartTime), 4);
+		$jobEndTime = microtime(true);
+		$jobUsedTime = round(($jobEndTime - $jobStartTime), 4);
 
 		Log::info('---【'.$this->description.'】完成---,耗时'.$jobUsedTime.'秒');
 	}
 
-	private function statisticsByNode($node_id)
-	{
+	private function statisticsByNode($node_id) {
 		$start_time = strtotime(date('Y-m-d 00:00:00', strtotime("-1 day")));
 		$end_time = strtotime(date('Y-m-d 23:59:59', strtotime("-1 day")));
 
@@ -42,7 +38,7 @@ class AutoStatisticsNodeDailyTraffic extends Command
 
 		$u = $query->sum('u');
 		$d = $query->sum('d');
-		$total = $u+$d;
+		$total = $u + $d;
 		$traffic = flowAutoShow($total);
 
 		if($total){ // 有数据才记录

+ 8 - 12
app/Console/Commands/AutoStatisticsNodeHourlyTraffic.php

@@ -8,33 +8,29 @@ use App\Http\Models\UserTrafficLog;
 use Illuminate\Console\Command;
 use Log;
 
-class AutoStatisticsNodeHourlyTraffic extends Command
-{
+class AutoStatisticsNodeHourlyTraffic extends Command {
 	protected $signature = 'autoStatisticsNodeHourlyTraffic';
 	protected $description = '自动统计节点每小时流量';
 
-	public function __construct()
-	{
+	public function __construct() {
 		parent::__construct();
 	}
 
-	public function handle()
-	{
-		$jobStartTime = microtime(TRUE);
+	public function handle() {
+		$jobStartTime = microtime(true);
 
 		$nodeList = SsNode::query()->whereStatus(1)->orderBy('id', 'asc')->get();
 		foreach($nodeList as $node){
 			$this->statisticsByNode($node->id);
 		}
 
-		$jobEndTime = microtime(TRUE);
-		$jobUsedTime = round(($jobEndTime-$jobStartTime), 4);
+		$jobEndTime = microtime(true);
+		$jobUsedTime = round(($jobEndTime - $jobStartTime), 4);
 
 		Log::info('---【'.$this->description.'】完成---,耗时'.$jobUsedTime.'秒');
 	}
 
-	private function statisticsByNode($node_id)
-	{
+	private function statisticsByNode($node_id) {
 		$start_time = strtotime(date('Y-m-d H:i:s', strtotime("-1 hour")));
 		$end_time = time();
 
@@ -42,7 +38,7 @@ class AutoStatisticsNodeHourlyTraffic extends Command
 
 		$u = $query->sum('u');
 		$d = $query->sum('d');
-		$total = $u+$d;
+		$total = $u + $d;
 		$traffic = flowAutoShow($total);
 
 		if($total){ // 有数据才记录

+ 8 - 12
app/Console/Commands/AutoStatisticsUserDailyTraffic.php

@@ -9,19 +9,16 @@ use App\Http\Models\UserTrafficLog;
 use Illuminate\Console\Command;
 use Log;
 
-class AutoStatisticsUserDailyTraffic extends Command
-{
+class AutoStatisticsUserDailyTraffic extends Command {
 	protected $signature = 'autoStatisticsUserDailyTraffic';
 	protected $description = '自动统计用户每日流量';
 
-	public function __construct()
-	{
+	public function __construct() {
 		parent::__construct();
 	}
 
-	public function handle()
-	{
-		$jobStartTime = microtime(TRUE);
+	public function handle() {
+		$jobStartTime = microtime(true);
 
 		$userList = User::query()->where('status', '>=', 0)->whereEnable(1)->get();
 		foreach($userList as $user){
@@ -35,14 +32,13 @@ class AutoStatisticsUserDailyTraffic extends Command
 			}
 		}
 
-		$jobEndTime = microtime(TRUE);
-		$jobUsedTime = round(($jobEndTime-$jobStartTime), 4);
+		$jobEndTime = microtime(true);
+		$jobUsedTime = round(($jobEndTime - $jobStartTime), 4);
 
 		Log::info('---【'.$this->description.'】完成---,耗时'.$jobUsedTime.'秒');
 	}
 
-	private function statisticsByNode($user_id, $node_id = 0)
-	{
+	private function statisticsByNode($user_id, $node_id = 0) {
 		$start_time = strtotime(date('Y-m-d 00:00:00', strtotime("-1 day")));
 		$end_time = strtotime(date('Y-m-d 23:59:59', strtotime("-1 day")));
 
@@ -54,7 +50,7 @@ class AutoStatisticsUserDailyTraffic extends Command
 
 		$u = $query->sum('u');
 		$d = $query->sum('d');
-		$total = $u+$d;
+		$total = $u + $d;
 		$traffic = flowAutoShow($total);
 
 		if($total){ // 有数据才记录

+ 8 - 12
app/Console/Commands/AutoStatisticsUserHourlyTraffic.php

@@ -9,19 +9,16 @@ use App\Http\Models\UserTrafficLog;
 use Illuminate\Console\Command;
 use Log;
 
-class AutoStatisticsUserHourlyTraffic extends Command
-{
+class AutoStatisticsUserHourlyTraffic extends Command {
 	protected $signature = 'autoStatisticsUserHourlyTraffic';
 	protected $description = '自动统计用户每小时流量';
 
-	public function __construct()
-	{
+	public function __construct() {
 		parent::__construct();
 	}
 
-	public function handle()
-	{
-		$jobStartTime = microtime(TRUE);
+	public function handle() {
+		$jobStartTime = microtime(true);
 
 		$userList = User::query()->where('status', '>=', 0)->whereEnable(1)->get();
 		foreach($userList as $user){
@@ -35,14 +32,13 @@ class AutoStatisticsUserHourlyTraffic extends Command
 			}
 		}
 
-		$jobEndTime = microtime(TRUE);
-		$jobUsedTime = round(($jobEndTime-$jobStartTime), 4);
+		$jobEndTime = microtime(true);
+		$jobUsedTime = round(($jobEndTime - $jobStartTime), 4);
 
 		Log::info('---【'.$this->description.'】完成---,耗时'.$jobUsedTime.'秒');
 	}
 
-	private function statisticsByNode($user_id, $node_id = 0)
-	{
+	private function statisticsByNode($user_id, $node_id = 0) {
 		$start_time = strtotime(date('Y-m-d H:i:s', strtotime("-1 hour")));
 		$end_time = time();
 
@@ -54,7 +50,7 @@ class AutoStatisticsUserHourlyTraffic extends Command
 
 		$u = $query->sum('u');
 		$d = $query->sum('d');
-		$total = $u+$d;
+		$total = $u + $d;
 		$traffic = flowAutoShow($total);
 
 		if($total){ // 有数据才记录

+ 70 - 59
app/Console/Commands/DailyJob.php

@@ -13,21 +13,18 @@ use App\Http\Models\UserLabel;
 use Illuminate\Console\Command;
 use Log;
 
-class DailyJob extends Command
-{
+class DailyJob extends Command {
 	protected static $systemConfig;
 	protected $signature = 'dailyJob';
 	protected $description = '每日任务';
 
-	public function __construct()
-	{
+	public function __construct() {
 		parent::__construct();
 		self::$systemConfig = Helpers::systemConfig();
 	}
 
-	public function handle()
-	{
-		$jobStartTime = microtime(TRUE);
+	public function handle() {
+		$jobStartTime = microtime(true);
 
 		// 过期用户处理
 		$this->expireUser();
@@ -40,27 +37,30 @@ class DailyJob extends Command
 			$this->resetUserTraffic();
 		}
 
-		$jobEndTime = microtime(TRUE);
-		$jobUsedTime = round(($jobEndTime-$jobStartTime), 4);
+		$jobEndTime = microtime(true);
+		$jobUsedTime = round(($jobEndTime - $jobStartTime), 4);
 
 		Log::info('---【'.$this->description.'】完成---,耗时'.$jobUsedTime.'秒');
 	}
 
-	private function expireUser()
-	{
+	private function expireUser() {
 		// 过期用户处理
-		$userList = User::query()->where('status', '>=', 0)->whereEnable(1)->where('expire_time', '<', date('Y-m-d'))->get();
+		$userList = User::query()
+		                ->where('status', '>=', 0)
+		                ->whereEnable(1)
+		                ->where('expire_time', '<', date('Y-m-d'))
+		                ->get();
 		foreach($userList as $user){
 			if(self::$systemConfig['is_ban_status']){
 				User::query()->whereId($user->id)->update([
-					'u'               => 0,
-					'd'               => 0,
-					'transfer_enable' => 0,
-					'enable'          => 0,
-					'reset_time'      => NULL,
-					'ban_time'        => 0,
-					'status'          => -1
-				]);
+					                                          'u'               => 0,
+					                                          'd'               => 0,
+					                                          'transfer_enable' => 0,
+					                                          'enable'          => 0,
+					                                          'reset_time'      => null,
+					                                          'ban_time'        => 0,
+					                                          'status'          => -1
+				                                          ]);
 
 				$this->addUserBanLog($user->id, 0, '【禁止登录,清空账户】-账号已过期');
 
@@ -71,13 +71,13 @@ class DailyJob extends Command
 				Helpers::addUserTrafficModifyLog($user->id, 0, $user->transfer_enable, 0, '[定时任务]账号已过期(禁止登录,清空账户)');
 			}else{
 				User::query()->whereId($user->id)->update([
-					'u'               => 0,
-					'd'               => 0,
-					'transfer_enable' => 0,
-					'enable'          => 0,
-					'reset_time'      => NULL,
-					'ban_time'        => 0
-				]);
+					                                          'u'               => 0,
+					                                          'd'               => 0,
+					                                          'transfer_enable' => 0,
+					                                          'enable'          => 0,
+					                                          'reset_time'      => null,
+					                                          'ban_time'        => 0
+				                                          ]);
 
 				$this->addUserBanLog($user->id, 0, '【封禁代理,清空账户】-账号已过期');
 
@@ -93,12 +93,11 @@ class DailyJob extends Command
 	/**
 	 * 添加用户封禁日志
 	 *
-	 * @param int    $userId  用户ID
-	 * @param int    $minutes 封禁时长,单位分钟
-	 * @param string $desc    封禁理由
+	 * @param  int     $userId   用户ID
+	 * @param  int     $minutes  封禁时长,单位分钟
+	 * @param  string  $desc     封禁理由
 	 */
-	private function addUserBanLog($userId, $minutes, $desc)
-	{
+	private function addUserBanLog($userId, $minutes, $desc) {
 		$log = new UserBanLog();
 		$log->user_id = $userId;
 		$log->minutes = $minutes;
@@ -107,9 +106,11 @@ class DailyJob extends Command
 	}
 
 	// 关闭超过72小时未处理的工单
-	private function closeTickets()
-	{
-		$ticketList = Ticket::query()->where('updated_at', '<=', date('Y-m-d', strtotime("-3 days")))->whereStatus(1)->get();
+	private function closeTickets() {
+		$ticketList = Ticket::query()
+		                    ->where('updated_at', '<=', date('Y-m-d', strtotime("-3 days")))
+		                    ->whereStatus(1)
+		                    ->get();
 		foreach($ticketList as $ticket){
 			$ret = Ticket::query()->whereId($ticket->id)->update(['status' => 2]);
 			if($ret){
@@ -119,9 +120,12 @@ class DailyJob extends Command
 	}
 
 	// 重置用户流量
-	private function resetUserTraffic()
-	{
-		$userList = User::query()->where('status', '>=', 0)->where('expire_time', '>', date('Y-m-d'))->where('reset_time', '<=', date('Y-m-d'))->get();
+	private function resetUserTraffic() {
+		$userList = User::query()
+		                ->where('status', '>=', 0)
+		                ->where('expire_time', '>', date('Y-m-d'))
+		                ->where('reset_time', '<=', date('Y-m-d'))
+		                ->get();
 		foreach($userList as $user){
 			// 跳过 没有重置日期的账号
 			if(!$user->reset_time){
@@ -130,14 +134,14 @@ class DailyJob extends Command
 
 			// 取出用户正在使用的套餐
 			$order = Order::query()
-				->with(['goods'])
-				->whereUserId($user->id)
-				->whereStatus(2)
-				->whereIsExpire(0)
-				->whereHas('goods', function($q){
-					$q->whereType(2);
-				})
-				->first();
+			              ->with(['goods'])
+			              ->whereUserId($user->id)
+			              ->whereStatus(2)
+			              ->whereIsExpire(0)
+			              ->whereHas('goods', function($q) {
+				              $q->whereType(2);
+			              })
+			              ->first();
 
 			// 无订单的免费/特殊用户跳过
 			if(!$order){
@@ -146,26 +150,33 @@ class DailyJob extends Command
 
 			// 过期生效中的加油包
 			Order::query()
-				->with(['goods'])
-				->whereUserId($user->id)
-				->whereStatus(2)
-				->whereIsExpire(0)
-				->whereHas('goods', function($q){
-					$q->whereType(1);
-				})->update(['is_expire' => 1]);
+			     ->with(['goods'])
+			     ->whereUserId($user->id)
+			     ->whereStatus(2)
+			     ->whereIsExpire(0)
+			     ->whereHas('goods', function($q) {
+				     $q->whereType(1);
+			     })
+			     ->update(['is_expire' => 1]);
 
 			//账号下一个重置时间
 			$nextResetTime = date('Y-m-d', strtotime("+".$order->goods->period." days"));
 			if($nextResetTime >= $user->expire_time){
-				$nextResetTime = NULL;
+				$nextResetTime = null;
 			}
 			// 可用流量 变动日志
-			if($user->transfer_enable != $order->goods->traffic*1048576){
-				Helpers::addUserTrafficModifyLog($order->user_id, $order->oid, $user->transfer_enable, $order->goods->traffic*1048576, '【流量重置】重置可用流量');
+			if($user->transfer_enable != $order->goods->traffic * 1048576){
+				Helpers::addUserTrafficModifyLog($order->user_id, $order->oid, $user->transfer_enable,
+				                                 $order->goods->traffic * 1048576, '【流量重置】重置可用流量');
 			}
 			// 重置流量
-			User::query()->whereId($user->id)->update(['u' => 0, 'd' => 0, 'transfer_enable' => $order->goods->traffic*1048576, 'reset_time' => $nextResetTime]);
-			Log::info('用户[ID:'.$user->id.'  昵称: '.$user->username.'  邮箱: '.$user->email.'] 流量重置为 '.($order->goods->traffic*1048576).'. 重置日期为 '.($nextResetTime? : '【无】'));
+			User::query()->whereId($user->id)->update([
+				                                          'u'               => 0,
+				                                          'd'               => 0,
+				                                          'transfer_enable' => $order->goods->traffic * 1048576,
+				                                          'reset_time'      => $nextResetTime
+			                                          ]);
+			Log::info('用户[ID:'.$user->id.'  昵称: '.$user->username.'  邮箱: '.$user->email.'] 流量重置为 '.($order->goods->traffic * 1048576).'. 重置日期为 '.($nextResetTime?: '【无】'));
 		}
 	}
-}
+}

+ 21 - 26
app/Console/Commands/NodeBlockedDetection.php

@@ -12,21 +12,18 @@ use Illuminate\Console\Command;
 use Log;
 use Mail;
 
-class NodeBlockedDetection extends Command
-{
+class NodeBlockedDetection extends Command {
 	protected static $systemConfig;
 	protected $signature = 'nodeBlockedDetection';
 	protected $description = '节点阻断检测';
 
-	public function __construct()
-	{
+	public function __construct() {
 		parent::__construct();
 		self::$systemConfig = Helpers::systemConfig();
 	}
 
-	public function handle()
-	{
-		$jobStartTime = microtime(TRUE);
+	public function handle() {
+		$jobStartTime = microtime(true);
 		if(self::$systemConfig['nodes_detection']){
 			if(!Cache::has('LastCheckTime')){
 				$this->checkNodes();
@@ -37,21 +34,20 @@ class NodeBlockedDetection extends Command
 			}
 		}
 
-		$jobEndTime = microtime(TRUE);
-		$jobUsedTime = round(($jobEndTime-$jobStartTime), 4);
+		$jobEndTime = microtime(true);
+		$jobUsedTime = round(($jobEndTime - $jobStartTime), 4);
 
 		Log::info("---【{$this->description}】完成---,耗时 {$jobUsedTime} 秒");
 	}
 
 	// 监测节点状态
-	private function checkNodes()
-	{
+	private function checkNodes() {
 		$nodeList = SsNode::query()->whereIsTransit(0)->whereStatus(1)->where('detectionType', '>', 0)->get();
-		$sendText = FALSE;
+		$sendText = false;
 		$message = "| 线路 | 协议 | 状态 |\r\n| ------ | ------ | ------ |\r\n";
 		$additionalMessage = '';
 		foreach($nodeList as $node){
-			$info = FALSE;
+			$info = false;
 			if($node->detectionType == 0){
 				continue;
 			}
@@ -66,19 +62,19 @@ class NodeBlockedDetection extends Command
 				}
 			}
 			if($node->detectionType != 1){
-				$icmpCheck = NetworkDetection::networkCheck($node->ip, TRUE);
-				if($icmpCheck != FALSE && $icmpCheck != "通讯正常"){
+				$icmpCheck = NetworkDetection::networkCheck($node->ip, true);
+				if($icmpCheck != false && $icmpCheck != "通讯正常"){
 					$message .= "| ".$node->name." | ICMP | ".$icmpCheck." |\r\n";
-					$sendText = TRUE;
-					$info = TRUE;
+					$sendText = true;
+					$info = true;
 				}
 			}
 			if($node->detectionType != 2){
-				$tcpCheck = NetworkDetection::networkCheck($node->ip, FALSE, $node->single? $node->port : NULL);
-				if($tcpCheck != FALSE && $tcpCheck != "通讯正常"){
+				$tcpCheck = NetworkDetection::networkCheck($node->ip, false, $node->single? $node->port : null);
+				if($tcpCheck != false && $tcpCheck != "通讯正常"){
 					$message .= "| ".$node->name." | TCP | ".$tcpCheck." |\r\n";
-					$sendText = TRUE;
-					$info = TRUE;
+					$sendText = true;
+					$info = true;
 				}
 			}
 
@@ -113,18 +109,17 @@ class NodeBlockedDetection extends Command
 		}
 
 		// 随机生成下次检测时间
-		Cache::put('LastCheckTime', time()+mt_rand(3000, 3600), 4000);
+		Cache::put('LastCheckTime', time() + mt_rand(3000, 3600), 4000);
 	}
 
 	/**
 	 * 通知管理员
 	 *
-	 * @param string $title   消息标题
-	 * @param string $content 消息内容
+	 * @param  string  $title    消息标题
+	 * @param  string  $content  消息内容
 	 *
 	 */
-	private function notifyMaster($title, $content)
-	{
+	private function notifyMaster($title, $content) {
 		$result = PushNotification::send($title, $content);
 		if(!$result && self::$systemConfig['webmaster_email']){
 			$logId = Helpers::addNotificationLog($title, $content, 1, self::$systemConfig['webmaster_email']);

+ 31 - 22
app/Console/Commands/ServiceTimer.php

@@ -12,34 +12,32 @@ use Exception;
 use Illuminate\Console\Command;
 use Log;
 
-class ServiceTimer extends Command
-{
+class ServiceTimer extends Command {
 	protected $signature = 'serviceTimer';
 	protected $description = '服务计时器';
 
-	public function __construct()
-	{
+	public function __construct() {
 		parent::__construct();
 	}
 
-	public function handle()
-	{
-		$jobStartTime = microtime(TRUE);
+	public function handle() {
+		$jobStartTime = microtime(true);
 
 		// 扣减用户到期商品的流量
 		$this->decGoodsTraffic();
 
-		$jobEndTime = microtime(TRUE);
-		$jobUsedTime = round(($jobEndTime-$jobStartTime), 4);
+		$jobEndTime = microtime(true);
+		$jobUsedTime = round(($jobEndTime - $jobStartTime), 4);
 
 		Log::info('---【'.$this->description.'】完成---,耗时'.$jobUsedTime.'秒');
 	}
 
 	// 扣减用户到期商品的流量
-	private function decGoodsTraffic()
-	{
+	private function decGoodsTraffic() {
 		//获取失效的套餐
-		$orderList = Order::query()->with(['goods'])->whereStatus(2)->whereIsExpire(0)->whereHas('goods', function($q){ $q->whereType(2); })->where('expire_at', '<=', date('Y-m-d H:i:s'))->get();
+		$orderList = Order::query()->with(['goods'])->whereStatus(2)->whereIsExpire(0)->whereHas('goods', function($q) {
+				$q->whereType(2);
+			})->where('expire_at', '<=', date('Y-m-d H:i:s'))->get();
 		if($orderList->isNotEmpty()){
 			try{
 				DB::beginTransaction();
@@ -49,27 +47,38 @@ class ServiceTimer extends Command
 
 					// 过期生效中的加油包
 					Order::query()
-						->with(['goods'])
-						->whereUserId($order->user_id)
-						->whereStatus(2)
-						->whereIsExpire(0)
-						->whereHas('goods', function($q){
-							$q->whereType(1);
-						})->update(['is_expire' => 1]);
+					     ->with(['goods'])
+					     ->whereUserId($order->user_id)
+					     ->whereStatus(2)
+					     ->whereIsExpire(0)
+					     ->whereHas('goods', function($q) {
+						     $q->whereType(1);
+					     })
+					     ->update(['is_expire' => 1]);
 
 					if(empty($order->user) || empty($order->goods)){
 						continue;
 					}
 
 					// 清理全部流量
-					Helpers::addUserTrafficModifyLog($order->user_id, $order->oid, $order->user->transfer_enable, 0, '[定时任务]用户所购商品到期,扣减商品对应的流量');
-					User::query()->whereId($order->user_id)->update(['u' => 0, 'd' => 0, 'transfer_enable' => 0, 'reset_time' => NULL]);
+					Helpers::addUserTrafficModifyLog($order->user_id, $order->oid, $order->user->transfer_enable, 0,
+					                                 '[定时任务]用户所购商品到期,扣减商品对应的流量');
+					User::query()->whereId($order->user_id)->update([
+						                                                'u'               => 0,
+						                                                'd'               => 0,
+						                                                'transfer_enable' => 0,
+						                                                'reset_time'      => null
+					                                                ]);
 
 					// 删除对应用户的所有标签
 					UserLabel::query()->whereUserId($order->user_id)->delete();
 
 					// 检查该订单对应用户是否有预支付套餐
-					$prepaidOrder = Order::query()->whereUserId($order->user_id)->whereStatus(3)->orderBy('oid', 'asc')->first();
+					$prepaidOrder = Order::query()
+					                     ->whereUserId($order->user_id)
+					                     ->whereStatus(3)
+					                     ->orderBy('oid', 'asc')
+					                     ->first();
 
 					if($prepaidOrder){
 						(new ServiceController)->activePrepaidOrder($prepaidOrder->oid);

+ 9 - 13
app/Console/Commands/UserExpireAutoWarning.php

@@ -10,45 +10,41 @@ use Illuminate\Console\Command;
 use Log;
 use Mail;
 
-class UserExpireAutoWarning extends Command
-{
+class UserExpireAutoWarning extends Command {
 	protected static $systemConfig;
 	protected $signature = 'userExpireAutoWarning';
 	protected $description = '用户临近到期自动发邮件提醒';
 
-	public function __construct()
-	{
+	public function __construct() {
 		parent::__construct();
 		self::$systemConfig = Helpers::systemConfig();
 	}
 
-	public function handle()
-	{
-		$jobStartTime = microtime(TRUE);
+	public function handle() {
+		$jobStartTime = microtime(true);
 
 		// 用户临近到期自动发邮件提醒
 		if(self::$systemConfig['expire_warning']){
 			$this->userExpireWarning();
 		}
 
-		$jobEndTime = microtime(TRUE);
-		$jobUsedTime = round(($jobEndTime-$jobStartTime), 4);
+		$jobEndTime = microtime(true);
+		$jobUsedTime = round(($jobEndTime - $jobStartTime), 4);
 
 		Log::info('---【'.$this->description.'】完成---,耗时'.$jobUsedTime.'秒');
 	}
 
-	private function userExpireWarning()
-	{
+	private function userExpireWarning() {
 		// 只取SSR没被禁用的用户,其他不用管
 		$userList = User::query()->whereEnable(1)->get();
 		foreach($userList as $user){
 			// 用户名不是邮箱的跳过
-			if(FALSE === filter_var($user->email, FILTER_VALIDATE_EMAIL)){
+			if(false === filter_var($user->email, FILTER_VALIDATE_EMAIL)){
 				continue;
 			}
 
 			// 计算剩余可用时间
-			$lastCanUseDays = ceil(round(strtotime($user->expire_time)-strtotime(date('Y-m-d H:i:s')))/3600/24);
+			$lastCanUseDays = ceil(round(strtotime($user->expire_time) - strtotime(date('Y-m-d H:i:s'))) / 3600 / 24);
 			if($lastCanUseDays == 0){
 				$title = '账号过期提醒';
 				$content = '您的账号将于今天晚上【24:00】过期。';

+ 21 - 14
app/Console/Commands/UserTrafficAbnormalAutoWarning.php

@@ -9,36 +9,38 @@ use App\Http\Models\UserTrafficHourly;
 use Illuminate\Console\Command;
 use Log;
 
-class UserTrafficAbnormalAutoWarning extends Command
-{
+class UserTrafficAbnormalAutoWarning extends Command {
 	protected static $systemConfig;
 	protected $signature = 'userTrafficAbnormalAutoWarning';
 	protected $description = '用户流量异常警告';
 
-	public function __construct()
-	{
+	public function __construct() {
 		parent::__construct();
 		self::$systemConfig = Helpers::systemConfig();
 	}
 
-	public function handle()
-	{
-		$jobStartTime = microtime(TRUE);
+	public function handle() {
+		$jobStartTime = microtime(true);
 
 		// 用户流量异常警告
 		$this->userTrafficAbnormalWarning();
 
-		$jobEndTime = microtime(TRUE);
-		$jobUsedTime = round(($jobEndTime-$jobStartTime), 4);
+		$jobEndTime = microtime(true);
+		$jobUsedTime = round(($jobEndTime - $jobStartTime), 4);
 
 		Log::info('---【'.$this->description.'】完成---,耗时'.$jobUsedTime.'秒');
 	}
 
 	// 用户流量异常警告
-	private function userTrafficAbnormalWarning()
-	{
+	private function userTrafficAbnormalWarning() {
 		// 1小时内流量异常用户(多往前取5分钟,防止数据统计任务执行时间过长导致没有数据)
-		$userTotalTrafficList = UserTrafficHourly::query()->whereNodeId(0)->where('total', '>', 104857600)->where('created_at', '>=', date('Y-m-d H:i:s', time()-3900))->groupBy('user_id')->selectRaw("user_id, sum(total) as totalTraffic")->get(); // 只统计100M以上的记录,加快查询速度
+		$userTotalTrafficList = UserTrafficHourly::query()
+		                                         ->whereNodeId(0)
+		                                         ->where('total', '>', 104857600)
+		                                         ->where('created_at', '>=', date('Y-m-d H:i:s', time() - 3900))
+		                                         ->groupBy('user_id')
+		                                         ->selectRaw("user_id, sum(total) as totalTraffic")
+		                                         ->get(); // 只统计100M以上的记录,加快查询速度
 		if(!$userTotalTrafficList->isEmpty()){
 			$title = "流量异常用户提醒";
 
@@ -46,8 +48,13 @@ class UserTrafficAbnormalAutoWarning extends Command
 				$user = User::query()->whereId($vo->user_id)->first();
 
 				// 推送通知管理员
-				if($vo->totalTraffic > (self::$systemConfig['traffic_ban_value']*1073741824)){
-					$traffic = UserTrafficHourly::query()->whereNodeId(0)->whereUserId($vo->user_id)->where('created_at', '>=', date('Y-m-d H:i:s', time()-3900))->selectRaw("user_id, sum(`u`) as totalU, sum(`d`) as totalD, sum(total) as totalTraffic")->first();
+				if($vo->totalTraffic > (self::$systemConfig['traffic_ban_value'] * 1073741824)){
+					$traffic = UserTrafficHourly::query()
+					                            ->whereNodeId(0)
+					                            ->whereUserId($vo->user_id)
+					                            ->where('created_at', '>=', date('Y-m-d H:i:s', time() - 3900))
+					                            ->selectRaw("user_id, sum(`u`) as totalU, sum(`d`) as totalD, sum(total) as totalTraffic")
+					                            ->first();
 
 					$content = "用户**{$user->email}(ID:{$user->id})**,最近1小时**上行流量:".flowAutoShow($traffic->totalU).",下行流量:".flowAutoShow($traffic->totalD).",共计:".flowAutoShow($traffic->totalTraffic)."**。";
 

+ 9 - 13
app/Console/Commands/UserTrafficAutoWarning.php

@@ -9,44 +9,40 @@ use Illuminate\Console\Command;
 use Log;
 use Mail;
 
-class UserTrafficAutoWarning extends Command
-{
+class UserTrafficAutoWarning extends Command {
 	protected static $systemConfig;
 	protected $signature = 'userTrafficAutoWarning';
 	protected $description = '用户流量超过警告阈值自动发邮件提醒';
 
-	public function __construct()
-	{
+	public function __construct() {
 		parent::__construct();
 		self::$systemConfig = Helpers::systemConfig();
 	}
 
-	public function handle()
-	{
-		$jobStartTime = microtime(TRUE);
+	public function handle() {
+		$jobStartTime = microtime(true);
 
 		// 用户流量超过警告阈值自动发邮件提醒
 		if(self::$systemConfig['traffic_warning']){
 			$this->userTrafficWarning();
 		}
 
-		$jobEndTime = microtime(TRUE);
-		$jobUsedTime = round(($jobEndTime-$jobStartTime), 4);
+		$jobEndTime = microtime(true);
+		$jobUsedTime = round(($jobEndTime - $jobStartTime), 4);
 
 		Log::info('---【'.$this->description.'】完成---,耗时'.$jobUsedTime.'秒');
 	}
 
 	// 用户流量超过警告阈值自动发邮件提醒
-	private function userTrafficWarning()
-	{
+	private function userTrafficWarning() {
 		$userList = User::query()->where('status', '>=', 0)->whereEnable(1)->where('transfer_enable', '>', 0)->get();
 		foreach($userList as $user){
 			// 用户名不是邮箱的跳过
-			if(FALSE === filter_var($user->email, FILTER_VALIDATE_EMAIL)){
+			if(false === filter_var($user->email, FILTER_VALIDATE_EMAIL)){
 				continue;
 			}
 
-			$usedPercent = round(($user->d+$user->u)/$user->transfer_enable, 2)*100; // 已使用流量百分比
+			$usedPercent = round(($user->d + $user->u) / $user->transfer_enable, 2) * 100; // 已使用流量百分比
 			if($usedPercent >= self::$systemConfig['traffic_warning_percent']){
 				$title = '流量提醒';
 				$content = '流量已使用:'.$usedPercent.'%,请保持关注。';

+ 7 - 11
app/Console/Commands/updateUserName.php

@@ -7,18 +7,15 @@ use App\Http\Models\User;
 use Illuminate\Console\Command;
 use Log;
 
-class updateUserName extends Command
-{
+class updateUserName extends Command {
 	protected $signature = 'updateUserName';
 	protected $description = '升级用户昵称';
 
-	public function __construct()
-	{
+	public function __construct() {
 		parent::__construct();
 	}
 
-	public function handle()
-	{
+	public function handle() {
 		Log::info('----------------------------【升级用户昵称】开始----------------------------');
 
 		$userList = User::query()->get();
@@ -43,8 +40,7 @@ class updateUserName extends Command
 	}
 }
 
-function process($id)
-{
+function process($id) {
 	$user = User::query()->whereId($id)->first();
 	// 先设个默认值
 	$name = $user->email;
@@ -52,14 +48,14 @@ function process($id)
 	if($user->qq){
 		$name = QQInfo::getName3($user->qq);
 		// 检测用户注册是否为QQ邮箱
-	}elseif(strpos(strtolower($user->email), '@qq') != FALSE){
+	}elseif(strpos(strtolower($user->email), '@qq') != false){
 		// 分离QQ邮箱后缀
 		$email = explode('@', $user->email);
 		if(is_numeric($email[0])){
 			$name = QQInfo::getName3($email[0]);
 		}else{
 			// 分离www前缀
-			if(strpos($email[0], '.') != FALSE){
+			if(strpos($email[0], '.') != false){
 				$temp = explode('.', $email[0]);
 				if(is_numeric($temp[1])){
 					$name = QQInfo::getName3($temp[1]);
@@ -69,7 +65,7 @@ function process($id)
 			}
 		}
 	}
-	if($name == FALSE){
+	if($name == false){
 		$name = $user->email;
 	}
 

+ 8 - 11
app/Console/Commands/upgradeUserResetTime.php

@@ -6,23 +6,20 @@ use App\Http\Models\User;
 use Illuminate\Console\Command;
 use Log;
 
-class upgradeUserResetTime extends Command
-{
+class upgradeUserResetTime extends Command {
 	protected $signature = 'upgradeUserResetTime';
 	protected $description = '升级用户重置日期';
 
-	public function __construct()
-	{
+	public function __construct() {
 		parent::__construct();
 	}
 
-	public function handle()
-	{
+	public function handle() {
 		Log::info('----------------------------【升级用户重置日期】开始----------------------------');
 
 		$userList = User::query()->get();
 		foreach($userList as $user){
-			$reset_time = NULL;
+			$reset_time = null;
 			if($user->traffic_reset_day){
 				$today = date('d');// 今天 日期
 				$last_day = date('t'); //本月最后一天
@@ -31,7 +28,7 @@ class upgradeUserResetTime extends Command
 				// 案例:31 29,重置日 大于 本月最后一天
 				if($resetDay > $last_day){
 					//往后推一个月
-					$resetDay = $resetDay-$last_day;
+					$resetDay = $resetDay - $last_day;
 					$reset_time = date('Y-m-'.$resetDay, strtotime("+1 month"));
 					//案例:20<30<31
 				}elseif($resetDay < $last_day && $resetDay > $today){
@@ -43,7 +40,7 @@ class upgradeUserResetTime extends Command
 				}elseif($resetDay < $today){
 					//类似第一种情况,向后推一月
 					if($resetDay > $next_last_day){
-						$resetDay = $resetDay-$next_last_day;
+						$resetDay = $resetDay - $next_last_day;
 						$reset_time = date('Y-m-'.$resetDay, strtotime("+1 month"));
 					}else{
 						$reset_time = date('Y-m-'.$resetDay, strtotime("+1 month"));
@@ -51,12 +48,12 @@ class upgradeUserResetTime extends Command
 				}
 				// 用户账号有效期大于重置日期
 				if($reset_time > $user->expire_time){
-					$reset_time = NULL;
+					$reset_time = null;
 				}
 				User::query()->whereId($user->id)->update(['reset_time' => $reset_time]);
 			}
 
-			Log::info('---用户[ID:'.$user->id.' - '.$user->username.' ('.$user->email.')]的新重置日期为'.($reset_time != NULL? '【'.$reset_time.'】' : '【无】').'---');
+			Log::info('---用户[ID:'.$user->id.' - '.$user->username.' ('.$user->email.')]的新重置日期为'.($reset_time != null? '【'.$reset_time.'】' : '【无】').'---');
 		}
 
 		Log::info('----------------------------【升级用户重置日期】结束----------------------------');

+ 4 - 7
app/Console/Kernel.php

@@ -20,8 +20,7 @@ use App\Console\Commands\UserTrafficAutoWarning;
 use Illuminate\Console\Scheduling\Schedule;
 use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
 
-class Kernel extends ConsoleKernel
-{
+class Kernel extends ConsoleKernel {
 	/**
 	 * The Artisan commands provided by your application.
 	 *
@@ -48,12 +47,11 @@ class Kernel extends ConsoleKernel
 	/**
 	 * Define the application's command schedule.
 	 *
-	 * @param Schedule $schedule
+	 * @param  Schedule  $schedule
 	 *
 	 * @return void
 	 */
-	protected function schedule(Schedule $schedule)
-	{
+	protected function schedule(Schedule $schedule) {
 		$schedule->command('autoJob')->everyMinute();
 		$schedule->command('serviceTimer')->everyTenMinutes();
 		$schedule->command('autoClearLog')->everyThirtyMinutes();
@@ -75,8 +73,7 @@ class Kernel extends ConsoleKernel
 	 *
 	 * @return void
 	 */
-	protected function commands()
-	{
+	protected function commands() {
 		$this->load(__DIR__.'/Commands');
 
 		require base_path('routes/console.php');

+ 3 - 6
app/Events/Event.php

@@ -8,8 +8,7 @@ use Illuminate\Broadcasting\PrivateChannel;
 use Illuminate\Foundation\Events\Dispatchable;
 use Illuminate\Queue\SerializesModels;
 
-class Event
-{
+class Event {
 	use Dispatchable, InteractsWithSockets, SerializesModels;
 
 	/**
@@ -17,8 +16,7 @@ class Event
 	 *
 	 * @return void
 	 */
-	public function __construct()
-	{
+	public function __construct() {
 		//
 	}
 
@@ -27,8 +25,7 @@ class Event
 	 *
 	 * @return Channel|array
 	 */
-	public function broadcastOn()
-	{
+	public function broadcastOn() {
 		return new PrivateChannel('channel-name');
 	}
 }

+ 23 - 16
app/Exceptions/Handler.php

@@ -13,16 +13,13 @@ use Log;
 use ReflectionException;
 use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
 
-class Handler extends ExceptionHandler
-{
+class Handler extends ExceptionHandler {
 	/**
 	 * A list of the exception types that are not reported.
 	 *
 	 * @var array
 	 */
-	protected $dontReport = [
-		//
-	];
+	protected $dontReport = [];
 
 	/**
 	 * A list of the inputs that are never flashed for validation exceptions.
@@ -37,13 +34,12 @@ class Handler extends ExceptionHandler
 	/**
 	 * Report or log an exception.
 	 *
-	 * @param Exception $exception
+	 * @param  Exception  $exception
 	 *
 	 * @return mixed|void
 	 * @throws Exception
 	 */
-	public function report(Exception $exception)
-	{
+	public function report(Exception $exception) {
 		// 记录异常来源
 		Log::info('异常来源:'.get_class($exception));
 
@@ -58,13 +54,12 @@ class Handler extends ExceptionHandler
 	/**
 	 * Render an exception into an HTTP response.
 	 *
-	 * @param Request   $request
-	 * @param Exception $exception
+	 * @param  Request    $request
+	 * @param  Exception  $exception
 	 *
 	 * @return Response
 	 */
-	public function render($request, Exception $exception)
-	{
+	public function render($request, Exception $exception) {
 		// 调试模式下直接返回错误信息
 		if(config('app.debug')){
 			return parent::render($request, $exception);
@@ -93,9 +88,15 @@ class Handler extends ExceptionHandler
 		// 捕获CSRF异常
 		if($exception instanceof TokenMismatchException){
 			if($request->ajax()){
-				return response()->json(['status' => 'fail', 'data' => '', 'message' => trans('error.RefreshPage').'<a href="/login" target="_blank">'.trans('error.Refresh').'</a>']);
+				return response()->json([
+					                        'status'  => 'fail',
+					                        'data'    => '',
+					                        'message' => trans('error.RefreshPage').'<a href="/login" target="_blank">'.trans('error.Refresh').'</a>'
+				                        ]);
 			}else{
-				return response()->view('auth.error', ['message' => trans('error.RefreshPage').'<a href="/login" target="_blank">'.trans('error.Refresh').'</a>']);
+				return response()->view('auth.error', [
+					'message' => trans('error.RefreshPage').'<a href="/login" target="_blank">'.trans('error.Refresh').'</a>'
+				]);
 			}
 		}
 
@@ -111,9 +112,15 @@ class Handler extends ExceptionHandler
 		// 捕获系统错误异常
 		if($exception instanceof ErrorException){
 			if($request->ajax()){
-				return response()->json(['status' => 'fail', 'data' => '', 'message' => trans('error.SystemError').', '.trans('error.Visit').'<a href="/logs" target="_blank">'.trans('error.log').'</a>']);
+				return response()->json([
+					                        'status'  => 'fail',
+					                        'data'    => '',
+					                        'message' => trans('error.SystemError').', '.trans('error.Visit').'<a href="/logs" target="_blank">'.trans('error.log').'</a>'
+				                        ]);
 			}else{
-				return response()->view('auth.error', ['message' => trans('error.SystemError').', '.trans('error.Visit').'<a href="/logs" target="_blank">'.trans('error.log').'</a>']);
+				return response()->view('auth.error', [
+					'message' => trans('error.SystemError').', '.trans('error.Visit').'<a href="/logs" target="_blank">'.trans('error.log').'</a>'
+				]);
 			}
 		}
 

+ 15 - 17
app/Http/Controllers/Admin/AffiliateController.php

@@ -16,24 +16,21 @@ use Response;
  *
  * @package App\Http\Controllers\Controller
  */
-class AffiliateController extends Controller
-{
+class AffiliateController extends Controller {
 	protected static $systemConfig;
 
-	function __construct()
-	{
+	function __construct() {
 		self::$systemConfig = Helpers::systemConfig();
 	}
 
 	// 提现申请列表
-	public function affiliateList(Request $request)
-	{
+	public function affiliateList(Request $request) {
 		$email = $request->input('email');
 		$status = $request->input('status');
 
 		$query = ReferralApply::with('user');
 		if(isset($email)){
-			$query->whereHas('user', function($q) use ($email){
+			$query->whereHas('user', function($q) use ($email) {
 				$q->where('email', 'like', '%'.$email.'%');
 			});
 		}
@@ -48,15 +45,18 @@ class AffiliateController extends Controller
 	}
 
 	// 提现申请详情
-	public function affiliateDetail(Request $request)
-	{
+	public function affiliateDetail(Request $request) {
 		$id = $request->input('id');
 
-		$list = NULL;
+		$list = null;
 		$apply = ReferralApply::query()->with(['user'])->whereId($id)->first();
 		if($apply && $apply->link_logs){
 			$link_logs = explode(',', $apply->link_logs);
-			$list = ReferralLog::query()->with(['user', 'order.goods'])->whereIn('id', $link_logs)->paginate(15)->appends($request->except('page'));
+			$list = ReferralLog::query()
+			                   ->with(['user', 'order.goods'])
+			                   ->whereIn('id', $link_logs)
+			                   ->paginate(15)
+			                   ->appends($request->except('page'));
 		}
 
 		$view['info'] = $apply;
@@ -66,8 +66,7 @@ class AffiliateController extends Controller
 	}
 
 	// 设置提现申请状态
-	public function setAffiliateStatus(Request $request)
-	{
+	public function setAffiliateStatus(Request $request) {
 		$id = $request->input('id');
 		$status = $request->input('status');
 
@@ -87,8 +86,7 @@ class AffiliateController extends Controller
 	}
 
 	// 用户返利流水记录
-	public function userRebateList(Request $request)
-	{
+	public function userRebateList(Request $request) {
 		$email = $request->input('email');
 		$ref_email = $request->input('ref_email');
 		$status = $request->input('status');
@@ -96,13 +94,13 @@ class AffiliateController extends Controller
 		$query = ReferralLog::query()->with(['user', 'order'])->orderBy('status', 'asc')->orderBy('id', 'desc');
 
 		if(isset($email)){
-			$query->whereHas('user', function($q) use ($email){
+			$query->whereHas('user', function($q) use ($email) {
 				$q->where('email', 'like', '%'.$email.'%');
 			});
 		}
 
 		if(isset($ref_email)){
-			$query->whereHas('ref_user', function($q) use ($ref_email){
+			$query->whereHas('ref_user', function($q) use ($ref_email) {
 				$q->where('email', 'like', '%'.$ref_email.'%');
 			});
 		}

+ 47 - 43
app/Http/Controllers/Admin/CouponController.php

@@ -20,11 +20,9 @@ use Response;
  *
  * @package App\Http\Controllers\Controller
  */
-class CouponController extends Controller
-{
+class CouponController extends Controller {
 	// 优惠券列表
-	public function couponList(Request $request)
-	{
+	public function couponList(Request $request) {
 		$sn = $request->input('sn');
 		$type = $request->input('type');
 		$status = $request->input('status');
@@ -49,8 +47,7 @@ class CouponController extends Controller
 	}
 
 	// 添加商品
-	public function addCoupon(Request $request)
-	{
+	public function addCoupon(Request $request) {
 		if($request->isMethod('POST')){
 			$this->validate($request, [
 				'name'            => 'required',
@@ -63,29 +60,29 @@ class CouponController extends Controller
 				'available_start' => 'required|date|before_or_equal:available_end',
 				'available_end'   => 'required|date|after_or_equal:available_start',
 			], [
-				'name.required'                   => '请填入卡券名称',
-				'type.required'                   => '请选择卡券类型',
-				'type.integer'                    => '卡券类型不合法,请重选',
-				'type.between'                    => '卡券类型不合法,请重选',
-				'usage.required'                  => '请选择卡券用途',
-				'usage.integer'                   => '卡券用途不合法,请重选',
-				'usage.between'                   => '卡券用途不合法,请重选',
-				'num.required'                    => '请填写卡券数量',
-				'num.integer'                     => '卡券数量不合法',
-				'num.min'                         => '卡券数量不合法,最小1',
-				'amount.required_unless'          => '请填入卡券面值',
-				'amount.numeric'                  => '卡券金额不合法',
-				'amount.min'                      => '卡券金额不合法,最小0.01',
-				'discount.required_if'            => '请填入卡券折扣',
-				'discount.numeric'                => '卡券折扣不合法',
-				'discount.between'                => '卡券折扣不合法,有效范围:1 ~ 9.9',
-				'available_start.required'        => '请填入有效期',
-				'available_start.date'            => '有效期不合法',
-				'available_start.before_or_equal' => '有效期不合法',
-				'available_end.required'          => '请填入有效期',
-				'available_end.date'              => '有效期不合法',
-				'available_end.after_or_equal'    => '有效期不合法'
-			]);
+				                'name.required'                   => '请填入卡券名称',
+				                'type.required'                   => '请选择卡券类型',
+				                'type.integer'                    => '卡券类型不合法,请重选',
+				                'type.between'                    => '卡券类型不合法,请重选',
+				                'usage.required'                  => '请选择卡券用途',
+				                'usage.integer'                   => '卡券用途不合法,请重选',
+				                'usage.between'                   => '卡券用途不合法,请重选',
+				                'num.required'                    => '请填写卡券数量',
+				                'num.integer'                     => '卡券数量不合法',
+				                'num.min'                         => '卡券数量不合法,最小1',
+				                'amount.required_unless'          => '请填入卡券面值',
+				                'amount.numeric'                  => '卡券金额不合法',
+				                'amount.min'                      => '卡券金额不合法,最小0.01',
+				                'discount.required_if'            => '请填入卡券折扣',
+				                'discount.numeric'                => '卡券折扣不合法',
+				                'discount.between'                => '卡券折扣不合法,有效范围:1 ~ 9.9',
+				                'available_start.required'        => '请填入有效期',
+				                'available_start.date'            => '有效期不合法',
+				                'available_start.before_or_equal' => '有效期不合法',
+				                'available_end.required'          => '请填入有效期',
+				                'available_end.date'              => '有效期不合法',
+				                'available_end.after_or_equal'    => '有效期不合法'
+			                ]);
 
 			$type = $request->input('type');
 
@@ -111,15 +108,17 @@ class CouponController extends Controller
 				for($i = 0; $i < $request->input('num'); $i++){
 					$obj = new Coupon();
 					$obj->name = $request->input('name');
-					$obj->sn = $request->input('sn')? : strtoupper(makeRandStr(8));
+					$obj->sn = $request->input('sn')?: strtoupper(makeRandStr(8));
 					$obj->logo = $logo;
 					$obj->type = $type;
 					$obj->usage = $request->input('usage');
 					$obj->amount = $type == 2? 0 : $request->input('amount');
 					$obj->discount = $type != 2? 0 : $request->input('discount');
 					$obj->rule = $request->input('rule');
-					$obj->available_start = strtotime(date('Y-m-d 00:00:00', strtotime($request->input('available_start'))));
-					$obj->available_end = strtotime(date('Y-m-d 23:59:59', strtotime($request->input('available_end'))));
+					$obj->available_start = strtotime(date('Y-m-d 00:00:00',
+					                                       strtotime($request->input('available_start'))));
+					$obj->available_end = strtotime(date('Y-m-d 23:59:59',
+					                                     strtotime($request->input('available_end'))));
 					$obj->status = 0;
 					$obj->save();
 				}
@@ -140,33 +139,38 @@ class CouponController extends Controller
 	}
 
 	// 删除优惠券
-	public function delCoupon(Request $request)
-	{
+	public function delCoupon(Request $request) {
 		Coupon::query()->whereId($request->input('id'))->delete();
 
 		return Response::json(['status' => 'success', 'data' => '', 'message' => '删除成功']);
 	}
 
 	// 导出卡券
-	public function exportCoupon()
-	{
+	public function exportCoupon() {
 		$voucherList = Coupon::type(1)->whereStatus(0)->get();
 		$discountCouponList = Coupon::type(2)->whereStatus(0)->get();
 		$refillList = Coupon::type(3)->whereStatus(0)->get();
 
 		$filename = '卡券'.date('Ymd').'.xlsx';
 		$spreadsheet = new Spreadsheet();
-		$spreadsheet->getProperties()->setCreator('SSRPanel')->setLastModifiedBy('SSRPanel')->setTitle('邀请码')->setSubject('邀请码')->setDescription('')->setKeywords('')->setCategory('');
+		$spreadsheet->getProperties()
+		            ->setCreator('SSRPanel')
+		            ->setLastModifiedBy('SSRPanel')
+		            ->setTitle('邀请码')
+		            ->setSubject('邀请码')
+		            ->setDescription('')
+		            ->setKeywords('')
+		            ->setCategory('');
 
 		// 抵用券
 		$spreadsheet->setActiveSheetIndex(0);
 		$sheet = $spreadsheet->getActiveSheet();
 		$sheet->setTitle('抵用券');
-		$sheet->fromArray(['名称', '类型', '有效期', '券码', '金额(元)', '使用限制(元)'], NULL);
+		$sheet->fromArray(['名称', '类型', '有效期', '券码', '金额(元)', '使用限制(元)'], null);
 		foreach($voucherList as $k => $vo){
 			$usage = $vo->usage == 1? '一次性' : '重复使用';
 			$dateRange = date('Y-m-d', $vo->available_start).' ~ '.date('Y-m-d', $vo->available_end);
-			$sheet->fromArray([$vo->name, $usage, $dateRange, $vo->sn, $vo->amount, $vo->rule], NULL, 'A'.($k+2));
+			$sheet->fromArray([$vo->name, $usage, $dateRange, $vo->sn, $vo->amount, $vo->rule], null, 'A'.($k + 2));
 		}
 
 		// 折扣券
@@ -174,11 +178,11 @@ class CouponController extends Controller
 		$spreadsheet->setActiveSheetIndex(1);
 		$sheet = $spreadsheet->getActiveSheet();
 		$sheet->setTitle('折扣券');
-		$sheet->fromArray(['名称', '类型', '有效期', '券码', '折扣(折)', '使用限制(元)'], NULL);
+		$sheet->fromArray(['名称', '类型', '有效期', '券码', '折扣(折)', '使用限制(元)'], null);
 		foreach($discountCouponList as $k => $vo){
 			$usage = $vo->usage == 1? '一次性' : '重复使用';
 			$dateRange = date('Y-m-d', $vo->available_start).' ~ '.date('Y-m-d', $vo->available_end);
-			$sheet->fromArray([$vo->name, $usage, $dateRange, $vo->sn, $vo->discount, $vo->rule], NULL, 'A'.($k+2));
+			$sheet->fromArray([$vo->name, $usage, $dateRange, $vo->sn, $vo->discount, $vo->rule], null, 'A'.($k + 2));
 		}
 
 		// 充值券
@@ -186,11 +190,11 @@ class CouponController extends Controller
 		$spreadsheet->setActiveSheetIndex(2);
 		$sheet = $spreadsheet->getActiveSheet();
 		$sheet->setTitle('充值券');
-		$sheet->fromArray(['名称', '类型', '有效期', '券码', '金额(元)'], NULL);
+		$sheet->fromArray(['名称', '类型', '有效期', '券码', '金额(元)'], null);
 		foreach($refillList as $k => $vo){
 			$usage = '一次性';
 			$dateRange = date('Y-m-d', $vo->available_start).' ~ '.date('Y-m-d', $vo->available_end);
-			$sheet->fromArray([$vo->name, $usage, $dateRange, $vo->sn, $vo->amount], NULL, 'A'.($k+2));
+			$sheet->fromArray([$vo->name, $usage, $dateRange, $vo->sn, $vo->amount], null, 'A'.($k + 2));
 		}
 
 		// 指针切换回第一个sheet

+ 14 - 14
app/Http/Controllers/Admin/MarketingController.php

@@ -19,18 +19,15 @@ use Response;
  *
  * @package App\Http\Controllers\Controller
  */
-class MarketingController extends Controller
-{
+class MarketingController extends Controller {
 	protected static $systemConfig;
 
-	function __construct()
-	{
+	function __construct() {
 		self::$systemConfig = Helpers::systemConfig();
 	}
 
 	// 邮件群发消息列表
-	public function emailList(Request $request)
-	{
+	public function emailList(Request $request) {
 		$status = $request->input('status');
 
 		$query = Marketing::query()->whereType(1);
@@ -45,8 +42,7 @@ class MarketingController extends Controller
 	}
 
 	// 消息通道群发列表
-	public function pushList(Request $request)
-	{
+	public function pushList(Request $request) {
 		$status = $request->input('status');
 
 		$query = Marketing::query()->whereType(2);
@@ -61,8 +57,7 @@ class MarketingController extends Controller
 	}
 
 	// 添加推送消息
-	public function addPushMarketing(Request $request)
-	{
+	public function addPushMarketing(Request $request) {
 		$title = trim($request->input('title'));
 		$content = $request->input('content');
 
@@ -73,7 +68,13 @@ class MarketingController extends Controller
 		DB::beginTransaction();
 		try{
 			$client = new Client();
-			$response = $client->request('GET', 'https://pushbear.ftqq.com/sub', ['query' => ['sendkey' => self::$systemConfig['push_bear_send_key'], 'text' => $title, 'desp' => $content]]);
+			$response = $client->request('GET', 'https://pushbear.ftqq.com/sub', [
+				'query' => [
+					'sendkey' => self::$systemConfig['push_bear_send_key'],
+					'text'    => $title,
+					'desp'    => $content
+				]
+			]);
 
 			$result = json_decode($response->getBody());
 			if($result->code){ // 失败
@@ -96,8 +97,7 @@ class MarketingController extends Controller
 		}
 	}
 
-	private function addMarketing($type = 1, $title = '', $content = '', $status = 1, $error = '', $receiver = '')
-	{
+	private function addMarketing($type = 1, $title = '', $content = '', $status = 1, $error = '', $receiver = '') {
 		$marketing = new Marketing();
 		$marketing->type = $type;
 		$marketing->receiver = $receiver;
@@ -108,4 +108,4 @@ class MarketingController extends Controller
 
 		return $marketing->save();
 	}
-}
+}

+ 12 - 12
app/Http/Controllers/Admin/SensitiveWordsController.php

@@ -15,28 +15,29 @@ use Validator;
  *
  * @package App\Http\Controllers\Controller
  */
-class SensitiveWordsController extends Controller
-{
+class SensitiveWordsController extends Controller {
 	// 敏感词列表
-	public function sensitiveWordsList()
-	{
+	public function sensitiveWordsList() {
 		$view['list'] = SensitiveWords::query()->orderBy('id', 'desc')->paginate(15);
 
 		return Response::view('admin.sensitiveWords.sensitiveWordsList', $view);
 	}
 
 	// 添加敏感词
-	public function addSensitiveWords(Request $request)
-	{
+	public function addSensitiveWords(Request $request) {
 		$validator = Validator::make($request->all(), [
 			'words' => 'required|unique:sensitive_words'
 		], [
-			'words.required' => '添加失败:请填写敏感词',
-			'words.unique'   => '添加失败:敏感词已存在'
-		]);
+			                             'words.required' => '添加失败:请填写敏感词',
+			                             'words.unique'   => '添加失败:敏感词已存在'
+		                             ]);
 
 		if($validator->fails()){
-			return Response::json(['status' => 'fail', 'data' => '', 'message' => $validator->getMessageBag()->first()]);
+			return Response::json([
+				                      'status'  => 'fail',
+				                      'data'    => '',
+				                      'message' => $validator->getMessageBag()->first()
+			                      ]);
 		}
 
 		$obj = new SensitiveWords();
@@ -51,8 +52,7 @@ class SensitiveWordsController extends Controller
 	}
 
 	// 删除敏感词
-	public function delSensitiveWords(Request $request)
-	{
+	public function delSensitiveWords(Request $request) {
 		$result = SensitiveWords::query()->whereId($request->input('id'))->delete();
 		if($result){
 			return Response::json(['status' => 'success', 'data' => '', 'message' => '删除成功']);

+ 28 - 14
app/Http/Controllers/Admin/ShopController.php

@@ -21,11 +21,9 @@ use Session;
  *
  * @package App\Http\Controllers\Controller
  */
-class ShopController extends Controller
-{
+class ShopController extends Controller {
 	// 商品列表
-	public function goodsList(Request $request)
-	{
+	public function goodsList(Request $request) {
 		$type = $request->input('type');
 		$status = $request->input('status');
 
@@ -45,10 +43,27 @@ class ShopController extends Controller
 	}
 
 	// 添加商品
-	public function addGoods(Request $request)
-	{
+	public function addGoods(Request $request) {
 		if($request->isMethod('POST')){
-			$this->validate($request, ['name' => 'required', 'traffic' => 'required_unless:type,3|integer|min:1024|max:10240000|nullable', 'price' => 'required|numeric|min:0', 'type' => 'required', 'days' => 'required|integer',], ['name.required' => '请填入名称', 'traffic.required_unless' => '请填入流量', 'traffic.integer' => '内含流量必须是整数值', 'traffic.min' => '内含流量不能低于1MB', 'traffic.max' => '内含流量不能超过10TB', 'price.required' => '请填入价格', 'price.numeric' => '价格不合法', 'price.min' => '价格最低0', 'type.required' => '请选择类型', 'days.required' => '请填入有效期', 'days.integer' => '有效期不合法',]);
+			$this->validate($request, [
+				'name'    => 'required',
+				'traffic' => 'required_unless:type,3|integer|min:1024|max:10240000|nullable',
+				'price'   => 'required|numeric|min:0',
+				'type'    => 'required',
+				'days'    => 'required|integer',
+			], [
+				                'name.required'           => '请填入名称',
+				                'traffic.required_unless' => '请填入流量',
+				                'traffic.integer'         => '内含流量必须是整数值',
+				                'traffic.min'             => '内含流量不能低于1MB',
+				                'traffic.max'             => '内含流量不能超过10TB',
+				                'price.required'          => '请填入价格',
+				                'price.numeric'           => '价格不合法',
+				                'price.min'               => '价格最低0',
+				                'type.required'           => '请选择类型',
+				                'days.required'           => '请填入有效期',
+				                'days.integer'            => '有效期不合法',
+			                ]);
 
 			$type = $request->input('type');
 			$price = $request->input('price');
@@ -136,8 +151,7 @@ class ShopController extends Controller
 	}
 
 	// 编辑商品
-	public function editGoods(Request $request, $id)
-	{
+	public function editGoods(Request $request, $id) {
 		if($request->isMethod('POST')){
 			$name = $request->input('name');
 			$info = $request->input('info');
@@ -201,13 +215,14 @@ class ShopController extends Controller
 					'name'      => $name,
 					'info'      => $info,
 					'desc'      => $desc,
-					'price'     => $price*100,
-					'renew'     => $renew*100,
+					'price'     => $price * 100,
+					'renew'     => $renew * 100,
 					'sort'      => $sort,
 					'color'     => $color,
 					'is_hot'    => $is_hot,
 					'limit_num' => $limit_num,
-					'status'    => $status];
+					'status'    => $status
+				];
 
 				if($logo){
 					$data['logo'] = $logo;
@@ -256,8 +271,7 @@ class ShopController extends Controller
 	}
 
 	// 删除商品
-	public function delGoods(Request $request)
-	{
+	public function delGoods(Request $request) {
 		Goods::query()->whereId($request->input('id'))->delete();
 
 		return Response::json(['status' => 'success', 'data' => '', 'message' => '删除成功']);

+ 8 - 15
app/Http/Controllers/Admin/SubscribeController.php

@@ -17,18 +17,15 @@ use Response;
  *
  * @package App\Http\Controllers\Controller
  */
-class SubscribeController extends Controller
-{
+class SubscribeController extends Controller {
 	protected static $systemConfig;
 
-	function __construct()
-	{
+	function __construct() {
 		self::$systemConfig = Helpers::systemConfig();
 	}
 
 	// 订阅码列表
-	public function subscribeList(Request $request)
-	{
+	public function subscribeList(Request $request) {
 		$user_id = $request->input('user_id');
 		$email = $request->input('email');
 		$status = $request->input('status');
@@ -40,7 +37,7 @@ class SubscribeController extends Controller
 		}
 
 		if(isset($email)){
-			$query->whereHas('user', function($q) use ($email){
+			$query->whereHas('user', function($q) use ($email) {
 				$q->where('email', 'like', '%'.$email.'%');
 			});
 		}
@@ -55,8 +52,7 @@ class SubscribeController extends Controller
 	}
 
 	//订阅记录
-	public function subscribeLog(Request $request)
-	{
+	public function subscribeLog(Request $request) {
 		$id = $request->input('id');
 		$query = UserSubscribeLog::with('user:email');
 
@@ -70,8 +66,7 @@ class SubscribeController extends Controller
 	}
 
 	// 订阅设备列表
-	public function deviceList(Request $request)
-	{
+	public function deviceList(Request $request) {
 		$type = $request->input('type');
 		$platform = $request->input('platform');
 		$name = $request->input('name');
@@ -101,8 +96,7 @@ class SubscribeController extends Controller
 	}
 
 	// 设置用户的订阅的状态
-	public function setSubscribeStatus(Request $request)
-	{
+	public function setSubscribeStatus(Request $request) {
 		$id = $request->input('id');
 		$status = $request->input('status', 0);
 
@@ -120,8 +114,7 @@ class SubscribeController extends Controller
 	}
 
 	// 设置设备是否允许订阅的状态
-	public function setDeviceStatus(Request $request)
-	{
+	public function setDeviceStatus(Request $request) {
 		$id = $request->input('id');
 		$status = $request->input('status', 0);
 

+ 10 - 13
app/Http/Controllers/Admin/TicketController.php

@@ -21,24 +21,21 @@ use Response;
  *
  * @package App\Http\Controllers\Controller
  */
-class TicketController extends Controller
-{
+class TicketController extends Controller {
 	protected static $systemConfig;
 
-	function __construct()
-	{
+	function __construct() {
 		self::$systemConfig = Helpers::systemConfig();
 	}
 
 	// 工单列表
-	public function ticketList(Request $request)
-	{
+	public function ticketList(Request $request) {
 		$email = $request->input('email');
 
 		$query = Ticket::query();
 
 		if(isset($email)){
-			$query->whereHas('user', function($q) use ($email){
+			$query->whereHas('user', function($q) use ($email) {
 				$q->where('email', 'like', '%'.$email.'%');
 			});
 		}
@@ -49,8 +46,7 @@ class TicketController extends Controller
 	}
 
 	// 回复工单
-	public function replyTicket(Request $request)
-	{
+	public function replyTicket(Request $request) {
 		$id = $request->input('id');
 
 		if($request->isMethod('POST')){
@@ -77,8 +73,10 @@ class TicketController extends Controller
 				// 发通知邮件
 				if(!Auth::user()->is_admin){
 					if(self::$systemConfig['webmaster_email']){
-						$logId = Helpers::addNotificationLog($title, $content, 1, self::$systemConfig['webmaster_email']);
-						Mail::to(self::$systemConfig['webmaster_email'])->send(new replyTicket($logId, $title, $content));
+						$logId = Helpers::addNotificationLog($title, $content, 1,
+						                                     self::$systemConfig['webmaster_email']);
+						Mail::to(self::$systemConfig['webmaster_email'])->send(new replyTicket($logId, $title,
+						                                                                       $content));
 					}
 				}else{
 					$logId = Helpers::addNotificationLog($title, $content, 1, $ticket->user->email);
@@ -103,8 +101,7 @@ class TicketController extends Controller
 	}
 
 	// 关闭工单
-	public function closeTicket(Request $request)
-	{
+	public function closeTicket(Request $request) {
 		$id = $request->input('id');
 
 		$ticket = Ticket::query()->with(['user'])->whereId($id)->first();

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 251 - 190
app/Http/Controllers/AdminController.php


+ 13 - 16
app/Http/Controllers/Api/LoginController.php

@@ -21,18 +21,15 @@ use Response;
  *
  * @package App\Http\Controllers
  */
-class LoginController extends Controller
-{
+class LoginController extends Controller {
 	protected static $systemConfig;
 
-	function __construct()
-	{
+	function __construct() {
 		self::$systemConfig = Helpers::systemConfig();
 	}
 
 	// 登录返回订阅信息
-	public function login(Request $request)
-	{
+	public function login(Request $request) {
 		$email = trim($request->input('email'));
 		$password = trim($request->input('password'));
 		$cacheKey = 'request_times_'.md5(getClientIp());
@@ -82,14 +79,14 @@ class LoginController extends Controller
 			}
 
 			$nodeList = DB::table('ss_node')
-				->selectRaw('ss_node.*')
-				->leftJoin('ss_node_label', 'ss_node.id', '=', 'ss_node_label.node_id')
-				->whereIn('ss_node_label.label_id', $userLabelIds)
-				->where('ss_node.status', 1)
-				->groupBy('ss_node.id')
-				->orderBy('ss_node.sort', 'desc')
-				->orderBy('ss_node.id', 'asc')
-				->get();
+			              ->selectRaw('ss_node.*')
+			              ->leftJoin('ss_node_label', 'ss_node.id', '=', 'ss_node_label.node_id')
+			              ->whereIn('ss_node_label.label_id', $userLabelIds)
+			              ->where('ss_node.status', 1)
+			              ->groupBy('ss_node.id')
+			              ->orderBy('ss_node.sort', 'desc')
+			              ->orderBy('ss_node.id', 'asc')
+			              ->get();
 
 			$c_nodes = collect();
 			foreach($nodeList as $node){
@@ -119,7 +116,7 @@ class LoginController extends Controller
 				'buy_link'     => '',
 				'money'        => '0.00',
 				'sspannelName' => 'ssrpanel',
-				'usedTraffic'  => flowAutoShow($user->u+$user->d),
+				'usedTraffic'  => flowAutoShow($user->u + $user->d),
 				'Traffic'      => flowAutoShow($user->transfer_enable),
 				'all'          => 1,
 				'residue'      => '',
@@ -136,4 +133,4 @@ class LoginController extends Controller
 			return Response::json(['status' => 'success', 'data' => [], 'message' => '登录失败']);
 		}
 	}
-}
+}

+ 3 - 5
app/Http/Controllers/Api/PingController.php

@@ -14,10 +14,8 @@ use Log;
  *
  * @package App\Http\Controllers\Api
  */
-class PingController extends Controller
-{
-	public function ping(Request $request)
-	{
+class PingController extends Controller {
+	public function ping(Request $request) {
 		$token = $request->input('token');
 		$host = $request->input('host');
 		$port = $request->input('port', 22);
@@ -51,7 +49,7 @@ class PingController extends Controller
 		}
 
 		// 如果不是IPv4
-		if(FALSE === filter_var($host, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)){
+		if(false === filter_var($host, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)){
 			// 如果是IPv6
 			if(filter_var($host, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)){
 				$host = '['.$host.']';

+ 110 - 101
app/Http/Controllers/AuthController.php

@@ -36,26 +36,23 @@ use Validator;
  *
  * @package App\Http\Controllers
  */
-class AuthController extends Controller
-{
+class AuthController extends Controller {
 	protected static $systemConfig;
 
-	function __construct()
-	{
+	function __construct() {
 		self::$systemConfig = Helpers::systemConfig();
 	}
 
 	// 登录
-	public function login(Request $request)
-	{
+	public function login(Request $request) {
 		if($request->isMethod('POST')){
 			$this->validate($request, [
 				'email'    => 'required',
 				'password' => 'required'
 			], [
-				'email.required'    => trans('auth.email_null'),
-				'password.required' => trans('auth.password_null')
-			]);
+				                'email.required'    => trans('auth.email_null'),
+				                'password.required' => trans('auth.password_null')
+			                ]);
 
 			$email = $request->input('email');
 			$password = $request->input('password');
@@ -63,7 +60,7 @@ class AuthController extends Controller
 
 			// 是否校验验证码
 			$captcha = $this->check_captcha($request);
-			if($captcha != FALSE){
+			if($captcha != false){
 				return $captcha;
 			}
 
@@ -77,11 +74,14 @@ class AuthController extends Controller
 				if(Auth::user()->status < 0){
 					Auth::logout(); // 强制销毁会话,因为Auth::attempt的时候会产生会话
 
-					return Redirect::back()->withInput()->withErrors(trans('auth.login_ban', ['email' => self::$systemConfig['webmaster_email']]));
+					return Redirect::back()->withInput()->withErrors(trans('auth.login_ban',
+					                                                       ['email' => self::$systemConfig['webmaster_email']]));
 				}elseif(Auth::user()->status == 0 && self::$systemConfig['is_activate_account']){
 					Auth::logout(); // 强制销毁会话,因为Auth::attempt的时候会产生会话
 
-					return Redirect::back()->withInput()->withErrors(trans('auth.active_tip').'<a href="/activeUser?email='.$email.'" target="_blank"><span style="color:#000">【'.trans('auth.active_account').'】</span></a>');
+					return Redirect::back()
+					               ->withInput()
+					               ->withErrors(trans('auth.active_tip').'<a href="/activeUser?email='.$email.'" target="_blank"><span style="color:#000">【'.trans('auth.active_account').'】</span></a>');
 				}
 			}
 
@@ -111,8 +111,7 @@ class AuthController extends Controller
 	}
 
 	// 校验验证码
-	private function check_captcha($request)
-	{
+	private function check_captcha($request) {
 		switch(self::$systemConfig['is_captcha']){
 			case 1: // 默认图形验证码
 				if(!Captcha::check($request->input('captcha'))){
@@ -123,8 +122,8 @@ class AuthController extends Controller
 				$result = $this->validate($request, [
 					'geetest_challenge' => 'required|geetest'
 				], [
-					'geetest' => trans('auth.captcha_fail')
-				]);
+					                          'geetest' => trans('auth.captcha_fail')
+				                          ]);
 
 				if(!$result){
 					return Redirect::back()->withInput()->withErrors(trans('auth.fail_captcha'));
@@ -158,11 +157,10 @@ class AuthController extends Controller
 	/**
 	 * 添加用户登录日志
 	 *
-	 * @param string $userId 用户ID
-	 * @param string $ip     IP地址
+	 * @param  string  $userId  用户ID
+	 * @param  string  $ip      IP地址
 	 */
-	private function addUserLoginLog($userId, $ip)
-	{
+	private function addUserLoginLog($userId, $ip) {
 		if(filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)){
 			Log::info('识别到IPv6,尝试解析:'.$ip);
 			$ipInfo = getIPv6($ip);
@@ -206,16 +204,14 @@ class AuthController extends Controller
 
 	// 退出
 
-	public function logout()
-	{
+	public function logout() {
 		Auth::logout();
 
 		return Redirect::to('login');
 	}
 
 	// 注册
-	public function register(Request $request)
-	{
+	public function register(Request $request) {
 		$cacheKey = 'register_times_'.md5(getClientIp()); // 注册限制缓存key
 
 		if($request->isMethod('POST')){
@@ -226,16 +222,16 @@ class AuthController extends Controller
 				'confirmPassword' => 'required|same:password',
 				'term'            => 'accepted'
 			], [
-				'username.required'        => trans('auth.email_null'),
-				'email.required'           => trans('auth.email_null'),
-				'email.email'              => trans('auth.email_legitimate'),
-				'email.unique'             => trans('auth.email_exist'),
-				'password.required'        => trans('auth.password_null'),
-				'password.min'             => trans('auth.password_limit'),
-				'confirmPassword.required' => trans('auth.confirm_password'),
-				'confirmPassword.same'     => trans('auth.password_same'),
-				'term.accepted'            => trans('auth.unaccepted')
-			]);
+				                'username.required'        => trans('auth.email_null'),
+				                'email.required'           => trans('auth.email_null'),
+				                'email.email'              => trans('auth.email_legitimate'),
+				                'email.unique'             => trans('auth.email_exist'),
+				                'password.required'        => trans('auth.password_null'),
+				                'password.min'             => trans('auth.password_limit'),
+				                'confirmPassword.required' => trans('auth.confirm_password'),
+				                'confirmPassword.same'     => trans('auth.password_same'),
+				                'term.accepted'            => trans('auth.unaccepted')
+			                ]);
 
 			$username = $request->input('username');
 			$email = $request->input('email');
@@ -260,7 +256,7 @@ class AuthController extends Controller
 			// 校验域名邮箱黑白名单
 			if(self::$systemConfig['is_email_filtering']){
 				$result = $this->emailChecker($email);
-				if($result != FALSE){
+				if($result != false){
 					return $result;
 				}
 			}
@@ -276,7 +272,9 @@ class AuthController extends Controller
 				if($code){
 					$codeEnable = Invite::query()->whereCode($code)->whereStatus(0)->doesntExist();
 					if($codeEnable){
-						return Redirect::back()->withInput($request->except(['code']))->withErrors(trans('auth.code_error'));
+						return Redirect::back()
+						               ->withInput($request->except(['code']))
+						               ->withErrors(trans('auth.code_error'));
 					}
 				}
 			}
@@ -284,11 +282,19 @@ class AuthController extends Controller
 			// 注册前发送激活码
 			if(self::$systemConfig['is_activate_account'] == 1){
 				if(!$verify_code){
-					return Redirect::back()->withInput($request->except(['verify_code']))->withErrors(trans('auth.captcha_null'));
+					return Redirect::back()
+					               ->withInput($request->except(['verify_code']))
+					               ->withErrors(trans('auth.captcha_null'));
 				}else{
-					$verifyCode = VerifyCode::query()->whereAddress($email)->whereCode($verify_code)->whereStatus(0)->firstOrFail();
+					$verifyCode = VerifyCode::query()
+					                        ->whereAddress($email)
+					                        ->whereCode($verify_code)
+					                        ->whereStatus(0)
+					                        ->firstOrFail();
 					if(!$verifyCode){
-						return Redirect::back()->withInput($request->except(['verify_code']))->withErrors(trans('auth.captcha_overtime'));
+						return Redirect::back()
+						               ->withInput($request->except(['verify_code']))
+						               ->withErrors(trans('auth.captcha_overtime'));
 					}
 
 					$verifyCode->status = 1;
@@ -298,7 +304,7 @@ class AuthController extends Controller
 
 			// 是否校验验证码
 			$captcha = $this->check_captcha($request);
-			if($captcha != FALSE){
+			if($captcha != false){
 				return $captcha;
 			}
 
@@ -307,7 +313,9 @@ class AuthController extends Controller
 				if(Cache::has($cacheKey)){
 					$registerTimes = Cache::get($cacheKey);
 					if($registerTimes >= self::$systemConfig['register_ip_limit']){
-						return Redirect::back()->withInput($request->except(['code']))->withErrors(trans('auth.register_anti'));
+						return Redirect::back()
+						               ->withInput($request->except(['code']))
+						               ->withErrors(trans('auth.register_anti'));
 					}
 				}
 			}
@@ -322,10 +330,11 @@ class AuthController extends Controller
 			$affArr = $this->getAff($code, $aff);
 			$referral_uid = $affArr['referral_uid'];
 
-			$transfer_enable = 1048576*(self::$systemConfig['default_traffic']+($referral_uid? self::$systemConfig['referral_traffic'] : 0));
+			$transfer_enable = 1048576 * (self::$systemConfig['default_traffic'] + ($referral_uid? self::$systemConfig['referral_traffic'] : 0));
 
 			// 创建新用户
-			$uid = Helpers::addUser($email, Hash::make($password), $transfer_enable, self::$systemConfig['default_days'], $referral_uid);
+			$uid = Helpers::addUser($email, Hash::make($password), $transfer_enable,
+			                        self::$systemConfig['default_days'], $referral_uid);
 
 			// 注册失败,抛出异常
 			if(!$uid){
@@ -383,7 +392,9 @@ class AuthController extends Controller
 					$referralUser = User::query()->whereId($referral_uid)->first();
 					if($referralUser){
 						if($referralUser->expire_time >= date('Y-m-d')){
-							User::query()->whereId($referral_uid)->increment('transfer_enable', self::$systemConfig['referral_traffic']*1048576);
+							User::query()
+							    ->whereId($referral_uid)
+							    ->increment('transfer_enable', self::$systemConfig['referral_traffic'] * 1048576);
 						}
 					}
 				}
@@ -397,7 +408,9 @@ class AuthController extends Controller
 
 			return Redirect::to('login')->withInput();
 		}else{
-			$view['emailList'] = self::$systemConfig['is_email_filtering'] != 2? FALSE : SensitiveWords::query()->whereType(2)->get();
+			$view['emailList'] = self::$systemConfig['is_email_filtering'] != 2? false : SensitiveWords::query()
+			                                                                                           ->whereType(2)
+			                                                                                           ->get();
 			Session::put('register_token', makeRandStr(16));
 
 			return Response::view('auth.register', $view);
@@ -405,8 +418,7 @@ class AuthController extends Controller
 	}
 
 	//邮箱检查
-	private function emailChecker($email)
-	{
+	private function emailChecker($email) {
 		$sensitiveWords = $this->sensitiveWords(self::$systemConfig['is_email_filtering']);
 		$emailSuffix = explode('@', $email); // 提取邮箱后缀
 		switch(self::$systemConfig['is_email_filtering']){
@@ -426,19 +438,18 @@ class AuthController extends Controller
 				return Response::json(['status' => 'fail', 'message' => trans('auth.email_invalid')]);
 		}
 
-		return FALSE;
+		return false;
 	}
 
 	/**
 	 * 获取AFF
 	 *
-	 * @param string $code 邀请码
-	 * @param int    $aff  URL中的aff参数
+	 * @param  string  $code  邀请码
+	 * @param  int     $aff   URL中的aff参数
 	 *
 	 * @return array
 	 */
-	private function getAff($code = '', $aff = NULL)
-	{
+	private function getAff($code = '', $aff = null) {
 		// 邀请人ID
 		$referral_uid = 0;
 
@@ -474,8 +485,7 @@ class AuthController extends Controller
 	}
 
 	// 生成申请的请求地址
-	private function addVerifyUrl($uid, $email)
-	{
+	private function addVerifyUrl($uid, $email) {
 		$token = md5(self::$systemConfig['website_name'].$email.microtime());
 		$verify = new Verify();
 		$verify->type = 1;
@@ -488,22 +498,22 @@ class AuthController extends Controller
 	}
 
 	// 重设密码页
-	public function resetPassword(Request $request)
-	{
+	public function resetPassword(Request $request) {
 		if($request->isMethod('POST')){
 			// 校验请求
 			$this->validate($request, [
 				'email' => 'required|email'
 			], [
-				'email.required' => trans('auth.email_null'),
-				'email.email'    => trans('auth.email_legitimate')
-			]);
+				                'email.required' => trans('auth.email_null'),
+				                'email.email'    => trans('auth.email_legitimate')
+			                ]);
 
 			$email = $request->input('email');
 
 			// 是否开启重设密码
 			if(!self::$systemConfig['is_reset_password']){
-				return Redirect::back()->withErrors(trans('auth.reset_password_close', ['email' => self::$systemConfig['webmaster_email']]));
+				return Redirect::back()->withErrors(trans('auth.reset_password_close',
+				                                          ['email' => self::$systemConfig['webmaster_email']]));
 			}
 
 			// 查找账号
@@ -517,7 +527,8 @@ class AuthController extends Controller
 			if(Cache::has('resetPassword_'.md5($email))){
 				$resetTimes = Cache::get('resetPassword_'.md5($email));
 				if($resetTimes >= self::$systemConfig['reset_password_times']){
-					return Redirect::back()->withErrors(trans('auth.reset_password_limit', ['time' => self::$systemConfig['reset_password_times']]));
+					return Redirect::back()->withErrors(trans('auth.reset_password_limit',
+					                                          ['time' => self::$systemConfig['reset_password_times']]));
 				}
 			}
 
@@ -530,7 +541,7 @@ class AuthController extends Controller
 			$logId = Helpers::addNotificationLog('重置密码', '请求地址:'.$resetPasswordUrl, 1, $email);
 			Mail::to($email)->send(new resetPassword($logId, $resetPasswordUrl));
 
-			Cache::put('resetPassword_'.md5($email), $resetTimes+1, 86400);
+			Cache::put('resetPassword_'.md5($email), $resetTimes + 1, 86400);
 
 			return Redirect::back()->with('successMsg', trans('auth.reset_password_success_tip'));
 		}else{
@@ -539,8 +550,7 @@ class AuthController extends Controller
 	}
 
 	// 重设密码
-	public function reset(Request $request, $token)
-	{
+	public function reset(Request $request, $token) {
 		if(!$token){
 			return Redirect::to('login');
 		}
@@ -550,12 +560,12 @@ class AuthController extends Controller
 				'password'        => 'required|min:6',
 				'confirmPassword' => 'required|same:password'
 			], [
-				'password.required'        => trans('auth.password_null'),
-				'password.min'             => trans('auth.password_limit'),
-				'confirmPassword.required' => trans('auth.password_null'),
-				'confirmPassword.min'      => trans('auth.password_limit'),
-				'confirmPassword.same'     => trans('auth.password_same'),
-			]);
+				                'password.required'        => trans('auth.password_null'),
+				                'password.min'             => trans('auth.password_limit'),
+				                'confirmPassword.required' => trans('auth.password_null'),
+				                'confirmPassword.min'      => trans('auth.password_limit'),
+				                'confirmPassword.same'     => trans('auth.password_same'),
+			                ]);
 			$password = $request->input('password');
 			// 校验账号
 			$verify = Verify::type(1)->with('user')->whereToken($token)->first();
@@ -584,7 +594,7 @@ class AuthController extends Controller
 			$verify = Verify::type(1)->whereToken($token)->first();
 			if(!$verify){
 				return Redirect::to('login');
-			}elseif(time()-strtotime($verify->created_at) >= 1800){
+			}elseif(time() - strtotime($verify->created_at) >= 1800){
 				// 置为已失效
 				$verify->status = 2;
 				$verify->save();
@@ -598,27 +608,28 @@ class AuthController extends Controller
 	}
 
 	// 激活账号页
-	public function activeUser(Request $request)
-	{
+	public function activeUser(Request $request) {
 		if($request->isMethod('POST')){
 			$this->validate($request, [
 				'email' => 'required|email|exists:user,email'
 			], [
-				'email.required' => trans('auth.email_null'),
-				'email.email'    => trans('auth.email_legitimate'),
-				'email.exists'   => trans('auth.email_notExist')
-			]);
+				                'email.required' => trans('auth.email_null'),
+				                'email.email'    => trans('auth.email_legitimate'),
+				                'email.exists'   => trans('auth.email_notExist')
+			                ]);
 			$email = $request->input('email');
 
 			// 是否开启账号激活
 			if(self::$systemConfig['is_activate_account'] != 2){
-				return Redirect::back()->withInput()->withErrors(trans('auth.active_close', ['email' => self::$systemConfig['webmaster_email']]));
+				return Redirect::back()->withInput()->withErrors(trans('auth.active_close',
+				                                                       ['email' => self::$systemConfig['webmaster_email']]));
 			}
 
 			// 查找账号
 			$user = User::query()->whereEmail($email)->first();
 			if($user->status < 0){
-				return Redirect::back()->withErrors(trans('auth.login_ban', ['email' => self::$systemConfig['webmaster_email']]));
+				return Redirect::back()->withErrors(trans('auth.login_ban',
+				                                          ['email' => self::$systemConfig['webmaster_email']]));
 			}elseif($user->status > 0){
 				return Redirect::back()->withErrors(trans('auth.email_normal'));
 			}
@@ -628,7 +639,8 @@ class AuthController extends Controller
 			if(Cache::has('activeUser_'.md5($email))){
 				$activeTimes = Cache::get('activeUser_'.md5($email));
 				if($activeTimes >= self::$systemConfig['active_times']){
-					return Redirect::back()->withErrors(trans('auth.active_limit', ['time' => self::$systemConfig['webmaster_email']]));
+					return Redirect::back()->withErrors(trans('auth.active_limit',
+					                                          ['time' => self::$systemConfig['webmaster_email']]));
 				}
 			}
 
@@ -641,7 +653,7 @@ class AuthController extends Controller
 			$logId = Helpers::addNotificationLog('激活账号', '请求地址:'.$activeUserUrl, 1, $email);
 			Mail::to($email)->send(new activeUser($logId, $activeUserUrl));
 
-			Cache::put('activeUser_'.md5($email), $activeTimes+1, 86400);
+			Cache::put('activeUser_'.md5($email), $activeTimes + 1, 86400);
 
 			return Redirect::back()->with('successMsg', trans('auth.register_active_tip'));
 		}else{
@@ -650,8 +662,7 @@ class AuthController extends Controller
 	}
 
 	// 激活账号
-	public function active($token)
-	{
+	public function active($token) {
 		if(!$token){
 			return Redirect::to('login');
 		}
@@ -671,7 +682,7 @@ class AuthController extends Controller
 			Session::flash('errorMsg', trans('auth.email_normal'));
 
 			return Response::view('auth.active');
-		}elseif(time()-strtotime($verify->created_at) >= 1800){
+		}elseif(time() - strtotime($verify->created_at) >= 1800){
 			Session::flash('errorMsg', trans('auth.overtime'));
 
 			// 置为已失效
@@ -695,9 +706,11 @@ class AuthController extends Controller
 
 		// 账号激活后给邀请人送流量
 		if($verify->user->referral_uid){
-			$transfer_enable = self::$systemConfig['referral_traffic']*1048576;
+			$transfer_enable = self::$systemConfig['referral_traffic'] * 1048576;
 
-			User::query()->whereId($verify->user->referral_uid)->increment('transfer_enable', $transfer_enable, ['enable' => 1]);
+			User::query()
+			    ->whereId($verify->user->referral_uid)
+			    ->increment('transfer_enable', $transfer_enable, ['enable' => 1]);
 		}
 
 		Session::flash('successMsg', trans('auth.active_success'));
@@ -706,15 +719,14 @@ class AuthController extends Controller
 	}
 
 	// 发送注册验证码
-	public function sendCode(Request $request)
-	{
+	public function sendCode(Request $request) {
 		$validator = Validator::make($request->all(), [
 			'email' => 'required|email|unique:user'
 		], [
-			'email.required' => trans('auth.email_null'),
-			'email.email'    => trans('auth.email_legitimate'),
-			'email.unique'   => trans('auth.email_exist')
-		]);
+			                             'email.required' => trans('auth.email_null'),
+			                             'email.email'    => trans('auth.email_legitimate'),
+			                             'email.unique'   => trans('auth.email_exist')
+		                             ]);
 
 		$email = $request->input('email');
 
@@ -725,7 +737,7 @@ class AuthController extends Controller
 		// 校验域名邮箱黑白名单
 		if(self::$systemConfig['is_email_filtering']){
 			$result = $this->emailChecker($email);
-			if($result != FALSE){
+			if($result != false){
 				return $result;
 			}
 		}
@@ -741,7 +753,7 @@ class AuthController extends Controller
 		}
 
 		// 发送邮件
-		$code = makeRandStr(6, TRUE);
+		$code = makeRandStr(6, true);
 		$logId = Helpers::addNotificationLog('发送注册验证码', '验证码:'.$code, 1, $email);
 		Mail::to($email)->send(new sendVerifyCode($logId, $code));
 
@@ -753,8 +765,7 @@ class AuthController extends Controller
 	}
 
 	// 生成注册验证码
-	private function addVerifyCode($email, $code)
-	{
+	private function addVerifyCode($email, $code) {
 		$verify = new VerifyCode();
 		$verify->address = $email;
 		$verify->code = $code;
@@ -763,18 +774,16 @@ class AuthController extends Controller
 	}
 
 	// 公开的邀请码列表
-	public function free()
-	{
+	public function free() {
 		$view['inviteList'] = Invite::query()->whereUid(0)->whereStatus(0)->paginate();
 
 		return Response::view('auth.free', $view);
 	}
 
 	// 切换语言
-	public function switchLang($locale)
-	{
+	public function switchLang($locale) {
 		Session::put("locale", $locale);
 
 		return Redirect::back();
 	}
-}
+}

+ 38 - 55
app/Http/Controllers/Controller.php

@@ -14,39 +14,34 @@ use Illuminate\Foundation\Bus\DispatchesJobs;
 use Illuminate\Foundation\Validation\ValidatesRequests;
 use Illuminate\Routing\Controller as BaseController;
 
-class Controller extends BaseController
-{
+class Controller extends BaseController {
 	use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
 
 	// 生成随机密码
-	public function makePasswd()
-	{
+	public function makePasswd() {
 		return makeRandStr();
 	}
 
 	// 生成VmessId
-	public function makeVmessId()
-	{
+	public function makeVmessId() {
 		return createGuid();
 	}
 
 	// 生成网站安全码
-	public function makeSecurityCode()
-	{
+	public function makeSecurityCode() {
 		return strtolower(makeRandStr(8));
 	}
 
 	// 类似Linux中的tail命令
-	public function tail($file, $n, $base = 5)
-	{
+	public function tail($file, $n, $base = 5) {
 		$fileLines = $this->countLine($file);
 		if($fileLines < 15000){
-			return FALSE;
+			return false;
 		}
 
 		$fp = fopen($file, "r+");
 		assert($n > 0);
-		$pos = $n+1;
+		$pos = $n + 1;
 		$lines = [];
 		while(count($lines) <= $n){
 			try{
@@ -72,13 +67,12 @@ class Controller extends BaseController
 	 *
 	 * @return int
 	 */
-	public function countLine($file)
-	{
+	public function countLine($file) {
 		$fp = fopen($file, "r");
 		$i = 0;
 		while(!feof($fp)){
 			//每次读取2M
-			if($data = fread($fp, 1024*1024*2)){
+			if($data = fread($fp, 1024 * 1024 * 2)){
 				//计算读取到的行数
 				$num = substr_count($data, "\n");
 				$i += $num;
@@ -91,14 +85,12 @@ class Controller extends BaseController
 	}
 
 	// 获取敏感词
-	public function sensitiveWords($type)
-	{
+	public function sensitiveWords($type) {
 		return SensitiveWords::query()->whereType($type)->get()->pluck('words')->toArray();
 	}
 
 	// 将Base64图片转换为本地图片并保存
-	function base64ImageSaver($base64_image_content)
-	{
+	function base64ImageSaver($base64_image_content) {
 		// 匹配出图片的格式
 		if(preg_match('/^(data:\s*image\/(\w+);base64,)/', $base64_image_content, $result)){
 			$type = $result[2];
@@ -106,11 +98,12 @@ class Controller extends BaseController
 			$directory = date('Ymd');
 			$path = '/assets/images/qrcode/'.$directory.'/';
 			if(!file_exists(public_path($path))){ // 检查是否有该文件夹,如果没有就创建,并给予最高权限
-				mkdir(public_path($path), 0755, TRUE);
+				mkdir(public_path($path), 0755, true);
 			}
 
-			$fileName = makeRandStr(18, TRUE).".{$type}";
-			if(file_put_contents(public_path($path.$fileName), base64_decode(str_replace($result[1], '', $base64_image_content)))){
+			$fileName = makeRandStr(18, true).".{$type}";
+			if(file_put_contents(public_path($path.$fileName),
+			                     base64_decode(str_replace($result[1], '', $base64_image_content)))){
 				chmod(public_path($path.$fileName), 0744);
 
 				return $path.$fileName;
@@ -125,24 +118,23 @@ class Controller extends BaseController
 	/**
 	 * 节点信息
 	 *
-	 * @param int $uid      用户ID
-	 * @param int $nodeId   节点ID
-	 * @param int $infoType 信息类型:0为链接,1为文字
+	 * @param  int  $uid       用户ID
+	 * @param  int  $nodeId    节点ID
+	 * @param  int  $infoType  信息类型:0为链接,1为文字
 	 *
 	 * @return string
 	 */
-	function getNodeInfo($uid, $nodeId, $infoType)
-	{
+	function getNodeInfo($uid, $nodeId, $infoType) {
 		$user = User::whereId($uid)->first();
 		$node = SsNode::whereId($nodeId)->first();
-		$scheme = NULL;
+		$scheme = null;
 		// 获取分组名称
 		$group = SsGroup::query()->whereId($node->group_id)->first();
-		$host = $node->server? : $node->ip;
+		$host = $node->server?: $node->ip;
 
 		if($node->type == 1){
 			$group = $group? $group->name : Helpers::systemConfig()['website_name'];
-			$obfs_param = $user->obfs_param? : $node->obfs_param;
+			$obfs_param = $user->obfs_param?: $node->obfs_param;
 			if($node->single){
 				$port = $node->port;
 				$protocol = $node->protocol;
@@ -167,35 +159,27 @@ class Controller extends BaseController
 				}
 			}else{
 				// 生成文本配置信息
-				$data = "服务器:".$host.PHP_EOL.
-					"IPv6:".($node->ipv6? : '').PHP_EOL.
-					"远程端口:".$port.PHP_EOL.
-					"密码:".$passwd.PHP_EOL.
-					"加密方法:".$method.PHP_EOL.
-					"路由:绕过局域网及中国大陆地址".PHP_EOL.
-					"协议:".$protocol.PHP_EOL.
-					"协议参数:".$protocol_param.PHP_EOL.
-					"混淆方式:".$obfs.PHP_EOL.
-					"混淆参数:".$obfs_param.PHP_EOL.
-					"本地端口:1080".PHP_EOL;
+				$data = "服务器:".$host.PHP_EOL."IPv6:".($node->ipv6?: '').PHP_EOL."远程端口:".$port.PHP_EOL."密码:".$passwd.PHP_EOL."加密方法:".$method.PHP_EOL."路由:绕过局域网及中国大陆地址".PHP_EOL."协议:".$protocol.PHP_EOL."协议参数:".$protocol_param.PHP_EOL."混淆方式:".$obfs.PHP_EOL."混淆参数:".$obfs_param.PHP_EOL."本地端口:1080".PHP_EOL;
 			}
 		}else{
 			// 生成v2ray scheme
 			if($infoType != 1){
 				// 生成v2ray scheme
-				$data = 'vmess://'.base64_encode(json_encode(["v" => "2", "ps" => $node->name, "add" => $host, "port" => $node->v2_port, "id" => $user->vmess_id, "aid" => $node->v2_alter_id, "net" => $node->v2_net, "type" => $node->v2_type, "host" => $node->v2_host, "path" => $node->v2_path, "tls" => $node->v2_tls? "tls" : ""], JSON_PRETTY_PRINT));
+				$data = 'vmess://'.base64_encode(json_encode([
+					                                             "v"    => "2",
+					                                             "ps"   => $node->name,
+					                                             "add"  => $host,
+					                                             "port" => $node->v2_port,
+					                                             "id"   => $user->vmess_id,
+					                                             "aid"  => $node->v2_alter_id,
+					                                             "net"  => $node->v2_net,
+					                                             "type" => $node->v2_type,
+					                                             "host" => $node->v2_host,
+					                                             "path" => $node->v2_path,
+					                                             "tls"  => $node->v2_tls? "tls" : ""
+				                                             ], JSON_PRETTY_PRINT));
 			}else{
-				$data = "服务器:".$host.PHP_EOL.
-					"IPv6:".($node->ipv6? : "").PHP_EOL.
-					"端口:".$node->v2_port.PHP_EOL.
-					"加密方式:".$node->v2_method.PHP_EOL.
-					"用户ID:".$user->vmess_id.PHP_EOL.
-					"额外ID:".$node->v2_alter_id.PHP_EOL.
-					"传输协议:".$node->v2_net.PHP_EOL.
-					"伪装类型:".$node->v2_type.PHP_EOL.
-					"伪装域名:".($node->v2_host? : "").PHP_EOL.
-					"路径:".($node->v2_path? : "").PHP_EOL.
-					"TLS:".($node->v2_tls? "tls" : "").PHP_EOL;
+				$data = "服务器:".$host.PHP_EOL."IPv6:".($node->ipv6?: "").PHP_EOL."端口:".$node->v2_port.PHP_EOL."加密方式:".$node->v2_method.PHP_EOL."用户ID:".$user->vmess_id.PHP_EOL."额外ID:".$node->v2_alter_id.PHP_EOL."传输协议:".$node->v2_net.PHP_EOL."伪装类型:".$node->v2_type.PHP_EOL."伪装域名:".($node->v2_host?: "").PHP_EOL."路径:".($node->v2_path?: "").PHP_EOL."TLS:".($node->v2_tls? "tls" : "").PHP_EOL;
 			}
 		}
 
@@ -203,8 +187,7 @@ class Controller extends BaseController
 	}
 
 	// 写入订阅访问日志
-	public function log($subscribeId, $ip, $headers)
-	{
+	public function log($subscribeId, $ip, $headers) {
 		$log = new UserSubscribeLog();
 		$log->sid = $subscribeId;
 		$log->request_ip = $ip;

+ 69 - 49
app/Http/Controllers/Gateway/AbstractPayment.php

@@ -13,27 +13,23 @@ use App\Http\Models\UserLabel;
 use Illuminate\Http\Request;
 use Log;
 
-abstract class AbstractPayment
-{
+abstract class AbstractPayment {
 	protected static $systemConfig;
 
-	function __construct()
-	{
+	function __construct() {
 		self::$systemConfig = Helpers::systemConfig();
 	}
 
-	public static function generateGuid()
-	{
-		mt_srand((double)microtime()*10000);
-		$charid = strtoupper(md5(uniqid(mt_rand()+time(), TRUE)));
+	public static function generateGuid() {
+		mt_srand((double) microtime() * 10000);
+		$charid = strtoupper(md5(uniqid(mt_rand() + time(), true)));
 		$hyphen = chr(45);
-		$uuid = chr(123)
-			.substr($charid, 0, 8).$hyphen
-			.substr($charid, 8, 4).$hyphen
-			.substr($charid, 12, 4).$hyphen
-			.substr($charid, 16, 4).$hyphen
-			.substr($charid, 20, 12)
-			.chr(125);
+		$uuid = chr(123).substr($charid, 0, 8).$hyphen.substr($charid, 8, 4).$hyphen.substr($charid, 12,
+		                                                                                    4).$hyphen.substr($charid,
+		                                                                                                      16,
+		                                                                                                      4).$hyphen.substr($charid,
+		                                                                                                                        20,
+		                                                                                                                        12).chr(125);
 		$uuid = str_replace(['}', '{', '-'], '', $uuid);
 		$uuid = substr($uuid, 0, 8);
 
@@ -49,8 +45,7 @@ abstract class AbstractPayment
 
 	abstract public function getPurchaseHTML();
 
-	public function postPayment($data, $method)
-	{
+	public function postPayment($data, $method) {
 		// 获取需要的信息
 		$payment = Payment::whereSn($data)->first();
 		// 是否为余额购买套餐
@@ -65,9 +60,10 @@ abstract class AbstractPayment
 
 		//余额充值
 		if($order->goods_id == -1){
-			User::query()->whereId($order->user_id)->increment('balance', $order->amount*100);
+			User::query()->whereId($order->user_id)->increment('balance', $order->amount * 100);
 			// 余额变动记录日志
-			Helpers::addUserBalanceLog($order->user_id, $order->oid, $order->user->balance, $order->user->balance+$order->amount, $order->amount, '用户'.$method.'充值余额');
+			Helpers::addUserBalanceLog($order->user_id, $order->oid, $order->user->balance,
+			                           $order->user->balance + $order->amount, $order->amount, '用户'.$method.'充值余额');
 
 			return 0;
 		}
@@ -77,11 +73,21 @@ abstract class AbstractPayment
 			case 1:
 				$order->status = 2;
 				$order->save();
-				User::query()->whereId($order->user_id)->increment('transfer_enable', $goods->traffic*1048576);
-				Helpers::addUserTrafficModifyLog($order->user_id, $order->oid, $user->transfer_enable, $user->transfer_enable+$goods->traffic*1048576, '['.$method.']加上用户购买的套餐流量');
+				User::query()->whereId($order->user_id)->increment('transfer_enable', $goods->traffic * 1048576);
+				Helpers::addUserTrafficModifyLog($order->user_id, $order->oid, $user->transfer_enable,
+				                                 $user->transfer_enable + $goods->traffic * 1048576,
+				                                 '['.$method.']加上用户购买的套餐流量');
 				break;
 			case 2:
-				$activePlan = Order::query()->whereUserId($user->id)->with(['goods'])->whereIsExpire(0)->whereStatus(2)->whereHas('goods', function($q){ $q->whereType(2); })->exists();
+				$activePlan = Order::query()
+				                   ->whereUserId($user->id)
+				                   ->with(['goods'])
+				                   ->whereIsExpire(0)
+				                   ->whereStatus(2)
+				                   ->whereHas('goods', function($q) {
+					                   $q->whereType(2);
+				                   })
+				                   ->exists();
 
 				// 2为开始生效,3为预支付
 				$order->status = $activePlan? 3 : 2;
@@ -89,30 +95,31 @@ abstract class AbstractPayment
 
 				if($activePlan){
 					// 预支付订单, 刷新账号有效时间用于流量重置判断
-					User::query()->whereId($order->user_id)->update(['expire_time' => date('Y-m-d', strtotime("+".$goods->days." days", strtotime($user->expire_time)))]);
+					User::query()->whereId($order->user_id)->update([
+						                                                'expire_time' => date('Y-m-d',
+						                                                                      strtotime("+".$goods->days." days",
+						                                                                                strtotime($user->expire_time)))
+					                                                ]);
 				}else{
 					// 如果买的是套餐,则先将之前购买的套餐都无效化,重置用户已用、可用流量为0
-					Order::query()
-						->whereUserId($user->id)
-						->with(['goods'])
-						->whereHas('goods', function($q){
-							$q->where('type', '<=', 2);
-						})
-						->whereIsExpire(0)
-						->whereStatus(2)
-						->where('oid', '<>', $order->oid)
-						->update(['expire_at' => date('Y-m-d H:i:s'), 'is_expire' => 1]);
+					Order::query()->whereUserId($user->id)->with(['goods'])->whereHas('goods', function($q) {
+						$q->where('type', '<=', 2);
+					})->whereIsExpire(0)->whereStatus(2)->where('oid', '<>', $order->oid)->update([
+						                                                                              'expire_at' => date('Y-m-d H:i:s'),
+						                                                                              'is_expire' => 1
+					                                                                              ]);
 
 					User::query()->whereId($order->user_id)->update(['u' => 0, 'd' => 0, 'transfer_enable' => 0]);
-					Helpers::addUserTrafficModifyLog($order->user_id, $order->oid, $user->transfer_enable, 0, '['.$method.']用户购买新套餐,先清空流量');
+					Helpers::addUserTrafficModifyLog($order->user_id, $order->oid, $user->transfer_enable, 0,
+					                                 '['.$method.']用户购买新套餐,先清空流量');
 
-					$userTraffic = $goods->traffic*1048576;
+					$userTraffic = $goods->traffic * 1048576;
 					// 添加账号有效期
 					$expireTime = date('Y-m-d', strtotime("+".$goods->days." days"));
 					//账号下一个重置时间
 					$nextResetTime = date('Y-m-d', strtotime("+".$goods->period." days"));
 					if($nextResetTime >= $expireTime){
-						$nextResetTime = NULL;
+						$nextResetTime = null;
 					}
 
 					// 写入用户标签
@@ -121,7 +128,12 @@ abstract class AbstractPayment
 						UserLabel::query()->whereUserId($order->user_id)->delete();
 
 						//取出 商品默认标签  & 系统默认标签 去重
-						$newUserLabels = array_values(array_unique(array_merge(GoodsLabel::query()->whereGoodsId($order->goods_id)->pluck('label_id')->toArray(), self::$systemConfig['initial_labels_for_user']? explode(',', self::$systemConfig['initial_labels_for_user']) : [])));
+						$newUserLabels = array_values(array_unique(array_merge(GoodsLabel::query()
+						                                                                 ->whereGoodsId($order->goods_id)
+						                                                                 ->pluck('label_id')
+						                                                                 ->toArray(),
+						                                                       self::$systemConfig['initial_labels_for_user']? explode(',',
+						                                                                                                               self::$systemConfig['initial_labels_for_user']) : [])));
 
 						// 生成标签
 						foreach($newUserLabels as $Label){
@@ -132,8 +144,14 @@ abstract class AbstractPayment
 						}
 					}
 
-					User::query()->whereId($order->user_id)->increment('invite_num', $goods->invite_num? : 0, ['transfer_enable' => $userTraffic, 'reset_time' => $nextResetTime, 'expire_time' => $expireTime, 'enable' => 1]);
-					Helpers::addUserTrafficModifyLog($order->user_id, $order->oid, $user->transfer_enable, $userTraffic, '['.$method.']加上用户购买的套餐流量');
+					User::query()->whereId($order->user_id)->increment('invite_num', $goods->invite_num?: 0, [
+						'transfer_enable' => $userTraffic,
+						'reset_time'      => $nextResetTime,
+						'expire_time'     => $expireTime,
+						'enable'          => 1
+					]);
+					Helpers::addUserTrafficModifyLog($order->user_id, $order->oid, $user->transfer_enable, $userTraffic,
+					                                 '['.$method.']加上用户购买的套餐流量');
 				}
 
 				// 是否返利
@@ -146,8 +164,11 @@ abstract class AbstractPayment
 						User::query()->whereId($order->user->referral_uid)->increment('invite_num', 1);
 					}
 					//按照返利模式进行返利判断
-					if(self::$systemConfig['referral_type'] == 2 || (self::$systemConfig['referral_type'] == 1 && !$referral)){
-						$this->addReferralLog($order->user_id, $order->user->referral_uid, $order->oid, $order->amount, $order->amount*self::$systemConfig['referral_percent']);
+					if(self::$systemConfig['referral_type'] == 2
+					   || (self::$systemConfig['referral_type'] == 1
+					       && !$referral)){
+						$this->addReferralLog($order->user_id, $order->user->referral_uid, $order->oid, $order->amount,
+						                      $order->amount * self::$systemConfig['referral_percent']);
 					}
 				}
 
@@ -162,16 +183,15 @@ abstract class AbstractPayment
 	/**
 	 * 添加返利日志
 	 *
-	 * @param int $userId    用户ID
-	 * @param int $refUserId 返利用户ID
-	 * @param int $oid       订单ID
-	 * @param int $amount    发生金额
-	 * @param int $refAmount 返利金额
+	 * @param  int  $userId     用户ID
+	 * @param  int  $refUserId  返利用户ID
+	 * @param  int  $oid        订单ID
+	 * @param  int  $amount     发生金额
+	 * @param  int  $refAmount  返利金额
 	 *
 	 * @return int
 	 */
-	private function addReferralLog($userId, $refUserId, $oid, $amount, $refAmount)
-	{
+	private function addReferralLog($userId, $refUserId, $oid, $amount, $refAmount) {
 		$log = new ReferralLog();
 		$log->user_id = $userId;
 		$log->ref_user_id = $refUserId;
@@ -182,4 +202,4 @@ abstract class AbstractPayment
 
 		return $log->save();
 	}
-}
+}

+ 25 - 30
app/Http/Controllers/Gateway/BitpayX.php

@@ -9,17 +9,15 @@ use Auth;
 use Illuminate\Http\Request;
 use Response;
 
-class BitpayX extends AbstractPayment
-{
+class BitpayX extends AbstractPayment {
 	private $bitpayGatewayUri = 'https://api.mugglepay.com/v1/';
 
 	/**
-	 * @param Request $request
+	 * @param  Request  $request
 	 *
 	 * @return mixed
 	 */
-	public function purchase(Request $request)
-	{
+	public function purchase(Request $request) {
 		$payment = new Payment();
 		$payment->sn = self::generateGuid();
 		$payment->user_id = Auth::user()->id;
@@ -29,38 +27,40 @@ class BitpayX extends AbstractPayment
 
 		$data = [
 			'merchant_order_id' => $payment->sn,
-			'price_amount'      => (float)$request->input('amount'),
+			'price_amount'      => (float) $request->input('amount'),
 			'price_currency'    => 'CNY',
 			'pay_currency'      => $request->input('type') == 1? 'ALIPAY' : 'WECHAT',
 			'title'             => '支付单号:'.$payment->sn,
-			'description'       => parent::$systemConfig['subject_name']? : parent::$systemConfig['website_name'],
-			'callback_url'      => (parent::$systemConfig['website_callback_url']? : parent::$systemConfig['website_url']).'/callback/notify?method=bitpayx',
+			'description'       => parent::$systemConfig['subject_name']?: parent::$systemConfig['website_name'],
+			'callback_url'      => (parent::$systemConfig['website_callback_url']?: parent::$systemConfig['website_url']).'/callback/notify?method=bitpayx',
 			'success_url'       => parent::$systemConfig['website_url'].'/invoices',
 			'cancel_url'        => parent::$systemConfig['website_url'],
 			'token'             => $this->sign($this->prepareSignId($payment->sn)),
 
 		];
 
-		$result = json_decode($this->mprequest($data), TRUE);
+		$result = json_decode($this->mprequest($data), true);
 
 
 		if($result['status'] === 200 || $result['status'] === 201){
 			$result['payment_url'] .= '&lang=zh';
 			Payment::whereId($payment->id)->update(['url' => $result['payment_url']]);
 
-			return Response::json(['status' => 'success', 'url' => $result['payment_url'] .= '&lang=zh', 'message' => '创建订单成功!']);
+			return Response::json([
+				                      'status'  => 'success',
+				                      'url'     => $result['payment_url'] .= '&lang=zh',
+				                      'message' => '创建订单成功!'
+			                      ]);
 		}
 
 		return Response::json(['status' => 'fail', 'data' => $result, 'message' => '创建订单失败!']);
 	}
 
-	public function sign($data)
-	{
+	public function sign($data) {
 		return strtolower(md5(md5($data).parent::$systemConfig['bitpay_secret']));
 	}
 
-	public function prepareSignId($tradeno)
-	{
+	public function prepareSignId($tradeno) {
 		$data_sign = [
 			'merchant_order_id' => $tradeno,
 			'secret'            => parent::$systemConfig['bitpay_secret'],
@@ -71,8 +71,7 @@ class BitpayX extends AbstractPayment
 		return http_build_query($data_sign);
 	}
 
-	public function mprequest($data, $type = 'pay')
-	{
+	public function mprequest($data, $type = 'pay') {
 		$headers = ['content-type: application/json', 'token: '.parent::$systemConfig['bitpay_secret']];
 		$curl = curl_init();
 		if($type === 'pay'){
@@ -88,21 +87,20 @@ class BitpayX extends AbstractPayment
 		}
 		curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
 		curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
-		curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
-		curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
+		curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
+		curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
 		$data = curl_exec($curl);
 		curl_close($curl);
 
 		return $data;
 	}
 
-	public function notify(Request $request)
-	{
+	public function notify(Request $request) {
 		$inputString = file_get_contents('php://input', 'r');
 		$inputStripped = str_replace(["\r", "\n", "\t", "\v"], '', $inputString);
-		$inputJSON = json_decode($inputStripped, TRUE); //convert JSON into array
+		$inputJSON = json_decode($inputStripped, true); //convert JSON into array
 		$data = [];
-		if($inputJSON !== NULL){
+		if($inputJSON !== null){
 			$data = [
 				'status'            => $inputJSON['status'],
 				'order_id'          => $inputJSON['order_id'],
@@ -115,7 +113,7 @@ class BitpayX extends AbstractPayment
 		// 准备待签名数据
 		$str_to_sign = $this->prepareSignId($inputJSON['merchant_order_id']);
 		$resultVerify = $this->verify($str_to_sign, $inputJSON['token']);
-		$isPaid = $data !== NULL && $data['status'] !== NULL && $data['status'] === 'PAID';
+		$isPaid = $data !== null && $data['status'] !== null && $data['status'] === 'PAID';
 
 		if($resultVerify && $isPaid){
 			$this->postPayment($inputJSON['merchant_order_id'], 'BitPayX');
@@ -130,20 +128,17 @@ class BitpayX extends AbstractPayment
 		exit();
 	}
 
-	public function verify($data, $signature)
-	{
+	public function verify($data, $signature) {
 		$mySign = $this->sign($data);
 
 		return $mySign === $signature;
 	}
 
-	public function getReturnHTML(Request $request)
-	{
+	public function getReturnHTML(Request $request) {
 		// TODO: Implement getReturnHTML() method.
 	}
 
-	public function getPurchaseHTML()
-	{
+	public function getPurchaseHTML() {
 		// TODO: Implement getPurchaseHTML() method.
 	}
-}
+}

+ 8 - 13
app/Http/Controllers/Gateway/CodePay.php

@@ -6,10 +6,8 @@ use App\Http\Models\Payment;
 use Auth;
 use Response;
 
-class CodePay extends AbstractPayment
-{
-	public function purchase($request)
-	{
+class CodePay extends AbstractPayment {
+	public function purchase($request) {
 		$payment = new Payment();
 		$payment->sn = self::generateGuid();
 		$payment->user_id = Auth::user()->id;
@@ -20,12 +18,12 @@ class CodePay extends AbstractPayment
 		$data = [
 			'id'         => parent::$systemConfig['codepay_id'],
 			'pay_id'     => $payment->sn,
-			'type'       => $request->input('type'),//1支付宝支付 2QQ钱包 3微信支付
+			'type'       => $request->input('type'),            //1支付宝支付 2QQ钱包 3微信支付
 			'price'      => $payment->amount,
 			'page'       => 1,
 			'outTime'    => 900,
 			'param'      => '',
-			'notify_url' => (parent::$systemConfig['website_callback_url']? : parent::$systemConfig['website_url']).'/callback/notify?method=codepay',
+			'notify_url' => (parent::$systemConfig['website_callback_url']?: parent::$systemConfig['website_url']).'/callback/notify?method=codepay',
 			'return_url' => parent::$systemConfig['website_url'].'/invoices',
 		];
 
@@ -53,8 +51,7 @@ class CodePay extends AbstractPayment
 		return Response::json(['status' => 'success', 'url' => $url, 'message' => '创建订单成功!']);
 	}
 
-	public function notify($request)
-	{
+	public function notify($request) {
 		ksort($_POST);
 		reset($_POST);
 		$sign = '';
@@ -81,13 +78,11 @@ class CodePay extends AbstractPayment
 		exit('fail');
 	}
 
-	public function getReturnHTML($request)
-	{
+	public function getReturnHTML($request) {
 		// TODO: Implement getReturnHTML() method.
 	}
 
-	public function getPurchaseHTML()
-	{
+	public function getPurchaseHTML() {
 		// TODO: Implement getReturnHTML() method.
 	}
-}
+}

+ 15 - 19
app/Http/Controllers/Gateway/F2Fpay.php

@@ -12,28 +12,25 @@ use Payment\Exceptions\ClassNotFoundException;
 use Payment\Exceptions\GatewayException;
 use Response;
 
-class F2Fpay extends AbstractPayment
-{
+class F2Fpay extends AbstractPayment {
 	private static $aliConfig;
 
-	function __construct()
-	{
+	function __construct() {
 		parent::__construct();
 		self::$aliConfig = [
-			'use_sandbox'     => FALSE,
+			'use_sandbox'     => false,
 			'app_id'          => self::$systemConfig['f2fpay_app_id'],
 			'sign_type'       => 'RSA2',
 			'ali_public_key'  => self::$systemConfig['f2fpay_public_key'],
 			'rsa_private_key' => self::$systemConfig['f2fpay_private_key'],
 			'limit_pay'       => [],
-			'notify_url'      => (self::$systemConfig['website_callback_url']? : self::$systemConfig['website_url']).'/callback/notify?method=f2fpay',
+			'notify_url'      => (self::$systemConfig['website_callback_url']?: self::$systemConfig['website_url']).'/callback/notify?method=f2fpay',
 			'return_url'      => self::$systemConfig['website_url'].'/invoices',
 			'fee_type'        => 'CNY',
 		];
 	}
 
-	public function purchase($request)
-	{
+	public function purchase($request) {
 		$payment = new Payment();
 		$payment->sn = self::generateGuid();
 		$payment->user_id = Auth::user()->id;
@@ -43,9 +40,9 @@ class F2Fpay extends AbstractPayment
 
 		$data = [
 			'body'        => '',
-			'subject'     => self::$systemConfig['subject_name']? : self::$systemConfig['website_name'],
+			'subject'     => self::$systemConfig['subject_name']?: self::$systemConfig['website_name'],
 			'trade_no'    => $payment->sn,
-			'time_expire' => time()+900, // 必须 15分钟 内付款
+			'time_expire' => time() + 900, // 必须 15分钟 内付款
 			'amount'      => $payment->amount,
 		];
 
@@ -67,13 +64,14 @@ class F2Fpay extends AbstractPayment
 			exit;
 		}
 
-		Payment::whereId($payment->id)->update(['qr_code' => 'http://qr.topscan.com/api.php?text='.$result['qr_code'].'&bg=ffffff&fg=000000&pt=1c73bd&m=10&w=400&el=1&inpt=1eabfc&logo=https://t.alipayobjects.com/tfscom/T1Z5XfXdxmXXXXXXXX.png']);//后备:https://cli.im/api/qrcode/code?text=".$result['qr_code']."&mhid=5EfGCwztyckhMHcmI9ZcOKs
+		Payment::whereId($payment->id)->update([
+			                                       'qr_code' => 'http://qr.topscan.com/api.php?text='.$result['qr_code'].'&bg=ffffff&fg=000000&pt=1c73bd&m=10&w=400&el=1&inpt=1eabfc&logo=https://t.alipayobjects.com/tfscom/T1Z5XfXdxmXXXXXXXX.png'
+		                                       ]);//后备:https://cli.im/api/qrcode/code?text=".$result['qr_code']."&mhid=5EfGCwztyckhMHcmI9ZcOKs
 
 		return Response::json(['status' => 'success', 'data' => $payment->sn, 'message' => '创建订单成功!']);
 	}
 
-	public function notify($request)
-	{
+	public function notify($request) {
 		$data = [
 			'trade_no'       => $request->input('out_trade_no'),
 			'transaction_id' => $request->input('trade_no'),
@@ -82,7 +80,7 @@ class F2Fpay extends AbstractPayment
 		try{
 			$client = new Client(Client::ALIPAY, self::$aliConfig);
 			$result = $client->tradeQuery($data);
-			Log::info("【支付宝当面付】回调验证查询:".var_export($result, TRUE));
+			Log::info("【支付宝当面付】回调验证查询:".var_export($result, true));
 		}catch(InvalidArgumentException $e){
 			Log::error("【支付宝当面付】回调信息错误: ".$e->getMessage());
 			exit;
@@ -113,13 +111,11 @@ class F2Fpay extends AbstractPayment
 		exit($ret);
 	}
 
-	public function getReturnHTML($request)
-	{
+	public function getReturnHTML($request) {
 		// TODO: Implement getReturnHTML() method.
 	}
 
-	public function getPurchaseHTML()
-	{
+	public function getPurchaseHTML() {
 		// TODO: Implement getReturnHTML() method.
 	}
-}
+}

+ 9 - 13
app/Http/Controllers/Gateway/Local.php

@@ -11,18 +11,17 @@ use Auth;
 use Illuminate\Http\Request;
 use Response;
 
-class Local extends AbstractPayment
-{
-	public function purchase(Request $request)
-	{
+class Local extends AbstractPayment {
+	public function purchase(Request $request) {
 		$amount = $request->input('amount');
 		$order = Order::whereOid($request->input('oid'))->first();
 		$goods = Goods::query()->whereStatus(1)->whereId($request->input('goods_id'))->first();
 
 		if($goods){
-			User::query()->whereId(Auth::user()->id)->decrement('balance', $amount*100);
+			User::query()->whereId(Auth::user()->id)->decrement('balance', $amount * 100);
 			// 记录余额操作日志
-			Helpers::addUserBalanceLog(Auth::user()->id, $order->oid, Auth::user()->balance, Auth::user()->balance-$amount, -1*$amount, '购买商品:'.$goods->name);
+			Helpers::addUserBalanceLog(Auth::user()->id, $order->oid, Auth::user()->balance,
+			                           Auth::user()->balance - $amount, -1 * $amount, '购买商品:'.$goods->name);
 		}
 
 		self::postPayment($order->oid, '余额');
@@ -30,18 +29,15 @@ class Local extends AbstractPayment
 		return Response::json(['status' => 'success', 'message' => '购买完成!']);
 	}
 
-	public function notify(Request $request)
-	{
+	public function notify(Request $request) {
 		// TODO: Implement notify() method.
 	}
 
-	public function getReturnHTML(Request $request)
-	{
+	public function getReturnHTML(Request $request) {
 		// TODO: Implement getReturnHTML() method.
 	}
 
-	public function getPurchaseHTML()
-	{
+	public function getPurchaseHTML() {
 		// TODO: Implement getPurchaseHTML() method.
 	}
-}
+}

+ 13 - 19
app/Http/Controllers/Gateway/PayJs.php

@@ -8,12 +8,10 @@ use Log;
 use Response;
 use Xhat\Payjs\Payjs as Pay;
 
-class PayJs extends AbstractPayment
-{
+class PayJs extends AbstractPayment {
 	private static $config;
 
-	function __construct()
-	{
+	function __construct() {
 		parent::__construct();
 		self::$config = [
 			'mchid' => self::$systemConfig['payjs_mch_id'],   // 配置商户号
@@ -21,8 +19,7 @@ class PayJs extends AbstractPayment
 		];
 	}
 
-	public function purchase($request)
-	{
+	public function purchase($request) {
 		$payment = new Payment();
 		$payment->sn = self::generateGuid();
 		$payment->user_id = Auth::user()->id;
@@ -31,12 +28,12 @@ class PayJs extends AbstractPayment
 		$payment->save();
 
 		$result = (new Pay($this::$config))->native([
-			'body'         => parent::$systemConfig['subject_name']? : parent::$systemConfig['website_name'],
-			'total_fee'    => $payment->amount*100,
-			'out_trade_no' => $payment->sn,
-			'attach'       => '',
-			'notify_url'   => (parent::$systemConfig['website_callback_url']? : parent::$systemConfig['website_url']).'/callback/notify?method=payjs',
-		]);
+			                                            'body'         => parent::$systemConfig['subject_name']?: parent::$systemConfig['website_name'],
+			                                            'total_fee'    => $payment->amount * 100,
+			                                            'out_trade_no' => $payment->sn,
+			                                            'attach'       => '',
+			                                            'notify_url'   => (parent::$systemConfig['website_callback_url']?: parent::$systemConfig['website_url']).'/callback/notify?method=payjs',
+		                                            ]);
 
 		if(!$result->return_code){
 			Log::error('PayJs '.$result->return_msg);
@@ -47,8 +44,7 @@ class PayJs extends AbstractPayment
 		return Response::json(['status' => 'success', 'data' => $payment->sn, 'message' => '创建订单成功!']);
 	}
 
-	public function notify($request)
-	{
+	public function notify($request) {
 		$data = (new Pay($this::$config))->notify();
 
 		if($data['return_code'] == 1){
@@ -58,13 +54,11 @@ class PayJs extends AbstractPayment
 		exit("fail");
 	}
 
-	public function getReturnHTML($request)
-	{
+	public function getReturnHTML($request) {
 		// TODO: Implement getReturnHTML() method.
 	}
 
-	public function getPurchaseHTML()
-	{
+	public function getPurchaseHTML() {
 		// TODO: Implement getReturnHTML() method.
 	}
-}
+}

+ 18 - 25
app/Http/Controllers/Gateway/PayPal.php

@@ -13,13 +13,11 @@ use Log;
 use Response;
 use Srmklive\PayPal\Services\ExpressCheckout;
 
-class PayPal extends AbstractPayment
-{
+class PayPal extends AbstractPayment {
 	protected $provider;
 	protected $exChange;
 
-	public function __construct()
-	{
+	public function __construct() {
 		parent::__construct();
 		$this->provider = new ExpressCheckout();
 		$config = [
@@ -35,13 +33,14 @@ class PayPal extends AbstractPayment
 			'payment_action' => 'Sale',
 			'currency'       => 'USD',
 			'billing_type'   => 'MerchantInitiatedBilling',
-			'notify_url'     => (self::$systemConfig['website_callback_url']? : self::$systemConfig['website_url']).'/callback/notify?method=paypal',
+			'notify_url'     => (self::$systemConfig['website_callback_url']?: self::$systemConfig['website_url']).'/callback/notify?method=paypal',
 			'locale'         => 'zh_CN',
-			'validate_ssl'   => TRUE,
+			'validate_ssl'   => true,
 		];
 		$this->provider->setApiCredentials($config);
 		$this->exChange = 7;
-		$exChangeRate = json_decode(Curl::send('http://api.k780.com/?app=finance.rate&scur=USD&tcur=CNY&appkey=10003&sign=b59bc3ef6191eb9f747dd4e83c99f2a4'), TRUE);
+		$exChangeRate = json_decode(Curl::send('http://api.k780.com/?app=finance.rate&scur=USD&tcur=CNY&appkey=10003&sign=b59bc3ef6191eb9f747dd4e83c99f2a4'),
+		                            true);
 		if($exChangeRate){
 			if($exChangeRate['success']){
 				$this->exChange = $exChangeRate['result']['rate'];
@@ -49,8 +48,7 @@ class PayPal extends AbstractPayment
 		}
 	}
 
-	public function purchase(Request $request)
-	{
+	public function purchase(Request $request) {
 		$payment = new Payment();
 		$payment->sn = self::generateGuid();
 		$payment->user_id = Auth::user()->id;
@@ -63,7 +61,7 @@ class PayPal extends AbstractPayment
 		try{
 			$response = $this->provider->setExpressCheckout($data);
 			if(!$response['paypal_link']){
-				Log::error(var_export($response, TRUE));
+				Log::error(var_export($response, true));
 
 				return Response::json(['status' => 'fail', 'message' => '创建订单失败,请使用其他方式或通知管理员!']);
 			}
@@ -76,17 +74,16 @@ class PayPal extends AbstractPayment
 		}
 	}
 
-	protected function getCheckoutData($sn, $amount)
-	{
-		$amount = 0.3+ceil($amount/$this->exChange*100)/100;
+	protected function getCheckoutData($sn, $amount) {
+		$amount = 0.3 + ceil($amount / $this->exChange * 100) / 100;
 
 		return [
 			'invoice_id'          => $sn,
 			'items'               => [
 				[
-					'name'  => self::$systemConfig['subject_name']? : self::$systemConfig['website_name'],
+					'name'  => self::$systemConfig['subject_name']?: self::$systemConfig['website_name'],
 					'price' => $amount,
-					'desc'  => 'Description for'.(self::$systemConfig['subject_name']? : self::$systemConfig['website_name']),
+					'desc'  => 'Description for'.(self::$systemConfig['subject_name']?: self::$systemConfig['website_name']),
 					'qty'   => 1
 				]
 			],
@@ -97,8 +94,7 @@ class PayPal extends AbstractPayment
 		];
 	}
 
-	public function getCheckout(Request $request)
-	{
+	public function getCheckout(Request $request) {
 		$token = $request->get('token');
 		$PayerID = $request->get('PayerID');
 
@@ -123,12 +119,11 @@ class PayPal extends AbstractPayment
 		return redirect('/invoices');
 	}
 
-	public function notify(Request $request)
-	{
+	public function notify(Request $request) {
 		$request->merge(['cmd' => '_notify-validate']);
 		$post = $request->all();
 
-		$response = (string)$this->provider->verifyIPN($post);
+		$response = (string) $this->provider->verifyIPN($post);
 
 		if($response === 'VERIFIED' && $request['mp_desc']){
 			if(Payment::whereSn($request['mp_desc'])->first()->status == 0){
@@ -139,13 +134,11 @@ class PayPal extends AbstractPayment
 		exit("fail");
 	}
 
-	public function getReturnHTML(Request $request)
-	{
+	public function getReturnHTML(Request $request) {
 		// TODO: Implement getReturnHTML() method.
 	}
 
-	public function getPurchaseHTML()
-	{
+	public function getPurchaseHTML() {
 		// TODO: Implement getPurchaseHTML() method.
 	}
-}
+}

+ 23 - 26
app/Http/Controllers/PaymentController.php

@@ -26,22 +26,19 @@ use Response;
  *
  * @package App\Http\Controllers
  */
-class PaymentController extends Controller
-{
+class PaymentController extends Controller {
 	private static $method;
 
-	public static function notify(Request $request)
-	{
+	public static function notify(Request $request) {
 		self::$method = $request->input('method');
 
-		Log::info(self::$method."回调接口[POST]:".self::$method.var_export($request->all(), TRUE));
+		Log::info(self::$method."回调接口[POST]:".self::$method.var_export($request->all(), true));
 		self::getClient()->notify($request);
 
 		return 0;
 	}
 
-	public static function getClient()
-	{
+	public static function getClient() {
 		switch(self::$method){
 			case 'balance':
 				return new Local();
@@ -58,22 +55,19 @@ class PaymentController extends Controller
 			default:
 				Log::error("未知支付:".self::$method);
 
-				return NULL;
+				return null;
 		}
 	}
 
-	public static function returnHTML(Request $request)
-	{
+	public static function returnHTML(Request $request) {
 		return self::getClient()->getReturnHTML($request);
 	}
 
-	public static function purchaseHTML()
-	{
+	public static function purchaseHTML() {
 		return Response::view('user.components.purchase');
 	}
 
-	public static function getStatus(Request $request)
-	{
+	public static function getStatus(Request $request) {
 		$payment = Payment::whereSn($request->input('sn'))->first();
 		if($payment){
 			if($payment->status == 1){
@@ -89,8 +83,7 @@ class PaymentController extends Controller
 	}
 
 	// 创建支付订单
-	public function purchase(Request $request)
-	{
+	public function purchase(Request $request) {
 		$goods_id = $request->input('goods_id');
 		$coupon_sn = $request->input('coupon_sn');
 		self::$method = $request->input('method');
@@ -110,7 +103,9 @@ class PaymentController extends Controller
 			}
 
 			// 是否有生效的套餐
-			$activePlan = Order::uid()->with(['goods'])->whereHas('goods', function($q){ $q->whereType(2); })->whereStatus(2)->whereIsExpire(0)->doesntExist();
+			$activePlan = Order::uid()->with(['goods'])->whereHas('goods', function($q) {
+				$q->whereType(2);
+			})->whereStatus(2)->whereIsExpire(0)->doesntExist();
 
 			//无生效套餐,禁止购买加油包
 			if($goods->type == 1 && $activePlan){
@@ -135,7 +130,11 @@ class PaymentController extends Controller
 			if($goods->limit_num){
 				$count = Order::uid()->where('status', '>=', 0)->whereGoodsId($goods_id)->count();
 				if($count >= $goods->limit_num){
-					return Response::json(['status' => 'fail', 'data' => '', 'message' => '此商品/服务限购'.$goods->limit_num.'次,您已购买'.$count.'次']);
+					return Response::json([
+						                      'status'  => 'fail',
+						                      'data'    => '',
+						                      'message' => '此商品/服务限购'.$goods->limit_num.'次,您已购买'.$count.'次'
+					                      ]);
 				}
 			}
 
@@ -147,7 +146,7 @@ class PaymentController extends Controller
 				}
 
 				// 计算实际应支付总价
-				$amount = $coupon->type == 2? $goods->price*$coupon->discount/10 : $goods->price-$coupon->amount;
+				$amount = $coupon->type == 2? $goods->price * $coupon->discount / 10 : $goods->price - $coupon->amount;
 				$amount = $amount > 0? round($amount, 2) : 0; // 四舍五入保留2位小数,避免无法正常创建订单
 			}else{
 				$amount = $goods->price;
@@ -174,9 +173,9 @@ class PaymentController extends Controller
 		$order->user_id = Auth::user()->id;
 		$order->goods_id = $balance? -1 : $goods_id;
 		$order->coupon_id = !empty($coupon)? $coupon->id : 0;
-		$order->origin_amount = $balance? : $goods->price;
+		$order->origin_amount = $balance?: $goods->price;
 		$order->amount = $amount;
-		$order->expire_at = $balance? NULL : date("Y-m-d H:i:s", strtotime("+".$goods->days." days"));
+		$order->expire_at = $balance? null : date("Y-m-d H:i:s", strtotime("+".$goods->days." days"));
 		$order->is_expire = 0;
 		$order->pay_way = self::$method;
 		$order->status = 0;
@@ -199,8 +198,7 @@ class PaymentController extends Controller
 	}
 
 	// 支付单详情
-	public function detail($sn)
-	{
+	public function detail($sn) {
 		$payment = Payment::uid()->with(['order', 'order.goods'])->whereSn($sn)->first();
 		$view['payment'] = $payment;
 		$view['name'] = $payment->order->goods? $payment->order->goods->name : '余额充值';
@@ -210,8 +208,7 @@ class PaymentController extends Controller
 	}
 
 	// 回调日志
-	public function callbackList(Request $request)
-	{
+	public function callbackList(Request $request) {
 		$status = $request->input('status', 0);
 
 		$query = PaymentCallback::query();
@@ -224,4 +221,4 @@ class PaymentController extends Controller
 
 		return Response::view('admin.logs.callbackList', $view);
 	}
-}
+}

+ 29 - 13
app/Http/Controllers/ServiceController.php

@@ -10,22 +10,27 @@ use App\Http\Models\Order;
 use App\Http\Models\User;
 use App\Http\Models\UserLabel;
 
-class ServiceController extends Controller
-{
-	public function activePrepaidOrder($oid)
-	{
+class ServiceController extends Controller {
+	public function activePrepaidOrder($oid) {
 		// 取出预支付订单
 		$prepaidOrder = Order::find($oid);
 		//去除使用中的套餐和 流量包
-		Order::query()->whereUserId($prepaidOrder->user_id)->whereStatus(2)->whereIsExpire(0)->update(['expire_at' => date('Y-m-d H:i:s'), 'is_expire' => 1]);
+		Order::query()->whereUserId($prepaidOrder->user_id)->whereStatus(2)->whereIsExpire(0)->update([
+			                                                                                              'expire_at' => date('Y-m-d H:i:s'),
+			                                                                                              'is_expire' => 1
+		                                                                                              ]);
 		//取出对应套餐信息
 		$prepaidGood = Goods::query()->whereId($prepaidOrder->goods_id)->first();
 		//激活预支付套餐
-		Order::query()->whereOid($prepaidOrder->oid)->update(['expire_at' => date("Y-m-d H:i:s", strtotime("+".$prepaidGood->days." days")), 'status' => 2]);
+		Order::query()->whereOid($prepaidOrder->oid)->update([
+			                                                     'expire_at' => date("Y-m-d H:i:s",
+			                                                                         strtotime("+".$prepaidGood->days." days")),
+			                                                     'status'    => 2
+		                                                     ]);
 		//取出用户信息
 		$user = User::query()->whereId($prepaidOrder->user_id)->first();
 
-		$userTraffic = $prepaidGood->traffic*1048576;
+		$userTraffic = $prepaidGood->traffic * 1048576;
 		//拿出可能存在的其余套餐, 推算 最新的到期时间
 		$expire_time = date('Y-m-d', strtotime("+".$prepaidGood->days." days"));
 		$prepaidOrders = Order::query()->whereUserId($prepaidOrder->user_id)->whereStatus(3)->get();
@@ -37,13 +42,17 @@ class ServiceController extends Controller
 		//计算账号下一个重置时间
 		$nextResetTime = date('Y-m-d', strtotime("+".$prepaidGood->period." days"));
 		if($nextResetTime >= $expire_time){
-			$nextResetTime = NULL;
+			$nextResetTime = null;
 		}
 
 		// 用户默认标签
-		$defaultLabels = Helpers::systemConfig()['initial_labels_for_user']? explode(',', Helpers::systemConfig()['initial_labels_for_user']) : [];
+		$defaultLabels = Helpers::systemConfig()['initial_labels_for_user']? explode(',',
+		                                                                             Helpers::systemConfig()['initial_labels_for_user']) : [];
 		//取出 商品默认标签  & 系统默认标签 去重
-		$newUserLabels = array_values(array_unique(array_merge(GoodsLabel::query()->whereGoodsId($prepaidOrder->goods_id)->pluck('label_id')->toArray(), $defaultLabels)));
+		$newUserLabels = array_values(array_unique(array_merge(GoodsLabel::query()
+		                                                                 ->whereGoodsId($prepaidOrder->goods_id)
+		                                                                 ->pluck('label_id')
+		                                                                 ->toArray(), $defaultLabels)));
 
 		// 生成标签
 		foreach($newUserLabels as $vo){
@@ -52,8 +61,15 @@ class ServiceController extends Controller
 			$obj->label_id = $vo;
 			$obj->save();
 		}
-		Helpers::addUserTrafficModifyLog($prepaidOrder->user_id, $prepaidOrder->oid, $user->transfer_enable, $userTraffic, '[预支付订单激活]加上用户购买的套餐流量');
-		User::query()->whereId($prepaidOrder->user_id)->increment('invite_num', $prepaidOrder->invite_num? : 0, ['u' => 0, 'd' => 0, 'transfer_enable' => $userTraffic, 'expire_time' => $expire_time, 'reset_time' => $nextResetTime]);
+		Helpers::addUserTrafficModifyLog($prepaidOrder->user_id, $prepaidOrder->oid, $user->transfer_enable,
+		                                 $userTraffic, '[预支付订单激活]加上用户购买的套餐流量');
+		User::query()->whereId($prepaidOrder->user_id)->increment('invite_num', $prepaidOrder->invite_num?: 0, [
+			'u'               => 0,
+			'd'               => 0,
+			'transfer_enable' => $userTraffic,
+			'expire_time'     => $expire_time,
+			'reset_time'      => $nextResetTime
+		]);
 	}
 
-}
+}

+ 26 - 16
app/Http/Controllers/User/AffiliateController.php

@@ -11,37 +11,44 @@ use App\Http\Models\User;
 use Auth;
 use Response;
 
-class AffiliateController extends Controller
-{
+class AffiliateController extends Controller {
 	protected static $systemConfig;
 
-	function __construct()
-	{
+	function __construct() {
 		self::$systemConfig = Helpers::systemConfig();
 	}
 
 	// 推广返利
-	public function referral()
-	{
+	public function referral() {
 		if(Order::uid()->whereStatus(2)->doesntExist() && ReferralLog::uid()->doesntExist()){
-			return Response::view('auth.error', ['message' => '本功能对非付费用户禁用!请 <a class="btn btn-sm btn-danger" href="/">返 回</a>']);
+			return Response::view('auth.error',
+			                      ['message' => '本功能对非付费用户禁用!请 <a class="btn btn-sm btn-danger" href="/">返 回</a>']);
 		}
-		$view['referral_traffic'] = flowAutoShow(self::$systemConfig['referral_traffic']*1048576);
+		$view['referral_traffic'] = flowAutoShow(self::$systemConfig['referral_traffic'] * 1048576);
 		$view['referral_percent'] = self::$systemConfig['referral_percent'];
 		$view['referral_money'] = self::$systemConfig['referral_money'];
-		$view['totalAmount'] = ReferralLog::uid()->sum('ref_amount')/100;
-		$view['canAmount'] = ReferralLog::uid()->whereStatus(0)->sum('ref_amount')/100;
+		$view['totalAmount'] = ReferralLog::uid()->sum('ref_amount') / 100;
+		$view['canAmount'] = ReferralLog::uid()->whereStatus(0)->sum('ref_amount') / 100;
 		$view['link'] = self::$systemConfig['website_url'].'/register?aff='.Auth::user()->id;
-		$view['referralLogList'] = ReferralLog::uid()->with('user')->orderBy('id', 'desc')->paginate(10, ['*'], 'log_page');
-		$view['referralApplyList'] = ReferralApply::uid()->with('user')->orderBy('id', 'desc')->paginate(10, ['*'], 'apply_page');
-		$view['referralUserList'] = User::query()->select(['email', 'created_at'])->whereReferralUid(Auth::user()->id)->orderBy('id', 'desc')->paginate(10, ['*'], 'user_page');
+		$view['referralLogList'] = ReferralLog::uid()
+		                                      ->with('user')
+		                                      ->orderBy('id', 'desc')
+		                                      ->paginate(10, ['*'], 'log_page');
+		$view['referralApplyList'] = ReferralApply::uid()
+		                                          ->with('user')
+		                                          ->orderBy('id', 'desc')
+		                                          ->paginate(10, ['*'], 'apply_page');
+		$view['referralUserList'] = User::query()
+		                                ->select(['email', 'created_at'])
+		                                ->whereReferralUid(Auth::user()->id)
+		                                ->orderBy('id', 'desc')
+		                                ->paginate(10, ['*'], 'user_page');
 
 		return Response::view('user.referral', $view);
 	}
 
 	// 申请提现
-	public function extractMoney()
-	{
+	public function extractMoney() {
 		// 判断账户是否过期
 		if(Auth::user()->expire_time < date('Y-m-d')){
 			return Response::json(['status' => 'fail', 'message' => '申请失败:账号已过期,请先购买服务吧']);
@@ -57,7 +64,10 @@ class AffiliateController extends Controller
 		$ref_amount = ReferralLog::uid()->whereStatus(0)->sum('ref_amount');
 		$ref_amount /= 100;
 		if($ref_amount < self::$systemConfig['referral_money']){
-			return Response::json(['status' => 'fail', 'message' => '申请失败:满'.self::$systemConfig['referral_money'].'元才可以提现,继续努力吧']);
+			return Response::json([
+				                      'status'  => 'fail',
+				                      'message' => '申请失败:满'.self::$systemConfig['referral_money'].'元才可以提现,继续努力吧'
+			                      ]);
 		}
 
 		// 取出本次申请关联返利日志ID

+ 21 - 18
app/Http/Controllers/User/SubscribeController.php

@@ -12,18 +12,15 @@ use Illuminate\Http\Request;
 use Redirect;
 use Response;
 
-class SubscribeController extends Controller
-{
+class SubscribeController extends Controller {
 	protected static $systemConfig;
 
-	function __construct()
-	{
+	function __construct() {
 		self::$systemConfig = Helpers::systemConfig();
 	}
 
 	// 通过订阅码获取订阅信息
-	public function getSubscribeByCode(Request $request, $code)
-	{
+	public function getSubscribeByCode(Request $request, $code) {
 		if(empty($code)){
 			return Redirect::to('login');
 		}
@@ -51,14 +48,23 @@ class SubscribeController extends Controller
 			exit($this->noneNode());
 		}
 
-		$query = SsNode::query()->selectRaw('ss_node.*')->leftjoin("ss_node_label", "ss_node.id", "=", "ss_node_label.node_id");
+		$query = SsNode::query()
+		               ->selectRaw('ss_node.*')
+		               ->leftjoin("ss_node_label", "ss_node.id", "=", "ss_node_label.node_id");
 
 		// 启用混合订阅时,加入V2Ray节点,未启用时仅下发SSR节点信息
 		if(!self::$systemConfig['mix_subscribe']){
 			$query->where('ss_node.type', 1);
 		}
 
-		$nodeList = $query->where('ss_node.status', 1)->where('ss_node.is_subscribe', 1)->whereIn('ss_node_label.label_id', $userLabelIds)->groupBy('ss_node.id')->orderBy('ss_node.sort', 'desc')->orderBy('ss_node.id', 'asc')->get()->toArray();
+		$nodeList = $query->where('ss_node.status', 1)
+		                  ->where('ss_node.is_subscribe', 1)
+		                  ->whereIn('ss_node_label.label_id', $userLabelIds)
+		                  ->groupBy('ss_node.id')
+		                  ->orderBy('ss_node.sort', 'desc')
+		                  ->orderBy('ss_node.id', 'asc')
+		                  ->get()
+		                  ->toArray();
 		if(empty($nodeList)){
 			exit($this->noneNode());
 		}
@@ -68,7 +74,7 @@ class SubscribeController extends Controller
 			shuffle($nodeList);
 		}
 
-		$scheme = NULL;
+		$scheme = null;
 
 		// 展示到期时间和剩余流量
 		if(self::$systemConfig['is_custom_subscribe']){
@@ -99,20 +105,18 @@ class SubscribeController extends Controller
 	}
 
 	// 抛出无可用的节点信息,用于兼容防止客户端订阅失败
-	private function noneNode()
-	{
+	private function noneNode() {
 		return base64url_encode('ssr://'.base64url_encode('0.0.0.0:1:origin:none:plain:'.base64url_encode('0000').'/?obfsparam=&protoparam=&remarks='.base64url_encode('无可用节点或账号被封禁或订阅被封禁').'&group='.base64url_encode('错误').'&udpport=0&uot=0')."\n");
 	}
 
 	/**
 	 * 过期时间
 	 *
-	 * @param object $user
+	 * @param  object  $user
 	 *
 	 * @return string
 	 */
-	private function expireDate($user)
-	{
+	private function expireDate($user) {
 		$text = '到期时间: '.$user->expire_time;
 
 		return 'ssr://'.base64url_encode('0.0.0.1:1:origin:none:plain:'.base64url_encode('0000').'/?obfsparam=&protoparam=&remarks='.base64url_encode($text).'&group='.base64url_encode(self::$systemConfig['website_name']).'&udpport=0&uot=0')."\n";
@@ -121,13 +125,12 @@ class SubscribeController extends Controller
 	/**
 	 * 剩余流量
 	 *
-	 * @param object $user
+	 * @param  object  $user
 	 *
 	 * @return string
 	 */
-	private function lastTraffic($user)
-	{
-		$text = '剩余流量: '.flowAutoShow($user->transfer_enable-$user->u-$user->d);
+	private function lastTraffic($user) {
+		$text = '剩余流量: '.flowAutoShow($user->transfer_enable - $user->u - $user->d);
 
 		return 'ssr://'.base64url_encode('0.0.0.2:1:origin:none:plain:'.base64url_encode('0000').'/?obfsparam=&protoparam=&remarks='.base64url_encode($text).'&group='.base64url_encode(self::$systemConfig['website_name']).'&udpport=0&uot=0')."\n";
 	}

+ 168 - 97
app/Http/Controllers/UserController.php

@@ -44,60 +44,80 @@ use Validator;
  *
  * @package App\Http\Controllers
  */
-class UserController extends Controller
-{
+class UserController extends Controller {
 	protected static $systemConfig;
 
-	function __construct()
-	{
+	function __construct() {
 		self::$systemConfig = Helpers::systemConfig();
 	}
 
-	public function index()
-	{
+	public function index() {
 		$totalTransfer = Auth::user()->transfer_enable;
-		$usedTransfer = Auth::user()->u+Auth::user()->d;
-		$unusedTransfer = $totalTransfer-$usedTransfer > 0? $totalTransfer-$usedTransfer : 0;
+		$usedTransfer = Auth::user()->u + Auth::user()->d;
+		$unusedTransfer = $totalTransfer - $usedTransfer > 0? $totalTransfer - $usedTransfer : 0;
 		$expireTime = Auth::user()->expire_time;
-		$view['remainDays'] = $expireTime < date('Y-m-d')? -1 : (strtotime($expireTime)-strtotime(date('Y-m-d')))/86400;
-		$view['resetDays'] = Auth::user()->reset_time? round((strtotime(Auth::user()->reset_time)-strtotime(date('Y-m-d')))/86400) : 0;
+		$view['remainDays'] = $expireTime < date('Y-m-d')? -1 : (strtotime($expireTime) - strtotime(date('Y-m-d'))) / 86400;
+		$view['resetDays'] = Auth::user()->reset_time? round((strtotime(Auth::user()->reset_time) - strtotime(date('Y-m-d'))) / 86400) : 0;
 		$view['unusedTransfer'] = $unusedTransfer;
 		$view['expireTime'] = $expireTime;
 		$view['banedTime'] = Auth::user()->ban_time? date('Y-m-d H:i:s', Auth::user()->ban_time) : 0;
-		$view['unusedPercent'] = $totalTransfer > 0? round($unusedTransfer/$totalTransfer, 2) : 0;
+		$view['unusedPercent'] = $totalTransfer > 0? round($unusedTransfer / $totalTransfer, 2) : 0;
 		$view['noticeList'] = Article::type(2)->orderBy('id', 'desc')->Paginate(1); // 公告
 		//流量异常判断
-		$hourlyTraffic = UserTrafficHourly::query()->whereUserId(Auth::user()->id)->whereNodeId(0)->where('created_at', '>=', date('Y-m-d H:i:s', time()-3900))->sum('total');
-		$view['isTrafficWarning'] = $hourlyTraffic >= (self::$systemConfig['traffic_ban_value']*1073741824)? : 0;
+		$hourlyTraffic = UserTrafficHourly::query()
+		                                  ->whereUserId(Auth::user()->id)
+		                                  ->whereNodeId(0)
+		                                  ->where('created_at', '>=', date('Y-m-d H:i:s', time() - 3900))
+		                                  ->sum('total');
+		$view['isTrafficWarning'] = $hourlyTraffic >= (self::$systemConfig['traffic_ban_value'] * 1073741824)?: 0;
 		//付费用户判断
-		$view['not_paying_user'] = Order::uid()->whereStatus(2)->whereIsExpire(0)->where('origin_amount', '>', 0)->doesntExist();
-		$view['userLoginLog'] = UserLoginLog::query()->whereUserId(Auth::user()->id)->orderBy('id', 'desc')->first(); // 近期登录日志
+		$view['not_paying_user'] = Order::uid()
+		                                ->whereStatus(2)
+		                                ->whereIsExpire(0)
+		                                ->where('origin_amount', '>', 0)
+		                                ->doesntExist();
+		$view['userLoginLog'] = UserLoginLog::query()
+		                                    ->whereUserId(Auth::user()->id)
+		                                    ->orderBy('id', 'desc')
+		                                    ->first(); // 近期登录日志
 
 		$dailyData = [];
 		$hourlyData = [];
 
 		// 节点一个月内的流量
 		// TODO:有bug
-		$userTrafficDaily = UserTrafficDaily::query()->whereUserId(Auth::user()->id)->whereNodeId(0)->where('created_at', '<=', date('Y-m-d', time()))->orderBy('created_at', 'asc')->pluck('total')->toArray();
-
-		$dailyTotal = date('d', time())-1; // 今天不算,减一
+		$userTrafficDaily = UserTrafficDaily::query()
+		                                    ->whereUserId(Auth::user()->id)
+		                                    ->whereNodeId(0)
+		                                    ->where('created_at', '<=', date('Y-m-d', time()))
+		                                    ->orderBy('created_at', 'asc')
+		                                    ->pluck('total')
+		                                    ->toArray();
+
+		$dailyTotal = date('d', time()) - 1; // 今天不算,减一
 		$dailyCount = count($userTrafficDaily);
-		for($x = 0; $x < $dailyTotal-$dailyCount; $x++){
+		for($x = 0; $x < $dailyTotal - $dailyCount; $x++){
 			$dailyData[$x] = 0;
 		}
-		for($x = $dailyTotal-$dailyCount; $x < $dailyTotal; $x++){
-			$dailyData[$x] = round($userTrafficDaily[$x-($dailyTotal-$dailyCount)]/(1024*1024*1024), 3);
+		for($x = $dailyTotal - $dailyCount; $x < $dailyTotal; $x++){
+			$dailyData[$x] = round($userTrafficDaily[$x - ($dailyTotal - $dailyCount)] / (1024 * 1024 * 1024), 3);
 		}
 
 		// 节点一天内的流量
-		$userTrafficHourly = UserTrafficHourly::query()->whereUserId(Auth::user()->id)->whereNodeId(0)->where('created_at', '>=', date('Y-m-d', time()))->orderBy('created_at', 'asc')->pluck('total')->toArray();
+		$userTrafficHourly = UserTrafficHourly::query()
+		                                      ->whereUserId(Auth::user()->id)
+		                                      ->whereNodeId(0)
+		                                      ->where('created_at', '>=', date('Y-m-d', time()))
+		                                      ->orderBy('created_at', 'asc')
+		                                      ->pluck('total')
+		                                      ->toArray();
 		$hourlyTotal = date('H');
 		$hourlyCount = count($userTrafficHourly);
-		for($x = 0; $x < $hourlyTotal-$hourlyCount; $x++){
+		for($x = 0; $x < $hourlyTotal - $hourlyCount; $x++){
 			$hourlyData[$x] = 0;
 		}
-		for($x = ($hourlyTotal-$hourlyCount); $x < $hourlyTotal; $x++){
-			$hourlyData[$x] = round($userTrafficHourly[$x-($hourlyTotal-$hourlyCount)]/(1024*1024*1024), 3);
+		for($x = ($hourlyTotal - $hourlyCount); $x < $hourlyTotal; $x++){
+			$hourlyData[$x] = round($userTrafficHourly[$x - ($hourlyTotal - $hourlyCount)] / (1024 * 1024 * 1024), 3);
 		}
 
 		// 本月天数数据
@@ -120,8 +140,7 @@ class UserController extends Controller
 	}
 
 	// 签到
-	public function checkIn()
-	{
+	public function checkIn() {
 		// 系统开启登录加积分功能才可以签到
 		if(!self::$systemConfig['is_checkin']){
 			return Response::json(['status' => 'fail', 'message' => '系统未开启签到功能']);
@@ -132,25 +151,26 @@ class UserController extends Controller
 			return Response::json(['status' => 'fail', 'message' => '已经签到过了,明天再来吧']);
 		}
 
-		$traffic = mt_rand((int)self::$systemConfig['min_rand_traffic'], (int)self::$systemConfig['max_rand_traffic'])*1048576;
+		$traffic = mt_rand((int) self::$systemConfig['min_rand_traffic'],
+		                   (int) self::$systemConfig['max_rand_traffic']) * 1048576;
 		$ret = User::uid()->increment('transfer_enable', $traffic);
 		if(!$ret){
 			return Response::json(['status' => 'fail', 'message' => '签到失败,系统异常']);
 		}
 
 		// 写入用户流量变动记录
-		Helpers::addUserTrafficModifyLog(Auth::user()->id, 0, Auth::user()->transfer_enable, Auth::user()->transfer_enable+$traffic, '[签到]');
+		Helpers::addUserTrafficModifyLog(Auth::user()->id, 0, Auth::user()->transfer_enable,
+		                                 Auth::user()->transfer_enable + $traffic, '[签到]');
 
 		// 多久后可以再签到
-		$ttl = self::$systemConfig['traffic_limit_time']? self::$systemConfig['traffic_limit_time']*60 : 86400;
+		$ttl = self::$systemConfig['traffic_limit_time']? self::$systemConfig['traffic_limit_time'] * 60 : 86400;
 		Cache::put('userCheckIn_'.Auth::user()->id, '1', $ttl);
 
 		return Response::json(['status' => 'success', 'message' => '签到成功,系统送您 '.flowAutoShow($traffic).'流量']);
 	}
 
 	// 节点列表
-	public function nodeList(Request $request)
-	{
+	public function nodeList(Request $request) {
 		if($request->isMethod('POST')){
 			$node_id = $request->input('id');
 			$infoType = $request->input('type');
@@ -165,20 +185,36 @@ class UserController extends Controller
 			// 获取当前用户标签
 			$userLabelIds = UserLabel::uid()->pluck('label_id');
 			// 获取当前用户可用节点
-			$nodeList = SsNode::query()->selectRaw('ss_node.*')->leftJoin('ss_node_label', 'ss_node.id', '=', 'ss_node_label.node_id')->whereIn('ss_node_label.label_id', $userLabelIds)->where('ss_node.status', 1)->groupBy('ss_node.id')->orderBy('ss_node.sort', 'desc')->orderBy('ss_node.id', 'asc')->get();
+			$nodeList = SsNode::query()
+			                  ->selectRaw('ss_node.*')
+			                  ->leftJoin('ss_node_label', 'ss_node.id', '=', 'ss_node_label.node_id')
+			                  ->whereIn('ss_node_label.label_id', $userLabelIds)
+			                  ->where('ss_node.status', 1)
+			                  ->groupBy('ss_node.id')
+			                  ->orderBy('ss_node.sort', 'desc')
+			                  ->orderBy('ss_node.id', 'asc')
+			                  ->get();
 
 			foreach($nodeList as $node){
-				$node->ct = number_format(SsNodePing::query()->whereNodeId($node->id)->where('ct', '>', '0')->avg('ct'), 1, '.', '');
-				$node->cu = number_format(SsNodePing::query()->whereNodeId($node->id)->where('cu', '>', '0')->avg('cu'), 1, '.', '');
-				$node->cm = number_format(SsNodePing::query()->whereNodeId($node->id)->where('cm', '>', '0')->avg('cm'), 1, '.', '');
-				$node->hk = number_format(SsNodePing::query()->whereNodeId($node->id)->where('hk', '>', '0')->avg('hk'), 1, '.', '');
+				$node->ct = number_format(SsNodePing::query()->whereNodeId($node->id)->where('ct', '>', '0')->avg('ct'),
+				                          1, '.', '');
+				$node->cu = number_format(SsNodePing::query()->whereNodeId($node->id)->where('cu', '>', '0')->avg('cu'),
+				                          1, '.', '');
+				$node->cm = number_format(SsNodePing::query()->whereNodeId($node->id)->where('cm', '>', '0')->avg('cm'),
+				                          1, '.', '');
+				$node->hk = number_format(SsNodePing::query()->whereNodeId($node->id)->where('hk', '>', '0')->avg('hk'),
+				                          1, '.', '');
 
 				// 节点在线状态
-				$node->offline = SsNodeInfo::query()->whereNodeId($node->id)->where('log_time', '>=', strtotime("-10 minutes"))->orderBy('id', 'desc')->doesntExist();
+				$node->offline = SsNodeInfo::query()
+				                           ->whereNodeId($node->id)
+				                           ->where('log_time', '>=', strtotime("-10 minutes"))
+				                           ->orderBy('id', 'desc')
+				                           ->doesntExist();
 				// 节点标签
 				$node->labels = SsNodeLabel::query()->whereNodeId($node->id)->first();
 			}
-			$view['nodeList'] = $nodeList? : [];
+			$view['nodeList'] = $nodeList?: [];
 		}
 
 
@@ -186,16 +222,14 @@ class UserController extends Controller
 	}
 
 	// 公告详情
-	public function article(Request $request)
-	{
+	public function article(Request $request) {
 		$view['info'] = Article::query()->findOrFail($request->input('id'));
 
 		return Response::view('user.article', $view);
 	}
 
 	// 修改个人资料
-	public function profile(Request $request)
-	{
+	public function profile(Request $request) {
 		if($request->isMethod('POST')){
 			$old_password = trim($request->input('old_password'));
 			$new_password = trim($request->input('new_password'));
@@ -250,26 +284,45 @@ class UserController extends Controller
 	}
 
 	// 商品列表
-	public function services(Request $request)
-	{
+	public function services(Request $request) {
 		// 余额充值商品,只取10个
-		$view['chargeGoodsList'] = Goods::type(3)->whereStatus(1)->orderBy('price', 'asc')->orderBy('price', 'asc')->limit(10)->get();
-		$view['goodsList'] = Goods::query()->whereStatus(1)->where('type', '<=', '2')->orderBy('type', 'desc')->orderBy('sort', 'desc')->paginate(10)->appends($request->except('page'));
-		$renewOrder = Order::query()->with(['goods'])->whereUserId(Auth::user()->id)->whereStatus(2)->whereIsExpire(0)->whereHas('goods', function($q){ $q->whereType(2); })->first();
+		$view['chargeGoodsList'] = Goods::type(3)
+		                                ->whereStatus(1)
+		                                ->orderBy('price', 'asc')
+		                                ->orderBy('price', 'asc')
+		                                ->limit(10)
+		                                ->get();
+		$view['goodsList'] = Goods::query()
+		                          ->whereStatus(1)
+		                          ->where('type', '<=', '2')
+		                          ->orderBy('type', 'desc')
+		                          ->orderBy('sort', 'desc')
+		                          ->paginate(10)
+		                          ->appends($request->except('page'));
+		$renewOrder = Order::query()
+		                   ->with(['goods'])
+		                   ->whereUserId(Auth::user()->id)
+		                   ->whereStatus(2)
+		                   ->whereIsExpire(0)
+		                   ->whereHas('goods', function($q) {
+			                   $q->whereType(2);
+		                   })
+		                   ->first();
 		$renewPrice = $renewOrder? Goods::query()->whereId($renewOrder->goods_id)->first() : 0;
 		$view['renewTraffic'] = $renewPrice? $renewPrice->renew : 0;
 		// 有重置日时按照重置日为标准,否者就以过期日为标准
 		$dataPlusDays = Auth::user()->reset_time? Auth::user()->reset_time : Auth::user()->expire_time;
-		$view['dataPlusDays'] = $dataPlusDays > date('Y-m-d')? round((strtotime($dataPlusDays)-strtotime(date('Y-m-d')))/86400) : 0;
+		$view['dataPlusDays'] = $dataPlusDays > date('Y-m-d')? round((strtotime($dataPlusDays) - strtotime(date('Y-m-d'))) / 86400) : 0;
 		$view['purchaseHTML'] = PaymentController::purchaseHTML();
 
 		return Response::view('user.services', $view);
 	}
 
 	//重置流量
-	public function resetUserTraffic()
-	{
-		$temp = Order::uid()->whereStatus(2)->whereIsExpire(0)->with(['goods'])->whereHas('goods', function($q){ $q->whereType(2); })->first();
+	public function resetUserTraffic() {
+		$temp = Order::uid()->whereStatus(2)->whereIsExpire(0)->with(['goods'])->whereHas('goods', function($q) {
+			$q->whereType(2);
+		})->first();
 		$renewCost = Goods::query()->whereId($temp->goods_id)->first()->renew;
 		if(Auth::user()->balance < $renewCost){
 			return Response::json(['status' => 'fail', 'data' => '', 'message' => '余额不足,请充值余额']);
@@ -277,33 +330,35 @@ class UserController extends Controller
 			User::uid()->update(['u' => 0, 'd' => 0]);
 
 			// 扣余额
-			User::query()->whereId(Auth::user()->id)->decrement('balance', $renewCost*100);
+			User::query()->whereId(Auth::user()->id)->decrement('balance', $renewCost * 100);
 
 			// 记录余额操作日志
-			Helpers::addUserBalanceLog(Auth::user()->id, '', Auth::user()->balance, Auth::user()->balance-$renewCost, -1*$renewCost, '用户自行重置流量');
+			Helpers::addUserBalanceLog(Auth::user()->id, '', Auth::user()->balance, Auth::user()->balance - $renewCost,
+			                           -1 * $renewCost, '用户自行重置流量');
 
 			return Response::json(['status' => 'success', 'data' => '', 'message' => '重置成功']);
 		}
 	}
 
 	// 工单
-	public function ticketList(Request $request)
-	{
+	public function ticketList(Request $request) {
 		$view['ticketList'] = Ticket::uid()->orderBy('id', 'desc')->paginate(10)->appends($request->except('page'));
 
 		return Response::view('user.ticketList', $view);
 	}
 
 	// 订单
-	public function invoices(Request $request)
-	{
-		$view['orderList'] = Order::uid()->with(['user', 'goods', 'coupon', 'payment'])->orderBy('oid', 'desc')->paginate(10)->appends($request->except('page'));
+	public function invoices(Request $request) {
+		$view['orderList'] = Order::uid()
+		                          ->with(['user', 'goods', 'coupon', 'payment'])
+		                          ->orderBy('oid', 'desc')
+		                          ->paginate(10)
+		                          ->appends($request->except('page'));
 
 		return Response::view('user.invoices', $view);
 	}
 
-	public function activeOrder(Request $request)
-	{
+	public function activeOrder(Request $request) {
 		$oid = $request->input('oid');
 		$prepaidOrder = Order::query()->whereOid($oid)->first();
 		if(!$prepaidOrder){
@@ -318,16 +373,14 @@ class UserController extends Controller
 	}
 
 	// 订单明细
-	public function invoiceDetail($sn)
-	{
+	public function invoiceDetail($sn) {
 		$view['order'] = Order::uid()->with(['goods', 'coupon', 'payment'])->whereOrderSn($sn)->firstOrFail();
 
 		return Response::view('user.invoiceDetail', $view);
 	}
 
 	// 添加工单
-	public function addTicket(Request $request)
-	{
+	public function addTicket(Request $request) {
 		$title = $request->input('title');
 		$content = clean($request->input('content'));
 		$content = str_replace("eval", "", str_replace("atob", "", $content));
@@ -362,8 +415,7 @@ class UserController extends Controller
 	}
 
 	// 回复工单
-	public function replyTicket(Request $request)
-	{
+	public function replyTicket(Request $request) {
 		$id = $request->input('id');
 
 		$ticket = Ticket::uid()->with('user')->whereId($id)->firstOrFail();
@@ -416,8 +468,7 @@ class UserController extends Controller
 	}
 
 	// 关闭工单
-	public function closeTicket(Request $request)
-	{
+	public function closeTicket(Request $request) {
 		$id = $request->input('id');
 
 		$ret = Ticket::uid()->whereId($id)->update(['status' => 2]);
@@ -431,23 +482,22 @@ class UserController extends Controller
 	}
 
 	// 邀请码
-	public function invite()
-	{
+	public function invite() {
 		if(Order::uid()->whereStatus(2)->whereIsExpire(0)->where('origin_amount', '>', 0)->doesntExist()){
-			return Response::view('auth.error', ['message' => '本功能对非付费用户禁用!请 <a class="btn btn-sm btn-danger" href="/">返 回</a>']);
+			return Response::view('auth.error',
+			                      ['message' => '本功能对非付费用户禁用!请 <a class="btn btn-sm btn-danger" href="/">返 回</a>']);
 		}
 
 		$view['num'] = Auth::user()->invite_num; // 还可以生成的邀请码数量
 		$view['inviteList'] = Invite::uid()->with(['generator', 'user'])->paginate(10); // 邀请码列表
-		$view['referral_traffic'] = flowAutoShow(self::$systemConfig['referral_traffic']*1048576);
+		$view['referral_traffic'] = flowAutoShow(self::$systemConfig['referral_traffic'] * 1048576);
 		$view['referral_percent'] = self::$systemConfig['referral_percent'];
 
 		return Response::view('user.invite', $view);
 	}
 
 	// 生成邀请码
-	public function makeInvite()
-	{
+	public function makeInvite() {
 		if(Auth::user()->invite_num <= 0){
 			return Response::json(['status' => 'fail', 'data' => '', 'message' => '生成失败:已无邀请码生成名额']);
 		}
@@ -466,8 +516,7 @@ class UserController extends Controller
 	}
 
 	// 使用优惠券
-	public function redeemCoupon(Request $request)
-	{
+	public function redeemCoupon(Request $request) {
 		$coupon_sn = $request->input('coupon_sn');
 		$good_price = $request->input('price');
 
@@ -493,22 +542,33 @@ class UserController extends Controller
 			return Response::json(['status' => 'fail', 'title' => '使用条件未满足', 'message' => '请购买价格更高的套餐']);
 		}
 
-		$data = ['name' => $coupon->name, 'type' => $coupon->type, 'amount' => $coupon->amount, 'discount' => $coupon->discount];
+		$data = [
+			'name'     => $coupon->name,
+			'type'     => $coupon->type,
+			'amount'   => $coupon->amount,
+			'discount' => $coupon->discount
+		];
 
 		return Response::json(['status' => 'success', 'data' => $data, 'message' => '优惠券有效']);
 	}
 
 	// 购买服务
-	public function buy($goods_id)
-	{
+	public function buy($goods_id) {
 		$goods = Goods::query()->whereId($goods_id)->whereStatus(1)->first();
 		if(empty($goods)){
 			return Redirect::to('services');
 		}
 		// 有重置日时按照重置日为标准,否者就以过期日为标准
 		$dataPlusDays = Auth::user()->reset_time? Auth::user()->reset_time : Auth::user()->expire_time;
-		$view['dataPlusDays'] = $dataPlusDays > date('Y-m-d')? round((strtotime($dataPlusDays)-strtotime(date('Y-m-d')))/86400) : 0;
-		$view['activePlan'] = Order::uid()->with(['goods'])->whereIsExpire(0)->whereStatus(2)->whereHas('goods', function($q){ $q->whereType(2); })->exists();
+		$view['dataPlusDays'] = $dataPlusDays > date('Y-m-d')? round((strtotime($dataPlusDays) - strtotime(date('Y-m-d'))) / 86400) : 0;
+		$view['activePlan'] = Order::uid()
+		                           ->with(['goods'])
+		                           ->whereIsExpire(0)
+		                           ->whereStatus(2)
+		                           ->whereHas('goods', function($q) {
+			                           $q->whereType(2);
+		                           })
+		                           ->exists();
 		$view['purchaseHTML'] = PaymentController::purchaseHTML();
 		$view['goods'] = $goods;
 
@@ -516,12 +576,15 @@ class UserController extends Controller
 	}
 
 	// 帮助中心
-	public function help()
-	{
+	public function help() {
 		$view['articleList'] = Article::type(1)->orderBy('sort', 'desc')->orderBy('id', 'desc')->limit(10)->paginate(5);
 
 		//付费用户判断
-		$view['not_paying_user'] = Order::uid()->whereStatus(2)->whereIsExpire(0)->where('origin_amount', '>', 0)->doesntExist();
+		$view['not_paying_user'] = Order::uid()
+		                                ->whereStatus(2)
+		                                ->whereIsExpire(0)
+		                                ->where('origin_amount', '>', 0)
+		                                ->doesntExist();
 		//客户端安装
 		$view['Shadowrocket_install'] = 'itms-services://?action=download-manifest&url='.self::$systemConfig['website_url'].'/clients/Shadowrocket.plist';
 		$view['Quantumult_install'] = 'itms-services://?action=download-manifest&url='.self::$systemConfig['website_url'].'/clients/Quantumult.plist';
@@ -540,8 +603,7 @@ class UserController extends Controller
 	}
 
 	// 更换订阅地址
-	public function exchangeSubscribe()
-	{
+	public function exchangeSubscribe() {
 		DB::beginTransaction();
 		try{
 			// 更换订阅码
@@ -563,8 +625,7 @@ class UserController extends Controller
 	}
 
 	// 转换成管理员的身份
-	public function switchToAdmin()
-	{
+	public function switchToAdmin() {
 		if(!Session::has('admin')){
 			return Response::json(['status' => 'fail', 'data' => '', 'message' => '非法请求']);
 		}
@@ -577,14 +638,22 @@ class UserController extends Controller
 	}
 
 	// 卡券余额充值
-	public function charge(Request $request)
-	{
-		$validator = Validator::make($request->all(), ['coupon_sn' => ['required', Rule::exists('coupon', 'sn')->where(function($query){
-			$query->whereType(3)->whereStatus(0);
-		}),]], ['coupon_sn.required' => '券码不能为空', 'coupon_sn.exists' => '该券不可用']);
+	public function charge(Request $request) {
+		$validator = Validator::make($request->all(), [
+			'coupon_sn' => [
+				'required',
+				Rule::exists('coupon', 'sn')->where(function($query) {
+					$query->whereType(3)->whereStatus(0);
+				}),
+			]
+		], ['coupon_sn.required' => '券码不能为空', 'coupon_sn.exists' => '该券不可用']);
 
 		if($validator->fails()){
-			return Response::json(['status' => 'fail', 'data' => '', 'message' => $validator->getMessageBag()->first()]);
+			return Response::json([
+				                      'status'  => 'fail',
+				                      'data'    => '',
+				                      'message' => $validator->getMessageBag()->first()
+			                      ]);
 		}
 
 		$coupon = Coupon::query()->whereSn($request->input('coupon_sn'))->first();
@@ -592,10 +661,12 @@ class UserController extends Controller
 		try{
 			DB::beginTransaction();
 			// 写入日志
-			Helpers::addUserBalanceLog(Auth::user()->id, 0, Auth::user()->balance, Auth::user()->balance+$coupon->amount, $coupon->amount, '用户手动充值 - [充值券:'.$request->input('coupon_sn').']');
+			Helpers::addUserBalanceLog(Auth::user()->id, 0, Auth::user()->balance,
+			                           Auth::user()->balance + $coupon->amount, $coupon->amount,
+			                           '用户手动充值 - [充值券:'.$request->input('coupon_sn').']');
 
 			// 余额充值
-			User::uid()->increment('balance', $coupon->amount*100);
+			User::uid()->increment('balance', $coupon->amount * 100);
 
 			// 更改卡券状态
 			$coupon->status = 1;

+ 1 - 2
app/Http/Kernel.php

@@ -30,8 +30,7 @@ use Illuminate\Routing\Middleware\ValidateSignature;
 use Illuminate\Session\Middleware\StartSession;
 use Illuminate\View\Middleware\ShareErrorsFromSession;
 
-class Kernel extends HttpKernel
-{
+class Kernel extends HttpKernel {
 	/**
 	 * The application's global HTTP middleware stack.
 	 *

+ 4 - 6
app/Http/Middleware/Affiliate.php

@@ -6,18 +6,16 @@ use Closure;
 use Cookie;
 use Illuminate\Http\Request;
 
-class Affiliate
-{
+class Affiliate {
 	/**
 	 * 返利识别
 	 *
-	 * @param Request $request
-	 * @param Closure $next
+	 * @param  Request  $request
+	 * @param  Closure  $next
 	 *
 	 * @return mixed
 	 */
-	public function handle($request, Closure $next)
-	{
+	public function handle($request, Closure $next) {
 		$aff = trim($request->input('aff', 0));
 		if($aff){
 			Cookie::queue('register_aff', $aff, 129600);

+ 2 - 4
app/Http/Middleware/CheckForMaintenanceMode.php

@@ -4,14 +4,12 @@ namespace App\Http\Middleware;
 
 use Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode as Middleware;
 
-class CheckForMaintenanceMode extends Middleware
-{
+class CheckForMaintenanceMode extends Middleware {
 	/**
 	 * The URIs that should be reachable while maintenance mode is enabled.
 	 *
 	 * @var array
 	 */
-	protected $except = [
-		//
+	protected $except = [//
 	];
 }

+ 2 - 4
app/Http/Middleware/EncryptCookies.php

@@ -4,14 +4,12 @@ namespace App\Http\Middleware;
 
 use Illuminate\Cookie\Middleware\EncryptCookies as Middleware;
 
-class EncryptCookies extends Middleware
-{
+class EncryptCookies extends Middleware {
 	/**
 	 * The names of the cookies that should not be encrypted.
 	 *
 	 * @var array
 	 */
-	protected $except = [
-		//
+	protected $except = [//
 	];
 }

+ 5 - 7
app/Http/Middleware/RedirectIfAuthenticated.php

@@ -5,19 +5,17 @@ namespace App\Http\Middleware;
 use Closure;
 use Illuminate\Http\Request;
 
-class RedirectIfAuthenticated
-{
+class RedirectIfAuthenticated {
 	/**
 	 * Handle an incoming request.
 	 *
-	 * @param Request     $request
-	 * @param Closure     $next
-	 * @param string|null $guard
+	 * @param  Request      $request
+	 * @param  Closure      $next
+	 * @param  string|null  $guard
 	 *
 	 * @return mixed
 	 */
-	public function handle($request, Closure $next, $guard = NULL)
-	{
+	public function handle($request, Closure $next, $guard = null) {
 		if(auth()->guard($guard)->check()){
 			return redirect('/');
 		}

+ 5 - 7
app/Http/Middleware/SetLocale.php

@@ -6,18 +6,16 @@ use Closure;
 use Illuminate\Http\Request;
 use Session;
 
-class SetLocale
-{
+class SetLocale {
 	/**
 	 * 变更语言
 	 *
-	 * @param Request $request
-	 * @param Closure $next
+	 * @param  Request  $request
+	 * @param  Closure  $next
 	 *
 	 * @return mixed
 	 */
-	public function handle($request, Closure $next)
-	{
+	public function handle($request, Closure $next) {
 		if(Session::has('locale')){
 			app()->setLocale(Session::get('locale'));
 		}
@@ -30,4 +28,4 @@ class SetLocale
 		return $next($request);
 	}
 
-}
+}

+ 1 - 2
app/Http/Middleware/TrimStrings.php

@@ -4,8 +4,7 @@ namespace App\Http\Middleware;
 
 use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware;
 
-class TrimStrings extends Middleware
-{
+class TrimStrings extends Middleware {
 	/**
 	 * The names of the attributes that should not be trimmed.
 	 *

+ 1 - 2
app/Http/Middleware/TrustProxies.php

@@ -5,8 +5,7 @@ namespace App\Http\Middleware;
 use Fideloper\Proxy\TrustProxies as Middleware;
 use Illuminate\Http\Request;
 
-class TrustProxies extends Middleware
-{
+class TrustProxies extends Middleware {
 	/**
 	 * The trusted proxies for this application.
 	 *

+ 1 - 2
app/Http/Middleware/VerifyCsrfToken.php

@@ -4,8 +4,7 @@ namespace App\Http\Middleware;
 
 use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
 
-class VerifyCsrfToken extends Middleware
-{
+class VerifyCsrfToken extends Middleware {
 	/**
 	 * The URIs that should be excluded from CSRF verification.
 	 *

+ 47 - 0
app/Http/Middleware/WebApi.php

@@ -0,0 +1,47 @@
+<?php
+
+namespace App\Http\Middleware;
+
+use Closure;
+use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
+use Illuminate\Http\Request;
+use Response;
+
+class WebApi extends Middleware {
+	/**
+	 * Handle an incoming request.
+	 *
+	 * @param  Request  $request
+	 * @param  Closure  $next
+	 *
+	 * @return mixed
+	 */
+	public function handle($request, Closure $next) {
+		$key = $request->input('key');
+		// 未提供 key
+		if($key === null){
+			return Response::json([
+				                      'ret'  => 0,
+				                      'data' => 'Your key is null'
+			                      ]);
+		}
+
+		if(!in_array($key, env('WEB_API_KEY'))){
+			// key 不存在
+			return Response::json([
+				                      'ret'  => 0,
+				                      'data' => 'Token is invalid'
+			                      ]);
+		}
+
+		if(env('WEB_API') == false){
+			// 主站不提供 Webapi
+			return Response::json([
+				                      'ret'  => 0,
+				                      'data' => 'We regret this service is temporarily unavailable'
+			                      ]);
+		}
+
+		return $next($request);
+	}
+}

+ 4 - 6
app/Http/Middleware/isAdmin.php

@@ -7,18 +7,16 @@ use Closure;
 use Illuminate\Http\Request;
 use Redirect;
 
-class isAdmin
-{
+class isAdmin {
 	/**
 	 * 校验是否为管理员身份
 	 *
-	 * @param Request $request
-	 * @param Closure $next
+	 * @param  Request  $request
+	 * @param  Closure  $next
 	 *
 	 * @return mixed
 	 */
-	public function handle($request, Closure $next)
-	{
+	public function handle($request, Closure $next) {
 		if(!Auth::user()->is_admin){
 			return Redirect::to('/');
 		}

+ 4 - 6
app/Http/Middleware/isAdminlogin.php

@@ -6,18 +6,16 @@ use Closure;
 use Illuminate\Http\Request;
 use Redirect;
 
-class isAdminlogin
-{
+class isAdminlogin {
 	/**
 	 * Handle an incoming request.
 	 *
-	 * @param Request $request
-	 * @param Closure $next
+	 * @param  Request  $request
+	 * @param  Closure  $next
 	 *
 	 * @return mixed
 	 */
-	public function handle($request, Closure $next)
-	{
+	public function handle($request, Closure $next) {
 		if(auth()->guest()){
 			return Redirect::to('admin/login');
 		}

+ 14 - 11
app/Http/Middleware/isForbidden.php

@@ -10,18 +10,16 @@ use Closure;
 use Illuminate\Http\Request;
 use Log;
 
-class isForbidden
-{
+class isForbidden {
 	/**
 	 * 限制机器人、指定IP访问
 	 *
-	 * @param Request $request
-	 * @param Closure $next
+	 * @param  Request  $request
+	 * @param  Closure  $next
 	 *
 	 * @return mixed
 	 */
-	public function handle($request, Closure $next)
-	{
+	public function handle($request, Closure $next) {
 		// 拒绝机器人访问
 		if(Helpers::systemConfig()['is_forbid_robot']){
 			if(Agent::isRobot()){
@@ -32,7 +30,8 @@ class isForbidden
 		}
 
 		// 拒绝通过订阅链接域名访问网站,防止网站被探测
-		if(TRUE === strpos(Helpers::systemConfig()['subscribe_domain'], $request->getHost()) && FALSE === strpos(Helpers::systemConfig()['subscribe_domain'], Helpers::systemConfig()['website_url'])){
+		if(true === strpos(Helpers::systemConfig()['subscribe_domain'], $request->getHost())
+		   && false === strpos(Helpers::systemConfig()['subscribe_domain'], Helpers::systemConfig()['website_url'])){
 			Log::info("识别到通过订阅链接访问,强制跳转至百度(".getClientIp().")");
 
 			return redirect('https://www.baidu.com');
@@ -41,10 +40,10 @@ class isForbidden
 		$ip = getClientIP();
 		if(filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)){
 			Log::info('识别到IPv6,尝试解析:'.$ip);
-			$isIPv6 = TRUE;
+			$isIPv6 = true;
 			$ipInfo = getIPv6($ip);
 		}else{
-			$isIPv6 = FALSE;
+			$isIPv6 = false;
 			$ipInfo = QQWry::ip($ip); // 通过纯真IP库解析IPv4信息
 			if(isset($ipInfo['error'])){
 				Log::info('无法识别IPv4,尝试使用IPIP的IP库解析:'.$ip);
@@ -73,7 +72,9 @@ class isForbidden
 		if(!in_array($ipInfo['country'], ['本机地址', '局域网'])){
 			// 拒绝大陆IP访问
 			if(Helpers::systemConfig()['is_forbid_china']){
-				if(($ipInfo['country'] == '中国' && !in_array($ipInfo['province'], ['香港', '澳门', '台湾'])) || ($isIPv6 && $ipInfo['country'] == 'China')){
+				if(($ipInfo['country'] == '中国' && !in_array($ipInfo['province'], ['香港', '澳门', '台湾']))
+				   || ($isIPv6
+				       && $ipInfo['country'] == 'China')){
 					Log::info('识别到大陆IP,拒绝访问:'.$ip);
 
 					return response()->view('auth.error', ['message' => trans('error.ForbiddenChina')], 403);
@@ -82,7 +83,9 @@ class isForbidden
 
 			// 拒绝非大陆IP访问
 			if(Helpers::systemConfig()['is_forbid_oversea']){
-				if($ipInfo['country'] != '中国' || in_array($ipInfo['province'], ['香港', '澳门', '台湾']) || ($isIPv6 && $ipInfo['country'] != 'China')){
+				if($ipInfo['country'] != '中国' || in_array($ipInfo['province'], ['香港', '澳门', '台湾'])
+				   || ($isIPv6
+				       && $ipInfo['country'] != 'China')){
 					Log::info('识别到海外IP,拒绝访问:'.$ip.' - '.$ipInfo['country']);
 
 					return response()->view('auth.error', ['message' => trans('error.ForbiddenOversea')], 403);

+ 4 - 6
app/Http/Middleware/isLogin.php

@@ -6,18 +6,16 @@ use Closure;
 use Illuminate\Http\Request;
 use Redirect;
 
-class isLogin
-{
+class isLogin {
 	/**
 	 * 校验是否已登录
 	 *
-	 * @param Request $request
-	 * @param Closure $next
+	 * @param  Request  $request
+	 * @param  Closure  $next
 	 *
 	 * @return mixed
 	 */
-	public function handle($request, Closure $next)
-	{
+	public function handle($request, Closure $next) {
 		if(auth()->guest()){
 			return Redirect::to('login');
 		}

+ 9 - 8
app/Http/Middleware/isMaintenance.php

@@ -6,22 +6,23 @@ use App\Components\Helpers;
 use Closure;
 use Illuminate\Http\Request;
 
-class isMaintenance
-{
+class isMaintenance {
 	/**
 	 * 校验是否开启维护模式
 	 *
-	 * @param Request $request
-	 * @param Closure $next
+	 * @param  Request  $request
+	 * @param  Closure  $next
 	 *
 	 * @return mixed
 	 */
-	public function handle($request, Closure $next)
-	{
+	public function handle($request, Closure $next) {
 		if(Helpers::systemConfig()['maintenance_mode']){
-			return response()->view('auth.maintenance', ['message' => Helpers::systemConfig()['maintenance_content'], 'time' => Helpers::systemConfig()['maintenance_time']? : '0']);
+			return response()->view('auth.maintenance', [
+				'message' => Helpers::systemConfig()['maintenance_content'],
+				'time'    => Helpers::systemConfig()['maintenance_time']?: '0'
+			]);
 		}
 
 		return $next($request);
 	}
-}
+}

+ 7 - 7
app/Http/Middleware/isSecurity.php

@@ -7,18 +7,16 @@ use Cache;
 use Closure;
 use Log;
 
-class isSecurity
-{
+class isSecurity {
 	/**
 	 * 是否需要安全码才访问(仅用于登录页)
 	 *
-	 * @param         $request
-	 * @param Closure $next
+	 * @param           $request
+	 * @param  Closure  $next
 	 *
 	 * @return mixed
 	 */
-	public function handle($request, Closure $next)
-	{
+	public function handle($request, Closure $next) {
 		$ip = getClientIP();
 		$code = $request->securityCode;
 		$cacheKey = 'SecurityLogin_'.ip2long($ip);
@@ -28,7 +26,9 @@ class isSecurity
 			if($code != $websiteSecurityCode){
 				Log::info("拒绝非安全入口访问(".$ip.")");
 
-				return response()->view('auth.error', ['message' => trans('error.SecurityError').', '.trans('error.Visit').'<a href="/login?securityCode=" target="_self">'.trans('error.SecurityEnter').'</a>']);
+				return response()->view('auth.error', [
+					'message' => trans('error.SecurityError').', '.trans('error.Visit').'<a href="/login?securityCode=" target="_self">'.trans('error.SecurityEnter').'</a>'
+				]);
 			}else{
 				Cache::put($cacheKey, $ip, 7200); // 2小时之内无需再次输入安全码访问
 			}

+ 5 - 11
app/Http/Models/Article.php

@@ -10,27 +10,22 @@ use Illuminate\Support\Carbon;
 
 /**
  * 文章
- * Class Article
  *
- * @package App\Http\Models
- * @mixin Eloquent
  * @property int         $id
  * @property string      $title      标题
  * @property string|null $author     作者
  * @property string|null $summary    简介
  * @property string|null $logo       LOGO
  * @property string|null $content    内容
- * @property int|null    $type       类型:1-文章、2-公告、3-购买说明、4-使用教程
+ * @property int|null    $type       类型:1-文章、2-站内公告、3-站外公告
  * @property int         $sort       排序
  * @property Carbon|null $created_at 创建时间
  * @property Carbon|null $updated_at 最后更新时间
  * @property Carbon|null $deleted_at 删除时间
- * @method static bool|null forceDelete()
  * @method static \Illuminate\Database\Eloquent\Builder|Article newModelQuery()
  * @method static \Illuminate\Database\Eloquent\Builder|Article newQuery()
  * @method static Builder|Article onlyTrashed()
  * @method static \Illuminate\Database\Eloquent\Builder|Article query()
- * @method static bool|null restore()
  * @method static \Illuminate\Database\Eloquent\Builder|Article type($type)
  * @method static \Illuminate\Database\Eloquent\Builder|Article whereAuthor($value)
  * @method static \Illuminate\Database\Eloquent\Builder|Article whereContent($value)
@@ -45,9 +40,9 @@ use Illuminate\Support\Carbon;
  * @method static \Illuminate\Database\Eloquent\Builder|Article whereUpdatedAt($value)
  * @method static Builder|Article withTrashed()
  * @method static Builder|Article withoutTrashed()
+ * @mixin Eloquent
  */
-class Article extends Model
-{
+class Article extends Model {
 	use SoftDeletes;
 
 	protected $table = 'article';
@@ -55,8 +50,7 @@ class Article extends Model
 	protected $dates = ['deleted_at'];
 
 	// 筛选类型
-	function scopeType($query, $type)
-	{
+	function scopeType($query, $type) {
 		return $query->whereType($type);
 	}
-}
+}

+ 4 - 7
app/Http/Models/Config.php

@@ -8,10 +8,7 @@ use Illuminate\Database\Eloquent\Model;
 
 /**
  * 系统配置
- * Class Config
  *
- * @package App\Http\Models
- * @mixin Eloquent
  * @property int         $id
  * @property string      $name  配置名
  * @property string|null $value 配置值
@@ -21,11 +18,11 @@ use Illuminate\Database\Eloquent\Model;
  * @method static Builder|Config whereId($value)
  * @method static Builder|Config whereName($value)
  * @method static Builder|Config whereValue($value)
+ * @mixin Eloquent
  */
-class Config extends Model
-{
-	public $timestamps = FALSE;
+class Config extends Model {
+	public $timestamps = false;
 	protected $table = 'config';
 	protected $primaryKey = 'id';
 
-}
+}

+ 4 - 7
app/Http/Models/Country.php

@@ -8,10 +8,7 @@ use Illuminate\Database\Eloquent\Model;
 
 /**
  * 国家/地区
- * Class Country
  *
- * @package App\Http\Models
- * @mixin Eloquent
  * @property int    $id
  * @property string $name 名称
  * @property string $code 代码
@@ -21,10 +18,10 @@ use Illuminate\Database\Eloquent\Model;
  * @method static Builder|Country whereCode($value)
  * @method static Builder|Country whereId($value)
  * @method static Builder|Country whereName($value)
+ * @mixin Eloquent
  */
-class Country extends Model
-{
-	public $timestamps = FALSE;
+class Country extends Model {
+	public $timestamps = false;
 	protected $table = 'country';
 	protected $primaryKey = 'id';
-}
+}

+ 18 - 30
app/Http/Models/Coupon.php

@@ -10,16 +10,13 @@ use Illuminate\Support\Carbon;
 
 /**
  * 优惠券
- * Class Goods
  *
- * @package App\Http\Models
- * @mixin Eloquent
  * @property int         $id
  * @property string      $name            优惠券名称
  * @property string      $logo            优惠券LOGO
  * @property string      $sn              优惠券码
- * @property int         $type            类型:1-现金券、2-折扣券、3-充值券
- * @property int         $usage           用途:1-仅限一次性使用、2-可重复使用
+ * @property int         $type            类型:1-抵用券、2-折扣券、3-充值券
+ * @property int         $usage           用途:0-可重复使用、1-仅限一次性使用
  * @property int         $amount          金额,单位分
  * @property float       $discount        折扣
  * @property int         $rule            使用限制,单位分
@@ -29,12 +26,10 @@ use Illuminate\Support\Carbon;
  * @property Carbon|null $created_at      创建时间
  * @property Carbon|null $updated_at      最后更新时间
  * @property Carbon|null $deleted_at      删除时间
- * @method static bool|null forceDelete()
  * @method static \Illuminate\Database\Eloquent\Builder|Coupon newModelQuery()
  * @method static \Illuminate\Database\Eloquent\Builder|Coupon newQuery()
  * @method static Builder|Coupon onlyTrashed()
  * @method static \Illuminate\Database\Eloquent\Builder|Coupon query()
- * @method static bool|null restore()
  * @method static \Illuminate\Database\Eloquent\Builder|Coupon type($type)
  * @method static \Illuminate\Database\Eloquent\Builder|Coupon whereAmount($value)
  * @method static \Illuminate\Database\Eloquent\Builder|Coupon whereAvailableEnd($value)
@@ -53,9 +48,9 @@ use Illuminate\Support\Carbon;
  * @method static \Illuminate\Database\Eloquent\Builder|Coupon whereUsage($value)
  * @method static Builder|Coupon withTrashed()
  * @method static Builder|Coupon withoutTrashed()
+ * @mixin Eloquent
  */
-class Coupon extends Model
-{
+class Coupon extends Model {
 	use SoftDeletes;
 
 	protected $table = 'coupon';
@@ -63,38 +58,31 @@ class Coupon extends Model
 	protected $dates = ['deleted_at'];
 
 	// 筛选类型
-	function scopeType($query, $type)
-	{
+	function scopeType($query, $type) {
 		return $query->whereType($type);
 	}
 
-	function getAmountAttribute($value)
-	{
-		return $value/100;
+	function getAmountAttribute($value) {
+		return $value / 100;
 	}
 
-	function setAmountAttribute($value)
-	{
-		$this->attributes['amount'] = $value*100;
+	function setAmountAttribute($value) {
+		$this->attributes['amount'] = $value * 100;
 	}
 
-	function getDiscountAttribute($value)
-	{
-		return $value*10;
+	function getDiscountAttribute($value) {
+		return $value * 10;
 	}
 
-	function setDiscountAttribute($value)
-	{
-		$this->attributes['discount'] = $value/10;
+	function setDiscountAttribute($value) {
+		$this->attributes['discount'] = $value / 10;
 	}
 
-	function getRuleAttribute($value)
-	{
-		return $value/100;
+	function getRuleAttribute($value) {
+		return $value / 100;
 	}
 
-	function setRuleAttribute($value)
-	{
-		$this->attributes['rule'] = $value*100;
+	function setRuleAttribute($value) {
+		$this->attributes['rule'] = $value * 100;
 	}
-}
+}

+ 10 - 13
app/Http/Models/CouponLog.php

@@ -9,31 +9,28 @@ use Illuminate\Support\Carbon;
 
 /**
  * 优惠券使用日志
- * Class Goods
  *
- * @package App\Http\Models
- * @mixin Eloquent
  * @property int         $id
- * @property int         $coupon_id  优惠券ID
- * @property int         $goods_id   商品ID
- * @property int         $order_id   订单ID
- * @property string      $desc       备注
- * @property Carbon|null $created_at 创建时间
- * @property Carbon|null $updated_at 最后更新时间
+ * @property int         $coupon_id   优惠券ID
+ * @property int         $goods_id    商品ID
+ * @property int         $order_id    订单ID
+ * @property string      $description 备注
+ * @property Carbon|null $created_at  创建时间
+ * @property Carbon|null $updated_at  最后更新时间
  * @method static Builder|CouponLog newModelQuery()
  * @method static Builder|CouponLog newQuery()
  * @method static Builder|CouponLog query()
  * @method static Builder|CouponLog whereCouponId($value)
  * @method static Builder|CouponLog whereCreatedAt($value)
- * @method static Builder|CouponLog whereDesc($value)
+ * @method static Builder|CouponLog whereDescription($value)
  * @method static Builder|CouponLog whereGoodsId($value)
  * @method static Builder|CouponLog whereId($value)
  * @method static Builder|CouponLog whereOrderId($value)
  * @method static Builder|CouponLog whereUpdatedAt($value)
+ * @mixin Eloquent
  */
-class CouponLog extends Model
-{
+class CouponLog extends Model {
 	protected $table = 'coupon_log';
 	protected $primaryKey = 'id';
 
-}
+}

+ 6 - 23
app/Http/Models/Device.php

@@ -8,36 +8,20 @@ use Illuminate\Database\Eloquent\Model;
 
 /**
  * 订阅设备列表
- * Class Device
  *
- * @package App\Http\Models
- * @mixin Eloquent
- * @property int        $id
- * @property int        $type     类型:0-兼容、1-Shadowsocks(R)、2-V2Ray
- * @property int        $platform 所属平台:0-其他、1-iOS、2-Android、3-Mac、4-Windows、5-Linux
- * @property string     $name     设备名称
- * @property int        $status   状态:0-禁止订阅、1-允许订阅
- * @property string     $header   请求时头部的识别特征码
  * @property-read mixed $platform_label
  * @property-read mixed $type_label
  * @method static Builder|Device newModelQuery()
  * @method static Builder|Device newQuery()
  * @method static Builder|Device query()
- * @method static Builder|Device whereHeader($value)
- * @method static Builder|Device whereId($value)
- * @method static Builder|Device whereName($value)
- * @method static Builder|Device wherePlatform($value)
- * @method static Builder|Device whereStatus($value)
- * @method static Builder|Device whereType($value)
+ * @mixin Eloquent
  */
-class Device extends Model
-{
-	public $timestamps = FALSE;
+class Device extends Model {
+	public $timestamps = false;
 	protected $table = 'device';
 	protected $primaryKey = 'id';
 
-	function getTypeLabelAttribute()
-	{
+	function getTypeLabelAttribute() {
 		switch($this->attributes['type']){
 			case 1:
 				$type_label = '<span class="label label-danger"> Shadowsocks(R) </span>';
@@ -52,8 +36,7 @@ class Device extends Model
 		return $type_label;
 	}
 
-	function getPlatformLabelAttribute()
-	{
+	function getPlatformLabelAttribute() {
 		switch($this->attributes['platform']){
 			case 1:
 				$platform_label = '<i class="fa fa-apple"></i> iOS';
@@ -77,4 +60,4 @@ class Device extends Model
 
 		return $platform_label;
 	}
-}
+}

+ 16 - 28
app/Http/Models/Goods.php

@@ -11,20 +11,17 @@ use Illuminate\Support\Carbon;
 
 /**
  * 商品
- * Class Goods
  *
- * @package App\Http\Models
- * @mixin Eloquent
  * @property int                          $id
  * @property string                       $sku        商品服务SKU
  * @property string                       $name       商品名称
  * @property string                       $logo       商品图片地址
  * @property int                          $traffic    商品内含多少流量,单位MiB
- * @property int                          $type       商品类型:1-流量包、2-套餐、3-余额充值
+ * @property int                          $type       商品类型:1-流量包、2-套餐
  * @property int                          $price      售价,单位分
  * @property int                          $renew      流量重置价格,单位分
  * @property int                          $period     流量自动重置周期
- * @property string|null                  $info       商品
+ * @property string|null                  $info       商品信息
  * @property string|null                  $desc       商品描述
  * @property int                          $days       有效期
  * @property int                          $invite_num 赠送邀请码数
@@ -39,12 +36,10 @@ use Illuminate\Support\Carbon;
  * @property-read mixed                   $traffic_label
  * @property-read Collection|GoodsLabel[] $label
  * @property-read int|null                $label_count
- * @method static bool|null forceDelete()
  * @method static \Illuminate\Database\Eloquent\Builder|Goods newModelQuery()
  * @method static \Illuminate\Database\Eloquent\Builder|Goods newQuery()
  * @method static Builder|Goods onlyTrashed()
  * @method static \Illuminate\Database\Eloquent\Builder|Goods query()
- * @method static bool|null restore()
  * @method static \Illuminate\Database\Eloquent\Builder|Goods type($type)
  * @method static \Illuminate\Database\Eloquent\Builder|Goods whereColor($value)
  * @method static \Illuminate\Database\Eloquent\Builder|Goods whereCreatedAt($value)
@@ -69,47 +64,40 @@ use Illuminate\Support\Carbon;
  * @method static \Illuminate\Database\Eloquent\Builder|Goods whereUpdatedAt($value)
  * @method static Builder|Goods withTrashed()
  * @method static Builder|Goods withoutTrashed()
+ * @mixin Eloquent
  */
-class Goods extends Model
-{
+class Goods extends Model {
 	use SoftDeletes;
 
 	protected $table = 'goods';
 	protected $primaryKey = 'id';
 	protected $dates = ['deleted_at'];
 
-	function scopeType($query, $type)
-	{
+	function scopeType($query, $type) {
 		return $query->whereType($type)->whereStatus(1)->orderBy('sort', 'desc');
 	}
 
-	function label()
-	{
+	function label() {
 		return $this->hasMany(GoodsLabel::class, 'goods_id', 'id');
 	}
 
-	function getPriceAttribute($value)
-	{
-		return $value/100;
+	function getPriceAttribute($value) {
+		return $value / 100;
 	}
 
-	function setPriceAttribute($value)
-	{
-		$this->attributes['price'] = $value*100;
+	function setPriceAttribute($value) {
+		$this->attributes['price'] = $value * 100;
 	}
 
-	function getRenewAttribute($value)
-	{
-		return $value/100;
+	function getRenewAttribute($value) {
+		return $value / 100;
 	}
 
-	function setRenewAttribute($value)
-	{
-		return $this->attributes['renew'] = $value*100;
+	function setRenewAttribute($value) {
+		return $this->attributes['renew'] = $value * 100;
 	}
 
-	function getTrafficLabelAttribute()
-	{
-		return flowAutoShow($this->attributes['traffic']*1048576);
+	function getTrafficLabelAttribute() {
+		return flowAutoShow($this->attributes['traffic'] * 1048576);
 	}
 }

+ 6 - 16
app/Http/Models/GoodsLabel.php

@@ -8,29 +8,19 @@ use Illuminate\Database\Eloquent\Model;
 
 /**
  * 商品标签
- * Class GoodsLabel
  *
- * @package App\Http\Models
- * @mixin Eloquent
- * @property int        $id
- * @property int        $goods_id 商品ID
- * @property int        $label_id 标签ID
- * @property-read Goods $goods
+ * @property-read Goods|null $goods
  * @method static Builder|GoodsLabel newModelQuery()
  * @method static Builder|GoodsLabel newQuery()
  * @method static Builder|GoodsLabel query()
- * @method static Builder|GoodsLabel whereGoodsId($value)
- * @method static Builder|GoodsLabel whereId($value)
- * @method static Builder|GoodsLabel whereLabelId($value)
+ * @mixin Eloquent
  */
-class GoodsLabel extends Model
-{
-	public $timestamps = FALSE;
+class GoodsLabel extends Model {
+	public $timestamps = false;
 	protected $table = 'goods_label';
 	protected $primaryKey = 'id';
 
-	function goods()
-	{
+	function goods() {
 		return $this->hasOne(Goods::class, 'id', 'goods_id');
 	}
-}
+}

+ 19 - 28
app/Http/Models/Invite.php

@@ -11,28 +11,23 @@ use Illuminate\Support\Carbon;
 
 /**
  * 邀请码
- * Class Invite
  *
- * @package App\Http\Models
- * @mixin Eloquent
- * @property-read mixed  $status_label
- * @property int         $id
- * @property int         $uid        邀请人ID
- * @property int         $fuid       受邀人ID
- * @property string      $code       邀请码
- * @property int         $status     邀请码状态:0-未使用、1-已使用、2-已过期
- * @property string|null $dateline   有效期至
- * @property Carbon|null $created_at
- * @property Carbon|null $updated_at
- * @property Carbon|null $deleted_at 删除时间
- * @property-read User   $generator
- * @property-read User   $user
- * @method static bool|null forceDelete()
+ * @property int            $id
+ * @property int            $uid        邀请人ID
+ * @property int            $fuid       受邀人ID
+ * @property string         $code       邀请码
+ * @property int            $status     邀请码状态:0-未使用、1-已使用、2-已过期
+ * @property string|null    $dateline   有效期至
+ * @property Carbon|null    $created_at
+ * @property Carbon|null    $updated_at
+ * @property Carbon|null    $deleted_at 删除时间
+ * @property-read User|null $generator
+ * @property-read mixed     $status_label
+ * @property-read User|null $user
  * @method static \Illuminate\Database\Eloquent\Builder|Invite newModelQuery()
  * @method static \Illuminate\Database\Eloquent\Builder|Invite newQuery()
  * @method static Builder|Invite onlyTrashed()
  * @method static \Illuminate\Database\Eloquent\Builder|Invite query()
- * @method static bool|null restore()
  * @method static \Illuminate\Database\Eloquent\Builder|Invite uid()
  * @method static \Illuminate\Database\Eloquent\Builder|Invite whereCode($value)
  * @method static \Illuminate\Database\Eloquent\Builder|Invite whereCreatedAt($value)
@@ -45,32 +40,28 @@ use Illuminate\Support\Carbon;
  * @method static \Illuminate\Database\Eloquent\Builder|Invite whereUpdatedAt($value)
  * @method static Builder|Invite withTrashed()
  * @method static Builder|Invite withoutTrashed()
+ * @mixin Eloquent
  */
-class Invite extends Model
-{
+class Invite extends Model {
 	use SoftDeletes;
 
 	protected $table = 'invite';
 	protected $primaryKey = 'id';
 	protected $dates = ['deleted_at'];
 
-	function scopeUid($query)
-	{
+	function scopeUid($query) {
 		return $query->whereUid(Auth::user()->id);
 	}
 
-	function generator()
-	{
+	function generator() {
 		return $this->hasOne(User::class, 'id', 'uid');
 	}
 
-	function user()
-	{
+	function user() {
 		return $this->hasOne(User::class, 'id', 'fuid');
 	}
 
-	function getStatusLabelAttribute()
-	{
+	function getStatusLabelAttribute() {
 		switch($this->attributes['status']){
 			case 0:
 				$status_label = '<span class="badge badge-success">'.trans('home.invite_code_table_status_un').'</span>';
@@ -88,4 +79,4 @@ class Invite extends Model
 		return $status_label;
 	}
 
-}
+}

+ 4 - 7
app/Http/Models/Label.php

@@ -8,10 +8,7 @@ use Illuminate\Database\Eloquent\Model;
 
 /**
  * 标签
- * Class Label
  *
- * @package App\Http\Models
- * @mixin Eloquent
  * @property int    $id
  * @property string $name 名称
  * @property int    $sort 排序值
@@ -21,10 +18,10 @@ use Illuminate\Database\Eloquent\Model;
  * @method static Builder|Label whereId($value)
  * @method static Builder|Label whereName($value)
  * @method static Builder|Label whereSort($value)
+ * @mixin Eloquent
  */
-class Label extends Model
-{
-	public $timestamps = FALSE;
+class Label extends Model {
+	public $timestamps = false;
 	protected $table = 'label';
 	protected $primaryKey = 'id';
-}
+}

+ 4 - 13
app/Http/Models/Level.php

@@ -8,23 +8,14 @@ use Illuminate\Database\Eloquent\Model;
 
 /**
  * 等级
- * Class Level
  *
- * @package App\Http\Models
- * @mixin Eloquent
- * @property int    $id
- * @property int    $level      等级
- * @property string $level_name 等级名称
  * @method static Builder|Level newModelQuery()
  * @method static Builder|Level newQuery()
  * @method static Builder|Level query()
- * @method static Builder|Level whereId($value)
- * @method static Builder|Level whereLevel($value)
- * @method static Builder|Level whereLevelName($value)
+ * @mixin Eloquent
  */
-class Level extends Model
-{
-	public $timestamps = FALSE;
+class Level extends Model {
+	public $timestamps = false;
 	protected $table = 'level';
 	protected $primaryKey = 'id';
-}
+}

+ 5 - 9
app/Http/Models/Marketing.php

@@ -9,12 +9,9 @@ use Illuminate\Support\Carbon;
 
 /**
  * 营销
- * Class Marketing
  *
- * @package App\Http\Models
- * @mixin Eloquent
  * @property int         $id
- * @property int         $type     类型:1-邮件群发、2-订阅渠道群发
+ * @property int         $type     类型:1-邮件群发
  * @property string      $receiver 接收者
  * @property string      $title    标题
  * @property string      $content  内容
@@ -35,15 +32,14 @@ use Illuminate\Support\Carbon;
  * @method static Builder|Marketing whereTitle($value)
  * @method static Builder|Marketing whereType($value)
  * @method static Builder|Marketing whereUpdatedAt($value)
+ * @mixin Eloquent
  */
-class Marketing extends Model
-{
+class Marketing extends Model {
 	protected $table = 'marketing';
 	protected $primaryKey = 'id';
 	protected $appends = ['status_label'];
 
-	function getStatusLabelAttribute()
-	{
+	function getStatusLabelAttribute() {
 		$status_label = '';
 		switch($this->attributes['status']){
 			case -1:
@@ -59,4 +55,4 @@ class Marketing extends Model
 
 		return $status_label;
 	}
-}
+}

+ 5 - 7
app/Http/Models/NotificationLog.php

@@ -9,13 +9,12 @@ use Illuminate\Support\Carbon;
 
 /**
  * 推送通知日志
- * Class NotificationLog
  *
  * @property int         $id
- * @property int         $type       类型:1-邮件、2-ServerChan、3-Bark
+ * @property int         $type       类型:1-邮件、2-ServerChan、3-Bark、4-Telegram
  * @property string      $address    收信地址
- * @property string      $title      标题
- * @property string      $content    内容
+ * @property string|null $title      邮件标题
+ * @property string|null $content    邮件内容
  * @property int         $status     状态:-1发送失败、0-等待发送、1-发送成功
  * @property string|null $error      发送失败抛出的异常信息
  * @property Carbon|null $created_at 创建时间
@@ -34,9 +33,8 @@ use Illuminate\Support\Carbon;
  * @method static Builder|NotificationLog whereUpdatedAt($value)
  * @mixin Eloquent
  */
-class NotificationLog extends Model
-{
+class NotificationLog extends Model {
 	protected $table = 'notification_log';
 	protected $primaryKey = 'id';
 
-}
+}

+ 37 - 53
app/Http/Models/Order.php

@@ -10,30 +10,26 @@ use Illuminate\Support\Carbon;
 
 /**
  * 订单
- * Class Order
  *
- * @package App\Http\Models
- * @mixin Eloquent
- * @property-read mixed   $status_label
- * @property int          $oid
- * @property string       $order_sn      订单编号
- * @property int          $user_id       操作人
- * @property int          $goods_id      商品ID
- * @property int          $coupon_id     优惠券ID
- * @property string|null  $email         邮箱
- * @property int          $origin_amount 订单原始总价,单位分
- * @property int          $amount        订单总价,单位分
- * @property string|null  $expire_at     过期时间
- * @property int          $is_expire     是否已过期:0-未过期、1-已过期
- * @property int          $pay_way       支付方式:1-余额支付、2-有赞云支付
- * @property int          $status        订单状态:-1-已关闭、0-待支付、1-已支付待确认、2-已完成
- * @property Carbon|null  $created_at    创建时间
- * @property Carbon|null  $updated_at    最后一次更新时间
- * @property-read Coupon  $coupon
- * @property-read Goods   $goods
- * @property-read Payment $payment
- * @property-read User    $user
- * @property-read mixed   $pay_way_label
+ * @property int               $oid
+ * @property string            $order_sn      订单编号
+ * @property int               $user_id       操作人
+ * @property int               $goods_id      商品ID
+ * @property int               $coupon_id     优惠券ID
+ * @property int               $origin_amount 订单原始总价,单位分
+ * @property int               $amount        订单总价,单位分
+ * @property string|null       $expire_at     过期时间
+ * @property int               $is_expire     是否已过期:0-未过期、1-已过期
+ * @property string            $pay_way       支付方式:balance、f2fpay、codepay、payjs、bitpayx等
+ * @property int               $status        订单状态:-1-已关闭、0-待支付、1-已支付待确认、2-已完成
+ * @property Carbon|null       $created_at    创建时间
+ * @property Carbon|null       $updated_at    最后一次更新时间
+ * @property-read Coupon|null  $coupon
+ * @property-read mixed        $pay_way_label
+ * @property-read mixed        $status_label
+ * @property-read Goods|null   $goods
+ * @property-read Payment|null $payment
+ * @property-read User|null    $user
  * @method static Builder|Order newModelQuery()
  * @method static Builder|Order newQuery()
  * @method static Builder|Order query()
@@ -41,7 +37,6 @@ use Illuminate\Support\Carbon;
  * @method static Builder|Order whereAmount($value)
  * @method static Builder|Order whereCouponId($value)
  * @method static Builder|Order whereCreatedAt($value)
- * @method static Builder|Order whereEmail($value)
  * @method static Builder|Order whereExpireAt($value)
  * @method static Builder|Order whereGoodsId($value)
  * @method static Builder|Order whereIsExpire($value)
@@ -52,41 +47,35 @@ use Illuminate\Support\Carbon;
  * @method static Builder|Order whereStatus($value)
  * @method static Builder|Order whereUpdatedAt($value)
  * @method static Builder|Order whereUserId($value)
+ * @mixin Eloquent
  */
-class Order extends Model
-{
+class Order extends Model {
 	protected $table = 'order';
 	protected $primaryKey = 'oid';
 	protected $appends = ['status_label'];
 
-	function scopeUid($query)
-	{
+	function scopeUid($query) {
 		return $query->whereUserId(Auth::user()->id);
 	}
 
-	function user()
-	{
+	function user() {
 		return $this->hasOne(User::class, 'id', 'user_id');
 	}
 
-	function goods()
-	{
+	function goods() {
 		return $this->hasOne(Goods::class, 'id', 'goods_id')->withTrashed();
 	}
 
-	function coupon()
-	{
+	function coupon() {
 		return $this->hasOne(Coupon::class, 'id', 'coupon_id')->withTrashed();
 	}
 
-	function payment()
-	{
+	function payment() {
 		return $this->hasOne(Payment::class, 'oid', 'oid');
 	}
 
 	// 订单状态
-	function getStatusLabelAttribute()
-	{
+	function getStatusLabelAttribute() {
 		switch($this->attributes['status']){
 			case -1:
 				$status_label = trans('home.invoice_status_closed');
@@ -108,29 +97,24 @@ class Order extends Model
 	}
 
 
-	function getOriginAmountAttribute($value)
-	{
-		return $value/100;
+	function getOriginAmountAttribute($value) {
+		return $value / 100;
 	}
 
-	function setOriginAmountAttribute($value)
-	{
-		return $this->attributes['origin_amount'] = $value*100;
+	function setOriginAmountAttribute($value) {
+		return $this->attributes['origin_amount'] = $value * 100;
 	}
 
-	function getAmountAttribute($value)
-	{
-		return $value/100;
+	function getAmountAttribute($value) {
+		return $value / 100;
 	}
 
-	function setAmountAttribute($value)
-	{
-		return $this->attributes['amount'] = $value*100;
+	function setAmountAttribute($value) {
+		return $this->attributes['amount'] = $value * 100;
 	}
 
 	// 支付方式
-	function getPayWayLabelAttribute()
-	{
+	function getPayWayLabelAttribute() {
 		switch($this->attributes['pay_way']){
 			case 'balance':
 				$pay_way_label = '余额';
@@ -156,4 +140,4 @@ class Order extends Model
 
 		return $pay_way_label;
 	}
-}
+}

+ 17 - 25
app/Http/Models/Payment.php

@@ -10,16 +10,15 @@ use Illuminate\Support\Carbon;
 
 /**
  * 支付单
- * Class Payment
  *
  * @property int             $id
- * @property string|null     $sn
- * @property int             $user_id 用户ID
- * @property int|null        $oid     本地订单ID
- * @property int             $amount  金额,单位分
- * @property string|null     $qr_code 支付二维码
- * @property string|null     $url     支付链接
- * @property int             $status  状态:-1-支付失败、0-等待支付、1-支付成功
+ * @property string|null     $trade_no 支付单号(本地订单号)
+ * @property int             $user_id  用户ID
+ * @property int|null        $oid      本地订单ID
+ * @property int             $amount   金额,单位分
+ * @property string|null     $qr_code  支付二维码
+ * @property string|null     $url      支付链接
+ * @property int             $status   支付状态:-1-支付失败、0-等待支付、1-支付成功
  * @property Carbon          $created_at
  * @property Carbon          $updated_at
  * @property-read mixed      $status_label
@@ -34,47 +33,40 @@ use Illuminate\Support\Carbon;
  * @method static Builder|Payment whereId($value)
  * @method static Builder|Payment whereOid($value)
  * @method static Builder|Payment whereQrCode($value)
- * @method static Builder|Payment whereSn($value)
  * @method static Builder|Payment whereStatus($value)
+ * @method static Builder|Payment whereTradeNo($value)
  * @method static Builder|Payment whereUpdatedAt($value)
  * @method static Builder|Payment whereUrl($value)
  * @method static Builder|Payment whereUserId($value)
  * @mixin Eloquent
  */
-class Payment extends Model
-{
+class Payment extends Model {
 	protected $table = 'payment';
 	protected $primaryKey = 'id';
 	protected $appends = ['status_label'];
 
-	function scopeUid($query)
-	{
+	function scopeUid($query) {
 		return $query->whereUserId(Auth::user()->id);
 	}
 
-	function user()
-	{
+	function user() {
 		return $this->belongsTo(User::class, 'user_id', 'id');
 	}
 
-	function order()
-	{
+	function order() {
 		return $this->belongsTo(Order::class, 'oid', 'oid');
 	}
 
-	function getAmountAttribute($value)
-	{
-		return $value/100;
+	function getAmountAttribute($value) {
+		return $value / 100;
 	}
 
-	function setAmountAttribute($value)
-	{
-		return $this->attributes['amount'] = $value*100;
+	function setAmountAttribute($value) {
+		return $this->attributes['amount'] = $value * 100;
 	}
 
 	// 订单状态
-	function getStatusLabelAttribute()
-	{
+	function getStatusLabelAttribute() {
 		switch($this->attributes['status']){
 			case -1:
 				$status_label = '支付失败';

+ 12 - 32
app/Http/Models/PaymentCallback.php

@@ -8,54 +8,34 @@ use Illuminate\Database\Eloquent\Model;
 use Illuminate\Support\Carbon;
 
 /**
- * 支付回调(有赞云支付)
- * Class PaymentCallback
+ * 支付回调日志
  *
- * @package App\Http\Models
- * @mixin Eloquent
  * @property int         $id
- * @property string|null $client_id
- * @property string|null $yz_id
- * @property string|null $kdt_id
- * @property string|null $kdt_name
- * @property int|null    $mode
- * @property string|null $msg
- * @property int|null    $sendCount
- * @property string|null $sign
- * @property string|null $status
- * @property int|null    $test
- * @property string|null $type
- * @property string|null $version
+ * @property string|null $trade_no     本地订单号
+ * @property string|null $out_trade_no 外部订单号(支付平台)
+ * @property int|null    $amount       交易金额,单位分
+ * @property int|null    $status       交易状态:0-失败、1-成功
  * @property Carbon|null $created_at
  * @property Carbon|null $updated_at
  * @property-read mixed  $status_label
  * @method static Builder|PaymentCallback newModelQuery()
  * @method static Builder|PaymentCallback newQuery()
  * @method static Builder|PaymentCallback query()
- * @method static Builder|PaymentCallback whereClientId($value)
+ * @method static Builder|PaymentCallback whereAmount($value)
  * @method static Builder|PaymentCallback whereCreatedAt($value)
  * @method static Builder|PaymentCallback whereId($value)
- * @method static Builder|PaymentCallback whereKdtId($value)
- * @method static Builder|PaymentCallback whereKdtName($value)
- * @method static Builder|PaymentCallback whereMode($value)
- * @method static Builder|PaymentCallback whereMsg($value)
- * @method static Builder|PaymentCallback whereSendCount($value)
- * @method static Builder|PaymentCallback whereSign($value)
+ * @method static Builder|PaymentCallback whereOutTradeNo($value)
  * @method static Builder|PaymentCallback whereStatus($value)
- * @method static Builder|PaymentCallback whereTest($value)
- * @method static Builder|PaymentCallback whereType($value)
+ * @method static Builder|PaymentCallback whereTradeNo($value)
  * @method static Builder|PaymentCallback whereUpdatedAt($value)
- * @method static Builder|PaymentCallback whereVersion($value)
- * @method static Builder|PaymentCallback whereYzId($value)
+ * @mixin Eloquent
  */
-class PaymentCallback extends Model
-{
+class PaymentCallback extends Model {
 	protected $table = 'payment_callback';
 	protected $primaryKey = 'id';
 	protected $appends = ['status_label'];
 
-	function getStatusLabelAttribute()
-	{
+	function getStatusLabelAttribute() {
 		$status_label = '';
 		switch($this->attributes['status']){
 			case 'WAIT_BUYER_PAY':
@@ -74,4 +54,4 @@ class PaymentCallback extends Model
 
 		return $status_label;
 	}
-}
+}

+ 27 - 38
app/Http/Models/ReferralApply.php

@@ -10,20 +10,17 @@ use Illuminate\Support\Carbon;
 
 /**
  * 返利申请
- * Class ReferralApply
  *
- * @package App\Http\Models
- * @mixin Eloquent
- * @property int         $id
- * @property int         $user_id    用户ID
- * @property int         $before     操作前可提现金额,单位分
- * @property int         $after      操作后可提现金额,单位分
- * @property int         $amount     本次提现金额,单位分
- * @property string      $link_logs  关联返利日志ID,例如:1,3,4
- * @property int         $status     状态:-1-驳回、0-待审核、1-审核通过待打款、2-已打款
- * @property Carbon|null $created_at 创建时间
- * @property Carbon|null $updated_at 最后更新时间
- * @property-read User   $User
+ * @property int            $id
+ * @property int            $user_id    用户ID
+ * @property int            $before     操作前可提现金额,单位分
+ * @property int            $after      操作后可提现金额,单位分
+ * @property int            $amount     本次提现金额,单位分
+ * @property string         $link_logs  关联返利日志ID,例如:1,3,4
+ * @property int            $status     状态:-1-驳回、0-待审核、1-审核通过待打款、2-已打款
+ * @property Carbon|null    $created_at 创建时间
+ * @property Carbon|null    $updated_at 最后更新时间
+ * @property-read User|null $User
  * @method static Builder|ReferralApply newModelQuery()
  * @method static Builder|ReferralApply newQuery()
  * @method static Builder|ReferralApply query()
@@ -37,49 +34,41 @@ use Illuminate\Support\Carbon;
  * @method static Builder|ReferralApply whereStatus($value)
  * @method static Builder|ReferralApply whereUpdatedAt($value)
  * @method static Builder|ReferralApply whereUserId($value)
+ * @mixin Eloquent
  */
-class ReferralApply extends Model
-{
+class ReferralApply extends Model {
 	protected $table = 'referral_apply';
 	protected $primaryKey = 'id';
 
-	function scopeUid($query)
-	{
+	function scopeUid($query) {
 		return $query->whereUserId(Auth::user()->id);
 	}
 
-	function User()
-	{
+	function User() {
 		return $this->hasOne(User::class, 'id', 'user_id');
 	}
 
-	function getBeforeAttribute($value)
-	{
-		return $value/100;
+	function getBeforeAttribute($value) {
+		return $value / 100;
 	}
 
-	function setBeforeAttribute($value)
-	{
-		$this->attributes['before'] = $value*100;
+	function setBeforeAttribute($value) {
+		$this->attributes['before'] = $value * 100;
 	}
 
-	function getAfterAttribute($value)
-	{
-		return $value/100;
+	function getAfterAttribute($value) {
+		return $value / 100;
 	}
 
-	function setAfterAttribute($value)
-	{
-		$this->attributes['after'] = $value*100;
+	function setAfterAttribute($value) {
+		$this->attributes['after'] = $value * 100;
 	}
 
-	function getAmountAttribute($value)
-	{
-		return $value/100;
+	function getAmountAttribute($value) {
+		return $value / 100;
 	}
 
-	function setAmountAttribute($value)
-	{
-		$this->attributes['amount'] = $value*100;
+	function setAmountAttribute($value) {
+		$this->attributes['amount'] = $value * 100;
 	}
-}
+}

+ 27 - 38
app/Http/Models/ReferralLog.php

@@ -10,22 +10,19 @@ use Illuminate\Support\Carbon;
 
 /**
  * 返利日志
- * Class ReferralLog
  *
- * @package App\Http\Models
- * @mixin Eloquent
- * @property int         $id
- * @property int         $user_id     用户ID
- * @property int         $ref_user_id 推广人ID
- * @property int         $order_id    关联订单ID
- * @property int         $amount      消费金额,单位分
- * @property int         $ref_amount  返利金额
- * @property int         $status      状态:0-未提现、1-审核中、2-已提现
- * @property Carbon|null $created_at  创建时间
- * @property Carbon|null $updated_at  最后更新时间
- * @property-read Order  $order
- * @property-read User   $ref_user
- * @property-read User   $user
+ * @property int             $id
+ * @property int             $user_id     用户ID
+ * @property int             $ref_user_id 推广人ID
+ * @property int             $order_id    关联订单ID
+ * @property int             $amount      消费金额,单位分
+ * @property int             $ref_amount  返利金额
+ * @property int             $status      状态:0-未提现、1-审核中、2-已提现
+ * @property Carbon|null     $created_at  创建时间
+ * @property Carbon|null     $updated_at  最后更新时间
+ * @property-read Order|null $order
+ * @property-read User|null  $ref_user
+ * @property-read User|null  $user
  * @method static Builder|ReferralLog newModelQuery()
  * @method static Builder|ReferralLog newQuery()
  * @method static Builder|ReferralLog query()
@@ -39,49 +36,41 @@ use Illuminate\Support\Carbon;
  * @method static Builder|ReferralLog whereStatus($value)
  * @method static Builder|ReferralLog whereUpdatedAt($value)
  * @method static Builder|ReferralLog whereUserId($value)
+ * @mixin Eloquent
  */
-class ReferralLog extends Model
-{
+class ReferralLog extends Model {
 	protected $table = 'referral_log';
 	protected $primaryKey = 'id';
 
-	function scopeUid($query)
-	{
+	function scopeUid($query) {
 		return $query->whereRefUserId(Auth::user()->id);
 	}
 
-	function user()
-	{
+	function user() {
 		return $this->hasOne(User::class, 'id', 'user_id');
 	}
 
-	function ref_user()
-	{
+	function ref_user() {
 		return $this->hasOne(User::class, 'id', 'ref_user_id');
 	}
 
-	function order()
-	{
+	function order() {
 		return $this->hasOne(Order::class, 'oid', 'order_id');
 	}
 
-	function getAmountAttribute($value)
-	{
-		return $value/100;
+	function getAmountAttribute($value) {
+		return $value / 100;
 	}
 
-	function setAmountAttribute($value)
-	{
-		$this->attributes['amount'] = $value*100;
+	function setAmountAttribute($value) {
+		$this->attributes['amount'] = $value * 100;
 	}
 
-	function getRefAmountAttribute($value)
-	{
-		return $value/100;
+	function getRefAmountAttribute($value) {
+		return $value / 100;
 	}
 
-	function setRefAmountAttribute($value)
-	{
-		$this->attributes['ref_amount'] = $value*100;
+	function setRefAmountAttribute($value) {
+		$this->attributes['ref_amount'] = $value * 100;
 	}
-}
+}

+ 4 - 7
app/Http/Models/SensitiveWords.php

@@ -8,10 +8,7 @@ use Illuminate\Database\Eloquent\Model;
 
 /**
  * 敏感词
- * Class SensitiveWords
  *
- * @package App\Http\Models
- * @mixin Eloquent
  * @property int    $id
  * @property int    $type  类型:1-黑名单、2-白名单
  * @property string $words 敏感词
@@ -21,10 +18,10 @@ use Illuminate\Database\Eloquent\Model;
  * @method static Builder|SensitiveWords whereId($value)
  * @method static Builder|SensitiveWords whereType($value)
  * @method static Builder|SensitiveWords whereWords($value)
+ * @mixin Eloquent
  */
-class SensitiveWords extends Model
-{
-	public $timestamps = FALSE;
+class SensitiveWords extends Model {
+	public $timestamps = false;
 	protected $table = 'sensitive_words';
 	protected $primaryKey = 'id';
-}
+}

+ 6 - 11
app/Http/Models/SsConfig.php

@@ -8,10 +8,7 @@ use Illuminate\Database\Eloquent\Model;
 
 /**
  * 配置信息
- * Class SsConfig
  *
- * @package App\Http\Models
- * @mixin Eloquent
  * @property int    $id
  * @property string $name       配置名
  * @property int    $type       类型:1-加密方式、2-协议、3-混淆
@@ -27,23 +24,21 @@ use Illuminate\Database\Eloquent\Model;
  * @method static Builder|SsConfig whereName($value)
  * @method static Builder|SsConfig whereSort($value)
  * @method static Builder|SsConfig whereType($value)
+ * @mixin Eloquent
  */
-class SsConfig extends Model
-{
-	public $timestamps = FALSE;
+class SsConfig extends Model {
+	public $timestamps = false;
 	protected $table = 'ss_config';
 	protected $primaryKey = 'id';
 
 	// 筛选默认
 
-	function scopeDefault($query)
-	{
+	function scopeDefault($query) {
 		$query->whereIsDefault(1);
 	}
 
 	// 筛选类型
-	function scopeType($query, $type)
-	{
+	function scopeType($query, $type) {
 		$query->whereType($type);
 	}
-}
+}

+ 4 - 9
app/Http/Models/SsGroup.php

@@ -9,13 +9,9 @@ use Illuminate\Support\Carbon;
 
 /**
  * SS节点分组
- * Class SsNodeGroup
  *
- * @package App\Http\Models
- * @mixin Eloquent
  * @property int         $id
- * @property string      $name  分组名称
- * @property int         $level 分组级别
+ * @property string      $name 分组名称
  * @property Carbon|null $created_at
  * @property Carbon|null $updated_at
  * @method static Builder|SsGroup newModelQuery()
@@ -23,13 +19,12 @@ use Illuminate\Support\Carbon;
  * @method static Builder|SsGroup query()
  * @method static Builder|SsGroup whereCreatedAt($value)
  * @method static Builder|SsGroup whereId($value)
- * @method static Builder|SsGroup whereLevel($value)
  * @method static Builder|SsGroup whereName($value)
  * @method static Builder|SsGroup whereUpdatedAt($value)
+ * @mixin Eloquent
  */
-class SsGroup extends Model
-{
+class SsGroup extends Model {
 	protected $table = 'ss_group';
 	protected $primaryKey = 'id';
 
-}
+}

+ 4 - 7
app/Http/Models/SsGroupNode.php

@@ -8,10 +8,7 @@ use Illuminate\Database\Eloquent\Model;
 
 /**
  * SS分组和节点关联表
- * Class SsNodeGroup
  *
- * @package App\Http\Models
- * @mixin Eloquent
  * @property int $id
  * @property int $group_id 分组ID
  * @property int $node_id  节点ID
@@ -21,11 +18,11 @@ use Illuminate\Database\Eloquent\Model;
  * @method static Builder|SsGroupNode whereGroupId($value)
  * @method static Builder|SsGroupNode whereId($value)
  * @method static Builder|SsGroupNode whereNodeId($value)
+ * @mixin Eloquent
  */
-class SsGroupNode extends Model
-{
-	public $timestamps = FALSE;
+class SsGroupNode extends Model {
+	public $timestamps = false;
 	protected $table = 'ss_group_node';
 	protected $primaryKey = 'id';
 
-}
+}

+ 60 - 54
app/Http/Models/SsNode.php

@@ -10,49 +10,51 @@ use Illuminate\Support\Carbon;
 
 /**
  * SS节点信息
- * Class SsNode
  *
- * @package App\Http\Models
- * @mixin Eloquent
  * @property int                           $id
- * @property int                           $type             服务类型:1-SS、2-V2ray
- * @property string                        $name             名称
- * @property int                           $group_id         所属分组
- * @property string                        $country_code     国家代码
- * @property string|null                   $server           服务器域名地址
- * @property string|null                   $ip               服务器IPV4地址
- * @property string|null                   $ipv6             服务器IPV6地址
- * @property string|null                   $desc             节点简单描述
- * @property string                        $method           加密方式
- * @property string                        $protocol         协议
- * @property string|null                   $protocol_param   协议参数
- * @property string                        $obfs             混淆
- * @property string|null                   $obfs_param       混淆参数
- * @property float                         $traffic_rate     流量比率
- * @property int                           $bandwidth        出口带宽,单位M
- * @property int                           $traffic          每月可用流量,单位G
- * @property string|null                   $monitor_url      监控地址
- * @property int|null                      $is_subscribe     是否允许用户订阅该节点:0-否、1-是
- * @property int                           $is_ddns          是否使用DDNS:0-否、1-是
- * @property int                           $is_transit       是否中转节点:0-否、1-是
- * @property int                           $ssh_port         SSH端口
- * @property int                           $detectionType    节点检测: 0-关闭、1-只检测TCP、2-只检测ICMP、3-检测全部
- * @property int                           $compatible       兼容SS
- * @property int                           $single           启用单端口功能:0-否、1-是
- * @property string|null                   $port             单端口的端口号
- * @property string|null                   $passwd           单端口的连接密码
- * @property int                           $sort             排序值,值越大越靠前显示
- * @property int                           $status           状态:0-维护、1-正常
- * @property int                           $v2_alter_id      V2ray额外ID
- * @property int                           $v2_port          V2ray端口
- * @property string                        $v2_method        V2ray加密方式
- * @property string                        $v2_net           V2ray传输协议
- * @property string                        $v2_type          V2ray伪装类型
- * @property string                        $v2_host          V2ray伪装的域名
- * @property string                        $v2_path          V2ray WS/H2路径
- * @property int                           $v2_tls           V2ray底层传输安全 0 未开启 1 开启
- * @property int                           $v2_insider_port  V2ray内部端口(内部监听),v2_port为0时有效
- * @property int                           $v2_outsider_port V2ray外部端口(外部覆盖),v2_port为0时有效
+ * @property int                           $type            服务类型:1-ShadowsocksR、2-V2ray
+ * @property string                        $name            名称
+ * @property int                           $group_id        所属分组
+ * @property string|null                   $country_code    国家代码
+ * @property string|null                   $server          服务器域名地址
+ * @property string|null                   $ip              服务器IPV4地址
+ * @property string|null                   $ipv6            服务器IPV6地址
+ * @property string|null                   $relay_server    中转地址
+ * @property int|null                      $relay_port      中转端口
+ * @property int                           $level           等级:0-无等级,全部可见
+ * @property int                           $speed_limit     节点限速,为0表示不限速,单位Byte
+ * @property int                           $client_limit    设备数限制
+ * @property string|null                   $description     节点简单描述
+ * @property string                        $method          加密方式
+ * @property string                        $protocol        协议
+ * @property string|null                   $protocol_param  协议参数
+ * @property string                        $obfs            混淆
+ * @property string|null                   $obfs_param      混淆参数
+ * @property float                         $traffic_rate    流量比率
+ * @property int                           $is_subscribe    是否允许用户订阅该节点:0-否、1-是
+ * @property int                           $is_ddns         是否使用DDNS:0-否、1-是
+ * @property int                           $is_relay        是否中转节点:0-否、1-是
+ * @property int                           $is_udp          是否启用UDP:0-不启用、1-启用
+ * @property int                           $ssh_port        SSH端口
+ * @property int                           $detectiontype   节点检测: 0-关闭、1-只检测TCP、2-只检测ICMP、3-检测全部
+ * @property int                           $compatible      兼容SS
+ * @property int                           $single          启用单端口功能:0-否、1-是
+ * @property int|null                      $port            单端口的端口号
+ * @property string|null                   $passwd          单端口的连接密码
+ * @property int                           $sort            排序值,值越大越靠前显示
+ * @property int                           $status          状态:0-维护、1-正常
+ * @property int                           $v2_alter_id     V2Ray额外ID
+ * @property int                           $v2_connect_port V2Ray连接端口
+ * @property int                           $v2_port         V2Ray服务端口
+ * @property string                        $v2_method       V2Ray加密方式
+ * @property string                        $v2_net          V2Ray传输协议
+ * @property string                        $v2_type         V2Ray伪装类型
+ * @property string                        $v2_host         V2Ray伪装的域名
+ * @property string                        $v2_path         V2Ray的WS/H2路径
+ * @property int                           $v2_connect_tls  V2Ray连接TLS:0-未开启、1-开启
+ * @property int                           $v2_tls          V2Ray后端TLS:0-未开启、1-开启
+ * @property string|null                   $tls_provider    V2Ray节点的TLS提供商授权信息
+ * @property int                           $trojan_port     Trojan连接端口
  * @property Carbon                        $created_at
  * @property Carbon                        $updated_at
  * @property-read Collection|SsNodeLabel[] $label
@@ -60,21 +62,22 @@ use Illuminate\Support\Carbon;
  * @method static Builder|SsNode newModelQuery()
  * @method static Builder|SsNode newQuery()
  * @method static Builder|SsNode query()
- * @method static Builder|SsNode whereBandwidth($value)
+ * @method static Builder|SsNode whereClientLimit($value)
  * @method static Builder|SsNode whereCompatible($value)
  * @method static Builder|SsNode whereCountryCode($value)
  * @method static Builder|SsNode whereCreatedAt($value)
- * @method static Builder|SsNode whereDesc($value)
- * @method static Builder|SsNode whereDetectionType($value)
+ * @method static Builder|SsNode whereDescription($value)
+ * @method static Builder|SsNode whereDetectiontype($value)
  * @method static Builder|SsNode whereGroupId($value)
  * @method static Builder|SsNode whereId($value)
  * @method static Builder|SsNode whereIp($value)
  * @method static Builder|SsNode whereIpv6($value)
  * @method static Builder|SsNode whereIsDdns($value)
+ * @method static Builder|SsNode whereIsRelay($value)
  * @method static Builder|SsNode whereIsSubscribe($value)
- * @method static Builder|SsNode whereIsTransit($value)
+ * @method static Builder|SsNode whereIsUdp($value)
+ * @method static Builder|SsNode whereLevel($value)
  * @method static Builder|SsNode whereMethod($value)
- * @method static Builder|SsNode whereMonitorUrl($value)
  * @method static Builder|SsNode whereName($value)
  * @method static Builder|SsNode whereObfs($value)
  * @method static Builder|SsNode whereObfsParam($value)
@@ -82,33 +85,36 @@ use Illuminate\Support\Carbon;
  * @method static Builder|SsNode wherePort($value)
  * @method static Builder|SsNode whereProtocol($value)
  * @method static Builder|SsNode whereProtocolParam($value)
+ * @method static Builder|SsNode whereRelayPort($value)
+ * @method static Builder|SsNode whereRelayServer($value)
  * @method static Builder|SsNode whereServer($value)
  * @method static Builder|SsNode whereSingle($value)
  * @method static Builder|SsNode whereSort($value)
+ * @method static Builder|SsNode whereSpeedLimit($value)
  * @method static Builder|SsNode whereSshPort($value)
  * @method static Builder|SsNode whereStatus($value)
- * @method static Builder|SsNode whereTraffic($value)
+ * @method static Builder|SsNode whereTlsProvider($value)
  * @method static Builder|SsNode whereTrafficRate($value)
+ * @method static Builder|SsNode whereTrojanPort($value)
  * @method static Builder|SsNode whereType($value)
  * @method static Builder|SsNode whereUpdatedAt($value)
  * @method static Builder|SsNode whereV2AlterId($value)
+ * @method static Builder|SsNode whereV2ConnectPort($value)
+ * @method static Builder|SsNode whereV2ConnectTls($value)
  * @method static Builder|SsNode whereV2Host($value)
- * @method static Builder|SsNode whereV2InsiderPort($value)
  * @method static Builder|SsNode whereV2Method($value)
  * @method static Builder|SsNode whereV2Net($value)
- * @method static Builder|SsNode whereV2OutsiderPort($value)
  * @method static Builder|SsNode whereV2Path($value)
  * @method static Builder|SsNode whereV2Port($value)
  * @method static Builder|SsNode whereV2Tls($value)
  * @method static Builder|SsNode whereV2Type($value)
+ * @mixin Eloquent
  */
-class SsNode extends Model
-{
+class SsNode extends Model {
 	protected $table = 'ss_node';
 	protected $primaryKey = 'id';
 
-	function label()
-	{
+	function label() {
 		return $this->hasMany(SsNodeLabel::class, 'node_id', 'id');
 	}
-}
+}

+ 4 - 7
app/Http/Models/SsNodeInfo.php

@@ -8,10 +8,7 @@ use Illuminate\Database\Eloquent\Model;
 
 /**
  * SS节点负载情况
- * Class SsNodeInfo
  *
- * @package App\Http\Models
- * @mixin Eloquent
  * @property int    $id
  * @property int    $node_id  节点ID
  * @property int    $uptime   后端存活时长,单位秒
@@ -25,11 +22,11 @@ use Illuminate\Database\Eloquent\Model;
  * @method static Builder|SsNodeInfo whereLogTime($value)
  * @method static Builder|SsNodeInfo whereNodeId($value)
  * @method static Builder|SsNodeInfo whereUptime($value)
+ * @mixin Eloquent
  */
-class SsNodeInfo extends Model
-{
-	public $timestamps = FALSE;
+class SsNodeInfo extends Model {
+	public $timestamps = false;
 	protected $table = 'ss_node_info';
 	protected $primaryKey = 'id';
 
-}
+}

+ 5 - 10
app/Http/Models/SsNodeIp.php

@@ -9,10 +9,7 @@ use Illuminate\Support\Carbon;
 
 /**
  * SS节点在线IP信息
- * Class SsNodeIp
  *
- * @package App\Http\Models
- * @mixin Eloquent
  * @property int         $id
  * @property int         $node_id    节点ID
  * @property int         $user_id    用户ID
@@ -32,19 +29,17 @@ use Illuminate\Support\Carbon;
  * @method static Builder|SsNodeIp wherePort($value)
  * @method static Builder|SsNodeIp whereType($value)
  * @method static Builder|SsNodeIp whereUserId($value)
+ * @mixin Eloquent
  */
-class SsNodeIp extends Model
-{
+class SsNodeIp extends Model {
 	protected $table = 'ss_node_ip';
 	protected $primaryKey = 'id';
 
-	function node()
-	{
+	function node() {
 		return $this->belongsTo(SsNode::class, 'node_id', 'id');
 	}
 
-	function user()
-	{
+	function user() {
 		return $this->belongsTo(User::class, 'port', 'port');
 	}
-}
+}

+ 9 - 13
app/Http/Models/SsNodeLabel.php

@@ -8,29 +8,25 @@ use Illuminate\Database\Eloquent\Model;
 
 /**
  * 节点标签
- * Class SsNodeLabel
  *
- * @package App\Http\Models
- * @mixin Eloquent
- * @property-read Label $labelInfo
- * @property int        $id
- * @property int        $node_id  用户ID
- * @property int        $label_id 标签ID
+ * @property int             $id
+ * @property int             $node_id  用户ID
+ * @property int             $label_id 标签ID
+ * @property-read Label|null $labelInfo
  * @method static Builder|SsNodeLabel newModelQuery()
  * @method static Builder|SsNodeLabel newQuery()
  * @method static Builder|SsNodeLabel query()
  * @method static Builder|SsNodeLabel whereId($value)
  * @method static Builder|SsNodeLabel whereLabelId($value)
  * @method static Builder|SsNodeLabel whereNodeId($value)
+ * @mixin Eloquent
  */
-class SsNodeLabel extends Model
-{
-	public $timestamps = FALSE;
+class SsNodeLabel extends Model {
+	public $timestamps = false;
 	protected $table = 'ss_node_label';
 	protected $primaryKey = 'id';
 
-	function labelInfo()
-	{
+	function labelInfo() {
 		return $this->hasOne(Label::class, 'id', 'label_id');
 	}
-}
+}

+ 4 - 7
app/Http/Models/SsNodeOnlineLog.php

@@ -8,10 +8,7 @@ use Illuminate\Database\Eloquent\Model;
 
 /**
  * SS节点用户在线情况
- * Class SsNodeOnlineLog
  *
- * @package App\Http\Models
- * @mixin Eloquent
  * @property int $id
  * @property int $node_id     节点ID
  * @property int $online_user 在线用户数
@@ -23,11 +20,11 @@ use Illuminate\Database\Eloquent\Model;
  * @method static Builder|SsNodeOnlineLog whereLogTime($value)
  * @method static Builder|SsNodeOnlineLog whereNodeId($value)
  * @method static Builder|SsNodeOnlineLog whereOnlineUser($value)
+ * @mixin Eloquent
  */
-class SsNodeOnlineLog extends Model
-{
-	public $timestamps = FALSE;
+class SsNodeOnlineLog extends Model {
+	public $timestamps = false;
 	protected $table = 'ss_node_online_log';
 	protected $primaryKey = 'id';
 
-}
+}

+ 13 - 17
app/Http/Models/SsNodePing.php

@@ -9,38 +9,34 @@ use Illuminate\Support\Carbon;
 
 /**
  * 节点定时Ping测速
- * App\Http\Models\SsNodePing
  *
- * @mixin Eloquent
- * @property int         $id
- * @property int         $node_id 对应节点id
- * @property int         $ct      电信
- * @property int         $cu      联通
- * @property int         $cm      移动
- * @property int         $hk      香港
- * @property Carbon      $created_at
- * @property Carbon      $updated_at
+ * @property int              $id
+ * @property int              $node_id 对应节点id
+ * @property int              $ct      电信
+ * @property int              $cu      联通
+ * @property int              $cm      移动
+ * @property int              $hk      香港
+ * @property Carbon           $created_at
+ * @property Carbon           $updated_at
+ * @property-read SsNode|null $node
  * @method static Builder|SsNodePing newModelQuery()
  * @method static Builder|SsNodePing newQuery()
  * @method static Builder|SsNodePing query()
  * @method static Builder|SsNodePing whereCm($value)
  * @method static Builder|SsNodePing whereCreatedAt($value)
+ * @method static Builder|SsNodePing whereCt($value)
  * @method static Builder|SsNodePing whereCu($value)
  * @method static Builder|SsNodePing whereHk($value)
  * @method static Builder|SsNodePing whereId($value)
  * @method static Builder|SsNodePing whereNodeId($value)
  * @method static Builder|SsNodePing whereUpdatedAt($value)
- * @method static Builder|SsNodePing whereUt($value)
- * @method static Builder|SsNodePing whereCt($value)
- * @property-read SsNode $node
+ * @mixin Eloquent
  */
-class SsNodePing extends Model
-{
+class SsNodePing extends Model {
 	protected $table = 'ss_node_ping';
 	protected $primaryKey = 'id';
 
-	public function node()
-	{
+	public function node() {
 		return $this->hasOne(SsNode::class, 'id', 'node_id');
 	}
 }

+ 13 - 17
app/Http/Models/SsNodeTrafficDaily.php

@@ -9,19 +9,16 @@ use Illuminate\Support\Carbon;
 
 /**
  * 节点每日流量统计
- * Class SsUserTrafficDaily
  *
- * @package App\Http\Models
- * @mixin Eloquent
- * @property int         $id
- * @property int         $node_id    节点ID
- * @property int         $u          上传流量
- * @property int         $d          下载流量
- * @property int         $total      总流量
- * @property string|null $traffic    总流量(带单位)
- * @property Carbon|null $created_at 创建时间
- * @property Carbon|null $updated_at 最后更新时间
- * @property-read SsNode $info
+ * @property int              $id
+ * @property int              $node_id    节点ID
+ * @property int              $u          上传流量
+ * @property int              $d          下载流量
+ * @property int              $total      总流量
+ * @property string|null      $traffic    总流量(带单位)
+ * @property Carbon|null      $created_at 创建时间
+ * @property Carbon|null      $updated_at 最后更新时间
+ * @property-read SsNode|null $info
  * @method static Builder|SsNodeTrafficDaily newModelQuery()
  * @method static Builder|SsNodeTrafficDaily newQuery()
  * @method static Builder|SsNodeTrafficDaily query()
@@ -33,15 +30,14 @@ use Illuminate\Support\Carbon;
  * @method static Builder|SsNodeTrafficDaily whereTraffic($value)
  * @method static Builder|SsNodeTrafficDaily whereU($value)
  * @method static Builder|SsNodeTrafficDaily whereUpdatedAt($value)
+ * @mixin Eloquent
  */
-class SsNodeTrafficDaily extends Model
-{
+class SsNodeTrafficDaily extends Model {
 	protected $table = 'ss_node_traffic_daily';
 	protected $primaryKey = 'id';
 
-	function info()
-	{
+	function info() {
 		return $this->hasOne(SsNode::class, 'id', 'node_id');
 	}
 
-}
+}

+ 13 - 17
app/Http/Models/SsNodeTrafficHourly.php

@@ -9,19 +9,16 @@ use Illuminate\Support\Carbon;
 
 /**
  * 节点每日流量统计
- * Class SsUserTrafficHourly
  *
- * @package App\Http\Models
- * @mixin Eloquent
- * @property int         $id
- * @property int         $node_id    节点ID
- * @property int         $u          上传流量
- * @property int         $d          下载流量
- * @property int         $total      总流量
- * @property string|null $traffic    总流量(带单位)
- * @property Carbon|null $created_at 创建时间
- * @property Carbon|null $updated_at 最后更新时间
- * @property-read SsNode $info
+ * @property int              $id
+ * @property int              $node_id    节点ID
+ * @property int              $u          上传流量
+ * @property int              $d          下载流量
+ * @property int              $total      总流量
+ * @property string|null      $traffic    总流量(带单位)
+ * @property Carbon|null      $created_at 创建时间
+ * @property Carbon|null      $updated_at 最后更新时间
+ * @property-read SsNode|null $info
  * @method static Builder|SsNodeTrafficHourly newModelQuery()
  * @method static Builder|SsNodeTrafficHourly newQuery()
  * @method static Builder|SsNodeTrafficHourly query()
@@ -33,14 +30,13 @@ use Illuminate\Support\Carbon;
  * @method static Builder|SsNodeTrafficHourly whereTraffic($value)
  * @method static Builder|SsNodeTrafficHourly whereU($value)
  * @method static Builder|SsNodeTrafficHourly whereUpdatedAt($value)
+ * @mixin Eloquent
  */
-class SsNodeTrafficHourly extends Model
-{
+class SsNodeTrafficHourly extends Model {
 	protected $table = 'ss_node_traffic_hourly';
 	protected $primaryKey = 'id';
 
-	function info()
-	{
+	function info() {
 		return $this->hasOne(SsNode::class, 'id', 'node_id');
 	}
-}
+}

+ 15 - 21
app/Http/Models/Ticket.php

@@ -10,19 +10,16 @@ use Illuminate\Support\Carbon;
 
 /**
  * 工单
- * Class Ticket
  *
- * @package App\Http\Models
- * @mixin Eloquent
- * @property int         $id
- * @property int         $user_id
- * @property string      $title      标题
- * @property string      $content    内容
- * @property int         $status     状态:0-待处理、1-已处理未关闭、2-已关闭
- * @property Carbon|null $created_at 创建时间
- * @property Carbon|null $updated_at 最后更新时间
- * @property-read mixed  $status_label
- * @property-read User   $user
+ * @property int            $id
+ * @property int            $user_id    用户ID
+ * @property string         $title      标题
+ * @property string         $content    内容
+ * @property int            $status     状态:0-待处理、1-已处理未关闭、2-已关闭
+ * @property Carbon|null    $created_at 创建时间
+ * @property Carbon|null    $updated_at 最后更新时间
+ * @property-read mixed     $status_label
+ * @property-read User|null $user
  * @method static Builder|Ticket newModelQuery()
  * @method static Builder|Ticket newQuery()
  * @method static Builder|Ticket query()
@@ -34,24 +31,21 @@ use Illuminate\Support\Carbon;
  * @method static Builder|Ticket whereTitle($value)
  * @method static Builder|Ticket whereUpdatedAt($value)
  * @method static Builder|Ticket whereUserId($value)
+ * @mixin Eloquent
  */
-class Ticket extends Model
-{
+class Ticket extends Model {
 	protected $table = 'ticket';
 	protected $primaryKey = 'id';
 
-	function scopeUid($query)
-	{
+	function scopeUid($query) {
 		return $query->whereUserId(Auth::user()->id);
 	}
 
-	function user()
-	{
+	function user() {
 		return $this->hasOne(User::class, 'id', 'user_id');
 	}
 
-	function getStatusLabelAttribute()
-	{
+	function getStatusLabelAttribute() {
 		switch($this->attributes['status']){
 			case 0:
 				$status_label = '<span class="badge badge-lg badge-success">'.trans('home.ticket_table_status_wait').'</span>';
@@ -69,4 +63,4 @@ class Ticket extends Model
 		return $status_label;
 	}
 
-}
+}

+ 11 - 15
app/Http/Models/TicketReply.php

@@ -9,17 +9,14 @@ use Illuminate\Support\Carbon;
 
 /**
  * 工单回复
- * Class TicketReply
  *
- * @package App\Http\Models
- * @mixin Eloquent
- * @property int         $id
- * @property int         $ticket_id  工单ID
- * @property int         $user_id    回复人ID
- * @property string      $content    回复内容
- * @property Carbon|null $created_at 创建时间
- * @property Carbon|null $updated_at 最后更新时间
- * @property-read User   $user
+ * @property int            $id
+ * @property int            $ticket_id  工单ID
+ * @property int            $user_id    回复用户的ID
+ * @property string         $content    回复内容
+ * @property Carbon|null    $created_at 创建时间
+ * @property Carbon|null    $updated_at 最后更新时间
+ * @property-read User|null $user
  * @method static Builder|TicketReply newModelQuery()
  * @method static Builder|TicketReply newQuery()
  * @method static Builder|TicketReply query()
@@ -29,14 +26,13 @@ use Illuminate\Support\Carbon;
  * @method static Builder|TicketReply whereTicketId($value)
  * @method static Builder|TicketReply whereUpdatedAt($value)
  * @method static Builder|TicketReply whereUserId($value)
+ * @mixin Eloquent
  */
-class TicketReply extends Model
-{
+class TicketReply extends Model {
 	protected $table = 'ticket_reply';
 	protected $primaryKey = 'id';
 
-	function user()
-	{
+	function user() {
 		return $this->hasOne(User::class, 'id', 'user_id');
 	}
-}
+}

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно