*/ public const STORE_NAMES = [ '支付宝-常州春之华家居有限公司', '支付宝-常州诗科家电子商务有限公司', '支付宝-常州玖阔家居有限公司20240319', '支付宝-常州阔之煜家居有限公司', '支付宝-常州熊泽家居有限公司', '支付宝-常州雄川家居有限公司', '支付宝-常州泽之云家居有限公司', '支付宝-常州君佰家居有限公司', ]; /** @var array */ public const ACCOUNT_MAP = [ '支付宝-常州春之华家居有限公司' => ['store' => '得物-全米', 'merchant_no' => '2088641917126568'], '支付宝-常州诗科家电子商务有限公司' => ['store' => '得物-木刻理想', 'merchant_no' => '2088741650909210'], '支付宝-常州玖阔家居有限公司20240319' => ['store' => '得物-米客米家家居旗舰店', 'merchant_no' => '2088841004631652'], '支付宝-常州阔之煜家居有限公司' => ['store' => '得物-宜造', 'merchant_no' => '2088841085257651'], '支付宝-常州熊泽家居有限公司' => ['store' => '得物-墨尚思', 'merchant_no' => '2088841143397934'], '支付宝-常州雄川家居有限公司' => ['store' => '得物-卓禾', 'merchant_no' => '2088741272387795'], '支付宝-常州泽之云家居有限公司' => ['store' => '得物-欧意朗', 'merchant_no' => '2088841917714972'], '支付宝-常州君佰家居有限公司' => ['store' => '得物-亿家达', 'merchant_no' => '2088970585568179'], ]; private readonly TaobaoAlipaySettlementBillRepository $source; public function __construct(TaobaoAlipaySettlementBillRepository $source) { $this->source = $source->scopedToStores(self::STORE_NAMES); } /** @return array */ public function paginate(array $filters, string $sort, string $direction, int $page, int $perPage): array { $result = $this->source->paginate($filters, $sort, $direction, $page, $perPage); $result['data'] = array_map( fn (array $row): array => $this->withAccountMap($row), $result['data'], ); return $result; } /** @return iterable> */ public function exportRows(array $filters, string $sort = 'occurred_at', string $direction = 'asc'): iterable { foreach ($this->source->exportRows($filters, $sort, $direction) as $row) { yield $this->withAccountMap($row); } } /** @return array{shops:list,bill_items:list} */ public function filterOptions(): array { $options = $this->source->accountBillFilterOptions(); $shops = array_values(array_unique(array_merge(self::STORE_NAMES, $options['shops']))); sort($shops, SORT_NATURAL); return [ 'shops' => $shops, 'bill_items' => $options['bill_items'], ]; } /** @param array $row @return array */ private function withAccountMap(array $row): array { $accountName = trim((string) ($row['store_name'] ?? '')); $mapping = self::ACCOUNT_MAP[$accountName] ?? null; $row['dewu_alipay_account_name'] = $accountName; $row['dewu_store_name'] = $mapping['store'] ?? ''; $row['dewu_merchant_no'] = $mapping['merchant_no'] ?? ''; return $row; } }