1], [['limit'], 'default', 'value' => 20], ]; } public function search() { $query = Box::find()->alias('b') ->leftJoin(['goods' => Goods::tableName()], 'b.goods_id=goods.id') ->leftJoin(['goodHub' => GoodsHub::tableName()], 'goods.goods_hub_id=goodHub.id') ->leftJoin(['storeBj' => StoreBj::tableName()], 'b.bj_id=storeBj.id') ->select('b.id,b.created_at,b.status,goodHub.name as goods_name,storeBj.name as bj_name,b.sort') ->where([ 'b.is_delete' => 0 ]) ->andFilterWhere(['b.status' => $this->status]) ->andFilterWhere(['goodHub.name' => $this->keywords]); $count = $query->count(); $pagination = new Pagination(['totalCount' => $count, 'pageSize' => $this->limit]); $list = $query->offset($pagination->offset)->limit($pagination->limit)->orderBy(['b.sort'=>SORT_DESC,'b.id' => SORT_DESC])->asArray()->all(); foreach ($list as $index => $item) { // $item['business'] = $item['begin_time'] . '-' . $item['end_time']; $item['created_at_cn'] = date("Y-m-d H:i", $item['created_at']); // $item['device'] = json_decode($item['device'], true); $list[$index] = $item; } $data = []; $data['code'] = 0; $data['msg'] = 'ok'; $data['data'] = $list; $data['count'] = $count; return $data; } }