fix: #10000 盘点导入修改
This commit is contained in:
parent
5da97fe3cf
commit
a853e1ecf4
@ -8,11 +8,11 @@ use App\Models\GoodsSku;
|
||||
use App\Utils\DateTimeUtils;
|
||||
use Exception;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Maatwebsite\Excel\Concerns\SkipsEmptyRows;
|
||||
use Maatwebsite\Excel\Concerns\ToCollection;
|
||||
use App\Utils\ArrayUtils;
|
||||
use App\Events\StockUpdateEvent;
|
||||
|
||||
class InventoryImport implements ToCollection, SkipsEmptyRows
|
||||
{
|
||||
@ -36,8 +36,6 @@ class InventoryImport implements ToCollection, SkipsEmptyRows
|
||||
$updateIds = [];
|
||||
$day = DateTimeUtils::getToday();
|
||||
$dateTime = date('Y-m-d H:i:s');
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
foreach ($collection as $row) {
|
||||
if (!isset($hasGoods[$row[0]])) {
|
||||
continue;
|
||||
@ -51,7 +49,11 @@ class InventoryImport implements ToCollection, SkipsEmptyRows
|
||||
continue;
|
||||
}
|
||||
$goodsSku->stock = $row[6] + $row[7];
|
||||
if ('下架' === $goodsSku->status) {
|
||||
$goodsSku->status = 1;
|
||||
}
|
||||
$goodsSku->save();
|
||||
event(new StockUpdateEvent($goodsSku));
|
||||
$updateIds[] = $goodsSku->id;
|
||||
DailyStockRecord::query()->where('sku_id', $goodsSku->id)->where('day', $day)->update([
|
||||
'arrived_today_num' => $row[7],
|
||||
@ -59,12 +61,6 @@ class InventoryImport implements ToCollection, SkipsEmptyRows
|
||||
'inventory_time' => $dateTime
|
||||
]);
|
||||
}
|
||||
DB::commit();
|
||||
} catch (Exception $exception) {
|
||||
DB::rollBack();
|
||||
// 返回错误
|
||||
throw $exception;
|
||||
}
|
||||
$onSkuIds = GoodsSku::query()
|
||||
->where('status', '<>', 0)
|
||||
->pluck('id')
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user