瀏覽代碼

[智价云] 采集优化调整(分块处理采集数据匹配规则)

tangyuanwang 1 天之前
父節點
當前提交
3f68567f66

+ 5 - 15
app/Console/Commands/DailyTask.php

@@ -8,7 +8,7 @@ use App\Jobs\Manager\Process\LowPriceGoodsJobs;
 use App\Jobs\Manager\Process\ViolationProductJobs;
 use App\Jobs\Manager\Process\ViolationCompanyJobs;
 use App\Models\Manager\External\Company as CompanyModel;
-use App\Jobs\Manager\Process\ViolationStoreJobs;
+use App\Jobs\Manager\Process\ScrapeDataProductJobs;
 
 /**
  * 定时清洗采集的商品数据
@@ -43,25 +43,15 @@ class DailyTask extends Command
 
         try {
             Log::info('每日数据清洗任务执行中 - ' . now());
+            $start_time = time() - 60 * 5; // 开始时间 5分钟之前
+            $end_time = time(); //结束时间
             $CompanyModel = new CompanyModel();
             $company_list = $CompanyModel->select(['id', 'status'])->where('status', 0)->orderByDesc('cleaning_priority')->get()->toarray();
             foreach ($company_list as $company) {
-                $message_data = ['company_id' => $company['id'], 'page' => '1', 'limit' => '50'];
+                $message_data = ['company_id' => $company['id'], 'page' => '1', 'limit' => '10000', 'start_time' => $start_time, 'end_time' => $end_time];
                 //执行低价挂网商品数据清洗任务
-                LowPriceGoodsJobs::dispatch($message_data);
-                //执行违规商品数据清洗任务
-                ViolationProductJobs::dispatch($message_data);
-                //执行违规公司数据清洗任务
-                ViolationCompanyJobs::dispatch($message_data);
+                ScrapeDataProductJobs::dispatch($message_data);
             }
-            // $message_data = ['page' => '1', 'limit' => '50'];
-            // 执行低价挂网商品数据清洗任务
-            // LowPriceGoodsJobs::dispatch($message_data);
-            // 执行违规商品数据清洗任务
-            // ViolationProductJobs::dispatch($message_data);
-            // 执行违规公司数据清洗任务
-            // ViolationCompanyJobs::dispatch($message_data);
-            // 示例:记录日志
             $this->info('每日任务执行完成!');
             return Command::SUCCESS;
         } catch (\Exception $e) {

+ 483 - 503
app/Jobs/Manager/Process/LowPriceGoodsDataJobs.php

@@ -12,15 +12,12 @@ use App\Facades\Servers\Logs\Log;
 use App\Models\Manager\Process\LowPriceGoods as LowPriceGoodsModel;
 use App\Models\Manager\Personnel\Employee as EmployeeModel;
 use App\Models\Api\Process\ExecuteLog as ExecuteLogModel;
-use App\Models\Manager\Process\ScrapeData as ScrapeDataModel;
 use App\Models\Manager\WashConfig\ViolationCompany as ViolationCompanyModel;
 use App\Models\Manager\WashConfig\ViolationCompanyMember as ViolationCompanyMemberModel;
 use App\Models\Manager\Citys as CitysModel;
 use App\Models\Manager\Personnel\EmployeePlatform as EmployeePlatformModel;
 use App\Models\Manager\Personnel\EmployeeArea as EmployeeAreaModel;
-use Illuminate\Support\Facades\DB;
 use App\Models\Manager\WashConfig\ViolationStore as ViolationStoreModel;
-use Illuminate\Support\Carbon;
 
 /**
  * 数据清洗-低价挂网商品队列
@@ -72,7 +69,6 @@ class LowPriceGoodsDataJobs implements ShouldQueue
         $CitysModel = new CitysModel();
         $EmployeeModel = new EmployeeModel();
         $LowPriceGoodsModel = new LowPriceGoodsModel();
-        $ScrapeDataModel = new ScrapeDataModel();
         $ViolationCompanyModel = new ViolationCompanyModel();
         $ViolationCompanyMemberModel = new ViolationCompanyMemberModel();
         $EmployeePlatformModel = new EmployeePlatformModel();
@@ -89,548 +85,532 @@ class LowPriceGoodsDataJobs implements ShouldQueue
         $executeLog_id = $message_data['executeLog_id'];
         $category_name = $message_data['category_name']; //产品分类名称
         $specify_responsible_person = $message_data['specify_responsible_person']; //指派责任人 0=开启 1=关闭
-        $limit = isset($message_data['limit']) ? $message_data['limit'] : 10;
-        $page = isset($message_data['page']) ? $message_data['page'] : 1;
         $company_id = isset($message_data['company_id']) ? $message_data['company_id'] : 0; //品牌方公司ID
         $product_brand = $message_data['product_brand']; //商品品牌名称
         $product_keywords = $message_data['product_keyword']; //关键字
-        $item_totle_page = $message_data['item_totle_page']; //清洗商品总页数
-        $item_now_page = $message_data['item_now_page']; //清洗商品当前页
+        $product_data = isset($this->message_data['product_data']) ? $this->message_data['product_data'] : [];
+        $index_number = isset($this->message_data['index_number']) ? $this->message_data['index_number'] : 0;
+        $data_totle = isset($this->message_data['data_totle']) ? $this->message_data['data_totle'] : 0;
 
-        $where = [];
-        $start_time = $message_data['start_time'];
-        $end_time = $message_data['end_time'];
-        $start_time_string = date('Y-m-d H:i:s', $start_time);
-        $end_time_string = date('Y-m-d H:i:s', $end_time);
-        $where[] = ['insert_time', '>=', $start_time_string];
-        $where[] = ['insert_time', '<=', $end_time_string];
-        $where[] = ['product_name', 'like', '%' . $product_name . '%'];
-        if ($product_brand) $where[] = ['product_brand', 'like', '%' . $product_brand . '%'];
-
-        $ScrapeDataModel = $ScrapeDataModel
-            ->orWhere(function ($q) use ($where, $enable_full_quantity, $product_specs, $product_keywords, $company_scope, $social_credit_code, $suggested_price, $platform) {
-                $q->where([['min_price', '>=', '0.01'], ['number', '>=', '1']])->whereRaw('(min_price / NULLIF(number, 0)) < ' . floatval($suggested_price)); //计算单盒价格
-                if ($enable_full_quantity == 1) {
-                    $where[] = ['product_name', 'like', '%' . $product_specs . '%']; //如果不是全量清洗,则查询规格,从商品名称中查找规格
-                }
-                $q->where($where);
-                if (!empty($product_keywords)) {
-                    $q->where(function ($query) use ($product_keywords) {
-                        // 平台条件(固定)
-                        $query->where(function ($query_li) use ($product_keywords) {
-                            foreach ($product_keywords as $product_keyword) {
-                                if (empty($product_keyword)) continue;
-                                $query_li->orWhere([['product_name', 'like', '%' . $product_keyword . '%']]);
-                            }
-                        });
-                    });
-                }
-                if ($company_scope == 2 && $social_credit_code != '') {
-                    $q->whereIn('qualification_number', $social_credit_code);
-                }
-                if ($platform != '0' && !empty($platform)) {
-                    $platform = explode(',', $platform);
-                    $q->whereIn('platform_id', $platform);
-                }
-            })->orWhere(function ($q) use ($where, $enable_full_quantity, $product_specs, $product_keywords, $company_scope, $social_credit_code, $suggested_price, $platform) {
-                $q->where([['min_price', '>=', '0.01'], ['number', '>=', '1']])->whereRaw('(min_price / NULLIF(number, 0)) < ' . floatval($suggested_price)); //计算单盒价格
-                if ($enable_full_quantity == 1) {
-                    $where[] = ['product_specs', 'like', '%' . $product_specs . '%']; //如果不是全量清洗,则查询规格,从商品规格中查找规格
-                }
-                $q->where($where);
-                if (!empty($product_keywords)) {
-                    $q->where(function ($query) use ($product_keywords) {
-                        // 平台条件(固定)
-                        $query->where(function ($query_li) use ($product_keywords) {
-                            foreach ($product_keywords as $product_keyword) {
-                                if (empty($product_keyword)) continue;
-                                $query_li->orWhere([['product_name', 'like', '%' . $product_keyword . '%']]);
-                            }
-                        });
-                    });
-                }
-                if ($company_scope == 2 && $social_credit_code != '') {
-                    $q->whereIn('qualification_number', $social_credit_code);
-                }
-                if ($platform != '0' && !empty($platform)) {
-                    $platform = explode(',', $platform);
-                    $q->whereIn('platform_id', $platform);
+    //-------------------------------------- 清洗规则(开始) --------------------------------------
+        //过滤没有链接数据
+        if (trim($product_data['link_url']) == '')  return true;
+        //数据是否命中低价
+        if ($product_data['number'] < 1 || $product_data['min_price'] < 0.01) return true;
+        //计算单盒价格
+        $unit_price = round($product_data['min_price'] / $product_data['number'], 2);
+        if ($unit_price > $suggested_price) return true;
+        //数据是否命中商品名称
+        $hit_product_name = false;
+        if (strpos($product_data['product_name'], $product_name) !== false) {
+            $hit_product_name = true;
+        }
+        if ($hit_product_name != true) return true;
+        //数据是否命中规格
+        $hit_product_specs = false;
+        if ($enable_full_quantity == 1 && $product_specs) {
+            //product_name 包含规格
+            if (strpos($product_data['product_name'], $product_specs) !== false) {
+                $hit_product_specs = true;
+            } else if (strpos($product_data['product_specs'], $product_specs) !== false) {
+                $hit_product_specs = true;
+            }
+        }
+        if ($hit_product_specs != true) return true;
+        //数据是否命中关键字
+        $hit_product_keywords = false;
+        if (!empty($product_keywords)) {
+            $product_keywords = explode(',', $product_keywords);
+            foreach ($product_keywords as $product_keyword) {
+                if (empty($product_keyword)) continue;
+                if (strpos($product_data['product_name'], $product_keyword) !== false) {
+                    $hit_product_keywords = true;
+                    break;
                 }
-            });
-        $product_data_info = $ScrapeDataModel->orderbyDesc('id')->paginate($limit, ['*',DB::raw('ROUND(min_price / NULLIF(number, 0), 2) as unit_price')], 'page', $page)->toarray();
-        $product_datas = $product_data_info['data'];
+            }
+        }
+        if ($hit_product_keywords != true) return true;
+        //数据是否命中指定公司
+        $hit_company_scope = false;
+        if ($company_scope == 2 && $social_credit_code != '') {
+            if ($product_data['qualification_number'] == $social_credit_code) {
+                $hit_company_scope = true;
+            }
+        }
+        if ($hit_company_scope != true) return true;
+        //数据是否命中平台
+        $hit_platform = false;
+        if ($platform != '0' && !empty($platform)) {
+            $platform = explode(',', $platform);
+            if (in_array($product_data['platform_id'], $platform)) {
+                $hit_platform = true;
+            }
+        }
+        if ($hit_platform != true) return true;
+        //-------------------------------------- 清洗规则(结束) --------------------------------------
 
-        if (empty($product_datas)) {
-            if ($executeLog_id && $item_now_page >= $item_totle_page) {
-                (new ExecuteLogModel())->where('id', $executeLog_id)->update(['status' => 0, 'update_time' => time()]);
+        //-------------------------------------- 处理营业执照地区信息(开始) --------------------------------------
+        $province_name = $product_data['province_name'];
+        $city_name = $product_data['city_name'];
+        //特殊地区1级移除市
+        if ($province_name && in_array($province_name, ['北京市', '天津市', '上海市', '重庆市'])) {
+            //移除市这个字符
+            $province_name = trim(str_replace('市', '', $province_name));
+        } else if ($province_name && in_array($province_name, ['北京', '天津', '上海', '重庆'])) {
+        } else if ($province_name && in_array($province_name, ['内蒙古', '广西', '西藏', '新疆', '宁夏'])) {
+            switch ($province_name) {
+                case '内蒙古':
+                    $province_name = '内蒙古自治区';
+                    break;
+                case '广西':
+                    $province_name = '广西壮族自治区';
+                    break;
+                case '西藏':
+                    $province_name = '西藏自治区';
+                    break;
+                case '新疆':
+                    $province_name = '新疆维吾尔自治区';
+                    break;
+                case '宁夏':
+                    $province_name = '宁夏回族自治区';
+                    break;
             }
-            return true;
+        } else if ($province_name && in_array($province_name, ['内蒙古自治区', '广西壮族自治区', '西藏自治区', '新疆维吾尔自治区', '宁夏回族自治区'])) {
+            //完整匹配不做处理
+        } else if (trim($province_name) != '' && strpos($province_name, '省') === false) {
+            //是否存在市省,如果不存在则补全
+            $province_name = $province_name . '省';
         }
-        foreach ($product_datas as $product_data) {
-            //-------------------------------------- 处理营业执照地区信息(开始) --------------------------------------
-            $province_name = $product_data['province_name'];
-            $city_name = $product_data['city_name'];
-            //特殊地区1级移除市
-            if ($province_name && in_array($province_name, ['北京市', '天津市', '上海市', '重庆市'])) {
-                //移除市这个字符
-                $province_name = trim(str_replace('市', '', $province_name));
-            } else if ($province_name && in_array($province_name, ['北京', '天津', '上海', '重庆'])) {
-            } else if ($province_name && in_array($province_name, ['内蒙古', '广西', '西藏', '新疆', '宁夏'])) {
-                switch ($province_name) {
-                    case '内蒙古':
-                        $province_name = '内蒙古自治区';
-                        break;
-                    case '广西':
-                        $province_name = '广西壮族自治区';
-                        break;
-                    case '西藏':
-                        $province_name = '西藏自治区';
-                        break;
-                    case '新疆':
-                        $province_name = '新疆维吾尔自治区';
-                        break;
-                    case '宁夏':
-                        $province_name = '宁夏回族自治区';
-                        break;
+        if (trim($province_name) != '') {
+            //根据最新处理后的省份名称获取省份ID
+            $db_province_id = $CitysModel->where([['name', '=', $province_name], ['level', '=', '1']])->value('id');
+            if (!empty($db_province_id)) {
+                $product_data['province_id'] = $db_province_id;
+            } else {
+                //逆推省份ID失败,则修改为未知名称
+                $province_name = '未知';
+            }
+        } else {
+            //尝试从地区详情里面匹配省份名称
+            $db_province_data_list = $CitysModel->where([['level', '=', '1']])->select(['id', 'name'])->get()->toarray();
+            foreach ($db_province_data_list as $db_province_data) {
+                $db_province_name = $db_province_data['name'];
+                if (strpos($product_data['area_info'], $db_province_name) !== false) {
+                    $province_name = $db_province_name;
+                    $product_data['province_id'] = $db_province_data['id'];
+                    break;
                 }
-            } else if ($province_name && in_array($province_name, ['内蒙古自治区', '广西壮族自治区', '西藏自治区', '新疆维吾尔自治区', '宁夏回族自治区'])) {
-                //完整匹配不做处理
-            } else if (trim($province_name) != '' && strpos($province_name, '省') === false) {
-                //是否存在市省,如果不存在则补全
-                $province_name = $province_name . '省';
             }
-            if (trim($province_name) != '') {
-                //根据最新处理后的省份名称获取省份ID
-                $db_province_id = $CitysModel->where([['name', '=', $province_name], ['level', '=', '1']])->value('id');
-                if (!empty($db_province_id)) {
-                    $product_data['province_id'] = $db_province_id;
+        }
+        if (trim($city_name) != '') {
+            //校验是否存在县这个字眼
+            if (strpos($city_name, '县') !== false) {
+                $db_city_id = $CitysModel->where([['name', '=', $city_name], ['level', '=', '2']])->value('id');
+                if (!empty($db_city_id)) {
+                    $product_data['city_id'] = $db_city_id;
+                }
+            } elseif (trim($city_name) != '' && strpos($city_name, '市') === false) {
+                //是否存在市
+                $city_name = $city_name . '市';
+                //根据最新处理后的市名称获取市ID
+                $db_city_id = $CitysModel->where([['name', '=', $city_name], ['level', '=', '2']])->value('id');
+                if (!empty($db_city_id)) {
+                    $product_data['city_id'] = $db_city_id;
                 } else {
-                    //逆推省份ID失败,则修改为未知名称
-                    $province_name = '未知';
+                    $city_name = '未知';
                 }
             } else {
-                //尝试从地区详情里面匹配省份名称
-                $db_province_data_list = $CitysModel->where([['level', '=', '1']])->select(['id', 'name'])->get()->toarray();
-                foreach ($db_province_data_list as $db_province_data) {
-                    $db_province_name = $db_province_data['name'];
-                    if (strpos($product_data['area_info'], $db_province_name) !== false) {
-                        $province_name = $db_province_name;
-                        $product_data['province_id'] = $db_province_data['id'];
-                        break;
-                    }
+                $db_city_id = $CitysModel->where([['name', '=', $city_name], ['level', '=', '2']])->value('id');
+                if (!empty($db_city_id)) {
+                    $product_data['city_id'] = $db_city_id;
+                } else {
+                    $city_name = '未知';
                 }
             }
-            if (trim($city_name) != '') {
-                //校验是否存在县这个字眼
-                if (strpos($city_name, '县') !== false) {
-                    $db_city_id = $CitysModel->where([['name', '=', $city_name], ['level', '=', '2']])->value('id');
-                    if (!empty($db_city_id)) {
-                        $product_data['city_id'] = $db_city_id;
-                    }
-                } elseif (trim($city_name) != '' && strpos($city_name, '市') === false) {
-                    //是否存在市
-                    $city_name = $city_name . '市';
-                    //根据最新处理后的市名称获取市ID
-                    $db_city_id = $CitysModel->where([['name', '=', $city_name], ['level', '=', '2']])->value('id');
-                    if (!empty($db_city_id)) {
+        } else {
+            if (trim($product_data['area_info']) != '') {
+                //尝试从地区详情里面匹配市名称
+                $db_city_name_list = $CitysModel->where([['level', '=', '2']])->pluck('name')->toarray();
+                foreach ($db_city_name_list as $db_city_name) {
+                    if (strpos($product_data['area_info'], $db_city_name) !== false) {
+                        $db_city_id = $CitysModel->where([['name', '=', $db_city_name], ['level', '=', '2']])->value('id');
                         $product_data['city_id'] = $db_city_id;
-                    } else {
-                        $city_name = '未知';
-                    }
-                } else {
-                    $db_city_id = $CitysModel->where([['name', '=', $city_name], ['level', '=', '2']])->value('id');
-                    if (!empty($db_city_id)) {
-                        $product_data['city_id'] = $db_city_id;
-                    } else {
-                        $city_name = '未知';
-                    }
-                }
-            } else {
-                if (trim($product_data['area_info']) != '') {
-                    //尝试从地区详情里面匹配市名称
-                    $db_city_name_list = $CitysModel->where([['level', '=', '2']])->pluck('name')->toarray();
-                    foreach ($db_city_name_list as $db_city_name) {
-                        if (strpos($product_data['area_info'], $db_city_name) !== false) {
-                            $db_city_id = $CitysModel->where([['name', '=', $db_city_name], ['level', '=', '2']])->value('id');
-                            $product_data['city_id'] = $db_city_id;
-                            $product_data['city_name'] = $db_city_name;
-                            $city_name = $db_city_name;
-                            break;
-                        }
+                        $product_data['city_name'] = $db_city_name;
+                        $city_name = $db_city_name;
+                        break;
                     }
                 }
             }
-            //如果存在市区city_id 则逆推省份ID以及名称
-            if (!empty($product_data['city_id']) && empty($product_data['province_id'])) {
-                $db_province_id = $CitysModel->where([['id', '=', $product_data['city_id']], ['level', '=', '2']])->value('pid');
-                $db_province_name = $CitysModel->where([['id', '=', $db_province_id], ['level', '=', '1']])->value('name');
-                $product_data['province_id'] = $db_province_id;
-                $product_data['province_name'] = $db_province_name;
-                $province_name = $db_province_name;
+        }
+        //如果存在市区city_id 则逆推省份ID以及名称
+        if (!empty($product_data['city_id']) && empty($product_data['province_id'])) {
+            $db_province_id = $CitysModel->where([['id', '=', $product_data['city_id']], ['level', '=', '2']])->value('pid');
+            $db_province_name = $CitysModel->where([['id', '=', $db_province_id], ['level', '=', '1']])->value('name');
+            $product_data['province_id'] = $db_province_id;
+            $product_data['province_name'] = $db_province_name;
+            $province_name = $db_province_name;
+        }
+        if (trim($product_data['area_info']) == '' && trim($city_name) != '' && trim($province_name) != '') {
+            $product_data['area_info'] = $province_name . $city_name;
+        }
+        //-------------------------------------- 处理营业执照地区信息(结束) --------------------------------------
+
+        //-------------------------------------- 处理发货省份地区信息(开始) --------------------------------------
+        $shipment_province_name = $product_data['shipment_province_name'];
+        $shipment_city_name = $product_data['shipment_city_name'];
+        //特殊地区1级移除市
+        if ($shipment_province_name && in_array($shipment_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;
             }
-            if (trim($product_data['area_info']) == '' && trim($city_name) != '' && trim($province_name) != '') {
-                $product_data['area_info'] = $province_name . $city_name;
+        } else if ($shipment_province_name && in_array($shipment_province_name, ['内蒙古自治区', '广西壮族自治区', '西藏自治区', '新疆维吾尔自治区', '宁夏回族自治区'])) {
+            //完整匹配不做处理
+        } else if (trim($shipment_province_name) != '' && strpos($shipment_province_name, '省') === false) {
+            //是否存在市省,如果不存在则补全
+            $shipment_province_name = $shipment_province_name . '省';
+        }
+        if (trim($shipment_province_name) != '') {
+            //根据最新处理后的省份名称获取省份ID
+            $db_shipment_province_id = $CitysModel->where([['name', '=', $shipment_province_name], ['level', '=', '1']])->value('id');
+            if (!empty($db_shipment_province_id)) {
+                $product_data['shipment_province_id'] = $db_shipment_province_id;
+            } else {
+                //逆推省份ID失败,则修改为未知名称
+                $shipment_province_name = '未知';
             }
-            //-------------------------------------- 处理营业执照地区信息(结束) --------------------------------------
-
-            //-------------------------------------- 处理发货省份地区信息(开始) --------------------------------------
-            $shipment_province_name = $product_data['shipment_province_name'];
-            $shipment_city_name = $product_data['shipment_city_name'];
-            //特殊地区1级移除市
-            if ($shipment_province_name && in_array($shipment_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;
+        }
+        if (trim($shipment_city_name) != '') {
+            //校验是否存在县这个字眼
+            if (strpos($shipment_city_name, '县') !== false) {
+                $db_shipment_city_id = $CitysModel->where([['name', '=', $shipment_city_name], ['level', '=', '2']])->value('id');
+                if (!empty($db_shipment_city_id)) {
+                    $product_data['shipment_city_id'] = $db_shipment_city_id;
                 }
-            } else if ($shipment_province_name && in_array($shipment_province_name, ['内蒙古自治区', '广西壮族自治区', '西藏自治区', '新疆维吾尔自治区', '宁夏回族自治区'])) {
-                //完整匹配不做处理
-            } else if (trim($shipment_province_name) != '' && strpos($shipment_province_name, '省') === false) {
-                //是否存在市省,如果不存在则补全
-                $shipment_province_name = $shipment_province_name . '省';
-            }
-            if (trim($shipment_province_name) != '') {
-                //根据最新处理后的省份名称获取省份ID
-                $db_shipment_province_id = $CitysModel->where([['name', '=', $shipment_province_name], ['level', '=', '1']])->value('id');
-                if (!empty($db_shipment_province_id)) {
-                    $product_data['shipment_province_id'] = $db_shipment_province_id;
+            } elseif (trim($shipment_city_name) != '' && strpos($shipment_city_name, '市') === false) {
+                //是否存在市
+                $shipment_city_name = $shipment_city_name . '市';
+                //根据最新处理后的市名称获取市ID
+                $db_shipment_city_id = $CitysModel->where([['name', '=', $shipment_city_name], ['level', '=', '2']])->value('id');
+                if (!empty($db_shipment_city_id)) {
+                    $product_data['shipment_city_id'] = $db_shipment_city_id;
                 } else {
-                    //逆推省份ID失败,则修改为未知名称
-                    $shipment_province_name = '未知';
+                    //逆推市ID失败,则修改为未知名称
+                    $shipment_city_name = '未知';
                 }
-            }
-            if (trim($shipment_city_name) != '') {
-                //校验是否存在县这个字眼
-                if (strpos($shipment_city_name, '县') !== false) {
-                    $db_shipment_city_id = $CitysModel->where([['name', '=', $shipment_city_name], ['level', '=', '2']])->value('id');
-                    if (!empty($db_shipment_city_id)) {
-                        $product_data['shipment_city_id'] = $db_shipment_city_id;
-                    }
-                } elseif (trim($shipment_city_name) != '' && strpos($shipment_city_name, '市') === false) {
-                    //是否存在市
-                    $shipment_city_name = $shipment_city_name . '市';
-                    //根据最新处理后的市名称获取市ID
-                    $db_shipment_city_id = $CitysModel->where([['name', '=', $shipment_city_name], ['level', '=', '2']])->value('id');
-                    if (!empty($db_shipment_city_id)) {
-                        $product_data['shipment_city_id'] = $db_shipment_city_id;
-                    } else {
-                        //逆推市ID失败,则修改为未知名称
-                        $shipment_city_name = '未知';
-                    }
+            } else {
+                $db_shipment_city_id = $CitysModel->where([['name', '=', $shipment_city_name], ['level', '=', '2']])->value('id');
+                if (!empty($db_shipment_city_id)) {
+                    $product_data['shipment_city_id'] = $db_shipment_city_id;
                 } else {
-                    $db_shipment_city_id = $CitysModel->where([['name', '=', $shipment_city_name], ['level', '=', '2']])->value('id');
-                    if (!empty($db_shipment_city_id)) {
-                        $product_data['shipment_city_id'] = $db_shipment_city_id;
-                    } else {
-                        //逆推市ID失败,则修改为未知名称
-                        $shipment_city_name = '未知';
-                    }
+                    //逆推市ID失败,则修改为未知名称
+                    $shipment_city_name = '未知';
                 }
             }
-            //如果存在市区shipment_city_id 则逆推省份ID以及名称
-            if (!empty($product_data['shipment_city_id']) && empty($product_data['shipment_province_id'])) {
-                $db_shipment_province_id = $CitysModel->where([['id', '=', $product_data['shipment_city_id']], ['level', '=', '2']])->value('pid');
-                $db_shipment_province_name = $CitysModel->where([['id', '=', $db_shipment_province_id], ['level', '=', '1']])->value('name');
-                $product_data['shipment_province_id'] = $db_shipment_province_id;
-                $product_data['shipment_province_name'] = $db_shipment_province_name;
-            }
-            //-------------------------------------- 处理发货省份地区信息(结束) --------------------------------------
-            //处理链接信息
-            preg_match('/https?:\/\/[^\s\'"<>]+/i', $product_data['link_url'], $matches);
-            if (!empty($matches)) {
-                $product_data['link_url'] = $matches[0];
-            }
-            if (trim($product_data['link_url']) == '') continue;
-            $is_ultra_low_price = 0; //是否超低价0=否1=是
-            if ($ultra_low_price > 0 && $product_data['online_posting_count'] < $ultra_low_price) {
-                $is_ultra_low_price = 1;
-            }
-            //合并省份市区ID
-            $merge_city_id = 0;
-            $merge_province_id = 0;
-            $merge_city_name = '';
-            $merge_province_name = '';
-            if (!empty($product_data['city_id']) && !empty($product_data['province_id'])) {
-                $merge_city_id = $product_data['city_id'];
-                $merge_province_id = $product_data['province_id'];
-                $merge_city_name = $city_name;
-                $merge_province_name = $province_name;
-            } else if (!empty($product_data['shipment_city_id']) && !empty($product_data['shipment_province_id'])) {
-                $merge_city_id = $product_data['shipment_city_id'];
-                $merge_province_id = $product_data['shipment_province_id'];
-                $merge_city_name = $shipment_city_name;
-                $merge_province_name = $shipment_province_name;
-            }
-            $insert_product_data = [
-                'company_id' => $company_id,
-                'source_id' => $product_data['id'],
-                'platform'    => $product_data['platform_id'],
-                'company_name'    => $product_data['company_name'],
-                'social_credit_code' => $product_data['qualification_number'],
-                'product_brand'    => $product_brand != '' ? $product_brand : $product_data['product_brand'],
-                'product_name'    => $product_name,
-                'product_specs'    => $product_specs,
-                'inventory'    => $product_data['inventory'] ? $product_data['inventory'] : '',
-                'sales'    => $product_data['sales'] ? $product_data['sales'] : '',
-                'snapshot_url' => $product_data['snapshot_url'] ? $product_data['snapshot_url'] : '',
-                'suggested_price'    => $suggested_price,
-                'ultra_low_price'  => $ultra_low_price,
-                'is_ultra_low_price' => $is_ultra_low_price,
-                'online_posting_price'    => $product_data['unit_price'],
-                'online_posting_count'    => $product_data['online_posting_count'],
-                'continuous_listing_count'    => $product_data['continuous_listing_count'],
-                'link_url'    => $product_data['link_url'],
-                'store_name'    => $product_data['store_name'],
-                'anonymous_store_name'    => $product_data['anonymous_store_name'],
-                'province_id' => $product_data['province_id'],
-                'province_name' => $province_name,
-                'city_id' => $product_data['city_id'],
-                'city_name' => $city_name,
-                'area_info' => $product_data['area_info'],
-                'category_name' => $category_name,
-                'company_category_name' => '',
-                'first_responsible_person' => '',
-                'responsible_person' => '',
-                'source_responsible_person' => '',
-                'scrape_date' => $product_data['scrape_date'],
-                'collection_time' => strtotime($product_data['insert_time']),
-                'shipment_province_id' => $product_data['shipment_province_id'],
-                'shipment_province_name' => $product_data['shipment_province_name'],
-                'shipment_city_id' => $product_data['shipment_city_id'],
-                'shipment_city_name' => $product_data['shipment_city_name'],
-                'collect_config_info' => $product_data['collect_config_info'],
-                'merge_city_id' => $merge_city_id,
-                'merge_province_id' => $merge_province_id,
-                'merge_city_name' => $merge_city_name,
-                'merge_province_name' => $merge_province_name,
-            ];
+        }
+        //如果存在市区shipment_city_id 则逆推省份ID以及名称
+        if (!empty($product_data['shipment_city_id']) && empty($product_data['shipment_province_id'])) {
+            $db_shipment_province_id = $CitysModel->where([['id', '=', $product_data['shipment_city_id']], ['level', '=', '2']])->value('pid');
+            $db_shipment_province_name = $CitysModel->where([['id', '=', $db_shipment_province_id], ['level', '=', '1']])->value('name');
+            $product_data['shipment_province_id'] = $db_shipment_province_id;
+            $product_data['shipment_province_name'] = $db_shipment_province_name;
+        }
+        //-------------------------------------- 处理发货省份地区信息(结束) --------------------------------------
+        //处理链接信息
+        preg_match('/https?:\/\/[^\s\'"<>]+/i', $product_data['link_url'], $matches);
+        if (!empty($matches)) {
+            $product_data['link_url'] = $matches[0];
+        }
 
-            //获取指定人员信息
-            if ($specify_responsible_person == 0) {
-                //获取店铺责任人信息
-                $ViolationStoreModel = new ViolationStoreModel();
-                $store_data_info = $ViolationStoreModel->where('store_name', $product_data['store_name'])->first();
-                if (!empty($store_data_info) && trim($store_data_info->employee_ids) != '') {
-                    //查询店铺第一责任人信息
-                    $EmployeeModel = new EmployeeModel();
-                    $store_where_query = [];
-                    $employee_id_store = explode(',', $store_data_info->employee_ids);
-                    $store_where_query[] = ['company_id', '=', $company_id];
-                    $store_where_query[] = ['id', 'in', $employee_id_store];
-                    $store_where_query[] = ['status', '=', 0];
-                    $store_where_query[] = ['duty_type', '=', 1]; //责任类型1=第一责任人,2=责任人
-                    $first_responsible_person = $EmployeeModel->pluck('id')->implode(',');
-                    $insert_product_data['first_responsible_person'] = $first_responsible_person;
-                    //查询店铺责任人信息
-                    $EmployeeModel = new EmployeeModel();
-                    $store_where_query = [];
-                    $employee_id_store = explode(',', $store_data_info->employee_ids);
-                    $store_where_query[] = ['company_id', '=', $company_id];
-                    $store_where_query[] = ['id', 'in', $employee_id_store];
-                    $store_where_query[] = ['status', '=', 0];
-                    $store_where_query[] = ['duty_type', '=', 2]; //责任类型1=第一责任人,2=责任人
-                    $responsible_person = $EmployeeModel->pluck('id')->implode(',');
-                    $insert_product_data['responsible_person'] = $responsible_person;
-                    //溯源责任人
-                    $source_responsible_person = '';
-                    if ($first_responsible_person && $responsible_person) {
-                        //转换成数组,合并后在去重
-                        $first_responsible_person = explode(',', $first_responsible_person);
-                        $responsible_person = explode(',', $responsible_person);
-                        $source_responsible_person = array_unique(array_merge($first_responsible_person, $responsible_person));
-                        $source_responsible_person = ',' . implode(',', $source_responsible_person) . ',';
-                    } else if ($first_responsible_person) {
-                        $source_responsible_person = $first_responsible_person;
-                    } else if ($responsible_person) {
-                        $source_responsible_person = $responsible_person;
-                    }
-                    $insert_product_data['source_responsible_person'] = $source_responsible_person;
-                } else {
-                    //获取公司绑定责任人信息
-                    $company_data = $ViolationCompanyModel->leftjoin('washconfig_company_category', 'washconfig_company_category.id', '=', 'washconfig_violation_company.category_id')
-                        ->where('washconfig_violation_company.social_credit_code', $product_data['qualification_number'])
-                        ->where('washconfig_violation_company.company_id', $company_id)
-                        ->select(['washconfig_violation_company.id', 'washconfig_company_category.name as category_name'])->first();
-                    $employee_id_list = [];
-                    if ($company_data) {
-                        $employee_id_list = $ViolationCompanyMemberModel->where('company_logid', $company_data->id)->pluck('employee_id')->toarray();
-                        $insert_product_data['company_category_name'] = $company_data->category_name ? $company_data->category_name : '';
-                    }
-                    $where_query1 = [];
-                    $where_query2 = [];
-                    $where_query3 = [];
-                    //查询指定公司第一责任人
-                    if (!empty($employee_id_list)) {
-                        $where_query1[] = ['company_id', '=', $company_id];
-                        $where_query1[] = ['id', 'in', $employee_id_list];
-                        $where_query1[] = ['status', '=', 0];
-                        $where_query1[] = ['duty_type', '=', 1]; //责任类型1=第一责任人,2=责任人
-                    }
-                    //查询地区配置的第一责任人
-                    $employee_id_area = $EmployeeAreaModel->where('city_id', $product_data['city_id'])->pluck('employee_id')->toarray();
-                    if (!empty($employee_id_area)) {
-                        $where_query2[] = ['company_id', '=', $company_id];
-                        $where_query2[] = ['id', 'in', $employee_id_area];
-                        $where_query2[] = ['status', '=', 0];
-                        $where_query2[] = ['duty_type', '=', 1]; //责任类型1=第一责任人,2=责任人
-                    }
-                    //查询平台配置的第一责任人
-                    $employee_id_platform = $EmployeePlatformModel->where('platform_id', $product_data['platform_id'])->pluck('employee_id')->toarray();
-                    if (!empty($employee_id_platform)) {
-                        $where_query3[] = ['company_id', '=', $company_id];
-                        $where_query3[] = ['id', 'in', $employee_id_platform];
-                        $where_query3[] = ['status', '=', 0];
-                        $where_query3[] = ['duty_type', '=', 1]; //责任类型1=第一责任人,2=责任人
-                    }
-                    //并行查询第一责任人
-                    $EmployeeModel = new EmployeeModel();
-                    $EmployeeModel = $EmployeeModel
-                        ->orWhere(function ($q) use ($employee_id_list, $company_id) {
-                            if (!empty($employee_id_list)) {
-                                $q->where('company_id', $company_id)
-                                    ->orWhereIn('id', $employee_id_list)
-                                    ->where('duty_type', 1)
-                                    ->where('status', 0);
-                            }
-                        })->orWhere(function ($q) use ($employee_id_area, $company_id) {
-                            if (!empty($employee_id_area)) {
-                                $q->where('company_id', $company_id)
-                                    ->whereIn('id', $employee_id_area)
-                                    ->where('duty_type', 1)
-                                    ->where('status', 0);
-                            }
-                        })->orWhere(function ($q) use ($employee_id_platform, $company_id) {
-                            if (!empty($employee_id_platform)) {
-                                $q->where('company_id', $company_id)
-                                    ->whereIn('id', $employee_id_platform)
-                                    ->where('duty_type', 1)
-                                    ->where('status', 0);
-                            }
-                        });
-                    $first_responsible_person = $EmployeeModel->pluck('id')->implode(',');
+        $is_ultra_low_price = 0; //是否超低价0=否1=是
+        if ($ultra_low_price > 0 && $product_data['online_posting_count'] < $ultra_low_price) {
+            $is_ultra_low_price = 1;
+        }
+        //合并省份市区ID
+        $merge_city_id = 0;
+        $merge_province_id = 0;
+        $merge_city_name = '';
+        $merge_province_name = '';
+        if (!empty($product_data['city_id']) && !empty($product_data['province_id'])) {
+            $merge_city_id = $product_data['city_id'];
+            $merge_province_id = $product_data['province_id'];
+            $merge_city_name = $city_name;
+            $merge_province_name = $province_name;
+        } else if (!empty($product_data['shipment_city_id']) && !empty($product_data['shipment_province_id'])) {
+            $merge_city_id = $product_data['shipment_city_id'];
+            $merge_province_id = $product_data['shipment_province_id'];
+            $merge_city_name = $shipment_city_name;
+            $merge_province_name = $shipment_province_name;
+        }
+        $insert_product_data = [
+            'company_id' => $company_id,
+            'source_id' => $product_data['id'],
+            'platform'    => $product_data['platform_id'],
+            'company_name'    => $product_data['company_name'],
+            'social_credit_code' => $product_data['qualification_number'],
+            'product_brand'    => $product_brand != '' ? $product_brand : $product_data['product_brand'],
+            'product_name'    => $product_name,
+            'product_specs'    => $product_specs,
+            'inventory'    => $product_data['inventory'] ? $product_data['inventory'] : '',
+            'sales'    => $product_data['sales'] ? $product_data['sales'] : '',
+            'snapshot_url' => $product_data['snapshot_url'] ? $product_data['snapshot_url'] : '',
+            'suggested_price'    => $suggested_price,
+            'ultra_low_price'  => $ultra_low_price,
+            'is_ultra_low_price' => $is_ultra_low_price,
+            'online_posting_price'    => $product_data['unit_price'],
+            'online_posting_count'    => $product_data['online_posting_count'],
+            'continuous_listing_count'    => $product_data['continuous_listing_count'],
+            'link_url'    => $product_data['link_url'],
+            'store_name'    => $product_data['store_name'],
+            'anonymous_store_name'    => $product_data['anonymous_store_name'],
+            'province_id' => $product_data['province_id'],
+            'province_name' => $province_name,
+            'city_id' => $product_data['city_id'],
+            'city_name' => $city_name,
+            'area_info' => $product_data['area_info'],
+            'category_name' => $category_name,
+            'company_category_name' => '',
+            'first_responsible_person' => '',
+            'responsible_person' => '',
+            'source_responsible_person' => '',
+            'scrape_date' => $product_data['scrape_date'],
+            'collection_time' => strtotime($product_data['insert_time']),
+            'shipment_province_id' => $product_data['shipment_province_id'],
+            'shipment_province_name' => $product_data['shipment_province_name'],
+            'shipment_city_id' => $product_data['shipment_city_id'],
+            'shipment_city_name' => $product_data['shipment_city_name'],
+            'collect_config_info' => $product_data['collect_config_info'],
+            'merge_city_id' => $merge_city_id,
+            'merge_province_id' => $merge_province_id,
+            'merge_city_name' => $merge_city_name,
+            'merge_province_name' => $merge_province_name,
+        ];
 
-                    //当以上规则匹配不到责任人时,则去查询发货地区信息关联责任人
-                    if (trim($first_responsible_person) == '' && trim($product_data['shipment_city_id']) != '') {
-                        $employee_id_area = $EmployeeAreaModel->where('city_id', $product_data['city_id'])->pluck('employee_id')->toarray();
+        //获取指定人员信息
+        if ($specify_responsible_person == 0) {
+            //获取店铺责任人信息
+            $ViolationStoreModel = new ViolationStoreModel();
+            $store_data_info = $ViolationStoreModel->where('store_name', $product_data['store_name'])->first();
+            if (!empty($store_data_info) && trim($store_data_info->employee_ids) != '') {
+                //查询店铺第一责任人信息
+                $EmployeeModel = new EmployeeModel();
+                $store_where_query = [];
+                $employee_id_store = explode(',', $store_data_info->employee_ids);
+                $store_where_query[] = ['company_id', '=', $company_id];
+                $store_where_query[] = ['id', 'in', $employee_id_store];
+                $store_where_query[] = ['status', '=', 0];
+                $store_where_query[] = ['duty_type', '=', 1]; //责任类型1=第一责任人,2=责任人
+                $first_responsible_person = $EmployeeModel->pluck('id')->implode(',');
+                $insert_product_data['first_responsible_person'] = $first_responsible_person;
+                //查询店铺责任人信息
+                $EmployeeModel = new EmployeeModel();
+                $store_where_query = [];
+                $employee_id_store = explode(',', $store_data_info->employee_ids);
+                $store_where_query[] = ['company_id', '=', $company_id];
+                $store_where_query[] = ['id', 'in', $employee_id_store];
+                $store_where_query[] = ['status', '=', 0];
+                $store_where_query[] = ['duty_type', '=', 2]; //责任类型1=第一责任人,2=责任人
+                $responsible_person = $EmployeeModel->pluck('id')->implode(',');
+                $insert_product_data['responsible_person'] = $responsible_person;
+                //溯源责任人
+                $source_responsible_person = '';
+                if ($first_responsible_person && $responsible_person) {
+                    //转换成数组,合并后在去重
+                    $first_responsible_person = explode(',', $first_responsible_person);
+                    $responsible_person = explode(',', $responsible_person);
+                    $source_responsible_person = array_unique(array_merge($first_responsible_person, $responsible_person));
+                    $source_responsible_person = ',' . implode(',', $source_responsible_person) . ',';
+                } else if ($first_responsible_person) {
+                    $source_responsible_person = $first_responsible_person;
+                } else if ($responsible_person) {
+                    $source_responsible_person = $responsible_person;
+                }
+                $insert_product_data['source_responsible_person'] = $source_responsible_person;
+            } else {
+                //获取公司绑定责任人信息
+                $company_data = $ViolationCompanyModel->leftjoin('washconfig_company_category', 'washconfig_company_category.id', '=', 'washconfig_violation_company.category_id')
+                    ->where('washconfig_violation_company.social_credit_code', $product_data['qualification_number'])
+                    ->where('washconfig_violation_company.company_id', $company_id)
+                    ->select(['washconfig_violation_company.id', 'washconfig_company_category.name as category_name'])->first();
+                $employee_id_list = [];
+                if ($company_data) {
+                    $employee_id_list = $ViolationCompanyMemberModel->where('company_logid', $company_data->id)->pluck('employee_id')->toarray();
+                    $insert_product_data['company_category_name'] = $company_data->category_name ? $company_data->category_name : '';
+                }
+                $where_query1 = [];
+                $where_query2 = [];
+                $where_query3 = [];
+                //查询指定公司第一责任人
+                if (!empty($employee_id_list)) {
+                    $where_query1[] = ['company_id', '=', $company_id];
+                    $where_query1[] = ['id', 'in', $employee_id_list];
+                    $where_query1[] = ['status', '=', 0];
+                    $where_query1[] = ['duty_type', '=', 1]; //责任类型1=第一责任人,2=责任人
+                }
+                //查询地区配置的第一责任人
+                $employee_id_area = $EmployeeAreaModel->where('city_id', $product_data['city_id'])->pluck('employee_id')->toarray();
+                if (!empty($employee_id_area)) {
+                    $where_query2[] = ['company_id', '=', $company_id];
+                    $where_query2[] = ['id', 'in', $employee_id_area];
+                    $where_query2[] = ['status', '=', 0];
+                    $where_query2[] = ['duty_type', '=', 1]; //责任类型1=第一责任人,2=责任人
+                }
+                //查询平台配置的第一责任人
+                $employee_id_platform = $EmployeePlatformModel->where('platform_id', $product_data['platform_id'])->pluck('employee_id')->toarray();
+                if (!empty($employee_id_platform)) {
+                    $where_query3[] = ['company_id', '=', $company_id];
+                    $where_query3[] = ['id', 'in', $employee_id_platform];
+                    $where_query3[] = ['status', '=', 0];
+                    $where_query3[] = ['duty_type', '=', 1]; //责任类型1=第一责任人,2=责任人
+                }
+                //并行查询第一责任人
+                $EmployeeModel = new EmployeeModel();
+                $EmployeeModel = $EmployeeModel
+                    ->orWhere(function ($q) use ($employee_id_list, $company_id) {
+                        if (!empty($employee_id_list)) {
+                            $q->where('company_id', $company_id)
+                                ->orWhereIn('id', $employee_id_list)
+                                ->where('duty_type', 1)
+                                ->where('status', 0);
+                        }
+                    })->orWhere(function ($q) use ($employee_id_area, $company_id) {
                         if (!empty($employee_id_area)) {
-                            $where_city[] = ['company_id', '=', $company_id];
-                            $where_city[] = ['id', 'in', $employee_id_area];
-                            $where_city[] = ['status', '=', 0];
-                            $where_city[] = ['duty_type', '=', 1]; //责任类型1=第一责任人,2=责任人
-                            $EmployeeModel = new EmployeeModel();
-                            $first_responsible_person = $EmployeeModel->where($where_city)->pluck('id')->implode(',');
+                            $q->where('company_id', $company_id)
+                                ->whereIn('id', $employee_id_area)
+                                ->where('duty_type', 1)
+                                ->where('status', 0);
                         }
-                    }
+                    })->orWhere(function ($q) use ($employee_id_platform, $company_id) {
+                        if (!empty($employee_id_platform)) {
+                            $q->where('company_id', $company_id)
+                                ->whereIn('id', $employee_id_platform)
+                                ->where('duty_type', 1)
+                                ->where('status', 0);
+                        }
+                    });
+                $first_responsible_person = $EmployeeModel->pluck('id')->implode(',');
 
-                    //调试记录查询条件
-                    $insert_product_data['first_responsible_person'] = $first_responsible_person;
-                    //查询责任人
-                    $where_query1 = [];
-                    $where_query2 = [];
-                    $where_query3 = [];
-                    //查询指定公司责任人
-                    if (!empty($employee_id_list)) {
-                        $where_query1[] = ['company_id', '=', $company_id];
-                        $where_query1[] = ['id', 'in', $employee_id_list];
-                        $where_query1[] = ['status', '=', 0];
-                        $where_query1[] = ['duty_type', '=', 2]; //责任类型1=第一责任人,2=责任人
-                    }
-                    //查询地区配置的员工
+                //当以上规则匹配不到责任人时,则去查询发货地区信息关联责任人
+                if (trim($first_responsible_person) == '' && trim($product_data['shipment_city_id']) != '') {
                     $employee_id_area = $EmployeeAreaModel->where('city_id', $product_data['city_id'])->pluck('employee_id')->toarray();
                     if (!empty($employee_id_area)) {
-                        $where_query2[] = ['company_id', '=', $company_id];
-                        $where_query2[] = ['id', 'in', $employee_id_area];
-                        $where_query2[] = ['status', '=', 0];
-                        $where_query2[] = ['duty_type', '=', 2]; //责任类型1=第一责任人,2=责任人
-                    }
-                    //查询平台配置的员工
-                    $employee_id_platform = $EmployeePlatformModel->where('platform_id', $product_data['platform_id'])->pluck('employee_id')->toarray();
-                    if (!empty($employee_id_platform)) {
-                        $where_query3[] = ['company_id', '=', $company_id];
-                        $where_query3[] = ['id', 'in', $employee_id_platform];
-                        $where_query3[] = ['status', '=', 0];
-                        $where_query3[] = ['duty_type', '=', 2]; //责任类型1=第一责任人,2=责任人
+                        $where_city[] = ['company_id', '=', $company_id];
+                        $where_city[] = ['id', 'in', $employee_id_area];
+                        $where_city[] = ['status', '=', 0];
+                        $where_city[] = ['duty_type', '=', 1]; //责任类型1=第一责任人,2=责任人
+                        $EmployeeModel = new EmployeeModel();
+                        $first_responsible_person = $EmployeeModel->where($where_city)->pluck('id')->implode(',');
                     }
-                    //并行查询责任人
-                    $EmployeeModel = new EmployeeModel();
-                    $EmployeeModel = $EmployeeModel
-                        ->orWhere(function ($q) use ($employee_id_list, $company_id) {
-                            if (!empty($employee_id_list)) {
-                                $q->where('company_id', $company_id)
-                                    ->orWhereIn('id', $employee_id_list)
-                                    ->where('duty_type', 2)
-                                    ->where('status', 0);
-                            }
-                        })->orWhere(function ($q) use ($employee_id_area, $company_id) {
-                            if (!empty($employee_id_area)) {
-                                $q->where('company_id', $company_id)
-                                    ->whereIn('id', $employee_id_area)
-                                    ->where('duty_type', 2)
-                                    ->where('status', 0);
-                            }
-                        })->orWhere(function ($q) use ($employee_id_platform, $company_id) {
-                            if (!empty($employee_id_platform)) {
-                                $q->where('company_id', $company_id)
-                                    ->whereIn('id', $employee_id_platform)
-                                    ->where('duty_type', 2)
-                                    ->where('status', 0);
-                            }
-                        });
-                    $responsible_person = $EmployeeModel->pluck('id')->implode(',');
+                }
 
-                    //当以上规则匹配不到责任人时,则去查询发货地区信息关联责任人
-                    if (trim($responsible_person) == '' && trim($product_data['shipment_city_id']) != '') {
-                        $employee_id_area = $EmployeeAreaModel->where('city_id', $product_data['city_id'])->pluck('employee_id')->toarray();
+                //调试记录查询条件
+                $insert_product_data['first_responsible_person'] = $first_responsible_person;
+                //查询责任人
+                $where_query1 = [];
+                $where_query2 = [];
+                $where_query3 = [];
+                //查询指定公司责任人
+                if (!empty($employee_id_list)) {
+                    $where_query1[] = ['company_id', '=', $company_id];
+                    $where_query1[] = ['id', 'in', $employee_id_list];
+                    $where_query1[] = ['status', '=', 0];
+                    $where_query1[] = ['duty_type', '=', 2]; //责任类型1=第一责任人,2=责任人
+                }
+                //查询地区配置的员工
+                $employee_id_area = $EmployeeAreaModel->where('city_id', $product_data['city_id'])->pluck('employee_id')->toarray();
+                if (!empty($employee_id_area)) {
+                    $where_query2[] = ['company_id', '=', $company_id];
+                    $where_query2[] = ['id', 'in', $employee_id_area];
+                    $where_query2[] = ['status', '=', 0];
+                    $where_query2[] = ['duty_type', '=', 2]; //责任类型1=第一责任人,2=责任人
+                }
+                //查询平台配置的员工
+                $employee_id_platform = $EmployeePlatformModel->where('platform_id', $product_data['platform_id'])->pluck('employee_id')->toarray();
+                if (!empty($employee_id_platform)) {
+                    $where_query3[] = ['company_id', '=', $company_id];
+                    $where_query3[] = ['id', 'in', $employee_id_platform];
+                    $where_query3[] = ['status', '=', 0];
+                    $where_query3[] = ['duty_type', '=', 2]; //责任类型1=第一责任人,2=责任人
+                }
+                //并行查询责任人
+                $EmployeeModel = new EmployeeModel();
+                $EmployeeModel = $EmployeeModel
+                    ->orWhere(function ($q) use ($employee_id_list, $company_id) {
+                        if (!empty($employee_id_list)) {
+                            $q->where('company_id', $company_id)
+                                ->orWhereIn('id', $employee_id_list)
+                                ->where('duty_type', 2)
+                                ->where('status', 0);
+                        }
+                    })->orWhere(function ($q) use ($employee_id_area, $company_id) {
                         if (!empty($employee_id_area)) {
-                            $where_city[] = ['company_id', '=', $company_id];
-                            $where_city[] = ['id', 'in', $employee_id_area];
-                            $where_city[] = ['status', '=', 0];
-                            $where_city[] = ['duty_type', '=', 2]; //责任类型1=第一责任人,2=责任人
-                            $EmployeeModel = new EmployeeModel();
-                            $responsible_person = $EmployeeModel->where($where_city)->pluck('id')->implode(',');
+                            $q->where('company_id', $company_id)
+                                ->whereIn('id', $employee_id_area)
+                                ->where('duty_type', 2)
+                                ->where('status', 0);
                         }
-                    }
-                    $insert_product_data['responsible_person'] = $responsible_person;
+                    })->orWhere(function ($q) use ($employee_id_platform, $company_id) {
+                        if (!empty($employee_id_platform)) {
+                            $q->where('company_id', $company_id)
+                                ->whereIn('id', $employee_id_platform)
+                                ->where('duty_type', 2)
+                                ->where('status', 0);
+                        }
+                    });
+                $responsible_person = $EmployeeModel->pluck('id')->implode(',');
 
-                    //溯源责任人
-                    $source_responsible_person = '';
-                    if ($first_responsible_person && $responsible_person) {
-                        //转换成数组,合并后在去重
-                        $first_responsible_person = explode(',', $first_responsible_person);
-                        $responsible_person = explode(',', $responsible_person);
-                        $source_responsible_person = array_unique(array_merge($first_responsible_person, $responsible_person));
-                        $source_responsible_person = ',' . implode(',', $source_responsible_person) . ',';
-                    } else if ($first_responsible_person) {
-                        $source_responsible_person = $first_responsible_person;
-                    } else if ($responsible_person) {
-                        $source_responsible_person = $responsible_person;
+                //当以上规则匹配不到责任人时,则去查询发货地区信息关联责任人
+                if (trim($responsible_person) == '' && trim($product_data['shipment_city_id']) != '') {
+                    $employee_id_area = $EmployeeAreaModel->where('city_id', $product_data['city_id'])->pluck('employee_id')->toarray();
+                    if (!empty($employee_id_area)) {
+                        $where_city[] = ['company_id', '=', $company_id];
+                        $where_city[] = ['id', 'in', $employee_id_area];
+                        $where_city[] = ['status', '=', 0];
+                        $where_city[] = ['duty_type', '=', 2]; //责任类型1=第一责任人,2=责任人
+                        $EmployeeModel = new EmployeeModel();
+                        $responsible_person = $EmployeeModel->where($where_city)->pluck('id')->implode(',');
                     }
-                    $insert_product_data['source_responsible_person'] = $source_responsible_person;
                 }
+                $insert_product_data['responsible_person'] = $responsible_person;
+
+                //溯源责任人
+                $source_responsible_person = '';
+                if ($first_responsible_person && $responsible_person) {
+                    //转换成数组,合并后在去重
+                    $first_responsible_person = explode(',', $first_responsible_person);
+                    $responsible_person = explode(',', $responsible_person);
+                    $source_responsible_person = array_unique(array_merge($first_responsible_person, $responsible_person));
+                    $source_responsible_person = ',' . implode(',', $source_responsible_person) . ',';
+                } else if ($first_responsible_person) {
+                    $source_responsible_person = $first_responsible_person;
+                } else if ($responsible_person) {
+                    $source_responsible_person = $responsible_person;
+                }
+                $insert_product_data['source_responsible_person'] = $source_responsible_person;
             }
-            //插入数据
-            $LowPriceGoodsModel->addLowPriceGoods($insert_product_data);
         }
-        //继续执行下一页
-        $message_data['page'] = $page + 1;
-        $message_data['limit'] = $limit;
-        LowPriceGoodsDataJobs::dispatch($message_data)->delay(now()->addSeconds(3));
+        //插入数据
+        $LowPriceGoodsModel->addLowPriceGoods($insert_product_data);
+        if ($index_number == $data_totle) {
+            (new ExecuteLogModel())->where('id', $executeLog_id)->update(['status' => 0, 'update_time' => time()]);
+        }
     }
 
 

+ 15 - 19
app/Jobs/Manager/Process/LowPriceGoodsJobs.php

@@ -12,9 +12,7 @@ use App\Facades\Servers\Logs\Log;
 use App\Models\Manager\WashConfig\LowPriceGoods as ConfigLowPriceGoodsModel;
 use App\Models\Manager\Process\ExecuteLog as ExecuteLogModel;
 use App\Jobs\Manager\Process\LowPriceGoodsDataJobs;
-use App\Models\Manager\WashConfig\ViolationStore as ViolationStoreModel;
 use App\Models\Manager\WashConfig\LowPriceGoodsCompany as LowPriceGoodsCompanyModel;
-use Illuminate\Support\Carbon;
 
 /**
  * 数据清洗-低价挂网商品配置队列
@@ -25,7 +23,7 @@ use Illuminate\Support\Carbon;
 class LowPriceGoodsJobs implements ShouldQueue
 {
     use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
-    
+
     public $tries = 3; // 限制重试次数
     public $timeout = 600; // 10分钟超时
 
@@ -48,17 +46,18 @@ class LowPriceGoodsJobs implements ShouldQueue
     public function handle()
     {
         try {
-            // $start_time = Carbon::today()->startOfDay()->getTimestamp(); // 今天开始时间 00:00:00
-            $start_time = time() - 60 * 5; // 开始时间 5分钟之前
-            $end_time = time(); //结束时间
             $ConfigLowPriceGoodsModel = new ConfigLowPriceGoodsModel();
             $LowPriceGoodsCompanyModel = new LowPriceGoodsCompanyModel();
-            $limit = isset($this->message_data['limit']) ? $this->message_data['limit'] : 50;
+            $limit = isset($this->message_data['limit']) ? $this->message_data['limit'] : 1000;
             $page = isset($this->message_data['page']) ? $this->message_data['page'] : 1;
             $executeLog_id = isset($this->message_data['executeLog_id']) ? $this->message_data['executeLog_id'] : 0;
             $admin_id = isset($this->message_data['admin_id']) ? $this->message_data['admin_id'] : 0;
             $is_admin = isset($this->message_data['is_admin']) ? $this->message_data['is_admin'] : 0;
             $company_id = isset($this->message_data['company_id']) ? $this->message_data['company_id'] : 0;
+            $product_data = isset($this->message_data['product_data']) ? $this->message_data['product_data'] : [];
+            $index_number = isset($this->message_data['index_number']) ? $this->message_data['index_number'] : 0;
+            $data_totle = isset($this->message_data['data_totle']) ? $this->message_data['data_totle'] : 0;
+
             if ($page == 1) {
                 $ExecuteLogModel = new ExecuteLogModel();
                 $insert_data = ['company_id' => $company_id, 'name' => '低价挂网商品', 'code' => 'LowPriceGoodsJobs', 'admin_id' => $admin_id, 'is_admin' => $is_admin];
@@ -70,16 +69,14 @@ class LowPriceGoodsJobs implements ShouldQueue
             if ($company_id) {
                 $ConfigLowPriceGoodsModel = $ConfigLowPriceGoodsModel->where('washconfig_lowprice_product.company_id', $company_id);
             }
-            $totle_page = 0;
             $list_config_data = $ConfigLowPriceGoodsModel->with(['product_keyword'])->paginate($limit, ['*'], 'page', $page)->toarray();
             if (!$list_config_data || empty($list_config_data['data'])) {
-                if($page == 1 && $executeLog_id){
-                    $ExecuteLogModel->where('id', $executeLog_id)->update(['status' => 0,'update_time'=> time()]);
+                if ($page == 1 && $executeLog_id) {
+                    $ExecuteLogModel->where('id', $executeLog_id)->update(['status' => 0, 'update_time' => time()]);
                 }
                 return true;
             }
             //获取总页码
-            $totle_page = $list_config_data['last_page'];
             $list_data = $list_config_data['data'];
             foreach ($list_data as $key => $value) {
                 $company_data = $LowPriceGoodsCompanyModel->where('washconfig_lowprice_product_company.lowprice_product_logid', $value['id'])
@@ -90,7 +87,7 @@ class LowPriceGoodsJobs implements ShouldQueue
                 $message_data = [
                     'company_id' => $value['company_id'],
                     'id' => $value['id'],
-                    'platform' => $value['platform'],  
+                    'platform' => $value['platform'],
                     'product_name' => $value['product_name'],
                     'enable_full_quantity' => $value['enable_full_quantity'],
                     'product_specs' => $value['product_specs'],
@@ -104,20 +101,19 @@ class LowPriceGoodsJobs implements ShouldQueue
                     'specify_responsible_person' => $value['specify_responsible_person'],
                     'product_brand' => $value['product_brand'],
                     'product_keyword' => $value['product_keyword'],
-                    'item_totle_page' => $totle_page,
-                    'item_now_page' => $page,
-                    'start_time' => $start_time,
-                    'end_time' => $end_time,
+                    'product_data'   => $product_data,
+                    'index_number'   => $index_number,
+                    'data_totle'     => $data_totle,
                 ];
-                // LowPriceGoodsDataJobs::dispatch($message_data);
-                LowPriceGoodsDataJobs::dispatchSync($message_data);
+                LowPriceGoodsDataJobs::dispatch($message_data);
+                // LowPriceGoodsDataJobs::dispatchSync($message_data);
             }
             $now_message_data = [
                 'limit' => $limit,
                 'page' => $page + 1,
                 'executeLog_id' => $executeLog_id,
             ];
-            LowPriceGoodsJobs::dispatch($now_message_data)->delay(now()->addSeconds(3));
+            LowPriceGoodsJobs::dispatch($now_message_data)->delay(now()->addSeconds(1));
         } catch (\Exception $e) {
             Log::info('job_error', '数据清洗-低价挂网商品配置队列失败', ['data' => $this->message_data, 'error' => $e->getMessage()]);
         }

+ 111 - 0
app/Jobs/Manager/Process/ScrapeDataProductJobs.php

@@ -0,0 +1,111 @@
+<?php
+
+namespace App\Jobs\Manager\Process;
+
+use Illuminate\Bus\Queueable;
+use Illuminate\Contracts\Queue\ShouldBeUnique;
+use Illuminate\Contracts\Queue\ShouldQueue;
+use Illuminate\Foundation\Bus\Dispatchable;
+use Illuminate\Queue\InteractsWithQueue;
+use Illuminate\Queue\SerializesModels;
+use App\Facades\Servers\Logs\Log;
+use App\Models\Manager\Process\ScrapeData as ScrapeDataModel;
+use Illuminate\Support\Facades\DB;
+use Illuminate\Support\Facades\Cache;
+use App\Jobs\Manager\Process\LowPriceGoodsJobs;
+use App\Jobs\Manager\Process\ViolationProductJobs;
+use App\Jobs\Manager\Process\ViolationCompanyJobs;
+
+/**
+ * 数据清洗-读取采集商品数据队列
+ * @author  唐远望
+ * @version 1.0
+ * @date  2025-12-10
+ */
+class ScrapeDataProductJobs implements ShouldQueue
+{
+    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
+
+    public $tries = 3; // 限制重试次数
+    public $timeout = 600; // 10分钟超时
+
+    protected $message_data;
+    /**
+     * Create a new job instance.
+     *
+     * @return void
+     */
+    public function __construct(array $message_data)
+    {
+        $this->message_data = $message_data;
+    }
+
+    /**
+     * Execute the job.
+     *
+     * @return void
+     */
+    public function handle()
+    {
+        try {
+            $ScrapeDataModel = new ScrapeDataModel();
+            $limit = isset($message_data['limit']) ? $message_data['limit'] : 10000;
+            $page = isset($message_data['page']) ? $message_data['page'] : 1;
+            $company_id = isset($message_data['company_id']) ? $message_data['company_id'] : 0; //品牌方公司ID
+
+            $start_time = $this->message_data['start_time'];
+            $end_time = $this->message_data['end_time'];
+            $start_time_string = date('Y-m-d H:i:s', $start_time);
+            $end_time_string = date('Y-m-d H:i:s', $end_time);
+
+            $key_name = 'ScrapeDataProductJobs_' . $company_id . '_' . $start_time . '_' . $end_time;
+            $product_datas = Cache::get($key_name);
+            if (empty($product_datas)) {
+                $where = [];
+                $where[] = ['insert_time', '>=', $start_time_string];
+                $where[] = ['insert_time', '<=', $end_time_string];
+                $where[] = ['min_price', '>=', '0.01'];
+                $where[] = ['number', '>=', '1'];
+                $where[] = ['company_id', '=', $company_id];
+                $product_data_info = $ScrapeDataModel->select('*', DB::raw('ROUND(min_price / NULLIF(number, 0), 2) as unit_price'))
+                    ->where($where)->orderbyDesc('id')->paginate($limit, ['*'], 'page', $page)->toarray();
+                $product_datas = $product_data_info['data'];
+                if (empty($product_datas) && $page == 1) {
+                    //如果查询第一页为空,则直接返回
+                    return true;
+                } else if (empty($product_datas) && $page > 1) {
+                    //如果查询第二页为空,则直接返回,表示查询完毕,则处理数据清洗任务
+                    $data_totle = count($product_datas);
+                    $index_number = 0;
+                    foreach ($product_datas as $key => $product_data) {
+                        $index_number = $key + 1;
+                        $message_data = ['company_id' => $company_id, 'page' => '1', 'limit' => '50', 'product_data' => $product_data, 'index_number' => $index_number, 'data_totle' => $data_totle];
+                        LowPriceGoodsJobs::dispatch($message_data);
+                        // LowPriceGoodsJobs::dispatchSync($message_data);
+                        ViolationProductJobs::dispatch($message_data);
+                        // ViolationProductJobs::dispatchSync($message_data);
+                        ViolationCompanyJobs::dispatch($message_data);
+                        // ViolationCompanyJobs::dispatchSync($message_data);
+                    }
+                }
+                return true;
+            } else {
+                //合并数据
+                $product_datas = array_merge($product_datas, Cache::get($key_name));
+                Cache::put($key_name, $product_datas, 360); //缓存6分钟
+                //继续执行下一页
+                $message_data['page'] = $page + 1;
+                $message_data['limit'] = $limit;
+                ScrapeDataProductJobs::dispatch($message_data)->delay(now()->addSeconds(1));
+            }
+        } catch (\Exception $e) {
+            Log::info('job_error', '数据清洗-读取采集商品数据队列失败', ['data' => $this->message_data, 'error' => $e->getMessage()]);
+        }
+    }
+
+
+    public function failed(\Throwable $exception)
+    {
+        Log::info('job_error', '数据清洗-读取采集商品数据队列完全失败', ['data' => $this->message_data, 'error' => $exception->getMessage()]);
+    }
+}

