Browse Source

简化代码,修复支付逻辑错误

兔姬桑 4 years ago
parent
commit
95eea7fb48
64 changed files with 692 additions and 608 deletions
  1. 28 1
      app/Components/Helpers.php
  2. 30 30
      app/Console/Commands/AutoJob.php
  3. 1 1
      app/Console/Commands/AutoPingNode.php
  4. 2 2
      app/Console/Commands/AutoReportNode.php
  5. 2 2
      app/Console/Commands/AutoStatisticsNodeDailyTraffic.php
  6. 2 2
      app/Console/Commands/AutoStatisticsNodeHourlyTraffic.php
  7. 4 4
      app/Console/Commands/AutoStatisticsUserDailyTraffic.php
  8. 4 4
      app/Console/Commands/AutoStatisticsUserHourlyTraffic.php
  9. 16 16
      app/Console/Commands/DailyJob.php
  10. 2 2
      app/Console/Commands/NodeBlockedDetection.php
  11. 9 9
      app/Console/Commands/ServiceTimer.php
  12. 1 1
      app/Console/Commands/UserExpireAutoWarning.php
  13. 3 3
      app/Console/Commands/UserTrafficAbnormalAutoWarning.php
  14. 1 1
      app/Console/Commands/UserTrafficAutoWarning.php
  15. 1 1
      app/Console/Commands/upgradeUserResetTime.php
  16. 63 63
      app/Http/Controllers/AdminController.php
  17. 3 3
      app/Http/Controllers/Api/LoginController.php
  18. 20 20
      app/Http/Controllers/AuthController.php
  19. 1 27
      app/Http/Controllers/Controller.php
  20. 6 6
      app/Http/Controllers/CouponController.php
  21. 26 19
      app/Http/Controllers/Gateway/AbstractPayment.php
  22. 2 2
      app/Http/Controllers/Gateway/AopF2F.php
  23. 48 0
      app/Http/Controllers/Gateway/Local.php
  24. 4 4
      app/Http/Controllers/MarketingController.php
  25. 24 34
      app/Http/Controllers/PaymentController.php
  26. 1 1
      app/Http/Controllers/SensitiveWordsController.php
  27. 8 8
      app/Http/Controllers/ServiceController.php
  28. 6 6
      app/Http/Controllers/ShopController.php
  29. 12 12
      app/Http/Controllers/SubscribeController.php
  30. 4 4
      app/Http/Controllers/TicketController.php
  31. 36 36
      app/Http/Controllers/UserController.php
  32. 1 1
      app/Http/Models/Article.php
  33. 1 1
      app/Http/Models/Coupon.php
  34. 1 1
      app/Http/Models/Goods.php
  35. 1 1
      app/Http/Models/Invite.php
  36. 55 1
      app/Http/Models/Order.php
  37. 1 17
      app/Http/Models/Payment.php
  38. 1 1
      app/Http/Models/ReferralApply.php
  39. 1 1
      app/Http/Models/ReferralLog.php
  40. 2 2
      app/Http/Models/SsConfig.php
  41. 1 1
      app/Http/Models/Ticket.php
  42. 1 1
      app/Http/Models/User.php
  43. 1 1
      app/Http/Models/UserLabel.php
  44. 1 1
      app/Http/Models/UserSubscribe.php
  45. 1 1
      app/Http/Models/Verify.php
  46. 1 1
      app/Mail/activeUser.php
  47. 1 1
      app/Mail/closeTicket.php
  48. 1 1
      app/Mail/newTicket.php
  49. 2 2
      app/Mail/nodeCrashWarning.php
  50. 1 1
      app/Mail/replyTicket.php
  51. 1 1
      app/Mail/resetPassword.php
  52. 1 1
      app/Mail/sendUserInfo.php
  53. 1 1
      app/Mail/sendVerifyCode.php
  54. 1 1
      app/Mail/userExpireWarning.php
  55. 1 1
      app/Mail/userExpireWarningToday.php
  56. 1 1
      app/Mail/userTrafficWarning.php
  57. 197 197
      config/debugbar.php
  58. 4 4
      resources/views/admin/layouts.blade.php
  59. 7 15
      resources/views/admin/orderList.blade.php
  60. 9 11
      resources/views/user/buy.blade.php
  61. 12 8
      resources/views/user/invoiceDetail.blade.php
  62. 1 1
      resources/views/user/layouts.blade.php
  63. 3 3
      routes/web.php
  64. 8 2
      sql/mod/20200422.sql

+ 28 - 1
app/Components/Helpers.php

@@ -8,6 +8,7 @@ use App\Http\Models\Level;
 use App\Http\Models\NotificationLog;
 use App\Http\Models\SsConfig;
 use App\Http\Models\User;
+use App\Http\Models\UserBalanceLog;
 use App\Http\Models\UserSubscribe;
 use App\Http\Models\UserTrafficModifyLog;
 
