...
|
...
|
@@ -12,8 +12,8 @@ namespace app\api\controller; |
|
|
use app\common\controller\Api;
|
|
|
use think\Cache;
|
|
|
use think\Db;
|
|
|
|
|
|
/**
|
|
|
use think\Validate;
|
|
|
/**
|
|
|
* 社区首页
|
|
|
*/
|
|
|
class House extends Api
|
...
|
...
|
@@ -117,9 +117,8 @@ class House extends Api |
|
|
$info['is_new'] = 1;
|
|
|
}
|
|
|
}
|
|
|
$this->success('success',$info);
|
|
|
|
|
|
}
|
|
|
$this->success('success',$info);
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -399,6 +398,9 @@ class House extends Api |
|
|
* @ApiMethod (POST)
|
|
|
* @ApiRoute (/api/house/city_list)
|
|
|
*
|
|
|
* @ApiParams (name="page", type="inter", required=false, description="当前页(默认1)")
|
|
|
* @ApiParams (name="pageNum", type="inter", required=false, description="每页显示数据个数(默认10)")
|
|
|
*
|
|
|
* @ApiReturn({
|
|
|
"code": 1,
|
|
|
"msg": "成功",
|
...
|
...
|
@@ -413,7 +415,10 @@ class House extends Api |
|
|
*/
|
|
|
public function city_list()
|
|
|
{
|
|
|
$data = Db::name('area')->field('id,name')->where('level',2)->select();
|
|
|
// $page = $this->request->param('page', 1, 'intval');
|
|
|
// $pageNum = $this->request->param('pageNum', 10, 'intval');
|
|
|
$data['total_num'] = Db::name('area')->field('id,name')->where('level',2)->count();
|
|
|
$data['info'] = Db::name('area')->field('id,name')->where('level',2)->select();
|
|
|
$this->success('success',$data);
|
|
|
|
|
|
}
|
...
|
...
|
@@ -561,7 +566,7 @@ class House extends Api |
|
|
* @ApiTitle (获取验证码)
|
|
|
* @ApiSummary (获取验证码)
|
|
|
* @ApiMethod (POST)
|
|
|
* @ApiRoute (/api/login/getcode)
|
|
|
* @ApiRoute (/api/house/getcode)
|
|
|
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
|
|
*
|
|
|
* @ApiParams (name="mobile", type="string", required=false, description="手机号")
|
...
|
...
|
@@ -605,7 +610,7 @@ class House extends Api |
|
|
* @ApiTitle (验证验证码)
|
|
|
* @ApiSummary (验证验证码)
|
|
|
* @ApiMethod (POST)
|
|
|
* @ApiRoute (/api/login/verify)
|
|
|
* @ApiRoute (/api/house/verify)
|
|
|
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
|
|
*
|
|
|
* @ApiParams (name="mobile", type="string", required=true, description="手机号")
|
...
|
...
|
@@ -638,4 +643,140 @@ class House extends Api |
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* @ApiTitle (社区物业管理员列表)
|
|
|
* @ApiSummary (社区物业管理员列表)
|
|
|
* @ApiMethod (POST)
|
|
|
* @ApiRoute (/api/house/house_admin_list)
|
|
|
*
|
|
|
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
|
|
* @ApiParams (name="house_id", type="string", required=true, description="小区id")
|
|
|
*
|
|
|
* @ApiReturn({
|
|
|
"code": 1,
|
|
|
"msg": "成功",
|
|
|
"time": "1571492001",
|
|
|
"data": {
|
|
|
"id"://id
|
|
|
"user_id"://用户id
|
|
|
"avatar"://管理员头像
|
|
|
"nickname"://昵称
|
|
|
"is_have"://是否带有红标签 1有2没有
|
|
|
}
|
|
|
})
|
|
|
*/
|
|
|
public function house_admin_list()
|
|
|
{
|
|
|
$user_id = $this->auth->id;
|
|
|
$house_id = $this->request->param('house_id');
|
|
|
if(empty($house_id)){
|
|
|
$this->error('缺少必要参数');
|
|
|
}
|
|
|
|
|
|
$data = Db::name('house_admin')
|
|
|
->alias('a')
|
|
|
->join('user b','a.user_id = b.id')
|
|
|
->where('a.house_id',$house_id)
|
|
|
->field('a.id,a.user_id,b.avatar,b.nickname')
|
|
|
->order('a.direct')
|
|
|
->select();
|
|
|
foreach ($data as &$v){
|
|
|
$mes = Db::name('message')
|
|
|
->where('house_id',$house_id)
|
|
|
->where('user_id',$v['user_id'])
|
|
|
->where('to_user_id',$user_id)
|
|
|
->where('is_read',2)
|
|
|
->find();
|
|
|
if(empty($mes)){
|
|
|
$v['is_have'] = 2;
|
|
|
}else{
|
|
|
$v['is_have'] = 1;
|
|
|
}
|
|
|
}
|
|
|
$this->success('success',$data);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @ApiTitle (聊天记录列表)
|
|
|
* @ApiSummary (聊天记录列表)
|
|
|
* @ApiMethod (POST)
|
|
|
* @ApiRoute (/api/house/chat_record)
|
|
|
*
|
|
|
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
|
|
* @ApiParams (name="house_id", type="inter", required=true, description="社区id")
|
|
|
* @ApiParams (name="user_id", type="inter", required=true, description="社区物业管理员用户id")
|
|
|
*
|
|
|
* @ApiReturn({
|
|
|
"code": 1,
|
|
|
"msg": "成功",
|
|
|
"time": "1571492001",
|
|
|
"data": {
|
|
|
"id"://id
|
|
|
"user_id"://发送者id
|
|
|
"house_id"://社区id
|
|
|
"to_user_id"://接收者用户id
|
|
|
"type"://消息类型1文字类型2图片类型
|
|
|
"content"://文字消息
|
|
|
"image"://图片消息
|
|
|
"is_read"://是否已读1已读2未读
|
|
|
"createtime"://创建时间
|
|
|
"updatetime"://修改时间
|
|
|
"nickname"://昵称
|
|
|
"is_have"://是否带有红标签 1有2没有
|
|
|
"is_left"://是否在右边 1是2否
|
|
|
}
|
|
|
})
|
|
|
*/
|
|
|
public function chat_record()
|
|
|
{
|
|
|
$qiniu = get_addon_config('qiniu')['cdnurl'];
|
|
|
$user_id = $this->auth->id; //当前登录用户id
|
|
|
$house_id = $this->request->param('house_id'); //社区id
|
|
|
$wuye_user_id = $this->request->param('user_id'); //物业用户id
|
|
|
if(empty($house_id) || empty($wuye_user_id)){
|
|
|
$this->error('缺少必要参数');
|
|
|
}
|
|
|
|
|
|
$house_admin = Db::name('house_admin')->where('user_id',$wuye_user_id)->where('house_id',$house_id)->find();
|
|
|
if(empty($house_admin)){
|
|
|
$this->error('参数有误,社区与管理员id不匹配');
|
|
|
}
|
|
|
|
|
|
$data = Db::name('message')
|
|
|
->where('house_id',$house_id)
|
|
|
->where('user_id',$user_id)
|
|
|
->where('to_user_id',$wuye_user_id)
|
|
|
->order('createtime desc')
|
|
|
->select();
|
|
|
foreach ($data as &$v){
|
|
|
$v['is_right'] = 1;
|
|
|
if($v['type'] == 2){
|
|
|
$v['image'] = $qiniu.$v['image'];
|
|
|
}
|
|
|
}
|
|
|
$arr = Db::name('message')
|
|
|
->where('house_id',$house_id)
|
|
|
->where('user_id',$wuye_user_id)
|
|
|
->where('to_user_id',$user_id)
|
|
|
->order('createtime desc')
|
|
|
->select();
|
|
|
foreach ($arr as &$v){
|
|
|
$v['is_right'] = 2;
|
|
|
if($v['type'] == 2){
|
|
|
$v['image'] = $qiniu.$v['image'];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
$info = array_merge($data,$arr);
|
|
|
|
|
|
array_multisort(array_column($info,'createtime'),SORT_DESC,$info);
|
|
|
foreach ($info as &$val){
|
|
|
$val['createtime'] = date('Y-m-d H:i:s',$val['createtime']);
|
|
|
}
|
|
|
|
|
|
$this->success('success',$info);
|
|
|
|
|
|
}
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|