+ 329 - 342
app/Jobs/Manager/Process/ViolationCompanyDataJobs.php

@@ -18,8 +18,6 @@ use App\Models\Manager\Citys as CitysModel;
 use App\Models\Manager\Personnel\EmployeePlatform as EmployeePlatformModel;
 use App\Models\Manager\Personnel\EmployeeArea as EmployeeAreaModel;
 use App\Models\Manager\WashConfig\ViolationStore as ViolationStoreModel;
-use Illuminate\Support\Facades\DB;
-use Illuminate\Support\Carbon;
 
 /**
  * 数据清洗-违规公司店铺清洗数据队列
@@ -82,381 +80,370 @@ class ViolationCompanyDataJobs implements ShouldQueue
         $executeLog_id = $message_data['executeLog_id'];
         $company_category_name = $message_data['company_category_name']; //公司类别名称
         $specify_responsible_person = $message_data['specify_responsible_person']; //指派责任人 0=开启 1=关闭
-        $limit = isset($message_data['limit']) ? $message_data['limit'] : 10;
-        $page = isset($message_data['page']) ? $message_data['page'] : 1;
         $company_id = isset($message_data['company_id']) ? $message_data['company_id'] : 0; //品牌方公司ID
-        $item_totle_page = $message_data['item_totle_page']; //清洗店铺总页数
-        $item_now_page = $message_data['item_now_page']; //清洗店铺当前页
 
-        $start_time =$message_data['start_time'];
-        $end_time = $message_data['end_time'];
-        $start_time_string = date('Y-m-d H:i:s', $start_time);
-        $end_time_string = date('Y-m-d H:i:s', $end_time);
-        $where_map[] = ['insert_time', '>=', $start_time_string];
-        $where_map[] = ['insert_time', '<=', $end_time_string];
 
-        if ($platform != '0' && !empty($platform)) {
-            $platform = explode(',', $platform);
-            $ScrapeDataModel = $ScrapeDataModel->where('qualification_number', $social_credit_code)->where($where_map)->whereIn('platform_id', $platform);
-        } else {
-            $ScrapeDataModel = $ScrapeDataModel->where('qualification_number', $social_credit_code)->where($where_map);
+        $product_data = isset($this->message_data['product_data']) ? $this->message_data['product_data'] : [];
+        $index_number = isset($this->message_data['index_number']) ? $this->message_data['index_number'] : 0;
+        $data_totle = isset($this->message_data['data_totle']) ? $this->message_data['data_totle'] : 0;
+
+        //-------------------------------------- 清洗规则(开始) --------------------------------------
+        //过滤没有链接数据
+        if (trim($product_data['link_url']) == '')  return true;
+        //数据是否命中指定公司
+        $hit_company_scope = false;
+        if ($social_credit_code == '') return true;
+        if ($product_data['qualification_number'] == $social_credit_code) {
+            $hit_company_scope = true;
         }
-        $product_data_info = $ScrapeDataModel->paginate($limit, ['*'], 'page', $page)->toarray();
-        $product_datas = $product_data_info['data'];
-        if (empty($product_datas)) {
-            if ($executeLog_id && $item_now_page >= $item_totle_page) {
-                (new ExecuteLogModel())->where('id', $executeLog_id)->update(['status' => 0, 'update_time' => time()]);
+        if ($hit_company_scope != true)  return true;
+        //-------------------------------------- 清洗规则(结束) --------------------------------------
+
+        $store_name = $product_data['store_name'];
+        $anonymous_store_name = $product_data['anonymous_store_name'];
+        if ($anonymous_store_name != '') {
+            $store_name = $anonymous_store_name;
+        }
+        //-------------------------------------- 处理营业执照地区信息(开始) --------------------------------------
+        $province_name = $product_data['province_name'];
+        $city_name = $product_data['city_name'];
+        //特殊地区1级移除市
+        if ($province_name && in_array($province_name, ['北京市', '天津市', '上海市', '重庆市'])) {
+            //移除市这个字符
+            $province_name = trim(str_replace('市', '', $province_name));
+        } else if ($province_name && in_array($province_name, ['北京', '天津', '上海', '重庆'])) {
+        } else if ($province_name && in_array($province_name, ['内蒙古', '广西', '西藏', '新疆', '宁夏'])) {
+            switch ($province_name) {
+                case '内蒙古':
+                    $province_name = '内蒙古自治区';
+                    break;
+                case '广西':
+                    $province_name = '广西壮族自治区';
+                    break;
+                case '西藏':
+                    $province_name = '西藏自治区';
+                    break;
+                case '新疆':
+                    $province_name = '新疆维吾尔自治区';
+                    break;
+                case '宁夏':
+                    $province_name = '宁夏回族自治区';
+                    break;
             }
-            return true;
+        } else if ($province_name && in_array($province_name, ['内蒙古自治区', '广西壮族自治区', '西藏自治区', '新疆维吾尔自治区', '宁夏回族自治区'])) {
+            //完整匹配不做处理
+        } else if (trim($province_name) != '' && strpos($province_name, '省') === false) {
+            //是否存在市省,如果不存在则补全
+            $province_name = $province_name . '省';
         }
-        foreach ($product_datas as $product_data) {
-            $store_name = $product_data['store_name'];
-            $anonymous_store_name = $product_data['anonymous_store_name'];
-            if ($anonymous_store_name != '') {
-                $store_name = $anonymous_store_name;
+        if (trim($province_name) != '') {
+            //根据最新处理后的省份名称获取省份ID
+            $db_province_id = $CitysModel->where([['name', '=', $province_name], ['level', '=', '1']])->value('id');
+            if (!empty($db_province_id)) {
+                $product_data['province_id'] = $db_province_id;
+            } else {
+                //逆推省份ID失败,则修改为未知名称
+                $province_name = '未知';
             }
-            //-------------------------------------- 处理营业执照地区信息(开始) --------------------------------------
-            $province_name = $product_data['province_name'];
-            $city_name = $product_data['city_name'];
-            //特殊地区1级移除市
-            if ($province_name && in_array($province_name, ['北京市', '天津市', '上海市', '重庆市'])) {
-                //移除市这个字符
-                $province_name = trim(str_replace('市', '', $province_name));
-            } else if ($province_name && in_array($province_name, ['北京', '天津', '上海', '重庆'])) {
-            } else if ($province_name && in_array($province_name, ['内蒙古', '广西', '西藏', '新疆', '宁夏'])) {
-                switch ($province_name) {
-                    case '内蒙古':
-                        $province_name = '内蒙古自治区';
-                        break;
-                    case '广西':
-                        $province_name = '广西壮族自治区';
-                        break;
-                    case '西藏':
-                        $province_name = '西藏自治区';
-                        break;
-                    case '新疆':
-                        $province_name = '新疆维吾尔自治区';
-                        break;
-                    case '宁夏':
-                        $province_name = '宁夏回族自治区';
-                        break;
+        } else {
+            //尝试从地区详情里面匹配省份名称
+            $db_province_data_list = $CitysModel->where([['level', '=', '1']])->select(['id', 'name'])->get()->toarray();
+            foreach ($db_province_data_list as $db_province_data) {
+                $db_province_name = $db_province_data['name'];
+                if (strpos($product_data['area_info'], $db_province_name) !== false) {
+                    $province_name = $db_province_name;
+                    $product_data['province_id'] = $db_province_data['id'];
+                    break;
                 }
-            } else if ($province_name && in_array($province_name, ['内蒙古自治区', '广西壮族自治区', '西藏自治区', '新疆维吾尔自治区', '宁夏回族自治区'])) {
-                //完整匹配不做处理
-            } else if (trim($province_name) != '' && strpos($province_name, '省') === false) {
-                //是否存在市省,如果不存在则补全
-                $province_name = $province_name . '省';
             }
-            if (trim($province_name) != '') {
-                //根据最新处理后的省份名称获取省份ID
-                $db_province_id = $CitysModel->where([['name', '=', $province_name], ['level', '=', '1']])->value('id');
-                if (!empty($db_province_id)) {
-                    $product_data['province_id'] = $db_province_id;
+        }
+        if (trim($city_name) != '') {
+            //校验是否存在县这个字眼
+            if (strpos($city_name, '县') !== false) {
+                $db_city_id = $CitysModel->where([['name', '=', $city_name], ['level', '=', '2']])->value('id');
+                if (!empty($db_city_id)) {
+                    $product_data['city_id'] = $db_city_id;
+                }
+            } elseif (trim($city_name) != '' && strpos($city_name, '市') === false) {
+                //是否存在市
+                $city_name = $city_name . '市';
+                //根据最新处理后的市名称获取市ID
+                $db_city_id = $CitysModel->where([['name', '=', $city_name], ['level', '=', '2']])->value('id');
+                if (!empty($db_city_id)) {
+                    $product_data['city_id'] = $db_city_id;
                 } else {
-                    //逆推省份ID失败,则修改为未知名称
-                    $province_name = '未知';
+                    $city_name = '未知';
                 }
             } else {
-                //尝试从地区详情里面匹配省份名称
-                $db_province_data_list = $CitysModel->where([['level', '=', '1']])->select(['id', 'name'])->get()->toarray();
-                foreach ($db_province_data_list as $db_province_data) {
-                    $db_province_name = $db_province_data['name'];
-                    if (strpos($product_data['area_info'], $db_province_name) !== false) {
-                        $province_name = $db_province_name;
-                        $product_data['province_id'] = $db_province_data['id'];
-                        break;
-                    }
+                $db_city_id = $CitysModel->where([['name', '=', $city_name], ['level', '=', '2']])->value('id');
+                if (!empty($db_city_id)) {
+                    $product_data['city_id'] = $db_city_id;
+                } else {
+                    $city_name = '未知';
                 }
             }
-            if (trim($city_name) != '') {
-                //校验是否存在县这个字眼
-                if (strpos($city_name, '县') !== false) {
-                    $db_city_id = $CitysModel->where([['name', '=', $city_name], ['level', '=', '2']])->value('id');
-                    if (!empty($db_city_id)) {
-                        $product_data['city_id'] = $db_city_id;
-                    }
-                } elseif (trim($city_name) != '' && strpos($city_name, '市') === false) {
-                    //是否存在市
-                    $city_name = $city_name . '市';
-                    //根据最新处理后的市名称获取市ID
-                    $db_city_id = $CitysModel->where([['name', '=', $city_name], ['level', '=', '2']])->value('id');
-                    if (!empty($db_city_id)) {
-                        $product_data['city_id'] = $db_city_id;
-                    } else {
-                        $city_name = '未知';
-                    }
-                } else {
-                    $db_city_id = $CitysModel->where([['name', '=', $city_name], ['level', '=', '2']])->value('id');
-                    if (!empty($db_city_id)) {
+        } else {
+            if (trim($product_data['area_info']) != '') {
+                //尝试从地区详情里面匹配市名称
+                $db_city_name_list = $CitysModel->where([['level', '=', '2']])->pluck('name')->toarray();
+                foreach ($db_city_name_list as $db_city_name) {
+                    if (strpos($product_data['area_info'], $db_city_name) !== false) {
+                        $db_city_id = $CitysModel->where([['name', '=', $db_city_name], ['level', '=', '2']])->value('id');
                         $product_data['city_id'] = $db_city_id;
-                    } else {
-                        $city_name = '未知';
+                        $product_data['city_name'] = $db_city_name;
+                        $city_name = $db_city_name;
+                        break;
                     }
                 }
+            }
+        }
+        //如果存在市区city_id 则逆推省份ID以及名称
+        if (!empty($product_data['city_id']) && empty($product_data['province_id'])) {
+            $db_province_id = $CitysModel->where([['id', '=', $product_data['city_id']], ['level', '=', '2']])->value('pid');
+            $db_province_name = $CitysModel->where([['id', '=', $db_province_id], ['level', '=', '1']])->value('name');
+            $product_data['province_id'] = $db_province_id;
+            $product_data['province_name'] = $db_province_name;
+            $province_name = $db_province_name;
+        }
+        if (trim($product_data['area_info']) == '' && trim($city_name) != '' && trim($province_name) != '') {
+            $product_data['area_info'] = $province_name . $city_name;
+        }
+        //-------------------------------------- 处理营业执照地区信息(结束) --------------------------------------
+
+        //处理链接信息
+        preg_match('/https?:\/\/[^\s\'"<>]+/i', $product_data['link_url'], $matches);
+        if (!empty($matches)) {
+            $product_data['link_url'] = $matches[0];
+        }
+        $insert_product_data = [
+            'company_id' => $company_id,
+            'source_id' => $product_data['id'],
+            'platform'    => $product_data['platform_id'],
+            'company_name'    => $product_data['company_name'],
+            'link_url'    => $product_data['link_url'],
+            'store_name'    => $store_name,
+            'social_credit_code' => $social_credit_code,
+            'province_id'    => $product_data['province_id'],
+            'province_name' => $province_name,
+            'city_id' => $product_data['city_id'],
+            'city_name' => $city_name,
+            'area_info' => $product_data['area_info'],
+            'company_category_name' => $company_category_name,
+            'first_responsible_person' => '',
+            'responsible_person' => '',
+            'source_responsible_person' => '',
+            'scrape_date' => $product_data['scrape_date'],
+            'collection_time' => strtotime($product_data['insert_time']),
+        ];
+        //获取指定人员信息
+        if ($specify_responsible_person == 0) {
+            //获取店铺责任人信息
+            $ViolationStoreModel = new ViolationStoreModel();
+            $store_data_info = $ViolationStoreModel->where('store_name', $product_data['store_name'])->first();
+            if (!empty($store_data_info) && trim($store_data_info->employee_ids) != '') {
+                //查询店铺第一责任人信息
+                $EmployeeModel = new EmployeeModel();
+                $store_where_query = [];
+                $employee_id_store = explode(',', $store_data_info->employee_ids);
+                $store_where_query[] = ['company_id', '=', $company_id];
+                $store_where_query[] = ['id', 'in', $employee_id_store];
+                $store_where_query[] = ['status', '=', 0];
+                $store_where_query[] = ['duty_type', '=', 1]; //责任类型1=第一责任人,2=责任人
+                $first_responsible_person = $EmployeeModel->pluck('id')->implode(',');
+                $insert_product_data['first_responsible_person'] = $first_responsible_person;
+                //查询店铺责任人信息
+                $EmployeeModel = new EmployeeModel();
+                $store_where_query = [];
+                $employee_id_store = explode(',', $store_data_info->employee_ids);
+                $store_where_query[] = ['company_id', '=', $company_id];
+                $store_where_query[] = ['id', 'in', $employee_id_store];
+                $store_where_query[] = ['status', '=', 0];
+                $store_where_query[] = ['duty_type', '=', 2]; //责任类型1=第一责任人,2=责任人
+                $responsible_person = $EmployeeModel->pluck('id')->implode(',');
+                $insert_product_data['responsible_person'] = $responsible_person;
+                //溯源责任人
+                $source_responsible_person = '';
+                if ($first_responsible_person && $responsible_person) {
+                    //转换成数组,合并后在去重
+                    $first_responsible_person = explode(',', $first_responsible_person);
+                    $responsible_person = explode(',', $responsible_person);
+                    $source_responsible_person = array_unique(array_merge($first_responsible_person, $responsible_person));
+                    $source_responsible_person = ',' . implode(',', $source_responsible_person) . ',';
+                } else if ($first_responsible_person) {
+                    $source_responsible_person = $first_responsible_person;
+                } else if ($responsible_person) {
+                    $source_responsible_person = $responsible_person;
+                }
+                $insert_product_data['source_responsible_person'] = $source_responsible_person;
             } else {
-                if (trim($product_data['area_info']) != '') {
-                    //尝试从地区详情里面匹配市名称
-                    $db_city_name_list = $CitysModel->where([['level', '=', '2']])->pluck('name')->toarray();
-                    foreach ($db_city_name_list as $db_city_name) {
-                        if (strpos($product_data['area_info'], $db_city_name) !== false) {
-                            $db_city_id = $CitysModel->where([['name', '=', $db_city_name], ['level', '=', '2']])->value('id');
-                            $product_data['city_id'] = $db_city_id;
-                            $product_data['city_name'] = $db_city_name;
-                            $city_name = $db_city_name;
-                            break;
-                        }
-                    }
+                //获取公司绑定责任人信息
+                $company_data = $ViolationCompanyModel->leftjoin('washconfig_company_category', 'washconfig_company_category.id', '=', 'washconfig_violation_company.category_id')
+                    ->where('washconfig_violation_company.social_credit_code', $product_data['qualification_number'])
+                    ->where('washconfig_violation_company.company_id', $company_id)
+                    ->select(['washconfig_violation_company.id', 'washconfig_company_category.name as category_name'])->first();
+                $employee_id_list = [];
+                if ($company_data) {
+                    $employee_id_list = $ViolationCompanyMemberModel->where('company_logid', $company_data->id)->pluck('employee_id')->toarray();
+                    $insert_product_data['company_category_name'] = $company_data->category_name ? $company_data->category_name : '';
                 }
-            }
-            //如果存在市区city_id 则逆推省份ID以及名称
-            if (!empty($product_data['city_id']) && empty($product_data['province_id'])) {
-                $db_province_id = $CitysModel->where([['id', '=', $product_data['city_id']], ['level', '=', '2']])->value('pid');
-                $db_province_name = $CitysModel->where([['id', '=', $db_province_id], ['level', '=', '1']])->value('name');
-                $product_data['province_id'] = $db_province_id;
-                $product_data['province_name'] = $db_province_name;
-                $province_name = $db_province_name;
-            }
-            if (trim($product_data['area_info']) == '' && trim($city_name) != '' && trim($province_name) != '') {
-                $product_data['area_info'] = $province_name . $city_name;
-            }
-            //-------------------------------------- 处理营业执照地区信息(结束) --------------------------------------
+                $where_query1 = [];
+                $where_query2 = [];
+                $where_query3 = [];
+                //查询指定公司第一责任人
+                if (!empty($employee_id_list)) {
+                    $where_query1[] = ['company_id', '=', $company_id];
+                    $where_query1[] = ['id', 'in', $employee_id_list];
+                    $where_query1[] = ['status', '=', 0];
+                    $where_query1[] = ['duty_type', '=', 1]; //责任类型1=第一责任人,2=责任人
+                }
+                //查询地区配置的第一责任人
+                $employee_id_area = $EmployeeAreaModel->where('city_id', $product_data['city_id'])->pluck('employee_id')->toarray();
+                if (!empty($employee_id_area)) {
+                    $where_query2[] = ['company_id', '=', $company_id];
+                    $where_query2[] = ['id', 'in', $employee_id_area];
+                    $where_query2[] = ['status', '=', 0];
+                    $where_query2[] = ['duty_type', '=', 1]; //责任类型1=第一责任人,2=责任人
+                }
+                //查询平台配置的第一责任人
+                $employee_id_platform = $EmployeePlatformModel->where('platform_id', $product_data['platform_id'])->pluck('employee_id')->toarray();
+                if (!empty($employee_id_platform)) {
+                    $where_query3[] = ['company_id', '=', $company_id];
+                    $where_query3[] = ['id', 'in', $employee_id_platform];
+                    $where_query3[] = ['status', '=', 0];
+                    $where_query3[] = ['duty_type', '=', 1]; //责任类型1=第一责任人,2=责任人
+                }
+                //并行查询第一责任人
+                $EmployeeModel = new EmployeeModel();
+                $EmployeeModel = $EmployeeModel
+                    ->orWhere(function ($q) use ($employee_id_list, $company_id) {
+                        if (!empty($employee_id_list)) {
+                            $q->where('company_id', $company_id)
+                                ->orWhereIn('id', $employee_id_list)
+                                ->where('duty_type', 1)
+                                ->where('status', 0);
+                        }
+                    })->orWhere(function ($q) use ($employee_id_area, $company_id) {
+                        if (!empty($employee_id_area)) {
+                            $q->where('company_id', $company_id)
+                                ->whereIn('id', $employee_id_area)
+                                ->where('duty_type', 1)
+                                ->where('status', 0);
+                        }
+                    })->orWhere(function ($q) use ($employee_id_platform, $company_id) {
+                        if (!empty($employee_id_platform)) {
+                            $q->where('company_id', $company_id)
+                                ->whereIn('id', $employee_id_platform)
+                                ->where('duty_type', 1)
+                                ->where('status', 0);
+                        }
+                    });
+                $first_responsible_person = $EmployeeModel->pluck('id')->implode(',');
 
-            //处理链接信息
-            preg_match('/https?:\/\/[^\s\'"<>]+/i', $product_data['link_url'], $matches);
-            if (!empty($matches)) {
-                $product_data['link_url'] = $matches[0];
-            }
-            $insert_product_data = [
-                'company_id' => $company_id,
-                'source_id' => $product_data['id'],
-                'platform'    => $product_data['platform_id'],
-                'company_name'    => $product_data['company_name'],
-                'link_url'    => $product_data['link_url'],
-                'store_name'    => $store_name,
-                'social_credit_code' => $social_credit_code,
-                'province_id'    => $product_data['province_id'],
-                'province_name' => $province_name,
-                'city_id' => $product_data['city_id'],
-                'city_name' => $city_name,
-                'area_info' => $product_data['area_info'],
-                'company_category_name' => $company_category_name,
-                'first_responsible_person' => '',
-                'responsible_person' => '',
-                'source_responsible_person' => '',
-                'scrape_date' => $product_data['scrape_date'],
-                'collection_time' => strtotime($product_data['insert_time']),
-            ];
-            //获取指定人员信息
-            if ($specify_responsible_person == 0) {
-                //获取店铺责任人信息
-                $ViolationStoreModel = new ViolationStoreModel();
-                $store_data_info = $ViolationStoreModel->where('store_name', $product_data['store_name'])->first();
-                if (!empty($store_data_info) && trim($store_data_info->employee_ids) != '') {
-                    //查询店铺第一责任人信息
-                    $EmployeeModel = new EmployeeModel();
-                    $store_where_query = [];
-                    $employee_id_store = explode(',', $store_data_info->employee_ids);
-                    $store_where_query[] = ['company_id', '=', $company_id];
-                    $store_where_query[] = ['id', 'in', $employee_id_store];
-                    $store_where_query[] = ['status', '=', 0];
-                    $store_where_query[] = ['duty_type', '=', 1]; //责任类型1=第一责任人,2=责任人
-                    $first_responsible_person = $EmployeeModel->pluck('id')->implode(',');
-                    $insert_product_data['first_responsible_person'] = $first_responsible_person;
-                    //查询店铺责任人信息
-                    $EmployeeModel = new EmployeeModel();
-                    $store_where_query = [];
-                    $employee_id_store = explode(',', $store_data_info->employee_ids);
-                    $store_where_query[] = ['company_id', '=', $company_id];
-                    $store_where_query[] = ['id', 'in', $employee_id_store];
-                    $store_where_query[] = ['status', '=', 0];
-                    $store_where_query[] = ['duty_type', '=', 2]; //责任类型1=第一责任人,2=责任人
-                    $responsible_person = $EmployeeModel->pluck('id')->implode(',');
-                    $insert_product_data['responsible_person'] = $responsible_person;
-                    //溯源责任人
-                    $source_responsible_person = '';
-                    if ($first_responsible_person && $responsible_person) {
-                        //转换成数组,合并后在去重
-                        $first_responsible_person = explode(',', $first_responsible_person);
-                        $responsible_person = explode(',', $responsible_person);
-                        $source_responsible_person = array_unique(array_merge($first_responsible_person, $responsible_person));
-                        $source_responsible_person = ',' . implode(',', $source_responsible_person) . ',';
-                    } else if ($first_responsible_person) {
-                        $source_responsible_person = $first_responsible_person;
-                    } else if ($responsible_person) {
-                        $source_responsible_person = $responsible_person;
-                    }
-                    $insert_product_data['source_responsible_person'] = $source_responsible_person;
-                } else {
-                    //获取公司绑定责任人信息
-                    $company_data = $ViolationCompanyModel->leftjoin('washconfig_company_category', 'washconfig_company_category.id', '=', 'washconfig_violation_company.category_id')
-                        ->where('washconfig_violation_company.social_credit_code', $product_data['qualification_number'])
-                        ->where('washconfig_violation_company.company_id', $company_id)
-                        ->select(['washconfig_violation_company.id', 'washconfig_company_category.name as category_name'])->first();
-                    $employee_id_list = [];
-                    if ($company_data) {
-                        $employee_id_list = $ViolationCompanyMemberModel->where('company_logid', $company_data->id)->pluck('employee_id')->toarray();
-                        $insert_product_data['company_category_name'] = $company_data->category_name ? $company_data->category_name : '';
-                    }
-                    $where_query1 = [];
-                    $where_query2 = [];
-                    $where_query3 = [];
-                    //查询指定公司第一责任人
-                    if (!empty($employee_id_list)) {
-                        $where_query1[] = ['company_id', '=', $company_id];
-                        $where_query1[] = ['id', 'in', $employee_id_list];
-                        $where_query1[] = ['status', '=', 0];
-                        $where_query1[] = ['duty_type', '=', 1]; //责任类型1=第一责任人,2=责任人
-                    }
-                    //查询地区配置的第一责任人
+                //当以上规则匹配不到责任人时,则去查询发货地区信息关联责任人
+                if (trim($first_responsible_person) == '' && trim($product_data['shipment_city_id']) != '') {
                     $employee_id_area = $EmployeeAreaModel->where('city_id', $product_data['city_id'])->pluck('employee_id')->toarray();
                     if (!empty($employee_id_area)) {
-                        $where_query2[] = ['company_id', '=', $company_id];
-                        $where_query2[] = ['id', 'in', $employee_id_area];
-                        $where_query2[] = ['status', '=', 0];
-                        $where_query2[] = ['duty_type', '=', 1]; //责任类型1=第一责任人,2=责任人
-                    }
-                    //查询平台配置的第一责任人
-                    $employee_id_platform = $EmployeePlatformModel->where('platform_id', $product_data['platform_id'])->pluck('employee_id')->toarray();
-                    if (!empty($employee_id_platform)) {
-                        $where_query3[] = ['company_id', '=', $company_id];
-                        $where_query3[] = ['id', 'in', $employee_id_platform];
-                        $where_query3[] = ['status', '=', 0];
-                        $where_query3[] = ['duty_type', '=', 1]; //责任类型1=第一责任人,2=责任人
+                        $where_city[] = ['company_id', '=', $company_id];
+                        $where_city[] = ['id', 'in', $employee_id_area];
+                        $where_city[] = ['status', '=', 0];
+                        $where_city[] = ['duty_type', '=', 1]; //责任类型1=第一责任人,2=责任人
+                        $EmployeeModel = new EmployeeModel();
+                        $first_responsible_person = $EmployeeModel->where($where_city)->pluck('id')->implode(',');
                     }
-                    //并行查询第一责任人
-                    $EmployeeModel = new EmployeeModel();
-                    $EmployeeModel = $EmployeeModel
-                        ->orWhere(function ($q) use ($employee_id_list, $company_id) {
-                            if (!empty($employee_id_list)) {
-                                $q->where('company_id', $company_id)
-                                    ->orWhereIn('id', $employee_id_list)
-                                    ->where('duty_type', 1)
-                                    ->where('status', 0);
-                            }
-                        })->orWhere(function ($q) use ($employee_id_area, $company_id) {
-                            if (!empty($employee_id_area)) {
-                                $q->where('company_id', $company_id)
-                                    ->whereIn('id', $employee_id_area)
-                                    ->where('duty_type', 1)
-                                    ->where('status', 0);
-                            }
-                        })->orWhere(function ($q) use ($employee_id_platform, $company_id) {
-                            if (!empty($employee_id_platform)) {
-                                $q->where('company_id', $company_id)
-                                    ->whereIn('id', $employee_id_platform)
-                                    ->where('duty_type', 1)
-                                    ->where('status', 0);
-                            }
-                        });
-                    $first_responsible_person = $EmployeeModel->pluck('id')->implode(',');
+                }
 
-                    //当以上规则匹配不到责任人时,则去查询发货地区信息关联责任人
-                    if (trim($first_responsible_person) == '' && trim($product_data['shipment_city_id']) != '') {
-                        $employee_id_area = $EmployeeAreaModel->where('city_id', $product_data['city_id'])->pluck('employee_id')->toarray();
+                //调试记录查询条件
+                $insert_product_data['first_responsible_person'] = $first_responsible_person;
+                //查询责任人
+                $where_query1 = [];
+                $where_query2 = [];
+                $where_query3 = [];
+                //查询指定公司责任人
+                if (!empty($employee_id_list)) {
+                    $where_query1[] = ['company_id', '=', $company_id];
+                    $where_query1[] = ['id', 'in', $employee_id_list];
+                    $where_query1[] = ['status', '=', 0];
+                    $where_query1[] = ['duty_type', '=', 2]; //责任类型1=第一责任人,2=责任人
+                }
+                //查询地区配置的员工
+                $employee_id_area = $EmployeeAreaModel->where('city_id', $product_data['city_id'])->pluck('employee_id')->toarray();
+                if (!empty($employee_id_area)) {
+                    $where_query2[] = ['company_id', '=', $company_id];
+                    $where_query2[] = ['id', 'in', $employee_id_area];
+                    $where_query2[] = ['status', '=', 0];
+                    $where_query2[] = ['duty_type', '=', 2]; //责任类型1=第一责任人,2=责任人
+                }
+                //查询平台配置的员工
+                $employee_id_platform = $EmployeePlatformModel->where('platform_id', $product_data['platform_id'])->pluck('employee_id')->toarray();
+                if (!empty($employee_id_platform)) {
+                    $where_query3[] = ['company_id', '=', $company_id];
+                    $where_query3[] = ['id', 'in', $employee_id_platform];
+                    $where_query3[] = ['status', '=', 0];
+                    $where_query3[] = ['duty_type', '=', 2]; //责任类型1=第一责任人,2=责任人
+                }
+                //并行查询责任人
+                $EmployeeModel = new EmployeeModel();
+                $EmployeeModel = $EmployeeModel
+                    ->orWhere(function ($q) use ($employee_id_list, $company_id) {
+                        if (!empty($employee_id_list)) {
+                            $q->where('company_id', $company_id)
+                                ->orWhereIn('id', $employee_id_list)
+                                ->where('duty_type', 2)
+                                ->where('status', 0);
+                        }
+                    })->orWhere(function ($q) use ($employee_id_area, $company_id) {
                         if (!empty($employee_id_area)) {
-                            $where_city[] = ['company_id', '=', $company_id];
-                            $where_city[] = ['id', 'in', $employee_id_area];
-                            $where_city[] = ['status', '=', 0];
-                            $where_city[] = ['duty_type', '=', 1]; //责任类型1=第一责任人,2=责任人
-                            $EmployeeModel = new EmployeeModel();
-                            $first_responsible_person = $EmployeeModel->where($where_city)->pluck('id')->implode(',');
+                            $q->where('company_id', $company_id)
+                                ->whereIn('id', $employee_id_area)
+                                ->where('duty_type', 2)
+                                ->where('status', 0);
                         }
-                    }
+                    })->orWhere(function ($q) use ($employee_id_platform, $company_id) {
+                        if (!empty($employee_id_platform)) {
+                            $q->where('company_id', $company_id)
+                                ->whereIn('id', $employee_id_platform)
+                                ->where('duty_type', 2)
+                                ->where('status', 0);
+                        }
+                    });
+                $responsible_person = $EmployeeModel->pluck('id')->implode(',');
 
-                    //调试记录查询条件
-                    $insert_product_data['first_responsible_person'] = $first_responsible_person;
-                    //查询责任人
-                    $where_query1 = [];
-                    $where_query2 = [];
-                    $where_query3 = [];
-                    //查询指定公司责任人
-                    if (!empty($employee_id_list)) {
-                        $where_query1[] = ['company_id', '=', $company_id];
-                        $where_query1[] = ['id', 'in', $employee_id_list];
-                        $where_query1[] = ['status', '=', 0];
-                        $where_query1[] = ['duty_type', '=', 2]; //责任类型1=第一责任人,2=责任人
-                    }
-                    //查询地区配置的员工
+                //当以上规则匹配不到责任人时,则去查询发货地区信息关联责任人
+                if (trim($responsible_person) == '' && trim($product_data['shipment_city_id']) != '') {
                     $employee_id_area = $EmployeeAreaModel->where('city_id', $product_data['city_id'])->pluck('employee_id')->toarray();
                     if (!empty($employee_id_area)) {
-                        $where_query2[] = ['company_id', '=', $company_id];
-                        $where_query2[] = ['id', 'in', $employee_id_area];
-                        $where_query2[] = ['status', '=', 0];
-                        $where_query2[] = ['duty_type', '=', 2]; //责任类型1=第一责任人,2=责任人
+                        $where_city[] = ['company_id', '=', $company_id];
+                        $where_city[] = ['id', 'in', $employee_id_area];
+                        $where_city[] = ['status', '=', 0];
+                        $where_city[] = ['duty_type', '=', 2]; //责任类型1=第一责任人,2=责任人
+                        $EmployeeModel = new EmployeeModel();
+                        $responsible_person = $EmployeeModel->where($where_city)->pluck('id')->implode(',');
                     }
-                    //查询平台配置的员工
-                    $employee_id_platform = $EmployeePlatformModel->where('platform_id', $product_data['platform_id'])->pluck('employee_id')->toarray();
-                    if (!empty($employee_id_platform)) {
-                        $where_query3[] = ['company_id', '=', $company_id];
-                        $where_query3[] = ['id', 'in', $employee_id_platform];
-                        $where_query3[] = ['status', '=', 0];
-                        $where_query3[] = ['duty_type', '=', 2]; //责任类型1=第一责任人,2=责任人
-                    }
-                    //并行查询责任人
-                    $EmployeeModel = new EmployeeModel();
-                    $EmployeeModel = $EmployeeModel
-                        ->orWhere(function ($q) use ($employee_id_list, $company_id) {
-                            if (!empty($employee_id_list)) {
-                                $q->where('company_id', $company_id)
-                                    ->orWhereIn('id', $employee_id_list)
-                                    ->where('duty_type', 2)
-                                    ->where('status', 0);
-                            }
-                        })->orWhere(function ($q) use ($employee_id_area, $company_id) {
-                            if (!empty($employee_id_area)) {
-                                $q->where('company_id', $company_id)
-                                    ->whereIn('id', $employee_id_area)
-                                    ->where('duty_type', 2)
-                                    ->where('status', 0);
-                            }
-                        })->orWhere(function ($q) use ($employee_id_platform, $company_id) {
-                            if (!empty($employee_id_platform)) {
-                                $q->where('company_id', $company_id)
-                                    ->whereIn('id', $employee_id_platform)
-                                    ->where('duty_type', 2)
-                                    ->where('status', 0);
-                            }
-                        });
-                    $responsible_person = $EmployeeModel->pluck('id')->implode(',');
-
-                    //当以上规则匹配不到责任人时,则去查询发货地区信息关联责任人
-                    if (trim($responsible_person) == '' && trim($product_data['shipment_city_id']) != '') {
-                        $employee_id_area = $EmployeeAreaModel->where('city_id', $product_data['city_id'])->pluck('employee_id')->toarray();
-                        if (!empty($employee_id_area)) {
-                            $where_city[] = ['company_id', '=', $company_id];
-                            $where_city[] = ['id', 'in', $employee_id_area];
-                            $where_city[] = ['status', '=', 0];
-                            $where_city[] = ['duty_type', '=', 2]; //责任类型1=第一责任人,2=责任人
-                            $EmployeeModel = new EmployeeModel();
-                            $responsible_person = $EmployeeModel->where($where_city)->pluck('id')->implode(',');
-                        }
-                    }
-                    $insert_product_data['responsible_person'] = $responsible_person;
+                }
+                $insert_product_data['responsible_person'] = $responsible_person;
 
-                    //溯源责任人
-                    $source_responsible_person = '';
-                    if ($first_responsible_person && $responsible_person) {
-                        //转换成数组,合并后在去重
-                        $first_responsible_person = explode(',', $first_responsible_person);
-                        $responsible_person = explode(',', $responsible_person);
-                        $source_responsible_person = array_unique(array_merge($first_responsible_person, $responsible_person));
-                        $source_responsible_person = ',' . implode(',', $source_responsible_person) . ',';
-                    } else if ($first_responsible_person) {
-                        $source_responsible_person = $first_responsible_person;
-                    } else if ($responsible_person) {
-                        $source_responsible_person = $responsible_person;
-                    }
-                    $insert_product_data['source_responsible_person'] = $source_responsible_person;
+                //溯源责任人
+                $source_responsible_person = '';
+                if ($first_responsible_person && $responsible_person) {
+                    //转换成数组,合并后在去重
+                    $first_responsible_person = explode(',', $first_responsible_person);
+                    $responsible_person = explode(',', $responsible_person);
+                    $source_responsible_person = array_unique(array_merge($first_responsible_person, $responsible_person));
+                    $source_responsible_person = ',' . implode(',', $source_responsible_person) . ',';
+                } else if ($first_responsible_person) {
+                    $source_responsible_person = $first_responsible_person;
+                } else if ($responsible_person) {
+                    $source_responsible_person = $responsible_person;
                 }
+                $insert_product_data['source_responsible_person'] = $source_responsible_person;
             }
+        }
 
-            //插入数据
-            $ViolationStoreModel->addViolationStore($insert_product_data);
+        //插入数据
+        $ViolationStoreModel->addViolationStore($insert_product_data);
+        if ($index_number == $data_totle) {
+            (new ExecuteLogModel())->where('id', $executeLog_id)->update(['status' => 0, 'update_time' => time()]);
         }
-        //继续执行下一页
-        $message_data['page'] = $page + 1;
-        $message_data['limit'] = $limit;
-        ViolationCompanyDataJobs::dispatch($message_data)->delay(now()->addSeconds(3));
     }
 
 

+ 7 - 8
app/Jobs/Manager/Process/ViolationCompanyJobs.php

@@ -12,7 +12,6 @@ use App\Facades\Servers\Logs\Log;
 use App\Models\Manager\WashConfig\ViolationCompany as ViolationCompanyModel;
 use App\Models\Manager\Process\ExecuteLog as ExecuteLogModel;
 use App\Jobs\Manager\Process\ViolationCompanyDataJobs;
-use Illuminate\Support\Carbon;
 
 /**
  * 数据清洗-违规挂网公司配置队列
@@ -50,12 +49,15 @@ class ViolationCompanyJobs implements ShouldQueue
             $start_time = time() - 60 * 5; // 开始时间 5分钟之前
             $end_time = time(); //结束时间
             $ViolationCompanyModel = new ViolationCompanyModel();
-            $limit = isset($this->message_data['limit']) ? $this->message_data['limit'] : 50;
+            $limit = isset($this->message_data['limit']) ? $this->message_data['limit'] : 1000;
             $page = isset($this->message_data['page']) ? $this->message_data['page'] : 1;
             $executeLog_id = isset($this->message_data['executeLog_id']) ? $this->message_data['executeLog_id'] : 0;
             $admin_id = isset($this->message_data['admin_id']) ? $this->message_data['admin_id'] : 0;
             $is_admin = isset($this->message_data['is_admin']) ? $this->message_data['is_admin'] : 0;
             $company_id = isset($this->message_data['company_id']) ? $this->message_data['company_id'] : 0;
+            $product_data = isset($this->message_data['product_data']) ? $this->message_data['product_data'] : [];
+            $index_number = isset($this->message_data['index_number']) ? $this->message_data['index_number'] : 0;
+            $data_totle = isset($this->message_data['data_totle']) ? $this->message_data['data_totle'] : 0;
             if($page == 1){
                 $ExecuteLogModel = new ExecuteLogModel();
                 $insert_data =['company_id'=>$company_id,'name' =>'违规挂网公司店铺', 'code' => 'ViolationCompanyJobs', 'admin_id' => $admin_id,'is_admin' => $is_admin];
@@ -66,7 +68,6 @@ class ViolationCompanyJobs implements ShouldQueue
             if($company_id){
                 $ViolationCompanyModel = $ViolationCompanyModel->where('washconfig_violation_company.company_id', $company_id);
             }
-            $totle_page = 0;
             $list_config_data = $ViolationCompanyModel->paginate($limit, ['*'], 'page', $page)->toarray();
             if (!$list_config_data || empty($list_config_data['data'])) {
                 if($page == 1 && $executeLog_id){
@@ -74,7 +75,6 @@ class ViolationCompanyJobs implements ShouldQueue
                 }
                 return true;
             }
-            $totle_page = $list_config_data['last_page'];
             $list_data = $list_config_data['data'];
             foreach ($list_data as $key => $value) {
                 $message_data = [
@@ -87,10 +87,9 @@ class ViolationCompanyJobs implements ShouldQueue
                     'executeLog_id' => $executeLog_id,
                     'company_category_name' => $value['category_name'],
                     'specify_responsible_person' => $value['specify_responsible_person'],
-                    'item_totle_page' => $totle_page,
-                    'item_now_page' => $page,
-                    'start_time' => $start_time,
-                    'end_time' => $end_time,
+                    'product_data'   => $product_data,
+                    'index_number'   => $index_number,
+                    'data_totle'     => $data_totle,
                 ];
                 ViolationCompanyDataJobs::dispatch($message_data);
                 // ViolationCompanyDataJobs::dispatchSync($message_data);

+ 471 - 494
app/Jobs/Manager/Process/ViolationProductDataJobs.php

@@ -12,15 +12,12 @@ use App\Facades\Servers\Logs\Log;
 use App\Models\Manager\Process\ViolationProduct as ViolationProductModel;
 use App\Models\Manager\Personnel\Employee as EmployeeModel;
 use App\Models\Api\Process\ExecuteLog as ExecuteLogModel;
-use App\Models\Manager\Process\ScrapeData as ScrapeDataModel;
 use App\Models\Manager\WashConfig\ViolationCompany as ViolationCompanyModel;
 use App\Models\Manager\WashConfig\ViolationCompanyMember as ViolationCompanyMemberModel;
 use App\Models\Manager\Citys as CitysModel;
 use App\Models\Manager\Personnel\EmployeePlatform as EmployeePlatformModel;
 use App\Models\Manager\Personnel\EmployeeArea as EmployeeAreaModel;
 use App\Models\Manager\WashConfig\ViolationStore as ViolationStoreModel;
-use Illuminate\Support\Facades\DB;
-use Illuminate\Support\Carbon;
 
 /**
  * 数据清洗-违规挂网商品数据队列
@@ -72,7 +69,6 @@ class ViolationProductDataJobs implements ShouldQueue
         $CitysModel = new CitysModel();
         $EmployeeModel = new EmployeeModel();
         $ViolationProductModel = new ViolationProductModel();
-        $ScrapeDataModel = new ScrapeDataModel();
         $ViolationCompanyModel = new ViolationCompanyModel();
         $ViolationCompanyMemberModel = new ViolationCompanyMemberModel();
         $EmployeePlatformModel = new EmployeePlatformModel();
@@ -87,539 +83,520 @@ class ViolationProductDataJobs implements ShouldQueue
         $executeLog_id = $message_data['executeLog_id'];
         $category_name = $message_data['category_name']; //产品分类名称
         $specify_responsible_person = $message_data['specify_responsible_person']; //指派责任人 0=开启 1=关闭
-        $limit = isset($message_data['limit']) ? $message_data['limit'] : 10;
-        $page = isset($message_data['page']) ? $message_data['page'] : 1;
         $company_id = isset($message_data['company_id']) ? $message_data['company_id'] : 0; //品牌方公司ID
         $product_brand = $message_data['product_brand']; //商品品牌名称
         $product_keywords = $message_data['product_keyword']; //关键字
-        $item_totle_page = $message_data['item_totle_page']; //清洗商品总页数
-        $item_now_page = $message_data['item_now_page']; //清洗商品当前页
+        $product_data = isset($this->message_data['product_data']) ? $this->message_data['product_data'] : [];
+        $index_number = isset($this->message_data['index_number']) ? $this->message_data['index_number'] : 0;
+        $data_totle = isset($this->message_data['data_totle']) ? $this->message_data['data_totle'] : 0;
 
-        $where = [];
-        $start_time = $message_data['start_time'];
-        $end_time = $message_data['end_time'];
-        $start_time_string = date('Y-m-d H:i:s', $start_time);
-        $end_time_string = date('Y-m-d H:i:s', $end_time);
-        $where[] = ['insert_time', '>=', $start_time_string];
-        $where[] = ['insert_time', '<=', $end_time_string];
-        $where[] = ['product_name', 'like', '%' . $product_name . '%'];
-        if ($product_brand) $where[] = ['product_brand', 'like', '%' . $product_brand . '%'];
-
-        $ScrapeDataModel = $ScrapeDataModel
-            ->orWhere(function ($q) use ($where, $enable_full_quantity, $product_specs, $product_keywords, $company_scope, $social_credit_code, $platform) {
-                if ($enable_full_quantity == 1) {
-                    $where[] = ['product_name', 'like', '%' . $product_specs . '%']; //如果不是全量清洗,则查询规格,从商品名称中查找规格
-                }
-                $q->where($where);
-                if (!empty($product_keywords)) {
-                    $q->where(function ($query) use ($product_keywords) {
-                        // 平台条件(固定)
-                        $query->where(function ($query_li) use ($product_keywords) {
-                            foreach ($product_keywords as $product_keyword) {
-                                if (empty($product_keyword)) continue;
-                                $query_li->orWhere([['product_name', 'like', '%' . $product_keyword . '%']]);
-                            }
-                        });
-                    });
-                }
-                if ($company_scope == 2 && $social_credit_code != '') {
-                    $q->whereIn('qualification_number', $social_credit_code);
-                }
-                if ($platform != '0' && !empty($platform)) {
-                    $platform = explode(',', $platform);
-                    $q->whereIn('platform_id', $platform);
-                }
-            })->orWhere(function ($q) use ($where, $enable_full_quantity, $product_specs, $product_keywords, $company_scope, $social_credit_code, $platform) {
-                if ($enable_full_quantity == 1) {
-                    $where[] = ['product_specs', 'like', '%' . $product_specs . '%']; //如果不是全量清洗,则查询规格,从商品规格中查找规格
-                }
-                $q->where($where);
-                if (!empty($product_keywords)) {
-                    $q->where(function ($query) use ($product_keywords) {
-                        // 平台条件(固定)
-                        $query->where(function ($query_li) use ($product_keywords) {
-                            foreach ($product_keywords as $product_keyword) {
-                                if (empty($product_keyword)) continue;
-                                $query_li->orWhere([['product_name', 'like', '%' . $product_keyword . '%']]);
-                            }
-                        });
-                    });
-                }
-                if ($company_scope == 2 && $social_credit_code != '') {
-                    $q->whereIn('qualification_number', $social_credit_code);
-                }
-                if ($platform != '0' && !empty($platform)) {
-                    $platform = explode(',', $platform);
-                    $q->whereIn('platform_id', $platform);
+        //-------------------------------------- 清洗规则(开始) --------------------------------------
+        //过滤没有链接数据
+        if (trim($product_data['link_url']) == '')  return true;
+        //数据是否命中商品名称
+        $hit_product_name = false;
+        if (strpos($product_data['product_name'], $product_name) !== false) {
+            $hit_product_name = true;
+        }
+        if ($hit_product_name != true) return true;
+        //数据是否命中规格
+        $hit_product_specs = false;
+        if ($enable_full_quantity == 1 && $product_specs) {
+            //product_name 包含规格
+            if (strpos($product_data['product_name'], $product_specs) !== false) {
+                $hit_product_specs = true;
+            } else if (strpos($product_data['product_specs'], $product_specs) !== false) {
+                $hit_product_specs = true;
+            }
+        }
+        if ($hit_product_specs != true) return true;
+        //数据是否命中关键字
+        $hit_product_keywords = false;
+        if (!empty($product_keywords)) {
+            $product_keywords = explode(',', $product_keywords);
+            foreach ($product_keywords as $product_keyword) {
+                if (empty($product_keyword)) continue;
+                if (strpos($product_data['product_name'], $product_keyword) !== false) {
+                    $hit_product_keywords = true;
+                    break;
                 }
-            });
-        $product_data_info = $ScrapeDataModel->orderbyDesc('id')->paginate($limit, ['*'], 'page', $page)->toarray();
-        $product_datas = $product_data_info['data'];
+            }
+        }
+        if ($hit_product_keywords != true) return true;
+        //数据是否命中指定公司
+        $hit_company_scope = false;
+        if ($company_scope == 2 && $social_credit_code != '') {
+            if ($product_data['qualification_number'] == $social_credit_code) {
+                $hit_company_scope = true;
+            }
+        }
+        if ($hit_company_scope != true) return true;
+        //数据是否命中平台
+        $hit_platform = false;
+        if ($platform != '0' && !empty($platform)) {
+            $platform = explode(',', $platform);
+            if (in_array($product_data['platform_id'], $platform)) {
+                $hit_platform = true;
+            }
+        }
+        if ($hit_platform != true) return true;
+        //-------------------------------------- 清洗规则(结束) --------------------------------------
+
 
 
-        if (empty($product_datas)) {
-            if ($executeLog_id && $item_now_page >= $item_totle_page) {
-                (new ExecuteLogModel())->where('id', $executeLog_id)->update(['status' => 0, 'update_time' => time()]);
+        //-------------------------------------- 处理营业执照地区信息(开始) --------------------------------------
+        $province_name = $product_data['province_name'];
+        $city_name = $product_data['city_name'];
+        //特殊地区1级移除市
+        if ($province_name && in_array($province_name, ['北京市', '天津市', '上海市', '重庆市'])) {
+            //移除市这个字符
+            $province_name = trim(str_replace('市', '', $province_name));
+        } else if ($province_name && in_array($province_name, ['北京', '天津', '上海', '重庆'])) {
+        } else if ($province_name && in_array($province_name, ['内蒙古', '广西', '西藏', '新疆', '宁夏'])) {
+            switch ($province_name) {
+                case '内蒙古':
+                    $province_name = '内蒙古自治区';
+                    break;
+                case '广西':
+                    $province_name = '广西壮族自治区';
+                    break;
+                case '西藏':
+                    $province_name = '西藏自治区';
+                    break;
+                case '新疆':
+                    $province_name = '新疆维吾尔自治区';
+                    break;
+                case '宁夏':
+                    $province_name = '宁夏回族自治区';
+                    break;
             }
-            return true;
+        } else if ($province_name && in_array($province_name, ['内蒙古自治区', '广西壮族自治区', '西藏自治区', '新疆维吾尔自治区', '宁夏回族自治区'])) {
+            //完整匹配不做处理
+        } else if (trim($province_name) != '' && strpos($province_name, '省') === false) {
+            //是否存在市省,如果不存在则补全
+            $province_name = $province_name . '省';
         }
-        foreach ($product_datas as $product_data) {
-            //-------------------------------------- 处理营业执照地区信息(开始) --------------------------------------
-            $province_name = $product_data['province_name'];
-            $city_name = $product_data['city_name'];
-            //特殊地区1级移除市
-            if ($province_name && in_array($province_name, ['北京市', '天津市', '上海市', '重庆市'])) {
-                //移除市这个字符
-                $province_name = trim(str_replace('市', '', $province_name));
-            } else if ($province_name && in_array($province_name, ['北京', '天津', '上海', '重庆'])) {
-            } else if ($province_name && in_array($province_name, ['内蒙古', '广西', '西藏', '新疆', '宁夏'])) {
-                switch ($province_name) {
-                    case '内蒙古':
-                        $province_name = '内蒙古自治区';
-                        break;
-                    case '广西':
-                        $province_name = '广西壮族自治区';
-                        break;
-                    case '西藏':
-                        $province_name = '西藏自治区';
-                        break;
-                    case '新疆':
-                        $province_name = '新疆维吾尔自治区';
-                        break;
-                    case '宁夏':
-                        $province_name = '宁夏回族自治区';
-                        break;
+        if (trim($province_name) != '') {
+            //根据最新处理后的省份名称获取省份ID
+            $db_province_id = $CitysModel->where([['name', '=', $province_name], ['level', '=', '1']])->value('id');
+            if (!empty($db_province_id)) {
+                $product_data['province_id'] = $db_province_id;
+            } else {
+                //逆推省份ID失败,则修改为未知名称
+                $province_name = '未知';
+            }
+        } else {
+            //尝试从地区详情里面匹配省份名称
+            $db_province_data_list = $CitysModel->where([['level', '=', '1']])->select(['id', 'name'])->get()->toarray();
+            foreach ($db_province_data_list as $db_province_data) {
+                $db_province_name = $db_province_data['name'];
+                if (strpos($product_data['area_info'], $db_province_name) !== false) {
+                    $province_name = $db_province_name;
+                    $product_data['province_id'] = $db_province_data['id'];
+                    break;
                 }
-            } else if ($province_name && in_array($province_name, ['内蒙古自治区', '广西壮族自治区', '西藏自治区', '新疆维吾尔自治区', '宁夏回族自治区'])) {
-                //完整匹配不做处理
-            } else if (trim($province_name) != '' && strpos($province_name, '省') === false) {
-                //是否存在市省,如果不存在则补全
-                $province_name = $province_name . '省';
             }
-            if (trim($province_name) != '') {
-                //根据最新处理后的省份名称获取省份ID
-                $db_province_id = $CitysModel->where([['name', '=', $province_name], ['level', '=', '1']])->value('id');
-                if (!empty($db_province_id)) {
-                    $product_data['province_id'] = $db_province_id;
+        }
+        if (trim($city_name) != '') {
+            //校验是否存在县这个字眼
+            if (strpos($city_name, '县') !== false) {
+                $db_city_id = $CitysModel->where([['name', '=', $city_name], ['level', '=', '2']])->value('id');
+                if (!empty($db_city_id)) {
+                    $product_data['city_id'] = $db_city_id;
+                }
+            } elseif (trim($city_name) != '' && strpos($city_name, '市') === false) {
+                //是否存在市
+                $city_name = $city_name . '市';
+                //根据最新处理后的市名称获取市ID
+                $db_city_id = $CitysModel->where([['name', '=', $city_name], ['level', '=', '2']])->value('id');
+                if (!empty($db_city_id)) {
+                    $product_data['city_id'] = $db_city_id;
                 } else {
-                    //逆推省份ID失败,则修改为未知名称
-                    $province_name = '未知';
+                    $city_name = '未知';
                 }
             } else {
-                //尝试从地区详情里面匹配省份名称
-                $db_province_data_list = $CitysModel->where([['level', '=', '1']])->select(['id', 'name'])->get()->toarray();
-                foreach ($db_province_data_list as $db_province_data) {
-                    $db_province_name = $db_province_data['name'];
-                    if (strpos($product_data['area_info'], $db_province_name) !== false) {
-                        $province_name = $db_province_name;
-                        $product_data['province_id'] = $db_province_data['id'];
-                        break;
-                    }
+                $db_city_id = $CitysModel->where([['name', '=', $city_name], ['level', '=', '2']])->value('id');
+                if (!empty($db_city_id)) {
+                    $product_data['city_id'] = $db_city_id;
+                } else {
+                    $city_name = '未知';
                 }
             }
-            if (trim($city_name) != '') {
-                //校验是否存在县这个字眼
-                if (strpos($city_name, '县') !== false) {
-                    $db_city_id = $CitysModel->where([['name', '=', $city_name], ['level', '=', '2']])->value('id');
-                    if (!empty($db_city_id)) {
+        } else {
+            if (trim($product_data['area_info']) != '') {
+                //尝试从地区详情里面匹配市名称
+                $db_city_name_list = $CitysModel->where([['level', '=', '2']])->pluck('name')->toarray();
+                foreach ($db_city_name_list as $db_city_name) {
+                    if (strpos($product_data['area_info'], $db_city_name) !== false) {
+                        $db_city_id = $CitysModel->where([['name', '=', $db_city_name], ['level', '=', '2']])->value('id');
                         $product_data['city_id'] = $db_city_id;
-                    }
-                } elseif (trim($city_name) != '' && strpos($city_name, '市') === false) {
-                    //是否存在市
-                    $city_name = $city_name . '市';
-                    //根据最新处理后的市名称获取市ID
-                    $db_city_id = $CitysModel->where([['name', '=', $city_name], ['level', '=', '2']])->value('id');
-                    if (!empty($db_city_id)) {
-                        $product_data['city_id'] = $db_city_id;
-                    } else {
-                        $city_name = '未知';
-                    }
-                } else {
-                    $db_city_id = $CitysModel->where([['name', '=', $city_name], ['level', '=', '2']])->value('id');
-                    if (!empty($db_city_id)) {
-                        $product_data['city_id'] = $db_city_id;
-                    } else {
-                        $city_name = '未知';
-                    }
-                }
-            } else {
-                if (trim($product_data['area_info']) != '') {
-                    //尝试从地区详情里面匹配市名称
-                    $db_city_name_list = $CitysModel->where([['level', '=', '2']])->pluck('name')->toarray();
-                    foreach ($db_city_name_list as $db_city_name) {
-                        if (strpos($product_data['area_info'], $db_city_name) !== false) {
-                            $db_city_id = $CitysModel->where([['name', '=', $db_city_name], ['level', '=', '2']])->value('id');
-                            $product_data['city_id'] = $db_city_id;
-                            $product_data['city_name'] = $db_city_name;
-                            $city_name = $db_city_name;
-                            break;
-                        }
+                        $product_data['city_name'] = $db_city_name;
+                        $city_name = $db_city_name;
+                        break;
                     }
                 }
             }
-            //如果存在市区city_id 则逆推省份ID以及名称
-            if (!empty($product_data['city_id']) && empty($product_data['province_id'])) {
-                $db_province_id = $CitysModel->where([['id', '=', $product_data['city_id']], ['level', '=', '2']])->value('pid');
-                $db_province_name = $CitysModel->where([['id', '=', $db_province_id], ['level', '=', '1']])->value('name');
-                $product_data['province_id'] = $db_province_id;
-                $product_data['province_name'] = $db_province_name;
-                $province_name = $db_province_name;
+        }
+        //如果存在市区city_id 则逆推省份ID以及名称
+        if (!empty($product_data['city_id']) && empty($product_data['province_id'])) {
+            $db_province_id = $CitysModel->where([['id', '=', $product_data['city_id']], ['level', '=', '2']])->value('pid');
+            $db_province_name = $CitysModel->where([['id', '=', $db_province_id], ['level', '=', '1']])->value('name');
+            $product_data['province_id'] = $db_province_id;
+            $product_data['province_name'] = $db_province_name;
+            $province_name = $db_province_name;
+        }
+        if (trim($product_data['area_info']) == '' && trim($city_name) != '' && trim($province_name) != '') {
+            $product_data['area_info'] = $province_name . $city_name;
+        }
+        //-------------------------------------- 处理营业执照地区信息(结束) --------------------------------------
+
+        //-------------------------------------- 处理发货省份地区信息(开始) --------------------------------------
+        $shipment_province_name = $product_data['shipment_province_name'];
+        $shipment_city_name = $product_data['shipment_city_name'];
+        //特殊地区1级移除市
+        if ($shipment_province_name && in_array($shipment_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;
             }
-            if (trim($product_data['area_info']) == '' && trim($city_name) != '' && trim($province_name) != '') {
-                $product_data['area_info'] = $province_name . $city_name;
+        } else if ($shipment_province_name && in_array($shipment_province_name, ['内蒙古自治区', '广西壮族自治区', '西藏自治区', '新疆维吾尔自治区', '宁夏回族自治区'])) {
+            //完整匹配不做处理
+        } else if (trim($shipment_province_name) != '' && strpos($shipment_province_name, '省') === false) {
+            //是否存在市省,如果不存在则补全
+            $shipment_province_name = $shipment_province_name . '省';
+        }
+        if (trim($shipment_province_name) != '') {
+            //根据最新处理后的省份名称获取省份ID
+            $db_shipment_province_id = $CitysModel->where([['name', '=', $shipment_province_name], ['level', '=', '1']])->value('id');
+            if (!empty($db_shipment_province_id)) {
+                $product_data['shipment_province_id'] = $db_shipment_province_id;
+            } else {
+                //逆推省份ID失败,则修改为未知名称
+                $shipment_province_name = '未知';
             }
-            //-------------------------------------- 处理营业执照地区信息(结束) --------------------------------------
-
-            //-------------------------------------- 处理发货省份地区信息(开始) --------------------------------------
-            $shipment_province_name = $product_data['shipment_province_name'];
-            $shipment_city_name = $product_data['shipment_city_name'];
-            //特殊地区1级移除市
-            if ($shipment_province_name && in_array($shipment_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;
+        }
+        if (trim($shipment_city_name) != '') {
+            //校验是否存在县这个字眼
+            if (strpos($shipment_city_name, '县') !== false) {
+                $db_shipment_city_id = $CitysModel->where([['name', '=', $shipment_city_name], ['level', '=', '2']])->value('id');
+                if (!empty($db_shipment_city_id)) {
+                    $product_data['shipment_city_id'] = $db_shipment_city_id;
                 }
-            } else if ($shipment_province_name && in_array($shipment_province_name, ['内蒙古自治区', '广西壮族自治区', '西藏自治区', '新疆维吾尔自治区', '宁夏回族自治区'])) {
-                //完整匹配不做处理
-            } else if (trim($shipment_province_name) != '' && strpos($shipment_province_name, '省') === false) {
-                //是否存在市省,如果不存在则补全
-                $shipment_province_name = $shipment_province_name . '省';
-            }
-            if (trim($shipment_province_name) != '') {
-                //根据最新处理后的省份名称获取省份ID
-                $db_shipment_province_id = $CitysModel->where([['name', '=', $shipment_province_name], ['level', '=', '1']])->value('id');
-                if (!empty($db_shipment_province_id)) {
-                    $product_data['shipment_province_id'] = $db_shipment_province_id;
+            } elseif (trim($shipment_city_name) != '' && strpos($shipment_city_name, '市') === false) {
+                //是否存在市
+                $shipment_city_name = $shipment_city_name . '市';
+                //根据最新处理后的市名称获取市ID
+                $db_shipment_city_id = $CitysModel->where([['name', '=', $shipment_city_name], ['level', '=', '2']])->value('id');
+                if (!empty($db_shipment_city_id)) {
+                    $product_data['shipment_city_id'] = $db_shipment_city_id;
                 } else {
-                    //逆推省份ID失败,则修改为未知名称
-                    $shipment_province_name = '未知';
+                    //逆推市ID失败,则修改为未知名称
+                    $shipment_city_name = '未知';
                 }
-            }
-            if (trim($shipment_city_name) != '') {
-                //校验是否存在县这个字眼
-                if (strpos($shipment_city_name, '县') !== false) {
-                    $db_shipment_city_id = $CitysModel->where([['name', '=', $shipment_city_name], ['level', '=', '2']])->value('id');
-                    if (!empty($db_shipment_city_id)) {
-                        $product_data['shipment_city_id'] = $db_shipment_city_id;
-                    }
-                } elseif (trim($shipment_city_name) != '' && strpos($shipment_city_name, '市') === false) {
-                    //是否存在市
-                    $shipment_city_name = $shipment_city_name . '市';
-                    //根据最新处理后的市名称获取市ID
-                    $db_shipment_city_id = $CitysModel->where([['name', '=', $shipment_city_name], ['level', '=', '2']])->value('id');
-                    if (!empty($db_shipment_city_id)) {
-                        $product_data['shipment_city_id'] = $db_shipment_city_id;
-                    } else {
-                        //逆推市ID失败,则修改为未知名称
-                        $shipment_city_name = '未知';
-                    }
+            } else {
+                $db_shipment_city_id = $CitysModel->where([['name', '=', $shipment_city_name], ['level', '=', '2']])->value('id');
+                if (!empty($db_shipment_city_id)) {
+                    $product_data['shipment_city_id'] = $db_shipment_city_id;
                 } else {
-                    $db_shipment_city_id = $CitysModel->where([['name', '=', $shipment_city_name], ['level', '=', '2']])->value('id');
-                    if (!empty($db_shipment_city_id)) {
-                        $product_data['shipment_city_id'] = $db_shipment_city_id;
-                    } else {
-                        //逆推市ID失败,则修改为未知名称
-                        $shipment_city_name = '未知';
-                    }
+                    //逆推市ID失败,则修改为未知名称
+                    $shipment_city_name = '未知';
                 }
             }
-            //如果存在市区shipment_city_id 则逆推省份ID以及名称
-            if (!empty($product_data['shipment_city_id']) && empty($product_data['shipment_province_id'])) {
-                $db_shipment_province_id = $CitysModel->where([['id', '=', $product_data['shipment_city_id']], ['level', '=', '2']])->value('pid');
-                $db_shipment_province_name = $CitysModel->where([['id', '=', $db_shipment_province_id], ['level', '=', '1']])->value('name');
-                $product_data['shipment_province_id'] = $db_shipment_province_id;
-                $product_data['shipment_province_name'] = $db_shipment_province_name;
-            }
-            //-------------------------------------- 处理发货省份地区信息(结束) --------------------------------------
-            //处理链接信息
-            preg_match('/https?:\/\/[^\s\'"<>]+/i', $product_data['link_url'], $matches);
-            if (!empty($matches)) {
-                $product_data['link_url'] = $matches[0];
-            }
-            if (trim($product_data['link_url']) == '') continue;
-            //合并省份市区ID
-            $merge_city_id = 0;
-            $merge_province_id = 0;
-            $merge_city_name = '';
-            $merge_province_name = '';
-            if (!empty($product_data['city_id']) && !empty($product_data['province_id'])) {
-                $merge_city_id = $product_data['city_id'];
-                $merge_province_id = $product_data['province_id'];
-                $merge_city_name = $city_name;
-                $merge_province_name = $province_name;
-            } else if (!empty($product_data['shipment_city_id']) && !empty($product_data['shipment_province_id'])) {
-                $merge_city_id = $product_data['shipment_city_id'];
-                $merge_province_id = $product_data['shipment_province_id'];
-                $merge_city_name = $shipment_city_name;
-                $merge_province_name = $shipment_province_name;
-            }
-            $insert_product_data = [
-                'company_id' => $company_id,
-                'source_id' => $product_data['id'],
-                'platform'    => $product_data['platform_id'],
-                'company_name'    => $product_data['company_name'],
-                'product_brand'    => $product_brand != '' ? $product_brand : $product_data['product_brand'],
-                'product_name'    => $product_name,
-                'product_specs'    => $product_specs,
-                'inventory'    => $product_data['inventory'] ? $product_data['inventory'] : '',
-                'sales'    => $product_data['sales'] ? $product_data['sales'] : '',
-                'snapshot_url' => $product_data['snapshot_url'] ? $product_data['snapshot_url'] : '',
-                'online_posting_count'    => $product_data['online_posting_count'],
-                'continuous_listing_count'    => $product_data['continuous_listing_count'],
-                'link_url'    => $product_data['link_url'],
-                'store_name'    => $product_data['store_name'],
-                'anonymous_store_name'    => $product_data['anonymous_store_name'],
-                'social_credit_code'    => $product_data['qualification_number'],
-                'province_id'    => $product_data['province_id'],
-                'province_name' => $province_name,
-                'city_id' => $product_data['city_id'],
-                'city_name' => $city_name,
-                'area_info' => $product_data['area_info'],
-                'category_name' => $category_name,
-                'company_category_name' => '',
-                'first_responsible_person' => '',
-                'responsible_person' => '',
-                'source_responsible_person' => '',
-                'scrape_date' => $product_data['scrape_date'],
-                'collection_time' => strtotime($product_data['insert_time']),
-                'shipment_province_id' => $product_data['shipment_province_id'],
-                'shipment_province_name' => $product_data['shipment_province_name'],
-                'shipment_city_id' => $product_data['shipment_city_id'],
-                'shipment_city_name' => $product_data['shipment_city_name'],
-                'collect_config_info' => $product_data['collect_config_info'],
-                'merge_city_id' => $merge_city_id,
-                'merge_province_id' => $merge_province_id,
-                'merge_city_name' => $merge_city_name,
-                'merge_province_name' => $merge_province_name,
-            ];
-            //获取指定人员信息
-            if ($specify_responsible_person == 0) {
-                //获取店铺责任人信息
-                $ViolationStoreModel = new ViolationStoreModel();
-                $store_data_info = $ViolationStoreModel->where('store_name', $product_data['store_name'])->first();
-                if (!empty($store_data_info) && trim($store_data_info->employee_ids) != '') {
-                    //查询店铺第一责任人信息
-                    $EmployeeModel = new EmployeeModel();
-                    $store_where_query = [];
-                    $employee_id_store = explode(',', $store_data_info->employee_ids);
-                    $store_where_query[] = ['company_id', '=', $company_id];
-                    $store_where_query[] = ['id', 'in', $employee_id_store];
-                    $store_where_query[] = ['status', '=', 0];
-                    $store_where_query[] = ['duty_type', '=', 1]; //责任类型1=第一责任人,2=责任人
-                    $first_responsible_person = $EmployeeModel->pluck('id')->implode(',');
-                    $insert_product_data['first_responsible_person'] = $first_responsible_person;
-                    //查询店铺责任人信息
-                    $EmployeeModel = new EmployeeModel();
-                    $store_where_query = [];
-                    $employee_id_store = explode(',', $store_data_info->employee_ids);
-                    $store_where_query[] = ['company_id', '=', $company_id];
-                    $store_where_query[] = ['id', 'in', $employee_id_store];
-                    $store_where_query[] = ['status', '=', 0];
-                    $store_where_query[] = ['duty_type', '=', 2]; //责任类型1=第一责任人,2=责任人
-                    $responsible_person = $EmployeeModel->pluck('id')->implode(',');
-                    $insert_product_data['responsible_person'] = $responsible_person;
-                    //溯源责任人
-                    $source_responsible_person = '';
-                    if ($first_responsible_person && $responsible_person) {
-                        //转换成数组,合并后在去重
-                        $first_responsible_person = explode(',', $first_responsible_person);
-                        $responsible_person = explode(',', $responsible_person);
-                        $source_responsible_person = array_unique(array_merge($first_responsible_person, $responsible_person));
-                        $source_responsible_person = ',' . implode(',', $source_responsible_person) . ',';
-                    } else if ($first_responsible_person) {
-                        $source_responsible_person = $first_responsible_person;
-                    } else if ($responsible_person) {
-                        $source_responsible_person = $responsible_person;
-                    }
-                    $insert_product_data['source_responsible_person'] = $source_responsible_person;
-                } else {
-                    //获取公司绑定责任人信息
-                    $company_data = $ViolationCompanyModel->leftjoin('washconfig_company_category', 'washconfig_company_category.id', '=', 'washconfig_violation_company.category_id')
-                        ->where('washconfig_violation_company.social_credit_code', $product_data['qualification_number'])
-                        ->where('washconfig_violation_company.company_id', $company_id)
-                        ->select(['washconfig_violation_company.id', 'washconfig_company_category.name as category_name'])->first();
-                    $employee_id_list = [];
-                    if ($company_data) {
-                        $employee_id_list = $ViolationCompanyMemberModel->where('company_logid', $company_data->id)->pluck('employee_id')->toarray();
-                        $insert_product_data['company_category_name'] = $company_data->category_name ? $company_data->category_name : '';
-                    }
-                    $where_query1 = [];
-                    $where_query2 = [];
-                    $where_query3 = [];
-                    //查询指定公司第一责任人
-                    if (!empty($employee_id_list)) {
-                        $where_query1[] = ['company_id', '=', $company_id];
-                        $where_query1[] = ['id', 'in', $employee_id_list];
-                        $where_query1[] = ['status', '=', 0];
-                        $where_query1[] = ['duty_type', '=', 1]; //责任类型1=第一责任人,2=责任人
-                    }
-                    //查询地区配置的第一责任人
-                    $employee_id_area = $EmployeeAreaModel->where('city_id', $product_data['city_id'])->pluck('employee_id')->toarray();
-                    if (!empty($employee_id_area)) {
-                        $where_query2[] = ['company_id', '=', $company_id];
-                        $where_query2[] = ['id', 'in', $employee_id_area];
-                        $where_query2[] = ['status', '=', 0];
-                        $where_query2[] = ['duty_type', '=', 1]; //责任类型1=第一责任人,2=责任人
-                    }
-                    //查询平台配置的第一责任人
-                    $employee_id_platform = $EmployeePlatformModel->where('platform_id', $product_data['platform_id'])->pluck('employee_id')->toarray();
-                    if (!empty($employee_id_platform)) {
-                        $where_query3[] = ['company_id', '=', $company_id];
-                        $where_query3[] = ['id', 'in', $employee_id_platform];
-                        $where_query3[] = ['status', '=', 0];
-                        $where_query3[] = ['duty_type', '=', 1]; //责任类型1=第一责任人,2=责任人
-                    }
-                    //并行查询第一责任人
-                    $EmployeeModel = new EmployeeModel();
-                    $EmployeeModel = $EmployeeModel
-                        ->orWhere(function ($q) use ($employee_id_list, $company_id) {
-                            if (!empty($employee_id_list)) {
-                                $q->where('company_id', $company_id)
-                                    ->orWhereIn('id', $employee_id_list)
-                                    ->where('duty_type', 1)
-                                    ->where('status', 0);
-                            }
-                        })->orWhere(function ($q) use ($employee_id_area, $company_id) {
-                            if (!empty($employee_id_area)) {
-                                $q->where('company_id', $company_id)
-                                    ->whereIn('id', $employee_id_area)
-                                    ->where('duty_type', 1)
-                                    ->where('status', 0);
-                            }
-                        })->orWhere(function ($q) use ($employee_id_platform, $company_id) {
-                            if (!empty($employee_id_platform)) {
-                                $q->where('company_id', $company_id)
-                                    ->whereIn('id', $employee_id_platform)
-                                    ->where('duty_type', 1)
-                                    ->where('status', 0);
-                            }
-                        });
-                    $first_responsible_person = $EmployeeModel->pluck('id')->implode(',');
-
-                    //当以上规则匹配不到责任人时,则去查询发货地区信息关联责任人
-                    if (trim($first_responsible_person) == '' && trim($product_data['shipment_city_id']) != '') {
-                        $employee_id_area = $EmployeeAreaModel->where('city_id', $product_data['city_id'])->pluck('employee_id')->toarray();
+        }
+        //如果存在市区shipment_city_id 则逆推省份ID以及名称
+        if (!empty($product_data['shipment_city_id']) && empty($product_data['shipment_province_id'])) {
+            $db_shipment_province_id = $CitysModel->where([['id', '=', $product_data['shipment_city_id']], ['level', '=', '2']])->value('pid');
+            $db_shipment_province_name = $CitysModel->where([['id', '=', $db_shipment_province_id], ['level', '=', '1']])->value('name');
+            $product_data['shipment_province_id'] = $db_shipment_province_id;
+            $product_data['shipment_province_name'] = $db_shipment_province_name;
+        }
+        //-------------------------------------- 处理发货省份地区信息(结束) --------------------------------------
+        //处理链接信息
+        preg_match('/https?:\/\/[^\s\'"<>]+/i', $product_data['link_url'], $matches);
+        if (!empty($matches)) {
+            $product_data['link_url'] = $matches[0];
+        }
+        //合并省份市区ID
+        $merge_city_id = 0;
+        $merge_province_id = 0;
+        $merge_city_name = '';
+        $merge_province_name = '';
+        if (!empty($product_data['city_id']) && !empty($product_data['province_id'])) {
+            $merge_city_id = $product_data['city_id'];
+            $merge_province_id = $product_data['province_id'];
+            $merge_city_name = $city_name;
+            $merge_province_name = $province_name;
+        } else if (!empty($product_data['shipment_city_id']) && !empty($product_data['shipment_province_id'])) {
+            $merge_city_id = $product_data['shipment_city_id'];
+            $merge_province_id = $product_data['shipment_province_id'];
+            $merge_city_name = $shipment_city_name;
+            $merge_province_name = $shipment_province_name;
+        }
+        $insert_product_data = [
+            'company_id' => $company_id,
+            'source_id' => $product_data['id'],
+            'platform'    => $product_data['platform_id'],
+            'company_name'    => $product_data['company_name'],
+            'product_brand'    => $product_brand != '' ? $product_brand : $product_data['product_brand'],
+            'product_name'    => $product_name,
+            'product_specs'    => $product_specs,
+            'inventory'    => $product_data['inventory'] ? $product_data['inventory'] : '',
+            'sales'    => $product_data['sales'] ? $product_data['sales'] : '',
+            'snapshot_url' => $product_data['snapshot_url'] ? $product_data['snapshot_url'] : '',
+            'online_posting_count'    => $product_data['online_posting_count'],
+            'continuous_listing_count'    => $product_data['continuous_listing_count'],
+            'link_url'    => $product_data['link_url'],
+            'store_name'    => $product_data['store_name'],
+            'anonymous_store_name'    => $product_data['anonymous_store_name'],
+            'social_credit_code'    => $product_data['qualification_number'],
+            'province_id'    => $product_data['province_id'],
+            'province_name' => $province_name,
+            'city_id' => $product_data['city_id'],
+            'city_name' => $city_name,
+            'area_info' => $product_data['area_info'],
+            'category_name' => $category_name,
+            'company_category_name' => '',
+            'first_responsible_person' => '',
+            'responsible_person' => '',
+            'source_responsible_person' => '',
+            'scrape_date' => $product_data['scrape_date'],
+            'collection_time' => strtotime($product_data['insert_time']),
+            'shipment_province_id' => $product_data['shipment_province_id'],
+            'shipment_province_name' => $product_data['shipment_province_name'],
+            'shipment_city_id' => $product_data['shipment_city_id'],
+            'shipment_city_name' => $product_data['shipment_city_name'],
+            'collect_config_info' => $product_data['collect_config_info'],
+            'merge_city_id' => $merge_city_id,
+            'merge_province_id' => $merge_province_id,
+            'merge_city_name' => $merge_city_name,
+            'merge_province_name' => $merge_province_name,
+        ];
+        //获取指定人员信息
+        if ($specify_responsible_person == 0) {
+            //获取店铺责任人信息
+            $ViolationStoreModel = new ViolationStoreModel();
+            $store_data_info = $ViolationStoreModel->where('store_name', $product_data['store_name'])->first();
+            if (!empty($store_data_info) && trim($store_data_info->employee_ids) != '') {
+                //查询店铺第一责任人信息
+                $EmployeeModel = new EmployeeModel();
+                $store_where_query = [];
+                $employee_id_store = explode(',', $store_data_info->employee_ids);
+                $store_where_query[] = ['company_id', '=', $company_id];
+                $store_where_query[] = ['id', 'in', $employee_id_store];
+                $store_where_query[] = ['status', '=', 0];
+                $store_where_query[] = ['duty_type', '=', 1]; //责任类型1=第一责任人,2=责任人
+                $first_responsible_person = $EmployeeModel->pluck('id')->implode(',');
+                $insert_product_data['first_responsible_person'] = $first_responsible_person;
+                //查询店铺责任人信息
+                $EmployeeModel = new EmployeeModel();
+                $store_where_query = [];
+                $employee_id_store = explode(',', $store_data_info->employee_ids);
+                $store_where_query[] = ['company_id', '=', $company_id];
+                $store_where_query[] = ['id', 'in', $employee_id_store];
+                $store_where_query[] = ['status', '=', 0];
+                $store_where_query[] = ['duty_type', '=', 2]; //责任类型1=第一责任人,2=责任人
+                $responsible_person = $EmployeeModel->pluck('id')->implode(',');
+                $insert_product_data['responsible_person'] = $responsible_person;
+                //溯源责任人
+                $source_responsible_person = '';
+                if ($first_responsible_person && $responsible_person) {
+                    //转换成数组,合并后在去重
+                    $first_responsible_person = explode(',', $first_responsible_person);
+                    $responsible_person = explode(',', $responsible_person);
+                    $source_responsible_person = array_unique(array_merge($first_responsible_person, $responsible_person));
+                    $source_responsible_person = ',' . implode(',', $source_responsible_person) . ',';
+                } else if ($first_responsible_person) {
+                    $source_responsible_person = $first_responsible_person;
+                } else if ($responsible_person) {
+                    $source_responsible_person = $responsible_person;
+                }
+                $insert_product_data['source_responsible_person'] = $source_responsible_person;
+            } else {
+                //获取公司绑定责任人信息
+                $company_data = $ViolationCompanyModel->leftjoin('washconfig_company_category', 'washconfig_company_category.id', '=', 'washconfig_violation_company.category_id')
+                    ->where('washconfig_violation_company.social_credit_code', $product_data['qualification_number'])
+                    ->where('washconfig_violation_company.company_id', $company_id)
+                    ->select(['washconfig_violation_company.id', 'washconfig_company_category.name as category_name'])->first();
+                $employee_id_list = [];
+                if ($company_data) {
+                    $employee_id_list = $ViolationCompanyMemberModel->where('company_logid', $company_data->id)->pluck('employee_id')->toarray();
+                    $insert_product_data['company_category_name'] = $company_data->category_name ? $company_data->category_name : '';
+                }
+                $where_query1 = [];
+                $where_query2 = [];
+                $where_query3 = [];
+                //查询指定公司第一责任人
+                if (!empty($employee_id_list)) {
+                    $where_query1[] = ['company_id', '=', $company_id];
+                    $where_query1[] = ['id', 'in', $employee_id_list];
+                    $where_query1[] = ['status', '=', 0];
+                    $where_query1[] = ['duty_type', '=', 1]; //责任类型1=第一责任人,2=责任人
+                }
+                //查询地区配置的第一责任人
+                $employee_id_area = $EmployeeAreaModel->where('city_id', $product_data['city_id'])->pluck('employee_id')->toarray();
+                if (!empty($employee_id_area)) {
+                    $where_query2[] = ['company_id', '=', $company_id];
+                    $where_query2[] = ['id', 'in', $employee_id_area];
+                    $where_query2[] = ['status', '=', 0];
+                    $where_query2[] = ['duty_type', '=', 1]; //责任类型1=第一责任人,2=责任人
+                }
+                //查询平台配置的第一责任人
+                $employee_id_platform = $EmployeePlatformModel->where('platform_id', $product_data['platform_id'])->pluck('employee_id')->toarray();
+                if (!empty($employee_id_platform)) {
+                    $where_query3[] = ['company_id', '=', $company_id];
+                    $where_query3[] = ['id', 'in', $employee_id_platform];
+                    $where_query3[] = ['status', '=', 0];
+                    $where_query3[] = ['duty_type', '=', 1]; //责任类型1=第一责任人,2=责任人
+                }
+                //并行查询第一责任人
+                $EmployeeModel = new EmployeeModel();
+                $EmployeeModel = $EmployeeModel
+                    ->orWhere(function ($q) use ($employee_id_list, $company_id) {
+                        if (!empty($employee_id_list)) {
+                            $q->where('company_id', $company_id)
+                                ->orWhereIn('id', $employee_id_list)
+                                ->where('duty_type', 1)
+                                ->where('status', 0);
+                        }
+                    })->orWhere(function ($q) use ($employee_id_area, $company_id) {
                         if (!empty($employee_id_area)) {
-                            $where_city[] = ['company_id', '=', $company_id];
-                            $where_city[] = ['id', 'in', $employee_id_area];
-                            $where_city[] = ['status', '=', 0];
-                            $where_city[] = ['duty_type', '=', 1]; //责任类型1=第一责任人,2=责任人
-                            $EmployeeModel = new EmployeeModel();
-                            $first_responsible_person = $EmployeeModel->where($where_city)->pluck('id')->implode(',');
+                            $q->where('company_id', $company_id)
+                                ->whereIn('id', $employee_id_area)
+                                ->where('duty_type', 1)
+                                ->where('status', 0);
                         }
-                    }
+                    })->orWhere(function ($q) use ($employee_id_platform, $company_id) {
+                        if (!empty($employee_id_platform)) {
+                            $q->where('company_id', $company_id)
+                                ->whereIn('id', $employee_id_platform)
+                                ->where('duty_type', 1)
+                                ->where('status', 0);
+                        }
+                    });
+                $first_responsible_person = $EmployeeModel->pluck('id')->implode(',');
 
-                    //调试记录查询条件
-                    $insert_product_data['first_responsible_person'] = $first_responsible_person;
-                    //查询责任人
-                    $where_query1 = [];
-                    $where_query2 = [];
-                    $where_query3 = [];
-                    //查询指定公司责任人
-                    if (!empty($employee_id_list)) {
-                        $where_query1[] = ['company_id', '=', $company_id];
-                        $where_query1[] = ['id', 'in', $employee_id_list];
-                        $where_query1[] = ['status', '=', 0];
-                        $where_query1[] = ['duty_type', '=', 2]; //责任类型1=第一责任人,2=责任人
-                    }
-                    //查询地区配置的员工
+                //当以上规则匹配不到责任人时,则去查询发货地区信息关联责任人
+                if (trim($first_responsible_person) == '' && trim($product_data['shipment_city_id']) != '') {
                     $employee_id_area = $EmployeeAreaModel->where('city_id', $product_data['city_id'])->pluck('employee_id')->toarray();
                     if (!empty($employee_id_area)) {
-                        $where_query2[] = ['company_id', '=', $company_id];
-                        $where_query2[] = ['id', 'in', $employee_id_area];
-                        $where_query2[] = ['status', '=', 0];
-                        $where_query2[] = ['duty_type', '=', 2]; //责任类型1=第一责任人,2=责任人
-                    }
-                    //查询平台配置的员工
-                    $employee_id_platform = $EmployeePlatformModel->where('platform_id', $product_data['platform_id'])->pluck('employee_id')->toarray();
-                    if (!empty($employee_id_platform)) {
-                        $where_query3[] = ['company_id', '=', $company_id];
-                        $where_query3[] = ['id', 'in', $employee_id_platform];
-                        $where_query3[] = ['status', '=', 0];
-                        $where_query3[] = ['duty_type', '=', 2]; //责任类型1=第一责任人,2=责任人
+                        $where_city[] = ['company_id', '=', $company_id];
+                        $where_city[] = ['id', 'in', $employee_id_area];
+                        $where_city[] = ['status', '=', 0];
+                        $where_city[] = ['duty_type', '=', 1]; //责任类型1=第一责任人,2=责任人
+                        $EmployeeModel = new EmployeeModel();
+                        $first_responsible_person = $EmployeeModel->where($where_city)->pluck('id')->implode(',');
                     }
-                    //并行查询责任人
-                    $EmployeeModel = new EmployeeModel();
-                    $EmployeeModel = $EmployeeModel
-                        ->orWhere(function ($q) use ($employee_id_list, $company_id) {
-                            if (!empty($employee_id_list)) {
-                                $q->where('company_id', $company_id)
-                                    ->orWhereIn('id', $employee_id_list)
-                                    ->where('duty_type', 2)
-                                    ->where('status', 0);
-                            }
-                        })->orWhere(function ($q) use ($employee_id_area, $company_id) {
-                            if (!empty($employee_id_area)) {
-                                $q->where('company_id', $company_id)
-                                    ->whereIn('id', $employee_id_area)
-                                    ->where('duty_type', 2)
-                                    ->where('status', 0);
-                            }
-                        })->orWhere(function ($q) use ($employee_id_platform, $company_id) {
-                            if (!empty($employee_id_platform)) {
-                                $q->where('company_id', $company_id)
-                                    ->whereIn('id', $employee_id_platform)
-                                    ->where('duty_type', 2)
-                                    ->where('status', 0);
-                            }
-                        });
-                    $responsible_person = $EmployeeModel->pluck('id')->implode(',');
+                }
 
-                    //当以上规则匹配不到责任人时,则去查询发货地区信息关联责任人
-                    if (trim($responsible_person) == '' && trim($product_data['shipment_city_id']) != '') {
-                        $employee_id_area = $EmployeeAreaModel->where('city_id', $product_data['city_id'])->pluck('employee_id')->toarray();
+                //调试记录查询条件
+                $insert_product_data['first_responsible_person'] = $first_responsible_person;
+                //查询责任人
+                $where_query1 = [];
+                $where_query2 = [];
+                $where_query3 = [];
+                //查询指定公司责任人
+                if (!empty($employee_id_list)) {
+                    $where_query1[] = ['company_id', '=', $company_id];
+                    $where_query1[] = ['id', 'in', $employee_id_list];
+                    $where_query1[] = ['status', '=', 0];
+                    $where_query1[] = ['duty_type', '=', 2]; //责任类型1=第一责任人,2=责任人
+                }
+                //查询地区配置的员工
+                $employee_id_area = $EmployeeAreaModel->where('city_id', $product_data['city_id'])->pluck('employee_id')->toarray();
+                if (!empty($employee_id_area)) {
+                    $where_query2[] = ['company_id', '=', $company_id];
+                    $where_query2[] = ['id', 'in', $employee_id_area];
+                    $where_query2[] = ['status', '=', 0];
+                    $where_query2[] = ['duty_type', '=', 2]; //责任类型1=第一责任人,2=责任人
+                }
+                //查询平台配置的员工
+                $employee_id_platform = $EmployeePlatformModel->where('platform_id', $product_data['platform_id'])->pluck('employee_id')->toarray();
+                if (!empty($employee_id_platform)) {
+                    $where_query3[] = ['company_id', '=', $company_id];
+                    $where_query3[] = ['id', 'in', $employee_id_platform];
+                    $where_query3[] = ['status', '=', 0];
+                    $where_query3[] = ['duty_type', '=', 2]; //责任类型1=第一责任人,2=责任人
+                }
+                //并行查询责任人
+                $EmployeeModel = new EmployeeModel();
+                $EmployeeModel = $EmployeeModel
+                    ->orWhere(function ($q) use ($employee_id_list, $company_id) {
+                        if (!empty($employee_id_list)) {
+                            $q->where('company_id', $company_id)
+                                ->orWhereIn('id', $employee_id_list)
+                                ->where('duty_type', 2)
+                                ->where('status', 0);
+                        }
+                    })->orWhere(function ($q) use ($employee_id_area, $company_id) {
                         if (!empty($employee_id_area)) {
-                            $where_city[] = ['company_id', '=', $company_id];
-                            $where_city[] = ['id', 'in', $employee_id_area];
-                            $where_city[] = ['status', '=', 0];
-                            $where_city[] = ['duty_type', '=', 2]; //责任类型1=第一责任人,2=责任人
-                            $EmployeeModel = new EmployeeModel();
-                            $responsible_person = $EmployeeModel->where($where_city)->pluck('id')->implode(',');
+                            $q->where('company_id', $company_id)
+                                ->whereIn('id', $employee_id_area)
+                                ->where('duty_type', 2)
+                                ->where('status', 0);
                         }
-                    }
-                    $insert_product_data['responsible_person'] = $responsible_person;
+                    })->orWhere(function ($q) use ($employee_id_platform, $company_id) {
+                        if (!empty($employee_id_platform)) {
+                            $q->where('company_id', $company_id)
+                                ->whereIn('id', $employee_id_platform)
+                                ->where('duty_type', 2)
+                                ->where('status', 0);
+                        }
+                    });
+                $responsible_person = $EmployeeModel->pluck('id')->implode(',');
 
-                    //溯源责任人
-                    $source_responsible_person = '';
-                    if ($first_responsible_person && $responsible_person) {
-                        //转换成数组,合并后在去重
-                        $first_responsible_person = explode(',', $first_responsible_person);
-                        $responsible_person = explode(',', $responsible_person);
-                        $source_responsible_person = array_unique(array_merge($first_responsible_person, $responsible_person));
-                        $source_responsible_person = ',' . implode(',', $source_responsible_person) . ',';
-                    } else if ($first_responsible_person) {
-                        $source_responsible_person = $first_responsible_person;
-                    } else if ($responsible_person) {
-                        $source_responsible_person = $responsible_person;
+                //当以上规则匹配不到责任人时,则去查询发货地区信息关联责任人
+                if (trim($responsible_person) == '' && trim($product_data['shipment_city_id']) != '') {
+                    $employee_id_area = $EmployeeAreaModel->where('city_id', $product_data['city_id'])->pluck('employee_id')->toarray();
+                    if (!empty($employee_id_area)) {
+                        $where_city[] = ['company_id', '=', $company_id];
+                        $where_city[] = ['id', 'in', $employee_id_area];
+                        $where_city[] = ['status', '=', 0];
+                        $where_city[] = ['duty_type', '=', 2]; //责任类型1=第一责任人,2=责任人
+                        $EmployeeModel = new EmployeeModel();
+                        $responsible_person = $EmployeeModel->where($where_city)->pluck('id')->implode(',');
                     }
-                    $insert_product_data['source_responsible_person'] = $source_responsible_person;
                 }
+                $insert_product_data['responsible_person'] = $responsible_person;
+
+                //溯源责任人
+                $source_responsible_person = '';
+                if ($first_responsible_person && $responsible_person) {
+                    //转换成数组,合并后在去重
+                    $first_responsible_person = explode(',', $first_responsible_person);
+                    $responsible_person = explode(',', $responsible_person);
+                    $source_responsible_person = array_unique(array_merge($first_responsible_person, $responsible_person));
+                    $source_responsible_person = ',' . implode(',', $source_responsible_person) . ',';
+                } else if ($first_responsible_person) {
+                    $source_responsible_person = $first_responsible_person;
+                } else if ($responsible_person) {
+                    $source_responsible_person = $responsible_person;
+                }
+                $insert_product_data['source_responsible_person'] = $source_responsible_person;
             }
+        }
 
-            //插入数据
-            $ViolationProductModel->addViolationProduct($insert_product_data);
+        //插入数据
+        $ViolationProductModel->addViolationProduct($insert_product_data);
+        if ($index_number == $data_totle) {
+            (new ExecuteLogModel())->where('id', $executeLog_id)->update(['status' => 0, 'update_time' => time()]);
         }
-        //继续执行下一页
-        $message_data['page'] = $page + 1;
-        $message_data['limit'] = $limit;
-        ViolationProductDataJobs::dispatch($message_data)->delay(now()->addSeconds(3));
     }
 
 

+ 9 - 12
app/Jobs/Manager/Process/ViolationProductJobs.php

@@ -13,7 +13,6 @@ use App\Models\Manager\WashConfig\ViolationProduct as ConfigViolationProductMode
 use App\Models\Manager\Process\ExecuteLog as ExecuteLogModel;
 use App\Jobs\Manager\Process\ViolationProductDataJobs;
 use App\Models\Manager\WashConfig\ViolationProductCompany as ViolationProductCompanyModel;
-use Illuminate\Support\Carbon;
 
 /**
  * 数据清洗-违规挂网商品队列
@@ -47,17 +46,18 @@ class ViolationProductJobs implements ShouldQueue
     public function handle()
     {
         try {
-            // $start_time = Carbon::today()->startOfDay()->getTimestamp(); // 今天开始时间 00:00:00
-            $start_time = time() - 60 * 5; // 开始时间 5分钟之前
-            $end_time = time(); //结束时间
             $ConfigViolationProductModel = new ConfigViolationProductModel();
             $ViolationProductCompanyModel = new ViolationProductCompanyModel();
-            $limit = isset($this->message_data['limit']) ? $this->message_data['limit'] : 50;
+            $limit = isset($this->message_data['limit']) ? $this->message_data['limit'] : 1000;
             $page = isset($this->message_data['page']) ? $this->message_data['page'] : 1;
             $executeLog_id = isset($this->message_data['executeLog_id']) ? $this->message_data['executeLog_id'] : 0;
             $admin_id = isset($this->message_data['admin_id']) ? $this->message_data['admin_id'] : 0;
             $is_admin = isset($this->message_data['is_admin']) ? $this->message_data['is_admin'] : 0;
             $company_id = isset($this->message_data['company_id']) ? $this->message_data['company_id'] : 0;
+            $product_data = isset($this->message_data['product_data']) ? $this->message_data['product_data'] : [];
+            $index_number = isset($this->message_data['index_number']) ? $this->message_data['index_number'] : 0;
+            $data_totle = isset($this->message_data['data_totle']) ? $this->message_data['data_totle'] : 0;
+
             if($page == 1){
                 $ExecuteLogModel = new ExecuteLogModel();
                 $insert_data =['company_id'=> $company_id,'name' =>'违规挂网商品', 'code' => 'ViolationProductJobs', 'admin_id' => $admin_id,'is_admin' => $is_admin];
@@ -69,7 +69,6 @@ class ViolationProductJobs implements ShouldQueue
             if($company_id){
                 $ConfigViolationProductModel = $ConfigViolationProductModel->where('washconfig_violation_product.company_id', $company_id);
             }
-            $totle_page = 0;
             $list_config_data = $ConfigViolationProductModel->with(['product_keyword'])->paginate($limit, ['*'], 'page', $page)->toarray();
             if (!$list_config_data || empty($list_config_data['data'])) {
                 if($page == 1 && $executeLog_id){
@@ -77,7 +76,6 @@ class ViolationProductJobs implements ShouldQueue
                 }
                 return true;
             }
-            $totle_page = $list_config_data['last_page'];
             $list_data = $list_config_data['data'];
             foreach ($list_data as $key => $value) {
                 $company_data = $ViolationProductCompanyModel->where('washconfig_violation_product_company.violation_product_logid', $value['id'])
@@ -100,10 +98,9 @@ class ViolationProductJobs implements ShouldQueue
                     'specify_responsible_person' => $value['specify_responsible_person'],
                     'product_brand' => $value['product_brand'],
                     'product_keyword' => $value['product_keyword'],
-                    'item_totle_page' => $totle_page,
-                    'item_now_page' => $page,
-                    'start_time' => $start_time,
-                    'end_time' => $end_time,
+                    'product_data'   => $product_data,
+                    'index_number'   => $index_number,
+                    'data_totle'     => $data_totle,
                 ];
                 ViolationProductDataJobs::dispatch($message_data);
                 // ViolationProductDataJobs::dispatchSync($message_data);
@@ -113,7 +110,7 @@ class ViolationProductJobs implements ShouldQueue
                 'page' => $page + 1,
                 'executeLog_id' => $executeLog_id,
             ];
-            ViolationProductJobs::dispatch($now_message_data)->delay(now()->addSeconds(3));
+            ViolationProductJobs::dispatch($now_message_data)->delay(now()->addSeconds(1));
         } catch (\Exception $e) {
             Log::info('job_error', '数据清洗-违规挂网商品队列失败', ['data' => $this->message_data, 'error' => $e->getMessage()]);
         }

+ 0 - 300
app/Jobs/Manager/Process/ViolationStoreDataJobs.php

@@ -1,300 +0,0 @@
-<?php
-
-namespace App\Jobs\Manager\Process;
-
-use Illuminate\Bus\Queueable;
-use Illuminate\Contracts\Queue\ShouldBeUnique;
-use Illuminate\Contracts\Queue\ShouldQueue;
-use Illuminate\Foundation\Bus\Dispatchable;
-use Illuminate\Queue\InteractsWithQueue;
-use Illuminate\Queue\SerializesModels;
-use App\Facades\Servers\Logs\Log;
-use App\Models\Manager\Process\ViolationStore as ViolationStoreModel;
-use App\Models\Manager\Personnel\Employee as EmployeeModel;
-use App\Models\Api\Process\ExecuteLog as ExecuteLogModel;
-use App\Models\Manager\Process\ScrapeData as ScrapeDataModel;
-use App\Models\Manager\WashConfig\ViolationCompanyMember as ViolationCompanyMemberModel;
-use App\Models\Manager\Citys as CitysModel;
-use App\Models\Manager\Personnel\EmployeePlatform as EmployeePlatformModel;
-use App\Models\Manager\Personnel\EmployeeArea as EmployeeAreaModel;
-use Illuminate\Support\Facades\DB;
-use Illuminate\Support\Carbon;
-
-/**
- * 数据清洗-违规店铺清洗数据队列
- * @author  唐远望
- * @version 1.0
- * @date  2025-12-11
- */
-class ViolationStoreDataJobs implements ShouldQueue
-{
-    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
-        
-    public $tries = 3; // 限制重试次数
-    public $timeout = 600; // 5分钟超时
-
-    protected $message_data;
-    /**
-     * Create a new job instance.
-     *
-     * @return void
-     */
-    public function __construct(array $message_data)
-    {
-        $this->message_data = $message_data;
-    }
-
-    /**
-     * Execute the job.
-     *
-     * @return void
-     */
-    public function handle()
-    {
-        try {
-            $this->getViolationStoreData($this->message_data);
-        } catch (\Exception $e) {
-            Log::info('job_error', '数据清洗-违规店铺清洗数据队列失败', ['data' => $this->message_data, 'error' => $e->getMessage()]);
-        }
-    }
-
-
-    /**
-     * 采集商品数据清洗
-     * @author  唐远望
-     * @version 1.0
-     * @date  2025-12-11
-     */
-    public function getViolationStoreData($message_data)
-    {
-        $CitysModel = new CitysModel();
-        $EmployeeModel = new EmployeeModel();
-        $ViolationStoreModel = new ViolationStoreModel();
-        $ScrapeDataModel = new ScrapeDataModel();
-        $ViolationCompanyMemberModel = new ViolationCompanyMemberModel();
-        $EmployeePlatformModel = new EmployeePlatformModel();
-        $EmployeeAreaModel = new EmployeeAreaModel();
-        $platform = $message_data['platform']; //多个平台配置
-        $executeLog_id = $message_data['executeLog_id'];
-        $store_name = $message_data['store_name']; //店铺名称
-        $specify_responsible_person = $message_data['specify_responsible_person']; //指派责任人 0=开启 1=关闭
-        $limit = isset($message_data['limit']) ? $message_data['limit'] : 10;
-        $page = isset($message_data['page']) ? $message_data['page'] : 1;
-        $company_id = isset($message_data['company_id']) ? $message_data['company_id'] : 0; //品牌方公司ID
-        $item_totle_page = $message_data['item_totle_page']; //清洗店铺总页数
-        $item_now_page = $message_data['item_now_page']; //清洗店铺当前页
-        $employee_ids = $message_data['employee_ids']; //指派责任人ID列表
-
-        $start_time =$message_data['start_time'];
-        $end_time = $message_data['end_time'];
-        $start_time_string = date('Y-m-d H:i:s', $start_time);
-        $end_time_string = date('Y-m-d H:i:s', $end_time);
-        $where_map[] = ['insert_time', '>=', $start_time_string];
-        $where_map[] = ['insert_time', '<=', $end_time_string];
-
-        if ($platform != '0' && !empty($platform)) {
-            $platform = explode(',', $platform);
-            $ScrapeDataModel = $ScrapeDataModel->where('store_name', $store_name)->where($where_map)->whereIn('platform_id', $platform);
-        } else {
-            $ScrapeDataModel = $ScrapeDataModel->where('store_name', $store_name)->where($where_map);
-        }
-        $product_data_info = $ScrapeDataModel->paginate($limit, ['*'], 'page', $page)->toarray();
-        $product_datas = $product_data_info['data'];
-        if (empty($product_datas)) {
-            if ($executeLog_id && $item_now_page >= $item_totle_page) {
-                (new ExecuteLogModel())->where('id', $executeLog_id)->update(['status' => 0, 'update_time' => time()]);
-            }
-            return true;
-        }
-        foreach ($product_datas as $product_data) {
-            //-------------------------------------- 处理营业执照地区信息(开始) --------------------------------------
-            $province_name = $product_data['province_name'];
-            $city_name = $product_data['city_name'];
-            //特殊地区1级移除市
-            if ($province_name && in_array($province_name, ['北京市', '天津市', '上海市', '重庆市'])) {
-                //移除市这个字符
-                $province_name = trim(str_replace('市', '', $province_name));
-            } else if ($province_name && in_array($province_name, ['北京', '天津', '上海', '重庆'])) {
-            } else if ($province_name && in_array($province_name, ['内蒙古', '广西', '西藏', '新疆', '宁夏'])) {
-                switch ($province_name) {
-                    case '内蒙古':
-                        $province_name = '内蒙古自治区';
-                        break;
-                    case '广西':
-                        $province_name = '广西壮族自治区';
-                        break;
-                    case '西藏':
-                        $province_name = '西藏自治区';
-                        break;
-                    case '新疆':
-                        $province_name = '新疆维吾尔自治区';
-                        break;
-                    case '宁夏':
-                        $province_name = '宁夏回族自治区';
-                        break;
-                }
-            } else if ($province_name && in_array($province_name, ['内蒙古自治区', '广西壮族自治区', '西藏自治区', '新疆维吾尔自治区', '宁夏回族自治区'])) {
-                //完整匹配不做处理
-            } else if (trim($province_name) != '' && strpos($province_name, '省') === false) {
-                //是否存在市省,如果不存在则补全
-                $province_name = $province_name . '省';
-            }
-            if (trim($province_name) != '') {
-                //根据最新处理后的省份名称获取省份ID
-                $db_province_id = $CitysModel->where([['name', '=', $province_name], ['level', '=', '1']])->value('id');
-                if (!empty($db_province_id)) {
-                    $product_data['province_id'] = $db_province_id;
-                }else{
-                    //逆推省份ID失败,则修改为未知名称
-                    $province_name ='未知';
-                }
-            } else {
-                //尝试从地区详情里面匹配省份名称
-                $db_province_data_list = $CitysModel->where([['level', '=', '1']])->select(['id','name'])->get()->toarray();
-                foreach ($db_province_data_list as $db_province_data) {
-                    $db_province_name = $db_province_data['name'];
-                    if (strpos($product_data['area_info'], $db_province_name) !== false) {
-                        $province_name = $db_province_name;
-                        $product_data['province_id'] = $db_province_data['id'];
-                        break;
-                    }
-                }
-            }
-            if (trim($city_name) != '') {
-                //校验是否存在县这个字眼
-                if (strpos($city_name, '县') !== false) {
-                    $db_city_id = $CitysModel->where([['name', '=', $city_name], ['level', '=', '2']])->value('id');
-                    if (!empty($db_city_id)) {
-                        $product_data['city_id'] = $db_city_id;
-                    }
-                } elseif (trim($city_name) != '' && strpos($city_name, '市') === false) {
-                    //是否存在市
-                    $city_name = $city_name . '市';
-                    //根据最新处理后的市名称获取市ID
-                    $db_city_id = $CitysModel->where([['name', '=', $city_name], ['level', '=', '2']])->value('id');
-                    if (!empty($db_city_id)) {
-                        $product_data['city_id'] = $db_city_id;
-                    }else{
-                        $city_name ='未知';
-                    }
-                } else {
-                    $db_city_id = $CitysModel->where([['name', '=', $city_name], ['level', '=', '2']])->value('id');
-                    if (!empty($db_city_id)) {
-                        $product_data['city_id'] = $db_city_id;
-                    }else{
-                        $city_name ='未知';
-                    }
-                }
-            } else {
-                if (trim($product_data['area_info']) != '') {
-                    //尝试从地区详情里面匹配市名称
-                    $db_city_name_list = $CitysModel->where([['level', '=', '2']])->pluck('name')->toarray();
-                    foreach ($db_city_name_list as $db_city_name) {
-                        if (strpos($product_data['area_info'], $db_city_name) !== false) {
-                            $db_city_id = $CitysModel->where([['name', '=', $db_city_name], ['level', '=', '2']])->value('id');
-                            $product_data['city_id'] = $db_city_id;
-                            $product_data['city_name'] = $db_city_name;
-                            $city_name = $db_city_name;
-                            break;
-                        }
-                    }
-                }
-            }
-            //如果存在市区city_id 则逆推省份ID以及名称
-            if (!empty($product_data['city_id']) && empty($product_data['province_id'])) {
-                $db_province_id = $CitysModel->where([['id', '=', $product_data['city_id']], ['level', '=', '2']])->value('pid');
-                $db_province_name = $CitysModel->where([['id', '=', $db_province_id], ['level', '=', '1']])->value('name');
-                $product_data['province_id'] = $db_province_id;
-                $product_data['province_name'] = $db_province_name;
-                $province_name = $db_province_name;
-            }
-            if (trim($product_data['area_info']) == '' && trim($city_name) != '' && trim($province_name) != '') {
-                $product_data['area_info'] = $province_name . $city_name;
-            }
-            //-------------------------------------- 处理营业执照地区信息(结束) --------------------------------------
-
-            //处理链接信息
-            preg_match('/https?:\/\/[^\s\'"<>]+/i', $product_data['link_url'], $matches);
-            if (!empty($matches)) {
-                $product_data['link_url'] = $matches[0];
-            }
-            $store_name = $product_data['store_name'];
-            $anonymous_store_name = $product_data['anonymous_store_name'];
-            if ($anonymous_store_name != '') {
-                $store_name = $anonymous_store_name;
-            }
-            $insert_product_data = [
-                'company_id' => $company_id,
-                'source_id' => $product_data['id'],
-                'platform'    => $product_data['platform_id'],
-                'company_name'    => $product_data['company_name'],
-                'link_url'    => $product_data['link_url'],
-                'store_name'    => $store_name,
-                'social_credit_code' => $product_data['qualification_number'],
-                'province_id'    => $product_data['province_id'],
-                'province_name' => $province_name,
-                'city_id' => $product_data['city_id'],
-                'city_name' => $city_name,
-                'area_info' => $product_data['area_info'],
-                'company_category_name' => '',
-                'first_responsible_person' => '',
-                'responsible_person' => '',
-                'source_responsible_person' => '',
-                'scrape_date' => $product_data['scrape_date'],
-                'collection_time' => strtotime($product_data['insert_time']),
-            ];
-            $employee_id_list = explode(',', $employee_ids);
-            //获取指定人员信息
-            if ($specify_responsible_person == 0) {
-                $first_responsible_person ='';
-                //查询第一责任人
-                if (!empty($employee_id_list)) {
-                    $where_query1[] = ['company_id', '=', $company_id];
-                    $where_query1[] = ['id', 'in', $employee_id_list];
-                    $where_query1[] = ['status', '=', 0];
-                    $where_query1[] = ['duty_type', '=', 1]; //责任类型1=第一责任人,2=责任人
-                    $first_responsible_person = $EmployeeModel->where($where_query1)->pluck('id')->implode(',');
-                }
-                $insert_product_data['first_responsible_person'] = $first_responsible_person;
-                //查询责任人
-                $responsible_person ='';
-                if (!empty($employee_id_list)) {
-                    $where_query2[] = ['company_id', '=', $company_id];
-                    $where_query2[] = ['id', 'in', $employee_id_list];
-                    $where_query2[] = ['status', '=', 0];
-                    $where_query2[] = ['duty_type', '=', 2]; //责任类型1=第一责任人,2=责任人
-                    $responsible_person = $EmployeeModel->where($where_query2)->pluck('id')->implode(',');
-                }
-                $insert_product_data['responsible_person'] = $responsible_person;
-
-                //溯源责任人
-                $source_responsible_person = '';
-                if ($first_responsible_person && $responsible_person) {
-                    //转换成数组,合并后在去重
-                    $first_responsible_person = explode(',', $first_responsible_person);
-                    $responsible_person = explode(',', $responsible_person);
-                    $source_responsible_person = array_unique(array_merge($first_responsible_person, $responsible_person));
-                    $source_responsible_person = ',' . implode(',', $source_responsible_person) . ',';
-                } else if ($first_responsible_person) {
-                    $source_responsible_person = $first_responsible_person;
-                } else if ($responsible_person) {
-                    $source_responsible_person = $responsible_person;
-                }
-                $insert_product_data['source_responsible_person'] = $source_responsible_person;
-            }
-
-            //插入数据
-            $ViolationStoreModel->addViolationStore($insert_product_data);
-        }
-        //继续执行下一页
-        $message_data['page'] = $page + 1;
-        $message_data['limit'] = $limit;
-        ViolationStoreDataJobs::dispatch($message_data)->delay(now()->addSeconds(3));
-    }
-
-
-    public function failed(\Throwable $exception)
-    {
-        Log::info('job_error', '数据清洗-违规店铺清洗数据队列完全失败', ['data' => $this->message_data, 'error' => $exception->getMessage()]);
-    }
-}

