Просмотр исходного кода

使用数据迁移和播种机,更方便的更新数据库

zhangjiangbin 8 лет назад
Родитель
Сommit
c2c48c6f32
48 измененных файлов с 1756 добавлено и 108 удалено
  1. 15 12
      app/Console/Commands/AutoBanSubscribeJob.php
  2. 18 14
      app/Console/Commands/AutoBanUserJob.php
  3. 18 13
      app/Console/Commands/AutoCheckNodeStatusJob.php
  4. 14 11
      app/Console/Commands/AutoClearLogJob.php
  5. 18 11
      app/Console/Commands/AutoResetUserTrafficJob.php
  6. 16 11
      app/Console/Commands/UserExpireWarningJob.php
  7. 17 12
      app/Console/Commands/UserTrafficWarningJob.php
  8. 40 0
      database/migrations/2017_12_29_134159_create_article_table.php
  9. 49 0
      database/migrations/2017_12_29_135653_create_article_log_table.php
  10. 7 8
      database/migrations/2017_12_29_135722_create_config_table.php
  11. 8 6
      database/migrations/2017_12_29_135738_create_country_table.php
  12. 45 0
      database/migrations/2017_12_29_135751_create_coupon_table.php
  13. 37 0
      database/migrations/2017_12_29_135804_create_coupon_log_table.php
  14. 38 0
      database/migrations/2017_12_29_135816_create_email_log_table.php
  15. 45 0
      database/migrations/2017_12_29_135828_create_goods_table.php
  16. 39 0
      database/migrations/2017_12_29_135839_create_invite_table.php
  17. 36 0
      database/migrations/2017_12_29_135850_create_level_table.php
  18. 44 0
      database/migrations/2017_12_29_135900_create_order_table.php
  19. 42 0
      database/migrations/2017_12_29_135915_create_order_goods_table.php
  20. 40 0
      database/migrations/2017_12_29_135948_create_referral_apply_table.php
  21. 40 0
      database/migrations/2017_12_29_140008_create_referral_log_table.php
  22. 38 0
      database/migrations/2017_12_29_140026_create_ss_config_table.php
  23. 36 0
      database/migrations/2017_12_29_140038_create_ss_group_table.php
  24. 34 0
      database/migrations/2017_12_29_140049_create_ss_group_node_table.php
  25. 59 0
      database/migrations/2017_12_29_140101_create_ss_node_table.php
  26. 38 0
      database/migrations/2017_12_29_140111_create_ss_node_info_table.php
  27. 37 0
      database/migrations/2017_12_29_140125_create_ss_node_online_log_table.php
  28. 41 0
      database/migrations/2017_12_29_140140_create_ss_node_traffic_daily_table.php
  29. 41 0
      database/migrations/2017_12_29_140153_create_ss_node_traffic_hourly_table.php
  30. 37 0
      database/migrations/2017_12_29_140205_create_ticket_table.php
  31. 36 0
      database/migrations/2017_12_29_140216_create_ticket_reply_table.php
  32. 72 0
      database/migrations/2017_12_29_140229_create_user_table.php
  33. 41 0
      database/migrations/2017_12_29_140239_create_user_balance_log_table.php
  34. 40 0
      database/migrations/2017_12_29_140253_create_user_ban_log_table.php
  35. 40 0
      database/migrations/2017_12_29_140304_create_user_score_log_table.php
  36. 40 0
      database/migrations/2017_12_29_140319_create_user_subscribe_table.php
  37. 36 0
      database/migrations/2017_12_29_140330_create_user_subscribe_log_table.php
  38. 44 0
      database/migrations/2017_12_29_140345_create_user_traffic_daily_table.php
  39. 44 0
      database/migrations/2017_12_29_140357_create_user_traffic_hourly_table.php
  40. 43 0
      database/migrations/2017_12_29_140409_create_user_traffic_log_table.php
  41. 38 0
      database/migrations/2017_12_29_140422_create_verify_table.php
  42. 60 0
      database/seeds/ConfigTableSeeder.php
  43. 73 0
      database/seeds/CountryTableSeeder.php
  44. 22 0
      database/seeds/LevelTableSeeder.php
  45. 52 0
      database/seeds/SsConfigTableSeeder.php
  46. 54 0
      database/seeds/UserTableSeeder.php
  47. 32 8
      readme.md
  48. 2 2
      resources/views/admin/layouts.blade.php

+ 15 - 12
app/Console/Commands/AutoBanSubscribeJob.php

@@ -13,31 +13,23 @@ class AutoBanSubscribeJob extends Command
     protected $signature = 'command:autoBanSubscribeJob';
     protected $description = '自动封禁异常订阅链接';
 
