正在显示
3 个修改的文件
包含
59 行增加
和
8 行删除
@@ -251,19 +251,18 @@ class House extends Api | @@ -251,19 +251,18 @@ class House extends Api | ||
251 | $qiniu = get_addon_config('qiniu')['cdnurl']; | 251 | $qiniu = get_addon_config('qiniu')['cdnurl']; |
252 | $user_id = $this->auth->id; | 252 | $user_id = $this->auth->id; |
253 | $area = $this->request->param('area'); | 253 | $area = $this->request->param('area'); |
254 | - if(empty($area)){ | ||
255 | - $this->error('缺少必要参数'); | ||
256 | - } | ||
257 | $keyword = $this->request->param('keyword'); | 254 | $keyword = $this->request->param('keyword'); |
255 | + $sql = Db::name('house'); | ||
256 | + $where = []; | ||
257 | + if(!empty($area)){ | ||
258 | + $where['area'] = ['like',"%$area%"]; | ||
259 | + } | ||
258 | if(!empty($keyword)){ | 260 | if(!empty($keyword)){ |
259 | $where['name'] = ['like',"%$keyword%"]; | 261 | $where['name'] = ['like',"%$keyword%"]; |
260 | - }else{ | ||
261 | - $where = true; | ||
262 | } | 262 | } |
263 | 263 | ||
264 | //查询该市区下的所有小区 | 264 | //查询该市区下的所有小区 |
265 | $data = Db::name('house') | 265 | $data = Db::name('house') |
266 | - ->where('area','like',"%$area%") | ||
267 | ->where($where) | 266 | ->where($where) |
268 | ->field('id,name,area') | 267 | ->field('id,name,area') |
269 | ->order('createtime desc') | 268 | ->order('createtime desc') |
@@ -148,7 +148,7 @@ class HouseBoard extends Api | @@ -148,7 +148,7 @@ class HouseBoard extends Api | ||
148 | * @ApiMethod (POST) | 148 | * @ApiMethod (POST) |
149 | * | 149 | * |
150 | * @ApiHeaders (name=token, type=string, required=true, description="请求的Token") | 150 | * @ApiHeaders (name=token, type=string, required=true, description="请求的Token") |
151 | - * @ApiParams (name="house_board_id", type=inter, required=true, description="社区id") | 151 | + * @ApiParams (name="house_id", type=inter, required=true, description="社区id") |
152 | * @ApiParams (name="page", type="inter", required=false, description="当前页(默认1)") | 152 | * @ApiParams (name="page", type="inter", required=false, description="当前页(默认1)") |
153 | * @ApiParams (name="pageNum", type="inter", required=false, description="每页显示数据个数(默认10)") | 153 | * @ApiParams (name="pageNum", type="inter", required=false, description="每页显示数据个数(默认10)") |
154 | * | 154 | * |
@@ -174,7 +174,7 @@ class HouseBoard extends Api | @@ -174,7 +174,7 @@ class HouseBoard extends Api | ||
174 | $page = $this->request->param('page', 1, 'intval'); | 174 | $page = $this->request->param('page', 1, 'intval'); |
175 | $pageNum = $this->request->param('pageNum', 10, 'intval'); | 175 | $pageNum = $this->request->param('pageNum', 10, 'intval'); |
176 | $user_id = $this->auth->id; | 176 | $user_id = $this->auth->id; |
177 | - $house_id = $this->request->param('house_board_id'); | 177 | + $house_id = $this->request->param('house_id'); |
178 | if(empty($house_id)){ | 178 | if(empty($house_id)){ |
179 | $this->error('社区id不能为空'); | 179 | $this->error('社区id不能为空'); |
180 | } | 180 | } |
@@ -375,4 +375,56 @@ class HouseBoard extends Api | @@ -375,4 +375,56 @@ class HouseBoard extends Api | ||
375 | $this->success('success',$info); | 375 | $this->success('success',$info); |
376 | 376 | ||
377 | } | 377 | } |
378 | + | ||
379 | + /** | ||
380 | + * @ApiTitle (社区公告-社区活动) | ||
381 | + * @ApiSummary (社区公告-社区活动) | ||
382 | + * @ApiMethod (POST) | ||
383 | + * | ||
384 | + * @ApiHeaders (name=token, type=string, required=true, description="请求的Token") | ||
385 | + * @ApiParams (name="house_id", type="inter", required=true, description="社区id") | ||
386 | + * @ApiParams (name="user_id", type="inter", required=true, description="社区物业管理员用户id") | ||
387 | + * | ||
388 | + * @ApiReturn({ | ||
389 | + "code": 1, | ||
390 | + "msg": "success", | ||
391 | + "time": "1598587213", | ||
392 | + "data": [ | ||
393 | + { | ||
394 | + "id": 29, | ||
395 | + "title": "1", | ||
396 | + "content": "1", | ||
397 | + "activity_time": "2020-08-28-2020-08-28", | ||
398 | + "status": "已到期" | ||
399 | + } | ||
400 | + ] | ||
401 | + }) | ||
402 | + */ | ||
403 | + public function activity() | ||
404 | + { | ||
405 | + $user_id = $this->auth->id; | ||
406 | + $house_id = $this->request->param('house_id'); //社区id | ||
407 | + $now = time(); | ||
408 | + $list = Db::name('house_activity') | ||
409 | + ->alias('ha') | ||
410 | + ->join('house_activity_join haj','haj.house_activity_id = ha.id','left') | ||
411 | + ->where("find_in_set({$house_id},house_ids)") | ||
412 | + ->field('ha.id, | ||
413 | + ha.title, | ||
414 | + ha.content, | ||
415 | + ha.start_time, | ||
416 | + ha.end_time, | ||
417 | + haj.join_status | ||
418 | + ') | ||
419 | + ->order("ha.createtime desc") | ||
420 | + ->select(); | ||
421 | + foreach ($list as $k => &$v) { | ||
422 | + // 活动日期 | ||
423 | + $v['activity_time'] = date('Y-m-d',$v['start_time']).'-'.date('Y-m-d',$v['end_time']); | ||
424 | + // 活动日期 | ||
425 | + $v['status'] = $v['join_status'] == 1 ? '已报名' : ($v['end_time'] < time() ? '已到期' : '未报名'); | ||
426 | + unset($v['start_time'],$v['end_time'],$v['join_status'],); | ||
427 | + } | ||
428 | + $this->success('success',$list); | ||
429 | + } | ||
378 | } | 430 | } |
此 diff 太大无法显示。
-
请 注册 或 登录 后发表评论