From d7eca1bb4c0bec11953b0ad73e3f482c50f3bff5 Mon Sep 17 00:00:00 2001 From: ztt <835303992@qq.com> Date: Wed, 28 Feb 2024 13:46:23 +0800 Subject: [PATCH] =?UTF-8?q?=E9=97=A8=E5=BA=97=E8=AF=84=E8=AE=BA=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/service/Goods.php | 33 ++++++++++++++++--------- app/common/model/store/shop/Comment.php | 7 ++++++ 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/app/api/service/Goods.php b/app/api/service/Goods.php index 2d49d698..8af54b0a 100644 --- a/app/api/service/Goods.php +++ b/app/api/service/Goods.php @@ -16,11 +16,15 @@ use app\api\model\Goods as GoodsModel; use app\api\model\Setting as SettingModel; use app\api\model\GoodsSku as GoodsSkuModel; use app\api\model\Category as CategoryModel; +use app\api\model\UploadFile; use app\api\service\User as UserService; +use app\common\library\helper; +use app\common\model\Help; use app\common\model\store\Shop as ShopModel; use app\common\model\goods\GoodsHotWord; use app\api\service\sharp\Active as ActiveService; use app\common\enum\Setting as SettingEnum; +use app\common\model\store\shop\Comment; use app\common\service\Goods as GoodsService; use app\api\model\sharp\Active as SharpActiveModel; use app\api\model\sharp\ActiveTime as ActiveTimeModel; @@ -215,7 +219,7 @@ class Goods extends GoodsService 'store_id' => $storeid, 'is_main' => 1, ])->field('shop_name,star,shop_hours,summary,phone, - province_id,city_id,region_id,shop_id,address,latitude,longitude,wechat_img_id,history1,history2,history3,remark,history,parking_name,parking_desc,parking_latitude,parking_longitude')->find()->toArray(); + province_id,city_id,region_id,shop_id,address,latitude,longitude,wechat_img_id,history1,history2,history3,remark,history,parking_name,parking_desc,parking_latitude,parking_longitude,shop_image_id')->find()->toArray(); //todo wmc $info['remark'] = json_decode($info['remark'],true); $info['fuwu_hours'] = 5; @@ -223,16 +227,23 @@ class Goods extends GoodsService // $info['wechat'] = 'https://www.saas.njrenzhou.com/uploads/10001/20240127/12bb1b1747e652d258443247a5c4777c.png'; $info['history'] = json_decode($info['history'], true); - $info['evaluate'][] = [ - 'image' => 'http://qiniu.shop.royaum.com.cn/10001/20240201/13f2e675794e25176352fc039dfb6dcb.jpg', - 'nickname' => 'wmc', - 'content' => '很好', - ]; - $info['imageList'] = [ - 'http://qiniu.shop.royaum.com.cn/10001/20240201/13f2e675794e25176352fc039dfb6dcb.jpg', - 'http://qiniu.shop.royaum.com.cn/10001/20240201/13f2e675794e25176352fc039dfb6dcb.jpg' - - ]; +// $info['evaluate'][] = [ +// 'image' => 'http://qiniu.shop.royaum.com.cn/10001/20240201/13f2e675794e25176352fc039dfb6dcb.jpg', +// 'nickname' => 'wmc', +// 'content' => '很好', +// ]; + $info['evaluate'] = Comment::with('file') + ->field(['nickname,content,image_id']) + ->hidden(['file']) + ->where('shop_id','=', $info['shop_id']) + ->select(); +// $info['imageList'] = [ +// 'http://qiniu.shop.royaum.com.cn/10001/20240201/13f2e675794e25176352fc039dfb6dcb.jpg', +// 'http://qiniu.shop.royaum.com.cn/10001/20240201/13f2e675794e25176352fc039dfb6dcb.jpg' +// +// ]; + $file = UploadFile::whereIn('file_id', explode(',', $info['shop_image_id']))->select(); + $info['imageList'] = helper::getArrayColumn($file, 'preview_url'); return $info; } diff --git a/app/common/model/store/shop/Comment.php b/app/common/model/store/shop/Comment.php index a54d3981..1974c862 100644 --- a/app/common/model/store/shop/Comment.php +++ b/app/common/model/store/shop/Comment.php @@ -12,8 +12,10 @@ declare (strict_types=1); namespace app\common\model\store\shop; +use app\common\model\UploadFile; use cores\BaseModel; use think\model\relation\BelongsTo; +use think\model\relation\HasOne; /** * 商家门店评论模型 @@ -40,4 +42,9 @@ class Comment extends BaseModel return $this->BelongsTo("app\\{$module}\\model\\store\\Shop", 'shop_id'); } + public function file(): HasOne + { + return $this->hasOne(UploadFile::class,'file_id', 'image_id')->bind(['image' => 'preview_url']); + } + }