Преглед на файлове

[智价云] 省份城市合并导入更新

tangyuanwang преди 1 ден
родител
ревизия
8753a460ee
променени са 2 файла, в които са добавени 18 реда и са изтрити 141 реда
  1. 9 71
      app/Http/Controllers/Manager/Process/LowPriceGoods.php
  2. 9 70
      app/Http/Controllers/Manager/Process/ViolationProduct.php

+ 9 - 71
app/Http/Controllers/Manager/Process/LowPriceGoods.php

@@ -960,7 +960,7 @@ class LowPriceGoods extends Controller
         $sheet = $spreadsheet->getActiveSheet();
 
         //合并单元格
-        $sheet->mergeCells('A1:Y1');
+        $sheet->mergeCells('A1:X1');
         $sheet->setCellValue('A1', '低价挂网商品导入模板'); // 设置合并后的单元格内容
         // 获取合并后的单元格样式对象
         $style = $sheet->getStyle('A1');
@@ -990,11 +990,9 @@ class LowPriceGoods extends Controller
         $sheet->setCellValue('S2', '公司名称*');
         $sheet->setCellValue('T2', '商业类型');
         $sheet->setCellValue('U2', '信用代码');
-        $sheet->setCellValue('V2', '公司省');
-        $sheet->setCellValue('W2', '公司市');
-        $sheet->setCellValue('X2', '店铺省');
-        $sheet->setCellValue('Y2', '店铺市');
-        $sheet->setCellValue('Z2', '采集时间(Y-m-d H:i:s)*');
+        $sheet->setCellValue('V2', '省份');
+        $sheet->setCellValue('W2', '市区');
+        $sheet->setCellValue('X2', '采集时间(Y-m-d H:i:s)*');
         // 生成 Excel 文件
         $writer = new Xlsx($spreadsheet);
 
@@ -1072,16 +1070,6 @@ class LowPriceGoods extends Controller
                     }
                 }
                 $source_responsible_person_id = [];
