Эх сурвалжийг харах

面板 等级化-标签化 转换工具

兔姬桑 4 жил өмнө
parent
commit
3e3ecffa82

+ 41 - 0
app/Console/Commands/updateUserLevel.php

@@ -0,0 +1,41 @@
+<?php
+
+namespace App\Console\Commands;
+
+use App\Models\Goods;
+use App\Models\Order;
+use App\Models\User;
+use Illuminate\Console\Command;
+use Log;
+
+class updateUserLevel extends Command {
+	protected $signature = 'updateUserLevel';
+	protected $description = '更新用户等级';
+
+	public function __construct() {
+		parent::__construct();
+	}
+
+	public function handle() {
+		Log::info('----------------------------【用户等级升级】开始----------------------------');
+		// 预设level 0
+		$users = User::query()->where('level', '<>', 0)->get();
+		foreach($users as $user){
+			User::query()->whereId($user->id)->update(['level' => 0]);
+		}
+		// 获取商品列表,取新等级
+		$goodList = Goods::query()->where('level', '<>', 0)->whereType(2)->get();
+		// 取生效的套餐
+		$orderList = Order::query()->whereIn('goods_id', $goodList->pluck('id')->toArray())->whereStatus(2)->whereIsExpire(0)->get();
+		foreach($orderList as $order){
+			$ret = User::query()->whereId($order->user_id)->update(['level' => $order->goods->level]);
+
+			if($ret){
+				Log::info('用户: '.$order->user->id.', 按照订单'.$order->id.' 等级为'.$order->goods->level);
+			}else{
+				Log::error('用户: '.$order->user->id.' 等级更新失败!');
+			}
+		}
+		Log::info('----------------------------【用户等级升级】结束----------------------------');
+	}
+}

+ 9 - 4
resources/views/admin/shop/goodsInfo.blade.php

@@ -38,12 +38,17 @@
 					<strong>错误:</strong> {{$errors->first()}}
 				</div>
 			@endif
+			@if (Session::has('errorMsg'))
+				<div class="alert alert-success alert-dismissible" role="alert">
+					<button type="button" class="close" data-dismiss="alert" aria-label="Close">
+						<span aria-hidden="true">×</span>
+					</button>
+					{{Session::get('errorMsg')}}
+				</div>
+			@endif
 			<div class="panel-body">
 				<form action=@isset($goods){{url('/shop/edit?id='.$goods->id)}} @else {{url('/shop/add')}} @endisset"" method="post" enctype="multipart/form-data" class="form-horizontal" role="form">
 					{{csrf_field()}}
-					<label>
-						<input name="id" hidden/>
-					</label>
 					<div class="form-row">
 						<div class="col-lg-6 col-md-12">
 							<div class="form-group row">
@@ -223,7 +228,7 @@
 			$("#sort").val('{{$goods->sort}}')
 			$("#color").asColorPicker('val', '{{$goods->color}}')
 			$("#description").val('{{$goods->description}}')
-			$("#info").val('{{$goods->info}}')
+			$("#info").val('{!! $goods->info !!}')
 		})
 		@elseif(old('type'))
 		$(document).ready(function () {

+ 1 - 0
resources/views/user/nodeList.blade.php

@@ -19,6 +19,7 @@
 							</div>
 							<div class="col-8 text-break text-right">
 								<p class="font-size-20 blue-600">
+									<span class="badge badge-pill up m-0 badge-default">{{$node->getLevel->name}}</span>
 									@if($node->offline)
 										<i class="red-600 icon wb-warning" data-content="线路不稳定/维护中" data-trigger="hover" data-toggle="popover" data-placement="top"></i>
 									@endif

+ 1 - 1
sql/db.sql

@@ -36,7 +36,7 @@ CREATE TABLE `ss_node`
     `relay_port`     SMALLINT(5) UNSIGNED NULL     DEFAULT 0 COMMENT '中转端口',
     `level`          TINYINT(3) UNSIGNED  NOT NULL DEFAULT '0' COMMENT '等级:0-无等级,全部可见',
     `speed_limit`    BIGINT(20) UNSIGNED  NOT NULL DEFAULT '0' COMMENT '节点限速,为0表示不限速,单位Byte',
-    `client_limit`   TINYINT(3) UNSIGNED  NOT NULL DEFAULT 0 COMMENT '设备数限制',
+    `client_limit`   SMALLINT(5) UNSIGNED NOT NULL DEFAULT 0 COMMENT '设备数限制',
     `description`    VARCHAR(255)         NULL     DEFAULT NULL COMMENT '节点简单描述',
     `method`         VARCHAR(32)          NOT NULL DEFAULT 'aes-256-cfb' COMMENT '加密方式',
     `protocol`       VARCHAR(64)          NOT NULL DEFAULT 'origin' COMMENT '协议',

+ 1 - 1
sql/mod/20200711.sql

@@ -4,4 +4,4 @@ ALTER TABLE `ticket`
 ALTER TABLE `ticket_reply`
     ADD `admin_id` INT(10) UNSIGNED DEFAULT '0' COMMENT '管理员ID' AFTER `user_id`;
 
---升级sql后 运行 php artisan updateTicket 更新工单
+-- 升级sql后 运行 php artisan updateTicket 更新工单

+ 16 - 0
sql/mod/20200713.sql

@@ -0,0 +1,16 @@
+-- 请选择性 更新本文件! 以往ssrpanel使用label(标签)来区分用户的,可以使用本文件清理label, 再升级为用level(等级)区分的新版本
+-- Optional update! For original ssrpanel update Label to Level as new way to rank the user-node.
+
+DROP TABLE IF EXISTS `ss_node_label`;
+CREATE TABLE `ss_node_label`
+(
+    `id`       INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
+    `node_id`  INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '节点ID',
+    `label_id` INT(10) UNSIGNED NOT NULL DEFAULT '0' COMMENT '标签ID',
+    PRIMARY KEY (`id`),
+    INDEX `idx_node_label` (`node_id`, `label_id`)
+) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT ='节点标签';
+
+-- 更新sql之后 | After sql update
+-- 运行升级命令前, 请先给商品【套餐】加上等级,再运行 php artisan updateUserLevel 来更新等级; 别忘了同样要给节点加等级 和 标签!
+-- Before apply level, set up goods in the level your want in the goods edition page, then run 'php artisan updateUserLevel' to update Level; Don't forget add level and label to nodes afterward.