@@ -50,7 +51,7 @@ class Helpers
 	public static function makeSubscribeCode()
 	{
 		$code = makeRandStr(5);
-		if(UserSubscribe::query()->where('code', $code)->exists()){
+		if(UserSubscribe::query()->whereCode($code)->exists()){
 			$code = self::makeSubscribeCode();
 		}
 
@@ -209,6 +210,32 @@ class Helpers
 		return $log->save();
 	}
 
+	/**
+	 * 记录余额操作日志
+	 *
+	 * @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 = '')
+	{
+		$log = new UserBalanceLog();
+		$log->user_id = $userId;
+		$log->order_id = $oid;
+		$log->before = $before;
+		$log->after = $after;
+		$log->amount = $amount;
+		$log->desc = $desc;
+		$log->created_at = date('Y-m-d H:i:s');
+
+		return $log->save();
+	}
+
 	/**
 	 * 记录流量变动日志
 	 *

+ 30 - 30
app/Console/Commands/AutoJob.php

@@ -69,8 +69,8 @@ class AutoJob extends Command
 		// 检查 维护模式
 		if(self::$systemConfig['maintenance_mode']){
 			if(strtotime(self::$systemConfig['maintenance_time']) < time()){
-				Config::query()->where('name', 'maintenance_mode')->update(['value' => 0]);
-				Config::query()->where('name', 'maintenance_time')->update(['value' => '']);
+				Config::query()->whereName('maintenance_mode')->update(['value' => 0]);
+				Config::query()->whereName('maintenance_time')->update(['value' => '']);
 			}
 		}
 
@@ -84,20 +84,20 @@ class AutoJob extends Command
 	private function closePayments()
 	{
 		// 关闭超时未支付的在线支付订单(在线支付收款二维码超过30分钟自动关闭,关闭后无法再支付,所以我们限制15分钟内必须付款)
-		$paymentList = Payment::query()->where('status', 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{
 				foreach($paymentList as $payment){
 					// 关闭支付单
-					Payment::query()->where('id', $payment->id)->update(['status' => -1]);
+					Payment::query()->whereId($payment->id)->update(['status' => -1]);
 
 					// 关闭订单
-					Order::query()->where('oid', $payment->oid)->update(['status' => -1]);
+					Order::query()->whereOid($payment->oid)->update(['status' => -1]);
 
 					// 退回优惠券
 					if($payment->order->coupon_id){
-						Coupon::query()->where('id', $payment->order->coupon_id)->update(['status' => 0]);
+						Coupon::query()->whereId($payment->order->coupon_id)->update(['status' => 0]);
 
 						Helpers::addCouponLog($payment->order->coupon_id, $payment->order->goods_id, $payment->oid, '在线订单超时未支付,自动退回');
 					}
@@ -116,7 +116,7 @@ class AutoJob extends Command
 	private function closeOrders()
 	{
 		// 关闭超时未支付的在线支付订单(在线支付收款二维码超过30分钟自动关闭,关闭后无法再支付,所以我们限制15分钟内必须付款)
-		$orderList = Order::query()->where('status', 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{
@@ -126,7 +126,7 @@ class AutoJob extends Command
 
 					// 退回优惠券
 					if($order->coupon_id){
-						Coupon::query()->where('id', $order->coupon_id)->update(['status' => 0]);
+						Coupon::query()->whereId($order->coupon_id)->update(['status' => 0]);
 
 						Helpers::addCouponLog($order->coupon_id, $order->goods_id, $order->oid, '订单超时未支付,自动退回');
 					}
@@ -145,27 +145,27 @@ class AutoJob extends Command
 	private function expireCode()
 	{
 		// 注册验证码自动置无效
-		VerifyCode::query()->where('status', 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()->where('status', 0)->where('available_end', '<=', time())->update(['status' => 2]);
+		Coupon::query()->whereStatus(0)->where('available_end', '<=', time())->update(['status' => 2]);
 
 		// 邀请码到期自动置无效
-		Invite::query()->where('status', 0)->where('dateline', '<=', date('Y-m-d H:i:s'))->update(['status' => 2]);
+		Invite::query()->whereStatus(0)->where('dateline', '<=', date('Y-m-d H:i:s'))->update(['status' => 2]);
 	}
 
 	// 封禁访问异常的订阅链接
 	private function blockSubscribe()
 	{
 		if(self::$systemConfig['is_subscribe_ban']){
-			$userList = User::query()->where('status', '>=', 0)->where('enable', 1)->get();
+			$userList = User::query()->where('status', '>=', 0)->whereEnable(1)->get();
 			foreach($userList as $user){
-				$subscribe = UserSubscribe::query()->where('user_id', $user->id)->first();
+				$subscribe = UserSubscribe::query()->whereUserId($user->id)->first();
 				if($subscribe){
 					// 24小时内不同IP的请求次数
-					$request_times = UserSubscribeLog::query()->where('sid', $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()->where('id', $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小时内请求异常');
@@ -196,7 +196,7 @@ class AutoJob extends Command
 	{
 		// 封禁1小时内流量异常账号
 		if(self::$systemConfig['is_traffic_ban']){
-			$userList = User::query()->where('enable', 1)->where('status', '>=', 0)->where('ban_time', 0)->get();
+			$userList = User::query()->whereEnable(1)->where('status', '>=', 0)->whereBanTime(0)->get();
 			foreach($userList as $user){
 				// 对管理员豁免
 				if($user->is_admin){
@@ -204,9 +204,9 @@ class AutoJob extends Command
 				}
 
 				// 多往前取5分钟,防止数据统计任务执行时间过长导致没有数据
-				$totalTraffic = UserTrafficHourly::query()->where('user_id', $user->id)->where('node_id', 0)->where('created_at', '>=', date('Y-m-d H:i:s', time()-3900))->sum('total');
+				$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()->where('id', $user->id)->update(['enable' => 0, 'ban_time' => strtotime(date('Y-m-d H:i:s', strtotime("+".self::$systemConfig['traffic_ban_time']." minutes")))]);
+					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,9 +215,9 @@ class AutoJob extends Command
 		}
 
 		// 禁用流量超限用户
-		$userList = User::query()->where('enable', 1)->where('status', '>=', 0)->where('ban_time', 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()->where('id', $user->id)->update(['enable' => 0]);
+			User::query()->whereId($user->id)->update(['enable' => 0]);
 
 			// 写入日志
 			$this->addUserBanLog($user->id, 0, '【封禁代理】-流量已用完');
@@ -228,10 +228,10 @@ class AutoJob extends Command
 	private function unblockUsers()
 	{
 		// 解封被临时封禁的账号
-		$userList = User::query()->where('enable', 0)->where('status', '>=', 0)->where('ban_time', '>', 0)->get();
+		$userList = User::query()->whereEnable(0)->where('status', '>=', 0)->where('ban_time', '>', 0)->get();
 		foreach($userList as $user){
 			if($user->ban_time < time()){
-				User::query()->where('id', $user->id)->update(['enable' => 1, 'ban_time' => 0]);
+				User::query()->whereId($user->id)->update(['enable' => 1, 'ban_time' => 0]);
 
 				// 写入操作日志
 				$this->addUserBanLog($user->id, 0, '【自动解封】-临时封禁到期');
@@ -239,9 +239,9 @@ class AutoJob extends Command
 		}
 
 		// 可用流量大于已用流量也解封(比如:邀请返利自动加了流量)
-		$userList = User::query()->where('enable', 0)->where('status', '>=', 0)->where('ban_time', 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()->where('id', $user->id)->update(['enable' => 1]);
+			User::query()->whereId($user->id)->update(['enable' => 1]);
 
 			// 写入操作日志
 			$this->addUserBanLog($user->id, 0, '【自动解封】-有流量解封');
@@ -253,18 +253,18 @@ class AutoJob extends Command
 	{
 		if(self::$systemConfig['auto_release_port']){
 			## 自动分配端口
-			$userList = User::query()->where('enable', 1)->where('status', '>=', 0)->where('port', 0)->get();
+			$userList = User::query()->whereEnable(1)->where('status', '>=', 0)->wherePort(0)->get();
 			foreach($userList as $user){
 				$port = self::$systemConfig['is_rand_port']? Helpers::getRandPort() : Helpers::getOnlyPort();
 
-				User::query()->where('id', $user->id)->update(['port' => $port]);
+				User::query()->whereId($user->id)->update(['port' => $port]);
 			}
 
 			## 被封禁的账号自动释放端口
-			User::query()->where('enable', 0)->where('status', -1)->where('port', '!=', 0)->update(['port' => 0]);
+			User::query()->whereEnable(0)->whereStatus(-1)->where('port', '!=', 0)->update(['port' => 0]);
 
 			## 过期一个月的账户自动释放端口
-			User::query()->where('enable', 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]);
 		}
 	}
 
@@ -272,10 +272,10 @@ class AutoJob extends Command
 	private function checkNodeStatus()
 	{
 		if(self::$systemConfig['is_node_offline']){
-			$nodeList = SsNode::query()->where('is_transit', 0)->where('status', 1)->get();
+			$nodeList = SsNode::query()->whereIsTransit(0)->whereStatus(1)->get();
 			foreach($nodeList as $node){
 				// 10分钟内无节点负载信息则认为是后端炸了
-				$nodeTTL = SsNodeInfo::query()->where('node_id', $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']){
 						// 已通知次数

+ 1 - 1
app/Console/Commands/AutoPingNode.php

@@ -22,7 +22,7 @@ class AutoPingNode extends Command
 	{
 		$jobStartTime = microtime(TRUE);
 
-		$nodeList = SsNode::query()->where('is_transit', 0)->where('status', 1)->get();
+		$nodeList = SsNode::query()->whereIsTransit(0)->whereStatus(1)->get();
 		foreach($nodeList as $node){
 			$this->pingNode($node->id, $node->is_ddns? $node->server : $node->ip);
 		}

+ 2 - 2
app/Console/Commands/AutoReportNode.php

@@ -24,12 +24,12 @@ class AutoReportNode extends Command
 		$jobStartTime = microtime(TRUE);
 
 		if(Helpers::systemConfig()['node_daily_report']){
-			$nodeList = SsNode::query()->where('status', 1)->get();
+			$nodeList = SsNode::query()->whereStatus(1)->get();
 			if(!$nodeList->isEmpty()){
 				$msg = "|节点|上行流量|下行流量|合计|\r\n| :------ | :------ | :------ |\r\n";
 				foreach($nodeList as $node){
 					$log = SsNodeTrafficDaily::query()
-						->where('node_id', $node->id)
+						->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();

+ 2 - 2
app/Console/Commands/AutoStatisticsNodeDailyTraffic.php

@@ -22,7 +22,7 @@ class AutoStatisticsNodeDailyTraffic extends Command
 	{
 		$jobStartTime = microtime(TRUE);
 
-		$nodeList = SsNode::query()->where('status', 1)->orderBy('id', 'asc')->get();
+		$nodeList = SsNode::query()->whereStatus(1)->orderBy('id', 'asc')->get();
 		foreach($nodeList as $node){
 			$this->statisticsByNode($node->id);
 		}
@@ -38,7 +38,7 @@ class AutoStatisticsNodeDailyTraffic extends Command
 		$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")));
 
-		$query = UserTrafficLog::query()->where('node_id', $node_id)->whereBetween('log_time', [$start_time, $end_time]);
+		$query = UserTrafficLog::query()->whereNodeId($node_id)->whereBetween('log_time', [$start_time, $end_time]);
 
 		$u = $query->sum('u');
 		$d = $query->sum('d');

+ 2 - 2
app/Console/Commands/AutoStatisticsNodeHourlyTraffic.php

@@ -22,7 +22,7 @@ class AutoStatisticsNodeHourlyTraffic extends Command
 	{
 		$jobStartTime = microtime(TRUE);
 
-		$nodeList = SsNode::query()->where('status', 1)->orderBy('id', 'asc')->get();
+		$nodeList = SsNode::query()->whereStatus(1)->orderBy('id', 'asc')->get();
 		foreach($nodeList as $node){
 			$this->statisticsByNode($node->id);
 		}
@@ -38,7 +38,7 @@ class AutoStatisticsNodeHourlyTraffic extends Command
 		$start_time = strtotime(date('Y-m-d H:i:s', strtotime("-1 hour")));
 		$end_time = time();
 
-		$query = UserTrafficLog::query()->where('node_id', $node_id)->whereBetween('log_time', [$start_time, $end_time]);
+		$query = UserTrafficLog::query()->whereNodeId($node_id)->whereBetween('log_time', [$start_time, $end_time]);
 
 		$u = $query->sum('u');
 		$d = $query->sum('d');

+ 4 - 4
app/Console/Commands/AutoStatisticsUserDailyTraffic.php

@@ -23,13 +23,13 @@ class AutoStatisticsUserDailyTraffic extends Command
 	{
 		$jobStartTime = microtime(TRUE);
 
-		$userList = User::query()->where('status', '>=', 0)->where('enable', 1)->get();
+		$userList = User::query()->where('status', '>=', 0)->whereEnable(1)->get();
 		foreach($userList as $user){
 			// 统计一次所有节点的总和
 			$this->statisticsByNode($user->id);
 
 			// 统计每个节点产生的流量
-			$nodeList = SsNode::query()->where('status', 1)->orderBy('id', 'asc')->get();
+			$nodeList = SsNode::query()->whereStatus(1)->orderBy('id', 'asc')->get();
 			foreach($nodeList as $node){
 				$this->statisticsByNode($user->id, $node->id);
 			}
@@ -46,10 +46,10 @@ class AutoStatisticsUserDailyTraffic extends Command
 		$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")));
 
-		$query = UserTrafficLog::query()->where('user_id', $user_id)->whereBetween('log_time', [$start_time, $end_time]);
+		$query = UserTrafficLog::query()->whereUserId($user_id)->whereBetween('log_time', [$start_time, $end_time]);
 
 		if($node_id){
-			$query->where('node_id', $node_id);
+			$query->whereNodeId($node_id);
 		}
 
 		$u = $query->sum('u');

+ 4 - 4
app/Console/Commands/AutoStatisticsUserHourlyTraffic.php

@@ -23,13 +23,13 @@ class AutoStatisticsUserHourlyTraffic extends Command
 	{
 		$jobStartTime = microtime(TRUE);
 
-		$userList = User::query()->where('status', '>=', 0)->where('enable', 1)->get();
+		$userList = User::query()->where('status', '>=', 0)->whereEnable(1)->get();
 		foreach($userList as $user){
 			// 统计一次所有节点的总和
 			$this->statisticsByNode($user->id);
 
 			// 统计每个节点产生的流量
-			$nodeList = SsNode::query()->where('status', 1)->orderBy('id', 'asc')->get();
+			$nodeList = SsNode::query()->whereStatus(1)->orderBy('id', 'asc')->get();
 			foreach($nodeList as $node){
 				$this->statisticsByNode($user->id, $node->id);
 			}
@@ -46,10 +46,10 @@ class AutoStatisticsUserHourlyTraffic extends Command
 		$start_time = strtotime(date('Y-m-d H:i:s', strtotime("-1 hour")));
 		$end_time = time();
 
-		$query = UserTrafficLog::query()->where('user_id', $user_id)->whereBetween('log_time', [$start_time, $end_time]);
+		$query = UserTrafficLog::query()->whereUserId($user_id)->whereBetween('log_time', [$start_time, $end_time]);
 
 		if($node_id){
-			$query->where('node_id', $node_id);
+			$query->whereNodeId($node_id);
 		}
 
 		$u = $query->sum('u');

+ 16 - 16
app/Console/Commands/DailyJob.php

@@ -49,10 +49,10 @@ class DailyJob extends Command
 	private function expireUser()
 	{
 		// 过期用户处理
-		$userList = User::query()->where('status', '>=', 0)->where('enable', 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()->where('id', $user->id)->update([
+				User::query()->whereId($user->id)->update([
 					'u'               => 0,
 					'd'               => 0,
 					'transfer_enable' => 0,
@@ -65,12 +65,12 @@ class DailyJob extends Command
 				$this->addUserBanLog($user->id, 0, '【禁止登录,清空账户】-账号已过期');
 
 				// 废除其名下邀请码
-				Invite::query()->where('uid', $user->id)->where('status', 0)->update(['status' => 2]);
+				Invite::query()->whereUid($user->id)->whereStatus(0)->update(['status' => 2]);
 
 				// 写入用户流量变动记录
 				Helpers::addUserTrafficModifyLog($user->id, 0, $user->transfer_enable, 0, '[定时任务]账号已过期(禁止登录,清空账户)');
 			}else{
-				User::query()->where('id', $user->id)->update([
+				User::query()->whereId($user->id)->update([
 					'u'               => 0,
 					'd'               => 0,
 					'transfer_enable' => 0,
@@ -86,7 +86,7 @@ class DailyJob extends Command
 			}
 
 			// 移除标签
-			UserLabel::query()->where('user_id', $user->id)->delete();
+			UserLabel::query()->whereUserId($user->id)->delete();
 		}
 	}
 
@@ -109,9 +109,9 @@ class DailyJob extends Command
 	// 关闭超过72小时未处理的工单
 	private function closeTickets()
 	{
-		$ticketList = Ticket::query()->where('updated_at', '<=', date('Y-m-d', strtotime("-3 days")))->where('status', 1)->get();
+		$ticketList = Ticket::query()->where('updated_at', '<=', date('Y-m-d', strtotime("-3 days")))->whereStatus(1)->get();
 		foreach($ticketList as $ticket){
-			$ret = Ticket::query()->where('id', $ticket->id)->update(['status' => 2]);
+			$ret = Ticket::query()->whereId($ticket->id)->update(['status' => 2]);
 			if($ret){
 				PushNotification::send('工单关闭提醒', '工单:ID'.$ticket->id.'超过72小时未处理,系统已自动关闭');
 			}
@@ -131,11 +131,11 @@ class DailyJob extends Command
 			// 取出用户正在使用的套餐
 			$order = Order::query()
 				->with(['goods'])
-				->where('user_id', $user->id)
-				->where('status', 2)
-				->where('is_expire', 0)
+				->whereUserId($user->id)
+				->whereStatus(2)
+				->whereIsExpire(0)
 				->whereHas('goods', function($q){
-					$q->where('type', 2);
+					$q->whereType(2);
 				})
 				->first();
 
@@ -147,11 +147,11 @@ class DailyJob extends Command
 			// 过期生效中的加油包
 			Order::query()
 				->with(['goods'])
-				->where('user_id', $user->id)
-				->where('status', 2)
-				->where('is_expire', 0)
+				->whereUserID($user->id)
+				->whereStatus(2)
+				->whereIsExpire(0)
 				->whereHas('goods', function($q){
-					$q->where('type', 1);
+					$q->whereType(1);
 				})->update(['is_expire' => 1]);
 
 			//账号下一个重置时间
@@ -164,7 +164,7 @@ class DailyJob extends Command
 				Helpers::addUserTrafficModifyLog($order->user_id, $order->oid, $user->transfer_enable, $order->goods->traffic*1048576, '【流量重置】重置可用流量');
 			}
 			// 重置流量
-			User::query()->where('id', $user->id)->update(['u' => 0, 'd' => 0, 'transfer_enable' => $order->goods->traffic*1048576, 'reset_time' => $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? : '【无】'));
 		}
 	}

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

@@ -46,7 +46,7 @@ class NodeBlockedDetection extends Command
 	// 监测节点状态
 	private function checkNodes()
 	{
-		$nodeList = SsNode::query()->where('is_transit', 0)->where('status', 1)->where('detectionType', '>', 0)->get();
+		$nodeList = SsNode::query()->whereIsTransit(0)->whereStatus(1)->where('detectionType', '>', 0)->get();
 		$sendText = FALSE;
 		$message = "| 线路 | 协议 | 状态 |\r\n| ------ | ------ | ------ |\r\n";
 		$additionalMessage = '';
@@ -99,7 +99,7 @@ class NodeBlockedDetection extends Command
 						Cache::increment($cacheKey);
 					}else{
 						Cache::forget($cacheKey);
-						SsNode::query()->where('id', $node->id)->update(['status' => 0]);
+						SsNode::query()->whereId($node->id)->update(['status' => 0]);
 						$additionalMessage .= "\r\n节点【{$node->name}】自动进入维护状态\r\n";
 					}
 				}

+ 9 - 9
app/Console/Commands/ServiceTimer.php

@@ -39,22 +39,22 @@ class ServiceTimer extends Command
 	private function decGoodsTraffic()
 	{
 		//获取失效的套餐
-		$orderList = Order::query()->with(['goods'])->where('status', 2)->where('is_expire', 0)->whereHas('goods', function($q){ $q->where('type', 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();
 				foreach($orderList as $order){
 					// 过期本订单
-					Order::query()->where('oid', $order->oid)->update(['is_expire' => 1]);
+					Order::query()->whereOid($order->oid)->update(['is_expire' => 1]);
 
 					// 过期生效中的加油包
 					Order::query()
 						->with(['goods'])
-						->where('user_id', $order->user_id)
-						->where('status', 2)
-						->where('is_expire', 0)
+						->whereUserId($order->user_id)
+						->whereStatus(2)
+						->whereIsExpire(0)
 						->whereHas('goods', function($q){
-							$q->where('type', 1);
+							$q->whereType(1);
 						})->update(['is_expire' => 1]);
 
 					if(empty($order->user) || empty($order->goods)){
@@ -63,13 +63,13 @@ class ServiceTimer extends Command
 
 					// 清理全部流量
 					Helpers::addUserTrafficModifyLog($order->user_id, $order->oid, $order->user->transfer_enable, 0, '[定时任务]用户所购商品到期,扣减商品对应的流量');
-					User::query()->where('id', $order->user_id)->update(['u' => 0, 'd' => 0, 'transfer_enable' => 0, 'reset_time' => NULL]);
+					User::query()->whereId($order->user_id)->update(['u' => 0, 'd' => 0, 'transfer_enable' => 0, 'reset_time' => NULL]);
 
 					// 删除对应用户的所有标签
-					UserLabel::query()->where('user_id', $order->user_id)->delete();
+					UserLabel::query()->whereUserId($order->user_id)->delete();
 
 					// 检查该订单对应用户是否有预支付套餐
-					$prepaidOrder = Order::query()->where('user_id', $order->user_id)->where('status', 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);

+ 1 - 1
app/Console/Commands/UserExpireAutoWarning.php

@@ -40,7 +40,7 @@ class UserExpireAutoWarning extends Command
 	private function userExpireWarning()
 	{
 		// 只取SSR没被禁用的用户,其他不用管
-		$userList = User::query()->where('enable', 1)->get();
+		$userList = User::query()->whereEnable(1)->get();
 		foreach($userList as $user){
 			// 用户名不是邮箱的跳过
 			if(FALSE === filter_var($user->email, FILTER_VALIDATE_EMAIL)){

+ 3 - 3
app/Console/Commands/UserTrafficAbnormalAutoWarning.php

@@ -38,16 +38,16 @@ class UserTrafficAbnormalAutoWarning extends Command
 	private function userTrafficAbnormalWarning()
 	{
 		// 1小时内流量异常用户(多往前取5分钟,防止数据统计任务执行时间过长导致没有数据)
-		$userTotalTrafficList = UserTrafficHourly::query()->where('node_id', 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 = "流量异常用户提醒";
 
 			foreach($userTotalTrafficList as $vo){
-				$user = User::query()->where('id', $vo->user_id)->first();
+				$user = User::query()->whereId($vo->user_id)->first();
 
 				// 推送通知管理员
 				if($vo->totalTraffic > (self::$systemConfig['traffic_ban_value']*1073741824)){
-					$traffic = UserTrafficHourly::query()->where('node_id', 0)->where('user_id', $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();
+					$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)."**。";
 

+ 1 - 1
app/Console/Commands/UserTrafficAutoWarning.php

@@ -39,7 +39,7 @@ class UserTrafficAutoWarning extends Command
 	// 用户流量超过警告阈值自动发邮件提醒
 	private function userTrafficWarning()
 	{
-		$userList = User::query()->where('status', '>=', 0)->where('enable', 1)->where('transfer_enable', '>', 0)->get();
+		$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)){

+ 1 - 1
app/Console/Commands/upgradeUserResetTime.php

@@ -53,7 +53,7 @@ class upgradeUserResetTime extends Command
 				if($reset_time > $user->expire_time){
 					$reset_time = NULL;
 				}
-				User::query()->where('id', $user->id)->update(['reset_time' => $reset_time]);
+				User::query()->whereId($user->id)->update(['reset_time' => $reset_time]);
 			}
 
 			Log::info('---用户[ID:'.$user->id.' - '.$user->username.' ('.$user->email.')]的新重置日期为'.($reset_time != NULL? '【'.$reset_time.'】' : '【无】').'---');

+ 63 - 63
app/Http/Controllers/AdminController.php

@@ -73,16 +73,16 @@ class AdminController extends Controller
 
 		$view['expireDays'] = self::$systemConfig['expire_days'];
 		$view['totalUserCount'] = User::query()->count(); // 总用户数
-		$view['enableUserCount'] = User::query()->where('enable', 1)->count(); // 有效用户数
+		$view['enableUserCount'] = User::query()->whereEnable(1)->count(); // 有效用户数
 		$view['activeUserCount'] = User::query()->where('t', '>=', $past)->count(); // 活跃用户数
-		$view['unActiveUserCount'] = User::query()->where('t', '<=', $past)->where('enable', 1)->where('t', '>', 0)->count(); // 不活跃用户数
+		$view['unActiveUserCount'] = User::query()->where('t', '<=', $past)->whereEnable(1)->where('t', '>', 0)->count(); // 不活跃用户数
 		$view['onlineUserCount'] = User::query()->where('t', '>=', time()-600)->count(); // 10分钟内在线用户数
 		$view['expireWarningUserCount'] = User::query()->where('expire_time', '>=', date('Y-m-d', strtotime("now")))->where('expire_time', '<=', date('Y-m-d', strtotime("+".self::$systemConfig['expire_days']." days")))->count(); // 临近过期用户数
 		$view['largeTrafficUserCount'] = User::query()->whereRaw('(u + d) >= 107374182400')->whereIn('status', [0, 1])->count(); // 流量超过100G的用户
 
 		// 1小时内流量异常用户
 		$tempUsers = [];
-		$userTotalTrafficList = UserTrafficHourly::query()->where('node_id', 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()){
 			foreach($userTotalTrafficList as $vo){
 				if($vo->totalTraffic > (self::$systemConfig['traffic_ban_value']*1073741824)){
@@ -92,18 +92,18 @@ class AdminController extends Controller
 		}
 		$view['flowAbnormalUserCount'] = User::query()->whereIn('id', $tempUsers)->count();
 		$view['nodeCount'] = SsNode::query()->count();
-		$view['unnormalNodeCount'] = SsNode::query()->where('status', 0)->count();
+		$view['unnormalNodeCount'] = SsNode::query()->whereStatus(0)->count();
 		$flowCount = SsNodeTrafficDaily::query()->where('created_at', '>=', date('Y-m-d 00:00:00', strtotime("-30 days")))->sum('total');
 		$view['flowCount'] = flowAutoShow($flowCount);
 		$totalFlowCount = SsNodeTrafficDaily::query()->sum('total');
 		$view['totalFlowCount'] = flowAutoShow($totalFlowCount);
 		$view['totalBalance'] = User::query()->sum('balance')/100;
 		$view['totalWaitRefAmount'] = ReferralLog::query()->whereIn('status', [0, 1])->sum('ref_amount')/100;
-		$view['totalRefAmount'] = ReferralApply::query()->where('status', 2)->sum('amount')/100;
+		$view['totalRefAmount'] = ReferralApply::query()->whereStatus(2)->sum('amount')/100;
 		$view['totalOrder'] = Order::query()->count();
-		$view['totalOnlinePayOrder'] = Order::query()->where('pay_way', 2)->count();
-		$view['totalSuccessOrder'] = Order::query()->where('status', 2)->count();
-		$view['todaySuccessOrder'] = Order::query()->where('status', 2)->where('created_at', '>=', date('Y-m-d 00:00:00'))->where('created_at', '<=', date('Y-m-d 23:59:59'))->count();
+		$view['totalOnlinePayOrder'] = Order::query()->wherePayWay(2)->count();
+		$view['totalSuccessOrder'] = Order::query()->whereStatus(2)->count();
+		$view['todaySuccessOrder'] = Order::query()->whereStatus(2)->where('created_at', '>=', date('Y-m-d 00:00:00'))->where('created_at', '<=', date('Y-m-d 23:59:59'))->count();
 
 		return Response::view('admin.index', $view);
 	}
@@ -127,7 +127,7 @@ class AdminController extends Controller
 
 		$query = User::query()->with(['subscribe']);
 		if(isset($id)){
-			$query->where('id', $id);
+			$query->whereId($id);
 		}
 
 		if(isset($email)){
@@ -143,19 +143,19 @@ class AdminController extends Controller
 		}
 
 		if(isset($port)){
-			$query->where('port', $port);
+			$query->wherePort($port);
 		}
 
 		if(isset($pay_way)){
-			$query->where('pay_way', $pay_way);
+			$query->wherePayWay($pay_way);
 		}
 
 		if(isset($status)){
-			$query->where('status', $status);
+			$query->whereStatus($status);
 		}
 
 		if(isset($enable)){
-			$query->where('enable', $enable);
+			$query->whereEnable($enable);
 		}
 
 		// 流量超过100G的
@@ -175,13 +175,13 @@ class AdminController extends Controller
 
 		// 不活跃用户
 		if($unActive){
-			$query->where('t', '>', 0)->where('t', '<=', strtotime(date('Y-m-d', strtotime("-".self::$systemConfig['expire_days']." days"))))->where('enable', 1);
+			$query->where('t', '>', 0)->where('t', '<=', strtotime(date('Y-m-d', strtotime("-".self::$systemConfig['expire_days']." days"))))->whereEnable(1);
 		}
 
 		// 1小时内流量异常用户
 		if($flowAbnormal){
 			$tempUsers = [];
-			$userTotalTrafficList = UserTrafficHourly::query()->where('node_id', 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()){
 				foreach($userTotalTrafficList as $vo){
 					if($vo->totalTraffic > (self::$systemConfig['traffic_ban_value']*1024*1024*1024)){
@@ -208,7 +208,7 @@ class AdminController extends Controller
 
 			// 流量异常警告
 			$time = date('Y-m-d H:i:s', time()-3900);
-			$totalTraffic = UserTrafficHourly::query()->where('user_id', $user->id)->where('node_id', 0)->where('created_at', '>=', $time)->sum('total');
+			$totalTraffic = UserTrafficHourly::query()->whereUserId($user->id)->whereNodeId(0)->where('created_at', '>=', $time)->sum('total');
 			$user->trafficWarning = $totalTraffic > (self::$systemConfig['traffic_ban_value']*1024*1024*1024)? 1 : 0;
 
 			// 订阅地址
@@ -225,7 +225,7 @@ class AdminController extends Controller
 	{
 		if($request->isMethod('POST')){
 			// 校验email是否已存在
-			$exists = User::query()->where('email', $request->input('email'))->first();
+			$exists = User::query()->whereEmail($request->input('email'))->first();
 			if($exists){
 				return Response::json(['status' => 'fail', 'data' => '', 'message' => '用户名已存在,请重新输入']);
 			}
@@ -301,7 +301,7 @@ class AdminController extends Controller
 	private function makeUserLabels($userId, $labels)
 	{
 		// 先删除该用户所有的标签
-		UserLabel::query()->where('user_id', $userId)->delete();
+		UserLabel::query()->whereUserId($userId)->delete();
 
 		if(!empty($labels) && is_array($labels)){
 			foreach($labels as $label){
@@ -385,13 +385,13 @@ class AdminController extends Controller
 			$reset_time = $request->input('reset_time');
 
 			// 校验email是否已存在
-			$exists = User::query()->where('id', '<>', $id)->where('email', $email)->first();
+			$exists = User::query()->where('id', '<>', $id)->whereEmail($email)->first();
 			if($exists){
 				return Response::json(['status' => 'fail', 'data' => '', 'message' => '用户名已存在,请重新输入']);
 			}
 
 			// 校验端口是否已存在
-			$exists = User::query()->where('id', '<>', $id)->where('port', '>', 0)->where('port', $port)->first();
+			$exists = User::query()->where('id', '<>', $id)->where('port', '>', 0)->wherePort($port)->first();
 			if($exists){
 				return Response::json(['status' => 'fail', 'data' => '', 'message' => '端口已存在,请重新输入']);
 			}
@@ -406,7 +406,7 @@ class AdminController extends Controller
 			}
 
 			// 用户编辑前的信息
-			$user = User::query()->where('id', $id)->first();
+			$user = User::query()->whereId($id)->first();
 
 			DB::beginTransaction();
 			try{
@@ -448,7 +448,7 @@ class AdminController extends Controller
 					}
 				}
 
-				User::query()->where('id', $id)->update($data);
+				User::query()->whereId($id)->update($data);
 
 				// 重新生成用户标签
 				$this->makeUserLabels($id, $labels);
@@ -468,7 +468,7 @@ class AdminController extends Controller
 				return Response::json(['status' => 'fail', 'data' => '', 'message' => '编辑失败']);
 			}
 		}else{
-			$user = User::query()->with(['label', 'referral'])->where('id', $id)->first();
+			$user = User::query()->with(['label', 'referral'])->whereId($id)->first();
 			if($user){
 				$user->transfer_enable = flowToGB($user->transfer_enable);
 
@@ -505,13 +505,13 @@ class AdminController extends Controller
 
 		DB::beginTransaction();
 		try{
-			User::query()->where('id', $id)->delete();
-			UserSubscribe::query()->where('user_id', $id)->delete();
-			UserBanLog::query()->where('user_id', $id)->delete();
-			UserLabel::query()->where('user_id', $id)->delete();
-			UserBalanceLog::query()->where('user_id', $id)->delete();
-			UserTrafficModifyLog::query()->where('user_id', $id)->delete();
-			UserLoginLog::query()->where('user_id', $id)->delete();
+			User::query()->whereId($id)->delete();
+			UserSubscribe::query()->whereUserId($id)->delete();
+			UserBanLog::query()->whereUserId($id)->delete();
+			UserLabel::query()->whereUserId($id)->delete();
+			UserBalanceLog::query()->whereUserId($id)->delete();
+			UserTrafficModifyLog::query()->whereUserId($id)->delete();
+			UserLoginLog::query()->whereUserId($id)->delete();
 
 			DB::commit();
 
@@ -549,21 +549,21 @@ class AdminController extends Controller
 			$query = SsNode::query();
 
 			if(isset($status)){
-				$query->where('status', $status);
+				$query->whereStatus($status);
 			}
 
 			$nodeList = $query->orderBy('status', 'desc')->orderBy('id', 'asc')->paginate(15)->appends($request->except('page'));
 			foreach($nodeList as $node){
 				// 在线人数
-				$online_log = SsNodeOnlineLog::query()->where('node_id', $node->id)->where('log_time', '>=', strtotime("-5 minutes"))->orderBy('id', 'desc')->first();
+				$online_log = SsNodeOnlineLog::query()->whereNodeId($node->id)->where('log_time', '>=', strtotime("-5 minutes"))->orderBy('id', 'desc')->first();
 				$node->online_users = empty($online_log)? 0 : $online_log->online_user;
 
 				// 已产生流量
-				$totalTraffic = SsNodeTrafficDaily::query()->where('node_id', $node->id)->sum('total');
+				$totalTraffic = SsNodeTrafficDaily::query()->whereNodeId($node->id)->sum('total');
 				$node->transfer = flowAutoShow($totalTraffic);
 
 				// 负载(10分钟以内)
-				$node_info = SsNodeInfo::query()->where('node_id', $node->id)->where('log_time', '>=', strtotime("-10 minutes"))->orderBy('id', 'desc')->first();
+				$node_info = SsNodeInfo::query()->whereNodeId($node->id)->where('log_time', '>=', strtotime("-10 minutes"))->orderBy('id', 'desc')->first();
 				$node->isOnline = empty($node_info) || empty($node_info->load)? 0 : 1;
 				$node->load = $node->isOnline? $node_info->load : '离线';
 				$node->uptime = empty($node_info)? 0 : seconds2time($node_info->uptime);
@@ -759,12 +759,12 @@ class AdminController extends Controller
 					'v2_outsider_port' => $request->input('v2_outsider_port', 443)
 				];
 
-				SsNode::query()->where('id', $id)->update($data);
+				SsNode::query()->whereid($id)->update($data);
 
 				// 建立分组关联
 				if($request->input('group_id')){
 					// 先删除该节点所有关联
-					SsGroupNode::query()->where('node_id', $id)->delete();
+					SsGroupNode::query()->whereNodeId($id)->delete();
 
 					// 建立关联
 					$ssGroupNode = new SsGroupNode();
@@ -788,7 +788,7 @@ class AdminController extends Controller
 				return Response::json(['status' => 'fail', 'data' => '', 'message' => '编辑失败:'.$e->getMessage()]);
 			}
 		}else{
-			$node = SsNode::query()->with(['label'])->where('id', $id)->first();
+			$node = SsNode::query()->with(['label'])->whereId($id)->first();
 			if($node){
 				$labels = [];
 				foreach($node->label as $vo){
@@ -814,7 +814,7 @@ class AdminController extends Controller
 	private function makeNodeLabels($nodeId, $labels)
 	{
 		// 先删除所有该节点的标签
-		SsNodeLabel::query()->where('node_id', $nodeId)->delete();
+		SsNodeLabel::query()->whereNodeId($nodeId)->delete();
 
 		if(!empty($labels) && is_array($labels)){
 			foreach($labels as $label){
@@ -831,7 +831,7 @@ class AdminController extends Controller
 	{
 		$id = $request->input('id');
 
-		$node = SsNode::query()->where('id', $id)->first();
+		$node = SsNode::query()->whereId($id)->first();
 		if(!$node){
 			return Response::json(['status' => 'fail', 'data' => '', 'message' => '节点不存在,请重试']);
 		}
@@ -839,17 +839,17 @@ class AdminController extends Controller
 		DB::beginTransaction();
 		try{
 			// 删除分组关联、节点标签、节点相关日志
-			SsNode::query()->where('id', $id)->delete();
-			SsGroupNode::query()->where('node_id', $id)->delete();
-			SsNodeLabel::query()->where('node_id', $id)->delete();
-			SsNodeInfo::query()->where('node_id', $id)->delete();
-			SsNodeOnlineLog::query()->where('node_id', $id)->delete();
-			SsNodeTrafficDaily::query()->where('node_id', $id)->delete();
-			SsNodeTrafficHourly::query()->where('node_id', $id)->delete();
-			SsNodePing::query()->where('node_id', $id)->delete();
-			UserTrafficDaily::query()->where('node_id', $id)->delete();
-			UserTrafficHourly::query()->where('node_id', $id)->delete();
-			UserTrafficLog::query()->where('node_id', $id)->delete();
+			SsNode::query()->whereId($id)->delete();
+			SsGroupNode::query()->whereNodeId($id)->delete();
+			SsNodeLabel::query()->whereNodeId($id)->delete();
+			SsNodeInfo::query()->whereNodeId($id)->delete();
+			SsNodeOnlineLog::query()->whereNodeId($id)->delete();
+			SsNodeTrafficDaily::query()->whereNodeId($id)->delete();
+			SsNodeTrafficHourly::query()->whereNodeId($id)->delete();
+			SsNodePing::query()->whereNodeId($id)->delete();
+			UserTrafficDaily::query()->whereNodeId($id)->delete();
+			UserTrafficHourly::query()->whereNodeId($id)->delete();
+			UserTrafficLog::query()->whereNodeId($id)->delete();
 
 			DB::commit();
 
@@ -865,7 +865,7 @@ class AdminController extends Controller
 	// 节点流量监控
 	public function nodeMonitor($node_id)
 	{
-		$node = SsNode::query()->where('id', $node_id)->orderBy('sort', 'desc')->first();
+		$node = SsNode::query()->whereId($node_id)->orderBy('sort', 'desc')->first();
 		if(!$node){
 			Session::flash('errorMsg', '节点不存在,请重试');
 
@@ -877,7 +877,7 @@ class AdminController extends Controller
 		$hourlyData = [];
 
 		// 节点一个月内的流量
-		$nodeTrafficDaily = SsNodeTrafficDaily::query()->with(['info'])->where('node_id', $node->id)->where('created_at', '>=', date('Y-m', time()))->orderBy('created_at', 'asc')->pluck('total')->toArray();
+		$nodeTrafficDaily = SsNodeTrafficDaily::query()->with(['info'])->whereNodeId($node->id)->where('created_at', '>=', date('Y-m', time()))->orderBy('created_at', 'asc')->pluck('total')->toArray();
 		$dailyTotal = date('d', time())-1;//今天不算,减一
 		$dailyCount = count($nodeTrafficDaily);
 		for($x = 0; $x < ($dailyTotal-$dailyCount); $x++){
@@ -888,7 +888,7 @@ class AdminController extends Controller
 		}
 
 		// 节点一天内的流量
-		$nodeTrafficHourly = SsNodeTrafficHourly::query()->with(['info'])->where('node_id', $node->id)->where('created_at', '>=', date('Y-m-d', time()))->orderBy('created_at', 'asc')->pluck('total')->toArray();
+		$nodeTrafficHourly = SsNodeTrafficHourly::query()->with(['info'])->whereNodeId($node->id)->where('created_at', '>=', date('Y-m-d', time()))->orderBy('created_at', 'asc')->pluck('total')->toArray();
 		$hourlyTotal = date('H', time());
 		$hourlyCount = count($nodeTrafficHourly);
 		for($x = 0; $x < ($hourlyTotal-$hourlyCount); $x++){
@@ -925,7 +925,7 @@ class AdminController extends Controller
 	// Ping节点延迟
 	public function pingNode(Request $request)
 	{
-		$node = SsNode::query()->where('id', $request->input('id'))->first();
+		$node = SsNode::query()->whereId($request->input('id'))->first();
 		if(!$node){
 			return Response::json(['status' => 'fail', 'message' => '节点不存在,请重试']);
 		}
@@ -950,7 +950,7 @@ class AdminController extends Controller
 		$node_id = $request->input('nodeId');
 		$query = SsNodePing::query();
 		if(isset($node_id)){
-			$query->where('node_id', $node_id);
+			$query->whereNodeId($node_id);
 		}
 
 		$view['nodeList'] = SsNode::query()->orderBy('id', 'asc')->get();
@@ -1213,7 +1213,7 @@ class AdminController extends Controller
 		}
 
 		$view['list'] = $list;
-		$view['nodeList'] = SsNode::query()->where('status', 1)->orderBy('sort', 'desc')->orderBy('id', 'desc')->get();
+		$view['nodeList'] = SsNode::query()->whereStatus(1)->orderBy('sort', 'desc')->orderBy('id', 'desc')->get();
 
 		return Response::view('admin.trafficLog', $view);
 	}
@@ -2096,7 +2096,7 @@ EOF;
 	// 导出邀请码
 	public function exportInvite()
 	{
-		$inviteList = Invite::query()->where('status', 0)->orderBy('id', 'asc')->get();
+		$inviteList = Invite::query()->whereStatus(0)->orderBy('id', 'asc')->get();
 
 		$filename = '邀请码'.date('Ymd').'.xlsx';
 
@@ -2138,7 +2138,7 @@ EOF;
 		}
 
 		if($status){
-			$query->where('status', $status);
+			$query->whereStatus($status);
 		}
 
 		$view['applyList'] = $query->orderBy('id', 'desc')->paginate(15)->appends($request->except('page'));
@@ -2205,7 +2205,7 @@ EOF;
 		}
 
 		if(isset($status)){
-			$query->where('status', $status);
+			$query->whereStatus($status);
 		}
 
 		if(isset($range_time) && $range_time != ','){
@@ -2275,7 +2275,7 @@ EOF;
 				$user = User::query()->where('id', $userId)->first();
 
 				// 写入余额变动日志
-				$this->addUserBalanceLog($userId, 0, $user->balance, $user->balance+$amount, $amount, '后台手动充值');
+				Helpers::addUserBalanceLog($userId, 0, $user->balance, $user->balance+$amount, $amount, '后台手动充值');
 
 				// 加减余额
 				if($amount < 0){
@@ -2373,7 +2373,7 @@ EOF;
 		}
 
 		if(isset($status)){
-			$query->where('status', $status);
+			$query->whereStatus($status);
 		}
 
 		$view['list'] = $query->paginate(15)->appends($request->except('page'));
@@ -2389,7 +2389,7 @@ EOF;
 		$wechat = $request->input('wechat');
 		$qq = $request->input('qq');
 
-		$query = User::query()->where('status', '>=', 0)->where('enable', 1);
+		$query = User::query()->where('status', '>=', 0)->whereEnable(1);
 
 		if(isset($email)){
 			$query->where('email', 'like', '%'.$email.'%');
@@ -2588,7 +2588,7 @@ EOF;
 		}
 
 		$view['list'] = $list->paginate(20)->appends($request->except('page'));
-		$view['nodeList'] = SsNode::query()->where('status', 1)->orderBy('sort', 'desc')->orderBy('id', 'desc')->get();
+		$view['nodeList'] = SsNode::query()->whereStatus(1)->orderBy('sort', 'desc')->orderBy('id', 'desc')->get();
 
 		return Response::view('admin.onlineIPMonitor', $view);
 	}

+ 3 - 3
app/Http/Controllers/Api/LoginController.php

@@ -52,7 +52,7 @@ class LoginController extends Controller
 			Cache::put($cacheKey, 1, 3600);
 		}
 
-		$user = User::query()->where('email', $email)->where('status', '>=', 0)->first();
+		$user = User::query()->whereEmail($email)->where('status', '>=', 0)->first();
 		if(!$user){
 			Cache::increment($cacheKey);
 
@@ -64,7 +64,7 @@ class LoginController extends Controller
 		DB::beginTransaction();
 		try{
 			// 如果未生成过订阅链接则生成一个
-			$subscribe = UserSubscribe::query()->where('user_id', $user->id)->first();
+			$subscribe = UserSubscribe::query()->whereUserId($user->id)->first();
 
 			// 更新订阅链接访问次数
 			$subscribe->increment('times', 1);
@@ -76,7 +76,7 @@ class LoginController extends Controller
 			$url = self::$systemConfig['subscribe_domain']? self::$systemConfig['subscribe_domain'] : self::$systemConfig['website_url'];
 
 			// 节点列表
-			$userLabelIds = UserLabel::query()->where('user_id', $user->id)->pluck('label_id');
+			$userLabelIds = UserLabel::query()->whereUserId($user->id)->pluck('label_id');
 			if(empty($userLabelIds)){
 				return Response::json(['status' => 'fail', 'message' => '', 'data' => []]);
 			}

+ 20 - 20
app/Http/Controllers/AuthController.php

@@ -271,7 +271,7 @@ class AuthController extends Controller
 
 				// 校验邀请码合法性
 				if($code){
-					$codeEnable = Invite::query()->where('code', $code)->where('status', 0)->doesntExist();
+					$codeEnable = Invite::query()->whereCode($code)->whereStatus(0)->doesntExist();
 					if($codeEnable){
 						return Redirect::back()->withInput($request->except(['code']))->withErrors(trans('auth.code_error'));
 					}
@@ -283,7 +283,7 @@ class AuthController extends Controller
 				if(!$verify_code){
 					return Redirect::back()->withInput($request->except(['verify_code']))->withErrors(trans('auth.captcha_null'));
 				}else{
-					$verifyCode = VerifyCode::query()->where('address', $email)->where('code', $verify_code)->where('status', 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'));
 					}
@@ -358,7 +358,7 @@ class AuthController extends Controller
 
 			// 更新邀请码
 			if(self::$systemConfig['is_invite_register'] && $affArr['code_id']){
-				Invite::query()->where('id', $affArr['code_id'])->update(['fuid' => $uid, 'status' => 1]);
+				Invite::query()->whereId($affArr['code_id'])->update(['fuid' => $uid, 'status' => 1]);
 			}
 
 			// 清除邀请人Cookie
@@ -377,16 +377,16 @@ class AuthController extends Controller
 			}else{
 				// 则直接给推荐人加流量
 				if($referral_uid){
-					$referralUser = User::query()->where('id', $referral_uid)->first();
+					$referralUser = User::query()->whereId($referral_uid)->first();
 					if($referralUser){
 						if($referralUser->expire_time >= date('Y-m-d')){
-							User::query()->where('id', $referral_uid)->increment('transfer_enable', self::$systemConfig['referral_traffic']*1048576);
+							User::query()->whereId($referral_uid)->increment('transfer_enable', self::$systemConfig['referral_traffic']*1048576);
 						}
 					}
 				}
 
 				if(self::$systemConfig['is_activate_account'] == 1){
-					User::query()->where('id', $uid)->update(['status' => 1]);
+					User::query()->whereId($uid)->update(['status' => 1]);
 				}
 
 				Session::flash('regSuccessMsg', trans('auth.register_success'));
@@ -394,7 +394,7 @@ class AuthController extends Controller
 
 			return Redirect::to('login')->withInput();
 		}else{
-			$view['emailList'] = self::$systemConfig['is_email_filtering'] != 2? FALSE : SensitiveWords::query()->where('type', 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);
@@ -444,7 +444,7 @@ class AuthController extends Controller
 
 		// 有邀请码先用邀请码,用谁的邀请码就给谁返利
 		if($code){
-			$inviteCode = Invite::query()->where('code', $code)->where('status', 0)->first();
+			$inviteCode = Invite::query()->whereCode($code)->whereStatus(0)->first();
 			if($inviteCode){
 				$referral_uid = $inviteCode->uid;
 				$code_id = $inviteCode->id;
@@ -456,10 +456,10 @@ class AuthController extends Controller
 			// 检查一下cookie里有没有aff
 			$cookieAff = \Request::hasCookie('register_aff')? \Request::cookie('register_aff') : 0;
 			if($cookieAff){
-				$affUser = User::query()->where('id', $cookieAff)->exists();
+				$affUser = User::query()->whereId($cookieAff)->exists();
 				$referral_uid = $affUser? $cookieAff : 0;
 			}elseif($aff){ // 如果cookie里没有aff,就再检查一下请求的url里有没有aff,因为有些人的浏览器会禁用了cookie,比如chrome开了隐私模式
-				$affUser = User::query()->where('id', $aff)->exists();
+				$affUser = User::query()->whereId($aff)->exists();
 				$referral_uid = $affUser? $aff : 0;
 			}
 		}
@@ -504,7 +504,7 @@ class AuthController extends Controller
 			}
 
 			// 查找账号
-			$user = User::query()->where('email', $email)->first();
+			$user = User::query()->whereEmail($email)->first();
 			if(!$user){
 				return Redirect::back()->withErrors(trans('auth.email_notExist'));
 			}
@@ -555,7 +555,7 @@ class AuthController extends Controller
 			]);
 			$password = $request->input('password');
 			// 校验账号
-			$verify = Verify::type(1)->with('user')->where('token', $token)->first();
+			$verify = Verify::type(1)->with('user')->whereToken($token)->first();
 			if(!$verify){
 				return Redirect::to('login');
 			}elseif($verify->status == 1){
@@ -567,7 +567,7 @@ class AuthController extends Controller
 			}
 
 			// 更新密码
-			$ret = User::query()->where('id', $verify->user_id)->update(['password' => Hash::make($password)]);
+			$ret = User::query()->whereId($verify->user_id)->update(['password' => Hash::make($password)]);
 			if(!$ret){
 				return Redirect::back()->withErrors(trans('auth.reset_password_fail'));
 			}
@@ -578,7 +578,7 @@ class AuthController extends Controller
 
 			return Redirect::back()->with('successMsg', trans('auth.reset_password_new'));
 		}else{
-			$verify = Verify::type(1)->where('token', $token)->first();
+			$verify = Verify::type(1)->whereToken($token)->first();
 			if(!$verify){
 				return Redirect::to('login');
 			}elseif(time()-strtotime($verify->created_at) >= 1800){
@@ -588,7 +588,7 @@ class AuthController extends Controller
 			}
 
 			// 重新获取一遍verify
-			$view['verify'] = Verify::type(1)->where('token', $token)->first();
+			$view['verify'] = Verify::type(1)->whereToken($token)->first();
 
 			return Response::view('auth.reset', $view);
 		}
@@ -613,7 +613,7 @@ class AuthController extends Controller
 			}
 
 			// 查找账号
-			$user = User::query()->where('email', $email)->first();
+			$user = User::query()->whereEmail($email)->first();
 			if($user->status < 0){
 				return Redirect::back()->withErrors(trans('auth.login_ban', ['email' => self::$systemConfig['webmaster_email']]));
 			}elseif($user->status > 0){
@@ -653,7 +653,7 @@ class AuthController extends Controller
 			return Redirect::to('login');
 		}
 
-		$verify = Verify::type(1)->with('user')->where('token', $token)->first();
+		$verify = Verify::type(1)->with('user')->whereToken($token)->first();
 		if(!$verify){
 			return Redirect::to('login');
 		}elseif(empty($verify->user)){
@@ -679,7 +679,7 @@ class AuthController extends Controller
 		}
 
 		// 更新账号状态
-		$ret = User::query()->where('id', $verify->user_id)->update(['status' => 1]);
+		$ret = User::query()->whereId($verify->user_id)->update(['status' => 1]);
 		if(!$ret){
 			Session::flash('errorMsg', trans('auth.active_fail'));
 
@@ -694,7 +694,7 @@ class AuthController extends Controller
 		if($verify->user->referral_uid){
 			$transfer_enable = self::$systemConfig['referral_traffic']*1048576;
 
-			User::query()->where('id', $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'));
@@ -762,7 +762,7 @@ class AuthController extends Controller
 	// 公开的邀请码列表
 	public function free()
 	{
-		$view['inviteList'] = Invite::query()->where('uid', 0)->where('status', 0)->paginate();
+		$view['inviteList'] = Invite::query()->whereUid(0)->whereStatus(0)->paginate();
 
 		return Response::view('auth.free', $view);
 	}

+ 1 - 27
app/Http/Controllers/Controller.php

@@ -89,36 +89,10 @@ class Controller extends BaseController
 		return $i;
 	}
 
-	/**
-	 * 记录余额操作日志
-	 *
-	 * @param int    $userId 用户ID
-	 * @param string $oid    订单ID
-	 * @param int    $before 记录前余额
-	 * @param int    $after  记录后余额
-	 * @param int    $amount 发生金额
-	 * @param string $desc   描述
-	 *
-	 * @return int
-	 */
-	public function addUserBalanceLog($userId, $oid, $before, $after, $amount, $desc = '')
-	{
-		$log = new UserBalanceLog();
-		$log->user_id = $userId;
-		$log->order_id = $oid;
-		$log->before = $before;
-		$log->after = $after;
-		$log->amount = $amount;
-		$log->desc = $desc;
-		$log->created_at = date('Y-m-d H:i:s');
-
-		return $log->save();
-	}
-
 	// 获取敏感词
 	public function sensitiveWords($type)
 	{
-		return SensitiveWords::query()->where('type', $type)->get()->pluck('words')->toArray();
+		return SensitiveWords::query()->whereType($type)->get()->pluck('words')->toArray();
 	}
 
 	// 将Base64图片转换为本地图片并保存

+ 6 - 6
app/Http/Controllers/CouponController.php

@@ -35,11 +35,11 @@ class CouponController extends Controller
 		}
 
 		if(isset($type)){
-			$query->where('type', $type);
+			$query->whereType($type);
 		}
 
 		if(isset($status)){
-			$query->where('status', $status);
+			$query->whereStatus($status);
 		}
 
 		$view['couponList'] = $query->orderBy('id', 'desc')->paginate(15)->appends($request->except('page'));
