|
|
@@ -17,6 +17,7 @@ use App\Models\Manager\WashConfig\ViolationStore as ViolationStoreModel;
|
|
|
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;
|
|
|
|
|
|
/**
|
|
|
* 数据清洗-违规挂网商品数据队列
|
|
|
@@ -68,6 +69,7 @@ class ViolationProductDataJobs implements ShouldQueue
|
|
|
$ViolationStoreModel = new ViolationStoreModel();
|
|
|
$ViolationCompanyMemberModel = new ViolationCompanyMemberModel();
|
|
|
$EmployeePlatformModel = new EmployeePlatformModel();
|
|
|
+ $EmployeeAreaModel = new EmployeeAreaModel();
|
|
|
$platform = $message_data['platform']; //多个平台配置
|
|
|
$product_name = $message_data['product_name']; //商品名称
|
|
|
$product_specs = $message_data['product_specs']; //商品规格
|
|
|
@@ -106,8 +108,7 @@ class ViolationProductDataJobs implements ShouldQueue
|
|
|
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, ['北京', '天津', '上海', '重庆'])) {
|
|
|
} else if ($province_name && in_array($province_name, ['内蒙古', '广西', '西藏', '新疆', '宁夏'])) {
|
|
|
switch ($province_name) {
|
|
|
case '内蒙古':
|
|
|
@@ -127,7 +128,6 @@ class ViolationProductDataJobs implements ShouldQueue
|
|
|
break;
|
|
|
}
|
|
|
} else if ($province_name && in_array($province_name, ['内蒙古自治区', '广西壮族自治区', '西藏自治区', '新疆维吾尔自治区', '宁夏回族自治区'])) {
|
|
|
-
|
|
|
} else if (strpos($province_name, '省') === false) {
|
|
|
//是否存在市省,如果不存在则补全
|
|
|
if (strpos($province_name, '省') === false) {
|
|
|
@@ -135,7 +135,7 @@ class ViolationProductDataJobs implements ShouldQueue
|
|
|
}
|
|
|
}
|
|
|
if ($city_name != '') {
|
|
|
- $city_name = $CitysModel->where([['id', '=',$product_data['city_id']], ['level', '=', '2']])->value('name');
|
|
|
+ $city_name = $CitysModel->where([['id', '=', $product_data['city_id']], ['level', '=', '2']])->value('name');
|
|
|
}
|
|
|
$insert_product_data = [
|
|
|
'company_id' => $company_id,
|
|
|
@@ -174,53 +174,66 @@ class ViolationProductDataJobs implements ShouldQueue
|
|
|
$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 : '';
|
|
|
}
|
|
|
- //获取指定责任人信息
|
|
|
+ //获取指定人员信息
|
|
|
if ($specify_responsible_person == 0) {
|
|
|
- //查询指定公司责任人
|
|
|
- $EmployeeModel = $EmployeeModel->where('company_id', $company_id);
|
|
|
- //查询配置的第一责任人
|
|
|
$where_query1 = [];
|
|
|
+ $where_query2 = [];
|
|
|
+ $where_query3 = [];
|
|
|
+ //查询指定公司第一责任人
|
|
|
+ $EmployeeModel = $EmployeeModel->where('company_id', $company_id);
|
|
|
if (!empty($employee_id_list)) {
|
|
|
- $EmployeeModel = $EmployeeModel->whereIn('id', $employee_id_list);
|
|
|
- } else {
|
|
|
- $where_query1[] = ['city_ids', 'like', '%,' . $product_data['city_id'] . ',%'];
|
|
|
+ $where_query1[] = ['id', 'in', $employee_id_list];
|
|
|
+ $where_query1[] = ['status', '=', 0];
|
|
|
+ $where_query1[] = ['duty_type', '=', 1]; //责任类型1=第一责任人,2=责任人
|
|
|
}
|
|
|
- $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[] = ['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)) {
|
|
|
+ if (!empty($employee_id_platform)) {
|
|
|
//如果存在平台配置责任人,则查询地区相关的责任人或者平台配置的责任人
|
|
|
- $where_query1_other[] = ['id', 'in', $employee_id_platform];
|
|
|
- $where_query1_other[] = ['status', '=', 0];
|
|
|
- $where_query1_other[] = ['duty_type', '=', 1]; //责任类型1=第一责任人,2=责任人
|
|
|
- $first_responsible_person = $EmployeeModel->where($where_query1)->orWhere($where_query1_other)->pluck('id')->implode(',');
|
|
|
- } else {
|
|
|
- $first_responsible_person = $EmployeeModel->where($where_query1)->pluck('id')->implode(',');
|
|
|
+ $where_query3[] = ['id', 'in', $employee_id_platform];
|
|
|
+ $where_query3[] = ['status', '=', 0];
|
|
|
+ $where_query3[] = ['duty_type', '=', 1]; //责任类型1=第一责任人,2=责任人
|
|
|
}
|
|
|
+ //并行查询第一责任人
|
|
|
+ $first_responsible_person = $EmployeeModel->where($where_query1)->orWhere($where_query2)->orWhere($where_query3)->pluck('id')->implode(',');
|
|
|
$insert_product_data['first_responsible_person'] = $first_responsible_person;
|
|
|
-
|
|
|
- //查询配置的责任人
|
|
|
+ //查询责任人
|
|
|
+ $where_query1 = [];
|
|
|
$where_query2 = [];
|
|
|
- $EmployeeModel = new EmployeeModel();
|
|
|
+ $where_query3 = [];
|
|
|
+ //查询指定公司责任人
|
|
|
$EmployeeModel = $EmployeeModel->where('company_id', $company_id);
|
|
|
if (!empty($employee_id_list)) {
|
|
|
- $EmployeeModel = $EmployeeModel->whereIn('id', $employee_id_list);
|
|
|
- } else {
|
|
|
- $where_query2[] = ['city_ids', 'like', '%,' . $product_data['city_id'] . ',%'];
|
|
|
+ $where_query1[] = ['id', 'in', $employee_id_list];
|
|
|
+ $where_query1[] = ['status', '=', 0];
|
|
|
+ $where_query1[] = ['duty_type', '=', 2]; //责任类型1=第一责任人,2=责任人
|
|
|
}
|
|
|
- $where_query2[] = ['status', '=', 0];
|
|
|
- $where_query2[] = ['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[] = ['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_query2_other[] = ['id', 'in', $employee_id_platform];
|
|
|
- $where_query2_other[] = ['status', '=', 0];
|
|
|
- $where_query2_other[] = ['duty_type', '=', 2]; //责任类型1=第一责任人,2=责任人
|
|
|
- $responsible_person = $EmployeeModel->where($where_query2)->orWhere($where_query2_other)->pluck('id')->implode(',');
|
|
|
- }else{
|
|
|
- $responsible_person = $EmployeeModel->where($where_query2)->pluck('id')->implode(',');
|
|
|
+ //如果存在平台配置责任人,则查询地区相关的责任人或者平台配置的责任人
|
|
|
+ $where_query3[] = ['id', 'in', $employee_id_platform];
|
|
|
+ $where_query3[] = ['status', '=', 0];
|
|
|
+ $where_query3[] = ['duty_type', '=', 2]; //责任类型1=第一责任人,2=责任人
|
|
|
}
|
|
|
-
|
|
|
+ //并行查询责任人
|
|
|
+ $responsible_person = $EmployeeModel->where($where_query1)->orWhere($where_query2)->orWhere($where_query3)->pluck('id')->implode(',');
|
|
|
$insert_product_data['responsible_person'] = $responsible_person;
|
|
|
+
|
|
|
//溯源责任人
|
|
|
$source_responsible_person = '';
|
|
|
if ($first_responsible_person && $responsible_person) {
|