正在显示
3 个修改的文件
包含
124 行增加
和
11 行删除
@@ -167,7 +167,7 @@ class House extends Api | @@ -167,7 +167,7 @@ class House extends Api | ||
167 | 167 | ||
168 | $data = Db::name('house_board') | 168 | $data = Db::name('house_board') |
169 | ->field('id,house_id,title,content,look_num,createtime') | 169 | ->field('id,house_id,title,content,look_num,createtime') |
170 | - ->where('deletime','') | 170 | + ->where('deletetime','') |
171 | ->where('id',$id) | 171 | ->where('id',$id) |
172 | ->find(); | 172 | ->find(); |
173 | $data['createtime'] = date('Y-m-d',$data['createtime']); | 173 | $data['createtime'] = date('Y-m-d',$data['createtime']); |
@@ -392,9 +392,14 @@ class HouseBoard extends Api | @@ -392,9 +392,14 @@ class HouseBoard extends Api | ||
392 | { | 392 | { |
393 | "id": // 活动id | 393 | "id": // 活动id |
394 | "title": // 活动标题 | 394 | "title": // 活动标题 |
395 | + "spec_type": // 活动规格:0=无规格(免费),1=单规格,2=多规格 | ||
395 | "content": // 活动描述 | 396 | "content": // 活动描述 |
396 | "activity_time": 活动日期 | 397 | "activity_time": 活动日期 |
397 | - "status": // 活动状态 | 398 | + "price": // 报名费用 |
399 | + "status": { // 活动状态 | ||
400 | + "text": // 状态名称 | ||
401 | + "value": // 状态值 0=报名中,1=已报名,2=已到期 | ||
402 | + } | ||
398 | } | 403 | } |
399 | ] | 404 | ] |
400 | }) | 405 | }) |
@@ -404,27 +409,135 @@ class HouseBoard extends Api | @@ -404,27 +409,135 @@ class HouseBoard extends Api | ||
404 | $user_id = $this->auth->id; | 409 | $user_id = $this->auth->id; |
405 | $house_id = $this->request->param('house_id'); //社区id | 410 | $house_id = $this->request->param('house_id'); //社区id |
406 | empty($house_id) && $this->error('缺少必要参数'); | 411 | empty($house_id) && $this->error('缺少必要参数'); |
407 | - $now = time(); | 412 | + $list = $this->getActivityList("find_in_set({$house_id},house_ids)"); |
413 | + $this->success('success',$list); | ||
414 | + } | ||
415 | + | ||
416 | + /** | ||
417 | + * @ApiTitle (社区公告-社区活动-详情) | ||
418 | + * @ApiSummary (社区公告-社区活动-详情) | ||
419 | + * @ApiMethod (POST) | ||
420 | + * | ||
421 | + * @ApiHeaders (name=token, type=string, required=true, description="请求的Token") | ||
422 | + * @ApiParams (name="house_activity_id", type="inter", required=true, description="社区活动id") | ||
423 | + * | ||
424 | + * @ApiReturn({ | ||
425 | + "code": 1, | ||
426 | + "msg": "success", | ||
427 | + "time": "1598587213", | ||
428 | + "data": { | ||
429 | + "id": // 活动id | ||
430 | + "title": // 活动标题 | ||
431 | + "spec_type": // 活动规格:0=无规格(免费),1=单规格,2=多规格 | ||
432 | + "content": // 活动描述 | ||
433 | + "activity_time": 活动日期 | ||
434 | + "price": // 报名费用 | ||
435 | + "status": { // 活动状态 | ||
436 | + "text": // 状态名称 | ||
437 | + "value": // 状态值 0=报名中,1=已报名,2=已到期 | ||
438 | + } | ||
439 | + } | ||
440 | + }) | ||
441 | + */ | ||
442 | + public function activityInfo() | ||
443 | + { | ||
444 | + $user_id = $this->auth->id; | ||
445 | + $house_activity_id = $this->request->param('house_activity_id'); //社区id | ||
446 | + empty($house_activity_id) && $this->error('缺少必要参数'); | ||
447 | + $list = $this->getActivityList(['ha.id'=>$house_activity_id]); | ||
448 | + $info = !empty($list) ? $list[0] : []; | ||
449 | + $this->success('success',$info); | ||
450 | + } | ||
451 | + | ||
452 | + /** | ||
453 | + * 获取活动信息 | ||
454 | + */ | ||
455 | + private function getActivityList($where){ | ||
408 | $list = Db::name('house_activity') | 456 | $list = Db::name('house_activity') |
409 | ->alias('ha') | 457 | ->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, | 458 | + ->join('house_join hj','hj.house_activity_id = ha.id','left') |
459 | + ->where($where) | ||
460 | + ->field(' | ||
461 | + ha.id, | ||
413 | ha.title, | 462 | ha.title, |
414 | ha.content, | 463 | ha.content, |
415 | ha.start_time, | 464 | ha.start_time, |
416 | ha.end_time, | 465 | ha.end_time, |
417 | - haj.join_status | 466 | + ha.spec_type, |
467 | + hj.pay_status | ||
418 | ') | 468 | ') |
419 | ->order("ha.createtime desc") | 469 | ->order("ha.createtime desc") |
420 | ->select(); | 470 | ->select(); |
421 | foreach ($list as $k => &$v) { | 471 | foreach ($list as $k => &$v) { |
472 | + // 活动报名费用 | ||
473 | + $price = Db::name('house_activity_spec')->where('house_activity_id',$v['id'])->value('price'); | ||
474 | + $v['price'] = $price > 0 ? $price : 0; | ||
422 | // 活动日期 | 475 | // 活动日期 |
423 | $v['activity_time'] = date('Y-m-d',$v['start_time']).'-'.date('Y-m-d',$v['end_time']); | 476 | $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']); | 477 | + // 活动状态 |
478 | + if($v['pay_status'] == '1'){ | ||
479 | + $status = ['text'=>'已报名','value'=>1]; | ||
480 | + }else{ | ||
481 | + $status = $v['end_time'] < time() ? ['text'=>'已到期','value'=>2] : ['text'=>'报名中','value'=>0]; | ||
427 | } | 482 | } |
428 | - $this->success('success',$list); | 483 | + $v['status'] = $status; |
484 | + unset($v['start_time'],$v['end_time'],$v['pay_status']); | ||
485 | + } | ||
486 | + return $list; | ||
487 | + } | ||
488 | + | ||
489 | + /** | ||
490 | + * @ApiTitle (社区公告-社区活动-获取规格) | ||
491 | + * @ApiSummary (社区公告-社区活动-获取规格) | ||
492 | + * @ApiMethod (POST) | ||
493 | + * @ApiParams (name="house_activity_id", type="integer", required=true, description="活动ID") | ||
494 | + * @ApiReturnParams (name="code", type="integer", required=true, sample="0") | ||
495 | + * @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功") | ||
496 | + * @ApiReturnParams (name="data", type="object", description="扩展数据返回") | ||
497 | + * @ApiReturn ({ | ||
498 | + "code": 1, | ||
499 | + "msg": "成功", | ||
500 | + "time": "1598600665", | ||
501 | + "data": { | ||
502 | + "spec_attr": [ | ||
503 | + { | ||
504 | + "group_id": 25, | ||
505 | + "group_name": "颜色", | ||
506 | + "spec_items": [ | ||
507 | + { | ||
508 | + "item_id": 52, | ||
509 | + "spec_value": "白色" | ||
510 | + }, | ||
511 | + { | ||
512 | + "item_id": 54, | ||
513 | + "spec_value": "黑色" | ||
514 | + } | ||
515 | + ] | ||
516 | + } | ||
517 | + ], | ||
518 | + "spec_list": { | ||
519 | + "52_50": { | ||
520 | + "spec_sku_id": "52_50", | ||
521 | + "price": "12.00" | ||
522 | + } | ||
523 | + } | ||
524 | + } | ||
525 | + }) | ||
526 | + */ | ||
527 | + public function specData() | ||
528 | + { | ||
529 | + $house_activity_id = $this->request->param('house_activity_id'); | ||
530 | + $activity = \app\admin\model\HouseActivity::get($house_activity_id); | ||
531 | + empty($activity) && $this->error('活动信息不存在'); | ||
532 | + $spec_data = $activity['spec_type'] == '2' ? $activity->getManySpecData($activity['spec_rel'], $activity['spec']) : null; | ||
533 | + if($spec_data){ | ||
534 | + $spec_list = []; | ||
535 | + foreach($spec_data['spec_list'] as $v){ | ||
536 | + $spec_list[$v['spec_sku_id']]['spec_sku_id'] = $v['spec_sku_id']; | ||
537 | + $spec_list[$v['spec_sku_id']]['price'] = $v['form']['price']; | ||
538 | + } | ||
539 | + $spec_data['spec_list'] = $spec_list; | ||
540 | + } | ||
541 | + $this->success(__('成功'),$spec_data); | ||
429 | } | 542 | } |
430 | } | 543 | } |
此 diff 太大无法显示。
-
请 注册 或 登录 后发表评论