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.cover_pic,b.status,goodHub.name as goods_name,storeBj.name as bj_name') ->where([ 'b.status' => 1, 'b.is_delete' => 0 ]) ->andFilterWhere(['b.bj_id' => $this->bj_id]) ->andFilterWhere(['OR', ['like', '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.created_at' => SORT_DESC])->asArray()->all(); foreach ($list as $index => $item) { // $item['business'] = $item['begin_time'] . '-' . $item['end_time']; $list[$index]['created_at_cn'] = date("Y-m-d H:i", $item['created_at']); if ($item['cover_pic'] != null) { $pic_arr = json_decode($item['cover_pic'], true); if (is_array($pic_arr)) { foreach ($pic_arr as $key => $value) { $arr[] = SiteHelper::getFullUrl($value); // $pic_arr[] = $arr; } $list[$index]['cover_pic_arr'] = $arr; } } } $data = []; $data['code'] = 0; $data['msg'] = 'ok'; $data['data'] = $list; $data['count'] = $count; return $data; } public function lists() { $store = StoreBj::find()->where(['is_delete' => 0, 'status' => 1])->asArray()->all(); $data = []; $data['code'] = 0; $data['msg'] = 'ok'; $data['data'] = $store; return $data; } }