Browse Source

admin

master
chuan 2 months ago
parent
commit
b8207504c8
  1. 27
      app/admin/service/UserService.php
  2. 19
      app/model/AdminModel.php
  3. 3
      app/model/UserModel.php

27
app/admin/service/UserService.php

@ -2,6 +2,7 @@
namespace app\admin\service; namespace app\admin\service;
use app\admin\controller\Admin;
use app\admin\validate\UserValidate; use app\admin\validate\UserValidate;
use app\home\service\BaseHomeService; use app\home\service\BaseHomeService;
use app\model\AccountFrozenModel; use app\model\AccountFrozenModel;
@ -827,20 +828,27 @@ class UserService extends AdminBaseService
if ($isAgent) { if ($isAgent) {
$agentId = $adminId; $agentId = $adminId;
} else { // 指定一个默认代理 } else { // 指定一个默认代理
$getAgent = AdminModel::where(['role_id'=>AdminModel::ROLE_ID_AGENT])->find(); $agentId = AdminModel::getDefaultAgentId();
if (empty($getAgent)) { if (empty($agentId)) {
return $this->toData('500', '系统缺少代理账号'); return $this->toData('500', '系统缺少代理账号');
} }
$agentId = $getAgent->id;
} }
// 查询代理下的一个客服 // 查询代理下的一个客服 (等级关系: 代理-总监-组长-客服)
$getCustomer = AdminModel::where(['parent_id'=>$agentId])->find(); $director = AdminModel::where('parent_id', $agentId)->find();
if (empty($getCustomer)) { if (empty($director)) {
return $this->toData('500', '代理下缺少客服账号', ['agent_id'=>$agentId]); return $this->toData('500', '系统缺少总监账号');
} }
$customerId = $getCustomer->id; $teamHeader = AdminModel::where('parent_id', $director->id)->find();
if (empty($teamHeader)) {
return $this->toData('500', '系统缺少组长账号');
}
$customer = AdminModel::where('parent_id', $teamHeader->id)->find();
if (empty($customer)) {
return $this->toData('500', '系统缺少客服账号');
}
$customerId = $customer->id;
// 查询客服的chat信息 // 查询客服的chat信息
$customerChatInfo = UserChatLinkModel::where(['user_id'=>$customerId, 'user_type'=>UserChatLinkModel::USER_CHAT_LINK_USER_TYPE_ADMIN])->find(); //查询客服的聊天账号uuid $customerChatInfo = UserChatLinkModel::where(['user_id'=>$customerId, 'user_type'=>UserChatLinkModel::USER_CHAT_LINK_USER_TYPE_ADMIN])->find();
if (empty($customerChatInfo)) { if (empty($customerChatInfo)) {
return $this->toData('500', '客服账号缺少chat信息'); return $this->toData('500', '客服账号缺少chat信息');
} }
@ -850,7 +858,6 @@ class UserService extends AdminBaseService
return $this->toData('500', '当前代理还未创建chat群聊'); return $this->toData('500', '当前代理还未创建chat群聊');
} }
// 生成userNo // 生成userNo
$userNo = (new BaseHomeService())->getUniqUserNo(); $userNo = (new BaseHomeService())->getUniqUserNo();

19
app/model/AdminModel.php

@ -30,19 +30,18 @@ class AdminModel extends BaseModel
// 判断操作用户是否是代理商 // 判断操作用户是否是代理商
public static function checkUserIsAgent($adminId) public static function checkUserIsAgent($adminId)
{ {
// 代理角色
$admin = self::where('id', $adminId)->find(); $admin = self::where('id', $adminId)->find();
if($admin && $admin['role_id'] == self::ROLE_ID_AGENT){ if (empty($admin)) {
return true; return false;
} }
$agentRole = AuthRoleModel::where(['id'=>$admin->role_id])->find();
if (empty($agentRole)) {
return false; return false;
// $agentGroupId = env('AGENT.AGENT_GROUP_ID'); }
// $authGroupAccess = AuthGroupAccessModel::where('uid', $adminId)->find(); if ($agentRole->name != '代理') {
// if($authGroupAccess && $authGroupAccess['group_id'] == $agentGroupId){ return false;
// return true; }
// } return true;
// return false;
} }
/** /**

3
app/model/UserModel.php

@ -190,7 +190,7 @@ class UserModel extends BaseModel
* @param $ip * @param $ip
* @return int * @return int
*/ */
public static function emailRegister($email, $userNo, $inviteCode, $parentId, $password, $ip, $salt, $isTestUser, $agentId): int public static function emailRegister($email, $userNo, $inviteCode, $parentId, $password, $ip, $salt, $isTestUser, $agentId, $customerId=0): int
{ {
$self = new self; $self = new self;
$self->email = $email; $self->email = $email;
@ -198,6 +198,7 @@ class UserModel extends BaseModel
$self->invite_code = $inviteCode; $self->invite_code = $inviteCode;
$self->parent_id = $parentId; $self->parent_id = $parentId;
$self->agent_id = $agentId; $self->agent_id = $agentId;
$self->customer_id = $customerId;
$self->login_password = $password; $self->login_password = $password;
$self->salt = $salt; $self->salt = $salt;
$self->reg_ip = $ip; $self->reg_ip = $ip;

Loading…
Cancel
Save