57 lines
1.8 KiB
PHP
57 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace Modules\EcommerceFinance\Repositories;
|
|
|
|
/** 店铺收款账单·抖音账户(头条放心购)只读共享业务镜像。 */
|
|
class StoreReceivingDouyinBillMirrorRepository
|
|
{
|
|
public const SOURCE_CHANNEL = 'TouTiaoFXGZJ';
|
|
|
|
public function __construct(
|
|
private readonly StoreReceivingAlipayBillMirrorRepository $source,
|
|
private readonly ?DouyinAuthoritativeBillRepository $authoritative = null,
|
|
) {
|
|
}
|
|
|
|
/** @return array<string,mixed> */
|
|
public function paginate(array $filters, string $sort, string $direction, int $page, int $perPage): array
|
|
{
|
|
if ($this->authoritative?->available()) {
|
|
return $this->authoritative->paginate($filters, $sort, $direction, $page, $perPage);
|
|
}
|
|
return $this->source->paginateChannel(
|
|
$filters,
|
|
$sort,
|
|
$direction,
|
|
$page,
|
|
$perPage,
|
|
self::SOURCE_CHANNEL,
|
|
'douyin',
|
|
);
|
|
}
|
|
|
|
/** @return iterable<int,array<string,mixed>> */
|
|
public function exportRows(array $filters, string $sort = 'occurred_at', string $direction = 'asc'): iterable
|
|
{
|
|
if ($this->authoritative?->available()) {
|
|
return $this->authoritative->exportRows($filters, $sort, $direction);
|
|
}
|
|
return $this->source->exportChannelRows(
|
|
$filters,
|
|
$sort,
|
|
$direction,
|
|
self::SOURCE_CHANNEL,
|
|
'douyin',
|
|
);
|
|
}
|
|
|
|
/** @return array{shops:array<int,string>,bill_items:array<int,string>} */
|
|
public function filterOptions(): array
|
|
{
|
|
if ($this->authoritative?->available()) {
|
|
return $this->authoritative->filterOptions();
|
|
}
|
|
return $this->source->filterOptionsForChannel(self::SOURCE_CHANNEL);
|
|
}
|
|
}
|