@@ -141,7 +141,7 @@ class CouponController extends Controller
 	// 删除优惠券
 	public function delCoupon(Request $request)
 	{
-		Coupon::query()->where('id', $request->input('id'))->delete();
+		Coupon::query()->whereId($request->input('id'))->delete();
 
 		return Response::json(['status' => 'success', 'data' => '', 'message' => '删除成功']);
 	}
@@ -149,9 +149,9 @@ class CouponController extends Controller
 	// 导出卡券
 	public function exportCoupon()
 	{
-		$voucherList = Coupon::type(1)->where('status', 0)->get();
-		$discountCouponList = Coupon::type(2)->where('status', 0)->get();
-		$refillList = Coupon::type(3)->where('status', 0)->get();
+		$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();

+ 26 - 19
app/Http/Controllers/Gateway/AbstractPayment.php

@@ -49,39 +49,46 @@ abstract class AbstractPayment
 
 	abstract public function getPurchaseHTML();
 
-	public function postPayment($sn, $method)
+	public function postPayment($data, $method)
 	{
 		// 获取需要的信息
-		$payment = Payment::where('sn', $sn)->first();
-		$order = Order::find($payment->oid);
+		$payment = Payment::whereSn($data)->first();
+		// 是否为余额购买套餐
+		if($payment){
+			$order = Order::find($payment->oid);
+		}else{
+			$order = Order::find($data);
+		}
 		$goods = Goods::find($order->goods_id);
 		$user = User::find($order->user_id);
 
+		//余额充值
+		if($order->goods_id == -1){
+			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.'充值余额');
+
+			return 0;
+		}
+
 		// 商品为流量或者套餐
 		switch($goods->type){
 			case 1:
 				$order->status = 2;
 				$order->save();
-				User::query()->where('id', $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, '[在线支付]加上用户购买的套餐流量');
+				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()
-					->where('user_id', $user->id)
-					->where('is_expire', 0)
-					->where('status', 2)
-					->with(['goods'])
-					->whereHas('goods', function($q){
-						$q->where('type', 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;
 				$order->save();
 
 				if($activePlan){
 					// 预支付订单, 刷新账号有效时间用于流量重置判断
-					User::query()->where('id', $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()
@@ -90,13 +97,13 @@ abstract class AbstractPayment
 						->whereHas('goods', function($q){
 							$q->where('type', '<=', 2);
 						})
-						->where('is_expire', 0)
-						->where('status', 2)
+						->whereIsExpire(0)
+						->whereStatus(2)
 						->where('oid', '<>', $order->oid)
 						->update(['expire_at' => date('Y-m-d H:i:s'), 'is_expire' => 1]);
 
 					User::query()->where('id', $order->user_id)->update(['u' => 0, 'd' => 0, 'transfer_enable' => 0]);
-					Helpers::addUserTrafficModifyLog($order->user_id, $order->oid, $user->transfer_enable, 0, '[在线支付]用户购买新套餐,先清空流量');
+					Helpers::addUserTrafficModifyLog($order->user_id, $order->oid, $user->transfer_enable, 0, '['.$method.']用户购买新套餐,先清空流量');
 
 					$userTraffic = $goods->traffic*1048576;
 					// 添加账号有效期
@@ -125,7 +132,7 @@ abstract class AbstractPayment
 					}
 
 					User::query()->where('id', $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, '[在线支付]加上用户购买的套餐流量');
+					Helpers::addUserTrafficModifyLog($order->user_id, $order->oid, $user->transfer_enable, $userTraffic, '['.$method.']加上用户购买的套餐流量');
 				}
 
 				// 是否返利

+ 2 - 2
app/Http/Controllers/Gateway/AopF2F.php

@@ -55,7 +55,7 @@ class AopF2F extends AbstractPayment
 
 	public function notify($request)
 	{
-		$gateway = $this->createGateway();
+		$gateway = self::createGateway();
 		$aliRequest = $gateway->completePurchase();
 		$aliRequest->setParams($_POST);
 
@@ -64,7 +64,7 @@ class AopF2F extends AbstractPayment
 			$aliResponse = $aliRequest->send();
 			$pid = $aliResponse->data('out_trade_no');
 			if($aliResponse->isPaid()){
-				$this->postPayment($pid, '支付宝当面付');
+				self::postPayment($pid, '支付宝当面付');
 				exit('success');
 			}
 		}catch(Exception $e){

+ 48 - 0
app/Http/Controllers/Gateway/Local.php

@@ -0,0 +1,48 @@
+<?php
+
+
+namespace App\Http\Controllers\Gateway;
+
+use App\Components\Helpers;
+use App\Http\Models\Goods;
+use App\Http\Models\Order;
+use App\Http\Models\User;
+use Auth;
+use Illuminate\Http\Request;
+use Response;
+
+class Local extends AbstractPayment
+{
+
+	public function purchase(Request $request)
+	{
+		$amount = $request->input('amount');
+		$order = Order::whereOid($request->input('oid'))->first();
+		$goods = Goods::query()->where('status', 1)->where('id', $request->input('goods_id'))->first();
+
+		if($goods){
+			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);
+		}
+
+		self::postPayment($order->oid, '余额');
+
+		return Response::json(['status' => 'success', 'message' => '购买完成!']);
+	}
+
+	public function notify(Request $request)
+	{
+		// TODO: Implement notify() method.
+	}
+
+	public function getReturnHTML(Request $request)
+	{
+		// TODO: Implement getReturnHTML() method.
+	}
+
+	public function getPurchaseHTML()
+	{
+		// TODO: Implement getPurchaseHTML() method.
+	}
+}

+ 4 - 4
app/Http/Controllers/MarketingController.php

@@ -32,10 +32,10 @@ class MarketingController extends Controller
 	{
 		$status = $request->input('status');
 
-		$query = Marketing::query()->where('type', 1);
+		$query = Marketing::query()->whereType(1);
 
 		if(isset($status)){
-			$query->where('status', $status);
+			$query->whereStatus($status);
 		}
 
 		$view['list'] = $query->paginate(15)->appends($request->except('page'));
@@ -48,10 +48,10 @@ class MarketingController extends Controller
 	{
 		$status = $request->input('status');
 
-		$query = Marketing::query()->where('type', 2);
+		$query = Marketing::query()->whereType(2);
 
 		if(isset($status)){
-			$query->where('status', $status);
+			$query->whereStatus($status);
 		}
 
 		$view['list'] = $query->paginate(15);

+ 24 - 34
app/Http/Controllers/PaymentController.php

@@ -6,13 +6,13 @@ use App\Components\Helpers;
 use App\Http\Controllers\Gateway\AopF2F;
 use App\Http\Controllers\Gateway\BitpayX;
 use App\Http\Controllers\Gateway\CodePay;
+use App\Http\Controllers\Gateway\local;
 use App\Http\Controllers\Gateway\PayJs;
 use App\Http\Models\Coupon;
 use App\Http\Models\Goods;
 use App\Http\Models\Order;
 use App\Http\Models\Payment;
 use App\Http\Models\PaymentCallback;
-use App\Http\Models\User;
 use Auth;
 use Illuminate\Http\Request;
 use Response;
@@ -31,6 +31,8 @@ class PaymentController extends Controller
 	public static function getClient()
 	{
 		switch(self::$method){
+			case 'balance':
+				return new Local();
 			case 'f2fpay':
 				return new AopF2F();
 			case 'codepay':
@@ -72,38 +74,43 @@ class PaymentController extends Controller
 	}
 
 	// 创建支付订单
-	public static 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');
 		$balance = $request->input('amount');
-		$goods = Goods::query()->where('status', 1)->whereId($goods_id)->first();
-		if(isset($balance)){
+
+		$goods = Goods::query()->whereStatus(1)->whereId($goods_id)->first();
+		// 充值余额
+		if($balance){
 			if(!is_numeric($balance) || $balance <= 0){
 				return Response::json(['status' => 'fail', 'data' => '', 'message' => '充值余额不合规']);
 			}
 			$amount = $balance;
-		}elseif(isset($goods_id) && isset(self::$method)){
+			// 购买服务
+		}elseif($goods_id && self::$method){
 			if(!$goods){
 				return Response::json(['status' => 'fail', 'data' => '', 'message' => '订单创建失败:商品或服务已下架']);
 			}
+
 			// 是否有生效的套餐
-			$activePlan = Order::uid()->with(['goods'])->whereHas('goods', function($q){ $q->where('type', 2); })->where('status', 2)->where('is_expire', 0)->doesntExist();
+			$activePlan = Order::uid()->with(['goods'])->whereHas('goods', function($q){ $q->whereType(2); })->whereStatus(2)->whereIsExpire(0)->doesntExist();
+
 			//无生效套餐,禁止购买加油包
 			if($goods->type == 1 && $activePlan){
 				return Response::json(['status' => 'fail', 'data' => '', 'message' => '购买加油包前,请先购买套餐']);
 			}
 
 			//非余额付款下,检查对应的在线支付是否开启
-			if(self::$method != 1){
+			if(self::$method != 'balance'){
 				// 判断是否开启在线支付
 				if(!Helpers::systemConfig()['is_onlinePay']){
 					return Response::json(['status' => 'fail', 'data' => '', 'message' => '订单创建失败:系统并未开启在线支付功能']);
 				}
 
 				// 判断是否存在同个商品的未支付订单
-				$existsOrder = Order::uid()->where('status', 0)->where('goods_id', $goods_id)->exists();
+				$existsOrder = Order::uid()->whereStatus(0)->whereGoodsId($goods_id)->exists();
 				if($existsOrder){
 					return Response::json(['status' => 'fail', 'data' => '', 'message' => '订单创建失败:尚有未支付的订单,请先去支付']);
 				}
@@ -111,7 +118,7 @@ class PaymentController extends Controller
 
 			// 单个商品限购
 			if($goods->limit_num){
-				$count = Order::uid()->where('status', '>=', 0)->where('goods_id', $goods_id)->count();
+				$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.'次']);
 				}
@@ -119,7 +126,7 @@ class PaymentController extends Controller
 
 			// 使用优惠券
 			if($coupon_sn){
-				$coupon = Coupon::query()->where('status', 0)->whereIn('type', [1, 2])->where('sn', $coupon_sn)->first();
+				$coupon = Coupon::query()->whereStatus(0)->whereIn('type', [1, 2])->whereSn($coupon_sn)->first();
 				if(!$coupon){
 					return Response::json(['status' => 'fail', 'data' => '', 'message' => '订单创建失败:优惠券不存在']);
 				}
@@ -134,12 +141,12 @@ class PaymentController extends Controller
 			// 价格异常判断
 			if($amount < 0){
 				return Response::json(['status' => 'fail', 'data' => '', 'message' => '订单创建失败:订单总价异常']);
-			}elseif($amount == 0 && self::$method != 1){
+			}elseif($amount == 0 && self::$method != 'balance'){
 				return Response::json(['status' => 'fail', 'data' => '', 'message' => '订单创建失败:订单总价为0,无需使用在线支付']);
 			}
 
 			// 验证账号余额是否充足
-			if(self::$method == 1 && Auth::user()->balance < $amount){
+			if(self::$method == 'balance' && Auth::user()->balance < $amount){
 				return Response::json(['status' => 'fail', 'data' => '', 'message' => '您的余额不足,请先充值']);
 			}
 		}
@@ -170,33 +177,16 @@ class PaymentController extends Controller
 			Helpers::addCouponLog($coupon->id, $goods_id, $order->oid, '订单支付使用');
 		}
 
-		// 生成支付单
-		if(self::$method == 1){
-			// 扣余额
-			User::query()->where('id', Auth::user()->id)->decrement('balance', $amount*100);
-
-			// 记录余额操作日志
-			(new Controller)->addUserBalanceLog(Auth::user()->id, $order->oid, Auth::user()->balance, Auth::user()->balance-$amount, -1*$amount, '购买商品:'.$goods->name);
-			$order = Order::query()->where('oid', $orderSn)->first();
-			$order->status = 2;
-			$order->save();
-			User::query()->where('id', $order->user_id)->increment('balance', $order->amount*100);
-
-			// 余额变动记录日志
-			(new Controller)->addUserBalanceLog($order->user_id, $order->oid, $order->user->balance, $order->user->balance+$order->amount, $order->amount, '用户在线充值');
-		}else{
-			$request->merge(['oid' => $order->oid, 'amount' => $amount, 'type' => $request->input('pay_type')]);
-
-			return self::getClient()->purchase($request);
-		}
+		$request->merge(['oid' => $order->oid, 'amount' => $amount, 'type' => $request->input('pay_type')]);
 
-		return FALSE;
+		// 生成支付单
+		return self::getClient()->purchase($request);
 	}
 
 	// 支付单详情
 	public function detail($sn)
 	{
-		$payment = Payment::uid()->with(['order', 'order.goods'])->where('sn', $sn)->first();
+		$payment = Payment::uid()->with(['order', 'order.goods'])->whereSn($sn)->first();
 		$view['payment'] = $payment;
 		$view['name'] = $payment->order->goods? $payment->order->goods->name : '余额充值';
 		$view['days'] = $payment->order->goods? $payment->order->goods->days : 0;
@@ -212,7 +202,7 @@ class PaymentController extends Controller
 		$query = PaymentCallback::query();
 
 		if(isset($status)){
-			$query->where('status', $status);
+			$query->whereStatus($status);
 		}
 
 		$view['list'] = $query->orderBy('id', 'desc')->paginate(10)->appends($request->except('page'));

+ 1 - 1
app/Http/Controllers/SensitiveWordsController.php

@@ -52,7 +52,7 @@ class SensitiveWordsController extends Controller
 	// 删除敏感词
 	public function delSensitiveWords(Request $request)
 	{
-		$result = SensitiveWords::query()->where('id', $request->input('id'))->delete();
+		$result = SensitiveWords::query()->whereId($request->input('id'))->delete();
 		if($result){
 			return Response::json(['status' => 'success', 'data' => '', 'message' => '删除成功']);
 		}else{

+ 8 - 8
app/Http/Controllers/ServiceController.php

@@ -17,21 +17,21 @@ class ServiceController extends Controller
 		// 取出预支付订单
 		$prepaidOrder = Order::find($oid);
 		//去除使用中的套餐和 流量包
-		Order::query()->where('user_id', $prepaidOrder->user_id)->where('status', 2)->where('is_expire', 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()->where('id', $prepaidOrder->goods_id)->first();
+		$prepaidGood = Goods::query()->whereId($prepaidOrder->goods_id)->first();
 		//激活预支付套餐
-		Order::query()->where('oid', $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()->where('id', $prepaidOrder->user_id)->first();
+		$user = User::query()->whereId($prepaidOrder->user_id)->first();
 
 		$userTraffic = $prepaidGood->traffic*1048576;
 		//拿出可能存在的其余套餐, 推算 最新的到期时间
 		$expire_time = date('Y-m-d', strtotime("+".$prepaidGood->days." days"));
-		$prepaidOrders = Order::query()->where('user_id', $prepaidOrder->user_id)->where('status', 3)->get();
+		$prepaidOrders = Order::query()->whereUserId($prepaidOrder->user_id)->whereStatus(3)->get();
 		foreach($prepaidOrders as $paidOrder){
 			//取出对应套餐信息
-			$goods = Goods::query()->where('id', $paidOrder->goods_id)->first();
+			$goods = Goods::query()->whereId($paidOrder->goods_id)->first();
 			$expire_time = date('Y-m-d', strtotime("+".$goods->days." days", strtotime($expire_time)));
 		}
 		//计算账号下一个重置时间
@@ -43,7 +43,7 @@ class ServiceController extends Controller
 		// 用户默认标签
 		$defaultLabels = Helpers::systemConfig()['initial_labels_for_user']? explode(',', Helpers::systemConfig()['initial_labels_for_user']) : [];
 		//取出 商品默认标签  & 系统默认标签 去重
-		$newUserLabels = array_values(array_unique(array_merge(GoodsLabel::query()->where('goods_id', $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){
@@ -53,7 +53,7 @@ class ServiceController extends Controller
 			$obj->save();
 		}
 		Helpers::addUserTrafficModifyLog($prepaidOrder->user_id, $prepaidOrder->oid, $user->transfer_enable, $userTraffic, '[预支付订单激活]加上用户购买的套餐流量');
-		User::query()->where('id', $prepaidOrder->user_id)->increment('invite_num', $prepaidOrder->invite_num? : 0, ['u' => 0, 'd' => 0, 'transfer_enable' => $userTraffic, 'expire_time' => $expire_time, 'reset_time' => $nextResetTime]);
+		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]);
 	}
 
 }

+ 6 - 6
app/Http/Controllers/ShopController.php

@@ -31,11 +31,11 @@ class ShopController extends Controller
 		$query = Goods::query();
 
 		if(isset($type)){
-			$query->where('type', $type);
+			$query->whereType($type);
 		}
 
 		if(isset($status)){
-			$query->where('status', $status);
+			$query->whereStatus($status);
 		}
 
 		$view['goodsList'] = $query->orderBy('status', 'desc')->paginate(10)->appends($request->except('page'));
@@ -150,7 +150,7 @@ class ShopController extends Controller
 			$limit_num = $request->input('limit_num');
 			$status = $request->input('status');
 
-			$goods = Goods::query()->where('id', $id)->first();
+			$goods = Goods::query()->whereId($id)->first();
 			if(!$goods){
 				Session::flash('errorMsg', '商品不存在');
 
@@ -212,10 +212,10 @@ class ShopController extends Controller
 					$data['logo'] = $logo;
 				}
 
-				Goods::query()->where('id', $id)->update($data);
+				Goods::query()->whereId($id)->update($data);
 
 				// 先删除该商品所有的标签
-				GoodsLabel::query()->where('goods_id', $id)->delete();
+				GoodsLabel::query()->whereGoodsId($id)->delete();
 
 				// 生成商品标签
 				if(!empty($labels)){
@@ -238,7 +238,7 @@ class ShopController extends Controller
 
 			return Redirect::to('shop/editGoods/'.$id);
 		}else{
-			$goods = Goods::query()->with(['label'])->where('id', $id)->first();
+			$goods = Goods::query()->with(['label'])->whereId($id)->first();
 			if($goods){
 				$label = [];
 				foreach($goods->label as $vo){

+ 12 - 12
app/Http/Controllers/SubscribeController.php

@@ -39,7 +39,7 @@ class SubscribeController extends Controller
 		$query = UserSubscribe::with(['user:id,email']);
 
 		if(isset($user_id)){
-			$query->where('user_id', $user_id);
+			$query->whereUserId($user_id);
 		}
 
 		if(isset($email)){
@@ -49,7 +49,7 @@ class SubscribeController extends Controller
 		}
 
 		if(isset($status)){
-			$query->where('status', $status);
+			$query->whereStatus($status);
 		}
 
 		$view['subscribeList'] = $query->orderBy('id', 'desc')->paginate(20)->appends($request->except('page'));
@@ -64,7 +64,7 @@ class SubscribeController extends Controller
 		$query = UserSubscribeLog::with('user:email');
 
 		if(isset($id)){
-			$query->where('sid', $id);
+			$query->whereSid($id);
 		}
 
 		$view['subscribeLog'] = $query->orderBy('id', 'desc')->paginate(20)->appends($request->except('page'));
@@ -83,11 +83,11 @@ class SubscribeController extends Controller
 		$query = Device::query();
 
 		if(isset($type)){
-			$query->where('type', $type);
+			$query->whereType($type);
 		}
 
 		if(isset($platform)){
-			$query->where('platform', $platform);
+			$query->wherePlatform($platform);
 		}
 
 		if(isset($name)){
@@ -95,7 +95,7 @@ class SubscribeController extends Controller
 		}
 
 		if(isset($status)){
-			$query->where('status', $status);
+			$query->whereStatus($status);
 		}
 
 		$view['deviceList'] = $query->paginate(20)->appends($request->except('page'));
@@ -114,9 +114,9 @@ class SubscribeController extends Controller
 		}
 
 		if($status){
-			UserSubscribe::query()->where('id', $id)->update(['status' => 1, 'ban_time' => 0, 'ban_desc' => '']);
+			UserSubscribe::query()->whereId($id)->update(['status' => 1, 'ban_time' => 0, 'ban_desc' => '']);
 		}else{
-			UserSubscribe::query()->where('id', $id)->update(['status' => 0, 'ban_time' => time(), 'ban_desc' => '后台手动封禁']);
+			UserSubscribe::query()->whereId($id)->update(['status' => 0, 'ban_time' => time(), 'ban_desc' => '后台手动封禁']);
 		}
 
 		return Response::json(['status' => 'success', 'data' => '', 'message' => '操作成功']);
@@ -132,7 +132,7 @@ class SubscribeController extends Controller
 			return Response::json(['status' => 'fail', 'data' => '', 'message' => '操作异常']);
 		}
 
-		Device::query()->where('id', $id)->update(['status' => $status]);
+		Device::query()->whereId($id)->update(['status' => $status]);
 
 		return Response::json(['status' => 'success', 'data' => '', 'message' => '操作成功']);
 	}
@@ -145,12 +145,12 @@ class SubscribeController extends Controller
 		}
 
 		// 校验合法性
-		$subscribe = UserSubscribe::query()->with('user')->where('status', 1)->where('code', $code)->first();
+		$subscribe = UserSubscribe::query()->with('user')->whereStatus(1)->whereCode($code)->first();
 		if(!$subscribe){
 			exit($this->noneNode());
 		}
 
-		$user = User::query()->whereIn('status', [0, 1])->where('enable', 1)->where('id', $subscribe->user_id)->first();
+		$user = User::query()->whereIn('status', [0, 1])->whereEnable(1)->whereId($subscribe->user_id)->first();
 		if(!$user){
 			exit($this->noneNode());
 		}
@@ -162,7 +162,7 @@ class SubscribeController extends Controller
 		$this->log($subscribe->id, getClientIp(), $request->headers);
 
 		// 获取这个账号可用节点
-		$userLabelIds = UserLabel::query()->where('user_id', $user->id)->pluck('label_id');
+		$userLabelIds = UserLabel::query()->whereUserId($user->id)->pluck('label_id');
 		if(empty($userLabelIds)){
 			exit($this->noneNode());
 		}

+ 4 - 4
app/Http/Controllers/TicketController.php

@@ -65,7 +65,7 @@ class TicketController extends Controller
 
 			if($obj->id){
 				// 将工单置为已回复
-				$ticket = Ticket::query()->with(['user'])->where('id', $id)->first();
+				$ticket = Ticket::query()->with(['user'])->whereId($id)->first();
 				$ticket->status = 1;
 				$ticket->save();
 
@@ -94,8 +94,8 @@ class TicketController extends Controller
 				return Response::json(['status' => 'fail', 'data' => '', 'message' => '回复失败']);
 			}
 		}else{
-			$view['ticket'] = Ticket::query()->where('id', $id)->with('user')->first();
-			$view['replyList'] = TicketReply::query()->where('ticket_id', $id)->with('user')->orderBy('id', 'asc')->get();
+			$view['ticket'] = Ticket::query()->whereId($id)->with('user')->first();
+			$view['replyList'] = TicketReply::query()->whereTicketId($id)->with('user')->orderBy('id', 'asc')->get();
 
 			return Response::view('ticket.replyTicket', $view);
 		}
@@ -106,7 +106,7 @@ class TicketController extends Controller
 	{
 		$id = $request->input('id');
 
-		$ticket = Ticket::query()->with(['user'])->where('id', $id)->first();
+		$ticket = Ticket::query()->with(['user'])->whereId($id)->first();
 		if(!$ticket){
 			return Response::json(['status' => 'fail', 'data' => '', 'message' => '关闭失败']);
 		}

+ 36 - 36
app/Http/Controllers/UserController.php

@@ -69,18 +69,18 @@ class UserController extends Controller
 		$view['unusedPercent'] = $totalTransfer > 0? round($unusedTransfer/$totalTransfer, 2) : 0;
 		$view['noticeList'] = Article::type(2)->orderBy('id', 'desc')->Paginate(1); // 公告
 		//流量异常判断
-		$hourlyTraffic = UserTrafficHourly::query()->where('user_id', Auth::user()->id)->where('node_id', 0)->where('created_at', '>=', date('Y-m-d H:i:s', time()-3900))->sum('total');
+		$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()->where('status', 2)->where('is_expire', 0)->where('origin_amount', '>', 0)->doesntExist();
-		$view['userLoginLog'] = UserLoginLog::query()->where('user_id', 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()->where('user_id', Auth::user()->id)->where('node_id', 0)->where('created_at', '<=', date('Y-m-d', time()))->orderBy('created_at', 'asc')->pluck('total')->toArray();
+		$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);
@@ -92,7 +92,7 @@ class UserController extends Controller
 		}
 
 		// 节点一天内的流量
-		$userTrafficHourly = UserTrafficHourly::query()->where('user_id', Auth::user()->id)->where('node_id', 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++){
@@ -170,15 +170,15 @@ class UserController extends Controller
 			$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()->where('node_id', $node->id)->where('ct', '>', '0')->avg('ct'), 1, '.', '');
-				$node->cu = number_format(SsNodePing::query()->where('node_id', $node->id)->where('cu', '>', '0')->avg('cu'), 1, '.', '');
-				$node->cm = number_format(SsNodePing::query()->where('node_id', $node->id)->where('cm', '>', '0')->avg('cm'), 1, '.', '');
-				$node->hk = number_format(SsNodePing::query()->where('node_id', $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()->where('node_id', $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()->where('node_id', $node->id)->first();
+				$node->labels = SsNodeLabel::query()->whereNodeId($node->id)->first();
 			}
 			$view['nodeList'] = $nodeList? : [];
 		}
@@ -255,10 +255,10 @@ class UserController extends Controller
 	public function services(Request $request)
 	{
 		// 余额充值商品,只取10个
-		$view['chargeGoodsList'] = Goods::type(3)->where('status', 1)->orderBy('price', 'asc')->orderBy('price', 'asc')->limit(10)->get();
-		$view['goodsList'] = Goods::query()->where('status', 1)->where('type', '<=', '2')->orderBy('type', 'desc')->orderBy('sort', 'desc')->paginate(10)->appends($request->except('page'));
-		$renewOrder = Order::query()->with(['goods'])->where('user_id', Auth::user()->id)->where('status', 2)->where('is_expire', 0)->whereHas('goods', function($q){ $q->where('type', 2); })->first();
-		$renewPrice = $renewOrder? Goods::query()->where('id', $renewOrder->goods_id)->first() : 0;
+		$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;
@@ -271,15 +271,15 @@ class UserController extends Controller
 	//重置流量
 	public function resetUserTraffic()
 	{
-		$temp = Order::uid()->where('status', 2)->where('is_expire', 0)->with(['goods'])->whereHas('goods', function($q){ $q->where('type', 2); })->first();
-		$renewCost = Goods::query()->where('id', $temp->goods_id)->first()->renew;
+		$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' => '余额不足,请充值余额']);
 		}else{
 			User::uid()->update(['u' => 0, 'd' => 0]);
 
 			// 扣余额
-			User::query()->where('id', Auth::user()->id)->decrement('balance', $renewCost*100);
+			User::query()->whereId(Auth::user()->id)->decrement('balance', $renewCost*100);
 
 			// 记录余额操作日志
 			$this->addUserBalanceLog(Auth::user()->id, '', Auth::user()->balance, Auth::user()->balance-$renewCost, -1*$renewCost, '用户自行重置流量');
@@ -307,7 +307,7 @@ class UserController extends Controller
 	public function activeOrder(Request $request)
 	{
 		$oid = $request->input('oid');
-		$prepaidOrder = Order::query()->where('oid', $oid)->first();
+		$prepaidOrder = Order::query()->whereOid($oid)->first();
 		if(!$prepaidOrder){
 			return Response::json(['status' => 'fail', 'data' => '', 'message' => '查无此单!']);
 		}elseif($prepaidOrder->status != 3){
@@ -322,7 +322,7 @@ class UserController extends Controller
 	// 订单明细
 	public function invoiceDetail($sn)
 	{
-		$view['order'] = Order::uid()->with(['goods', 'coupon', 'payment'])->where('order_sn', $sn)->firstOrFail();
+		$view['order'] = Order::uid()->with(['goods', 'coupon', 'payment'])->whereOrderSn($sn)->firstOrFail();
 
 		return Response::view('user.invoiceDetail', $view);
 	}
@@ -368,7 +368,7 @@ class UserController extends Controller
 	{
 		$id = $request->input('id');
 
-		$ticket = Ticket::uid()->with('user')->where('id', $id)->firstOrFail();
+		$ticket = Ticket::uid()->with('user')->whereId($id)->firstOrFail();
 
 		if($request->isMethod('POST')){
 			$content = clean($request->input('content'));
@@ -411,7 +411,7 @@ class UserController extends Controller
 			}
 		}else{
 			$view['ticket'] = $ticket;
-			$view['replyList'] = TicketReply::query()->where('ticket_id', $id)->with('user')->orderBy('id', 'asc')->get();
+			$view['replyList'] = TicketReply::query()->whereTicketId($id)->with('user')->orderBy('id', 'asc')->get();
 
 			return Response::view('user.replyTicket', $view);
 		}
@@ -422,7 +422,7 @@ class UserController extends Controller
 	{
 		$id = $request->input('id');
 
-		$ret = Ticket::uid()->where('id', $id)->update(['status' => 2]);
+		$ret = Ticket::uid()->whereId($id)->update(['status' => 2]);
 		if($ret){
 			PushNotification::send('工单关闭提醒', '工单:ID'.$id.'用户已手动关闭');
 
@@ -435,7 +435,7 @@ class UserController extends Controller
 	// 邀请码
 	public function invite()
 	{
-		if(Order::uid()->where('status', 2)->where('is_expire', 0)->where('origin_amount', '>', 0)->doesntExist()){
+		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>']);
 		}
 
@@ -477,7 +477,7 @@ class UserController extends Controller
 			return Response::json(['status' => 'fail', 'title' => '使用失败', 'message' => '请输入您的优惠劵!']);
 		}
 
-		$coupon = Coupon::query()->where('sn', $coupon_sn)->whereIn('type', [1, 2])->first();
+		$coupon = Coupon::query()->whereSn($coupon_sn)->whereIn('type', [1, 2])->first();
 		if(!$coupon){
 			return Response::json(['status' => 'fail', 'title' => '优惠券不存在', 'message' => '请确认优惠券是否输入正确!']);
 		}elseif($coupon->status == 1){
@@ -503,14 +503,14 @@ class UserController extends Controller
 	// 购买服务
 	public function buy($goods_id)
 	{
-		$goods = Goods::query()->where('id', $goods_id)->where('status', 1)->first();
+		$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'])->where('is_expire', 0)->where('status', 2)->whereHas('goods', function($q){ $q->where('type', 2); })->exists();
+		$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;
 
@@ -520,18 +520,18 @@ class UserController extends Controller
 	// 推广返利
 	public function referral()
 	{
-		if(Order::uid()->where('status', 2)->where('is_expire', 0)->where('origin_amount', '>', 0)->doesntExist()){
+		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>']);
 		}
 		$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()->where('status', 0)->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'])->where('referral_uid', Auth::user()->id)->orderBy('id', 'desc')->paginate(10, ['*'], 'user_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);
 	}
@@ -551,7 +551,7 @@ class UserController extends Controller
 		}
 
 		// 校验可以提现金额是否超过系统设置的阀值
-		$ref_amount = ReferralLog::uid()->where('status', 0)->sum('ref_amount');
+		$ref_amount = ReferralLog::uid()->whereStatus(0)->sum('ref_amount');
 		$ref_amount = $ref_amount/100;
 		if($ref_amount < self::$systemConfig['referral_money']){
 			return Response::json(['status' => 'fail', 'data' => '', 'message' => '申请失败:满'.self::$systemConfig['referral_money'].'元才可以提现,继续努力吧']);
@@ -559,7 +559,7 @@ class UserController extends Controller
 
 		// 取出本次申请关联返利日志ID
 		$link_logs = '';
-		$referralLog = ReferralLog::uid()->where('status', 0)->get();
+		$referralLog = ReferralLog::uid()->whereStatus(0)->get();
 		foreach($referralLog as $log){
 			$link_logs .= $log->id.',';
 		}
@@ -583,12 +583,12 @@ class UserController extends Controller
 		$view['articleList'] = Article::type(1)->orderBy('sort', 'desc')->orderBy('id', 'desc')->limit(10)->paginate(5);
 
 		//付费用户判断
-		$view['not_paying_user'] = Order::uid()->where('status', 2)->where('is_expire', 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';
 		// 订阅连接
-		$subscribe = UserSubscribe::query()->where('user_id', Auth::user()->id)->first();
+		$subscribe = UserSubscribe::query()->whereUserId(Auth::user()->id)->first();
 		$view['subscribe_status'] = $subscribe->status;
 		$subscribe_link = (self::$systemConfig['subscribe_domain']? self::$systemConfig['subscribe_domain'] : self::$systemConfig['website_url']).'/s/'.$subscribe->code;
 		$view['link'] = $subscribe_link;
@@ -642,14 +642,14 @@ 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->where('type', 3)->where('status', 0);
+			$query->whereType(3)->whereStatus(0);
 		}),]], ['coupon_sn.required' => '券码不能为空', 'coupon_sn.exists' => '该券不可用']);
 
 		if($validator->fails()){
 			return Response::json(['status' => 'fail', 'data' => '', 'message' => $validator->getMessageBag()->first()]);
 		}
 
-		$coupon = Coupon::query()->where('sn', $request->input('coupon_sn'))->first();
+		$coupon = Coupon::query()->whereSn($request->input('coupon_sn'))->first();
 
 		try{
 			DB::beginTransaction();

+ 1 - 1
app/Http/Models/Article.php

@@ -57,6 +57,6 @@ class Article extends Model
 	// 筛选类型
 	function scopeType($query, $type)
 	{
-		return $query->where('type', $type);
+		return $query->whereType($type);
 	}
 }

+ 1 - 1
app/Http/Models/Coupon.php

@@ -65,7 +65,7 @@ class Coupon extends Model
 	// 筛选类型
 	function scopeType($query, $type)
 	{
-		return $query->where('type', $type);
+		return $query->whereType($type);
 	}
 
 	function getAmountAttribute($value)

+ 1 - 1
app/Http/Models/Goods.php

@@ -79,7 +79,7 @@ class Goods extends Model
 
 	function scopeType($query, $type)
 	{
-		return $query->where('type', $type)->where('status', 1)->orderBy('sort', 'desc');
+		return $query->whereType($type)->whereStatus(1)->orderBy('sort', 'desc');
 	}
 
 	function label()

+ 1 - 1
app/Http/Models/Invite.php

@@ -56,7 +56,7 @@ class Invite extends Model
 
 	function scopeUid($query)
 	{
-		return $query->where('uid', Auth::user()->id);
+		return $query->whereUid(Auth::user()->id);
 	}
 
 	function generator()

+ 55 - 1
app/Http/Models/Order.php

@@ -33,6 +33,7 @@ use Illuminate\Support\Carbon;
  * @property-read Goods   $goods
  * @property-read Payment $payment
  * @property-read User    $user
+ * @property-read mixed   $pay_way_label
  * @method static Builder|Order newModelQuery()
  * @method static Builder|Order newQuery()
  * @method static Builder|Order query()
@@ -60,7 +61,7 @@ class Order extends Model
 
 	function scopeUid($query)
 	{
-		return $query->where('user_id', Auth::user()->id);
+		return $query->whereUserId(Auth::user()->id);
 	}
 
 	function user()
@@ -83,6 +84,30 @@ class Order extends Model
 		return $this->hasOne(Payment::class, 'oid', 'oid');
 	}
 
+	// 订单状态
+	function getStatusLabelAttribute()
+	{
+		switch($this->attributes['status']){
+			case -1:
+				$status_label = trans('home.invoice_status_closed');
+				break;
+			case 1:
+				$status_label = trans('home.invoice_status_wait_confirm');
+				break;
+			case 2:
+				$status_label = trans('home.invoice_status_payment_confirm');
+				break;
+			case 0:
+				$status_label = trans('home.invoice_status_wait_payment');
+				break;
+			default:
+				$status_label = 'Unknown';
+		}
+
+		return $status_label;
+	}
+
+
 	function getOriginAmountAttribute($value)
 	{
 		return $value/100;
@@ -102,4 +127,33 @@ class Order extends Model
 	{
 		return $this->attributes['amount'] = $value*100;
 	}
+
+	// 支付方式
+	function getPayWayLabelAttribute()
+	{
+		switch($this->attributes['pay_way']){
+			case 'balance':
+				$pay_way_label = '余额';
+				break;
+			case 'youzan':
+				$pay_way_label = '有赞云';
+				break;
+			case 'f2fpay':
+				$pay_way_label = '支付宝当面付';
+				break;
+			case 'codepay':
+				$pay_way_label = '码支付';
+				break;
+			case 'payjs':
+				$pay_way_label = 'PayJs';
+				break;
+			case 'bitpayx':
+				$pay_way_label = '麻瓜宝';
+				break;
+			default:
+				$pay_way_label = '未知';
+		}
+
+		return $pay_way_label;
+	}
 }

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

@@ -21,7 +21,6 @@ use Illuminate\Support\Carbon;
  * @property int             $status  状态:-1-支付失败、0-等待支付、1-支付成功
  * @property Carbon          $created_at
  * @property Carbon          $updated_at
- * @property-read mixed      $pay_way_label
  * @property-read mixed      $status_label
  * @property-read Order|null $order
  * @property-read User       $user
@@ -48,7 +47,7 @@ class Payment extends Model
 
 	function scopeUid($query)
 	{
-		return $query->where('user_id', Auth::user()->id);
+		return $query->whereUserId(Auth::user()->id);
 	}
 
 	function user()
@@ -88,19 +87,4 @@ class Payment extends Model
 
 		return $status_label;
 	}
-
-	// 支付方式
-	function getPayWayLabelAttribute()
-	{
-		switch($this->attributes['pay_way']){
-			case 1:
-				$pay_way_label = '微信';
-				break;
-			case 2:
-			default:
-				$pay_way_label = '支付宝';
-		}
-
-		return $pay_way_label;
-	}
 }

+ 1 - 1
app/Http/Models/ReferralApply.php

@@ -45,7 +45,7 @@ class ReferralApply extends Model
 
 	function scopeUid($query)
 	{
-		return $query->where('user_id', Auth::user()->id);
+		return $query->whereUserId(Auth::user()->id);
 	}
 
 	function User()

+ 1 - 1
app/Http/Models/ReferralLog.php

@@ -47,7 +47,7 @@ class ReferralLog extends Model
 
 	function scopeUid($query)
 	{
-		return $query->where('ref_user_id', Auth::user()->id);
+		return $query->whereRefUserId(Auth::user()->id);
 	}
 
 	function user()

+ 2 - 2
app/Http/Models/SsConfig.php

@@ -38,12 +38,12 @@ class SsConfig extends Model
 
 	function scopeDefault($query)
 	{
-		$query->where('is_default', 1);
+		$query->whereIsDefault(1);
 	}
 
 	// 筛选类型
 	function scopeType($query, $type)
 	{
-		$query->where('type', $type);
+		$query->whereType($type);
 	}
 }

+ 1 - 1
app/Http/Models/Ticket.php

@@ -42,7 +42,7 @@ class Ticket extends Model
 
 	function scopeUid($query)
 	{
-		return $query->where('user_id', Auth::user()->id);
+		return $query->whereUserId(Auth::user()->id);
 	}
 
 	function user()

+ 1 - 1
app/Http/Models/User.php

@@ -120,7 +120,7 @@ class User extends Authenticatable
 
 	function scopeUid($query)
 	{
-		return $query->where('id', Auth::user()->id);
+		return $query->whereId(Auth::user()->id);
 	}
 
 	function levelList()

+ 1 - 1
app/Http/Models/UserLabel.php

@@ -33,7 +33,7 @@ class UserLabel extends Model
 
 	function scopeUid($query)
 	{
-		return $query->where('user_id', Auth::user()->id);
+		return $query->whereUserId(Auth::user()->id);
 	}
 
 	function user()

+ 1 - 1
app/Http/Models/UserSubscribe.php

@@ -45,7 +45,7 @@ class UserSubscribe extends Model
 
 	function scopeUid($query)
 	{
-		return $query->where('user_id', Auth::user()->id);
+		return $query->whereUserId(Auth::user()->id);
 	}
 
 	function user()

+ 1 - 1
app/Http/Models/Verify.php

@@ -41,7 +41,7 @@ class Verify extends Model
 	// 筛选类型
 	function scopeType($query, $type)
 	{
-		return $query->where('type', $type);
+		return $query->whereType($type);
 	}
 
 	function user()

+ 1 - 1
app/Mail/activeUser.php

@@ -32,6 +32,6 @@ class activeUser extends Mailable implements ShouldQueue
 	// 发件失败处理
 	public function failed(Exception $e)
 	{
-		NotificationLog::query()->where('id', $this->id)->update(['status' => -1, 'error' => $e->getMessage()]);
+		NotificationLog::query()->whereId($this->id)->update(['status' => -1, 'error' => $e->getMessage()]);
 	}
 }

+ 1 - 1
app/Mail/closeTicket.php

@@ -35,6 +35,6 @@ class closeTicket extends Mailable implements ShouldQueue
 	// 发件失败处理
 	public function failed(Exception $e)
 	{
-		NotificationLog::query()->where('id', $this->id)->update(['status' => -1, 'error' => $e->getMessage()]);
+		NotificationLog::query()->whereId($this->id)->update(['status' => -1, 'error' => $e->getMessage()]);
 	}
 }

+ 1 - 1
app/Mail/newTicket.php

@@ -35,6 +35,6 @@ class newTicket extends Mailable implements ShouldQueue
 	// 发件失败处理
 	public function failed(Exception $e)
 	{
-		NotificationLog::query()->where('id', $this->id)->update(['status' => -1, 'error' => $e->getMessage()]);
+		NotificationLog::query()->whereId($this->id)->update(['status' => -1, 'error' => $e->getMessage()]);
 	}
 }

+ 2 - 2
app/Mail/nodeCrashWarning.php

@@ -23,7 +23,7 @@ class nodeCrashWarning extends Mailable implements ShouldQueue
 
 	public function build()
 	{
-		$view['content'] = NotificationLog::query()->where('id', $this->id)->first()->content;
+		$view['content'] = NotificationLog::query()->whereId($this->id)->first()->content;
 
 		return $this->view('emails.nodeCrashWarning', $view)->subject('节点阻断警告');
 	}
@@ -31,6 +31,6 @@ class nodeCrashWarning extends Mailable implements ShouldQueue
 	// 发件失败处理
 	public function failed(Exception $e)
 	{
-		NotificationLog::query()->where('id', $this->id)->update(['status' => -1, 'error' => $e->getMessage()]);
+		NotificationLog::query()->whereId($this->id)->update(['status' => -1, 'error' => $e->getMessage()]);
 	}
 }

+ 1 - 1
app/Mail/replyTicket.php

@@ -35,6 +35,6 @@ class replyTicket extends Mailable implements ShouldQueue
 	// 发件失败处理
 	public function failed(Exception $e)
 	{
-		NotificationLog::query()->where('id', $this->id)->update(['status' => -1, 'error' => $e->getMessage()]);
+		NotificationLog::query()->whereId($this->id)->update(['status' => -1, 'error' => $e->getMessage()]);
 	}
 }

+ 1 - 1
app/Mail/resetPassword.php

@@ -32,6 +32,6 @@ class resetPassword extends Mailable implements ShouldQueue
 	// 发件失败处理
 	public function failed(Exception $e)
 	{
-		NotificationLog::query()->where('id', $this->id)->update(['status' => -1, 'error' => $e->getMessage()]);
+		NotificationLog::query()->whereId($this->id)->update(['status' => -1, 'error' => $e->getMessage()]);
 	}
 }

+ 1 - 1
app/Mail/sendUserInfo.php

@@ -32,6 +32,6 @@ class sendUserInfo extends Mailable implements ShouldQueue
 	// 发件失败处理
 	public function failed(Exception $e)
 	{
-		NotificationLog::query()->where('id', $this->id)->update(['status' => -1, 'error' => $e->getMessage()]);
+		NotificationLog::query()->whereId($this->id)->update(['status' => -1, 'error' => $e->getMessage()]);
 	}
 }

+ 1 - 1
app/Mail/sendVerifyCode.php

@@ -32,6 +32,6 @@ class sendVerifyCode extends Mailable implements ShouldQueue
 	// 发件失败处理
 	public function failed(Exception $e)
 	{
-		NotificationLog::query()->where('id', $this->id)->update(['status' => -1, 'error' => $e->getMessage()]);
+		NotificationLog::query()->whereId($this->id)->update(['status' => -1, 'error' => $e->getMessage()]);
 	}
 }

+ 1 - 1
app/Mail/userExpireWarning.php

@@ -32,6 +32,6 @@ class userExpireWarning extends Mailable implements ShouldQueue
 	// 发件失败处理
 	public function failed(Exception $e)
 	{
-		NotificationLog::query()->where('id', $this->id)->update(['status' => -1, 'error' => $e->getMessage()]);
+		NotificationLog::query()->whereId($this->id)->update(['status' => -1, 'error' => $e->getMessage()]);
 	}
 }

+ 1 - 1
app/Mail/userExpireWarningToday.php

@@ -28,6 +28,6 @@ class userExpireWarningToday extends Mailable implements ShouldQueue
 	// 发件失败处理
 	public function failed(Exception $e)
 	{
-		NotificationLog::query()->where('id', $this->id)->update(['status' => -1, 'error' => $e->getMessage()]);
+		NotificationLog::query()->whereId($this->id)->update(['status' => -1, 'error' => $e->getMessage()]);
 	}
 }

+ 1 - 1
app/Mail/userTrafficWarning.php

@@ -32,6 +32,6 @@ class userTrafficWarning extends Mailable implements ShouldQueue
 	// 发件失败处理
 	public function failed(Exception $e)
 	{
-		NotificationLog::query()->where('id', $this->id)->update(['status' => -1, 'error' => $e->getMessage()]);
+		NotificationLog::query()->whereId($this->id)->update(['status' => -1, 'error' => $e->getMessage()]);
 	}
 }

