...
|
...
|
@@ -177,9 +177,9 @@ class HouseAdmin extends Api |
|
|
$house_id = $this->request->param('house_id');
|
|
|
$mobile = $this->request->param('mobile');
|
|
|
$captcha = $this->request->param('captcha');
|
|
|
if (!$house_id || !$mobile || !$captcha) {
|
|
|
$this->error('缺少必要参数');
|
|
|
}
|
|
|
empty($house_id) && $this->error('缺少必要参数');
|
|
|
empty($mobile) && $this->error('请输入手机号');
|
|
|
empty($captcha) && $this->error('请输入验证码');
|
|
|
if (!Validate::regex($mobile, "^1\d{10}$")) {
|
|
|
$this->error('手机号格式不正确');
|
|
|
}
|
...
|
...
|
@@ -539,6 +539,7 @@ class HouseAdmin extends Api |
|
|
"total_num": 1, //总条数
|
|
|
"list": [{
|
|
|
"id": 1, //业主ID
|
|
|
"avatar": "http://community.qiniu.brotop.cn", //业主头像
|
|
|
"name": "liujianch", //业主名称
|
|
|
"remark": "" //业主备注
|
|
|
}]
|
...
|
...
|
@@ -552,16 +553,21 @@ class HouseAdmin extends Api |
|
|
$house_id = $this->request->param('house_id');
|
|
|
$keyword = $this->request->param('keyword');
|
|
|
empty($house_id) && $this->error('缺少必要参数');
|
|
|
$where['house_id'] = $house_id;
|
|
|
$where['status'] = 2;
|
|
|
$where['uh.house_id'] = $house_id;
|
|
|
$where['uh.status'] = 2;
|
|
|
if(!empty($keyword)){
|
|
|
$where['name|remark'] = ['like','%'.$keyword.'%'];
|
|
|
$where['uh.name|uh.remark'] = ['like','%'.$keyword.'%'];
|
|
|
}
|
|
|
$list = UserHouse::where($where)
|
|
|
->field('id,name,remark')
|
|
|
->order('createtime desc')
|
|
|
$list = UserHouse::alias('uh')
|
|
|
->join('user u','u.id = uh.user_id')
|
|
|
->where($where)
|
|
|
->field('uh.id,u.avatar,uh.name,uh.remark')
|
|
|
->order('uh.createtime desc')
|
|
|
->page($page,$pageNum)
|
|
|
->select();
|
|
|
foreach($list as &$v){
|
|
|
$v['avatar'] = cdnurl($v['avatar']);
|
|
|
}
|
|
|
$this->success('success',['total_num'=>count($list),'list'=>$list]);
|
|
|
}
|
|
|
|
...
|
...
|
@@ -585,9 +591,7 @@ class HouseAdmin extends Api |
|
|
$user_house_id = $this->request->param('user_house_id');
|
|
|
$remark = $this->request->param('remark');
|
|
|
empty($user_house_id) && $this->error('缺少必要参数');
|
|
|
if(!$user_house_id || !$remark){
|
|
|
$this->error('缺少必要参数');
|
|
|
}
|
|
|
empty($remark) && $this->error('请填写备注');
|
|
|
$info = UserHouse::get($user_house_id);
|
|
|
empty($info) && $this->error('业主信息不存在');
|
|
|
|
...
|
...
|
@@ -702,17 +706,17 @@ class HouseAdmin extends Api |
|
|
$pageNum = $this->request->param('pageNum', 10, 'intval');
|
|
|
$message_id = $this->request->param('message_id');
|
|
|
empty($message_id) && $this->error('缺少必要参数');
|
|
|
$info = Message::get($message_id);
|
|
|
empty($info) && $this->error('消息不存在');
|
|
|
$info->is_read_object = 1;
|
|
|
$info->save();
|
|
|
if($info['type'] == 2) {
|
|
|
$msg = Message::get($message_id);
|
|
|
empty($msg) && $this->error('消息不存在');
|
|
|
$msg->is_read_object = 1;
|
|
|
$msg->save();
|
|
|
if($msg['type'] == 2) {
|
|
|
$model = new StoreComment();
|
|
|
$object_model = new \app\api\model\Store();
|
|
|
$object_field = 'id,store_name as nickname,store_icon as avatar';
|
|
|
$object_id = 'store_id';
|
|
|
$object_user_id = 'store_user_id';
|
|
|
} elseif($info['type'] == 3) {
|
|
|
} elseif($msg['type'] == 3) {
|
|
|
$model = new HouseComment();
|
|
|
$object_model = new \app\api\model\HouseAdmin();
|
|
|
$object_field = 'id,nickname,avatar';
|
...
|
...
|
@@ -722,9 +726,9 @@ class HouseAdmin extends Api |
|
|
$this->error('消息类型错误');
|
|
|
}
|
|
|
$list = $model->where([
|
|
|
'user_id' => $info['user_id'],
|
|
|
$object_id => $info['object_id'],
|
|
|
$object_user_id => $info['object_user_id'],
|
|
|
'user_id' => $msg['user_id'],
|
|
|
$object_id => $msg['object_id'],
|
|
|
$object_user_id => $msg['object_user_id'],
|
|
|
])->order(['createtime'=>'asc'])
|
|
|
->page($page,$pageNum)
|
|
|
->select();
|
...
|
...
|
@@ -732,17 +736,87 @@ class HouseAdmin extends Api |
|
|
foreach ($list as &$v) {
|
|
|
if($v['type'] == 1) {
|
|
|
$user = $user_model->field('id,nickname,avatar')->where('id',$v['user_id'])->find();
|
|
|
$user['avatar'] = cdnurl($user['avatar']);
|
|
|
} else {
|
|
|
$user = $object_model->field($object_field)->where(['house_id'=>$v['house_id'],'user_id'=>$v['house_user_id']])->find();
|
|
|
$user['avatar'] = cdnurl($user['avatar']);
|
|
|
if($msg['type'] == 2) {
|
|
|
$user = $object_model->field($object_field)->where('id',$v[$object_id])->find();
|
|
|
} elseif ($msg['type'] == 3) {
|
|
|
$user = $object_model->field($object_field)->where(['house_id'=>$v[$object_id],'user_id'=>$v[$object_user_id]])->find();
|
|
|
}
|
|
|
}
|
|
|
$user['avatar'] = cdnurl($user['avatar']);
|
|
|
$v['user'] = $user;
|
|
|
}
|
|
|
$this->success('success',['total_num'=>count($list),'list'=>$list]);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @ApiTitle (社区管理员-留言消息-回复)
|
|
|
* @ApiSummary (社区管理员-留言消息-回复)
|
|
|
* @ApiMethod (POST)
|
|
|
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
|
|
* @ApiParams (name="message_id", type="integer", required=true, description="消息ID")
|
|
|
* @ApiParams (name="content", type="string", required=true, description="留言内容")
|
|
|
* @ApiParams (name="image", type="string", required=true, description="图片")
|
|
|
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
|
|
|
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
|
|
|
* @ApiReturn ({
|
|
|
'code':'1',
|
|
|
'msg':'返回成功'
|
|
|
})
|
|
|
*/
|
|
|
public function messageReply()
|
|
|
{
|
|
|
$message_id = $this->request->param('message_id');
|
|
|
$content = $this->request->param('content');
|
|
|
$image = $this->request->param('image');
|
|
|
empty($message_id) && $this->error('缺少必要参数');
|
|
|
if(empty($content) && empty($image)) {
|
|
|
$this->error('请填写内容或上传图片');
|
|
|
}
|
|
|
$msg = Message::get($message_id);
|
|
|
empty($msg) && $this->error('留言消息不存在');
|
|
|
Db::startTrans();
|
|
|
try{
|
|
|
HouseComment::create([
|
|
|
'user_id' => $msg['user_id'],
|
|
|
'house_id' => $msg['object_id'],
|
|
|
'house_user_id' => $msg['object_user_id'],
|
|
|
'type' => 2,
|
|
|
'content' => $content,
|
|
|
'image' => $image,
|
|
|
]);
|
|
|
// 记录最新内容
|
|
|
$msg = Message::get([
|
|
|
'user_id' => $msg['user_id'],
|
|
|
'object_id' => $msg['object_id'],
|
|
|
'object_user_id' => $msg['object_user_id'],
|
|
|
]);
|
|
|
$msg->content = $content;
|
|
|
$msg->image = $image;
|
|
|
$msg->is_read_user = 2;
|
|
|
$msg->is_read_object = 1;
|
|
|
$msg->save();
|
|
|
// 发送模板消息
|
|
|
// $send_data = array(
|
|
|
// "first" => '',
|
|
|
// 'keyword1' => '',
|
|
|
// "keyword2" => '',
|
|
|
// "keyword3" => date('Y-m-s',time()),
|
|
|
// "remark" => '',
|
|
|
// );
|
|
|
// $this->wxsendmessage('','','');
|
|
|
Db::commit();
|
|
|
} catch (PDOException $e) {
|
|
|
Db::rollback();
|
|
|
$this->error($e->getMessage());
|
|
|
} catch (Exception $e) {
|
|
|
Db::rollback();
|
|
|
$this->error($e->getMessage());
|
|
|
}
|
|
|
$this->success('回复成功');
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @ApiTitle (社区管理员-社区信息)
|
|
|
* @ApiSummary (社区管理员-社区信息)
|
|
|
* @ApiMethod (POST)
|
...
|
...
|
|