Przeglądaj źródła

[智价云] 导出导入超低监控价格补充

tangyuanwang 3 dni temu
rodzic
commit
1942729865
1 zmienionych plików z 38 dodań i 35 usunięć
  1. 38 35
      app/Http/Controllers/Manager/Process/LowPriceGoods.php

+ 38 - 35
app/Http/Controllers/Manager/Process/LowPriceGoods.php

@@ -955,17 +955,18 @@ class LowPriceGoods extends Controller
         $sheet->setCellValue('L2', '快照URL');
         $sheet->setCellValue('M2', '累计挂网次数');
         $sheet->setCellValue('N2', '连续挂网次数');
-        $sheet->setCellValue('O2', '链接地址*');
-        $sheet->setCellValue('P2', '店铺名称*');
-        $sheet->setCellValue('Q2', '匿名店铺');
-        $sheet->setCellValue('R2', '公司名称*');
-        $sheet->setCellValue('S2', '商业类型');
-        $sheet->setCellValue('T2', '信用代码');
-        $sheet->setCellValue('U2', '公司省');
-        $sheet->setCellValue('V2', '公司市');
-        $sheet->setCellValue('W2', '店铺省');
-        $sheet->setCellValue('X2', '店铺市');
-        $sheet->setCellValue('Y2', '采集时间(Y-m-d H:i:s)*');
+        $sheet->setCellValue('O2', '超低监控价格');
+        $sheet->setCellValue('P2', '链接地址*');
+        $sheet->setCellValue('Q2', '店铺名称*');
+        $sheet->setCellValue('R2', '匿名店铺');
+        $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)*');
         // 生成 Excel 文件
         $writer = new Xlsx($spreadsheet);
 
@@ -1043,7 +1044,7 @@ class LowPriceGoods extends Controller
                     }
                 }
                 $source_responsible_person_id = [];
-                $source_responsible_person_name = $item[22];
+                $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) {
@@ -1053,7 +1054,7 @@ class LowPriceGoods extends Controller
                 //         }
                 //     }
                 // }
-                $province_name = $item[20];
+                $province_name = $item[21];
                 //特殊地区1级移除市
                 if ($province_name && in_array($province_name, ['北京市', '天津市', '上海市', '重庆市'])) {
                     //移除市这个字符
@@ -1086,11 +1087,11 @@ class LowPriceGoods extends Controller
                 }
 
                 if (!empty($province_name) && !isset($province_id_data[$province_name])) return json_send(['code' => 'error', 'msg' => "第{$key_num}行省份信息不完整", 'data' => $item]);
-                $city_name = $item[21];
+                $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[22]) ? $item[22] : '';
+                $shipment_province_name = isset($item[23]) ? $item[23] : '';
                 //特殊地区1级移除市
                 if ($shipment_province_name && in_array($province_name, ['北京市', '天津市', '上海市', '重庆市'])) {
                     //移除市这个字符
@@ -1128,7 +1129,7 @@ class LowPriceGoods extends Controller
                     $shipment_province_id = $province_id_data[$shipment_province_name]['id'];
                 }
                 $shipment_city_id = '0';
