调整代码格式及使用常量去替换常用值

This commit is contained in:
柳清爽
2025-05-08 10:39:53 +08:00
parent b5939b36b3
commit 0426485177
31 changed files with 230 additions and 191 deletions

View File

@@ -12,6 +12,8 @@ class Administrator extends Model
{
use SoftDelete;
const MASTER_ID = 1;
// 设置数据表名
protected $name = 'administrators';

View File

@@ -3,12 +3,15 @@
namespace app\common\model;
use think\Model;
use think\model\concern\SoftDelete;
/**
* 设备任务配置模型类
*/
class DeviceTaskconf extends Model
{
use SoftDelete;
// 设置表名
protected $name = 'device_taskconf';
@@ -16,4 +19,5 @@ class DeviceTaskconf extends Model
protected $autoWriteTimestamp = true;
protected $createTime = 'createTime';
protected $updateTime = 'updateTime';
protected $defaultSoftDelete = 0;
}

View File

@@ -9,6 +9,9 @@ use think\Model;
*/
class Menu extends Model
{
const STATUS_ACTIVE = 1;
const TOP_LEVEL = 0;
// 设置数据表名
protected $name = 'menus';
}

View File

@@ -9,6 +9,14 @@ class User extends Model
{
use SoftDelete;
const ADMIN_STP = 1;
const ADMIN_OTP = 0;
const NOT_USER = -1;
const MASTER_USER = 1; // 操盘手
const CUSTOMER_USER = 2; // 门店接待
const STATUS_STOP = 0; // 禁用状态
const STATUS_ACTIVE = 1; // 活动状态
/**
* 数据表名
* @var string

View File

@@ -6,8 +6,10 @@ use app\common\model\Device as DeviceModel;
use app\common\model\DeviceTaskconf as DeviceTaskconfModel;
use app\common\model\DeviceUser as DeviceUserModel;
use app\common\model\DeviceWechatLogin;
use app\common\model\User as UserModel;
use app\common\model\WechatFriend;
use app\cunkebao\controller\BaseController;
use Eison\Utils\Helper\ArrHelper;
use library\ResponseHelper;
/**
@@ -67,17 +69,18 @@ class GetDeviceDetailV1Controller extends BaseController
$where = [
'deviceId' => $deviceId,
'companyId' => $this->getUserInfo('companyId'),
'deleteTime' => 0
];
$conf = DeviceTaskconfModel::where($where)->field('autoAddFriend,autoReply,contentSync,aiChat')->find();
$conf = DeviceTaskconfModel::alias('c')
->field([
'c.autoAddFriend', 'c.autoReply', 'c.contentSync', 'c.aiChat'
])
->where($where)
->find();
return $conf ? $conf->toArray() : [
'autoAddFriend' => 0,
'autoReply' => 0,
'contentSync' => 0,
'aiChat' => 0
];
return $conf
? $conf->toArray()
: ArrHelper::getValue([], 'autoAddFriend,autoReply,contentSync,aiChat', 0);
}
/**
@@ -125,7 +128,6 @@ class GetDeviceDetailV1Controller extends BaseController
->field([
'd.id', 'd.imei', 'd.memo', 'd.alive', 'd.updateTime as lastUpdateTime', 'd.extra'
])
->where('d.deleteTime', 0)
->find($id);
if (empty($device)) {
@@ -155,7 +157,7 @@ class GetDeviceDetailV1Controller extends BaseController
try {
$id = $this->request->param('id/d');
if ($this->getUserInfo('isAdmin') != 1) {
if ($this->getUserInfo('isAdmin') != UserModel::ADMIN_STP) {
$this->checkUserDevicePermission($id);
}

View File

@@ -4,6 +4,7 @@ namespace app\cunkebao\controller\device;
use app\common\model\DeviceHandleLog;
use app\common\model\DeviceUser as DeviceUserModel;
use app\common\model\User as UserModel;
use app\cunkebao\controller\BaseController;
use library\ResponseHelper;
@@ -29,7 +30,7 @@ class GetDeviceHandleLogsV1Controller extends BaseController
$hasPermission = DeviceUserModel::where($where)->count() > 0;
if (!$hasPermission) {
throw new \Exception('您没有权限查看该设备', '403');
throw new \Exception('您没有权限查看该设备', 403);
}
}
@@ -43,9 +44,7 @@ class GetDeviceHandleLogsV1Controller extends BaseController
{
return DeviceHandleLog::alias('l')
->field([
'l.id',
'l.content',
'l.createTime',
'l.id', 'l.content', 'l.createTime',
'u.username'
])
->leftJoin('users u', 'l.userId = u.id')
@@ -64,7 +63,7 @@ class GetDeviceHandleLogsV1Controller extends BaseController
try {
$deviceId = $this->request->param('id/d');
if ($this->getUserInfo('isAdmin') != 1) {
if ($this->getUserInfo('isAdmin') != UserModel::ADMIN_STP) {
$this->checkUserDevicePermission($deviceId);
}

View File

@@ -4,6 +4,7 @@ namespace app\cunkebao\controller\device;
use app\common\model\Device as DeviceModel;
use app\common\model\DeviceUser as DeviceUserModel;
use app\common\model\User as UserModel;
use app\common\model\WechatFriend;
use app\cunkebao\controller\BaseController;
use library\ResponseHelper;
@@ -34,7 +35,6 @@ class GetDeviceListV1Controller extends BaseController
}
$where['d.companyId'] = $this->getUserInfo('companyId');
$where['d.deleteTime'] = 0;
return array_merge($params, $where);
}
@@ -72,7 +72,11 @@ class GetDeviceListV1Controller extends BaseController
protected function getDeviceList(array $where, int $page = 1, int $limit = 10): \think\Paginator
{
$query = DeviceModel::alias('d')
->field(['d.id', 'd.imei', 'd.memo', 'l.wechatId', 'd.alive', 'wa.nickname', 'wa.alias', '0 totalFriend'])
->field([
'd.id', 'd.imei', 'd.memo', 'd.alive',
'l.wechatId',
'wa.nickname', 'wa.alias', '0 totalFriend'
])
->leftJoin('device_wechat_login l', 'd.id = l.deviceId')
->leftJoin('wechat_account wa', 'l.wechatId = wa.wechatId')
->order('d.id desc');
@@ -119,7 +123,7 @@ class GetDeviceListV1Controller extends BaseController
public function index()
{
try {
if ($this->getUserInfo('isAdmin') == 1) {
if ($this->getUserInfo('isAdmin') == UserModel::ADMIN_STP) {
$where = $this->makeWhere();
$result = $this->getDeviceList($where);
} else {

View File

@@ -4,6 +4,7 @@ namespace app\cunkebao\controller\device;
use app\common\model\DeviceUser as DeviceUserModel;
use app\common\model\DeviceWechatLogin as DeviceWechatLoginModel;
use app\common\model\User as UserModel;
use app\common\model\WechatAccount as WechatAccountModel;
use app\common\model\WechatFriend;
use app\cunkebao\controller\BaseController;
@@ -148,7 +149,7 @@ class GetRelatedAccountsV1Controller extends BaseController
try {
$deviceId = $this->request->param('id/d');
if ($this->getUserInfo('isAdmin') != 1) {
if ($this->getUserInfo('isAdmin') != UserModel::ADMIN_STP) {
$this->checkUserDevicePermission($deviceId);
}

View File

@@ -27,7 +27,6 @@ class PostAddDeviceV1Controller extends BaseController
$where = [
'imei' => $this->request->param('imei'),
'companyId' => $this->getUserInfo('companyId'),
'deleteTime' => 0
];
$exist = DeviceModel::where($where)->count() > 0;

View File

@@ -6,6 +6,7 @@ use app\common\model\Device as DeviceModel;
use app\common\model\DeviceHandleLog as DeviceHandleLogModel;
use app\common\model\DeviceTaskconf;
use app\common\model\DeviceUser as DeviceUserModel;
use app\common\model\User as UserModel;
use app\cunkebao\controller\BaseController;
use library\ResponseHelper;
use think\Db;
@@ -27,7 +28,6 @@ class UpdateDeviceTaskConfigV1Controller extends BaseController
$where = [
'deviceId' => $deviceId,
'companyId' => $this->getUserInfo('companyId'),
'deleteTime' => 0
];
$device = DeviceModel::find($where);
@@ -119,7 +119,7 @@ class UpdateDeviceTaskConfigV1Controller extends BaseController
$this->checkDeviceExists($id);
if ($this->getUserInfo('isAdmin') != 1) {
if ($this->getUserInfo('isAdmin') != UserModel::ADMIN_STP) {
$this->checkUserDevicePermission($id);
}

View File

@@ -2,6 +2,7 @@
namespace app\superadmin\controller\Menu;
use app\common\model\Administrator as AdministratorModel;
use app\common\model\Menu as MenuModel;
use app\common\model\AdministratorPermissions as AdministratorPermissionsModel;
use app\superadmin\controller\BaseController;
@@ -69,7 +70,7 @@ class GetMenuTreeController extends BaseController
protected function getMenuTree(): array
{
// 获取所有菜单
$allMenus = MenuModel::where('status', 1)->order('sort', 'asc')->select()->toArray();
$allMenus = MenuModel::where('status', MenuModel::STATUS_ACTIVE)->order('sort', 'asc')->select()->toArray();
// 组织成树状结构
return $allMenus ? $this->buildMenuTree($allMenus) : [];
@@ -84,8 +85,8 @@ class GetMenuTreeController extends BaseController
protected function getTopMenusInPermissionIds(array $permissionIds): array
{
$where = [
'parentId' => 0,
'status' => 1,
'parentId' => MenuModel::TOP_LEVEL,
'status' => MenuModel::STATUS_ACTIVE,
];
return MenuModel::where($where)->whereIn('id', $permissionIds)->order('sort', 'asc')->select()->toArray();
@@ -99,7 +100,7 @@ class GetMenuTreeController extends BaseController
*/
protected function getAllChildrenInPermissionIds(array $topMenuIds): array
{
return MenuModel::where('status', 1)->whereIn('parentId', $topMenuIds)->order('sort', 'asc')->select()->toArray();
return MenuModel::where('status', MenuModel::STATUS_ACTIVE)->whereIn('parentId', $topMenuIds)->order('sort', 'asc')->select()->toArray();
}
/**
@@ -165,7 +166,7 @@ class GetMenuTreeController extends BaseController
*/
public function index()
{
if ($this->getAdminInfo('id') == 1) {
if ($this->getAdminInfo('id') == AdministratorModel::MASTER_ID) {
$menuTree = $this->getMenuTree();
} else {
$menuTree = $this->getMenuTreeByPermissions(

View File

@@ -19,8 +19,8 @@ class GetTopLevelForPermissionController extends BaseController
protected function getTopLevelMenus(): array
{
$where = [
'parentId' => 0,
'status' => 1
'parentId' => MenuModel::TOP_LEVEL,
'status' => MenuModel::STATUS_NORMAL
];
return MenuModel::where($where)->field('id, title')->order('sort', 'asc')->select()->toArray();

View File

@@ -67,7 +67,7 @@ class AddAdministratorController extends BaseController
*/
protected function checkPermission(): self
{
if ($this->getAdminInfo('id') != 1) {
if ($this->getAdminInfo('id') != AdministratorModel::MASTER_ID) {
throw new \Exception('您没有权限添加管理员', 403);
}

View File

@@ -66,12 +66,12 @@ class DeleteAdministratorController extends BaseController
}
// 只有超级管理员(ID为1)可以删除管理员
if ($this->getAdminInfo('id') != 1) {
if ($this->getAdminInfo('id') != AdministratorModel::MASTER_ID) {
throw new \Exception('您没有权限删除管理员', 403);
}
// 不能删除超级管理员账号
if ($adminId == 1) {
if ($adminId == AdministratorModel::MASTER_ID) {
throw new \Exception('不能删除超级管理员账号', 403);
}
}

View File

@@ -22,9 +22,10 @@ class GetAdministratorDetailController extends BaseController
protected function getAdministrator(int $adminId): AdministratorModel
{
$admin = AdministratorModel::alias('a')
->field(
'a.id, a.account, a.username, a.status, a.authId, a.createTime createdAt, a.lastLoginTime lastLogin, p.permissions'
)
->field([
'a.id', 'a.account', 'a.username', 'a.status', 'a.authId', 'a.createTime createdAt', 'a.lastLoginTime lastLogin',
'p.permissions'
])
->leftJoin('administrator_permissions p', 'a.id = p.adminId')
->where('a.id', $adminId)
->find();

View File

@@ -40,9 +40,9 @@ class GetAdministratorListController extends Controller
protected function getAdministratorList(array $where): \think\Paginator
{
$query = AdministratorModel::alias('a')
->field(
'id, account, username, status, authId, createTime createdAt, lastLoginTime, lastLoginIp'
);
->field([
'a.id', 'a.account', 'a.username', 'a.status', 'a.authId', 'a.createTime createdAt', 'a.lastLoginTime', 'a.lastLoginIp'
]);
foreach ($where as $key => $value) {
if (is_numeric($key) && is_array($value) && isset($value[0]) && $value[0] === 'exp') {

View File

@@ -79,11 +79,11 @@ class UpdateAdministratorController extends BaseController
{
$currentAdminId = $this->getAdminInfo('id');
if ($currentAdminId != 1 && $currentAdminId != $adminId) {
if ($currentAdminId != AdministratorModel::MASTER_ID && $currentAdminId != $adminId) {
throw new \Exception('您没有权限修改其他管理员', 403);
}
if ($params['id'] != 1 && empty($params['permissionIds'])) {
if ($params['id'] != AdministratorModel::MASTER_ID && empty($params['permissionIds'])) {
throw new \Exception('请至少分配一种权限', 403);
}
@@ -137,7 +137,7 @@ class UpdateAdministratorController extends BaseController
$this->udpateAdministrator($params);
// 如果当前是超级管理员(ID为1),并且修改的不是自己,则更新权限
if ($this->getAdminInfo('id') == 1
if ($this->getAdminInfo('id') == AdministratorModel::MASTER_ID
&& $this->getAdminInfo('id') != $adminId
&& !empty($params['permissionIds'])
) {

View File

@@ -7,6 +7,7 @@ use app\superadmin\controller\administrator\DeleteAdministratorController;
use library\ResponseHelper;
use think\Controller;
use think\Validate;
use think\facade\Cookie;
class AuthLoginController extends Controller
{
@@ -133,8 +134,8 @@ class AuthLoginController extends Controller
}
// 设置cookies
\think\facade\Cookie::set('admin_id', $admin->id, $options);
\think\facade\Cookie::set('admin_token', $this->createToken($admin), $options);
Cookie::set('admin_id', $admin->id, $options);
Cookie::set('admin_token', $this->createToken($admin), $options);
}
/**
@@ -155,7 +156,7 @@ class AuthLoginController extends Controller
'id' => $admin->id,
'name' => $admin->username,
'account' => $admin->account,
'token' => cookie('admin_token')
'token' => Cookie::get('admin_token')
]
);
} catch (\Exception $e) {

View File

@@ -7,10 +7,12 @@ use app\common\model\Company as CompanyModel;
use app\common\model\User as UsersModel;
use app\superadmin\controller\BaseController;
use Eison\Utils\Helper\ArrHelper;
use Exception;
use library\ResponseHelper;
use library\s2\CurlHandle;
use think\Db;
use think\facade\Env;
use think\response\Json;
use think\Validate;
/**
@@ -23,7 +25,7 @@ class CreateCompanyController extends BaseController
*
* @param array $params
* @return mixed|null
* @throws \Exception
* @throws Exception
*/
protected function s2CreateUser(array $params): ?array
{
@@ -38,7 +40,7 @@ class CreateCompanyController extends BaseController
$result = json_decode($response, true);
if ($result['code'] != 200) {
throw new \Exception($result['msg'], 210 . $result['code']);
throw new Exception($result['msg'], 210 . $result['code']);
}
return $result['data'] ?: null;
@@ -63,7 +65,7 @@ class CreateCompanyController extends BaseController
$result = json_decode($response, true);
if ($result['code'] != 200) {
throw new \Exception($result['msg'], 210 . $result['code']);
throw new Exception($result['msg'], 210 . $result['code']);
}
return $result['data'] ?: null;
@@ -74,7 +76,7 @@ class CreateCompanyController extends BaseController
*
* @param array $params
* @return $this
* @throws \Exception
* @throws Exception
*/
protected function dataValidate(array $params): self
{
@@ -100,7 +102,7 @@ class CreateCompanyController extends BaseController
]);
if (!$validate->check($params)) {
throw new \Exception($validate->getError(), 400);
throw new Exception($validate->getError(), 400);
}
return $this;
@@ -111,7 +113,7 @@ class CreateCompanyController extends BaseController
*
* @param array $params
* @return void
* @throws \Exception
* @throws Exception
*/
protected function s2CreateDeviceGroup(array $params): void
{
@@ -119,7 +121,7 @@ class CreateCompanyController extends BaseController
$respon = json_decode($respon, true);
if ($respon['code'] != 200) {
throw new \Exception('设备分组添加错误', 210 . $respon['code']);
throw new Exception('设备分组添加错误', 210 . $respon['code']);
}
}
@@ -128,14 +130,14 @@ class CreateCompanyController extends BaseController
*
* @param array $params
* @return array
* @throws \Exception
* @throws Exception
*/
protected function creatS2About(array $params): array
{
$department = $this->s2CreateDepartmentAndUser($params);
if (!$department || !isset($department['id']) || !isset($department['departmentId'])) {
throw new \Exception('S2返参异常', 210402);
throw new Exception('S2返参异常', 210402);
}
// 设备创建分组
@@ -152,7 +154,7 @@ class CreateCompanyController extends BaseController
*
* @param array $params
* @return void
* @throws \Exception
* @throws Exception
*/
protected function ckbCreateCompany(array $params): void
{
@@ -160,7 +162,7 @@ class CreateCompanyController extends BaseController
$result = CompanyModel::create($params);
if (!$result) {
throw new \Exception('创建公司记录失败', 402);
throw new Exception('创建公司记录失败', 402);
}
}
@@ -169,13 +171,13 @@ class CreateCompanyController extends BaseController
*
* @param array $params
* @return void
* @throws \Exception
* @throws Exception
*/
protected function createFuncUsers(array $params): void
{
$seedCols = [
['account' => $params['account'] . '_offline', 'username' => '处理离线专用', 'status' => 0, 'isAdmin' => 0, 'typeId' => -1],
['account' => $params['account'] . '_delete' , 'username' => '处理删除专用', 'status' => 0, 'isAdmin' => 0, 'typeId' => -1],
['account' => $params['account'] . '_offline', 'username' => '处理离线专用', 'status' => UsersModel::STATUS_STOP, 'isAdmin' => UsersModel::ADMIN_OTP, 'typeId' => UsersModel::NOT_USER],
['account' => $params['account'] . '_delete', 'username' => '处理删除专用', 'status' => UsersModel::STATUS_STOP, 'isAdmin' => UsersModel::ADMIN_OTP, 'typeId' => UsersModel::NOT_USER],
];
foreach ($seedCols as $seeds) {
@@ -189,7 +191,7 @@ class CreateCompanyController extends BaseController
*
* @param array $params
* @return void
* @throws \Exception
* @throws Exception
*/
protected function ckbCreateUser(array $params): void
{
@@ -201,14 +203,14 @@ class CreateCompanyController extends BaseController
]);
if (!UsersModel::create($params)) {
throw new \Exception('创建用户记录失败', 402);
throw new Exception('创建用户记录失败', 402);
}
}
/**
* @param array $params
* @return void
* @throws \Exception
* @throws Exception
*/
protected function createCkbAbout(array $params)
{
@@ -217,8 +219,8 @@ class CreateCompanyController extends BaseController
// 2. 存客宝创建操盘手总账号
$this->ckbCreateUser(array_merge($params, [
'isAdmin' => 1, // 主要账号默认1
'typeId' => 1, // 类型:运营后台/操盘手传1、 门店传2
'isAdmin' => UsersModel::ADMIN_STP, // 主要账号默认1
'typeId' => UsersModel::MASTER_USER, // 类型:运营后台/操盘手传1、 门店传2
]));
}
@@ -227,7 +229,7 @@ class CreateCompanyController extends BaseController
*
* @param array $where
* @return void
* @throws \Exception
* @throws Exception
*/
protected function checkCompanyNameOrAccountOrPhoneExists(array $where): void
{
@@ -236,26 +238,26 @@ class CreateCompanyController extends BaseController
// 项目名称尽量不重名
$exists = CompanyModel::where(compact('name'))->count() > 0;
if ($exists) {
throw new \Exception('项目名称已存在', 403);
throw new Exception('项目名称已存在', 403);
}
// 账号不重名
$exists = UsersModel::where(compact('account'))->count() > 0;
if ($exists) {
throw new \Exception('用户账号已存在', 403);
throw new Exception('用户账号已存在', 403);
}
// 手机号不重名
$exists = UsersModel::where(compact('phone'))->count() > 0;
if ($exists) {
throw new \Exception('手机号已存在', 403);
throw new Exception('手机号已存在', 403);
}
}
/**
* 创建新项目
*
* @return \think\response\Json
* @return Json
*/
public function index()
{
@@ -273,7 +275,7 @@ class CreateCompanyController extends BaseController
Db::commit();
return ResponseHelper::success();
} catch (\Exception $e) {
} catch (Exception $e) {
Db::rollback();
return ResponseHelper::error($e->getMessage(), $e->getCode());
}

View File

@@ -23,9 +23,9 @@ class GetCompanyDetailForProfileController extends BaseController
*/
protected function getDeveiceWechats(int $companyId): array
{
$wechatId = DeviceWechatLoginModel::where('companyId', $companyId)->column('wechatId');
$wechatIds = DeviceWechatLoginModel::where('companyId', $companyId)->column('wechatId');
return array_unique($wechatId);
return array_unique($wechatIds);
}
/**
@@ -60,7 +60,7 @@ class GetCompanyDetailForProfileController extends BaseController
*/
protected function getUsersCountByCompanyId(int $companyId): int
{
$where = array_merge(compact('companyId'), array('isAdmin' => 0));
$where = array_merge(compact('companyId'), array('isAdmin' => UserModel::ADMIN_OTP));
return UserModel::where($where)->count();
}
@@ -79,7 +79,7 @@ class GetCompanyDetailForProfileController extends BaseController
'c.id', 'c.name', 'c.memo', 'c.companyId', 'c.createTime',
'u.account', 'u.phone'
])
->leftJoin('users u', 'c.companyId = u.companyId and u.isAdmin = 1')
->leftJoin('users u', 'c.companyId = u.companyId and u.isAdmin = ' . UserModel::ADMIN_STP)
->find($id);
if (!$detail) {

View File

@@ -4,6 +4,7 @@ namespace app\superadmin\controller\company;
use app\common\model\Company as CompanyModel;
use app\common\model\Device as DeviceModel;
use app\common\model\User as UserModel;
use app\superadmin\controller\BaseController;
use library\ResponseHelper;
@@ -43,7 +44,7 @@ class GetCompanyDetailForUpdateController extends BaseController
'c.id', 'c.name', 'c.status', 'c.memo', 'c.companyId',
'u.account', 'u.username', 'u.phone', 'u.s2_accountId'
])
->leftJoin('users u', 'c.companyId = u.companyId and u.isAdmin = 1')
->leftJoin('users u', 'c.companyId = u.companyId and u.isAdmin = ' . UserModel::ADMIN_STP)
->find($id);
if (!$detail) {

View File

@@ -23,7 +23,11 @@ class GetCompanyDevicesForProfileController extends Controller
{
$companyId = $this->request->param('companyId/d', 0);
$devices = DeviceModel::where(compact('companyId'))->field('id,memo,imei,phone,model,brand,alive,id deviceId')
$devices = DeviceModel::alias('d')
->field([
'd.id', 'd.memo', 'd.imei', 'd.phone', 'd.model', 'd.brand', 'd.alive', 'd.id deviceId'
])
->where(compact('companyId'))
->select()
->toArray();
@@ -47,7 +51,10 @@ class GetCompanyDevicesForProfileController extends Controller
// 获取最新登录记录id
$latestIds = array_column($latestLogs, 'lastedId');
return DeviceWechatLoginModel::field('deviceId,wechatId,alive wAlive')
return DeviceWechatLoginModel::alias('d')
->field([
'd.deviceId', 'd.wechatId', 'd.alive wAlive'
])
->whereIn('id', $latestIds)
->select()
->toArray();
@@ -65,7 +72,10 @@ class GetCompanyDevicesForProfileController extends Controller
$relations = $this->getDeviceWechatRelationsByDeviceIds($deviceIds);
// 统计微信好友数量
$friendCounts = WechatFriendModel::alias('f')->field('ownerWechatId wechatId,count(*) friendCount')
$friendCounts = WechatFriendModel::alias('f')
->field([
'f.ownerWechatId wechatId', 'count(*) friendCount'
])
->whereIn('ownerWechatId', array_column($relations, 'wechatId'))
->group('ownerWechatId')
->select()

View File

@@ -57,9 +57,9 @@ class GetCompanyListController extends BaseController
protected function getCompanyList(array $where): \think\Paginator
{
$query = CompanyModel::alias('c')
->field(
'id, name, status, companyId, memo, createTime'
);
->field([
'c.id', 'c.name', 'c.status', 'c.companyId', 'c.memo', 'c.createTime'
]);
foreach ($where as $key => $value) {
if (is_numeric($key) && is_array($value) && isset($value[0]) && $value[0] === 'exp') {

View File

@@ -21,10 +21,16 @@ class GetCompanySubusersForProfileController extends Controller
{
$where = [
'companyId' => $this->request->param('companyId/d', 0),
'isAdmin' => 0
'isAdmin' => UserModel::ADMIN_OTP
];
return UserModel::field('id,account,phone,username,avatar,status,createTime,typeId')->where($where)->select()->toArray();
return UserModel::alias('u')
->field([
'u.id', 'u.account', 'u.phone', 'u.username', 'u.avatar', 'u.status', 'u.createTime', 'u.typeId'
])
->where($where)
->select()
->toArray();
}
/**

View File

@@ -46,7 +46,7 @@ class UpdateCompanyController extends BaseController
protected function getUserDetailByCompanyId(): ?UsersModel
{
$where = [
'isAdmin' => 1, // 必须保证 isAdmin 有且只有一个
'isAdmin' => UsersModel::MASTER_USER, // 必须保证 isAdmin 有且只有一个
'companyId' => $this->companyId,
];

View File

@@ -78,15 +78,10 @@ class GetPoolListController extends BaseController
{
$query = TrafficPoolModel::alias('tp')
->field([
'ts.id',
'tp.wechatId',
'ts.createTime as addTime',
'ts.fromd as source',
'ts.id', 'ts.createTime as addTime', 'ts.fromd as source',
'c.name as projectName',
'wa.avatar',
'wa.gender',
'wa.nickname',
'wa.region',
'wa.avatar', 'wa.gender', 'wa.nickname', 'wa.region',
'wt.tags'
])
->join('traffic_source ts', 'tp.identifier = ts.identifier', 'RIGHT')