+ 197 - 197
config/debugbar.php

@@ -2,201 +2,201 @@
 
 return [
 
-    /*
-     |--------------------------------------------------------------------------
-     | Debugbar Settings
-     |--------------------------------------------------------------------------
-     |
-     | Debugbar is enabled by default, when debug is set to true in app.php.
-     | You can override the value by setting enable to true or false instead of null.
-     |
-     | You can provide an array of URI's that must be ignored (eg. 'api/*')
-     |
-     */
-
-    'enabled' => env('DEBUGBAR_ENABLED', null),
-    'except' => [
-        'telescope*'
-    ],
-
-    /*
-     |--------------------------------------------------------------------------
-     | Storage settings
-     |--------------------------------------------------------------------------
-     |
-     | DebugBar stores data for session/ajax requests.
-     | You can disable this, so the debugbar stores data in headers/session,
-     | but this can cause problems with large data collectors.
-     | By default, file storage (in the storage folder) is used. Redis and PDO
-     | can also be used. For PDO, run the package migrations first.
-     |
-     */
-    'storage' => [
-        'enabled'    => true,
-        'driver'     => 'file', // redis, file, pdo, custom
-        'path'       => storage_path('debugbar'), // For file driver
-        'connection' => null,   // Leave null for default connection (Redis/PDO)
-        'provider'   => '' // Instance of StorageInterface for custom driver
-    ],
-
-    /*
-     |--------------------------------------------------------------------------
-     | Vendors
-     |--------------------------------------------------------------------------
-     |
-     | Vendor files are included by default, but can be set to false.
-     | This can also be set to 'js' or 'css', to only include javascript or css vendor files.
-     | Vendor files are for css: font-awesome (including fonts) and highlight.js (css files)
-     | and for js: jquery and and highlight.js
-     | So if you want syntax highlighting, set it to true.
-     | jQuery is set to not conflict with existing jQuery scripts.
-     |
-     */
-
-    'include_vendors' => true,
-
-    /*
-     |--------------------------------------------------------------------------
-     | Capture Ajax Requests
-     |--------------------------------------------------------------------------
-     |
-     | The Debugbar can capture Ajax requests and display them. If you don't want this (ie. because of errors),
-     | you can use this option to disable sending the data through the headers.
-     |
-     | Optionally, you can also send ServerTiming headers on ajax requests for the Chrome DevTools.
-     */
-
-    'capture_ajax' => true,
-    'add_ajax_timing' => false,
-
-    /*
-     |--------------------------------------------------------------------------
-     | Custom Error Handler for Deprecated warnings
-     |--------------------------------------------------------------------------
-     |
-     | When enabled, the Debugbar shows deprecated warnings for Symfony components
-     | in the Messages tab.
-     |
-     */
-    'error_handler' => false,
-
-    /*
-     |--------------------------------------------------------------------------
-     | Clockwork integration
-     |--------------------------------------------------------------------------
-     |
-     | The Debugbar can emulate the Clockwork headers, so you can use the Chrome
-     | Extension, without the server-side code. It uses Debugbar collectors instead.
-     |
-     */
-    'clockwork' => false,
-
-    /*
-     |--------------------------------------------------------------------------
-     | DataCollectors
-     |--------------------------------------------------------------------------
-     |
-     | Enable/disable DataCollectors
-     |
-     */
-
-    'collectors' => [
-        'phpinfo'         => true,  // Php version
-        'messages'        => true,  // Messages
-        'time'            => true,  // Time Datalogger
-        'memory'          => true,  // Memory usage
-        'exceptions'      => true,  // Exception displayer
-        'log'             => true,  // Logs from Monolog (merged in messages if enabled)
-        'db'              => true,  // Show database (PDO) queries and bindings
-        'views'           => true,  // Views with their data
-        'route'           => true,  // Current route information
-        'auth'            => false, // Display Laravel authentication status
-        'gate'            => true, // Display Laravel Gate checks
-        'session'         => true,  // Display session data
-        'symfony_request' => true,  // Only one can be enabled..
-        'mail'            => true,  // Catch mail messages
-        'laravel'         => false, // Laravel version and environment
-        'events'          => false, // All events fired
-        'default_request' => false, // Regular or special Symfony request logger
-        'logs'            => false, // Add the latest log messages
-        'files'           => false, // Show the included files
-        'config'          => false, // Display config settings
-        'cache'           => false, // Display cache events
-        'models'          => false, // Display models
-    ],
-
-    /*
-     |--------------------------------------------------------------------------
-     | Extra options
-     |--------------------------------------------------------------------------
-     |
-     | Configure some DataCollectors
-     |
-     */
-
-    'options' => [
-        'auth' => [
-            'show_name' => true,   // Also show the users name/email in the debugbar
-        ],
-        'db' => [
-            'with_params'       => true,   // Render SQL with the parameters substituted
-            'backtrace'         => true,   // Use a backtrace to find the origin of the query in your files.
-            'timeline'          => false,  // Add the queries to the timeline
-            'explain' => [                 // Show EXPLAIN output on queries
-                'enabled' => false,
-                'types' => ['SELECT'],     // // workaround ['SELECT'] only. https://github.com/barryvdh/laravel-debugbar/issues/888 ['SELECT', 'INSERT', 'UPDATE', 'DELETE']; for MySQL 5.6.3+
-            ],
-            'hints'             => true,    // Show hints for common mistakes
-        ],
-        'mail' => [
-            'full_log' => false
-        ],
-        'views' => [
-            'data' => false,    //Note: Can slow down the application, because the data can be quite large..
-        ],
-        'route' => [
-            'label' => true  // show complete route on bar
-        ],
-        'logs' => [
-            'file' => null
-        ],
-        'cache' => [
-            'values' => true // collect cache values
-        ],
-    ],
-
-    /*
-     |--------------------------------------------------------------------------
-     | Inject Debugbar in Response
-     |--------------------------------------------------------------------------
-     |
-     | Usually, the debugbar is added just before </body>, by listening to the
-     | Response after the App is done. If you disable this, you have to add them
-     | in your template yourself. See http://phpdebugbar.com/docs/rendering.html
-     |
-     */
-
-    'inject' => true,
-
-    /*
-     |--------------------------------------------------------------------------
-     | DebugBar route prefix
-     |--------------------------------------------------------------------------
-     |
-     | Sometimes you want to set route prefix to be used by DebugBar to load
-     | its resources from. Usually the need comes from misconfigured web server or
-     | from trying to overcome bugs like this: http://trac.nginx.org/nginx/ticket/97
-     |
-     */
-    'route_prefix' => '_debugbar',
-
-    /*
-     |--------------------------------------------------------------------------
-     | DebugBar route domain
-     |--------------------------------------------------------------------------
-     |
-     | By default DebugBar route served from the same domain that request served.
-     | To override default domain, specify it as a non-empty value.
-     */
-    'route_domain' => null,
+	/*
+	 |--------------------------------------------------------------------------
+	 | Debugbar Settings
+	 |--------------------------------------------------------------------------
+	 |
+	 | Debugbar is enabled by default, when debug is set to true in app.php.
+	 | You can override the value by setting enable to true or false instead of null.
+	 |
+	 | You can provide an array of URI's that must be ignored (eg. 'api/*')
+	 |
+	 */
+
+	'enabled' => env('DEBUGBAR_ENABLED', NULL),
+	'except'  => [
+		'telescope*'
+	],
+
+	/*
+	 |--------------------------------------------------------------------------
+	 | Storage settings
+	 |--------------------------------------------------------------------------
+	 |
+	 | DebugBar stores data for session/ajax requests.
+	 | You can disable this, so the debugbar stores data in headers/session,
+	 | but this can cause problems with large data collectors.
+	 | By default, file storage (in the storage folder) is used. Redis and PDO
+	 | can also be used. For PDO, run the package migrations first.
+	 |
+	 */
+	'storage' => [
+		'enabled'    => TRUE,
+		'driver'     => 'file', // redis, file, pdo, custom
+		'path'       => storage_path('debugbar'), // For file driver
+		'connection' => NULL,   // Leave null for default connection (Redis/PDO)
+		'provider'   => '' // Instance of StorageInterface for custom driver
+	],
+
+	/*
+	 |--------------------------------------------------------------------------
+	 | Vendors
+	 |--------------------------------------------------------------------------
+	 |
+	 | Vendor files are included by default, but can be set to false.
+	 | This can also be set to 'js' or 'css', to only include javascript or css vendor files.
+	 | Vendor files are for css: font-awesome (including fonts) and highlight.js (css files)
+	 | and for js: jquery and and highlight.js
+	 | So if you want syntax highlighting, set it to true.
+	 | jQuery is set to not conflict with existing jQuery scripts.
+	 |
+	 */
+
+	'include_vendors' => TRUE,
+
+	/*
+	 |--------------------------------------------------------------------------
+	 | Capture Ajax Requests
+	 |--------------------------------------------------------------------------
+	 |
+	 | The Debugbar can capture Ajax requests and display them. If you don't want this (ie. because of errors),
+	 | you can use this option to disable sending the data through the headers.
+	 |
+	 | Optionally, you can also send ServerTiming headers on ajax requests for the Chrome DevTools.
+	 */
+
+	'capture_ajax'    => TRUE,
+	'add_ajax_timing' => FALSE,
+
+	/*
+	 |--------------------------------------------------------------------------
+	 | Custom Error Handler for Deprecated warnings
+	 |--------------------------------------------------------------------------
+	 |
+	 | When enabled, the Debugbar shows deprecated warnings for Symfony components
+	 | in the Messages tab.
+	 |
+	 */
+	'error_handler'   => FALSE,
+
+	/*
+	 |--------------------------------------------------------------------------
+	 | Clockwork integration
+	 |--------------------------------------------------------------------------
+	 |
+	 | The Debugbar can emulate the Clockwork headers, so you can use the Chrome
+	 | Extension, without the server-side code. It uses Debugbar collectors instead.
+	 |
+	 */
+	'clockwork'       => FALSE,
+
+	/*
+	 |--------------------------------------------------------------------------
+	 | DataCollectors
+	 |--------------------------------------------------------------------------
+	 |
+	 | Enable/disable DataCollectors
+	 |
+	 */
+
+	'collectors' => [
+		'phpinfo'         => TRUE,  // Php version
+		'messages'        => TRUE,  // Messages
+		'time'            => TRUE,  // Time Datalogger
+		'memory'          => TRUE,  // Memory usage
+		'exceptions'      => TRUE,  // Exception displayer
+		'log'             => TRUE,  // Logs from Monolog (merged in messages if enabled)
+		'db'              => TRUE,  // Show database (PDO) queries and bindings
+		'views'           => TRUE,  // Views with their data
+		'route'           => TRUE,  // Current route information
+		'auth'            => FALSE, // Display Laravel authentication status
+		'gate'            => TRUE, // Display Laravel Gate checks
+		'session'         => TRUE,  // Display session data
+		'symfony_request' => TRUE,  // Only one can be enabled..
+		'mail'            => TRUE,  // Catch mail messages
+		'laravel'         => FALSE, // Laravel version and environment
+		'events'          => FALSE, // All events fired
+		'default_request' => FALSE, // Regular or special Symfony request logger
+		'logs'            => FALSE, // Add the latest log messages
+		'files'           => FALSE, // Show the included files
+		'config'          => FALSE, // Display config settings
+		'cache'           => FALSE, // Display cache events
+		'models'          => FALSE, // Display models
+	],
+
+	/*
+	 |--------------------------------------------------------------------------
+	 | Extra options
+	 |--------------------------------------------------------------------------
+	 |
+	 | Configure some DataCollectors
+	 |
+	 */
+
+	'options' => [
+		'auth'  => [
+			'show_name' => TRUE,   // Also show the users name/email in the debugbar
+		],
+		'db'    => [
+			'with_params' => TRUE,   // Render SQL with the parameters substituted
+			'backtrace'   => TRUE,   // Use a backtrace to find the origin of the query in your files.
+			'timeline'    => FALSE,  // Add the queries to the timeline
+			'explain'     => [                 // Show EXPLAIN output on queries
+				'enabled' => FALSE,
+				'types'   => ['SELECT'],     // // workaround ['SELECT'] only. https://github.com/barryvdh/laravel-debugbar/issues/888 ['SELECT', 'INSERT', 'UPDATE', 'DELETE']; for MySQL 5.6.3+
+			],
+			'hints'       => TRUE,    // Show hints for common mistakes
+		],
+		'mail'  => [
+			'full_log' => FALSE
+		],
+		'views' => [
+			'data' => FALSE,    //Note: Can slow down the application, because the data can be quite large..
+		],
+		'route' => [
+			'label' => TRUE  // show complete route on bar
+		],
+		'logs'  => [
+			'file' => NULL
+		],
+		'cache' => [
+			'values' => TRUE // collect cache values
+		],
+	],
+
+	/*
+	 |--------------------------------------------------------------------------
+	 | Inject Debugbar in Response
+	 |--------------------------------------------------------------------------
+	 |
+	 | Usually, the debugbar is added just before </body>, by listening to the
+	 | Response after the App is done. If you disable this, you have to add them
+	 | in your template yourself. See http://phpdebugbar.com/docs/rendering.html
+	 |
+	 */
+
+	'inject'       => TRUE,
+
+	/*
+	 |--------------------------------------------------------------------------
+	 | DebugBar route prefix
+	 |--------------------------------------------------------------------------
+	 |
+	 | Sometimes you want to set route prefix to be used by DebugBar to load
+	 | its resources from. Usually the need comes from misconfigured web server or
+	 | from trying to overcome bugs like this: http://trac.nginx.org/nginx/ticket/97
+	 |
+	 */
+	'route_prefix' => '_debugbar',
+
+	/*
+	 |--------------------------------------------------------------------------
+	 | DebugBar route domain
+	 |--------------------------------------------------------------------------
+	 |
+	 | By default DebugBar route served from the same domain that request served.
+	 | To override default domain, specify it as a non-empty value.
+	 */
+	'route_domain' => NULL,
 ];

