优化部分代码,增加微信公众号模板

This commit is contained in:
李琦
2026-08-13 19:01:21 +08:00
parent 21f39eed85
commit 2f5e298d6b
10 changed files with 83 additions and 41 deletions

View File

@@ -96,7 +96,17 @@ class AdminService extends BaseService
{
$params['ip_table'] = json_encode([]);
$params['password'] = password_hash($params['password'], PASSWORD_DEFAULT);
$existsUser = $this->model::where('phone', $params['phone'])->whereOr('email', $params['email'])->exists();
// 手机号或邮箱任一重复都拒绝且必须排除软删记录deleted_at=0
// 原写法 whereOr('email',...) 是 Laravel 动态 where 的空操作(等于只按 phone 判断且不排软删),
// 这里用闭包 orWhere 正确表达「phone OR email」email 为空时不参与判重,避免误伤空邮箱账号
$email = $params['email'] ?? '';
$existsUser = $this->model::where('deleted_at', 0)
->where(function ($q) use ($params, $email) {
$q->where('phone', $params['phone']);
if ($email !== '') {
$q->orWhere('email', $email);
}
})->exists();
if ($existsUser) {
$this->utils->errorThrow('账号或邮箱已存在');
}