|
...
|
...
|
@@ -584,13 +584,14 @@ class ProductLogic extends BaseLogic |
|
|
|
* 产品导入
|
|
|
|
* @param $project_id
|
|
|
|
* @param $user_id
|
|
|
|
* @param $domain
|
|
|
|
* @param $data
|
|
|
|
* @return bool
|
|
|
|
* @throws \Exception
|
|
|
|
* @author Akun
|
|
|
|
* @date 2023/09/21 14:55
|
|
|
|
*/
|
|
|
|
public function importProduct($project_id, $user_id, $data)
|
|
|
|
public function importProduct($project_id, $user_id, $domain, $data)
|
|
|
|
{
|
|
|
|
$route = $data[1]??'';//自定义路由
|
|
|
|
if($route){
|
|
...
|
...
|
@@ -622,7 +623,7 @@ class ProductLogic extends BaseLogic |
|
|
|
$img_arr = explode('^v6sp$',$data[7]);
|
|
|
|
foreach ($img_arr as $v_img){
|
|
|
|
if($v_img){
|
|
|
|
$one_img = check_remote_url_down($v_img) ? CosService::uploadRemote($project_id,'image_product',$v_img) : $v_img;
|
|
|
|
$one_img = check_remote_url_down($v_img,$project_id,$domain);
|
|
|
|
if($one_img){
|
|
|
|
$one_gallery = [
|
|
|
|
'alt' => '这是一张产品图',
|
|
...
|
...
|
@@ -645,7 +646,8 @@ class ProductLogic extends BaseLogic |
|
|
|
preg_match_all('/<img\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $data[5], $result_intro);
|
|
|
|
if($result_intro[2]??[]){
|
|
|
|
foreach ($result_intro[2] as $vi_img){
|
|
|
|
check_remote_url_down($vi_img) && $data[5] = str_replace($vi_img,getImageUrl(CosService::uploadRemote($project_id,'image_product',$vi_img)),$data[5]);
|
|
|
|
$new_vi_img = check_remote_url_down($vi_img,$project_id,$domain,1);
|
|
|
|
$new_vi_img && $data[5] = str_replace($vi_img,$new_vi_img,$data[5]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
...
|
...
|
@@ -653,7 +655,8 @@ class ProductLogic extends BaseLogic |
|
|
|
preg_match_all('/<source\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $data[5], $result_intro_video);
|
|
|
|
if($result_intro_video[2]??[]){
|
|
|
|
foreach ($result_intro_video[2] as $vi_video){
|
|
|
|
check_remote_url_down($vi_video) && $data[5] = str_replace($vi_video,getImageUrl(CosService::uploadRemote($project_id,'image_product',$vi_video)),$data[5]);
|
|
|
|
$new_vi_video = check_remote_url_down($vi_video,$project_id,$domain,1);
|
|
|
|
$new_vi_video && $data[5] = str_replace($vi_video,$new_vi_video,$data[5]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
...
|
...
|
@@ -666,7 +669,8 @@ class ProductLogic extends BaseLogic |
|
|
|
preg_match_all('/<img\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $data[6], $result_content);
|
|
|
|
if($result_content[2]??[]){
|
|
|
|
foreach ($result_content[2] as $vc_img){
|
|
|
|
check_remote_url_down($vc_img) && $data[6] = str_replace($vc_img,getImageUrl(CosService::uploadRemote($project_id,'image_product',$vc_img)),$data[6]);
|
|
|
|
$new_vc_img = check_remote_url_down($vc_img,$project_id,$domain,1);
|
|
|
|
$new_vc_img && $data[6] = str_replace($vc_img,$new_vc_img,$data[6]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
...
|
...
|
@@ -674,7 +678,8 @@ class ProductLogic extends BaseLogic |
|
|
|
preg_match_all('/<source\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $data[6], $result_content_video);
|
|
|
|
if($result_content_video[2]??[]){
|
|
|
|
foreach ($result_content_video[2] as $vc_video){
|
|
|
|
check_remote_url_down($vc_video) && $data[6] = str_replace($vc_video,getImageUrl(CosService::uploadRemote($project_id,'image_product',$vc_video)),$data[6]);
|
|
|
|
$new_vc_video = check_remote_url_down($vc_video,$project_id,$domain,1);
|
|
|
|
$new_vc_video && $data[6] = str_replace($vc_video,$new_vc_video,$data[6]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
...
|
...
|
@@ -715,7 +720,8 @@ class ProductLogic extends BaseLogic |
|
|
|
|
|
|
|
if($result_desc[2]??[]){
|
|
|
|
foreach ($result_desc[2] as $vdesc_img){
|
|
|
|
check_remote_url_down($vdesc_img) && $v_desc['text'] = str_replace($vdesc_img,getImageUrl(CosService::uploadRemote($project_id,'image_product',$vdesc_img)),$v_desc['text']);
|
|
|
|
$new_vdesc_img = check_remote_url_down($vdesc_img,$project_id,$domain,1);
|
|
|
|
$new_vdesc_img && $v_desc['text'] = str_replace($vdesc_img,$new_vdesc_img,$v_desc['text']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
...
|
...
|
@@ -723,19 +729,32 @@ class ProductLogic extends BaseLogic |
|
|
|
preg_match_all('/<source\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', $v_desc['text'], $result_desc_video);
|
|
|
|
if($result_desc_video[2]??[]){
|
|
|
|
foreach ($result_desc_video[2] as $vdesc_video){
|
|
|
|
check_remote_url_down($vdesc_video) && $v_desc['text'] = str_replace($vdesc_video,getImageUrl(CosService::uploadRemote($project_id,'image_product',$vdesc_video)),$v_desc['text']);
|
|
|
|
$new_vdesc_video = check_remote_url_down($vdesc_video,$project_id,$domain,1);
|
|
|
|
$new_vdesc_video && $v_desc['text'] = str_replace($vdesc_video,$new_vdesc_video,$v_desc['text']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//处理参数
|
|
|
|
$attrs = [];
|
|
|
|
if($data[4]??''){
|
|
|
|
$attr_arr = json_decode($data[4],true);
|
|
|
|
foreach ($attr_arr as $ka=>$va){
|
|
|
|
$attrs[] = [
|
|
|
|
'key' => $ka,
|
|
|
|
'value' => $va
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$id = $this->model->addReturnId(
|
|
|
|
[
|
|
|
|
'project_id' => $project_id,
|
|
|
|
'title' => $data[0],
|
|
|
|
'thumb' => $thumb,
|
|
|
|
'gallery' => Arr::a2s($gallery),
|
|
|
|
'attrs' => trim($data[4]) ? $data[4] : Arr::a2s([]),
|
|
|
|
'attrs' => Arr::a2s($attrs),
|
|
|
|
'category_id' => $category_id,
|
|
|
|
'keyword_id' => $keyword_id,
|
|
|
|
'intro' => $intro,
|
...
|
...
|
|