+ 4 - 4
resources/views/admin/layouts.blade.php

@@ -145,9 +145,9 @@
 				<a href="javascript:void(0)">
 					<i class="site-menu-icon wb-chat-working" aria-hidden="true"></i>
 					<span class="site-menu-title">客服系统</span>
-					@if(\App\Http\Models\Ticket::query()->where('status','=','0')->count() > 0 )
+					@if(\App\Http\Models\Ticket::query()->whereStatus(0)->count() > 0 )
 						<div class="site-menu-badge">
-							<span class="badge badge-pill badge-success">{{\App\Http\Models\Ticket::query()->where('status','=','0')->count()}}</span>
+							<span class="badge badge-pill badge-success">{{\App\Http\Models\Ticket::query()->whereStatus(0)->count()}}</span>
 						</div>
 					@endif
 				</a>
@@ -155,9 +155,9 @@
 					<li class="site-menu-item {{in_array(Request::path(), ['ticket/ticketList', 'ticket/addTicket','ticket/replyTicket']) ? 'active open' : ''}}">
 						<a href="/ticket/ticketList" class="animsition-link">
 							<span class="site-menu-title">服务工单</span>
-							@if(\App\Http\Models\Ticket::query()->where('status','=','0')->count() > 0 )
+							@if(\App\Http\Models\Ticket::query()->whereStatus(0)->count() > 0 )
 								<div class="site-menu-label">
