作者 Cool
1 个管道 的构建 通过 耗费 0 秒

Merge branch 'master' of http://114.215.101.231:8099/guosheng/community into Branch_liuzhen

... ... @@ -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',null) //未下架
->order('createtime desc')
->find();
if(empty($house_board)){
$info['is_have'] = 2;
$info['title'] = '';
... ...
... ... @@ -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('您不是该小区的主管理员');
... ...
... ... @@ -92,6 +92,7 @@ class HouseBoard extends Api
/*最新公告信息*/
$house_board = Db::name('house_board')
->where('house_id',$data['house_id'])
->where('deletetime',null) //未下架
->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',null) //未下架
->order('weigh desc')
->page($page,$pageNum)
->select();
... ...
... ... @@ -35,9 +35,11 @@ return array (
'mail_smtp_pass' => 'password',
'mail_verify_type' => '2',
'mail_from' => '10000@qq.com',
'contact' => '',
'settled' => '',
'contact' => '联系我们喲',
'settled' => '<span style="white-space:normal;">联系我们喲</span>',
'send_score' => '800',
'withdraw_percent' => '100',
'withdraw_rule' => '',
'withdraw_rule' => '<br />',
'phone' => '010-12345678',
'house_board_count' => '2',
);
\ No newline at end of file
... ...