-                $shipment_city_name = isset($item[23]) ? $item[23] : '';
+                $shipment_city_name = isset($item[24]) ? $item[24] : '';
                 if (!isset($city_id_data[$shipment_city_name])) {
                     $shipment_city_name = '';
                 } else {
@@ -1158,15 +1159,17 @@ class LowPriceGoods extends Controller
                 $insert_product_data['snapshot_url'] = isset($item[11]) ? $item[11] : ''; // 快照URL
                 $insert_product_data['online_posting_count'] = isset($item[12]) ? $item[12] : 1; // 累计挂网次数
                 $insert_product_data['continuous_listing_count'] = isset($item[13]) ? $item[13] : 1; // 连续挂网次数
-                $insert_product_data['link_url'] = $item[14]; // 链接地址
-                $insert_product_data['store_name'] = $item[15]; // 店铺名称
-                $insert_product_data['anonymous_store_name'] = isset($item[16]) ? $item[16] : ''; // 匿名店铺名称
-                $insert_product_data['company_name'] = $item[17]; // 公司名称
-                $insert_product_data['company_category_name'] = isset($item[18]) ? $item[18] : ''; // 公司分类
-                $insert_product_data['social_credit_code'] = isset($item[19]) ? $item[19] : ''; // 信用代码
-                $insert_product_data['province_name'] = isset($item[20]) ? $item[20] : ''; // 省份
+                $insert_product_data['ultra_low_price'] = isset($item[14]) && is_numeric($item[14]) ? $item[14] : '0'; // 超低监控价格
+                $insert_product_data['is_ultra_low_price'] = isset($item[14]) && is_numeric($item[14]) && $item[14] < $item[8] ? 1:0; // 是否超低价0=否1=是
+                $insert_product_data['link_url'] = $item[15]; // 链接地址
+                $insert_product_data['store_name'] = $item[16]; // 店铺名称
+                $insert_product_data['anonymous_store_name'] = isset($item[17]) ? $item[17] : ''; // 匿名店铺名称
+                $insert_product_data['company_name'] = $item[18]; // 公司名称
+                $insert_product_data['company_category_name'] = isset($item[19]) ? $item[19] : ''; // 公司分类
+                $insert_product_data['social_credit_code'] = isset($item[20]) ? $item[20] : ''; // 信用代码
+                $insert_product_data['province_name'] = isset($item[21]) ? $item[21] : ''; // 省份
                 $insert_product_data['province_id'] = isset($province_id_data[$province_name]) ? $province_id_data[$province_name]['id'] : 0; // 省份ID
-                $insert_product_data['city_name'] =isset( $item[21]) ? $item[21] : ''; // 城市
+                $insert_product_data['city_name'] =isset( $item[22]) ? $item[22] : ''; // 城市
                 $insert_product_data['city_id'] = isset($city_id_data[$city_name]) ? $city_id_data[$city_name]['id'] : 0; // 城市ID
                 $insert_product_data['area_info'] = ''; // 详细地址
                 $insert_product_data['source_responsible_person'] = !empty($source_responsible_person_id) ? implode(',', $source_responsible_person_id) : ''; //溯源责任人ID集合
@@ -1178,8 +1181,8 @@ class LowPriceGoods extends Controller
                 $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[24]); // 采集时间
-                $insert_product_data['scrape_date'] = date('Y-m-d',strtotime($item[24])); // 检索采集日期
+                $insert_product_data['collection_time'] = strtotime($item[25]); // 采集时间
+                $insert_product_data['scrape_date'] = date('Y-m-d',strtotime($item[25])); // 检索采集日期
                 //插入数据
                 $LowPriceGoodsModel->addLowPriceGoods($insert_product_data, true);
             }
@@ -1218,32 +1221,32 @@ class LowPriceGoods extends Controller
         if (!$item[8]) {
             return ['code' => 'error', 'msg' => "第{$key}行挂网价格不能为空", 'data' => $item];
         }
-        if (!$item[14]) {
+        if (!$item[15]) {
             return ['code' => 'error', 'msg' => "第{$key}行链接地址不能为空", 'data' => $item];
         }
-        if (!$item[15]) {
+        if (!$item[16]) {
             return ['code' => 'error', 'msg' => "第{$key}行店铺名称不能为空", 'data' => $item];
         }
-        if (!$item[17]) {
+        if (!$item[18]) {
             return ['code' => 'error', 'msg' => "第{$key}行公司名称不能为空", 'data' => $item];
         }
-        // if (!$item[19]) {
+        // if (!$item[20]) {
         //     return ['code' => 'error', 'msg' => "第{$key}行信用代码不能为空", 'data' => $item];
         // }
-        // if (!$item[20]) {
+        // if (!$item[21]) {
         //     return ['code' => 'error', 'msg' => "第{$key}行省份不能为空", 'data' => $item];
         // }
-        // if (!$item[21]) {
+        // if (!$item[22]) {
         //     return ['code' => 'error', 'msg' => "第{$key}行城市不能为空", 'data' => $item];
         // }
-        if (!$item[24]) {
+        if (!$item[25]) {
             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[24])) {
+            if (!preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}$/', $item[25])) {
                 return ['code' => 'error', 'msg' => "第{$key}行采集时间格式不正确", 'data' => $item];
             }
-            if (strtotime($item[24]) > time()) {
+            if (strtotime($item[25]) > time()) {
                 return ['code' => 'error', 'msg' => "第{$key}行采集时间不能大于当前日期", 'data' => $item];
             }
         }