-									<span class="badge badge-danger badge-round mr-25">{{\App\Http\Models\Ticket::query()->where('status','=','0')->count()}}</span>
+									<span class="badge badge-danger badge-round mr-25">{{\App\Http\Models\Ticket::query()->whereStatus(0)->count()}}</span>
 								</div>
 							@endif
 						</a>

+ 7 - 15
resources/views/admin/orderList.blade.php

@@ -46,10 +46,12 @@
 					<div class="form-group col-lg-2 col-sm-6">
 						<select class="form-control" name="pay_way" id="pay_way" onChange="Search()">
 							<option value="" hidden>支付方式</option>
-							<option value="1">余额支付</option>
-							<option value="2">有赞云支付</option>
-							<option value="4">支付宝国际</option>
-							<option value="5">支付宝当面付</option>
+							<option value="balance">余额</option>
+							<option value="youzan">有赞云</option>
+							<option value="f2fpay">支付宝当面付</option>
+							<option value="codepay">码支付</option>
+							<option value="payjs">PayJs</option>
+							<option value="bitpayx">麻瓜宝</option>
 						</select>
 					</div>
 					<div class="form-group col-lg-2 col-sm-6">
@@ -117,17 +119,7 @@
 								<td> ¥{{$order->origin_amount}} </td>
 								<td> ¥{{$order->amount}} </td>
 								<td>
