You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
138 lines
6.6 KiB
138 lines
6.6 KiB
<?php
|
|
/**
|
|
* 通讯系统
|
|
*/
|
|
defined('IN_IA') or exit('Access Denied');
|
|
|
|
class ImModuleUniapp extends Uniapp {
|
|
//TODO:由于多功能通信大部分用户配置失败 如果删除多功能通信后需要保留发送图片和视频等功能 需要重新优化这里的通讯功能 目前普通通信仅支持发送文本信息
|
|
/**
|
|
* Comment: 通讯信息列表(用户)
|
|
* Author: zzw
|
|
* Date: 2019/8/27 9:04
|
|
*/
|
|
public function infoList(){
|
|
global $_W,$_GPC;
|
|
#1、参数获取
|
|
$page = $_GPC['page'] ? : 1;
|
|
$pageIndex = $_GPC['page_index'] ? : 10;
|
|
$plugin = $_GPC['plugin'] ? : '';
|
|
#2、获取列表信息 (1=用户;2=商户)
|
|
$data = Im::myList($_W['mid'],1,$page,$pageIndex,$plugin,true);
|
|
|
|
$this->renderSuccess('通讯列表',$data);
|
|
}
|
|
/**
|
|
* Comment: 获取通讯记录
|
|
* Author: zzw
|
|
* Date: 2019/8/26 17:42
|
|
*/
|
|
public function get(){
|
|
global $_W,$_GPC;
|
|
#1、参数接收
|
|
$page = $_GPC['page'] ? : 1;
|
|
$pageIndex = $_GPC['page_index'] ? : 10;
|
|
$thisId = $_GPC['id'] ? : $_W['mid'];//当前使用者的id:用户id(默认)|商户id
|
|
$thisType = $_GPC['type'] ? : 1;// 当前使用者的类型;1=用户(默认);2=商户
|
|
$otherPartyType = $_GPC['other_party_type'] ? : 1;//通讯对象类型;1=用户;2=商户
|
|
$otherPartyId = $_GPC['other_party_id'] or $this->renderError('缺少参数:other_party_id');//通讯对象id
|
|
#1、类型一致,id一致 则是给自己发送消息
|
|
if($thisId == $otherPartyId && $thisType == $otherPartyType) $this->renderError("不能给自己发送信息哦",['url'=>h5_url('pages/mainPages/userCenter/userCenter')]);
|
|
$sendInfo['send_id'] = $thisId;//发送方id
|
|
$sendInfo['send_type'] = $thisType;//发送方类型(1=用户;2=商户)
|
|
$sendInfo['receive_id'] = $otherPartyId;//接收人id
|
|
$sendInfo['receive_type'] = $otherPartyType;//接收人类型(1=用户;2=商户)
|
|
|
|
$data = Im::imRecord($page,$pageIndex,$sendInfo);
|
|
#3、修改信息为已读
|
|
//if(is_array($data['list']) && count($data['list']) > 0) Im::is_read(array_column($data['list'],'id'),$thisId);
|
|
//修改所有对方发送的通讯信息为已读
|
|
$where = " send_id = {$otherPartyId} AND send_type = {$otherPartyType} AND receive_id = {$thisId} AND receive_type = {$thisType} AND is_read = 0 ";
|
|
$sql = " UPDATE ".tablename(PDO_NAME."im")." SET is_read = 1 WHERE {$where} ";
|
|
pdo_query($sql);
|
|
#4、信息排序
|
|
$sortArr = array_column($data['list'], 'create_time');
|
|
array_multisort($sortArr, SORT_ASC, $data['list']);
|
|
#4、获取聊天对象的昵称 1=用户;2=商户
|
|
if($otherPartyType == 1){
|
|
$data['receive_name'] = pdo_getcolumn(PDO_NAME."member",['id'=>$otherPartyId],'nickname');
|
|
}else{
|
|
$data['receive_name'] = pdo_getcolumn(PDO_NAME."merchantdata",['id'=>$otherPartyId],'storename');
|
|
}
|
|
|
|
$this->renderSuccess('通讯记录',$data);
|
|
}
|
|
/**
|
|
* Comment: 发送通讯信息
|
|
* Author: zzw
|
|
* Date: 2019/8/26 15:48
|
|
*/
|
|
public function send (){
|
|
global $_W , $_GPC;
|
|
//判断是否绑定手机
|
|
$mastmobile = unserialize($_W['wlsetting']['userset']['plugin']);
|
|
if (empty($_W['wlmember']['mobile']) && in_array('private',$mastmobile)){
|
|
$this->renderError('未绑定手机号');
|
|
}
|
|
$freeChat = Rights::freeChatRights($_W['mid'],$_GPC['send_type']);
|
|
if (!$freeChat) {
|
|
$memberIsChat = Rights::memberIsChat($_W['mid']);
|
|
if (!$memberIsChat['status']) $this->renderError($memberIsChat['msg'],['is_jump' => 1]);
|
|
}
|
|
#1、参数接收
|
|
$sendId = $_GPC['send_id'] ? : $_W['mid'];//发送方id
|
|
$sendType = $_GPC['send_type'] ? : 1;//发送方类型(1=用户;2=商户)
|
|
$type = $_GPC['type'] ? : 0;//内容类型(0=文本信息(默认),1=图片地址,2=视频信息 3=名片 4=简历)
|
|
$plugin = $_GPC['plugin'] ? : '';//
|
|
!empty($_GPC['receive_id']) ? $receiveId = $_GPC['receive_id'] : $this->renderError('缺少参数:receive_id');//接收人id
|
|
!empty($_GPC['receive_type']) ? $receiveType = $_GPC['receive_type'] : $this->renderError('缺少参数:receive_type');//接收人类型(1=用户;2=商户)
|
|
!empty($_GPC['content']) ? $content = $_GPC['content'] : $this->renderError('缺少参数:content');//发送内容
|
|
if($sendId == $receiveId && $sendType == $receiveType) $this->renderError("不能给自己发送信息哦");
|
|
#2、信息拼装
|
|
$data['uniacid'] = $_W['uniacid'];//
|
|
$data['send_id'] = $sendId;//发送方id
|
|
$data['send_type'] = $sendType;//发送方类型(1=用户;2=商户)
|
|
$data['receive_id'] = $receiveId;//接收人id
|
|
$data['receive_type'] = $receiveType;//接收人类型(1=用户;2=商户)
|
|
$data['create_time'] = time();//发送时间(建立时间)
|
|
$data['type'] = $type;//内容类型(0=文本信息(默认),1=图片地址,2=视频信息)
|
|
$data['plugin'] = $plugin;//通讯插件
|
|
if(empty($data['type'])){
|
|
$data['content'] = htmlspecialchars_decode($content);//发送内容
|
|
}else{
|
|
$data['content'] = $content;//发送内容
|
|
}
|
|
|
|
#2、信息记录
|
|
$res = Im::insert($data);
|
|
if ($res) $this->renderSuccess('发送成功');
|
|
else $this->renderError('发送失败');
|
|
}
|
|
/**
|
|
* Comment: 通讯设置
|
|
* Author: zzw
|
|
* Date: 2021/3/8 11:57
|
|
*/
|
|
public function getSetInfo(){
|
|
global $_W,$_GPC;
|
|
//获取基本设置
|
|
//$set = Setting::wlsetting_read('im_set');
|
|
//判断用户是否存在简历信息
|
|
$isResume = pdo_get(PDO_NAME."recruit_resume",['mid' => $_W['mid']]);
|
|
//信息拼接
|
|
$data = [
|
|
'type' => 1,
|
|
'port' => '',
|
|
'mid' => $_W['mid'],
|
|
'is_card' => p('citycard') ? 1 : 0,//是否存在名片插件 0=不存在,1=存在
|
|
'is_recruit' => p('recruit') ? 1 : 0,//是否存在求职招聘插件 0=不存在,1=存在
|
|
'is_resume' => $isResume ? 1 : 0,//是否存在简历信息 0=不存在,1=存在
|
|
'resume_id' => $isResume['id'],//简历id
|
|
];
|
|
|
|
$this->renderSuccess('通讯设置信息',$data);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|