1], [['limit'], 'default', 'value' => 20], ]; } public function search() { $query = CoachReview::find()->alias('cr') ->select('cr.*,u.real_name,u.mobile_phone as phone') ->leftJoin(['u' => User::tableName()],'cr.user_id=u.id') ->where([ 'cr.is_delete' => 0 ]) ->andFilterWhere(['cr.status' => $this->status]) ->andFilterWhere(['cr.store_id' => $this->store_id]) ->andFilterWhere([ 'OR', ['like','cr.mobile_phone',$this->keywords], ['like','cr.title',$this->keywords], ['like','cr.number',$this->keywords], ['like','u.real_name',$this->keywords], ]); if(!\Yii::$app->admin->identity->user->store){ $query->andWhere(['>=','cr.status_review',1]); } $count = $query->count(); $pagination = new Pagination(['totalCount' => $count, 'pageSize' => $this->limit]); $list = $query->offset($pagination->offset)->limit($pagination->limit)->orderBy(['cr.created_at' => SORT_DESC])->asArray()->all(); foreach ($list as $index => $item){ $item['store_name'] = '获取失败'; $store = Store::findOne([ 'id' => $item['store_id'], 'is_delete' => 0 ]); if(!empty($store)){ $item['store_name'] = $store->name; } $item['created_at_cn'] = date("Y-m-d H:i",$item['created_at']); $item['phone'] = EncryptHelper::decryptMobilePhone($item['phone']); $item['qualification_cn'] = empty($item['qualification']) ? '' : SiteHelper::getFullUrl($item['qualification']); $list[$index] = $item; } $data = []; $data['code'] = 0; $data['msg'] = 'ok'; $data['data'] = $list; $data['count'] = $count; return $data; } }