34 lines
1.1 KiB
PHP
34 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace Modules\EcommerceFinance\Services;
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class AccessoryReshipSelectionStore
|
|
{
|
|
public const TABLE = 'business_accessory_reship_selections';
|
|
|
|
public static function key(array $row): string
|
|
{
|
|
return hash('sha256', json_encode([
|
|
(string) ($row['source_id'] ?? ''), (string) ($row['trade_no'] ?? ''),
|
|
(string) ($row['express_no'] ?? ''), (string) ($row['ship_time'] ?? ''),
|
|
(string) ($row['normalized_barcode'] ?? ''),
|
|
], JSON_UNESCAPED_UNICODE));
|
|
}
|
|
|
|
public function forMonth(int $companyId, string $month): array
|
|
{
|
|
return DB::table(self::TABLE)->where('company_id', $companyId)->where('month', $month)
|
|
->pluck('courier_name', 'row_key')->all();
|
|
}
|
|
|
|
public function save(int $companyId, string $month, string $key, string $courier, string $actor): void
|
|
{
|
|
DB::table(self::TABLE)->updateOrInsert(
|
|
['company_id' => $companyId, 'month' => $month, 'row_key' => $key],
|
|
['courier_name' => $courier, 'actor' => $actor, 'updated_at' => now()]
|
|
);
|
|
}
|
|
}
|