超管后台 - 对齐项目表数据结构调整添加/编辑页面表单项目及数据

This commit is contained in:
柳清爽
2025-04-22 16:30:35 +08:00
parent ad145ba296
commit cf37b4d6cc
4 changed files with 92 additions and 60 deletions

View File

@@ -126,7 +126,7 @@ class CreateCompanyController extends BaseController
protected function ckbCreateUser(array $params): void
{
$params = ArrHelper::getValue(
'username,account,password,companyId,s2_accountId,status,realName',
'username,account,password,companyId,s2_accountId,status,phone',
$params
);
@@ -156,6 +156,36 @@ class CreateCompanyController extends BaseController
$this->ckbCreateUser($params);
}
/**
* 检查项目名称是否已存在
*
* @param array $where
* @return void
* @throws \Exception
*/
protected function checkCompanyNameOrAccountOrPhoneExists(array $where): void
{
extract($where);
// 项目名称尽量不重名
$exists = CompanyModel::where(compact('name'))->count() > 0;
if ($exists) {
throw new \Exception('项目名称已存在', 403);
}
// 账号不重名
$exists = UsersModel::where(compact('account'))->count() > 0;
if ($exists) {
throw new \Exception('用户账号已存在', 403);
}
// 手机号不重名
$exists = UsersModel::where(compact('phone'))->count() > 0;
if ($exists) {
throw new \Exception('手机号已存在', 403);
}
}
/**
* 创建新项目
*
@@ -168,7 +198,7 @@ class CreateCompanyController extends BaseController
$params = $this->dataValidate($params)->creatS2About($params);
Db::startTrans();
$this->checkCompanyNameOrAccountOrPhoneExists(ArrHelper::getValue('name,account,phone', $params));
$this->createCkbAbout($params);
Db::commit();

View File

@@ -85,7 +85,7 @@ class UpdateCompanyController extends BaseController
*/
protected function updateUserAccount(array $params): void
{
$params = ArrHelper::getValue('username,account,password,realName,status', $params);
$params = ArrHelper::getValue('username,account,password,phone,status', $params);
$params = ArrHelper::rmValue($params);
if (isset($params['password'])) {
@@ -119,7 +119,7 @@ class UpdateCompanyController extends BaseController
/**
* 更新触客宝端数据
*
*
* @param array $params
* @return self
* @throws \Exception
@@ -142,7 +142,7 @@ class UpdateCompanyController extends BaseController
* @return void
* @throws \Exception
*/
protected function checkCompanyNameAndAccountExists(array $where): void
protected function checkCompanyNameOrAccountOrPhoneExists(array $where): void
{
extract($where);
@@ -152,12 +152,17 @@ class UpdateCompanyController extends BaseController
throw new \Exception('项目名称已存在', 403);
}
// 账号尽量不重名
// TODO数据迁移时存客宝主账号先查询出id通过id查询出S2的最新信息然后更新。
$exists = UsersModel::where(compact('account'))->where('companyId', '<>', $id)->count() > 0;
if ($exists) {
throw new \Exception('用户账号已存在', 403);
}
// 手机号不重复
$exists = UsersModel::where(compact('phone'))->where('companyId', '<>', $id)->count() > 0;
if ($exists) {
throw new \Exception('手机号已存在', 403);
}
}
/**
@@ -207,7 +212,7 @@ class UpdateCompanyController extends BaseController
// 数据验证
$this->dataValidate($params);
$this->checkCompanyNameAndAccountExists(ArrHelper::getValue('id,name,account', $params));
$this->checkCompanyNameOrAccountOrPhoneExists(ArrHelper::getValue('id,name,account,phone', $params));
Db::startTrans();
$this->updateCkbAbout($params)->updateS2About($params);