更新采集

This commit is contained in:
mkm 2023-10-10 14:54:50 +08:00
parent adbb943b51
commit f44b23bd7a

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 crmeb\services\UploadService;
use think\facade\App;
/**
* Class Auth
@ -69,6 +69,7 @@ class Auth extends BaseController
{
public function caiji()
{
$url=$this->request->host();
$parmas = $this->request->param();
$query=parse_url($parmas['url']);
$itemId=$this->convertUrlQuery($query['query']);
@ -79,23 +80,25 @@ class Auth extends BaseController
$req->setNumIids($itemId['itemId']);
$resp = $c->execute($req);
$res=$resp->results->n_tbk_item;
$arr = json_decode(json_encode($res), true);
$images=[];
$upload = UploadService::create();
$dir = 'def/' . date('Y-m-d');
$filename = basename($res->pict_url); // 获取文件名
$destination = public_path('uploads').'img/' . $filename; // 目标路径
$pict_url= $url.'/uploads/img/'.$filename;
file_put_contents($destination, file_get_contents($res->pict_url));
$oss = $upload->to($dir)->stream(file_get_contents($arr['pict_url']));
$pict_url = $oss->filePath;
foreach ($arr['small_images']['string'] as $k => $v) {
$oss = $upload->to($dir)->stream(file_get_contents($v));
$images[] = $oss->filePath;
if($resp && isset($resp->small_images) && isset($resp->small_images->string)){
foreach($resp->small_images->string as $k=>$v){
$filename = basename($v); // 获取文件名
$destination = public_path('uploads').'img/' . $filename; // 目标路径
file_put_contents($destination, file_get_contents($v));
$images[]=$url.'/uploads/img/'.$filename;
}
}
$data=[
"image" => $pict_url,
"slider_image" =>$images,
"store_name" => $arr['title'],
"store_info" => $arr['cat_leaf_name'],
"store_name" => json_decode(json_encode($res->title),true)[0],
"store_info" => json_decode(json_encode($res->cat_leaf_name),true)[0],
"keyword" => "",
"bar_code" => "",
"guarantee_template_id" => "",
@ -103,7 +106,7 @@ class Auth extends BaseController
"mer_cate_id" => [],
"unit_name" => $parmas['unit_name'],
"sort" => 0,
"is_show" => 1,
"is_show" => "",
"is_good" => 0,
"is_gift_bag" => 0,
"integral_rate" => -1,
@ -130,7 +133,7 @@ class Auth extends BaseController
"attrValue" => [
0 => [
"image" => $pict_url,
"price" => bcsub($arr['reserve_price'], ($arr['reserve_price'] * 0.05), 2),
"price" => bcsub($res->reserve_price,($res->reserve_price*0.05),2),
"cost" => 0,
"ot_price" => 0,
"svip_price" => null,
@ -146,7 +149,7 @@ class Auth extends BaseController
"svip_price_type" => 0,
"params" => [],
"mer_id" => $parmas['mer_id'],
"status" => 1,
"status" => 0,
"mer_status" => 1,
"rate" => 3,
];