-                $source_responsible_person_name = $item[23];
-                // if ($source_responsible_person_name) {
-                //     $source_responsible_person_name = explode(',', $source_responsible_person_name);
-                //     foreach ($source_responsible_person_name as $k => $v) {
-                //         $v = trim($v);
-                //         if (isset($result[$v])) {
-                //             $source_responsible_person_id[] = $result[$v]['id'];
-                //         }
-                //     }
-                // }
                 $province_name = $item[21];
                 //特殊地区1级移除市
                 if ($province_name && in_array($province_name, ['北京市', '天津市', '上海市', '重庆市'])) {
@@ -1118,52 +1106,6 @@ class LowPriceGoods extends Controller
                 $city_name = $item[22];
                 if (!empty($city_name)  && !isset($city_id_data[$city_name])) return json_send(['code' => 'error', 'msg' => "第{$key_num}行城市信息不完整", 'data' => $item]);
 
-
-                $shipment_province_name = isset($item[23]) ? $item[23] : '';
-                //特殊地区1级移除市
-                if ($shipment_province_name && in_array($province_name, ['北京市', '天津市', '上海市', '重庆市'])) {
-                    //移除市这个字符
-                    $shipment_province_name = trim(str_replace('市', '', $shipment_province_name));
-                } else if ($shipment_province_name && in_array($shipment_province_name, ['北京', '天津', '上海', '重庆'])) {
-                } else if ($shipment_province_name && in_array($shipment_province_name, ['内蒙古', '广西', '西藏', '新疆', '宁夏'])) {
-                    switch ($shipment_province_name) {
-                        case '内蒙古':
-                            $shipment_province_name = '内蒙古自治区';
-                            break;
-                        case '广西':
-                            $shipment_province_name = '广西壮族自治区';
-                            break;
-                        case '西藏':
-                            $shipment_province_name = '西藏自治区';
-                            break;
-                        case '新疆':
-                            $shipment_province_name = '新疆维吾尔自治区';
-                            break;
-                        case '宁夏':
-                            $shipment_province_name = '宁夏回族自治区';
-                            break;
-                    }
-                } else if ($shipment_province_name && in_array($shipment_province_name, ['内蒙古自治区', '广西壮族自治区', '西藏自治区', '新疆维吾尔自治区', '宁夏回族自治区'])) {
-                } else if (strpos($shipment_province_name, '省') === false) {
-                    //是否存在市省,如果不存在则补全
-                    if (strpos($shipment_province_name, '省') === false) {
-                        $shipment_province_name = $shipment_province_name . '省';
-                    }
-                }
-                $shipment_province_id = '0';
-                if (!isset($province_id_data[$shipment_province_name])) {
-                    $shipment_province_name = '';
-                } else {
-                    $shipment_province_id = $province_id_data[$shipment_province_name]['id'];
-                }
-                $shipment_city_id = '0';
-                $shipment_city_name = isset($item[24]) ? $item[24] : '';
-                if (!isset($city_id_data[$shipment_city_name])) {
-                    $shipment_city_name = '';
-                } else {
-                    $shipment_city_id = $city_id_data[$shipment_city_name]['id'];
-                }
-
                 // 权限判断
                 if ($is_admin != 1 && $company_id != 0) {
                     $insert_product_data['company_id'] = $company_id;
@@ -1205,12 +1147,8 @@ class LowPriceGoods extends Controller
                 $insert_product_data['status'] = 0; //状态0=有效=无效
                 $insert_product_data['insert_time'] = time();
                 $insert_product_data['source_id'] = 0; // 原始数据ID
-                $insert_product_data['shipment_province_id'] = $shipment_province_id; // 店铺省id
-                $insert_product_data['shipment_province_name'] = $shipment_province_name; // 店铺省
-                $insert_product_data['shipment_city_id'] = $shipment_city_id; // 店铺市id
-                $insert_product_data['shipment_city_name'] = $shipment_city_name; // 店铺市
-                $insert_product_data['collection_time'] = strtotime($item[25]); // 采集时间
-                $insert_product_data['scrape_date'] = date('Y-m-d', strtotime($item[25])); // 检索采集日期
+                $insert_product_data['collection_time'] = strtotime($item[23]); // 采集时间
+                $insert_product_data['scrape_date'] = date('Y-m-d', strtotime($item[23])); // 检索采集日期
                 //插入数据
                 $LowPriceGoodsModel->addLowPriceGoods($insert_product_data, true);
             }
@@ -1267,14 +1205,14 @@ class LowPriceGoods extends Controller
         // if (!$item[22]) {
         //     return ['code' => 'error', 'msg' => "第{$key}行城市不能为空", 'data' => $item];
         // }
-        if (!$item[25]) {
+        if (!$item[23]) {
             return ['code' => 'error', 'msg' => "第{$key}行采集时间不能为空", 'data' => $item];
         } else {
             //校验格式是否为Y-m-d H:i:s
-            if (!preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}$/', $item[25])) {
+            if (!preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}$/', $item[23])) {
                 return ['code' => 'error', 'msg' => "第{$key}行采集时间格式不正确", 'data' => $item];
             }
-            if (strtotime($item[25]) > time()) {
+            if (strtotime($item[23]) > time()) {
                 return ['code' => 'error', 'msg' => "第{$key}行采集时间不能大于当前日期", 'data' => $item];
             }
         }

+ 9 - 70
app/Http/Controllers/Manager/Process/ViolationProduct.php

@@ -752,7 +752,7 @@ class ViolationProduct extends Controller
         $sheet = $spreadsheet->getActiveSheet();
 
         //合并单元格
-        $sheet->mergeCells('A1:W1');
+        $sheet->mergeCells('A1:U1');
         $sheet->setCellValue('A1', '禁止挂网商品导入模板'); // 设置合并后的单元格内容
         // 获取合并后的单元格样式对象
         $style = $sheet->getStyle('A1');
@@ -779,11 +779,9 @@ class ViolationProduct extends Controller
         $sheet->setCellValue('P2', '公司名称*');
         $sheet->setCellValue('Q2', '公司分类名称');
         $sheet->setCellValue('R2', '信用代码');
-        $sheet->setCellValue('S2', '公司省');
-        $sheet->setCellValue('T2', '公司市');
-        $sheet->setCellValue('U2', '店铺省');
-        $sheet->setCellValue('V2', '店铺市');
-        $sheet->setCellValue('W2', '采集时间(Y-m-d H:i:s)*');
+        $sheet->setCellValue('S2', '省份');
+        $sheet->setCellValue('T2', '市区');
+        $sheet->setCellValue('U2', '采集时间(Y-m-d H:i:s)*');
         // 生成 Excel 文件
         $writer = new Xlsx($spreadsheet);
 
@@ -861,16 +859,6 @@ class ViolationProduct extends Controller
                     }
                 }
                 $source_responsible_person_id = [];
