From 90122bac919fb3b8012d871fe9010fa5efa1a499 Mon Sep 17 00:00:00 2001 From: lqmac Date: Fri, 7 Jun 2024 16:22:33 +0800 Subject: [PATCH] 1 --- app/common/model/Goods.php | 10 +++++++--- app/common/model/Store.php | 8 +++++++- app/job/service/goods/Collector.php | 24 ++++++++++++++++++++---- 3 files changed, 34 insertions(+), 8 deletions(-) diff --git a/app/common/model/Goods.php b/app/common/model/Goods.php index 31232b54..f96cdf8d 100644 --- a/app/common/model/Goods.php +++ b/app/common/model/Goods.php @@ -503,6 +503,10 @@ class Goods extends BaseModel if (isset($param['spec_type']) && $param['spec_type'] !== '') { $filter[] = ['spec_type', '=', $params['spec_type']]; } + //gj + if (isset($param['merchantId']) && $param['merchantId']) { + $filter[] = ['goods.merchant_id', '=', $param['merchantId']]; + } //是否店内 //if (isset($param['is_in_store']) && $param['is_in_store'] !== '') { if (isset($param['is_in_store']) && $param['is_in_store']) { @@ -574,9 +578,9 @@ class Goods extends BaseModel if (isset($param['is_has_detail']) && $param['is_has_detail'] !== '') { $filter[] = ['goods.is_has_detail', '=', $params['is_has_detail']]; } - if (isset($param['merchantId']) && $param['merchantId'] !== '') { - $filter[] = ['goods.merchant_id', '=', $params['merchantId']]; - } + // if (isset($param['merchantId']) && $param['merchantId'] !== '') { + // $filter[] = ['goods.merchant_id', '=', $params['merchantId']]; + // } if (isset($param['is_jd_remove']) && $param['is_jd_remove'] !== '') { $filter[] = ['goods.is_jd_remove', '=', $params['is_jd_remove']]; } diff --git a/app/common/model/Store.php b/app/common/model/Store.php index 152aef65..5c7992e7 100644 --- a/app/common/model/Store.php +++ b/app/common/model/Store.php @@ -46,7 +46,7 @@ class Store extends BaseModel { try { $list = self::withoutGlobalScope() - ->with(['logoImage']) + //->with(['logoImage']) ->where('store_id', '=', $storeId) ->find(); if ($list) { @@ -98,6 +98,12 @@ class Store extends BaseModel } else { $list['loginImg'] = null; } + if ($list['logo_image_id']) { + $files = UploadFile::getFileList([$list['logo_image_id']]); + $list['logoImage'] = $files ? $files[0] : null; + } else { + $list['logoImage'] = null; + } } return $list ?? null; } catch (\Exception $e) { diff --git a/app/job/service/goods/Collector.php b/app/job/service/goods/Collector.php index 62fdc707..6a73cb99 100644 --- a/app/job/service/goods/Collector.php +++ b/app/job/service/goods/Collector.php @@ -330,7 +330,27 @@ class Collector extends BaseService $model = $this->getRecord($recordId); return $model['status'] == GoodsCollectorStatusEnum::FAIL || $model['is_delete']; } + /** + * 抓取第三方商品内容 + * @param string $url + * @param int $storeId + * @return array + * @throws BaseException + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + public function collector1(string $url, int $storeId): array + { + // 获取商品来源 + $store = $this->getStore($url); + // 获取url中的商品ID + $itemId = $this->getItemId($url, $store); + getJdGoodsBySku + $item['goods_sku_no'] = $itemId; + return $item; + } /** * 抓取第三方商品内容 * @param string $url @@ -345,14 +365,10 @@ class Collector extends BaseService { // 获取商品来源 $store = $this->getStore($url); - // 获取url中的商品ID $itemId = $this->getItemId($url, $store); // 商城采集设置 $config = SettingModel::getItem(SettingEnum::COLLECTOR, $storeId); - // if (isset($config['config']['99api']['apiKey']) && !$config['config']['99api']['apiKey']) { - // $config['config']['99api']['apiKey'] = '9271DA7BF37C6F50BED49B7F0ADD49A2'; - // } // 请求API查询商品详情 $item = CollectorFacade::store($store) ->setOptions($config['config'][$config['provider']])