-									@if($order->pay_way == '1')
-										<span class="badge badge-lg badge-info"> 余额支付 </span>
-									@elseif($order->pay_way == '2')
-										<span class="badge badge-lg badge-info"> 有赞云支付 </span>
-									@elseif($order->pay_way == '4')
-										<span class="label label-info"> 支付宝国际 </span>
-									@elseif($order->pay_way == '5')
-										<span class="label label-info"> 支付宝当面付 </span>
-									@else
-										<span class="badge badge-lg badge-info"> 未知 </span>
-									@endif
+									<span class="badge badge-lg badge-info"> {{$order->pay_way_label}} </span>
 								</td>
 								<td>
 									@if($order->status == '-1')

+ 9 - 11
resources/views/user/buy.blade.php

@@ -53,7 +53,7 @@
 							<div class="float-right">
 								@include('user.components.purchase')
 								@if($goods->type <= 2)
-									<button class="btn btn-lg btn-primary" onclick="pay('1','0')"> {{trans('home.service_pay_button')}} </button>
+									<button class="btn btn-lg btn-primary" onclick="pay('balance','0')"> {{trans('home.service_pay_button')}} </button>
 								@endif
 							</div>
 						</div>
@@ -114,9 +114,9 @@
         }
 
         // 检查预支付
