Merge pull request '调整商品分类的错误' (#406) from dev into main

Reviewed-on: #406
This commit is contained in:
mkm 2024-12-23 17:42:55 +08:00
commit 147eefa363

View File

@ -19,11 +19,10 @@ class LocalController extends BaseAdminController
$spreadsheet = $reader->load($file->getRealPath());
$data = $spreadsheet->getActiveSheet()->toArray();
$updateCount = 0;
$finishCount = Redis::get('finishCount');
$finishCount = Redis::get('updateFinishCount');
$finishCount = empty($finishCount) ? 0 : $finishCount;
if ($finishCount >= count($data)) {
echo '数据已更新完成';
return;
return $this->success('数据已更新完成');
}
$max = $finishCount + 100;
foreach ($data as $k => $row) {
@ -42,15 +41,15 @@ class LocalController extends BaseAdminController
$updateCount++;
}
}
Redis::set('finishCount', 100 + $finishCount);
echo '更新成功:' . $updateCount . '条';
Redis::set('updateFinishCount', 100 + $finishCount);
return $this->success('更新成功:' . $updateCount . '条');
}
public function updateProduct($product, $row)
{
$topCateName = rtrim($row[1], '类');
$secondCateName = rtrim($row[2], '类');
$cateName = rtrim($row[3], '类');
$topCateName = $row[1];
$secondCateName = $row[2];
$cateName = $row[3];
$topCate = StoreCategory::where('name', $topCateName)->value('id');
$updateData = [];
if (!empty($topCate) && $topCate != $product['top_cate_id']) {