feat: 员工自助注册+审核流程

- 新增 registration_packages 表:管理员配置注册套餐(名称/角色)
- AuthController 新增 register() 和 registrationPackages() 公开接口
- UserController 新增 approve() / reject() 审核接口
- StoreController 新增 publicList() 公开门店列表
- 前端 /register 注册页:选门店→选岗位套餐→填信息→提交
- 前端 system/registration-packages:套餐 CRUD
- 用户管理页:待审核状态展示 + 通过/拒绝快捷操作
- 登录页底部加「申请注册」跳转链接
- 路由白名单加 /register
This commit is contained in:
li
2026-03-14 17:39:50 +08:00
parent 4a68855a88
commit ee2b1757d0
105 changed files with 7859 additions and 2469 deletions
@@ -85,4 +85,62 @@ class AuthController extends Controller
'menus' => $user->getMenuTree(),
]);
}
/**
* 获取可用注册套餐列表(公开接口)
*/
public function registrationPackages(Request $request): JsonResponse
{
$storeId = $request->input('store_id');
if (!$storeId) {
return $this->error('请选择门店', 42200);
}
$packages = \App\Models\System\RegistrationPackage::withoutGlobalScope('store')
->where('store_id', $storeId)
->where('status', 1)
->orderBy('sort')
->get(['id', 'name', 'description']);
return $this->success($packages);
}
/**
* 自助注册(公开接口)
* 注册后 status=2(待审核),需管理员审批后才能登录
*/
public function register(Request $request): JsonResponse
{
$data = $request->validate([
'store_id' => 'required|exists:stores,id',
'registration_package_id' => 'required|exists:registration_packages,id',
'username' => 'required|string|max:50|unique:users,username',
'password' => 'required|string|min:6',
'name' => 'required|string|max:50',
'phone' => 'required|string|max:20',
]);
// 验证套餐属于该门店
$package = \App\Models\System\RegistrationPackage::withoutGlobalScope('store')
->where('id', $data['registration_package_id'])
->where('store_id', $data['store_id'])
->where('status', 1)
->firstOrFail();
$user = \App\Models\User::create([
'store_id' => $data['store_id'],
'username' => $data['username'],
'password' => $data['password'],
'name' => $data['name'],
'phone' => $data['phone'],
'status' => 2, // Pending
]);
// 绑定套餐角色
if (!empty($package->role_ids)) {
$user->roles()->sync($package->role_ids);
}
return $this->success(null, '注册成功,请等待管理员审核后登录');
}
}