Commit d95a5806 authored by hujun's avatar hujun

当前设备

parent 6ed14e8e
......@@ -11,6 +11,7 @@ namespace app\api_broker\service;
use app\api\service\PushClientService;
use app\api\untils\GeTuiUtils;
use app\extra\RedisExt;
use app\model\AAgents;
use app\model\ABindingDevice;
use app\model\AStore;
......@@ -286,18 +287,24 @@ class PushMessageService
return false;
}
$m_agent_device = new ABindingDevice();
$device_id_array = $m_agent_device->getDeviceByAgentId([ 'agent_id' => $id, 'is_forbidden' => $is_forbidden, 'is_pc'=>0 ], 'id,push_id');
$result = [];
if (!empty($device_id_array)) {
foreach ($device_id_array as $k => $v) {
if (!empty($v['push_id'])) {
$house_id = empty($house_id) ? '':$house_id;
$result[] = $this->push->public_push_message_for_one($id, $v['push_id'], $title, $content, $type, $user_id, $house_id, $order_id, $title);
$key = 'agent_push_id_'.$id;
$redis = RedisExt::getRedis();
$push_id = $redis->get($key);
if (empty($push_id)) {
$m_agent_device = new ABindingDevice();
$device_id_array = $m_agent_device->getDeviceByAgentId([ 'agent_id' => $id, 'is_forbidden' => $is_forbidden, 'is_pc'=>0 ], 'id,push_id');
$result = [];
if (!empty($device_id_array)) {
foreach ($device_id_array as $k => $v) {
if (!empty($v['push_id'])) {
$house_id = empty($house_id) ? '':$house_id;
$result[] = $this->push->public_push_message_for_one($id, $v['push_id'], $title, $content, $type, $user_id, $house_id, $order_id, $title);
}
}
}
} else {
$result[] = $this->push->public_push_message_for_one($id, $push_id, $title, $content, $type, $user_id, $house_id, $order_id, $title);
}
return $result;
}
......@@ -690,7 +697,7 @@ class PushMessageService
}
}
$this->recordCheck(9, $agent_id_arr, $operation_id, $record_data);
$this->recordCheck(8, $agent_id_arr, $operation_id, $record_data);
return true;
}
}
\ No newline at end of file
......@@ -13,6 +13,7 @@ namespace app\chat\service;
use app\api_broker\service\RedisCacheService;
use app\chat\utils\RegisterUtil;
use app\chat\utils\RPush;
use app\extra\RedisExt;
use app\model\AAgents;
use app\model\ChatMsg;
use app\model\ChatMsgExt;
......@@ -89,6 +90,11 @@ class ChatService
if ($id > 0 && $device_id && $push_id) {
$this->savePushIdV3($id, $device_id, $push_id, $source);
}
if ($source == 1) {
$this->currentDevice($user_id, $push_id); //经纪人当前登陆设备
}
return ["code" => 200, "only_id" => $only_id];
}
......@@ -714,5 +720,24 @@ class ChatService
return $this->chatUserModel->addChatUser($params);
}
/**
* 记录当前设备
*
* @param $agent_id
* @param $push_id
* @return bool
*/
public function currentDevice($agent_id, $push_id)
{
if (empty($agent_id) || empty($push_id)) {
return false;
}
$key = 'agent_push_id_'.$agent_id;
$redis = RedisExt::getRedis();
$push_old = $redis->get($key);
if ($push_old != $push_id) {
$redis->set($key, $push_id);
}
return true;
}
}
\ No newline at end of file
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