|
|
@@ -64,21 +64,22 @@ class ViolationProductDataJobs implements ShouldQueue
|
|
|
$ScrapeDataModel = new ScrapeDataModel();
|
|
|
$ViolationStoreModel = new ViolationStoreModel();
|
|
|
$ViolationCompanyMemberModel = new ViolationCompanyMemberModel();
|
|
|
- $platform = $message_data['platform'];//多个平台配置
|
|
|
- $product_name = $message_data['product_name'];//商品名称
|
|
|
- $product_specs = $message_data['product_specs'];//商品规格
|
|
|
+ $platform = $message_data['platform']; //多个平台配置
|
|
|
+ $product_name = $message_data['product_name']; //商品名称
|
|
|
+ $product_specs = $message_data['product_specs']; //商品规格
|
|
|
$store_scope = $message_data['store_scope']; //店铺范围1=全部店铺2=指定店铺
|
|
|
$company_scope = $message_data['company_scope']; //公司范围1=全部公司2=指定公司
|
|
|
$social_credit_code = $message_data['social_credit_code']; //社会信用代码
|
|
|
$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'] : 50;
|
|
|
$page = isset($message_data['page']) ? $message_data['page'] : 1;
|
|
|
|
|
|
$where = [];
|
|
|
if ($platform != '0') {
|
|
|
$platform = explode(',', $platform);
|
|
|
- $ScrapeDataModel=$ScrapeDataModel->whereIn('platform_id', $platform);
|
|
|
+ $ScrapeDataModel = $ScrapeDataModel->whereIn('platform_id', $platform);
|
|
|
}
|
|
|
$where[] = ['product_name', 'like', '%' . $product_name . '%'];
|
|
|
$where[] = ['product_specs', 'like', '%' . $product_specs . '%'];
|
|
|
@@ -88,14 +89,14 @@ class ViolationProductDataJobs implements ShouldQueue
|
|
|
$product_data_info = $ScrapeDataModel->where($where)->paginate($limit, ['*'], 'page', $page)->toarray();
|
|
|
$product_datas = $product_data_info['data'];
|
|
|
if (empty($product_datas)) {
|
|
|
- if($executeLog_id){
|
|
|
+ if ($executeLog_id) {
|
|
|
(new ExecuteLogModel())->where('id', $executeLog_id)->update(['status' => 0]);
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
foreach ($product_datas as $product_data) {
|
|
|
$insert_product_data = [
|
|
|
- 'source_id'=> $product_data['id'],
|
|
|
+ 'source_id' => $product_data['id'],
|
|
|
'platform' => $product_data['platform_id'],
|
|
|
'company_name' => $product_data['company_name'],
|
|
|
'product_name' => $product_name,
|
|
|
@@ -111,49 +112,56 @@ class ViolationProductDataJobs implements ShouldQueue
|
|
|
'area_info' => $product_data['area_info'],
|
|
|
'category_name' => $category_name,
|
|
|
'company_category_name' => '',
|
|
|
+ 'first_responsible_person' => '',
|
|
|
+ 'responsible_person' => '',
|
|
|
+ 'source_responsible_person' => '',
|
|
|
];
|
|
|
//获取公司绑定责任人信息
|
|
|
$company_data = $ViolationStoreModel->leftjoin('washconfig_company_category', 'washconfig_company_category.id', '=', 'washconfig_violation_store.category_id')
|
|
|
- ->where('washconfig_violation_store.social_credit_code',$product_data['qualification_number'])->select(['washconfig_violation_store.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();
|
|
|
+ ->where('washconfig_violation_store.social_credit_code', $product_data['qualification_number'])->select(['washconfig_violation_store.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 =[];
|
|
|
- if(!empty($employee_id_list)){
|
|
|
- $EmployeeModel = $EmployeeModel->whereIn('id',$employee_id_list);
|
|
|
- }else{
|
|
|
- $where_query1[] = ['city_ids', 'like', '%,' . $product_data['city_id'] . ',%'];
|
|
|
- }
|
|
|
- $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;
|
|
|
+ //获取指定责任人信息
|
|
|
+ if ($specify_responsible_person == 0) {
|
|
|
+ //查询配置的第一责任人
|
|
|
+ $where_query1 = [];
|
|
|
+ if (!empty($employee_id_list)) {
|
|
|
+ $EmployeeModel = $EmployeeModel->whereIn('id', $employee_id_list);
|
|
|
+ } else {
|
|
|
+ $where_query1[] = ['city_ids', 'like', '%,' . $product_data['city_id'] . ',%'];
|
|
|
+ }
|
|
|
+ $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;
|
|
|
|
|
|
- //查询配置的责任人
|
|
|
- $where_query2 =[];
|
|
|
- $EmployeeModel = new EmployeeModel();
|
|
|
- if(!empty($employee_id_list)){
|
|
|
- $EmployeeModel = $EmployeeModel->whereIn('id',$employee_id_list);
|
|
|
- }else{
|
|
|
- $where_query2[] = ['city_ids', 'like', '%,' . $product_data['city_id'] . ',%'];
|
|
|
- }
|
|
|
- $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) {
|
|
|
- $source_responsible_person = $first_responsible_person . ',' . $responsible_person;
|
|
|
- } else if ($first_responsible_person) {
|
|
|
- $source_responsible_person = $first_responsible_person;
|
|
|
- } else if($responsible_person) {
|
|
|
- $source_responsible_person = $responsible_person;
|
|
|
+ //查询配置的责任人
|
|
|
+ $where_query2 = [];
|
|
|
+ $EmployeeModel = new EmployeeModel();
|
|
|
+ if (!empty($employee_id_list)) {
|
|
|
+ $EmployeeModel = $EmployeeModel->whereIn('id', $employee_id_list);
|
|
|
+ } else {
|
|
|
+ $where_query2[] = ['city_ids', 'like', '%,' . $product_data['city_id'] . ',%'];
|
|
|
+ }
|
|
|
+ $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) {
|
|
|
+ $source_responsible_person = $first_responsible_person . ',' . $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;
|
|
|
}
|
|
|
- $insert_product_data['source_responsible_person'] = $source_responsible_person;
|
|
|
+
|
|
|
//插入数据
|
|
|
$ViolationProductModel->addViolationProduct($insert_product_data);
|
|
|
}
|