andWhere([ 'status' => 1, 'is_delete' => 0, ]) ->select('id,name,start_time,end_time,poster_img_arr,poster_btn_name,poster_btn_url') ->asArray() ->all(); if(empty($data)){ return $this->apiReturnSuccess('ok',[]); } $res = []; foreach ($data as $key=>$val){ if($val['start_time'] > time() || $val['end_time'] < time()){ continue; } if(empty($val['poster_img_arr'])){ continue; } $val['poster_img_arr'] = json_decode($val['poster_img_arr'],true); if(empty($val['poster_img_arr'])){ continue; } if(count($val['poster_img_arr']) == 1){ $val['poster_img_arr'] = SiteHelper::getFullUrl($val['poster_img_arr'][0]); }else{ $tmp_data = []; foreach ($val['poster_img_arr'] as $k=>$v){ $tmp_data[] = SiteHelper::getFullUrl($v); } $val['poster_img_arr'] = $tmp_data; } $val['start_date'] = date('Y-m-d H:i',$val['start_time']); $val['end_date'] = date('Y-m-d H:i',$val['end_time']); $res[] = $val; } return $this->apiReturnSuccess('ok',$res); } /** * showdoc * @catalog 活动 * @title 获取活动详情 * @description 本接口提供获取活动详情 * @method get * @url /api/default/get-activity-info * @remark */ public function actionGetActivityInfo(){ if(empty($this->id)){ return $this->apiReturnError('暂无活动'); } $find = Activity::findOne([ 'id' => $this->id, 'is_delete' => 0, 'status' => 1, ]); if(empty($find)){ return $this->apiReturnError('暂无活动'); } $res = [ 'name' => $find->name, 'content' => $find->content, 'start_time' => $find->start_time, 'end_time' => $find->end_time, 'start_date' => date('Y-m-d H:i:s',$find->start_time), 'end_date' => date('Y-m-d H:i:s',$find->end_time), 'content_btn_name' => $find->content_btn_name, 'content_btn_url' => $find->content_btn_url, ]; return $this->apiReturnSuccess('ok',$res); } }