-    protected static $config;
-
     public function __construct()
     {
         parent::__construct();
-
-        $config = Config::query()->get();
-        $data = [];
-        foreach ($config as $vo) {
-            $data[$vo->name] = $vo->value;
-        }
-
-        self::$config = $data;
     }
 
     public function handle()
     {
+        $config = $this->systemConfig();
+
         // 封禁24小时访问异常的订阅链接
-        if (self::$config['is_subscribe_ban']) {
+        if ($config['is_subscribe_ban']) {
             $subscribeList = UserSubscribe::query()->where('status', 1)->get();
             if (!$subscribeList->isEmpty()) {
                 foreach ($subscribeList as $subscribe) {
                     // 24小时内的请求次数
                     $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');
-                    if ($request_times >= self::$config['subscribe_ban_times']) {
+                    if ($request_times >= $config['subscribe_ban_times']) {
                         UserSubscribe::query()->where('id', $subscribe->id)->update(['status' => 0, 'ban_time' => time(), 'ban_desc' => '存在异常,自动封禁']);
                     }
                 }
@@ -46,4 +38,15 @@ class AutoBanSubscribeJob extends Command
 
         Log::info('定时任务:' . $this->description);
     }
+
+    // 系统配置
+    private function systemConfig() {
+        $config = Config::query()->get();
+        $data = [];
+        foreach ($config as $vo) {
+            $data[$vo->name] = $vo->value;
+        }
+
+        return $data;
+    }
 }

+ 18 - 14
app/Console/Commands/AutoBanUserJob.php

@@ -14,35 +14,27 @@ class AutoBanUserJob extends Command
     protected $signature = 'command:autoBanUserJob';
     protected $description = '自动封禁用户';
 
-    protected static $config;
-
     public function __construct()
     {
         parent::__construct();
-
-        $config = Config::query()->get();
-        $data = [];
-        foreach ($config as $vo) {
-            $data[$vo->name] = $vo->value;
-        }
-
-        self::$config = $data;
     }
 
     public function handle()
     {
+        $config = $this->systemConfig();
+
         // 封禁24小时内流量异常账号
-        if (self::$config['is_traffic_ban']) {
+        if ($config['is_traffic_ban']) {
             $userList = User::query()->where('status', '>=', 0)->where('enable', 1)->get();
             foreach ($userList as $user) {
                 $time = date('Y-m-d H:i:s', time() - 24 * 60 * 60);
                 $totalTraffic = UserTrafficHourly::query()->where('user_id', $user->id)->where('node_id', 0)->where('created_at', '>=', $time)->sum('total');
-                if ($totalTraffic >= (self::$config['traffic_ban_value'] * 1024 * 1024 * 1024)) {
-                    $ban_time = date('Y-m-d H:i:s', strtotime("+" . self::$config['traffic_ban_time'] . " minutes"));
+                if ($totalTraffic >= ($config['traffic_ban_value'] * 1024 * 1024 * 1024)) {
+                    $ban_time = date('Y-m-d H:i:s', strtotime("+" . $config['traffic_ban_time'] . " minutes"));
                     User::query()->where('id', $user->id)->update(['enable' => 0, 'ban_time' => $ban_time]);
 
                     // 写入日志
-                    $this->log($user->id, self::$config['traffic_ban_time'], '【自动封禁】-流量异常');
+                    $this->log($user->id, $config['traffic_ban_time'], '【自动封禁】-流量异常');
                 }
             }
         }
@@ -50,6 +42,18 @@ class AutoBanUserJob extends Command
         Log::info('定时任务:' . $this->description);
     }
 
+    // 系统配置
+    private function systemConfig()
+    {
+        $config = Config::query()->get();
+        $data = [];
+        foreach ($config as $vo) {
+            $data[$vo->name] = $vo->value;
+        }
+
+        return $data;
+    }
+
     private function log($user_id, $minutes, $desc)
     {
         $log = new UserBanLog();

+ 18 - 13
app/Console/Commands/AutoCheckNodeStatusJob.php

@@ -18,23 +18,16 @@ class AutoCheckNodeStatusJob extends Command
     protected $signature = 'command:autoCheckNodeStatusJob';
     protected $description = '自动监测节点是否宕机';
     protected $cacheKey = 'node_shutdown_warning_';
-    protected static $config;
 
     public function __construct()
     {
         parent::__construct();
-
-        $config = Config::query()->get();
-        $data = [];
-        foreach ($config as $vo) {
-            $data[$vo->name] = $vo->value;
-        }
-
-        self::$config = $data;
     }
 
     public function handle()
     {
+        $config = $this->systemConfig();
+
         $nodeList = SsNode::query()->where('status', 1)->get();
         foreach ($nodeList as $node) {
             // 10分钟内无节点信息则认为是宕机,因为每个节点的负载信息最多保存10分钟
@@ -49,9 +42,9 @@ class AutoCheckNodeStatusJob extends Command
                 $content = "系统监测到节点【{$node->name}】({$node->server})可能宕机了,请及时检查。";
 
                 // 发邮件通知管理员
-                if (self::$config['is_node_crash_warning'] && self::$config['crash_warning_email']) {
+                if ($config['is_node_crash_warning'] && $config['crash_warning_email']) {
                     try {
-                        Mail::to(self::$config['crash_warning_email'])->send(new nodeCrashWarning(self::$config['website_name'], $node->name, $node->server));
+                        Mail::to($config['crash_warning_email'])->send(new nodeCrashWarning($config['website_name'], $node->name, $node->server));
                         $this->sendEmailLog(1, $title, $content);
                     } catch (\Exception $e) {
                         $this->sendEmailLog(1, $title, $content, 0, $e->getMessage());
@@ -62,9 +55,9 @@ class AutoCheckNodeStatusJob extends Command
                 }
 
                 // 通过ServerChan发微信消息提醒管理员
-                if (self::$config['is_server_chan'] && self::$config['server_chan_key']) {
+                if ($config['is_server_chan'] && $config['server_chan_key']) {
                     $serverChan = new ServerChan();
-                    $result = $serverChan->send($title, $content, self::$config['server_chan_key']);
+                    $result = $serverChan->send($title, $content, $config['server_chan_key']);
                     if ($result->errno > 0) {
                         $this->sendEmailLog(1, '[ServerChan]' . $title, $content);
                     } else {
@@ -99,4 +92,16 @@ class AutoCheckNodeStatusJob extends Command
         $emailLogObj->created_at = date('Y-m-d H:i:s');
         $emailLogObj->save();
     }
+
+    // 系统配置
+    private function systemConfig()
+    {
+        $config = Config::query()->get();
+        $data = [];
+        foreach ($config as $vo) {
+            $data[$vo->name] = $vo->value;
+        }
+
+        return $data;
+    }
 }

+ 14 - 11
app/Console/Commands/AutoClearLogJob.php

@@ -16,24 +16,16 @@ class AutoClearLogJob extends Command
     protected $signature = 'command:autoClearLogJob';
     protected $description = '自动清除日志';
 
-    protected static $config;
-
     public function __construct()
     {
         parent::__construct();
-
-        $config = Config::query()->get();
-        $data = [];
-        foreach ($config as $vo) {
-            $data[$vo->name] = $vo->value;
-        }
-
-        self::$config = $data;
     }
 
     public function handle()
     {
-        if (self::$config['is_clear_log']) {
+        $config = $this->systemConfig();
+
+        if ($config['is_clear_log']) {
             // 自动清除10分钟以前的节点负载信息日志
             SsNodeInfo::query()->where('log_time', '<=', strtotime(date('Y-m-d H:i:s', strtotime("-10 minutes"))))->delete();
 
@@ -52,4 +44,15 @@ class AutoClearLogJob extends Command
 
         Log::info('定时任务:' . $this->description);
     }
+
+    // 系统配置
+    private function systemConfig() {
+        $config = Config::query()->get();
+        $data = [];
+        foreach ($config as $vo) {
+            $data[$vo->name] = $vo->value;
+        }
+
+        return $data;
+    }
 }

+ 18 - 11
app/Console/Commands/AutoResetUserTrafficJob.php

@@ -12,24 +12,17 @@ class AutoResetUserTrafficJob extends Command
 {
     protected $signature = 'command:autoResetUserTrafficJob';
     protected $description = '自动重置用户可用流量';
-    protected static $config;
 
     public function __construct()
     {
         parent::__construct();
-
-        $config = Config::query()->get();
-        $data = [];
-        foreach ($config as $vo) {
-            $data[$vo->name] = $vo->value;
-        }
-
-        self::$config = $data;
     }
 
     public function handle()
     {
-        if (self::$config['reset_traffic']) {
+        $config = $this->systemConfig();
+
+        if ($config['reset_traffic']) {
             $userList = User::query()->where('status', '>=', 0)->where('enable', 1)->get();
             foreach ($userList as $user) {
                 if (!$user->traffic_reset_day) {
@@ -37,7 +30,9 @@ class AutoResetUserTrafficJob extends Command
                 }
 
                 // 取出用户最后购买的有效套餐
-                $order = Order::query()->with(['user', 'goods'])->whereHas('goods', function ($q) { $q->where('type', 2); })->where('user_id', $user->id)->where('is_expire', 0)->orderBy('oid', 'desc')->first();
+                $order = Order::query()->with(['user', 'goods'])->whereHas('goods', function ($q) {
+                    $q->where('type', 2);
+                })->where('user_id', $user->id)->where('is_expire', 0)->orderBy('oid', 'desc')->first();
                 if (!$order) {
                     continue;
                 }
@@ -61,4 +56,16 @@ class AutoResetUserTrafficJob extends Command
 
         Log::info('定时任务:' . $this->description);
     }
+
+    // 系统配置
+    private function systemConfig()
+    {
+        $config = Config::query()->get();
+        $data = [];
+        foreach ($config as $vo) {
+            $data[$vo->name] = $vo->value;
+        }
+
+        return $data;
+    }
 }

+ 16 - 11
app/Console/Commands/UserExpireWarningJob.php

@@ -20,19 +20,13 @@ class UserExpireWarningJob extends Command
     public function __construct()
     {
         parent::__construct();
-
-        $config = Config::query()->get();
-        $data = [];
-        foreach ($config as $vo) {
-            $data[$vo->name] = $vo->value;
-        }
-
-        self::$config = $data;
     }
 
     public function handle()
     {
-        if (self::$config['expire_warning']) {
+        $config = $this->systemConfig();
+
+        if ($config['expire_warning']) {
             $userList = User::query()->where('transfer_enable', '>', 0)->whereIn('status', [0, 1])->where('enable', 1)->get();
             foreach ($userList as $user) {
                 // 用户名不是邮箱的跳过
@@ -41,12 +35,12 @@ class UserExpireWarningJob extends Command
                 }
 
                 $lastCanUseDays = floor(round(strtotime($user->expire_time) - strtotime(date('Y-m-d H:i:s'))) / 3600 / 24);
-                if ($lastCanUseDays > 0 && $lastCanUseDays <= self::$config['expire_days']) {
+                if ($lastCanUseDays > 0 && $lastCanUseDays <= $config['expire_days']) {
                     $title = '账号过期提醒';
                     $content = '账号还剩' . $lastCanUseDays . '天即将过期';
 
                     try {
-                        Mail::to($user->username)->send(new userExpireWarning(self::$config['website_name'], $lastCanUseDays));
+                        Mail::to($user->username)->send(new userExpireWarning($config['website_name'], $lastCanUseDays));
                         $this->sendEmailLog($user->id, $title, $content);
                     } catch (\Exception $e) {
                         $this->sendEmailLog($user->id, $title, $content, 0, $e->getMessage());
@@ -77,4 +71,15 @@ class UserExpireWarningJob extends Command
         $emailLogObj->created_at = date('Y-m-d H:i:s');
         $emailLogObj->save();
     }
+
+    // 系统配置
+    private function systemConfig() {
+        $config = Config::query()->get();
+        $data = [];
+        foreach ($config as $vo) {
+            $data[$vo->name] = $vo->value;
+        }
+
+        return $data;
+    }
 }

+ 17 - 12
app/Console/Commands/UserTrafficWarningJob.php

@@ -20,19 +20,13 @@ class UserTrafficWarningJob extends Command
     public function __construct()
     {
         parent::__construct();
-
-        $config = Config::query()->get();
-        $data = [];
-        foreach ($config as $vo) {
-            $data[$vo->name] = $vo->value;
-        }
-
-        self::$config = $data;
     }
 
     public function handle()
     {
-        if (self::$config['traffic_warning']) {
+        $config = $this->systemConfig();
+
+        if ($config['traffic_warning']) {
             $userList = User::query()->where('transfer_enable', '>', 0)->whereIn('status', [0, 1])->where('enable', 1)->get();
             foreach ($userList as $user) {
                 // 用户名不是邮箱的跳过
@@ -41,12 +35,12 @@ class UserTrafficWarningJob extends Command
                 }
 
                 $usedPercent = round(($user->d + $user->u) / $user->transfer_enable, 2) * 100; // 已使用流量百分比
-                if ($usedPercent >= self::$config['traffic_warning_percent']) {
+                if ($usedPercent >= $config['traffic_warning_percent']) {
                     $title = '流量警告';
-                    $content = '流量已使用:' . $usedPercent . '%,超过设置的流量阈值' . self::$config['traffic_warning_percent'] . '%';
+                    $content = '流量已使用:' . $usedPercent . '%,超过设置的流量阈值' . $config['traffic_warning_percent'] . '%';
 
                     try {
-                        Mail::to($user->username)->send(new userTrafficWarning(self::$config['website_name'], $usedPercent));
+                        Mail::to($user->username)->send(new userTrafficWarning($config['website_name'], $usedPercent));
                         $this->sendEmailLog($user->id, $title, $content);
                     } catch (\Exception $e) {
                         $this->sendEmailLog($user->id, $title, $content, 0, $e->getMessage());
@@ -77,4 +71,15 @@ class UserTrafficWarningJob extends Command
         $emailLogObj->created_at = date('Y-m-d H:i:s');
         $emailLogObj->save();
     }
+
+    // 系统配置
+    private function systemConfig() {
+        $config = Config::query()->get();
+        $data = [];
+        foreach ($config as $vo) {
+            $data[$vo->name] = $vo->value;
+        }
+
+        return $data;
+    }
 }

+ 40 - 0
database/migrations/2017_12_29_134159_create_article_table.php

@@ -0,0 +1,40 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateArticleTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('article', function (Blueprint $table) {
+            $table->engine = 'InnoDB';
+
+            $table->increments('id');
+            $table->string('title', 100)->comment('文章标题');
+            $table->string('author', 50)->comment('作者');
+            $table->text('content')->comment('文章内容')->nullable();
+            $table->tinyInteger('is_del')->default('0')->comment('是否删除');
+            $table->tinyInteger('type')->comment('类型:1-文章、2-公告');
+            $table->integer('sort')->default('0')->comment('排序');
+            $table->dateTime('created_at')->nullable();
+            $table->dateTime('updated_at')->nullable();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('article');
+    }
+}

+ 49 - 0
database/migrations/2017_12_29_135653_create_article_log_table.php

@@ -0,0 +1,49 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateArticleLogTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('article_log', function (Blueprint $table) {
+            $table->engine = 'InnoDB';
+
+            $table->increments('id');
+            $table->integer('aid')->default('0')->comment('文章ID');
+            $table->string('lat', 50)->comment('纬度');
+            $table->string('lng', 50)->comment('经度');
+            $table->string('ip', 30)->comment('IP地址');
+            $table->text('headers')->comment('浏览器头部信息')->nullable();
+            $table->string('nation', 255)->comment('国家');
+            $table->string('province', 255)->comment('省');
+            $table->string('city', 255)->comment('市');
+            $table->string('district', 255)->comment('区');
+            $table->string('street', 255)->comment('街道');
+            $table->string('street_number', 255)->comment('门牌');
+            $table->string('address', 255)->comment('地址');
+            $table->text('full')->comment('地图完整请求数据')->nullable();
+            $table->tinyInteger('is_pull')->default('0')->comment('是否获取拉取地址信息');
+            $table->tinyInteger('status')->default('0')->comment('状态:0-未查看、1-已查看');
+            $table->dateTime('created_at')->nullable();
+            $table->dateTime('updated_at')->nullable();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('article_log');
+    }
+}

+ 7 - 8
database/migrations/2014_10_12_000000_create_users_table.php → database/migrations/2017_12_29_135722_create_config_table.php

@@ -4,7 +4,7 @@ use Illuminate\Support\Facades\Schema;
 use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Database\Migrations\Migration;
 
-class CreateUsersTable extends Migration
+class CreateConfigTable extends Migration
 {
     /**
      * Run the migrations.
@@ -13,13 +13,12 @@ class CreateUsersTable extends Migration
      */
     public function up()
     {
-        Schema::create('users', function (Blueprint $table) {
+        Schema::create('config', function (Blueprint $table) {
+            $table->engine = 'InnoDB';
+
             $table->increments('id');
-            $table->string('name');
-            $table->string('email')->unique();
-            $table->string('password');
-            $table->rememberToken();
-            $table->timestamps();
+            $table->string('name', 255)->comment('配置名');
+            $table->string('value', 255)->comment('配置值');
         });
     }
 
@@ -30,6 +29,6 @@ class CreateUsersTable extends Migration
      */
     public function down()
     {
-        Schema::dropIfExists('users');
+        Schema::dropIfExists('config');
     }
 }

+ 8 - 6
database/migrations/2014_10_12_100000_create_password_resets_table.php → database/migrations/2017_12_29_135738_create_country_table.php

@@ -4,7 +4,7 @@ use Illuminate\Support\Facades\Schema;
 use Illuminate\Database\Schema\Blueprint;
 use Illuminate\Database\Migrations\Migration;
 
-class CreatePasswordResetsTable extends Migration
+class CreateCountryTable extends Migration
 {
     /**
      * Run the migrations.
@@ -13,10 +13,12 @@ class CreatePasswordResetsTable extends Migration
      */
     public function up()
     {
-        Schema::create('password_resets', function (Blueprint $table) {
-            $table->string('email')->index();
-            $table->string('token');
-            $table->timestamp('created_at')->nullable();
+        Schema::create('country', function (Blueprint $table) {
+            $table->engine = 'MyISAM';
+
+            $table->increments('id');
+            $table->string('country_name', 50)->comment('名称');
+            $table->string('country_code', 10)->comment('代码');
         });
     }
 
@@ -27,6 +29,6 @@ class CreatePasswordResetsTable extends Migration
      */
     public function down()
     {
-        Schema::dropIfExists('password_resets');
+        Schema::dropIfExists('country');
     }
 }

+ 45 - 0
database/migrations/2017_12_29_135751_create_coupon_table.php

@@ -0,0 +1,45 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateCouponTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('coupon', function (Blueprint $table) {
+            $table->engine = 'InnoDB';
+
+            $table->increments('id');
+            $table->string('name', 50)->comment('优惠券名称');
+            $table->string('logo', 255)->comment('优惠券LOGO');
+            $table->char('sn', 8)->comment('优惠券码');
+            $table->tinyInteger('type')->default('1')->comment('类型:1-现金优惠、2-折扣优惠');
+            $table->tinyInteger('usage')->default('1')->comment('用途:1-仅限一次性使用、2-可重复使用');
+            $table->integer('amount')->default('0')->comment('金额,单位分');
+            $table->decimal('discount', 10, 2)->default('0.00')->comment('折扣');
+            $table->integer('available_start')->comment('有效期开始');
+            $table->integer('available_end')->comment('有效期结束');
+            $table->tinyInteger('is_del')->default('0')->comment('是否已删除:0-未删除、1-已删除');
+            $table->tinyInteger('status')->default('1')->comment('状态:0-未使用、1-已使用、2-已失效');
+            $table->dateTime('created_at')->nullable();
+            $table->dateTime('updated_at')->nullable();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('coupon');
+    }
+}

+ 37 - 0
database/migrations/2017_12_29_135804_create_coupon_log_table.php

@@ -0,0 +1,37 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateCouponLogTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('coupon_log', function (Blueprint $table) {
+            $table->engine = 'InnoDB';
+
+            $table->increments('id');
+            $table->integer('coupon_id')->default('0')->comment('优惠券ID');
+            $table->integer('goods_id')->default('0')->comment('商品ID');
+            $table->integer('order_id')->default('0')->comment('订单ID');
+            $table->dateTime('created_at')->nullable();
+            $table->dateTime('updated_at')->nullable();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('coupon_log');
+    }
+}

+ 38 - 0
database/migrations/2017_12_29_135816_create_email_log_table.php

@@ -0,0 +1,38 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateEmailLogTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('email_log', function (Blueprint $table) {
+            $table->engine = 'InnoDB';
+
+            $table->increments('id');
+            $table->integer('user_id')->default('0')->comment('接收者ID');
+            $table->string('title', 255)->comment('邮件标题');
+            $table->text('content')->comment('邮件内容')->nullable();
+            $table->tinyInteger('status')->comment('状态:1-发送成功、2-发送失败');
+            $table->text('error')->comment('发送失败抛出的异常信息')->nullable();
+            $table->dateTime('created_at');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('email_log');
+    }
+}

+ 45 - 0
database/migrations/2017_12_29_135828_create_goods_table.php

@@ -0,0 +1,45 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateGoodsTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('goods', function (Blueprint $table) {
+            $table->engine = 'InnoDB';
+
+            $table->increments('id');
+            $table->string('sku', 15)->comment('商品服务SKU')->nullable();
+            $table->string('name', 100)->comment('商品名称');
+            $table->string('logo', 255)->comment('商品图片地址');
+            $table->bigInteger('traffic')->default('0')->comment('商品内含多少流量,单位Mib');
+            $table->integer('score')->default('0')->comment('商品价值多少积分');
+            $table->tinyInteger('type')->default('1')->comment('商品类型:1-流量包、2-套餐');
+            $table->integer('price')->default('0')->comment('商品售价,单位分');
+            $table->string('desc', 255)->comment('商品描述')->nullable();
+            $table->integer('days')->default('30')->comment('有效期');
+            $table->tinyInteger('is_del')->default('0')->comment('是否已删除:0-否、1-是');
+            $table->tinyInteger('status')->default('1')->comment('状态:0-下架、1-上架');
+            $table->dateTime('created_at')->nullable();
+            $table->dateTime('updated_at')->nullable();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('goods');
+    }
+}

+ 39 - 0
database/migrations/2017_12_29_135839_create_invite_table.php

@@ -0,0 +1,39 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateInviteTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('invite', function (Blueprint $table) {
+            $table->engine = 'InnoDB';
+
+            $table->increments('id');
+            $table->integer('uid')->default('0')->comment('邀请人ID');
+            $table->integer('fuid')->default('0')->comment('受邀人ID');
+            $table->char('code', 32)->comment('邀请码');
+            $table->tinyInteger('status')->default('0')->comment('邀请码状态:0-未使用、1-已使用、2-已过期');
+            $table->dateTime('dateline')->comment('有效期至')->nullable();
+            $table->dateTime('created_at')->nullable();
+            $table->dateTime('updated_at')->nullable();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('invite');
+    }
+}

+ 36 - 0
database/migrations/2017_12_29_135850_create_level_table.php

@@ -0,0 +1,36 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateLevelTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('level', function (Blueprint $table) {
+            $table->engine = 'InnoDB';
+
+            $table->increments('id');
+            $table->integer('level')->default('1')->comment('等级');
+            $table->string('level_name', 100)->comment('等级名称');
+            $table->dateTime('created_at')->nullable();
+            $table->dateTime('updated_at')->nullable();;
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('level');
+    }
+}

+ 44 - 0
database/migrations/2017_12_29_135900_create_order_table.php

@@ -0,0 +1,44 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateOrderTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('order', function (Blueprint $table) {
+            $table->engine = 'InnoDB';
+
+            $table->increments('oid');
+            $table->string('orderId', 20)->comment('订单编号');
+            $table->integer('user_id')->default('0')->comment('操作人');
+            $table->integer('goods_id')->default('0')->comment('商品ID');
+            $table->integer('coupon_id')->default('0')->comment('优惠券ID');
+            $table->integer('totalOriginalPrice')->default('0')->comment('订单原始总价,单位分');
+            $table->integer('totalPrice')->default('0')->comment('订单总价,单位分');
+            $table->dateTime('expire_at')->comment('过期时间')->nullable();
+            $table->tinyInteger('is_expire')->default('0')->comment('是否已过期:0-未过期、1-已过期');
+            $table->tinyInteger('pay_way')->default('1')->comment('支付方式:1-余额支付、2-PayPal');
+            $table->tinyInteger('status')->default('0')->comment('订单状态:-1-已关闭、0-待支付、1-已支付待确认、2-已完成');
+            $table->dateTime('created_at')->nullable();
+            $table->dateTime('updated_at')->nullable();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('order');
+    }
+}

+ 42 - 0
database/migrations/2017_12_29_135915_create_order_goods_table.php

@@ -0,0 +1,42 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateOrderGoodsTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('order_goods', function (Blueprint $table) {
+            $table->engine = 'InnoDB';
+
+            $table->increments('id');
+            $table->integer('oid')->default('0')->comment('订单ID');
+            $table->string('orderId', 20)->comment('订单编号');
+            $table->integer('user_id')->default('0')->comment('用户ID');
+            $table->integer('goods_id')->default('0')->comment('商品ID');
+            $table->integer('num')->default('0')->comment('商品数量');
+            $table->integer('original_price')->default('0')->comment('商品原价,单位分');
+            $table->integer('price')->default('0')->comment('商品实际价格,单位分');
+            $table->tinyInteger('is_expire')->default('0')->comment('是否已过期:0-未过期、1-已过期');
+            $table->dateTime('created_at')->nullable();
+            $table->dateTime('updated_at')->nullable();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('order_goods');
+    }
+}

+ 40 - 0
database/migrations/2017_12_29_135948_create_referral_apply_table.php

@@ -0,0 +1,40 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateReferralApplyTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('referral_apply', function (Blueprint $table) {
+            $table->engine = 'InnoDB';
+
+            $table->increments('id');
+            $table->integer('user_id')->default('0')->comment('用户ID');
+            $table->integer('before')->default('0')->comment('操作前可提现金额');
+            $table->integer('after')->default('0')->comment('操作后可提现金额');
+            $table->integer('amount')->default('0')->comment('本次提现金额');
+            $table->string('link_logs', 255)->comment('关联返利日志ID,例如:1,3,4')->nullable();
+            $table->tinyInteger('status')->default('0')->comment('状态:-1-驳回、0-待审核、1-审核通过待打款、2-已打款');
+            $table->dateTime('created_at')->nullable();
+            $table->dateTime('updated_at')->nullable();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('referral_apply');
+    }
+}

+ 40 - 0
database/migrations/2017_12_29_140008_create_referral_log_table.php

@@ -0,0 +1,40 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateReferralLogTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('referral_log', function (Blueprint $table) {
+            $table->engine = 'InnoDB';
+
+            $table->increments('id');
+            $table->integer('user_id')->default('0')->comment('用户ID');
+            $table->integer('ref_user_id')->default('0')->comment('推广人ID');
+            $table->integer('order_id')->default('0')->comment('关联订单ID');
+            $table->integer('amount')->default('0')->comment('消费金额,单位分');
+            $table->integer('ref_amount')->default('0')->comment('返利金额');
+            $table->tinyInteger('status')->default('0')->comment('状态:0-未提现、1-审核中、2-已提现');
+            $table->dateTime('created_at')->nullable();
+            $table->dateTime('updated_at')->nullable();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('referral_log');
+    }
+}

+ 38 - 0
database/migrations/2017_12_29_140026_create_ss_config_table.php

@@ -0,0 +1,38 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateSsConfigTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('ss_config', function (Blueprint $table) {
+            $table->engine = 'InnoDB';
+
+            $table->increments('id');
+            $table->string('name', 50)->default('0')->comment('配置名');
+            $table->tinyInteger('type')->default('1')->comment('类型:1-加密方式、2-协议、3-混淆');
+            $table->tinyInteger('is_default')->default('0')->comment('是否默认:0-不是、1-是');
+            $table->integer('sort')->default('0')->comment('排序:值越大排越前');
+            $table->dateTime('created_at')->nullable();
+            $table->dateTime('updated_at')->nullable();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('ss_config');
+    }
+}

+ 36 - 0
database/migrations/2017_12_29_140038_create_ss_group_table.php

@@ -0,0 +1,36 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateSsGroupTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('ss_group', function (Blueprint $table) {
+            $table->engine = 'InnoDB';
+
+            $table->increments('id');
+            $table->string('name', 50)->comment('分组名称');
+            $table->tinyInteger('level')->default('1')->comment('分组级别');
+            $table->dateTime('created_at')->nullable();
+            $table->dateTime('updated_at')->nullable();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('ss_group');
+    }
+}

+ 34 - 0
database/migrations/2017_12_29_140049_create_ss_group_node_table.php

@@ -0,0 +1,34 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateSsGroupNodeTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('ss_group_node', function (Blueprint $table) {
+            $table->engine = 'InnoDB';
+
+            $table->increments('id');
+            $table->integer('group_id')->default('0')->comment('分组ID');
+            $table->integer('node_id')->default('0')->comment('节点ID');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('ss_group_node');
+    }
+}

+ 59 - 0
database/migrations/2017_12_29_140101_create_ss_node_table.php

@@ -0,0 +1,59 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateSsNodeTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('ss_node', function (Blueprint $table) {
+            $table->engine = 'InnoDB';
+
+            $table->increments('id');
+            $table->string('name', 128)->comment('名称');
+            $table->integer('group_id')->default('0')->comment('所属分组');
+            $table->char('country_code', 5)->comment('国家代码');
+            $table->string('server', 128)->comment('服务器地址');
+            $table->string('desc', 255)->comment('节点简单描述');
+            $table->string('method', 30)->default('aes-192-ctr')->comment('加密方式');
+            $table->string('custom_method', 30)->default('aes-192-ctr')->comment('自定义加密方式');
+            $table->string('protocol', 128)->default('auth_chain_a')->comment('协议');
+            $table->string('protocol_param', 128)->comment('协议参数');
+            $table->string('obfs', 128)->default('tls1.2_ticket_auth')->comment('混淆');
+            $table->string('obfs_param', 128)->comment('混淆参数');
+            $table->float('traffic_rate')->default('1')->comment('流量比率');
+            $table->integer('bandwidth')->default('100')->comment('出口带宽,单位M');
+            $table->bigInteger('traffic')->default('1000')->comment('每月可用流量,单位G');
+            $table->string('monitor_url', 255)->comment('监控地址');
+            $table->tinyInteger('compatible')->default('0')->comment('兼容SS');
+            $table->tinyInteger('single')->default('0')->comment('单端口多用户');
+            $table->tinyInteger('single_force')->comment('模式:0-兼容模式、1-严格模式');
+            $table->string('single_port', 50)->comment('端口号,用,号分隔');
+            $table->string('single_passwd', 50)->comment('密码');
+            $table->string('single_method', 128)->comment('加密方式');
+            $table->string('single_protocol', 128)->comment('协议');
+            $table->string('single_obfs', 128)->comment('混淆');
+            $table->integer('sort')->default('0')->comment('排序值,值越大越靠前显示');
+            $table->tinyInteger('status')->default('1')->comment('状态:0-维护、1-正常');
+            $table->dateTime('created_at')->nullable();
+            $table->dateTime('updated_at')->nullable();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('ss_node');
+    }
+}

+ 38 - 0
database/migrations/2017_12_29_140111_create_ss_node_info_table.php

@@ -0,0 +1,38 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateSsNodeInfoTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('ss_node_info', function (Blueprint $table) {
+            $table->engine = 'InnoDB';
+
+            $table->increments('id');
+            $table->integer('node_id')->default('0')->comment('节点ID');
+            $table->float('uptime')->comment('更新时间');
+            $table->string('load', 32)->comment('负载');
+            $table->integer('log_time')->comment('记录时间');
+
+            $table->index('node_id');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('ss_node_info');
+    }
+}

+ 37 - 0
database/migrations/2017_12_29_140125_create_ss_node_online_log_table.php

@@ -0,0 +1,37 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateSsNodeOnlineLogTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('ss_node_online_log', function (Blueprint $table) {
+            $table->engine = 'InnoDB';
+
+            $table->increments('id');
+            $table->integer('node_id')->default('0')->comment('节点ID');
+            $table->integer('online_user')->default('0')->comment('在线用户数');
+            $table->integer('log_time')->default('0')->comment('记录时间');
+
+            $table->index('node_id');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('ss_node_online_log');
+    }
+}

+ 41 - 0
database/migrations/2017_12_29_140140_create_ss_node_traffic_daily_table.php

@@ -0,0 +1,41 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateSsNodeTrafficDailyTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('ss_node_traffic_daily', function (Blueprint $table) {
+            $table->engine = 'InnoDB';
+
+            $table->increments('id');
+            $table->integer('node_id')->default('0')->comment('节点ID');
+            $table->bigInteger('u')->default('0')->comment('上传流量');
+            $table->bigInteger('d')->default('0')->comment('下载流量');
+            $table->bigInteger('total')->default('0')->comment('总流量');
+            $table->string('traffic', 255)->comment('总流量(带单位)');
+            $table->dateTime('created_at')->nullable();
+            $table->dateTime('updated_at')->nullable();
+
+            $table->index('node_id');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('ss_node_traffic_daily');
+    }
+}

+ 41 - 0
database/migrations/2017_12_29_140153_create_ss_node_traffic_hourly_table.php

@@ -0,0 +1,41 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateSsNodeTrafficHourlyTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('ss_node_traffic_hourly', function (Blueprint $table) {
+            $table->engine = 'InnoDB';
+
+            $table->increments('id');
+            $table->integer('node_id')->default('0')->comment('节点ID');
+            $table->bigInteger('u')->default('0')->comment('上传流量');
+            $table->bigInteger('d')->default('0')->comment('下载流量');
+            $table->bigInteger('total')->default('0')->comment('总流量');
+            $table->string('traffic', 255)->comment('总流量(带单位)');
+            $table->dateTime('created_at')->nullable();
+            $table->dateTime('updated_at')->nullable();
+
+            $table->index('node_id');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('ss_node_traffic_hourly');
+    }
+}

+ 37 - 0
database/migrations/2017_12_29_140205_create_ticket_table.php

@@ -0,0 +1,37 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateTicketTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('ticket', function (Blueprint $table) {
+            $table->engine = 'InnoDB';
+
+            $table->increments('id');
+            $table->integer('user_id')->default('0')->comment('用户ID');
+            $table->string('title', 255)->comment('标题');
+            $table->text('content')->comment('内容');
+            $table->tinyInteger('status')->default('0')->comment('状态:0-待处理、1-已处理未关闭、2-已关闭');
+            $table->dateTime('created_at');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('ticket');
+    }
+}

+ 36 - 0
database/migrations/2017_12_29_140216_create_ticket_reply_table.php

@@ -0,0 +1,36 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateTicketReplyTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('ticket_reply', function (Blueprint $table) {
+            $table->engine = 'InnoDB';
+
+            $table->increments('id');
+            $table->integer('ticket_id')->default('0')->comment('工单ID');
+            $table->integer('user_id')->default('0')->comment('回复人ID');
+            $table->text('content')->comment('回复内容')->nullable();
+            $table->dateTime('created_at');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('ticket_reply');
+    }
+}

+ 72 - 0
database/migrations/2017_12_29_140229_create_user_table.php

@@ -0,0 +1,72 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateUserTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('user', function (Blueprint $table) {
+            $table->engine = 'InnoDB';
+
+            $table->increments('id');
+            $table->string('username', 128)->comment('用户名');
+            $table->string('password', 64)->comment('密码');
+            $table->integer('port')->default('0')->comment('SS端口');
+            $table->string('passwd', 16)->comment('SS密码');
+            $table->bigInteger('transfer_enable')->default('1073741824000')->comment('可用流量,单位字节,默认1TiB');
+            $table->bigInteger('u')->default('0')->comment('已上传流量,单位字节');
+            $table->bigInteger('d')->default('0')->comment('已下载流量,单位字节');
+            $table->integer('t')->default('0')->comment('最后使用时间');
+            $table->tinyInteger('enable')->default('1')->comment('SS状态');
+            $table->string('method', 30)->default('aes-192-ctr')->comment('加密方式');
+            $table->string('custom_method', 30)->default('aes-192-ctr')->comment('自定义加密方式');
+            $table->string('protocol', 30)->default('auth_chain_a')->comment('协议');
+            $table->string('protocol_param', 255)->comment('协议参数');
+            $table->string('obfs', 30)->default('tls1.2_ticket_auth')->comment('混淆');
+            $table->string('obfs_param', 255)->comment('混淆参数');
+            $table->integer('speed_limit_per_con')->default('204800')->comment('单连接限速,默认200M,单位KB');
+            $table->integer('speed_limit_per_user')->default('204800')->comment('单用户限速,默认200M,单位KB');
+            $table->tinyInteger('gender')->default('1')->comment('性别:0-女、1-男');
+            $table->string('wechat', 30)->comment('微信');
+            $table->string('qq', 20)->comment('QQ');
+            $table->tinyInteger('usage')->default('1')->comment('用途:1-手机、2-电脑、3-路由器、4-其他');
+            $table->tinyInteger('pay_way')->default('3')->comment('付费方式:0-免费、1-月付、2-半年付、3-年付');
+            $table->decimal('balance', 10, 2)->default('0.00')->comment('余额');
+            $table->integer('score')->default('0')->comment('积分');
+            $table->dateTime('enable_time')->comment('开通日期');
+            $table->dateTime('expire_time')->default('2099-01-01')->comment('过期时间');
+            $table->integer('ban_time')->default('0')->comment('封禁到期时间');
+            $table->text('remark')->comment('备注');
+            $table->tinyInteger('level')->default('1')->comment('等级');
+            $table->tinyInteger('is_admin')->default('0')->comment('是否管理员:0-否、1-是');
+            $table->string('reg_ip', 20)->default('127.0.0.1')->comment('注册IP');
+            $table->integer('last_login')->default('0')->comment('最后一次登录时间');
+            $table->integer('referral_uid')->default('0')->comment('邀请人');
+            $table->tinyInteger('traffic_reset_day')->default('0')->comment('流量自动重置日,0表示不重置');
+            $table->tinyInteger('status')->default('0')->comment('状态:-1-禁用、0-未激活、1-正常');
+            $table->string('remember_token', 255)->nullable();
+            $table->dateTime('created_at')->nullable();
+            $table->dateTime('updated_at')->nullable();
+
+            $table->unique('port');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('user');
+    }
+}

+ 41 - 0
database/migrations/2017_12_29_140239_create_user_balance_log_table.php

@@ -0,0 +1,41 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateUserBalanceLogTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('user_balance_log', function (Blueprint $table) {
+            $table->engine = 'InnoDB';
+
+            $table->increments('id');
+            $table->integer('user_id')->default('0')->comment('用户ID');
+            $table->integer('order_id')->default('0')->comment('订单ID');
+            $table->integer('before')->default('0')->comment('发生前余额,单位分');
+            $table->integer('after')->default('0')->comment('发生后金额,单位分');
+            $table->integer('amount')->default('0')->comment('发生金额,单位分');
+            $table->string('desc', 255)->comment('操作描述');
+            $table->dateTime('created_at');
+
+            $table->index('user_id');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('user_balance_log');
+    }
+}

+ 40 - 0
database/migrations/2017_12_29_140253_create_user_ban_log_table.php

@@ -0,0 +1,40 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateUserBanLogTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('user_ban_log', function (Blueprint $table) {
+            $table->engine = 'InnoDB';
+
+            $table->increments('id');
+            $table->integer('user_id')->default('0')->comment('用户ID');
+            $table->integer('minutes')->default('0')->comment('封禁账号时长,单位分钟');
+            $table->string('desc', 255)->comment('操作描述');
+            $table->tinyInteger('status')->default('0')->comment('状态:0-未处理、1-已处理');
+            $table->dateTime('created_at')->nullable();
+            $table->dateTime('updated_at')->nullable();
+
+            $table->index('user_id');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('user_ban_log');
+    }
+}

+ 40 - 0
database/migrations/2017_12_29_140304_create_user_score_log_table.php

@@ -0,0 +1,40 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateUserScoreLogTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('user_score_log', function (Blueprint $table) {
+            $table->engine = 'InnoDB';
+
+            $table->increments('id');
+            $table->integer('user_id')->default('0')->comment('用户ID');
+            $table->integer('before')->default('0')->comment('发生前的积分值');
+            $table->integer('after')->default('0')->comment('发生后的积分值');
+            $table->integer('score')->default('0')->comment('发生值');
+            $table->string('desc', 50)->comment('描述');
+            $table->dateTime('created_at');
+
+            $table->index('user_id');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('user_score_log');
+    }
+}

+ 40 - 0
database/migrations/2017_12_29_140319_create_user_subscribe_table.php

@@ -0,0 +1,40 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateUserSubscribeTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('user_subscribe', function (Blueprint $table) {
+            $table->engine = 'InnoDB';
+
+            $table->increments('id');
+            $table->integer('user_id')->default('0')->comment('用户ID');
+            $table->string('code', 20)->comment('订阅地址唯一识别码');
+            $table->integer('times')->default('0')->comment('地址请求次数');
+            $table->tinyInteger('status')->default('1')->comment('状态:0-禁用、1-启用');
+            $table->integer('ban_time')->default('0')->comment('封禁时间');
+            $table->string('ban_desc', 50)->comment('封禁理由');
+            $table->dateTime('created_at')->nullable();
+            $table->dateTime('updated_at')->nullable();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('user_subscribe');
+    }
+}

+ 36 - 0
database/migrations/2017_12_29_140330_create_user_subscribe_log_table.php

@@ -0,0 +1,36 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateUserSubscribeLogTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('user_subscribe_log', function (Blueprint $table) {
+            $table->engine = 'InnoDB';
+
+            $table->increments('id');
+            $table->integer('sid')->default('0')->comment('对应user_subscribe的id');
+            $table->string('request_ip', 20)->default('127.0.0.1')->comment('请求IP');
+            $table->dateTime('request_time')->comment('请求时间');
+            $table->text('request_header')->comment('请求头部信息');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('user_subscribe_log');
+    }
+}

+ 44 - 0
database/migrations/2017_12_29_140345_create_user_traffic_daily_table.php

@@ -0,0 +1,44 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateUserTrafficDailyTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('user_traffic_daily', function (Blueprint $table) {
+            $table->engine = 'InnoDB';
+
+            $table->increments('id');
+            $table->integer('user_id')->default('0')->comment('用户ID');
+            $table->integer('node_id')->default('0')->comment('节点ID,0表示统计全部节点');
+            $table->bigInteger('u')->default('0')->comment('上传流量');
+            $table->bigInteger('d')->default('0')->comment('下载流量');
+            $table->bigInteger('total')->default('0')->comment('总流量');
+            $table->string('traffic', 255)->comment('总流量(带单位)');
+            $table->dateTime('created_at')->nullable();
+            $table->dateTime('updated_at')->nullable();
+
+            $table->index('user_id');
+            $table->index('node_id');
+            $table->index(['user_id', 'node_id']);
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('user_traffic_daily');
+    }
+}

+ 44 - 0
database/migrations/2017_12_29_140357_create_user_traffic_hourly_table.php

@@ -0,0 +1,44 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateUserTrafficHourlyTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('user_traffic_hourly', function (Blueprint $table) {
+            $table->engine = 'InnoDB';
+
+            $table->increments('id');
+            $table->integer('user_id')->default('0')->comment('用户ID');
+            $table->integer('node_id')->default('0')->comment('节点ID,0表示统计全部节点');
+            $table->bigInteger('u')->default('0')->comment('上传流量');
+            $table->bigInteger('d')->default('0')->comment('下载流量');
+            $table->bigInteger('total')->default('0')->comment('总流量');
+            $table->string('traffic', 255)->comment('总流量(带单位)');
+            $table->dateTime('created_at')->nullable();
+            $table->dateTime('updated_at')->nullable();
+
+            $table->index('user_id');
+            $table->index('node_id');
+            $table->index(['user_id', 'node_id']);
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('user_traffic_hourly');
+    }
+}

+ 43 - 0
database/migrations/2017_12_29_140409_create_user_traffic_log_table.php

@@ -0,0 +1,43 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateUserTrafficLogTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('user_traffic_log', function (Blueprint $table) {
+            $table->engine = 'InnoDB';
+
+            $table->increments('id');
+            $table->integer('user_id')->default('0')->comment('用户ID');
+            $table->integer('u')->default('0')->comment('上传流量');
+            $table->integer('d')->default('0')->comment('下载流量');
+            $table->integer('node_id')->default('0')->comment('节点ID');
+            $table->float('rate')->comment('流量比例');
+            $table->string('traffic', 32)->comment('产生流量');
+            $table->integer('log_time')->comment('记录时间');
+
+            $table->index('user_id');
+            $table->index('node_id');
+            $table->index(['user_id', 'node_id']);
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('user_traffic_log');
+    }
+}

+ 38 - 0
database/migrations/2017_12_29_140422_create_verify_table.php

@@ -0,0 +1,38 @@
+<?php
+
+use Illuminate\Support\Facades\Schema;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class CreateVerifyTable extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::create('verify', function (Blueprint $table) {
+            $table->engine = 'InnoDB';
+
+            $table->increments('id');
+            $table->integer('user_id')->default('0')->comment('用户ID');
+            $table->string('username', 50)->comment('用户名');
+            $table->string('token', 32)->comment('校验token');
+            $table->tinyInteger('status')->default('0')->comment('状态:0-未使用、1-已使用、2-已失效');
+            $table->dateTime('created_at')->nullable();
+            $table->dateTime('updated_at')->nullable();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        Schema::dropIfExists('verify');
+    }
+}

+ 60 - 0
database/seeds/ConfigTableSeeder.php

@@ -0,0 +1,60 @@
+<?php
+
+use Illuminate\Database\Seeder;
+
+class ConfigTableSeeder extends Seeder
+{
+    /**
+     * Run the database seeds.
+     *
+     * @return void
+     */
+    public function run()
+    {
+        DB::insert("INSERT INTO `config` VALUES ('1', 'is_rand_port', 0);");
+        DB::insert("INSERT INTO `config` VALUES ('2', 'is_user_rand_port', 0);");
+        DB::insert("INSERT INTO `config` VALUES ('3', 'invite_num', 3);");
+        DB::insert("INSERT INTO `config` VALUES ('4', 'is_register', 1);");
+        DB::insert("INSERT INTO `config` VALUES ('5', 'is_invite_register', 1);");
+        DB::insert("INSERT INTO `config` VALUES ('6', 'website_name', 'SSRPanel');");
+        DB::insert("INSERT INTO `config` VALUES ('7', 'is_reset_password', 1);");
+        DB::insert("INSERT INTO `config` VALUES ('8', 'reset_password_times', 3);");
+        DB::insert("INSERT INTO `config` VALUES ('9', 'website_url', 'http://www.ssrpanel.com');");
+        DB::insert("INSERT INTO `config` VALUES ('10', 'is_active_register', 1);");
+        DB::insert("INSERT INTO `config` VALUES ('11', 'active_times', 3);");
+        DB::insert("INSERT INTO `config` VALUES ('12', 'login_add_score', 1);");
+        DB::insert("INSERT INTO `config` VALUES ('13', 'min_rand_score', 1);");
+        DB::insert("INSERT INTO `config` VALUES ('14', 'max_rand_score', 100);");
+        DB::insert("INSERT INTO `config` VALUES ('15', 'wechat_qrcode', '');");
+        DB::insert("INSERT INTO `config` VALUES ('16', 'alipay_qrcode', '');");
+        DB::insert("INSERT INTO `config` VALUES ('17', 'login_add_score_range', 1440);");
+        DB::insert("INSERT INTO `config` VALUES ('18', 'referral_traffic', 1024);");
+        DB::insert("INSERT INTO `config` VALUES ('19', 'referral_percent', 0.2);");
+        DB::insert("INSERT INTO `config` VALUES ('20', 'referral_money', 100);");
+        DB::insert("INSERT INTO `config` VALUES ('21', 'referral_status', 1);");
+        DB::insert("INSERT INTO `config` VALUES ('22', 'default_traffic', 1024);");
+        DB::insert("INSERT INTO `config` VALUES ('23', 'traffic_warning', 0);");
+        DB::insert("INSERT INTO `config` VALUES ('24', 'traffic_warning_percent', 80);");
+        DB::insert("INSERT INTO `config` VALUES ('25', 'expire_warning', 0);");
+        DB::insert("INSERT INTO `config` VALUES ('26', 'expire_days', 15);");
+        DB::insert("INSERT INTO `config` VALUES ('27', 'reset_traffic', 1);");
+        DB::insert("INSERT INTO `config` VALUES ('28', 'default_days', 7);");
+        DB::insert("INSERT INTO `config` VALUES ('29', 'subscribe_max', 3);");
+        DB::insert("INSERT INTO `config` VALUES ('30', 'min_port', 10000);");
+        DB::insert("INSERT INTO `config` VALUES ('31', 'max_port', 40000);");
+        DB::insert("INSERT INTO `config` VALUES ('32', 'is_captcha', 0);");
+        DB::insert("INSERT INTO `config` VALUES ('33', 'is_traffic_ban', 1);");
+        DB::insert("INSERT INTO `config` VALUES ('34', 'traffic_ban_value', 10);");
+        DB::insert("INSERT INTO `config` VALUES ('35', 'traffic_ban_time', 60);");
+        DB::insert("INSERT INTO `config` VALUES ('36', 'is_clear_log', 1);");
+        DB::insert("INSERT INTO `config` VALUES ('37', 'is_node_crash_warning', 0);");
+        DB::insert("INSERT INTO `config` VALUES ('38', 'crash_warning_email', '');");
+        DB::insert("INSERT INTO `config` VALUES ('39', 'is_server_chan', 0);");
+        DB::insert("INSERT INTO `config` VALUES ('40', 'server_chan_key', '');");
+        DB::insert("INSERT INTO `config` VALUES ('41', 'is_subscribe_ban', 1);");
+        DB::insert("INSERT INTO `config` VALUES ('42', 'subscribe_ban_times', 20);");
+        DB::insert("INSERT INTO `config` VALUES ('43', 'paypal_status', 0);");
+        DB::insert("INSERT INTO `config` VALUES ('44', 'paypal_client_id', '');");
+        DB::insert("INSERT INTO `config` VALUES ('45', 'paypal_client_secret', '');");
+    }
+}

+ 73 - 0
database/seeds/CountryTableSeeder.php

@@ -0,0 +1,73 @@
+<?php
+
+use Illuminate\Database\Seeder;
+
+class CountryTableSeeder extends Seeder
+{
+    /**
+     * Run the database seeds.
+     *
+     * @return void
+     */
+    public function run()
+    {
+        DB::insert("INSERT INTO `country` VALUES ('1', '澳大利亚', 'au');");
+        DB::insert("INSERT INTO `country` VALUES ('2', '巴西', 'br');");
+        DB::insert("INSERT INTO `country` VALUES ('3', '加拿大', 'ca');");
+        DB::insert("INSERT INTO `country` VALUES ('4', '瑞士', 'ch');");
+        DB::insert("INSERT INTO `country` VALUES ('5', '中国', 'cn');");
+        DB::insert("INSERT INTO `country` VALUES ('6', '德国', 'de');");
+        DB::insert("INSERT INTO `country` VALUES ('7', '丹麦', 'dk');");
+        DB::insert("INSERT INTO `country` VALUES ('8', '埃及', 'eg');");
+        DB::insert("INSERT INTO `country` VALUES ('9', '法国', 'fr');");
+        DB::insert("INSERT INTO `country` VALUES ('10', '希腊', 'gr');");
+        DB::insert("INSERT INTO `country` VALUES ('11', '香港', 'hk');");
+        DB::insert("INSERT INTO `country` VALUES ('12', '印度尼西亚', 'id');");
+        DB::insert("INSERT INTO `country` VALUES ('13', '爱尔兰', 'ie');");
+        DB::insert("INSERT INTO `country` VALUES ('14', '以色列', 'il');");
+        DB::insert("INSERT INTO `country` VALUES ('15', '印度', 'in');");
+        DB::insert("INSERT INTO `country` VALUES ('16', '伊拉克', 'iq');");
+        DB::insert("INSERT INTO `country` VALUES ('17', '伊朗', 'ir');");
+        DB::insert("INSERT INTO `country` VALUES ('18', '意大利', 'it');");
+        DB::insert("INSERT INTO `country` VALUES ('19', '日本', 'jp');");
+        DB::insert("INSERT INTO `country` VALUES ('20', '韩国', 'kr');");
+        DB::insert("INSERT INTO `country` VALUES ('21', '墨西哥', 'mx');");
+        DB::insert("INSERT INTO `country` VALUES ('22', '马来西亚', 'my');");
+        DB::insert("INSERT INTO `country` VALUES ('23', '荷兰', 'nl');");
+        DB::insert("INSERT INTO `country` VALUES ('24', '挪威', 'no');");
+        DB::insert("INSERT INTO `country` VALUES ('25', '纽西兰', 'nz');");
+        DB::insert("INSERT INTO `country` VALUES ('26', '菲律宾', 'ph');");
+        DB::insert("INSERT INTO `country` VALUES ('27', '俄罗斯', 'ru');");
+        DB::insert("INSERT INTO `country` VALUES ('28', '瑞典', 'se');");
+        DB::insert("INSERT INTO `country` VALUES ('29', '新加坡', 'sg');");
+        DB::insert("INSERT INTO `country` VALUES ('30', '泰国', 'th');");
+        DB::insert("INSERT INTO `country` VALUES ('31', '土耳其', 'tr');");
+        DB::insert("INSERT INTO `country` VALUES ('32', '台湾', 'tw');");
+        DB::insert("INSERT INTO `country` VALUES ('33', '英国', 'uk');");
+        DB::insert("INSERT INTO `country` VALUES ('34', '美国', 'us');");
+        DB::insert("INSERT INTO `country` VALUES ('35', '越南', 'vn');");
+        DB::insert("INSERT INTO `country` VALUES ('36', '波兰', 'pl');");
+        DB::insert("INSERT INTO `country` VALUES ('37', '哈萨克斯坦', 'kz');");
+        DB::insert("INSERT INTO `country` VALUES ('38', '乌克兰', 'ua');");
+        DB::insert("INSERT INTO `country` VALUES ('39', '罗马尼亚', 'ro');");
+        DB::insert("INSERT INTO `country` VALUES ('40', '阿联酋', 'ae');");
+        DB::insert("INSERT INTO `country` VALUES ('41', '南非', 'za');");
+        DB::insert("INSERT INTO `country` VALUES ('42', '缅甸', 'mm');");
+        DB::insert("INSERT INTO `country` VALUES ('43', '冰岛', 'is');");
+        DB::insert("INSERT INTO `country` VALUES ('44', '芬兰', 'fi');");
+        DB::insert("INSERT INTO `country` VALUES ('45', '卢森堡', 'lu');");
+        DB::insert("INSERT INTO `country` VALUES ('46', '比利时', 'be');");
+        DB::insert("INSERT INTO `country` VALUES ('47', '保加利亚', 'bg');");
+        DB::insert("INSERT INTO `country` VALUES ('48', '立陶宛', 'lt');");
+        DB::insert("INSERT INTO `country` VALUES ('49', '哥伦比亚', 'co');");
+        DB::insert("INSERT INTO `country` VALUES ('50', '澳门', 'mo');");
+        DB::insert("INSERT INTO `country` VALUES ('51', '肯尼亚', 'ke');");
+        DB::insert("INSERT INTO `country` VALUES ('52', '捷克', 'cz');");
+        DB::insert("INSERT INTO `country` VALUES ('53', '摩尔多瓦', 'md');");
+        DB::insert("INSERT INTO `country` VALUES ('54', '西班牙', 'es');");
+        DB::insert("INSERT INTO `country` VALUES ('55', '巴基斯坦', 'pk');");
+        DB::insert("INSERT INTO `country` VALUES ('56', '葡萄牙', 'pt');");
+        DB::insert("INSERT INTO `country` VALUES ('57', '匈牙利', 'hu');");
+        DB::insert("INSERT INTO `country` VALUES ('58', '阿根廷', 'ar');");
+    }
+}

+ 22 - 0
database/seeds/LevelTableSeeder.php

@@ -0,0 +1,22 @@
+<?php
+
+use Illuminate\Database\Seeder;
+
+class LevelTableSeeder extends Seeder
+{
+    /**
+     * Run the database seeds.
+     *
+     * @return void
+     */
+    public function run()
+    {
+        DB::insert("INSERT INTO `level` VALUES (1, '1', '倔强青铜', '2017-10-26 15:56:52', '2017-10-26 15:38:58');");
+        DB::insert("INSERT INTO `level` VALUES (2, '2', '秩序白银', '2017-10-26 15:57:30', '2017-10-26 12:37:51');");
+        DB::insert("INSERT INTO `level` VALUES (3, '3', '荣耀黄金', '2017-10-26 15:41:31', '2017-10-26 15:41:31');");
+        DB::insert("INSERT INTO `level` VALUES (4, '4', '尊贵铂金', '2017-10-26 15:41:38', '2017-10-26 15:41:38');");
+        DB::insert("INSERT INTO `level` VALUES (5, '5', '永恒钻石', '2017-10-26 15:41:47', '2017-10-26 15:41:47');");
+        DB::insert("INSERT INTO `level` VALUES (6, '6', '至尊黑曜', '2017-10-26 15:41:56', '2017-10-26 15:41:56');");
+        DB::insert("INSERT INTO `level` VALUES (7, '7', '最强王者', '2017-10-26 15:42:02', '2017-10-26 15:42:02');");
+    }
+}

+ 52 - 0
database/seeds/SsConfigTableSeeder.php

@@ -0,0 +1,52 @@
+<?php
+
+use Illuminate\Database\Seeder;
+
+class SsConfigTableSeeder extends Seeder
+{
+    /**
+     * Run the database seeds.
+     *
+     * @return void
+     */
+    public function run()
+    {
+        DB::insert("INSERT INTO `ss_config` VALUES ('1', 'none', '1', '0', '0', '2017-08-01 13:12:23', '2017-08-01 13:12:23');");
+        DB::insert("INSERT INTO `ss_config` VALUES ('2', 'rc4-md5', '1', '0', '0', '2017-08-01 13:12:29', '2017-08-01 13:12:29');");
+        DB::insert("INSERT INTO `ss_config` VALUES ('3', 'bf-cfb', '1', '0', '0', '2017-08-01 13:13:05', '2017-08-01 13:13:05');");
+        DB::insert("INSERT INTO `ss_config` VALUES ('4', 'aes-128-cfb', '1', '0', '0', '2017-08-01 13:13:13', '2017-08-01 13:13:13');");
+        DB::insert("INSERT INTO `ss_config` VALUES ('5', 'aes-192-cfb', '1', '0', '0', '2017-08-01 13:13:25', '2017-08-01 13:13:25');");
+        DB::insert("INSERT INTO `ss_config` VALUES ('6', 'aes-256-cfb', '1', '0', '0', '2017-08-01 13:13:39', '2017-08-01 13:13:39');");
+        DB::insert("INSERT INTO `ss_config` VALUES ('7', 'aes-128-ctr', '1', '0', '0', '2017-08-01 13:13:46', '2017-08-01 13:13:46');");
+        DB::insert("INSERT INTO `ss_config` VALUES ('8', 'aes-192-ctr', '1', '1', '0', '2017-08-01 13:13:53', '2017-08-01 13:13:53');");
+        DB::insert("INSERT INTO `ss_config` VALUES ('9', 'aes-256-ctr', '1', '0', '0', '2017-08-01 13:14:00', '2017-08-01 13:14:00');");
+        DB::insert("INSERT INTO `ss_config` VALUES ('10', 'camellia-128-cfb', '1', '0', '0', '2017-08-01 13:14:08', '2017-08-01 13:14:08');");
+        DB::insert("INSERT INTO `ss_config` VALUES ('11', 'camellia-192-cfb', '1', '0', '0', '2017-08-01 13:14:12', '2017-08-01 13:14:12');");
+        DB::insert("INSERT INTO `ss_config` VALUES ('12', 'camellia-256-cfb', '1', '0', '0', '2017-08-01 13:14:51', '2017-08-01 13:14:51');");
+        DB::insert("INSERT INTO `ss_config` VALUES ('13', 'salsa20', '1', '0', '0', '2017-08-01 13:15:09', '2017-08-01 13:15:09');");
+        DB::insert("INSERT INTO `ss_config` VALUES ('14', 'chacha20', '1', '0', '0', '2017-08-01 13:15:16', '2017-08-01 13:15:16');");
+        DB::insert("INSERT INTO `ss_config` VALUES ('15', 'chacha20-ietf', '1', '0', '0', '2017-08-01 13:15:27', '2017-08-01 13:15:27');");
+        DB::insert("INSERT INTO `ss_config` VALUES ('16', 'chacha20-ietf-poly1305', '1', '0', '0', '2017-08-01 13:15:39', '2017-08-01 13:15:39');");
+        DB::insert("INSERT INTO `ss_config` VALUES ('17', 'chacha20-poly1305', '1', '0', '0', '2017-08-01 13:15:46', '2017-08-01 13:15:46');");
+        DB::insert("INSERT INTO `ss_config` VALUES ('18', 'xchacha-ietf-poly1305', '1', '0', '0', '2017-08-01 13:21:51', '2017-08-01 13:21:51');");
+        DB::insert("INSERT INTO `ss_config` VALUES ('19', 'aes-128-gcm', '1', '0', '0', '2017-08-01 13:22:05', '2017-08-01 13:22:05');");
+        DB::insert("INSERT INTO `ss_config` VALUES ('20', 'aes-192-gcm', '1', '0', '0', '2017-08-01 13:22:12', '2017-08-01 13:22:12');");
+        DB::insert("INSERT INTO `ss_config` VALUES ('21', 'aes-256-gcm', '1', '0', '0', '2017-08-01 13:22:19', '2017-08-01 13:22:19');");
+        DB::insert("INSERT INTO `ss_config` VALUES ('22', 'sodium-aes-256-gcm', '1', '0', '0', '2017-08-01 13:22:32', '2017-08-01 13:22:32');");
+        DB::insert("INSERT INTO `ss_config` VALUES ('23', 'origin', '2', '0', '0', '2017-08-01 13:23:57', '2017-08-01 13:23:57');");
+        DB::insert("INSERT INTO `ss_config` VALUES ('24', 'auth_sha1_v4', '2', '0', '0', '2017-08-01 13:24:41', '2017-08-01 13:24:41');");
+        DB::insert("INSERT INTO `ss_config` VALUES ('25', 'auth_aes128_md5', '2', '0', '0', '2017-08-01 13:24:58', '2017-08-01 13:24:58');");
+        DB::insert("INSERT INTO `ss_config` VALUES ('26', 'auth_aes128_sha1', '2', '0', '0', '2017-08-01 13:25:11', '2017-08-01 13:25:11');");
+        DB::insert("INSERT INTO `ss_config` VALUES ('27', 'auth_chain_a', '2', '1', '0', '2017-08-01 13:25:24', '2017-08-01 13:25:24');");
+        DB::insert("INSERT INTO `ss_config` VALUES ('28', 'auth_chain_b', '2', '0', '0', '2017-08-01 14:02:31', '2017-08-01 14:02:31');");
+        DB::insert("INSERT INTO `ss_config` VALUES ('29', 'plain', '3', '0', '0', '2017-08-01 13:29:14', '2017-08-01 13:29:14');");
+        DB::insert("INSERT INTO `ss_config` VALUES ('30', 'http_simple', '3', '0', '0', '2017-08-01 13:29:30', '2017-08-01 13:29:30');");
+        DB::insert("INSERT INTO `ss_config` VALUES ('31', 'http_post', '3', '0', '0', '2017-08-01 13:29:38', '2017-08-01 13:29:38');");
+        DB::insert("INSERT INTO `ss_config` VALUES ('32', 'tls1.2_ticket_auth', '3', '1', '0', '2017-08-01 13:29:51', '2017-08-01 13:29:51');");
+        DB::insert("INSERT INTO `ss_config` VALUES ('33', 'tls1.2_ticket_fastauth', '3', '0', '0', '2017-08-01 14:02:19', '2017-08-01 14:02:19');");
+        DB::insert("INSERT INTO `ss_config` VALUES ('34', 'auth_chain_c', '2', '0', '0', '2017-08-01 14:02:31', '2017-08-01 14:02:31');");
+        DB::insert("INSERT INTO `ss_config` VALUES ('35', 'auth_chain_d', '2', '0', '0', '2017-08-01 14:02:31', '2017-08-01 14:02:31');");
+        DB::insert("INSERT INTO `ss_config` VALUES ('36', 'auth_chain_e', '2', '0', '0', '2017-08-01 14:02:31', '2017-08-01 14:02:31');");
+        DB::insert("INSERT INTO `ss_config` VALUES ('37', 'auth_chain_f', '2', '0', '0', '2017-08-01 14:02:31', '2017-08-01 14:02:31');");
+    }
+}

+ 54 - 0
database/seeds/UserTableSeeder.php

@@ -0,0 +1,54 @@
+<?php
+
+use Illuminate\Database\Seeder;
+
+class UserTableSeeder extends Seeder
+{
+    /**
+     * Run the database seeds.
+     *
+     * @return void
+     */
+    public function run()
+    {
+        DB::table('user')->insert([
+            'id'                   => 1,
+            'username'             => 'admin',
+            'password'             => 'e10adc3949ba59abbe56e057f20f883e',
+            'port'                 => 10000,
+            'passwd'               => '@123',
+            'transfer_enable'      => 1073741824000,
+            'u'                    => 0,
+            'd'                    => 0,
+            't'                    => 0,
+            'enable'               => 1,
+            'method'               => 'aes-192-ctr',
+            'custom_method'        => 'aes-192-ctr',
+            'protocol'             => 'auth_chain_a',
+            'protocol_param'       => '',
+            'obfs'                 => 'tls1.2_ticket_auth',
+            'obfs_param'           => '',
+            'speed_limit_per_con'  => 204800,
+            'speed_limit_per_user' => 204800,
+            'gender'               => 1,
+            'wechat'               => '',
+            'qq'                   => '',
+            'usage'                => 1,
+            'pay_way'              => 3,
+            'balance'              => '0.00',
+            'score'                => 0,
+            'enable_time'          => date('Y-m-d'),
+            'expire_time'          => '2099-01-01',
+            'ban_time'             => 0,
+            'remark'               => '',
+            'level'                => 1,
+            'is_admin'             => 1,
+            'reg_ip'               => '127.0.0.1',
+            'last_login'           => 0,
+            'referral_uid'         => 0,
+            'traffic_reset_day'    => 0,
+            'status'               => 0,
+            'remember_token'       => ''
+        ]);
+    }
+}

+ 32 - 8
readme.md

@@ -38,7 +38,7 @@ telegram群组:https://t.me/chatssrpanel
 强烈不建议使用OVZ(OpenVZ),一无法加速二容易崩溃,512M以下内存的容易经常性宕机(低内存KVM也会宕机)
 ````
 
-## 安装步骤
+## 安装
 #### 环境要求
 ````
 PHP 7.1 (必须)
@@ -54,13 +54,7 @@ cd /home/wwwroot/
 git clone https://github.com/ssrpanel/ssrpanel.git
 ````
 
-#### 先配置数据库
-````
-mysql 创建一个数据库,然后自行导入sql\db.sql
-config\database.php 中的mysql选项自行配置数据库
-````
-
-#### 其次配置一下运行环境
+#### 安装面板
 ````
 cd ssrpanel/
 php composer.phar install
@@ -69,6 +63,36 @@ chown -R www:www storage/
 chmod -R 777 storage/
 ````
 
+#### 配置数据库
+
+##### 连接数据库
+````
+先自行创建一个utf8mb4的数据库,
+然后编辑config/database.php,编辑mysql选项中如下配置值:
+host、port、database、username、password
+````
+
+##### 自动部署
+
+###### 表结构迁移
+````
+php artisan migrate
+````
+
+###### 数据播种
+````
+php artisan db:seed --class=ConfigTableSeeder
+php artisan db:seed --class=CountryTableSeeder
+php artisan db:seed --class=LevelTableSeeder
+php artisan db:seed --class=SsConfigTableSeeder
+php artisan db:seed --class=UserTableSeeder
+````
+
+##### 手工迁移数据
+````
+手动将sql/db.sql导入到创建好的数据库
+````
+
 #### 加入NGINX的URL重写规则
 ````
 location / {

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

@@ -162,14 +162,14 @@
                         </li>
                     </ul>
                 </li>
-                <li class="nav-item {{in_array(Request::path(), ['admin/userList', 'admin/addUser', 'admin/editUser', 'admin/userOrderList', 'admin/userBalanceLogList']) ? 'active open' : ''}}">
+                <li class="nav-item {{in_array(Request::path(), ['admin/userList', 'admin/addUser', 'admin/editUser', 'admin/userOrderList', 'admin/userBalanceLogList', 'admin/export', 'admin/userMonitor']) ? 'active open' : ''}}">
                     <a href="javascript:;" class="nav-link nav-toggle">
                         <i class="icon-users"></i>
                         <span class="title">用户管理</span>
                         <span class="arrow"></span>
                     </a>
                     <ul class="sub-menu">
-                        <li class="nav-item {{in_array(Request::path(), ['admin/userList', 'admin/addUser', 'admin/editUser']) ? 'active open' : ''}}">
+                        <li class="nav-item {{in_array(Request::path(), ['admin/userList', 'admin/addUser', 'admin/editUser', 'admin/export', 'admin/userMonitor']) ? 'active open' : ''}}">
                             <a href="{{url('admin/userList')}}" class="nav-link ">
                                 <i class="icon-user"></i>
                                 <span class="title">用户列表</span>