|
|
@ -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(); |
|
|
|
|
|
|
|