|
|
@@ -19,6 +19,7 @@ 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;
|
|
|
|
|
|
/**
|
|
|
@@ -30,7 +31,7 @@ use Illuminate\Support\Carbon;
|
|
|
class LowPriceGoodsDataJobs implements ShouldQueue
|
|
|
{
|
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
|
-
|
|
|
+
|
|
|
public $tries = 3; // 限制重试次数
|
|
|
public $timeout = 600; // 10分钟超时
|
|
|
|
|
|
@@ -102,7 +103,7 @@ class LowPriceGoodsDataJobs implements ShouldQueue
|
|
|
}
|
|
|
$ScrapeDataModel = $ScrapeDataModel->where([['min_price', '>=', '0.01'], ['number', '>=', '1']]);
|
|
|
$start_time = time() - 60 * 5; // 开始时间 5分钟之前
|
|
|
- $end_time = time();//结束时间
|
|
|
+ $end_time = 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];
|
|
|
@@ -175,13 +176,13 @@ class LowPriceGoodsDataJobs implements ShouldQueue
|
|
|
$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{
|
|
|
+ } else {
|
|
|
//逆推省份ID失败,则修改为未知名称
|
|
|
- $province_name ='未知';
|
|
|
+ $province_name = '未知';
|
|
|
}
|
|
|
} else {
|
|
|
//尝试从地区详情里面匹配省份名称
|
|
|
- $db_province_data_list = $CitysModel->where([['level', '=', '1']])->select(['id','name'])->get()->toarray();
|
|
|
+ $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) {
|
|
|
@@ -205,15 +206,15 @@ class LowPriceGoodsDataJobs implements ShouldQueue
|
|
|
$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 {
|
|
|
+ $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 {
|
|
|
+ $city_name = '未知';
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
@@ -281,7 +282,7 @@ class LowPriceGoodsDataJobs implements ShouldQueue
|
|
|
$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{
|
|
|
+ } else {
|
|
|
//逆推省份ID失败,则修改为未知名称
|
|
|
$shipment_province_name = '未知';
|
|
|
}
|
|
|
@@ -300,7 +301,7 @@ class LowPriceGoodsDataJobs implements ShouldQueue
|
|
|
$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{
|
|
|
+ } else {
|
|
|
//逆推市ID失败,则修改为未知名称
|
|
|
$shipment_city_name = '未知';
|
|
|
}
|
|
|
@@ -308,7 +309,7 @@ class LowPriceGoodsDataJobs implements ShouldQueue
|
|
|
$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{
|
|
|
+ } else {
|
|
|
//逆推市ID失败,则修改为未知名称
|
|
|
$shipment_city_name = '未知';
|
|
|
}
|
|
|
@@ -365,168 +366,209 @@ class LowPriceGoodsDataJobs implements ShouldQueue
|
|
|
'shipment_city_name' => $product_data['shipment_city_name'],
|
|
|
'collect_config_info' => $product_data['collect_config_info'],
|
|
|
];
|
|
|
- //获取公司绑定责任人信息
|
|
|
- $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 : '';
|
|
|
- }
|
|
|
+
|
|
|
//获取指定人员信息
|
|
|
if ($specify_responsible_person == 0) {
|
|
|
- $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']) != '') {
|
|
|
+ //获取店铺责任人信息
|
|
|
+ $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_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(',');
|
|
|
+ $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(',');
|
|
|
|
|
|
- //调试记录查询条件
|
|
|
- $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 (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)) {
|
|
|
- $q->where('company_id', $company_id)
|
|
|
- ->whereIn('id', $employee_id_area)
|
|
|
- ->where('duty_type', 2)
|
|
|
- ->where('status', 0);
|
|
|
+ $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(',');
|
|
|
}
|
|
|
- })->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']) != '') {
|
|
|
+ //调试记录查询条件
|
|
|
+ $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_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(',');
|
|
|
+ $where_query2[] = ['company_id', '=', $company_id];
|
|
|
+ $where_query2[] = ['id', 'in', $employee_id_area];
|
|
|
+ $where_query2[] = ['status', '=', 0];
|
|
|
+ $where_query2[] = ['duty_type', '=', 2]; //责任类型1=第一责任人,2=责任人
|
|
|
}
|
|
|
- }
|
|
|
- $insert_product_data['responsible_person'] = $responsible_person;
|
|
|
+ //查询平台配置的员工
|
|
|
+ $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;
|
|
|
|
|
|
- //溯源责任人
|
|
|
- $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;
|
|
|
+ //溯源责任人
|
|
|
+ $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;
|
|
|
}
|
|
|
- $insert_product_data['source_responsible_person'] = $source_responsible_person;
|
|
|
}
|
|
|
//插入数据
|
|
|
$LowPriceGoodsModel->addLowPriceGoods($insert_product_data);
|