商户后台
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user