Commit 37fe5f1d authored by zw's avatar zw

聊天 经纪人修改

parent e11cb2ea
......@@ -68,8 +68,10 @@ class AppChat extends Basic
/**
* 验证用户角色,生成唯一id
*
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function userChat()
{
......@@ -105,6 +107,9 @@ class AppChat extends Basic
/**
* 获取经纪人或用户的信息
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getUserOrAgentInfo()
{
......
......@@ -12,6 +12,7 @@ namespace app\chat\service;
use app\chat\utils\RegisterUtil;
use app\chat\utils\RPush;
use app\model\AAgents;
use app\model\Agents;
use app\model\ChatMsg;
use app\model\ChatMsgExt;
......@@ -43,20 +44,24 @@ class ChatService
protected $userModel;
protected $agentsModel;
protected $chatUserModel;
protected $agentsV2Model;
public function __construct()
{
$this->userModel = new Users();
$this->agentsModel = new Agents();
$this->chatUserModel = new ChatUser();
$this->agentsV2Model = new AAgents();
}
/**
* @param $user_id
* @param $mobile
* @param $source
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function register($user_id, $mobile, $source)
{
......@@ -89,16 +94,22 @@ class ChatService
* 生成唯一id
* @param $userId integer 用户id
* @param $source integer 来源 '1经纪人 2用户'
* @return string
* @return null|string
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function createOnlyId($userId, $source)
{
$onlyId = "";
switch ($source) {
case 1:
$where_["inuse"] = 1;
/*$where_["inuse"] = 1;
$where_["id"] = $userId;
$agentsResult = $this->agentsModel->getAgentsById("id", $where_);*/
$where_["status"] = 0;
$where_["id"] = $userId;
$agentsResult = $this->agentsModel->getAgentsById("id", $where_);
$agentsResult = $this->agentsV2Model->getAgentsByStoreId( $where_);
if (count($agentsResult) > 0 && $agentsResult[0]['id'] > 0)
$onlyId = self::SOURCE_TYPE_AGENT . $userId;
break;
......@@ -176,7 +187,7 @@ class ChatService
* 保存推送到环信的消息状态 往msg_status中插入数据
* @param $response
* @param $target
* @param $sender
* @param $from
* @param $msg_content
*/
public function saveSendStatus($response, $target, $from, $msg_content)
......@@ -191,12 +202,15 @@ class ChatService
$this->insertPushLog($from, $target[0], $msg_content, $status, $error_reason);
}
/**
* 根据手机号或者onlyId获取用户信息
* @param $only_id
* @param $type 之后扩展
* @return array|false|\PDOStatement|string|\think\Model
*
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getUserInfo($only_id, $type)
{
......@@ -223,13 +237,19 @@ class ChatService
$info_arr = [];
if (count($agent_phone) > 0) {
$field = "id,realname as user_nick,phone as user_phone,head_portrait as user_pic,CONCAT(agentshopname,'-',sub_shopname) as shop_name";
/* $field = "id,realname as user_nick,phone as user_phone,head_portrait as user_pic,CONCAT(agentshopname,'-',sub_shopname) as shop_name";
$where_agent["phone"] = array( "in", $agent_phone );
$where_agent["inuse"] = 1;
$where_agent["level"] = array( "in", [ 2, 5 ] );
$agentsResult = $this->agentsModel->getAgentsById($field, $where_agent);
$agentsResult = $this->agentsModel->getAgentsById($field, $where_agent);*/
$field = "a.id,a.name as user_nick,a.phone as user_phone,a.img as user_pic,CONCAT(c.district_name,'-',b.store_name) as shop_name";
$where_agent["a.phone"] = array( "in", $agent_phone );
$agentsResult = $this->agentsV2Model->getAgentsInfoByAgentId($field, $where_agent);
foreach ($agentsResult as $v) {
if ($v["user_pic"]) {
......@@ -338,17 +358,6 @@ class ChatService
$msgExtModel->addChatMsgExt($param);
}
/** 获取聊天记录
* @param $sender
* @param $start
* @param $limit
* @param $site_id
* @return array
*/
public function getHistoryChatList($sender, $start, $limit, $site_id)
{
//todo
}
/**
* 往chat_msg_status中插入数据,记录推送的状态
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment