...
|
...
|
@@ -392,9 +392,14 @@ class HouseBoard extends Api |
|
|
{
|
|
|
"id": // 活动id
|
|
|
"title": // 活动标题
|
|
|
"spec_type": // 活动规格:0=无规格(免费),1=单规格,2=多规格
|
|
|
"content": // 活动描述
|
|
|
"activity_time": 活动日期
|
|
|
"status": // 活动状态
|
|
|
"price": // 报名费用
|
|
|
"status": { // 活动状态
|
|
|
"text": // 状态名称
|
|
|
"value": // 状态值 0=报名中,1=已报名,2=已到期
|
|
|
}
|
|
|
}
|
|
|
]
|
|
|
})
|
...
|
...
|
@@ -404,27 +409,135 @@ class HouseBoard extends Api |
|
|
$user_id = $this->auth->id;
|
|
|
$house_id = $this->request->param('house_id'); //社区id
|
|
|
empty($house_id) && $this->error('缺少必要参数');
|
|
|
$now = time();
|
|
|
$list = $this->getActivityList("find_in_set({$house_id},house_ids)");
|
|
|
$this->success('success',$list);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @ApiTitle (社区公告-社区活动-详情)
|
|
|
* @ApiSummary (社区公告-社区活动-详情)
|
|
|
* @ApiMethod (POST)
|
|
|
*
|
|
|
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
|
|
* @ApiParams (name="house_activity_id", type="inter", required=true, description="社区活动id")
|
|
|
*
|
|
|
* @ApiReturn({
|
|
|
"code": 1,
|
|
|
"msg": "success",
|
|
|
"time": "1598587213",
|
|
|
"data": {
|
|
|
"id": // 活动id
|
|
|
"title": // 活动标题
|
|
|
"spec_type": // 活动规格:0=无规格(免费),1=单规格,2=多规格
|
|
|
"content": // 活动描述
|
|
|
"activity_time": 活动日期
|
|
|
"price": // 报名费用
|
|
|
"status": { // 活动状态
|
|
|
"text": // 状态名称
|
|
|
"value": // 状态值 0=报名中,1=已报名,2=已到期
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
*/
|
|
|
public function activityInfo()
|
|
|
{
|
|
|
$user_id = $this->auth->id;
|
|
|
$house_activity_id = $this->request->param('house_activity_id'); //社区id
|
|
|
empty($house_activity_id) && $this->error('缺少必要参数');
|
|
|
$list = $this->getActivityList(['ha.id'=>$house_activity_id]);
|
|
|
$info = !empty($list) ? $list[0] : [];
|
|
|
$this->success('success',$info);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取活动信息
|
|
|
*/
|
|
|
private function getActivityList($where){
|
|
|
$list = Db::name('house_activity')
|
|
|
->alias('ha')
|
|
|
->join('house_activity_join haj','haj.house_activity_id = ha.id','left')
|
|
|
->where("find_in_set({$house_id},house_ids)")
|
|
|
->field('ha.id,
|
|
|
->join('house_join hj','hj.house_activity_id = ha.id','left')
|
|
|
->where($where)
|
|
|
->field('
|
|
|
ha.id,
|
|
|
ha.title,
|
|
|
ha.content,
|
|
|
ha.start_time,
|
|
|
ha.end_time,
|
|
|
haj.join_status
|
|
|
ha.spec_type,
|
|
|
hj.pay_status
|
|
|
')
|
|
|
->order("ha.createtime desc")
|
|
|
->select();
|
|
|
foreach ($list as $k => &$v) {
|
|
|
// 活动报名费用
|
|
|
$price = Db::name('house_activity_spec')->where('house_activity_id',$v['id'])->value('price');
|
|
|
$v['price'] = $price > 0 ? $price : 0;
|
|
|
// 活动日期
|
|
|
$v['activity_time'] = date('Y-m-d',$v['start_time']).'-'.date('Y-m-d',$v['end_time']);
|
|
|
// 活动日期
|
|
|
$v['status'] = $v['join_status'] == 1 ? '已报名' : ($v['end_time'] < time() ? '已到期' : '未报名');
|
|
|
unset($v['start_time'],$v['end_time'],$v['join_status']);
|
|
|
// 活动状态
|
|
|
if($v['pay_status'] == '1'){
|
|
|
$status = ['text'=>'已报名','value'=>1];
|
|
|
}else{
|
|
|
$status = $v['end_time'] < time() ? ['text'=>'已到期','value'=>2] : ['text'=>'报名中','value'=>0];
|
|
|
}
|
|
|
$this->success('success',$list);
|
|
|
$v['status'] = $status;
|
|
|
unset($v['start_time'],$v['end_time'],$v['pay_status']);
|
|
|
}
|
|
|
return $list;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @ApiTitle (社区公告-社区活动-获取规格)
|
|
|
* @ApiSummary (社区公告-社区活动-获取规格)
|
|
|
* @ApiMethod (POST)
|
|
|
* @ApiParams (name="house_activity_id", type="integer", required=true, description="活动ID")
|
|
|
* @ApiReturnParams (name="code", type="integer", required=true, sample="0")
|
|
|
* @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
|
|
|
* @ApiReturnParams (name="data", type="object", description="扩展数据返回")
|
|
|
* @ApiReturn ({
|
|
|
"code": 1,
|
|
|
"msg": "成功",
|
|
|
"time": "1598600665",
|
|
|
"data": {
|
|
|
"spec_attr": [
|
|
|
{
|
|
|
"group_id": 25,
|
|
|
"group_name": "颜色",
|
|
|
"spec_items": [
|
|
|
{
|
|
|
"item_id": 52,
|
|
|
"spec_value": "白色"
|
|
|
},
|
|
|
{
|
|
|
"item_id": 54,
|
|
|
"spec_value": "黑色"
|
|
|
}
|
|
|
]
|
|
|
}
|
|
|
],
|
|
|
"spec_list": {
|
|
|
"52_50": {
|
|
|
"spec_sku_id": "52_50",
|
|
|
"price": "12.00"
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
*/
|
|
|
public function specData()
|
|
|
{
|
|
|
$house_activity_id = $this->request->param('house_activity_id');
|
|
|
$activity = \app\admin\model\HouseActivity::get($house_activity_id);
|
|
|
empty($activity) && $this->error('活动信息不存在');
|
|
|
$spec_data = $activity['spec_type'] == '2' ? $activity->getManySpecData($activity['spec_rel'], $activity['spec']) : null;
|
|
|
if($spec_data){
|
|
|
$spec_list = [];
|
|
|
foreach($spec_data['spec_list'] as $v){
|
|
|
$spec_list[$v['spec_sku_id']]['spec_sku_id'] = $v['spec_sku_id'];
|
|
|
$spec_list[$v['spec_sku_id']]['price'] = $v['form']['price'];
|
|
|
}
|
|
|
$spec_data['spec_list'] = $spec_list;
|
|
|
}
|
|
|
$this->success(__('成功'),$spec_data);
|
|
|
}
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|