0], ['type', 'in', 'range' => [Favorite::FAVORITE_GOODS, Favorite::FAVORITE_SHOP]], [['page', 'limit',], 'integer',], [['page'], 'default', 'value' => 1], [['limit'], 'default', 'value' => 20], ]; } public function league_search($saas_user_id) { $admin = Admin::findOne(['saas_user_id' => $saas_user_id, 'is_delete' => 0, 'type' => 'store']); $store = Store::findOne($admin->type_id); if($store){ return [ 'code' => 0, 'data' => $store->league_price, 'msg' => '查找成功' ]; }else{ return [ 'code' => 1, 'msg' => '该账户不是商城管理员' ]; } } public function search() { if (!$this->validate()) { return [ 'code' => 1, 'msg' => $this->getErrorSummary(false)[0] ]; } // 暂无商品收藏列表 // if ($this->type == Favorite::FAVORITE_GOODS) { // $query = Favorite::find()->where(['store_id' => $this->store_id, 'type' => Favorite::FAVORITE_GOODS, 'is_delete' => 0, 'user_id' => $this->user_id]); // $count = $query->count(); // $pagination = new Pagination(['totalCount' => $count, 'page' => $this->page - 1, 'pageSize' => $this->limit]); // $list = $query->select('*')->limit($pagination->limit)->offset($pagination->offset)->orderBy('created_at DESC')->asArray()->all(); // $new_list = []; // foreach ($list as $i => $favorite) { // $goods = Goods::findOne(['store_id' => $this->store_id, 'is_delete' => 0, 'status' => Goods::STATUS_NORMAL, 'id' => $favorite['goods_id']]); // if (!$goods) { // continue; // } // if ($goods->is_negotiable) { // $goods->price = Goods::GOODS_NEGOTIABLE; // } // $new_list[] = (object)[ // 'id' => $favorite['id'], // 'goods_id' => $goods->id, // 'name' => $goods->name, // 'price' => $goods->price, // 'goods_pic' => $goods->getGoodsPic(0)->pic_url, // 'is_negotiable' => $goods->is_negotiable, // ]; // } // return [ // 'code' => 0, // 'data' => (object)[ // 'row_count' => $count, // 'page_count' => $pagination->pageCount, // 'list' => $new_list, // ], // ]; // } if ($this->type == Favorite::FAVORITE_SHOP) { $query = Favorite::find()->where(['type' => Favorite::FAVORITE_SHOP, 'is_delete' => 0, 'saas_id' => $this->saas_id]); $count = $query->count(); $pagination = new Pagination(['totalCount' => $count, 'page' => $this->page - 1, 'pageSize' => $this->limit]); $list = $query->select('*')->limit($pagination->limit)->offset($pagination->offset)->orderBy('created_at DESC')->asArray()->all(); $new_list = []; foreach ($list as $key => $shop) { //$mch = Mch::find()->where(['id' => $shop['goods_id'], 'store_id' => $this->store_id, 'is_delete' => 0, 'is_open' => 1, 'is_lock' => 0])->one(); //$store = Store::find()->where(['id' =>$shop['store_id'], 'is_delete' => 0])->one(); $storeInfo = Store::find()->alias('s')->where(['s.id'=>$shop['store_id'],'s.is_delete'=>0])->select('s.id,s.name,s.logo,s.address,s.category_id,s.sales,s.rank,s.per_spend,s.coordinate,s.business_model')->asArray()->one(); if (!$storeInfo) { continue; } if($storeInfo['category_id']>0){ $categoryInfo = Cat::find()->where(['id'=>$storeInfo['category_id'],'is_delete'=>0])->asArray()->one(); if($categoryInfo){ $storeInfo['category_name'] = $categoryInfo['name']; }else{ $storeInfo['category_name'] = ''; } } $new_list[] = (object)[ 'id' => $shop['id'], 'created_at' => $shop['created_at'], 'store_info' => $storeInfo //'goods_list' => Goods::find()->where(['store_id' => $this->store_id, 'status' => Goods::STATUS_NORMAL, 'is_delete' => 0, 'mch_id' => $shop['goods_id']])->select('id, price, cover_pic, mch_id')->limit(4)->orderBy('created_at DESC')->asArray()->all() ]; } return [ 'code' => 0, 'data' => (object)[ 'row_count' => $count, 'page_count' => $pagination->pageCount, 'list' => $new_list, ], ]; } } }