+ 0 - 112
app/Jobs/Manager/Process/ViolationStoreJobs.php

@@ -1,112 +0,0 @@
-<?php
-
-namespace App\Jobs\Manager\Process;
-
-use Illuminate\Bus\Queueable;
-use Illuminate\Contracts\Queue\ShouldBeUnique;
-use Illuminate\Contracts\Queue\ShouldQueue;
-use Illuminate\Foundation\Bus\Dispatchable;
-use Illuminate\Queue\InteractsWithQueue;
-use Illuminate\Queue\SerializesModels;
-use App\Facades\Servers\Logs\Log;
-use App\Models\Manager\WashConfig\ViolationStore as ViolationStoreModel;
-use App\Models\Manager\Process\ExecuteLog as ExecuteLogModel;
-use App\Jobs\Manager\Process\ViolationStoreDataJobs;
-use Illuminate\Support\Carbon;
-
-/**
- * 数据清洗-违规挂网店铺配置队列
- * @author  唐远望
- * @version 1.0
- * @date  2025-12-11
- */
-class ViolationStoreJobs implements ShouldQueue
-{
-    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
-    
-    public $tries = 3; // 限制重试次数
-    public $timeout = 600; // 10分钟超时
-
-    protected $message_data;
-    /**
-     * Create a new job instance.
-     *
-     * @return void
-     */
-    public function __construct(array $message_data)
-    {
-        $this->message_data = $message_data;
-    }
-
-    /**
-     * Execute the job.
-     *
-     * @return void
-     */
-    public function handle()
-    {
-        try {
-            // $start_time = Carbon::today()->startOfDay()->getTimestamp(); // 今天开始时间 00:00:00
-            $start_time = time() - 60 * 5; // 开始时间 5分钟之前
-            $end_time = time(); //结束时间
-            $ViolationStoreModel = new ViolationStoreModel();
-            $limit = isset($this->message_data['limit']) ? $this->message_data['limit'] : 50;
-            $page = isset($this->message_data['page']) ? $this->message_data['page'] : 1;
-            $executeLog_id = isset($this->message_data['executeLog_id']) ? $this->message_data['executeLog_id'] : 0;
-            $admin_id = isset($this->message_data['admin_id']) ? $this->message_data['admin_id'] : 0;
-            $is_admin = isset($this->message_data['is_admin']) ? $this->message_data['is_admin'] : 0;
-            $company_id = isset($this->message_data['company_id']) ? $this->message_data['company_id'] : 0;
-            if($page == 1){
-                $ExecuteLogModel = new ExecuteLogModel();
-                $insert_data =['company_id'=>$company_id,'name' =>'违规挂网店铺', 'code' => 'ViolationStoreJobs', 'admin_id' => $admin_id,'is_admin' => $is_admin];
-                $executeLog_id=$ExecuteLogModel->addExecuteLog_content($insert_data);
-            }
-            $ViolationStoreModel = $ViolationStoreModel->where('status', 0)->where('store_type', 1);
-            if($company_id){
-                $ViolationStoreModel = $ViolationStoreModel->where('company_id', $company_id);
-            }
-            $totle_page = 0;
-            $list_config_data = $ViolationStoreModel->paginate($limit, ['*'], 'page', $page)->toarray();
-            if (!$list_config_data || empty($list_config_data['data'])) {
-                if($page == 1 && $executeLog_id){
-                    $ExecuteLogModel->where('id', $executeLog_id)->update(['status' => 0,'update_time'=> time()]);
-                }
-                return true;
-            }
-            $totle_page = $list_config_data['last_page'];
-            $list_data = $list_config_data['data'];
-            foreach ($list_data as $key => $value) {
-                $message_data = [
-                    'company_id' => $value['company_id'],
-                    'id' => $value['id'],
-                    'platform' => $value['platform'],
-                    'store_type' => $value['store_type'],
-                    'store_name' => $value['store_name'],
-                    'employee_ids' => $value['employee_ids'],
-                    'executeLog_id' => $executeLog_id,
-                    'specify_responsible_person' => $value['specify_responsible_person'],
-                    'item_totle_page' => $totle_page,
-                    'item_now_page' => $page,
-                    'start_time' => $start_time,
-                    'end_time' => $end_time,
-                ];
-                ViolationStoreDataJobs::dispatch($message_data);
-                // ViolationStoreDataJobs::dispatchSync($message_data);
-            }
-            $now_message_data = [
-                'limit' => $limit,
-                'page' => $page + 1,
-                'executeLog_id' => $executeLog_id,
-            ];
-            ViolationStoreJobs::dispatch($now_message_data)->delay(now()->addSeconds(3));
-        } catch (\Exception $e) {
-            Log::info('job_error', '数据清洗-违规挂网店铺队列失败', ['data' => $this->message_data, 'error' => $e->getMessage()]);
-        }
-    }
-
-
-    public function failed(\Throwable $exception)
-    {
-        Log::info('job_error', '数据清洗-违规挂网店铺队列完全失败', ['data' => $this->message_data, 'error' => $exception->getMessage()]);
-    }
-}