| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
- /**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
- namespace app\modules\client\models\v1;
- use app\cyy\ApiResponse;
- use app\models\Shop;
- use app\models\ShopPic;
- use app\modules\client\models\ApiModel;
- class ShopForm extends ApiModel
- {
- public $store_id;
- public $user;
- public $shop_id;
- public function rules()
- {
- return [
- [['shop_id'], 'integer']
- ];
- }
- public function search()
- {
- if (!$this->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("&nbsp;", " ", $value);
- $value = str_replace(" ", " ", $value);
- }
- }
- // return new ApiResponse(0, 'success', ['shop'=>$shop]);
- return [
- 'code' => 0,
- 'msg' => 'success',
- 'data' => ['shop'=>$shop]
- ];
- }
- }
|