|
@@ -141,7 +141,7 @@ class LowPriceGoods extends Controller
|
|
|
//多选第一责任人
|
|
//多选第一责任人
|
|
|
if ($first_responsible_person && is_string($first_responsible_person)) {
|
|
if ($first_responsible_person && is_string($first_responsible_person)) {
|
|
|
$first_responsible_person = explode(',', $first_responsible_person);
|
|
$first_responsible_person = explode(',', $first_responsible_person);
|
|
|
- $subQuery = $LowPriceGoodsMemberModel->whereIn('employee_id', $first_responsible_person)->distinct('lowprice_product_logid')->select('lowprice_product_logid');
|
|
|
|
|
|
|
+ $subQuery = $LowPriceGoodsMemberModel->whereIn('employee_id', $first_responsible_person)->where('duty_type',1)->distinct('lowprice_product_logid')->select('lowprice_product_logid');
|
|
|
$LowPriceGoodsModel = $LowPriceGoodsModel->whereIn('id', function ($query1) use ($subQuery) {
|
|
$LowPriceGoodsModel = $LowPriceGoodsModel->whereIn('id', function ($query1) use ($subQuery) {
|
|
|
$query1->select('lowprice_product_logid')->fromSub($subQuery, 'sub1');
|
|
$query1->select('lowprice_product_logid')->fromSub($subQuery, 'sub1');
|
|
|
});
|
|
});
|
|
@@ -149,7 +149,7 @@ class LowPriceGoods extends Controller
|
|
|
//多选责任人
|
|
//多选责任人
|
|
|
if ($responsible_person && is_string($responsible_person)) {
|
|
if ($responsible_person && is_string($responsible_person)) {
|
|
|
$responsible_person = explode(',', $responsible_person);
|
|
$responsible_person = explode(',', $responsible_person);
|
|
|
- $subQuery = $LowPriceGoodsMemberModel->whereIn('employee_id', $responsible_person)->distinct('lowprice_product_logid')->select('lowprice_product_logid');
|
|
|
|
|
|
|
+ $subQuery = $LowPriceGoodsMemberModel->whereIn('employee_id', $responsible_person)->where('duty_type',2)->distinct('lowprice_product_logid')->select('lowprice_product_logid');
|
|
|
$LowPriceGoodsModel = $LowPriceGoodsModel->whereIn('id', function ($query1) use ($subQuery) {
|
|
$LowPriceGoodsModel = $LowPriceGoodsModel->whereIn('id', function ($query1) use ($subQuery) {
|
|
|
$query1->select('lowprice_product_logid')->fromSub($subQuery, 'sub1');
|
|
$query1->select('lowprice_product_logid')->fromSub($subQuery, 'sub1');
|
|
|
});
|
|
});
|
|
@@ -157,7 +157,7 @@ class LowPriceGoods extends Controller
|
|
|
//多选溯源责任人
|
|
//多选溯源责任人
|
|
|
if ($source_responsible_person && is_string($source_responsible_person)) {
|
|
if ($source_responsible_person && is_string($source_responsible_person)) {
|
|
|
$source_responsible_person = explode(',', $source_responsible_person);
|
|
$source_responsible_person = explode(',', $source_responsible_person);
|
|
|
- $subQuery = $LowPriceGoodsMemberModel->whereIn('employee_id', $source_responsible_person)->distinct('lowprice_product_logid')->select('lowprice_product_logid');
|
|
|
|
|
|
|
+ $subQuery = $LowPriceGoodsMemberModel->whereIn('employee_id', $source_responsible_person)->where('duty_type',3)->distinct('lowprice_product_logid')->select('lowprice_product_logid');
|
|
|
$LowPriceGoodsModel = $LowPriceGoodsModel->whereIn('id', function ($query1) use ($subQuery) {
|
|
$LowPriceGoodsModel = $LowPriceGoodsModel->whereIn('id', function ($query1) use ($subQuery) {
|
|
|
$query1->select('lowprice_product_logid')->fromSub($subQuery, 'sub1');
|
|
$query1->select('lowprice_product_logid')->fromSub($subQuery, 'sub1');
|
|
|
});
|
|
});
|
|
@@ -172,12 +172,12 @@ class LowPriceGoods extends Controller
|
|
|
$city_ids = explode(',', $city_ids);
|
|
$city_ids = explode(',', $city_ids);
|
|
|
$LowPriceGoodsModel = $LowPriceGoodsModel->whereIn('city_id', $city_ids);
|
|
$LowPriceGoodsModel = $LowPriceGoodsModel->whereIn('city_id', $city_ids);
|
|
|
}
|
|
}
|
|
|
- //多选发货省份
|
|
|
|
|
|
|
+ //多选店铺省
|
|
|
if ($shipment_province_ids && is_string($shipment_province_ids)) {
|
|
if ($shipment_province_ids && is_string($shipment_province_ids)) {
|
|
|
$shipment_province_ids = explode(',', $shipment_province_ids);
|
|
$shipment_province_ids = explode(',', $shipment_province_ids);
|
|
|
$LowPriceGoodsModel = $LowPriceGoodsModel->whereIn('shipment_province_id', $shipment_province_ids);
|
|
$LowPriceGoodsModel = $LowPriceGoodsModel->whereIn('shipment_province_id', $shipment_province_ids);
|
|
|
}
|
|
}
|
|
|
- //多选发货城市
|
|
|
|
|
|
|
+ //多选店铺市
|
|
|
if ($shipment_city_ids && is_string($shipment_city_ids)) {
|
|
if ($shipment_city_ids && is_string($shipment_city_ids)) {
|
|
|
$shipment_city_ids = explode(',', $shipment_city_ids);
|
|
$shipment_city_ids = explode(',', $shipment_city_ids);
|
|
|
$LowPriceGoodsModel = $LowPriceGoodsModel->whereIn('shipment_city_id', $shipment_city_ids);
|
|
$LowPriceGoodsModel = $LowPriceGoodsModel->whereIn('shipment_city_id', $shipment_city_ids);
|
|
@@ -197,10 +197,12 @@ class LowPriceGoods extends Controller
|
|
|
})
|
|
})
|
|
|
->where($map)
|
|
->where($map)
|
|
|
->orderByDesc('insert_time')
|
|
->orderByDesc('insert_time')
|
|
|
|
|
+ ->orderByDesc('collection_time')
|
|
|
->paginate($limit)->toarray();
|
|
->paginate($limit)->toarray();
|
|
|
} else {
|
|
} else {
|
|
|
$result = $LowPriceGoodsModel->where($map)
|
|
$result = $LowPriceGoodsModel->where($map)
|
|
|
->orderByDesc('insert_time')
|
|
->orderByDesc('insert_time')
|
|
|
|
|
+ ->orderByDesc('collection_time')
|
|
|
->paginate($limit)->toarray();
|
|
->paginate($limit)->toarray();
|
|
|
}
|
|
}
|
|
|
// 分配数据
|
|
// 分配数据
|
|
@@ -266,6 +268,8 @@ class LowPriceGoods extends Controller
|
|
|
$message_data['shipment_province_ids'] = request('shipment_province_ids', '');
|
|
$message_data['shipment_province_ids'] = request('shipment_province_ids', '');
|
|
|
$message_data['shipment_city_ids'] = request('shipment_city_ids', '');
|
|
$message_data['shipment_city_ids'] = request('shipment_city_ids', '');
|
|
|
$message_data['product_brand'] = request('product_brand', '');
|
|
$message_data['product_brand'] = request('product_brand', '');
|
|
|
|
|
+ $message_data['collection_time_start_time'] = request('collection_time_start_time', '');
|
|
|
|
|
+ $message_data['collection_time_end_time'] = request('collection_time_end_time', '');
|
|
|
|
|
|
|
|
$low_price_goods_where = [];
|
|
$low_price_goods_where = [];
|
|
|
// 权限判断
|
|
// 权限判断
|
|
@@ -274,12 +278,6 @@ class LowPriceGoods extends Controller
|
|
|
} else {
|
|
} else {
|
|
|
$low_price_goods_where['company_id'] = $message_data['admin_company_id'];
|
|
$low_price_goods_where['company_id'] = $message_data['admin_company_id'];
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- $key_name = 'ExportLowPriceGoodsJobs_' . $low_price_goods_where['company_id'];
|
|
|
|
|
- $export_data_info = Cache::get($key_name);
|
|
|
|
|
- if ($export_data_info) return json_send(['code' => 'fail', 'msg' => '导出任务正在执行中,请稍后再试', 'data' => '']);
|
|
|
|
|
- //创建缓存
|
|
|
|
|
- Cache::put($key_name,'1', 60 * 60 * 3);
|
|
|
|
|
// 查询条件
|
|
// 查询条件
|
|
|
$map = [];
|
|
$map = [];
|
|
|
$job_page = isset($message_data['job_page']) ? $message_data['job_page'] : 1;
|
|
$job_page = isset($message_data['job_page']) ? $message_data['job_page'] : 1;
|
|
@@ -306,7 +304,12 @@ class LowPriceGoods extends Controller
|
|
|
$shipment_province_ids = $message_data['shipment_province_ids'] ?? '';
|
|
$shipment_province_ids = $message_data['shipment_province_ids'] ?? '';
|
|
|
$shipment_city_ids = $message_data['shipment_city_ids'] ?? '';
|
|
$shipment_city_ids = $message_data['shipment_city_ids'] ?? '';
|
|
|
$product_brand = $message_data['product_brand'] ?? '';
|
|
$product_brand = $message_data['product_brand'] ?? '';
|
|
|
|
|
+
|
|
|
|
|
+ $collection_time_start_time = $message_data['collection_time_start_time'] ?? '';
|
|
|
|
|
+ $collection_time_end_time = $message_data['collection_time_end_time'] ?? '';
|
|
|
// 时间条件
|
|
// 时间条件
|
|
|
|
|
+ if ($collection_time_start_time) $map[] = ['collection_time', '>=', strtotime($collection_time_start_time)];
|
|
|
|
|
+ if ($collection_time_end_time) $map[] = ['collection_time', '<=', strtotime($collection_time_end_time)];
|
|
|
if ($start_time) $map[] = ['insert_time', '>=', strtotime($start_time)];
|
|
if ($start_time) $map[] = ['insert_time', '>=', strtotime($start_time)];
|
|
|
if ($end_time) $map[] = ['insert_time', '<=', strtotime($end_time)];
|
|
if ($end_time) $map[] = ['insert_time', '<=', strtotime($end_time)];
|
|
|
// 其他条件
|
|
// 其他条件
|
|
@@ -373,7 +376,7 @@ class LowPriceGoods extends Controller
|
|
|
//多选第一责任人
|
|
//多选第一责任人
|
|
|
if ($first_responsible_person && is_string($first_responsible_person)) {
|
|
if ($first_responsible_person && is_string($first_responsible_person)) {
|
|
|
$first_responsible_person = explode(',', $first_responsible_person);
|
|
$first_responsible_person = explode(',', $first_responsible_person);
|
|
|
- $subQuery = $LowPriceGoodsMemberModel->whereIn('employee_id', $first_responsible_person)->distinct('lowprice_product_logid')->select('lowprice_product_logid');
|
|
|
|
|
|
|
+ $subQuery = $LowPriceGoodsMemberModel->whereIn('employee_id', $first_responsible_person)->where('duty_type',1)->distinct('lowprice_product_logid')->select('lowprice_product_logid');
|
|
|
$LowPriceGoodsModel = $LowPriceGoodsModel->whereIn('id', function ($query1) use ($subQuery) {
|
|
$LowPriceGoodsModel = $LowPriceGoodsModel->whereIn('id', function ($query1) use ($subQuery) {
|
|
|
$query1->select('lowprice_product_logid')->fromSub($subQuery, 'sub1');
|
|
$query1->select('lowprice_product_logid')->fromSub($subQuery, 'sub1');
|
|
|
});
|
|
});
|
|
@@ -381,7 +384,7 @@ class LowPriceGoods extends Controller
|
|
|
//多选责任人
|
|
//多选责任人
|
|
|
if ($responsible_person && is_string($responsible_person)) {
|
|
if ($responsible_person && is_string($responsible_person)) {
|
|
|
$responsible_person = explode(',', $responsible_person);
|
|
$responsible_person = explode(',', $responsible_person);
|
|
|
- $subQuery = $LowPriceGoodsMemberModel->whereIn('employee_id', $responsible_person)->distinct('lowprice_product_logid')->select('lowprice_product_logid');
|
|
|
|
|
|
|
+ $subQuery = $LowPriceGoodsMemberModel->whereIn('employee_id', $responsible_person)->where('duty_type',2)->distinct('lowprice_product_logid')->select('lowprice_product_logid');
|
|
|
$LowPriceGoodsModel = $LowPriceGoodsModel->whereIn('id', function ($query1) use ($subQuery) {
|
|
$LowPriceGoodsModel = $LowPriceGoodsModel->whereIn('id', function ($query1) use ($subQuery) {
|
|
|
$query1->select('lowprice_product_logid')->fromSub($subQuery, 'sub1');
|
|
$query1->select('lowprice_product_logid')->fromSub($subQuery, 'sub1');
|
|
|
});
|
|
});
|
|
@@ -389,7 +392,7 @@ class LowPriceGoods extends Controller
|
|
|
//多选溯源责任人
|
|
//多选溯源责任人
|
|
|
if ($source_responsible_person && is_string($source_responsible_person)) {
|
|
if ($source_responsible_person && is_string($source_responsible_person)) {
|
|
|
$source_responsible_person = explode(',', $source_responsible_person);
|
|
$source_responsible_person = explode(',', $source_responsible_person);
|
|
|
- $subQuery = $LowPriceGoodsMemberModel->whereIn('employee_id', $source_responsible_person)->distinct('lowprice_product_logid')->select('lowprice_product_logid');
|
|
|
|
|
|
|
+ $subQuery = $LowPriceGoodsMemberModel->whereIn('employee_id', $source_responsible_person)->where('duty_type',3)->distinct('lowprice_product_logid')->select('lowprice_product_logid');
|
|
|
$LowPriceGoodsModel = $LowPriceGoodsModel->whereIn('id', function ($query1) use ($subQuery) {
|
|
$LowPriceGoodsModel = $LowPriceGoodsModel->whereIn('id', function ($query1) use ($subQuery) {
|
|
|
$query1->select('lowprice_product_logid')->fromSub($subQuery, 'sub1');
|
|
$query1->select('lowprice_product_logid')->fromSub($subQuery, 'sub1');
|
|
|
});
|
|
});
|
|
@@ -404,12 +407,12 @@ class LowPriceGoods extends Controller
|
|
|
$city_ids = explode(',', $city_ids);
|
|
$city_ids = explode(',', $city_ids);
|
|
|
$LowPriceGoodsModel = $LowPriceGoodsModel->whereIn('city_id', $city_ids);
|
|
$LowPriceGoodsModel = $LowPriceGoodsModel->whereIn('city_id', $city_ids);
|
|
|
}
|
|
}
|
|
|
- //多选发货省份
|
|
|
|
|
|
|
+ //多选店铺省
|
|
|
if ($shipment_province_ids && is_string($shipment_province_ids)) {
|
|
if ($shipment_province_ids && is_string($shipment_province_ids)) {
|
|
|
$shipment_province_ids = explode(',', $shipment_province_ids);
|
|
$shipment_province_ids = explode(',', $shipment_province_ids);
|
|
|
$LowPriceGoodsModel = $LowPriceGoodsModel->whereIn('shipment_province_id', $shipment_province_ids);
|
|
$LowPriceGoodsModel = $LowPriceGoodsModel->whereIn('shipment_province_id', $shipment_province_ids);
|
|
|
}
|
|
}
|
|
|
- //多选发货城市
|
|
|
|
|
|
|
+ //多选店铺市
|
|
|
if ($shipment_city_ids && is_string($shipment_city_ids)) {
|
|
if ($shipment_city_ids && is_string($shipment_city_ids)) {
|
|
|
$shipment_city_ids = explode(',', $shipment_city_ids);
|
|
$shipment_city_ids = explode(',', $shipment_city_ids);
|
|
|
$LowPriceGoodsModel = $LowPriceGoodsModel->whereIn('shipment_city_id', $shipment_city_ids);
|
|
$LowPriceGoodsModel = $LowPriceGoodsModel->whereIn('shipment_city_id', $shipment_city_ids);
|
|
@@ -438,14 +441,20 @@ class LowPriceGoods extends Controller
|
|
|
if ($result_count == 0) return json_send(['code' => 'fail', 'msg' => '没有查询到数据', 'data' => '']);
|
|
if ($result_count == 0) return json_send(['code' => 'fail', 'msg' => '没有查询到数据', 'data' => '']);
|
|
|
if ($result_count > 150000) return json_send(['code' => 'fail', 'msg' => '导出数据超过15万条,请缩小导出范围后再试', 'data' => '']);
|
|
if ($result_count > 150000) return json_send(['code' => 'fail', 'msg' => '导出数据超过15万条,请缩小导出范围后再试', 'data' => '']);
|
|
|
|
|
|
|
|
|
|
+ $key_name = 'ExportLowPriceGoodsJobs_' . $low_price_goods_where['company_id'];
|
|
|
|
|
+ $export_data_info = Cache::get($key_name);
|
|
|
|
|
+ if ($export_data_info) return json_send(['code' => 'fail', 'msg' => '导出任务正在执行中,请稍后再试', 'data' => '']);
|
|
|
|
|
+ //创建缓存
|
|
|
|
|
+ Cache::put($key_name,'1', 60 * 60 * 3);
|
|
|
|
|
+
|
|
|
// 生成唯一文件ID
|
|
// 生成唯一文件ID
|
|
|
$fileId = make_snow_flake();
|
|
$fileId = make_snow_flake();
|
|
|
$message_data['file_id'] = $fileId;
|
|
$message_data['file_id'] = $fileId;
|
|
|
$fileName = '低价挂网商品数据' . $fileId . '.xlsx';
|
|
$fileName = '低价挂网商品数据' . $fileId . '.xlsx';
|
|
|
$message_data['company_id'] = $low_price_goods_where['company_id'];
|
|
$message_data['company_id'] = $low_price_goods_where['company_id'];
|
|
|
$message_data['user_id'] = $message_data['user_id'];
|
|
$message_data['user_id'] = $message_data['user_id'];
|
|
|
- ExportLowPriceGoodsJobs::dispatch($message_data);
|
|
|
|
|
- // ExportLowPriceGoodsJobs::dispatchSync($message_data);
|
|
|
|
|
|
|
+ // ExportLowPriceGoodsJobs::dispatch($message_data);
|
|
|
|
|
+ ExportLowPriceGoodsJobs::dispatchSync($message_data);
|
|
|
return json_send(['code' => 'success', 'msg' => '导出任务添加成功', 'data' => ['file_id' => $fileId, 'file_name' => $fileName]]);
|
|
return json_send(['code' => 'success', 'msg' => '导出任务添加成功', 'data' => ['file_id' => $fileId, 'file_name' => $fileName]]);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -908,7 +917,7 @@ class LowPriceGoods extends Controller
|
|
|
$sheet = $spreadsheet->getActiveSheet();
|
|
$sheet = $spreadsheet->getActiveSheet();
|
|
|
|
|
|
|
|
//合并单元格
|
|
//合并单元格
|
|
|
- $sheet->mergeCells('A1:R1');
|
|
|
|
|
|
|
+ $sheet->mergeCells('A1:Y1');
|
|
|
$sheet->setCellValue('A1', '低价挂网商品导入模板'); // 设置合并后的单元格内容
|
|
$sheet->setCellValue('A1', '低价挂网商品导入模板'); // 设置合并后的单元格内容
|
|
|
// 获取合并后的单元格样式对象
|
|
// 获取合并后的单元格样式对象
|
|
|
$style = $sheet->getStyle('A1');
|
|
$style = $sheet->getStyle('A1');
|
|
@@ -920,7 +929,7 @@ class LowPriceGoods extends Controller
|
|
|
$sheet->setCellValue('A2', '第一责任人姓名');
|
|
$sheet->setCellValue('A2', '第一责任人姓名');
|
|
|
$sheet->setCellValue('B2', '责任人姓名');
|
|
$sheet->setCellValue('B2', '责任人姓名');
|
|
|
$sheet->setCellValue('C2', '平台名称*');
|
|
$sheet->setCellValue('C2', '平台名称*');
|
|
|
- $sheet->setCellValue('D2', '商品分类名称');
|
|
|
|
|
|
|
+ $sheet->setCellValue('D2', '商品类型');
|
|
|
$sheet->setCellValue('E2', '品牌名称');
|
|
$sheet->setCellValue('E2', '品牌名称');
|
|
|
$sheet->setCellValue('F2', '商品名称*');
|
|
$sheet->setCellValue('F2', '商品名称*');
|
|
|
$sheet->setCellValue('G2', '商品规格*');
|
|
$sheet->setCellValue('G2', '商品规格*');
|
|
@@ -935,14 +944,13 @@ class LowPriceGoods extends Controller
|
|
|
$sheet->setCellValue('P2', '店铺名称*');
|
|
$sheet->setCellValue('P2', '店铺名称*');
|
|
|
$sheet->setCellValue('Q2', '匿名店铺');
|
|
$sheet->setCellValue('Q2', '匿名店铺');
|
|
|
$sheet->setCellValue('R2', '公司名称*');
|
|
$sheet->setCellValue('R2', '公司名称*');
|
|
|
- $sheet->setCellValue('S2', '公司分类名称');
|
|
|
|
|
|
|
+ $sheet->setCellValue('S2', '商业类型');
|
|
|
$sheet->setCellValue('T2', '信用代码');
|
|
$sheet->setCellValue('T2', '信用代码');
|
|
|
- $sheet->setCellValue('U2', '省份');
|
|
|
|
|
- $sheet->setCellValue('V2', '城市');
|
|
|
|
|
- $sheet->setCellValue('W2', '溯源责任人');
|
|
|
|
|
- $sheet->setCellValue('X2', '检索采集日期(Y-m-d)*');
|
|
|
|
|
- $sheet->setCellValue('Y2', '发货省份');
|
|
|
|
|
- $sheet->setCellValue('Z2', '发货城市');
|
|
|
|
|
|
|
+ $sheet->setCellValue('U2', '公司省');
|
|
|
|
|
+ $sheet->setCellValue('V2', '公司市');
|
|
|
|
|
+ $sheet->setCellValue('W2', '店铺省');
|
|
|
|
|
+ $sheet->setCellValue('X2', '店铺市');
|
|
|
|
|
+ $sheet->setCellValue('Y2', '采集时间(Y-m-d H:i:s)*');
|
|
|
// 生成 Excel 文件
|
|
// 生成 Excel 文件
|
|
|
$writer = new Xlsx($spreadsheet);
|
|
$writer = new Xlsx($spreadsheet);
|
|
|
|
|
|
|
@@ -1021,15 +1029,15 @@ class LowPriceGoods extends Controller
|
|
|
}
|
|
}
|
|
|
$source_responsible_person_id = [];
|
|
$source_responsible_person_id = [];
|
|
|
$source_responsible_person_name = $item[22];
|
|
$source_responsible_person_name = $item[22];
|
|
|
- if ($source_responsible_person_name) {
|
|
|
|
|
- $source_responsible_person_name = explode(',', $source_responsible_person_name);
|
|
|
|
|
- foreach ($source_responsible_person_name as $k => $v) {
|
|
|
|
|
- $v = trim($v);
|
|
|
|
|
- if (isset($result[$v])) {
|
|
|
|
|
- $source_responsible_person_id[] = $result[$v]['id'];
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // if ($source_responsible_person_name) {
|
|
|
|
|
+ // $source_responsible_person_name = explode(',', $source_responsible_person_name);
|
|
|
|
|
+ // foreach ($source_responsible_person_name as $k => $v) {
|
|
|
|
|
+ // $v = trim($v);
|
|
|
|
|
+ // if (isset($result[$v])) {
|
|
|
|
|
+ // $source_responsible_person_id[] = $result[$v]['id'];
|
|
|
|
|
+ // }
|
|
|
|
|
+ // }
|
|
|
|
|
+ // }
|
|
|
$province_name = $item[20];
|
|
$province_name = $item[20];
|
|
|
//特殊地区1级移除市
|
|
//特殊地区1级移除市
|
|
|
if ($province_name && in_array($province_name, ['北京市', '天津市', '上海市', '重庆市'])) {
|
|
if ($province_name && in_array($province_name, ['北京市', '天津市', '上海市', '重庆市'])) {
|
|
@@ -1067,7 +1075,7 @@ class LowPriceGoods extends Controller
|
|
|
if (!empty($city_name) && !isset($city_id_data[$city_name])) return json_send(['code' => 'error', 'msg' => "第{$key_num}行城市信息不完整", 'data' => $item]);
|
|
if (!empty($city_name) && !isset($city_id_data[$city_name])) return json_send(['code' => 'error', 'msg' => "第{$key_num}行城市信息不完整", 'data' => $item]);
|
|
|
|
|
|
|
|
|
|
|
|
|
- $shipment_province_name = isset($item[24]) ? $item[24] : '';
|
|
|
|
|
|
|
+ $shipment_province_name = isset($item[22]) ? $item[22] : '';
|
|
|
//特殊地区1级移除市
|
|
//特殊地区1级移除市
|
|
|
if ($shipment_province_name && in_array($province_name, ['北京市', '天津市', '上海市', '重庆市'])) {
|
|
if ($shipment_province_name && in_array($province_name, ['北京市', '天津市', '上海市', '重庆市'])) {
|
|
|
//移除市这个字符
|
|
//移除市这个字符
|
|
@@ -1105,7 +1113,7 @@ class LowPriceGoods extends Controller
|
|
|
$shipment_province_id = $province_id_data[$shipment_province_name]['id'];
|
|
$shipment_province_id = $province_id_data[$shipment_province_name]['id'];
|
|
|
}
|
|
}
|
|
|
$shipment_city_id = '0';
|
|
$shipment_city_id = '0';
|
|
|
- $shipment_city_name = isset($item[25]) ? $item[25] : '';
|
|
|
|
|
|
|
+ $shipment_city_name = isset($item[23]) ? $item[23] : '';
|
|
|
if (!isset($city_id_data[$shipment_city_name])) {
|
|
if (!isset($city_id_data[$shipment_city_name])) {
|
|
|
$shipment_city_name = '';
|
|
$shipment_city_name = '';
|
|
|
} else {
|
|
} else {
|
|
@@ -1151,11 +1159,12 @@ class LowPriceGoods extends Controller
|
|
|
$insert_product_data['status'] = 0; //状态0=有效=无效
|
|
$insert_product_data['status'] = 0; //状态0=有效=无效
|
|
|
$insert_product_data['insert_time'] = time();
|
|
$insert_product_data['insert_time'] = time();
|
|
|
$insert_product_data['source_id'] = 0; // 原始数据ID
|
|
$insert_product_data['source_id'] = 0; // 原始数据ID
|
|
|
- $insert_product_data['scrape_date'] = $item[23]; // 原始数据类型
|
|
|
|
|
- $insert_product_data['shipment_province_id'] = $shipment_province_id; // 发货省份id
|
|
|
|
|
- $insert_product_data['shipment_province_name'] = $shipment_province_name; // 发货省份
|
|
|
|
|
- $insert_product_data['shipment_city_id'] = $shipment_city_id; // 发货城市id
|
|
|
|
|
- $insert_product_data['shipment_city_name'] = $shipment_city_name; // 发货城市
|
|
|
|
|
|
|
+ $insert_product_data['shipment_province_id'] = $shipment_province_id; // 店铺省id
|
|
|
|
|
+ $insert_product_data['shipment_province_name'] = $shipment_province_name; // 店铺省
|
|
|
|
|
+ $insert_product_data['shipment_city_id'] = $shipment_city_id; // 店铺市id
|
|
|
|
|
+ $insert_product_data['shipment_city_name'] = $shipment_city_name; // 店铺市
|
|
|
|
|
+ $insert_product_data['collection_time'] = strtotime($item[24]); // 采集时间
|
|
|
|
|
+ $insert_product_data['scrape_date'] = date('Y-m-d',strtotime($item[24])); // 检索采集日期
|
|
|
//插入数据
|
|
//插入数据
|
|
|
$LowPriceGoodsModel->addLowPriceGoods($insert_product_data, true);
|
|
$LowPriceGoodsModel->addLowPriceGoods($insert_product_data, true);
|
|
|
}
|
|
}
|
|
@@ -1212,15 +1221,15 @@ class LowPriceGoods extends Controller
|
|
|
// if (!$item[21]) {
|
|
// if (!$item[21]) {
|
|
|
// return ['code' => 'error', 'msg' => "第{$key}行城市不能为空", 'data' => $item];
|
|
// return ['code' => 'error', 'msg' => "第{$key}行城市不能为空", 'data' => $item];
|
|
|
// }
|
|
// }
|
|
|
- if (!$item[23]) {
|
|
|
|
|
- return ['code' => 'error', 'msg' => "第{$key}行检索采集日期不能为空", 'data' => $item];
|
|
|
|
|
|
|
+ if (!$item[24]) {
|
|
|
|
|
+ return ['code' => 'error', 'msg' => "第{$key}行采集时间不能为空", 'data' => $item];
|
|
|
} else {
|
|
} else {
|
|
|
- //校验格式是否为Y-m-d
|
|
|
|
|
- if (!preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/', $item[23])) {
|
|
|
|
|
- return ['code' => 'error', 'msg' => "第{$key}行检索采集日期格式不正确", 'data' => $item];
|
|
|
|
|
|
|
+ //校验格式是否为Y-m-d H:i:s
|
|
|
|
|
+ if (!preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}$/', $item[24])) {
|
|
|
|
|
+ return ['code' => 'error', 'msg' => "第{$key}行采集时间格式不正确", 'data' => $item];
|
|
|
}
|
|
}
|
|
|
- if (strtotime($item[23] . ' 00:00:00') > time()) {
|
|
|
|
|
- return ['code' => 'error', 'msg' => "第{$key}行检索采集日期不能大于当前日期", 'data' => $item];
|
|
|
|
|
|
|
+ if (strtotime($item[24]) > time()) {
|
|
|
|
|
+ return ['code' => 'error', 'msg' => "第{$key}行采集时间不能大于当前日期", 'data' => $item];
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|