validate()) { return [ 'code' => 1, 'msg' => $this->getErrorSummary(false)[0] ]; } $shop = Shop::find()->where([ 'store_id' => $this->store_id, 'id' => $this->shop_id, 'is_delete' => 0 ])->asArray()->one(); if (!$shop) { // return new ApiResponse(1, '店铺不存在'); return [ 'code' => 1, 'msg' => '店铺不存在' ]; } $shop_pic = ShopPic::find()->select(['pic_url'])->where(['store_id' => $this->store_id, 'shop_id' => $shop['id'], 'is_delete' => 0])->column(); $shop['pic_list'] = $shop_pic; if (!$shop_pic) { $shop['pic_list'] = [$shop['pic_url']]; } foreach ($shop as $index => &$value) { if (!$value) { if (in_array($index, ['pic_url', 'cover_url', 'pic_list'])) { continue; } $shop[$index] = "暂无设置"; } if ($index == 'content') { $value = str_replace(" ", " ", $value); $value = str_replace(" ", " ", $value); } } // return new ApiResponse(0, 'success', ['shop'=>$shop]); return [ 'code' => 0, 'msg' => 'success', 'data' => ['shop'=>$shop] ]; } }