商户后台

This commit is contained in:
liu
2026-06-17 12:41:49 +08:00
parent 845bea4b81
commit f63a7db58f
46 changed files with 2215 additions and 43 deletions
@@ -23,7 +23,7 @@ return new class extends Migration
$table->integer('sex')->default(0)->comment('性别(男、女)');
$table->string('bio', 255)->default('')->nullable()->comment('个人简介');
$table->string('mobile', 20)->default('')->comment('手机号');
$table->string('email', 50)->unique()->comment('邮箱');
$table->string('email', 50)->default('')->comment('邮箱');
$table->timestamp('email_verified_at')->nullable();
$table->integer('dept_id')->default(0)->comment('部门ID');
$table->string('login_ip', 60)->default('')->comment('最后登录IP');
@@ -78,7 +78,7 @@ return new class extends Migration
$table->comment('系统用户部门表');
});
}
// 系统用户权限表
if (! Schema::hasTable('sys_rule')) {
Schema::create('sys_rule', function (Blueprint $table) {
@@ -8,21 +8,6 @@ return new class extends Migration
{
public function up(): void
{
// 商户分类
if (! Schema::hasTable('merchant_categories')) {
Schema::create('merchant_categories', function (Blueprint $table) {
$table->id();
$table->string('name', 50)->comment('分类名称');
$table->string('slug', 50)->comment('标识');
$table->string('description', 255)->default('')->comment('描述');
$table->string('icon', 255)->default('')->comment('图标');
$table->integer('sort')->default(0)->comment('排序');
$table->tinyInteger('status')->default(1)->comment('状态:0=禁用,1=正常');
$table->timestamps();
$table->unique('slug');
$table->comment('商户分类');
});
}
// 商户/店铺
if (! Schema::hasTable('merchants')) {
@@ -74,6 +59,22 @@ return new class extends Migration
});
}
// 商户商品分类
if (! Schema::hasTable('platform_categories')) {
Schema::create('platform_categories', function (Blueprint $table) {
$table->id();
$table->string('name', 50)->comment('分类名称');
$table->string('slug', 50)->comment('标识');
$table->string('description', 255)->default('')->comment('描述');
$table->string('icon', 255)->default('')->comment('图标');
$table->integer('sort')->default(0)->comment('排序');
$table->tinyInteger('status')->default(1)->comment('状态:0=禁用,1=正常');
$table->timestamps();
$table->unique('slug');
$table->comment('商户分类');
});
}
// 商品
if (! Schema::hasTable('merchant_products')) {
Schema::create('merchant_products', function (Blueprint $table) {
+107
View File
@@ -675,6 +675,85 @@ class SysRuleSeeder extends Seeder
],
],
],
[
'type' => 'menu',
'name' => '商户管理',
'local' => 'menu.merchant_portal',
'icon' => 'ShopOutlined',
'key' => 'merchant.portal',
'children' => [
[
'type' => 'route',
'name' => '商品列表',
'key' => 'merchant.portal.product',
'path' => '/merchant-portal/product',
'local' => 'menu.merchant_portal.product',
'children' => [
['type' => 'rule', 'name' => '查询列表', 'key' => 'merchant.portal.product.query'],
['type' => 'rule', 'name' => '新增商品', 'key' => 'merchant.portal.product.create'],
['type' => 'rule', 'name' => '修改商品', 'key' => 'merchant.portal.product.update'],
['type' => 'rule', 'name' => '删除商品', 'key' => 'merchant.portal.product.delete'],
],
],
[
'type' => 'route',
'name' => '商品分类',
'key' => 'merchant.portal.product-category',
'path' => '/merchant-portal/product-category',
'local' => 'menu.merchant_portal.product-category',
'children' => [
['type' => 'rule', 'name' => '查询列表', 'key' => 'merchant.portal.product-category.query'],
['type' => 'rule', 'name' => '新增分类', 'key' => 'merchant.portal.product-category.create'],
['type' => 'rule', 'name' => '修改分类', 'key' => 'merchant.portal.product-category.update'],
['type' => 'rule', 'name' => '删除分类', 'key' => 'merchant.portal.product-category.delete'],
],
],
[
'type' => 'route',
'name' => '订单列表',
'key' => 'merchant.portal.order',
'path' => '/merchant-portal/order',
'local' => 'menu.merchant_portal.order',
'children' => [
['type' => 'rule', 'name' => '查询列表', 'key' => 'merchant.portal.order.query'],
],
],
[
'type' => 'route',
'name' => '交易流水',
'key' => 'merchant.portal.payment',
'path' => '/merchant-portal/payment',
'local' => 'menu.merchant_portal.payment',
'children' => [
['type' => 'rule', 'name' => '查询列表', 'key' => 'merchant.portal.payment.query'],
],
],
[
'type' => 'route',
'name' => '打印机管理',
'key' => 'merchant.portal.printer',
'path' => '/merchant-portal/printer',
'local' => 'menu.merchant_portal.printer',
'children' => [
['type' => 'rule', 'name' => '查询列表', 'key' => 'merchant.portal.printer.query'],
['type' => 'rule', 'name' => '新增打印机', 'key' => 'merchant.portal.printer.create'],
['type' => 'rule', 'name' => '修改打印机', 'key' => 'merchant.portal.printer.update'],
['type' => 'rule', 'name' => '删除打印机', 'key' => 'merchant.portal.printer.delete'],
],
],
[
'type' => 'route',
'name' => '商户信息',
'key' => 'merchant.portal.store',
'path' => '/merchant-portal/store',
'local' => 'menu.merchant_portal.store',
'children' => [
['type' => 'rule', 'name' => '查看信息', 'key' => 'merchant.portal.store.query'],
['type' => 'rule', 'name' => '修改信息', 'key' => 'merchant.portal.store.update'],
],
],
],
],
[
'type' => 'route',
'name' => 'XinAdmin',
@@ -695,6 +774,34 @@ class SysRuleSeeder extends Seeder
->where('status', 1)
->select(DB::raw('1 as role_id'), 'id')
);
// 创建"商户"角色并分配商户门户权限
$merchantRoleExists = DB::table('sys_role')->where('name', '商户')->exists();
if (! $merchantRoleExists) {
$merchantRoleId = DB::table('sys_role')->insertGetId([
'name' => '商户',
'status' => 1,
'created_at' => now(),
'updated_at' => now(),
]);
// 为商户角色分配 merchant.portal.* 及 dashboard 权限
$portalRuleIds = DB::table('sys_rule')
->where('status', 1)
->where(function ($query) {
$query->where('key', 'LIKE', 'merchant.portal.%')
->orWhere('key', 'dashboard')
->orWhere('key', 'dashboard.analysis');
})
->pluck('id');
$insertData = $portalRuleIds->map(fn ($ruleId) => [
'role_id' => $merchantRoleId,
'rule_id' => $ruleId,
])->toArray();
DB::table('sys_role_rule')->insert($insertData);
}
}
/**