cqp 5 月之前
父节点
当前提交
88a42e1e15
共有 1 个文件被更改,包括 12 次插入0 次删除
  1. 12 0
      app/Service/ImportService.php

+ 12 - 0
app/Service/ImportService.php

@@ -520,6 +520,8 @@ class ImportService extends Service
                 if(in_array($t,$array_clean)) return [false, '产品编码:'. $value[1] .'在文件中重复出现'];
                 $array_clean[] = $t;
 
+                $value[2] = $this->convertHyphens($value[2]);
+
                 if(! empty($value[8])){
                     if(! isset($map_attr[$value[8]])) return [false, '产品属性不存在' . $value[8]];
                     $value[8] = $map_attr[$value[8]];
@@ -726,6 +728,16 @@ class ImportService extends Service
         return [true, ''];
     }
 
+    function convertHyphens($string) {
+        // 定义要被替换的字符
+        $search = array('-', '-', '—');  // 全角连字符、半角连字符 和 破折号
+        $replace = '-';             // 替换成半角连字符
+
+        // 执行替换
+        $res = str_replace($search, $replace, $string);
+        return $res;
+    }
+
     function generateTitleToIdMap($tree, $prefix = '') {
         $result = [];