|
|
@@ -60,50 +60,60 @@ class LowPriceGoodsDataJobs implements ShouldQueue
|
|
|
$EmployeeModel = new EmployeeModel();
|
|
|
$LowPriceGoodsModel = new LowPriceGoodsModel();
|
|
|
$ScrapeDataModel = new ScrapeDataModel();
|
|
|
- $platform = $message_data['platform'];//多个平台配置
|
|
|
- $product_name = $message_data['product_name'];//商品名称
|
|
|
- $product_specs = $message_data['product_specs'];//商品规格
|
|
|
- $suggested_price = $message_data['suggested_price'];//指导价格
|
|
|
- $store_scope = $message_data['store_scope'];//店铺范围(为空时全部)
|
|
|
+ $platform = $message_data['platform']; //多个平台配置
|
|
|
+ $product_name = $message_data['product_name']; //商品名称
|
|
|
+ $product_specs = $message_data['product_specs']; //商品规格
|
|
|
+ $suggested_price = $message_data['suggested_price']; //指导价格
|
|
|
+ $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'];
|
|
|
$limit = isset($message_data['limit']) ? $message_data['limit'] : 50;
|
|
|
$page = isset($message_data['page']) ? $message_data['page'] : 1;
|
|
|
-
|
|
|
- $where=[];
|
|
|
- $where[] = ['platform', 'in', $platform];
|
|
|
- $where[] = ['product_name', 'like', '%'. $product_name. '%'];
|
|
|
- $where[] = ['product_specs', 'like', '%'. $product_specs. '%'];
|
|
|
- $where[] = ['suggested_price', '<', $suggested_price];
|
|
|
- if($store_scope){
|
|
|
- $where[] = ['store_name', 'like', '%'. $store_scope. '%'];
|
|
|
+
|
|
|
+ $where = [];
|
|
|
+ if ($platform != 'all') {
|
|
|
+ $platform = explode(',', $platform);
|
|
|
+ $ScrapeDataModel=$ScrapeDataModel->whereIn('platform', $platform);
|
|
|
}
|
|
|
- $product_datas = $ScrapeDataModel->where($where)->get()->toarray(); //商品数据
|
|
|
+ $where[] = ['product_name', 'like', '%' . $product_name . '%'];
|
|
|
+ $where[] = ['product_specs', 'like', '%' . $product_specs . '%'];
|
|
|
+ $where[] = ['one_box_price', '<', $suggested_price];
|
|
|
+ if ($company_scope == 2) {
|
|
|
+ $ScrapeDataModel->whereIn('qualification_number', $social_credit_code);
|
|
|
+ }
|
|
|
+ $product_data_info = $ScrapeDataModel->where($where)->paginate($limit, ['*'], 'page', $page)->toarray();
|
|
|
+ $product_datas = $product_data_info['data'];
|
|
|
if (empty($product_datas)) {
|
|
|
- (new ExecuteLogModel())->where('id', $executeLog_id)->update(['status' => 0]);
|
|
|
- return false;
|
|
|
+ if($executeLog_id){
|
|
|
+ (new ExecuteLogModel())->where('id', $executeLog_id)->update(['status' => 0]);
|
|
|
+ }
|
|
|
+ return true;
|
|
|
}
|
|
|
foreach ($product_datas as $product_data) {
|
|
|
$insert_product_data = [
|
|
|
- 'platform' => $product_data['platform'],
|
|
|
+ 'source_id'=> $product_data['id'],
|
|
|
+ 'platform' => $product_data['platform_id'],
|
|
|
'company_name' => $product_data['company_name'],
|
|
|
- 'product_name' => $product_data['product_name'],
|
|
|
- 'product_specs' => $product_data['product_specs'],
|
|
|
- 'suggested_price' => $product_data['suggested_price'],
|
|
|
- 'online_posting_price' => $product_data['online_posting_price'],
|
|
|
+ 'social_credit_code' => $product_data['qualification_number'],
|
|
|
+ 'product_name' => $product_name,
|
|
|
+ 'product_specs' => $product_specs,
|
|
|
+ 'suggested_price' => $suggested_price,
|
|
|
+ 'online_posting_price' => $product_data['one_box_price'],
|
|
|
'online_posting_cunt' => $product_data['online_posting_cunt'],
|
|
|
'link_url' => $product_data['link_url'],
|
|
|
'store_name' => $product_data['store_name'],
|
|
|
];
|
|
|
//查询配置的第一责任人
|
|
|
$where_query1[] = ['city_ids', 'like', '%,' . $product_data['city_id'] . ',%'];
|
|
|
- $where_query1[] = ['status', '=', 1];
|
|
|
- $where_query1[] = ['duty_type', 'in', 1]; //责任类型1=第一责任人,2=责任人
|
|
|
+ $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[] = ['city_ids', 'like', '%,' . $product_data['city_id'] . ',%'];
|
|
|
- $where_query2[] = ['status', '=', 1];
|
|
|
- $where_query2[] = ['duty_type', 'in', 2]; //责任类型1=第一责任人,2=责任人
|
|
|
+ $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;
|
|
|
//溯源责任人
|
|
|
@@ -118,7 +128,7 @@ class LowPriceGoodsDataJobs implements ShouldQueue
|
|
|
//继续执行下一页
|
|
|
$message_data['page'] = $page + 1;
|
|
|
$message_data['limit'] = $limit;
|
|
|
- LowPriceGoodsDataJobs::dispatch($message_data);
|
|
|
+ $this->dispatch($message_data);
|
|
|
}
|
|
|
|
|
|
|