1], [['limit'], 'default', 'value' => 20], ]; } /** * 型号列表 */ public function search() { if (!$this->validate()) { return $this->getModelError(); } //未完成 if ($this->status == 1) { $status = [0, 1, 2]; } //完成 if ($this->status == 2) { $status = [3]; } $query = Report::find() ->select('id,model_number,pdf_path,pdf_at,step') ->where([ 'user_id' => $this->user_id ])->andFilterWhere([ 'in', 'step', $status ]); $count = $query->count(); $pagination = new Pagination(['totalCount' => $count, 'pageSize' => $this->limit, 'page' => $this->page - 1]); $list = $query->offset($pagination->offset)->limit($pagination->limit)->orderBy(['id' => SORT_DESC])->asArray()->all(); foreach ($list as $key => $value) { $value['pdf_at_cn'] = ''; if (!empty($value['pdf_at'])) { $value['pdf_at_cn'] = date('Y-m-d H:i:s', $value['pdf_at']); } $value['pdf_path'] = SiteHelper::getFullUrl($value['pdf_path']); $list[$key] = $value; } $end_flag = $this->page > $pagination->pageCount ? true : false; return [ 'code' => 0, 'msg' => 'ok', 'data' => $list, 'count' => $count, 'page_size' => $this->limit, 'page_count' => $pagination->pageCount, 'page_no' => $this->page, 'end_flag' => $end_flag ]; } /** * @catalog 数据列表 * @title 获取详情 * @description 数据列表-获取详情 */ public function actionGetInfo(){ if(empty($id)){ return $this->apiReturnError('请求错误'); } $find = Report::findOne([ 'id' => $this->id, ]); if(empty($find)){ return $this->apiReturnError('暂无数据'); } if(intval($find->step) !== 3){ return $this->apiReturnError('暂未生成结果'); } $json_de = []; if(!empty($find->json)){ $json_de = json_decode($find->json,true); } $res = $json_de??[]; $find_store = Store::findOne([ 'id' => $find->store_id, ]); $res['store'] = [ 'id' => $find->store_id, 'name' => $find_store->name??'暂无门店', ]; $res['created_date'] = date('Y-m-d H:i:s',$find->created_at); return $this->apiReturnSuccess('ok',$res); } }