更新采集

This commit is contained in:
mkm 2023-10-10 16:49:36 +08:00
parent f1bff4c734
commit 38f4b8907b
2 changed files with 54 additions and 57 deletions

View File

@ -1157,13 +1157,10 @@ class ProductRepository extends BaseRepository
public function apiProductDetail(array $where, int $productType, ?int $activityId, $userInfo = null)
{
$field = 'is_show,product_id,mer_id,image,slider_image,store_name,store_info,unit_name,price,cost,ot_price,stock,sales,video_link,product_type,extension_type,old_product_id,rate,guarantee_template_id,temp_id,once_max_count,pay_limit,once_min_count,integral_rate,delivery_way,delivery_free,type,cate_id,svip_price_type,svip_price,mer_svip_status';
$with = [
'attr',
'content' => function($query) {
$query->order('type ASC');
},
'content',
'attrValue',
'oldAttrValue',
'merchant' => function ($query) {
@ -1248,9 +1245,13 @@ class ProductRepository extends BaseRepository
$res['attr'] = $attr;
$res['sku'] = $sku;
$res->append($append);
if ($res['content'] && $res['content']['type'] == 1) {
$res['content']['content'] = json_decode($res['content']['content']);
$content= json_decode($res['content']['content']);
if(isset($content['image'])){
$res['content']['content'] =$content;
}else{
$res['content']['content'] =['image'=>$content];
}
}
$res['merchant']['recommend'] = $this->getRecommend($res['product_id'], $res['mer_id']);

View File

@ -57,7 +57,7 @@ use app\common\service\TopClient;
use app\controller\api\Ceshi;
use taobao\request\TbkItemInfoGetRequest;
use app\common\repositories\store\product\ProductRepository;
use think\facade\App;
use crmeb\services\UploadService;
/**
* Class Auth
@ -69,7 +69,6 @@ class Auth extends BaseController
{
public function caiji()
{
$url= env('SHOP_URL', 'https://test.shop.lihaink.cn');
$parmas = $this->request->param();
$query = parse_url($parmas['url']);
$itemId = $this->convertUrlQuery($query['query']);
@ -82,19 +81,16 @@ class Auth extends BaseController
$res = $resp->results->n_tbk_item;
$arr = json_decode(json_encode($res), true);
$images = [];
$filename = basename($arr['pict_url']); // 获取文件名
$destination = public_path('uploads').'img/' . $filename; // 目标路径
$pict_url= $url.'/uploads/img/'.$filename;
file_put_contents($destination, file_get_contents($arr['pict_url']));
// if($resp && isset($resp->small_images) && isset($resp->small_images->string)){
$upload = UploadService::create();
$dir = 'def/' . date('Y-m-d');
$oss = $upload->to($dir)->stream(file_get_contents($arr['pict_url']));
$pict_url = $oss->filePath;
foreach ($arr['small_images']['string'] as $k => $v) {
// halt($v);
$filename = basename($v); // 获取文件名
$destination = public_path('uploads').'img/' . $filename; // 目标路径
file_put_contents($destination, file_get_contents($v));
$images[]=$url.'/uploads/img/'.$filename;
$oss = $upload->to($dir)->stream(file_get_contents($v));
$images[] = $oss->filePath;
}
// }
$data = [
"image" => $pict_url,
"slider_image" => $images,