lqmac 9 months ago
parent 89c7ffde8e
commit 90122bac91
  1. 10
      app/common/model/Goods.php
  2. 8
      app/common/model/Store.php
  3. 24
      app/job/service/goods/Collector.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']];
}

@ -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) {

@ -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']])

Loading…
Cancel
Save