-        function checkPrePaid() {
+        function pay(method, pay_type) {
             // 存在套餐 和 购买类型为套餐时 出现提示
-            if ('{{$activePlan}}' === '1') {
+            if ('{{$activePlan}}' === '1' && '{{$goods->type}}' === '2') {
                 swal.fire({
                     title: '套餐存在冲突',
                     html: '<p>当前购买套餐将自动设置为 <code>预支付套餐</code><p><ol class="text-left"><li> 预支付套餐会在生效中的套餐失效后自动开通!</li><li> 您可以在支付后手动激活套餐!</li></ol>',
@@ -125,18 +125,16 @@
                     cancelButtonText: '返 回',
                     confirmButtonText: '继 续',
                 }).then((result) => {
-                    if (!result.value) {
-                        window.location.reload();
+                    if (result.value) {
+                        contiousPay(method, pay_type);
                     }
                 })
+            } else {
+                contiousPay(method, pay_type);
             }
         }
 
-        // 支付
-        function pay(method, pay_type) {
-            if('{{$goods->type}}' === '2'){
-                checkPrePaid();
-            }
+        function contiousPay(method, pay_type) {
             const goods_id = '{{$goods->id}}';
             const coupon_sn = $('#coupon_sn').val();
             $.ajax({
@@ -153,7 +151,7 @@
                             timer: 1300,
                             showConfirmButton: false
                         });
-                        if (pay_type === '1') {
+                        if (method === 'balance') {
                             swal.fire({title: ret.message, type: 'success', timer: 1000, showConfirmButton: false})
                                 .then(() => window.location.href = '/invoices')
                         }

+ 12 - 8
resources/views/user/invoiceDetail.blade.php

@@ -54,21 +54,25 @@
 						<tbody>
 						<tr>
 							<td>
-								<h3>{{$order->goods->name}}</h3>
+								<h3>{{empty($order->goods) ? ($order->goods_id == -1 ? '余额充值': trans('home.invoice_table_goods_deleted')) : $order->goods->name}}</h3>
 							</td>
 							<td>
-								{{trans('home.service_days')}} <code>{{$order->goods->days}}</code> {{trans('home.day')}}
-								<br/>
-								@if($order->goods->type == '2')
-									<code>{{$order->goods->traffic_label}}</code> {{trans('home.bandwidth')}}/{{trans('home.month')}}
+								@if($order->goods)
+									{{trans('home.service_days')}} <code>{{$order->goods->days}}</code> {{trans('home.day')}}
+									<br/>
+									@if($order->goods->type == '2')
+										<code>{{$order->goods->traffic_label}}</code> {{trans('home.bandwidth')}}/{{trans('home.month')}}
+									@else
+										<code>{{$order->goods->traffic_label}}</code> {{trans('home.bandwidth')}}/<code>{{$order->goods->days}}</code> {{trans('home.day')}}
+									@endif
 								@else
-									<code>{{$order->goods->traffic_label}}</code> {{trans('home.bandwidth')}}/<code>{{$order->goods->days}}</code> {{trans('home.day')}}
+									余额充值
 								@endif
 							</td>
-							<td><strong>¥</strong> {{$order->goods->price}} </td>
+							<td><strong>¥</strong> {{$order->origin_amount}} </td>
 							<td> 1</td>
 							<td>{{$order->coupon ? $order->coupon->name : '无'}}</td>
-							<td> ¥{{$order->goods->price}} </td>
+							<td> ¥{{$order->amount}} </td>
 							<td> {{$order->status_label}} </td>
 						</tr>
 						</tbody>

+ 1 - 1
resources/views/user/layouts.blade.php

@@ -170,7 +170,7 @@
 					<span class="site-menu-title">{{trans('home.invoices')}}</span>
 				</a>
 			</li>
-			@if(!\App\Http\Models\Order::uid()->where('status', 2)->where('is_expire', 0)->where('origin_amount', '>', 0)->doesntExist())
+			@if(!\App\Http\Models\Order::uid()->whereStatus(2)->where('is_expire', 0)->where('origin_amount', '>', 0)->doesntExist())
 				@if(\App\Components\Helpers::systemConfig()['is_invite_register'])
 					<li class="site-menu-item {{in_array(Request::path(), ['invite']) ? 'active open' : ''}}">
 						<a href="/invite">

+ 3 - 3
routes/web.php

@@ -17,9 +17,9 @@ Route::group(['middleware' => ['isForbidden', 'affiliate', 'isMaintenance']], fu
 	Route::get('makeVmessId', 'Controller@makeVmessId'); // 生成VmessId
 	Route::get('makeSecurityCode', 'Controller@makeSecurityCode'); // 生成网站安全码
 });
-Route::any('admin/login', 'AuthController@login')->middleware('isForbidden','isSecurity'); // 登录
+Route::any('admin/login', 'AuthController@login')->middleware('isForbidden', 'isSecurity'); // 登录
 
-Route::group(['middleware' => ['isForbidden','isAdminLogin', 'isAdmin']], function(){
+Route::group(['middleware' => ['isForbidden', 'isAdminLogin', 'isAdmin']], function(){
 	Route::group(['prefix' => 'admin'], function(){
 		Route::get('', 'AdminController@index'); // 后台首页
 		Route::get('userList', 'AdminController@userList'); // 账号列表
@@ -165,4 +165,4 @@ Route::group(['middleware' => ['isForbidden', 'isMaintenance', 'isLogin']], func
 		Route::get('getStatus', 'PaymentController@getStatus'); // 获取支付单状态
 		Route::get('{sn}', 'PaymentController@detail'); // 支付单详情
 	});
-});
+});

+ 8 - 2
sql/mod/20200422.sql

@@ -1,2 +1,8 @@
--- ÍÆËÍ֪ͨ ·½Ê½ÖØÖÃ
-update `config` SET `name` = 'is_notification', `value` = '0' where `config`.`id` = 39;
+-- 推�通知 方��置
+update `config` SET `name` = 'is_notification', `value` = '0' where `config`.`id` = 39;
+
+-- 修改支付方�命�
+alter table `order` CHANGE `pay_way` `pay_way` VARCHAR(20) NOT NULL DEFAULT '1' COMMENT '支付方�:balance�f2fpay�codepay�payjs�bitpayx等';
+UPDATE `order` SET `pay_way`= 'balance' WHERE pay_way = '1';
+UPDATE `order` SET `pay_way`= 'youzan' WHERE pay_way = '2';
+UPDATE `order` SET `pay_way`= 'f2fpay' WHERE pay_way = '5';