-                $source_responsible_person_name = $item[20];
-                // if ($source_responsible_person_name) {
-                //     $source_responsible_person_name = explode(',', $source_responsible_person_name);
-                //     foreach ($source_responsible_person_name as $k => $v) {
-                //         $v = trim($v);
-                //         if (isset($result[$v])) {
-                //             $source_responsible_person_id[] = $result[$v]['id'];
-                //         }
-                //     }
-                // }
                 $province_name = $item[18];
                 //特殊地区1级移除市
                 if ($province_name && in_array($province_name, ['北京市', '天津市', '上海市', '重庆市'])) {
@@ -907,51 +895,6 @@ class ViolationProduct extends Controller
                 $city_name = $item[19];
                 if (!empty($city_name)  && !isset($city_id_data[$city_name])) return json_send(['code' => 'error', 'msg' => "第{$key_num}行城市信息不完整", 'data' => $item]);
 
-                $shipment_province_name = isset($item[20]) ? $item[20] : '';
-                //特殊地区1级移除市
-                if ($shipment_province_name && in_array($province_name, ['北京市', '天津市', '上海市', '重庆市'])) {
-                    //移除市这个字符
-                    $shipment_province_name = trim(str_replace('市', '', $shipment_province_name));
-                } else if ($shipment_province_name && in_array($shipment_province_name, ['北京', '天津', '上海', '重庆'])) {
-                } else if ($shipment_province_name && in_array($shipment_province_name, ['内蒙古', '广西', '西藏', '新疆', '宁夏'])) {
-                    switch ($shipment_province_name) {
-                        case '内蒙古':
-                            $shipment_province_name = '内蒙古自治区';
-                            break;
-                        case '广西':
-                            $shipment_province_name = '广西壮族自治区';
-                            break;
-                        case '西藏':
-                            $shipment_province_name = '西藏自治区';
-                            break;
-                        case '新疆':
-                            $shipment_province_name = '新疆维吾尔自治区';
-                            break;
-                        case '宁夏':
-                            $shipment_province_name = '宁夏回族自治区';
-                            break;
-                    }
-                } else if ($shipment_province_name && in_array($shipment_province_name, ['内蒙古自治区', '广西壮族自治区', '西藏自治区', '新疆维吾尔自治区', '宁夏回族自治区'])) {
-                } else if (strpos($shipment_province_name, '省') === false) {
-                    //是否存在市省,如果不存在则补全
-                    if (strpos($shipment_province_name, '省') === false) {
-                        $shipment_province_name = $shipment_province_name . '省';
-                    }
-                }
-                $shipment_province_id = '0';
-                if (!isset($province_id_data[$shipment_province_name])) {
-                    $shipment_province_name = '';
-                } else {
-                    $shipment_province_id = $province_id_data[$shipment_province_name]['id'];
-                }
-                $shipment_city_id = '0';
-                $shipment_city_name = isset($item[21]) ? $item[21] : '';
-                if (!isset($city_id_data[$shipment_city_name])) {
-                    $shipment_city_name = '';
-                } else {
-                    $shipment_city_id = $city_id_data[$shipment_city_name]['id'];
-                }
-
                 // 权限判断
                 if ($is_admin != 1 && $company_id != 0) {
                     $insert_product_data['company_id'] = $company_id;
@@ -989,12 +932,8 @@ class ViolationProduct extends Controller
                 $insert_product_data['status'] = 0; //状态0=有效=无效
                 $insert_product_data['insert_time'] = time();
                 $insert_product_data['source_id'] = 0; // 原始数据ID
-                $insert_product_data['shipment_province_id'] = $shipment_province_id; // 店铺省id
-                $insert_product_data['shipment_province_name'] = $shipment_province_name; // 店铺省
-                $insert_product_data['shipment_city_id'] = $shipment_city_id; // 店铺市id
-                $insert_product_data['shipment_city_name'] = $shipment_city_name; // 店铺市
-                $insert_product_data['scrape_date'] = date('Y-m-d',strtotime($item[22])); // 检索采集日期
-                $insert_product_data['collection_time'] = strtotime($item[22]); // 采集时间
+                $insert_product_data['scrape_date'] = date('Y-m-d',strtotime($item[20])); // 检索采集日期
+                $insert_product_data['collection_time'] = strtotime($item[20]); // 采集时间
                 //插入数据
                 $ViolationProductModel->addViolationProduct($insert_product_data, true);
             }
@@ -1045,14 +984,14 @@ class ViolationProduct extends Controller
         // if (!$item[19]) {
         //     return ['code' => 'error', 'msg' => "第{$key}行城市不能为空", 'data' => $item];
         // }
-        if (!$item[22]) {
+        if (!$item[20]) {
             return ['code' => 'error', 'msg' => "第{$key}行采集时间不能为空", 'data' => $item];
         } else {
             //校验格式是否为Y-m-d H:i:s
-            if (!preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}$/', $item[22])) {
+            if (!preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}$/', $item[20])) {
                 return ['code' => 'error', 'msg' => "第{$key}行采集时间格式不正确", 'data' => $item];
             }
-            if (strtotime($item[22]) > time()) {
+            if (strtotime($item[20]) > time()) {
                 return ['code' => 'error', 'msg' => "第{$key}行采集时间不能大于当前时间", 'data' => $item];
             }
         }