first commit

This commit is contained in:
2026-02-15 01:34:17 +07:00
commit baac22e3ae
95 changed files with 13238 additions and 0 deletions

View File

@@ -0,0 +1,59 @@
<?php
declare(strict_types=1);
namespace App\Services\WbService\SyncServices;
use App\Contracts\WbClientInterface;
use App\Contracts\WbSyncInterface;
use App\DTO\WbRequestDTO;
use App\Exceptions\WbServiceException;
use App\Models\Income;
final readonly class IncomesSyncService implements WbSyncInterface
{
public function __construct(
private WbClientInterface $client,
) {
}
/**
* @throws WbServiceException
*/
public function sync(WbRequestDTO $dto): array
{
return $this->client->fetch($dto);
}
public function save(array $data): void
{
if (empty($data)) {
return;
}
collect($data)
->chunk(500)
->each(function ($chunk) {
$rows = $chunk->map(function (array $row) {
return [
'income_id' => $row['income_id'],
'number' => $row['number'],
'date' => $row['date'],
'last_change_date' => $row['last_change_date'],
'supplier_article' => $row['supplier_article'],
'tech_size' => $row['tech_size'],
'barcode' => (string)$row['barcode'],
'quantity' => $row['quantity'],
'total_price' => $row['total_price'],
'date_close' => $row['date_close'],
'warehouse_name' => $row['warehouse_name'],
'nm_id' => $row['nm_id'],
'created_at' => now(),
'updated_at' => now(),
];
})->toArray();
Income::insert($rows);
});
}
}