Browse Source

admin

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

27
app/admin/service/UserService.php

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

21
app/model/AdminModel.php

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

3
app/model/UserModel.php

@ -190,7 +190,7 @@ class UserModel extends BaseModel
* @param $ip
* @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->email = $email;
@ -198,6 +198,7 @@ class UserModel extends BaseModel
$self->invite_code = $inviteCode;
$self->parent_id = $parentId;
$self->agent_id = $agentId;
$self->customer_id = $customerId;
$self->login_password = $password;
$self->salt = $salt;
$self->reg_ip = $ip;

Loading…
Cancel
Save