...
|
...
|
@@ -376,7 +376,9 @@ class HouseAdmin extends Api |
|
|
$count = HouseBoard::whereTime('createtime', 'week')
|
|
|
->where('house_id',$house_id)
|
|
|
->count();
|
|
|
$times = $count >= 2 ? 0 : 2-$count;
|
|
|
// 社区每周可发布公告次数
|
|
|
$house_board_count = config('site.house_board_count');
|
|
|
$times = $count >= $house_board_count ? 0 : $house_board_count-$count;
|
|
|
$this->success('success',compact('times'));
|
|
|
}
|
|
|
|
...
|
...
|
@@ -408,12 +410,45 @@ class HouseAdmin extends Api |
|
|
$count = HouseBoard::whereTime('createtime', 'week')
|
|
|
->where('house_id',$post['house_id'])
|
|
|
->count();
|
|
|
$count >= 2 && $this->error('本周发布次数已用完');
|
|
|
// 社区每周可发布公告次数
|
|
|
$house_board_count = config('site.house_board_count');
|
|
|
$count >= $house_board_count && $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('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');
|
|
|
// 把用户的当前社区改为发送公告的小区
|
|
|
Db::name('user')->where('id',$user_id)->setField('house_id',$post['house_id']);
|
|
|
$url = config('option.vue_url') . '/affiche';
|
|
|
$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 +945,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('您不是该小区的主管理员');
|
...
|
...
|
|