调整排序

This commit is contained in:
mkm 2023-11-25 14:33:05 +08:00
parent cf42b7e1d6
commit cab9448700
3 changed files with 268 additions and 227 deletions

View File

@ -2521,6 +2521,7 @@ class StoreOrderRepository extends BaseRepository
if ($typeCode == Merchant::TypeCode['TypeSupplyChain']) { if ($typeCode == Merchant::TypeCode['TypeSupplyChain']) {
$product_type = 98; //供应链 $product_type = 98; //供应链
} }
try {
foreach ($data as $datum) { foreach ($data as $datum) {
$find = Db::name('store_product')->where('mer_id', $merId)->where('store_name', $datum['value']['store_name'])->find(); $find = Db::name('store_product')->where('mer_id', $merId)->where('store_name', $datum['value']['store_name'])->find();
@ -2540,7 +2541,11 @@ class StoreOrderRepository extends BaseRepository
if ($find) { if ($find) {
$store_product_attr_value = Db::name('store_product_attr_value')->where('product_id', $find['product_id'])->where('bar_code', $datum['value']['bar_code'])->find(); $store_product_attr_value = Db::name('store_product_attr_value')->where('product_id', $find['product_id'])->where('bar_code', $datum['value']['bar_code'])->find();
if ($store_product_attr_value) { if ($store_product_attr_value) {
Log::error('xls导入商品:已经导入过该规格了'); $data['product_id'] = $find['product_id'];
$data['mer_id'] = $merId;
$data['store_name'] = $$datum['value']['store_name'];
$data['content'] = 'xls导入商品:已经导入过该规格了';
$this->create_product_import_log($data,0);
continue; continue;
} }
$is_update = false; $is_update = false;
@ -2617,16 +2622,12 @@ class StoreOrderRepository extends BaseRepository
->find(); ->find();
if (!$library) { if (!$library) {
$ProductLibrary = app()->make(ProductLibrary::class); $ProductLibrary = app()->make(ProductLibrary::class);
try {
$ProductLibrary->caiji($bar_code); $ProductLibrary->caiji($bar_code);
$library = Db::name('product_library')->where('bar_code', $bar_code)->where($bar_code_where)->field($bar_code_field) $library = Db::name('product_library')->where('bar_code', $bar_code)->where($bar_code_where)->field($bar_code_field)
->withAttr('slider_image', function ($value, $data) { ->withAttr('slider_image', function ($value, $data) {
return $value ? explode(',', $value) : []; return $value ? explode(',', $value) : [];
}) })
->find(); ->find();
} catch (Exception $e) {
Log::error('导入采集编码错误:' . $bar_code . '。' . $e->getMessage());
}
} }
} }
if ($library) { if ($library) {
@ -2705,12 +2706,37 @@ class StoreOrderRepository extends BaseRepository
// 'product_type' => $product_type, // 'product_type' => $product_type,
// ]; // ];
$make = app()->make(ProductRepository::class); $make = app()->make(ProductRepository::class);
$make->create($datas, $product_type); $product_id = $make->create($datas, $product_type);
if ($product_id) {
$data['product_id'] = $product_id;
$data['mer_id'] = $merId;
$data['store_name'] = $datum['value']['store_name'];
$this->create_product_import_log($data);
}
// Queue::push(ProductImportJob::class, $data_list); // Queue::push(ProductImportJob::class, $data_list);
} }
} }
} catch (Exception $e) {
$data['product_id'] = $product_id;
$data['mer_id'] = $merId;
$data['store_name'] = $$datum['value']['store_name'];
$data['content'] = $datum['value']['store_name'];
$this->create_product_import_log($data, 0);
}
return true; return true;
} }
public function create_product_import_log($data, $status = 1)
{
$data = [
'product_id' => $data['product_id'],
'mer_id' => $data['mer_id'],
'name' => $data['store_name'],
'content' => $data['content'] ?? '',
'status' => $status,
'create_time' => date('Y-m-d H:i:s'),
];
Db::name('store_product_import')->insert($data);
}
public function create_product_attr_value($find, $datum, $product_type, $attr_values, $merId, $sku) public function create_product_attr_value($find, $datum, $product_type, $attr_values, $merId, $sku)
{ {

View File

@ -184,6 +184,7 @@ class StoreImport extends BaseController
Queue::push(ImportPicJob::class,['mer_id'=>$mer_id,'path'=>$destination_path]); Queue::push(ImportPicJob::class,['mer_id'=>$mer_id,'path'=>$destination_path]);
return app('json')->success('开始导入数据,请稍后在列表中查看!,如果未导入请检查格式'); return app('json')->success('开始导入数据,请稍后在列表中查看!,如果未导入请检查格式');
} }
public function getXlsList($type_id,$path){ public function getXlsList($type_id,$path){
if($type_id==12){ if($type_id==12){
$check =[ $check =[

View File

@ -23,7 +23,7 @@ class ImportPicJob implements JobInterface
$files = scandir($directory); $files = scandir($directory);
$dir = 'def/' . date('Y-m-d'); $dir = 'def/' . date('Y-m-d');
$upload = UploadService::create(); $upload = UploadService::create();
try {
/**循环目录 */ /**循环目录 */
foreach ($files as $file) { foreach ($files as $file) {
if ($file === '.' || $file === '..' || $file === '__MACOSX') { if ($file === '.' || $file === '..' || $file === '__MACOSX') {
@ -67,7 +67,6 @@ class ImportPicJob implements JobInterface
if ($sku) { if ($sku) {
$sku = implode(',', $sku); $sku = implode(',', $sku);
$sku_arr[$sku] = $directory . '/' . $file . '/' . $file_two; $sku_arr[$sku] = $directory . '/' . $file . '/' . $file_two;
} }
} }
} }
@ -77,7 +76,6 @@ class ImportPicJob implements JobInterface
$update_content['image'] = []; $update_content['image'] = [];
$find = Db::name('store_product')->where($where)->where('store_name', $file)->find(); $find = Db::name('store_product')->where($where)->where('store_name', $file)->find();
if ($find) { if ($find) {
try {
/**更新商品图片 */ /**更新商品图片 */
$image = $upload->to($dir)->stream(file_get_contents($image)); $image = $upload->to($dir)->stream(file_get_contents($image));
$update['image'] = $image->filePath; $update['image'] = $image->filePath;
@ -116,14 +114,17 @@ class ImportPicJob implements JobInterface
Db::name('store_product_content') Db::name('store_product_content')
->insert(['product_id' => $find['product_id'], 'type' => 1, 'content' => json_encode($update_content)]); ->insert(['product_id' => $find['product_id'], 'type' => 1, 'content' => json_encode($update_content)]);
} }
}
}
} catch (Exception $e) { } catch (Exception $e) {
halt($e->getMessage(), $e->getLine()); $data['product_id'] = $find['product_id'];
} $data['mer_id'] = $data['mer_id'];
} $data['store_name'] = $find['store_name'];
$data['content'] = $e->getMessage();
$this->create_product_import_log($data, 0);
} }
$job->delete(); $job->delete();
} }
public function failed($data) public function failed($data)
@ -131,4 +132,17 @@ class ImportPicJob implements JobInterface
Log::error('导入商品图片失败:' . json_encode($data)); Log::error('导入商品图片失败:' . json_encode($data));
// TODO: Implement failed() method. // TODO: Implement failed() method.
} }
public function create_product_import_log($data, $status = 1)
{
$data = [
'product_id' => $data['product_id'],
'mer_id' => $data['mer_id'],
'name' => $data['store_name'],
'content' => $data['content'] ?? '',
'status' => $status,
'create_time' => date('Y-m-d H:i:s'),
];
Db::name('store_product_import')->insert($data);
}
} }