调整商品分类的错误

This commit is contained in:
lewis 2024-12-23 17:42:48 +08:00
parent c66204184b
commit be6cf0aa3f

View File

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