作者 Your Name
@@ -644,11 +644,11 @@ if (!function_exists('getFileUrl')) { @@ -644,11 +644,11 @@ if (!function_exists('getFileUrl')) {
644 * @method :post 644 * @method :post
645 * @time :2023/7/20 16:46 645 * @time :2023/7/20 16:46
646 */ 646 */
647 - function getFileUrl($path,$storage_type = 0,$location = 0){ 647 + function getFileUrl($path,$storage_type = 0,$location = 0,$file_cdn = 0){
648 if(is_array($path)){ 648 if(is_array($path)){
649 $url =[]; 649 $url =[];
650 foreach ($path as $v){ 650 foreach ($path as $v){
651 - $url[] = getFileUrl($v,$storage_type,$location); 651 + $url[] = getFileUrl($v,$storage_type,$location,$file_cdn);
652 } 652 }
653 }else{ 653 }else{
654 if(empty($path)){ 654 if(empty($path)){
@@ -662,7 +662,7 @@ if (!function_exists('getFileUrl')) { @@ -662,7 +662,7 @@ if (!function_exists('getFileUrl')) {
662 } 662 }
663 $file_type = pathinfo($path, PATHINFO_EXTENSION); 663 $file_type = pathinfo($path, PATHINFO_EXTENSION);
664 $fileTypeArr = ['zip', 'pdf', 'mp4', 'doc', 'docx', 'm4v', 'xlsx']; 664 $fileTypeArr = ['zip', 'pdf', 'mp4', 'doc', 'docx', 'm4v', 'xlsx'];
665 - if(in_array(strtolower($file_type),$fileTypeArr)){ 665 + if(in_array(strtolower($file_type),$fileTypeArr) && ($file_cdn == 0)){
666 $cdn2 = config('filesystems.disks.cos')['cdn2']; 666 $cdn2 = config('filesystems.disks.cos')['cdn2'];
667 return $cdn2.$path; 667 return $cdn2.$path;
668 } 668 }
@@ -85,7 +85,7 @@ class CustomModuleContentController extends BaseController @@ -85,7 +85,7 @@ class CustomModuleContentController extends BaseController
85 $v['image_link'] = getImageUrl($v['image'],$this->user['storage_type'] ?? 0,$this->user['project_location']); 85 $v['image_link'] = getImageUrl($v['image'],$this->user['storage_type'] ?? 0,$this->user['project_location']);
86 } 86 }
87 if(!empty($v['video'])){ 87 if(!empty($v['video'])){
88 - $v['video']['url'] = getFileUrl($v['video']['url'],$this->user['storage_type'] ?? 0,$this->user['project_location']); 88 + $v['video']['url'] = getFileUrl($v['video']['url'],$this->user['storage_type'] ?? 0,$this->user['project_location'],$this->user['file_cdn']);
89 $v['video']['video_image'] = getImageUrl($v['video']['video_image'],$this->user['storage_type'] ?? 0,$this->user['project_location']); 89 $v['video']['video_image'] = getImageUrl($v['video']['video_image'],$this->user['storage_type'] ?? 0,$this->user['project_location']);
90 } 90 }
91 return $this->success($v); 91 return $this->success($v);
@@ -133,11 +133,11 @@ class ProductController extends BaseController @@ -133,11 +133,11 @@ class ProductController extends BaseController
133 } 133 }
134 } 134 }
135 if(!empty($v['video'])){ 135 if(!empty($v['video'])){
136 - $v['video']['url'] = getFileUrl($v['video']['url'],$this->user['storage_type'] ?? 0,$this->user['project_location']); 136 + $v['video']['url'] = getFileUrl($v['video']['url'],$this->user['storage_type'] ?? 0,$this->user['project_location'],$this->user['file_cdn']);
137 $v['video']['video_image'] = getImageUrl($v['video']['video_image'] ?? '',$this->user['storage_type'] ?? 0,$this->user['project_location']); 137 $v['video']['video_image'] = getImageUrl($v['video']['video_image'] ?? '',$this->user['storage_type'] ?? 0,$this->user['project_location']);
138 } 138 }
139 if(!empty($v['files']) && !empty($v['files']['url'])){ 139 if(!empty($v['files']) && !empty($v['files']['url'])){
140 - $v['files']['url'] = getFileUrl($v['files']['url'],$this->user['storage_type'] ?? 0,$this->user['project_location']); 140 + $v['files']['url'] = getFileUrl($v['files']['url'],$this->user['storage_type'] ?? 0,$this->user['project_location'],$this->user['file_cdn']);
141 } 141 }
142 return $this->success($v); 142 return $this->success($v);
143 } 143 }
@@ -379,9 +379,9 @@ class ProductController extends BaseController @@ -379,9 +379,9 @@ class ProductController extends BaseController
379 foreach ($arr1 as $k1=>$v1){ 379 foreach ($arr1 as $k1=>$v1){
380 $v1 = (array)$v1; 380 $v1 = (array)$v1;
381 if(isset($v1['url'])){ 381 if(isset($v1['url'])){
382 - $v1['url'] = getFileUrl($v1['url'],$this->user['storage_type'],$this->user['project_location']); 382 + $v1['url'] = getFileUrl($v1['url'],$this->user['storage_type'],$this->user['project_location'],$this->user['file_cdn']);
383 }else{ 383 }else{
384 - $v1 = getFileUrl($v1,$this->user['storage_type'],$this->user['project_location']); 384 + $v1 = getFileUrl($v1,$this->user['storage_type'],$this->user['project_location'],$this->user['file_cdn']);
385 } 385 }
386 $arr1[$k1] = $v1; 386 $arr1[$k1] = $v1;
387 } 387 }
@@ -342,7 +342,7 @@ class FileController @@ -342,7 +342,7 @@ class FileController
342 if ($info === false) { 342 if ($info === false) {
343 $this->response('指定文件不存在!', Code::USER_ERROR); 343 $this->response('指定文件不存在!', Code::USER_ERROR);
344 } 344 }
345 - $fileUrl = getFileUrl($info['path'],$info['is_cos']); 345 + $fileUrl = getFileUrl($info['path'],$this->cache['storage_type'] ?? 0,$this->cache['project_location'] ?? 0,$this->cache['file_cdn'] ?? 0);
346 // 设置响应头 346 // 设置响应头
347 header('Content-Description: File Transfer'); 347 header('Content-Description: File Transfer');
348 header('Content-Type: application/octet-stream'); 348 header('Content-Type: application/octet-stream');
@@ -392,7 +392,7 @@ class FileController @@ -392,7 +392,7 @@ class FileController
392 $fileModel = new File(); 392 $fileModel = new File();
393 $lists = $fileModel->list($this->map,'id',['id','hash','type','path','created_at','name']); 393 $lists = $fileModel->list($this->map,'id',['id','hash','type','path','created_at','name']);
394 foreach ($lists as $k => $v){ 394 foreach ($lists as $k => $v){
395 - $v['file_link'] = getFileUrl($v['path'],$this->cache['storage_type'] ?? 0); 395 + $v['file_link'] = getFileUrl($v['path'],$this->cache['storage_type'] ?? 0,$this->cache['project_location'] ?? 0,$this->cache['file_cdn'] ?? 0);
396 $lists[$k] = $v; 396 $lists[$k] = $v;
397 } 397 }
398 $this->response('success',Code::SUCCESS,$lists); 398 $this->response('success',Code::SUCCESS,$lists);
@@ -408,7 +408,7 @@ class FileController @@ -408,7 +408,7 @@ class FileController
408 public function responseData($path, $name){ 408 public function responseData($path, $name){
409 $data = [ 409 $data = [
410 'file'=>$path, 410 'file'=>$path,
411 - 'file_link'=>getFileUrl($path,$this->cache['storage_type'] ?? 0), 411 + 'file_link'=>getFileUrl($path,$this->cache['storage_type'] ?? 0,$this->cache['project_location'] ?? 0,$this->cache['file_cdn'] ?? 0),
412 'name'=>$name, 412 'name'=>$name,
413 'file_download'=>url('a/download_files?path='.$path) 413 'file_download'=>url('a/download_files?path='.$path)
414 ]; 414 ];
@@ -66,7 +66,7 @@ class AyrReleaseLogic extends BaseLogic @@ -66,7 +66,7 @@ class AyrReleaseLogic extends BaseLogic
66 $arr[] = getImageUrl($v1); 66 $arr[] = getImageUrl($v1);
67 } 67 }
68 }else{ 68 }else{
69 - $arr[] = getFileUrl($v); 69 + $arr[] = getFileUrl($v,$this->user['storage_type'] ?? 0,$this->user['project_location'] ?? 0,$this->user['file_cdn'] ?? 0);
70 } 70 }
71 } 71 }
72 } 72 }
@@ -94,7 +94,7 @@ class CustomModuleContentLogic extends BaseLogic @@ -94,7 +94,7 @@ class CustomModuleContentLogic extends BaseLogic
94 }elseif($v['type'] == 4){ 94 }elseif($v['type'] == 4){
95 $arr1 = json_decode($info['values']); 95 $arr1 = json_decode($info['values']);
96 foreach ($arr1 as $k1=>$v1){ 96 foreach ($arr1 as $k1=>$v1){
97 - $v1 = getFileUrl($v1,$this->user['storage_type'],$this->user['project_location']); 97 + $v1 = getFileUrl($v1,$this->user['storage_type'],$this->user['project_location'],$this->user['file_cdn']);
98 $arr1[$k1] = $v1; 98 $arr1[$k1] = $v1;
99 } 99 }
100 $v['values'] = $arr1; 100 $v['values'] = $arr1;
@@ -434,16 +434,49 @@ class ProductLogic extends BaseLogic @@ -434,16 +434,49 @@ class ProductLogic extends BaseLogic
434 public function setCopyProduct(){ 434 public function setCopyProduct(){
435 $info = $this->model->read(['id'=>$this->param['id']]); 435 $info = $this->model->read(['id'=>$this->param['id']]);
436 $param = $this->setProductParams($info); 436 $param = $this->setProductParams($info);
437 - $save_id = $this->model->insertGetId($param);  
438 - $route = preg_replace('/-product.*/', '', $param['route']);  
439 - $route = RouteMap::setRoute($route, RouteMap::SOURCE_PRODUCT, $save_id, $this->user['project_id']);  
440 - $this->model->edit(['route'=>$route],['id'=>$save_id]);  
441 - //同步可视化装修数据  
442 - $this->copyTemplate($this->param['id'],$info['project_id'],$save_id); 437 + DB::beginTransaction();
  438 + try {
  439 + $save_id = $this->model->insertGetId($param);
  440 + CategoryRelated::saveRelated($save_id, $info['category_id']);
  441 + $route = preg_replace('/-product.*/', '', $param['route']);
  442 + //同步分类关联表
  443 + $route = RouteMap::setRoute($route, RouteMap::SOURCE_PRODUCT, $save_id, $this->user['project_id']);
  444 + $this->model->edit(['route'=>$route],['id'=>$save_id]);
  445 + //同步可视化装修数据
  446 + $this->copyTemplate($this->param['id'],$info['project_id'],$save_id);
  447 + //同步扩展字段
  448 + $this->copyExtendInfo($info['id'],$save_id);
  449 + DB::commit();
  450 + }catch (\Exception $e){
  451 + DB::rollBack();
  452 + $this->fail('复制失败,请联系管理员');
  453 + }
443 return $this->success(['id'=>$save_id]); 454 return $this->success(['id'=>$save_id]);
444 } 455 }
445 456
446 /** 457 /**
  458 + * @remark :复制项目扩展字段
  459 + * @name :copyExtendInfo
  460 + * @author :lyh
  461 + * @method :post
  462 + * @time :2024/7/12 9:23
  463 + */
  464 + public function copyExtendInfo($old_id,$new_id){
  465 + $extendInfoModel = new ExtendInfo();
  466 + $extendList = $extendInfoModel->list(['product_id'=>$old_id]);
  467 + if(!empty($extendList)){
  468 + foreach ($extendList as $k => $v){
  469 + $v['product_id'] = $new_id;
  470 + $v['created_at'] = date('Y-m-d H:i:s');
  471 + $v['updated_at'] = date('Y-m-d H:i:s');
  472 + $extendList[$k] = $v;
  473 + }
  474 + $extendList->insert($extendList);
  475 + }
  476 + return $this->success();
  477 + }
  478 +
  479 + /**
447 * @remark :同步模版数据 480 * @remark :同步模版数据
448 * @name :copyTemplate 481 * @name :copyTemplate
449 * @author :lyh 482 * @author :lyh
@@ -80,6 +80,9 @@ class TranslateLogic extends BaseLogic @@ -80,6 +80,9 @@ class TranslateLogic extends BaseLogic
80 if(!empty($arr2)){ 80 if(!empty($arr2)){
81 $i = 0; 81 $i = 0;
82 TranslateText: 82 TranslateText:
  83 + if($languageInfo['short'] == 'zh-ct'){
  84 + $languageInfo['short'] = 'zh-TW';
  85 + }
83 $translate_list = Translate::tran($arr2, $languageInfo['short']); 86 $translate_list = Translate::tran($arr2, $languageInfo['short']);
84 if(empty($translate_list)){ 87 if(empty($translate_list)){
85 if ($i < 3) { 88 if ($i < 3) {
@@ -279,6 +279,7 @@ class UserLoginLogic @@ -279,6 +279,7 @@ class UserLoginLogic
279 $info['project_type'] = $project['type']; 279 $info['project_type'] = $project['type'];
280 $info['storage_type'] = $project['storage_type']; 280 $info['storage_type'] = $project['storage_type'];
281 $info['project_location'] = $project['project_location']; 281 $info['project_location'] = $project['project_location'];
  282 + $info['file_cnd'] = $project['deploy_build']['file_cnd'];
282 $info['service_duration'] = $project['deploy_build']['service_duration'] ?? 0; 283 $info['service_duration'] = $project['deploy_build']['service_duration'] ?? 0;
283 $info['remain_day'] = $project['remain_day'] ?? 0; 284 $info['remain_day'] = $project['remain_day'] ?? 0;
284 if($info['is_customized'] == 1){ 285 if($info['is_customized'] == 1){