|
@@ -411,9 +411,38 @@ class HouseAdmin extends Api |
|
@@ -411,9 +411,38 @@ class HouseAdmin extends Api |
411
|
$count >= 2 && $this->error('本周发布次数已用完');
|
411
|
$count >= 2 && $this->error('本周发布次数已用完');
|
412
|
$images = $this->request->param('images/a');
|
412
|
$images = $this->request->param('images/a');
|
413
|
$post['images'] = implode(',',$images);
|
413
|
$post['images'] = implode(',',$images);
|
414
|
- (new HouseBoard)->allowField(true)->save(array_merge([
|
|
|
415
|
- 'admin_user_id' => $this->auth->id
|
|
|
416
|
- ],$post));
|
414
|
+ Db::startTrans();
|
|
|
415
|
+ try{
|
|
|
416
|
+ (new HouseBoard)->allowField(true)->save(array_merge([
|
|
|
417
|
+ 'admin_user_id' => $this->auth->id
|
|
|
418
|
+ ],$post));
|
|
|
419
|
+ // 该社区下的业主ID
|
|
|
420
|
+ $user_id_arr = UserHouse::where('house_id',$post['house_id'])
|
|
|
421
|
+ ->where('status',2)
|
|
|
422
|
+ ->column('user_id');
|
|
|
423
|
+ // 发送模板消息
|
|
|
424
|
+ if(!empty($user_id_arr)){
|
|
|
425
|
+ $house_name = House::where('house_id',$post['house_id'])->value('name');
|
|
|
426
|
+ $send_data = array(
|
|
|
427
|
+ "first" => '您绑定的社区【'.$house_name.'】发布了一条公告',
|
|
|
428
|
+ 'keyword1' => $post['title'],
|
|
|
429
|
+ "keyword2" => date('Y-m-s H:i:s',time()),
|
|
|
430
|
+ "remark" => '',
|
|
|
431
|
+ );
|
|
|
432
|
+ foreach ($user_id_arr as $user_id) {
|
|
|
433
|
+ $openid = Db::name('third')->where('user_id',$user_id)->value('openid');
|
|
|
434
|
+ $url = config('option.vue_url') . '/messagelk?is_template=1&house_id='.$post['house_id'].'&user_id='.$user_id;
|
|
|
435
|
+ $this->wxsendmessage($openid,$send_data,config('option.template')['msg'],$url);
|
|
|
436
|
+ }
|
|
|
437
|
+ }
|
|
|
438
|
+ Db::commit();
|
|
|
439
|
+ } catch (PDOException $e) {
|
|
|
440
|
+ Db::rollback();
|
|
|
441
|
+ $this->error($e->getMessage());
|
|
|
442
|
+ } catch (Exception $e) {
|
|
|
443
|
+ Db::rollback();
|
|
|
444
|
+ $this->error($e->getMessage());
|
|
|
445
|
+ }
|
417
|
$this->success('success');
|
446
|
$this->success('success');
|
418
|
}
|
447
|
}
|
419
|
|
448
|
|
|
@@ -910,10 +939,10 @@ class HouseAdmin extends Api |
|
@@ -910,10 +939,10 @@ class HouseAdmin extends Api |
910
|
$post = $this->request->param();
|
939
|
$post = $this->request->param();
|
911
|
empty($post['house_id']) && $this->error('缺少必要参数');
|
940
|
empty($post['house_id']) && $this->error('缺少必要参数');
|
912
|
empty($post['name']) && $this->error('请填写标题');
|
941
|
empty($post['name']) && $this->error('请填写标题');
|
913
|
- empty($post['phone']) && $this->error('请填写手机号');
|
942
|
+ empty($post['phone']) && $this->error('请填写电话');
|
914
|
empty($post['weigh']) && $this->error('请填写排序号');
|
943
|
empty($post['weigh']) && $this->error('请填写排序号');
|
915
|
- if (!Validate::regex($post['phone'], "^1\d{10}$")) {
|
|
|
916
|
- $this->error(__('Mobile is incorrect'));
|
944
|
+ if (!Validate::regex($post['phone'], "^1\d{10}$") && !Validate::regex($post['phone'], "^([0-9]{3,4}-)?[0-9]{7,8}$")) {
|
|
|
945
|
+ $this->error('电话格式不正确');
|
917
|
}
|
946
|
}
|
918
|
$admin = HouseAdminModel::get(['user_id'=>$this->auth->id,'house_id'=>$post['house_id'],'is_direct'=>1]);
|
947
|
$admin = HouseAdminModel::get(['user_id'=>$this->auth->id,'house_id'=>$post['house_id'],'is_direct'=>1]);
|
919
|
empty($admin) && $this->error('您不是该小区的主管理员');
|
948
|
empty($admin) && $this->error('您不是该小区的主管理员');
|