作者 何书鹏
1 个管道 的构建 通过 耗费 1 秒

合并分支 'heshupeng' 到 'master'

管理员公告管理



查看合并请求 !289
... ... @@ -93,7 +93,11 @@ class House extends Api
$info['house_name'] = Db::name('house')->where('id',$data['house_id'])->value('name');
//查询该社区的社区公告
$house_board = Db::name('house_board')->where('house_id',$data['house_id'])->order('createtime desc')->find();
$house_board = Db::name('house_board')
->where('house_id',$data['house_id'])
->where('deletetime','') //未下架
->order('createtime desc')
->find();
if(empty($house_board)){
$info['is_have'] = 2;
$info['title'] = '';
... ...
... ... @@ -411,9 +411,38 @@ class HouseAdmin extends Api
$count >= 2 && $this->error('本周发布次数已用完');
$images = $this->request->param('images/a');
$post['images'] = implode(',',$images);
(new HouseBoard)->allowField(true)->save(array_merge([
'admin_user_id' => $this->auth->id
],$post));
Db::startTrans();
try{
(new HouseBoard)->allowField(true)->save(array_merge([
'admin_user_id' => $this->auth->id
],$post));
// 该社区下的业主ID
$user_id_arr = UserHouse::where('house_id',$post['house_id'])
->where('status',2)
->column('user_id');
// 发送模板消息
if(!empty($user_id_arr)){
$house_name = House::where('house_id',$post['house_id'])->value('name');
$send_data = array(
"first" => '您绑定的社区【'.$house_name.'】发布了一条公告',
'keyword1' => $post['title'],
"keyword2" => date('Y-m-s H:i:s',time()),
"remark" => '',
);
foreach ($user_id_arr as $user_id) {
$openid = Db::name('third')->where('user_id',$user_id)->value('openid');
$url = config('option.vue_url') . '/messagelk?is_template=1&house_id='.$post['house_id'].'&user_id='.$user_id;
$this->wxsendmessage($openid,$send_data,config('option.template')['msg'],$url);
}
}
Db::commit();
} catch (PDOException $e) {
Db::rollback();
$this->error($e->getMessage());
} catch (Exception $e) {
Db::rollback();
$this->error($e->getMessage());
}
$this->success('success');
}
... ... @@ -910,10 +939,10 @@ class HouseAdmin extends Api
$post = $this->request->param();
empty($post['house_id']) && $this->error('缺少必要参数');
empty($post['name']) && $this->error('请填写标题');
empty($post['phone']) && $this->error('请填写手机号');
empty($post['phone']) && $this->error('请填写电话');
empty($post['weigh']) && $this->error('请填写排序号');
if (!Validate::regex($post['phone'], "^1\d{10}$")) {
$this->error(__('Mobile is incorrect'));
if (!Validate::regex($post['phone'], "^1\d{10}$") && !Validate::regex($post['phone'], "^([0-9]{3,4}-)?[0-9]{7,8}$")) {
$this->error('电话格式不正确');
}
$admin = HouseAdminModel::get(['user_id'=>$this->auth->id,'house_id'=>$post['house_id'],'is_direct'=>1]);
empty($admin) && $this->error('您不是该小区的主管理员');
... ...
... ... @@ -92,6 +92,7 @@ class HouseBoard extends Api
/*最新公告信息*/
$house_board = Db::name('house_board')
->where('house_id',$data['house_id'])
->where('deletetime','') //未下架
->order('createtime desc')
->field('id,title,content,look_num,createtime,images')
->find();
... ... @@ -223,6 +224,7 @@ class HouseBoard extends Api
->count();
$data['info'] = Db::name('house_board')
->where('house_id',$house_id)
->where('deletetime','') //未下架
->order('weigh desc')
->page($page,$pageNum)
->select();
... ...