Commit 6edaa036 authored by zw's avatar zw

liaotian

parent c64ea1e7
...@@ -81,22 +81,25 @@ class AppChat extends Basic ...@@ -81,22 +81,25 @@ class AppChat extends Basic
"user_id" => 118, "user_id" => 118,
"mobile" => "15821506182", "mobile" => "15821506182",
"source" => 1 //1经纪人 2用户 "source" => 1 //1经纪人 2用户
"push_id" => "ssss1231231123123"
);*/ );*/
$params = $this->params; $params = $this->params;
if (!isset($params['user_id']) || !isset($params['mobile']) || !isset($params['source'])) { if (!isset($params['user_id']) || !isset($params['mobile']) || !isset($params['source']) || !isset($params['push_id'])) {
return $this->response(ErrorCodeConst::ERROR_CODE_PARAM_NOT_EXIST, "请求参数错误"); return $this->response(ErrorCodeConst::ERROR_CODE_PARAM_NOT_EXIST, "请求参数错误");
} }
$user_id = $params['user_id']; $user_id = $params['user_id'];
$mobile = $params['mobile']; $mobile = $params['mobile'];
$source = $params['source']; $source = $params['source'];
$push_id = $params['push_id'];
if (!$user_id || !$mobile || !$source) { if (!$user_id || !$mobile || !$source || !$push_id) {
return $this->response(ErrorCodeConst::ERROR_CODE_PARAM_NOT_EXIST, "请求参数错误"); return $this->response(ErrorCodeConst::ERROR_CODE_PARAM_NOT_EXIST, "请求参数错误");
} }
$only_arr = $this->_chat->register($user_id, $mobile, $source); $only_arr = $this->_chat->register($user_id, $mobile, $source, $push_id);
if ($only_arr["code"] == 200) { if ($only_arr["code"] == 200) {
return $this->response("200", "success", [ "only_id" => $only_arr["only_id"] ]); return $this->response("200", "success", [ "only_id" => $only_arr["only_id"] ]);
......
...@@ -58,12 +58,13 @@ class ChatService ...@@ -58,12 +58,13 @@ class ChatService
* @param $user_id * @param $user_id
* @param $mobile * @param $mobile
* @param $source * @param $source
* @param $push_id
* @return array * @return array
* @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function register($user_id, $mobile, $source) public function register($user_id, $mobile, $source, $push_id)
{ {
$params["type"] = $source; $params["type"] = $source;
$params["user_id"] = $user_id; $params["user_id"] = $user_id;
...@@ -74,20 +75,21 @@ class ChatService ...@@ -74,20 +75,21 @@ class ChatService
if (count($chatUser) > 0) { if (count($chatUser) > 0) {
return [ "code" => "200", "only_id" => $chatUser[0]["only_id"] ]; return [ "code" => "200", "only_id" => $chatUser[0]["only_id"] ];
} else { } else {
$reg = new RegisterUtil();
$only_id = $this->createOnlyId($user_id, $source); $only_id = $this->createOnlyId($user_id, $source);
if (!$only_id) { if (!$only_id) {
return [ "code" => "101", "msg" => "user msg not found" ]; return [ "code" => "101", "msg" => "没有找到用户信息" ];
} } else {
$response = $reg->registerByCurl($only_id, $mobile);
if ($response) {
//todo insert
$this->insertChatUser($source, $user_id, $mobile, $only_id); $this->insertChatUser($source, $user_id, $mobile, $only_id);
} }
//todo 保存或更新push_id
return [ "code" => 200, "only_id" => $only_id ]; return [ "code" => 200, "only_id" => $only_id ];
} }
} }
private function savePushId(){
//todo
}
/** /**
* 生成唯一id * 生成唯一id
...@@ -103,12 +105,9 @@ class ChatService ...@@ -103,12 +105,9 @@ class ChatService
$onlyId = ""; $onlyId = "";
switch ($source) { switch ($source) {
case 1: case 1:
/*$where_["inuse"] = 1;
$where_["id"] = $userId;
$agentsResult = $this->agentsModel->getAgentsById("id", $where_);*/
$where_["status"] = 0; $where_["status"] = 0;
$where_["id"] = $userId; $where_["id"] = $userId;
$agentsResult = $this->agentsV2Model->getAgentsByStoreId( $where_); $agentsResult = $this->agentsV2Model->getAgentsByStoreId($where_);
if (count($agentsResult) > 0 && $agentsResult[0]['id'] > 0) if (count($agentsResult) > 0 && $agentsResult[0]['id'] > 0)
$onlyId = self::SOURCE_TYPE_AGENT . $userId; $onlyId = self::SOURCE_TYPE_AGENT . $userId;
break; break;
...@@ -153,32 +152,16 @@ class ChatService ...@@ -153,32 +152,16 @@ class ChatService
* @param $accessToken * @param $accessToken
* @return bool * @return bool
*/ */
public function sendMsg($user_name,$target_type, $target, $source, $is_user, $type, $msg_content, $from, $accessToken) public function sendMsg($user_name, $target_type, $target, $source, $is_user, $type, $msg_content, $from, $accessToken)
{ {
//todo 判断是否创建关系没有则保存
$this->verifyRelation($target, $from);
//fixme 之后扩展 此处有bug
/* if ($type == 3) {
try {
$house_id = (integer)trim($msg_content);
$HouseInfoModel = new HouseInfos();
$houseResult = $HouseInfoModel->getHousepusmessage($house_id);
if (count($houseResult) == 0)
return false;
} catch (Exception $e) {
return false;
}
}
//todo 判断是否创建关系没有则保存
$this->verifyRelation($target, $from);*/
$this->insertMsg($target_type, $target, $source, $is_user, $type, $msg_content, $from); $this->insertMsg($target_type, $target, $source, $is_user, $type, $msg_content, $from);
$rPush = new RPush(); $rPush = new RPush();
//todo 消息接收人必须是数据 //todo 消息接收人必须是数据
$rPush->send($user_name,$target_type, [ $target ], $msg_content, $from, $type, $accessToken, [ $this, 'saveSendStatus' ]); $rPush->send($user_name, $target_type, [ $target ], $msg_content, $from, $type, $accessToken, [ $this, 'saveSendStatus' ]);
return true; return true;
} }
...@@ -236,18 +219,18 @@ class ChatService ...@@ -236,18 +219,18 @@ class ChatService
$info_arr = []; $info_arr = [];
if (count($agent_phone) > 0) { 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["phone"] = array( "in", $agent_phone );
$where_agent["inuse"] = 1; $where_agent["inuse"] = 1;
$where_agent["level"] = array( "in", [ 2, 5 ] ); $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"; $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["phone"] = array( "in", $agent_phone ); $where_agent["phone"] = array( "in", $agent_phone );
$agentsResult = $this->agentsV2Model->getAgentsInfoByAgentId($field, $where_agent); $agentsResult = $this->agentsV2Model->getAgentsInfoByAgentId($field, $where_agent);
foreach ($agentsResult as $v) { foreach ($agentsResult as $v) {
if ($v["user_pic"]) { if ($v["user_pic"]) {
......
...@@ -60,12 +60,14 @@ class UWxInfo extends Model ...@@ -60,12 +60,14 @@ class UWxInfo extends Model
} }
} }
/** /**
* 根据微信open_id获取id * 根据微信open_id获取id
* @param string $open_id * @param string $open_id
* @param string $field * @param string $field
* @return false|\PDOStatement|string|\think\Collection * @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/ */
public function getWxInfoByOpenId(string $open_id , string $field = "id") public function getWxInfoByOpenId(string $open_id , string $field = "id")
{ {
......
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