...
|
...
|
@@ -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('您不是该小区的主管理员');
|
...
|
...
|
|