diff --git a/app/Http/Controllers/Business/Pages.php b/app/Http/Controllers/Business/Pages.php index 2fc2267a..fb669654 100644 --- a/app/Http/Controllers/Business/Pages.php +++ b/app/Http/Controllers/Business/Pages.php @@ -7056,6 +7056,8 @@ class Pages extends Controller $syncStatus = $this->nonJingxiRefunds->syncStatus($states); if (! $this->nonJingxiRefunds->ready()) { $pending = true; + } elseif ($pendingConfirmation && ! $this->nonJingxiRefunds->pendingConfirmationStatusReady()) { + $pending = true; } elseif (! $this->nonJingxiRefunds->queryReady()) { $indexPending = true; } else { diff --git a/config/business_data.php b/config/business_data.php index 348db6c9..753d0062 100644 --- a/config/business_data.php +++ b/config/business_data.php @@ -97,6 +97,10 @@ return [ 'role' => 'fact', 'target_store' => 'mariadb', 'consumer' => '订单售后费用明细·淘系售后明细', 'sync' => 'always', ], + 'jiansun.dbo.jst_refund_view' => [ + 'role' => 'operational', 'target_store' => 'mariadb', 'consumer' => '退款待确认·聚水潭当前状态', + 'partition_column' => 'as_date', 'sync' => 'always', + ], // This 20M+ row mapping is not queried by the current promotion page. // Keep/archive its existing data, but stop upstream refresh immediately. diff --git a/config/upstream_mirrors.php b/config/upstream_mirrors.php index f18434ea..be4d2f88 100644 --- a/config/upstream_mirrors.php +++ b/config/upstream_mirrors.php @@ -332,6 +332,7 @@ return [ 'operations_replica.rpt.jst_returnAndRefundItem', 'operations_replica.rpt.jst_qmcust_refundlist', 'operations_replica.rpt.jst_qmcust_refundlist_item', + 'jiansun.dbo.jst_refund_view', ], ], @@ -480,6 +481,22 @@ return [ ['as_id', 'Id'], ], ], + // 聚水潭报表副本的退款主表偶发仍停在 WaitConfirm,但本地业务库的 + // 当前退款视图已更新为 Confirmed。退款待确认页以该视图覆盖旧状态。 + 'jiansun.dbo.jst_refund_view' => [ + 'source_key' => 'jiansun', + 'schema' => 'dbo', + 'object' => 'jst_refund_view', + 'target' => 'ops_jst_refund_status', + 'keys' => ['as_id'], + 'watermark' => 'modified', + 'minimum_datetime' => ['column' => 'as_date', 'value' => '2026-10-01 00:00:00'], + 'full_reconcile_hours' => 168, + 'columns' => ['as_id', 'status', 'shop_status', 'confirm_date', 'modified', 'as_date'], + 'indexes' => [ + ['as_id'], + ], + ], 'operations_replica.rpt.jst_shopInfo' => ['source_key' => 'operations_replica', 'schema' => 'rpt', 'object' => 'jst_shopInfo', 'target' => 'ops_jst_shop_info', 'keys' => ['Id'], 'watermark' => 'updateTime', 'indexes' => [['shop_id', 'Id']]], // 淘系(天猫/淘宝)订单与售后:聚水潭单独存放在 qmcust 这套表里, diff --git a/docs/上游业务镜像清单.md b/docs/上游业务镜像清单.md index 10bd9a49..61dbe293 100644 --- a/docs/上游业务镜像清单.md +++ b/docs/上游业务镜像清单.md @@ -68,6 +68,7 @@ | 商品与仓库 | `rpt.jst_sku`、`rpt.jst_warehouseInfo`、`rpt.jst_skumap` | `ops_jst_*`(普通商品资料已切换) | | 推广费用 | `rpt.ads_itemid_sales_cost_ratio_v2_di` | `ops_item_sales_cost_ratio` | | 退款退货 | `rpt.jst_returnAndRefundInfo`、`rpt.jst_returnAndRefundItem`、`rpt.jst_qmcust_refundlist`、`rpt.jst_qmcust_refundlist_item` | `ops_jst_return_refund_*`、`ops_jst_qmcust_refunds`、`ops_jst_qmcust_refund_items` | +| 退款当前状态 | `jiansun/dbo.jst_refund_view` | `ops_jst_refund_status` | | 聚水潭店铺 | `rpt.jst_shopInfo` | `ops_jst_shop_info` | | 聚水潭原始账单 | `rpt.jst_originalBillInfo` | `ops_jst_original_bill_info` | | 店铺维度报表 | `jiansun/dbo.jst_originalBillInfo + dbo.jst_shopInfo + dbo.fys_shopInfo_flow` | `store_report_bill_rows`、`store_report_lifecycle_rows`、`store_report_daily_rows` | @@ -77,7 +78,7 @@ 售后(退货退款)页面及其导出共同读取上述两套售后主单、各自商品明细与店铺镜像,按 `as_date` 筛选。原售后资料优先;退款清单按 `as_id`、或非空的 `(shop_id, outer_as_id)` 排除已存在的业务单。无商品明细的主单仍显示,商品数量、明细金额及成本留空;店铺平台无法唯一确认时标为“待确认”,不推断平台。两个来源的订单关联不得混用。订单号筛选按完整内部订单号、线上订单号或平台售后单号精确查询,避免长文本标识的全表扫描;店铺和商品仍支持包含搜索。分页先限制各来源的候选主单及行标识,再加载当前页明细;导出使用同一筛选及稳定游标。 -“退款待确认”复用同一套售后查询,并在两个来源的 SQL 中固定筛选 `status=WaitConfirm`、`shop_status=SUCCESS`;页面分别显示为“待确认”和“退款成功”。筛选与导出始终保留该固定条件。 +“退款待确认”复用同一套售后查询,并用 `dbo.jst_refund_view` 的当前 `as_id => status/shop_status` 覆盖报表副本里的旧状态后固定筛选 `status=WaitConfirm`、`shop_status=SUCCESS`;页面分别显示为“待确认”和“退款成功”。覆盖表只保留 2026-10-01 起的当前状态字段,按 `as_id` 建立索引并每日同步。筛选与导出始终保留该固定条件。 `jst_returnAndRefundItem` 没有更新时间,除按 `Id` 追加外,每 168 小时通过现有调度分批执行可续传全量校准,覆盖历史编号变化及删除;全量完成后才清理上一代残留。人工历史校准前须备份相关镜像、目录及同步状态,并持有生产上游同步互斥锁。退款清单两表继续按 `local_updated` 使用重叠增量,不新建重复镜像。 diff --git a/modules/EcommerceFinance/Repositories/NonJingxiRefundMirrorRepository.php b/modules/EcommerceFinance/Repositories/NonJingxiRefundMirrorRepository.php index ea5609cc..e48802e2 100644 --- a/modules/EcommerceFinance/Repositories/NonJingxiRefundMirrorRepository.php +++ b/modules/EcommerceFinance/Repositories/NonJingxiRefundMirrorRepository.php @@ -23,6 +23,8 @@ class NonJingxiRefundMirrorRepository public const SHOP_DATASET = 'operations_replica.rpt.jst_shopInfo'; + public const STATUS_DATASET = 'jiansun.dbo.jst_refund_view'; + private const PENDING_CONFIRMATION_STATUS = 'WaitConfirm'; private const PENDING_CONFIRMATION_ONLINE_STATUS = 'SUCCESS'; @@ -75,6 +77,16 @@ class NonJingxiRefundMirrorRepository ->every(fn (string $key): bool => $this->mirror->ready($this->dataset($key))); } + public function pendingConfirmationStatusReady(): bool + { + try { + return Schema::connection($this->connection->getName())->hasTable('ops_jst_refund_status') + && $this->mirror->ready($this->dataset(self::STATUS_DATASET)); + } catch (\Throwable) { + return false; + } + } + public function queryReady(): bool { $schema = Schema::connection($this->connection->getName()); @@ -119,11 +131,12 @@ class NonJingxiRefundMirrorRepository self::SUPPLEMENT_DATASET => $this->mirror->state($this->dataset(self::SUPPLEMENT_DATASET)), self::SUPPLEMENT_ITEM_DATASET => $this->mirror->state($this->dataset(self::SUPPLEMENT_ITEM_DATASET)), self::SHOP_DATASET => $this->mirror->state($this->dataset(self::SHOP_DATASET)), + self::STATUS_DATASET => $this->mirror->state($this->dataset(self::STATUS_DATASET)), ]; } /** - * 财务驾驶舱只读取每日同步的四张退款表状态,使用一次查询避免拖慢首页。 + * 财务驾驶舱只读取每日同步的退款表状态,使用一次查询避免拖慢首页。 * * @return array|null> */ @@ -134,6 +147,7 @@ class NonJingxiRefundMirrorRepository self::ITEM_DATASET, self::SUPPLEMENT_DATASET, self::SUPPLEMENT_ITEM_DATASET, + self::STATUS_DATASET, ]; $states = $this->connection->table('business_mirror_table_states') ->whereIn('dataset_key', $keys) @@ -152,7 +166,7 @@ class NonJingxiRefundMirrorRepository public function syncStatus(?array $states = null, ?CarbonInterface $at = null): array { $states ??= $this->states(); - if (count(array_filter($states, 'is_array')) !== 5) { + if (count(array_filter($states, 'is_array')) !== 6) { return ['code' => 'unavailable', 'last_succeeded_at' => null]; } @@ -211,6 +225,7 @@ class NonJingxiRefundMirrorRepository */ public function paginatePendingConfirmation(array $filters, int $page, int $perPage): array { + $this->assertPendingStatusReady(); $result = $this->paginate($this->pendingConfirmationFilters($filters), $page, $perPage); foreach ($result['data'] as $row) { $this->normalizePendingConfirmationLabels($row); @@ -227,6 +242,7 @@ class NonJingxiRefundMirrorRepository */ public function pagePendingConfirmation(array $filters, int $page, int $perPage): array { + $this->assertPendingStatusReady(); if (! $this->ready() || ! $this->queryReady()) { throw new RuntimeException('business_mirror_dataset_not_ready'); } @@ -252,6 +268,7 @@ class NonJingxiRefundMirrorRepository */ public function pendingConfirmationMonthlySummary(string $from, string $to): array { + $this->assertPendingStatusReady(); if (! $this->ready() || ! $this->queryReady()) { throw new RuntimeException('business_mirror_dataset_not_ready'); } @@ -313,6 +330,7 @@ class NonJingxiRefundMirrorRepository */ public function pendingConfirmationPlatformMonthlySummary(string $from, string $to): array { + $this->assertPendingStatusReady(); if (! $this->ready() || ! $this->queryReady()) { throw new RuntimeException('business_mirror_dataset_not_ready'); } @@ -426,6 +444,7 @@ class NonJingxiRefundMirrorRepository */ public function exportPendingConfirmationRows(array $filters, int $chunkSize = 1000): iterable { + $this->assertPendingStatusReady(); foreach ($this->exportRows($this->pendingConfirmationFilters($filters), $chunkSize) as $row) { $this->normalizePendingConfirmationLabels($row); yield $row; @@ -509,8 +528,14 @@ class NonJingxiRefundMirrorRepository }); }); } + $statusAlias = null; + if (trim((string) ($filters['status'] ?? '')) !== '' + || trim((string) ($filters['shop_status'] ?? '')) !== '') { + $statusAlias = 'current_refund'; + $query->leftJoin('ops_jst_refund_status as current_refund', 'current_refund.as_id', '=', 'r.as_id'); + } $this->applyPlatformFilter($query, $filters, $supplement); - $this->applyFilters($query, $filters); + $this->applyFilters($query, $filters, $statusAlias); if ($filters['sku_id'] !== '') { if ($withItems) { $this->applySkuFilter($query, $filters['sku_id']); @@ -667,19 +692,27 @@ class NonJingxiRefundMirrorRepository } /** @param array{from:string,to:string,order_no:string,waybill_no:string,shop_name:string,sku_id:string,platform?:string} $filters */ - private function applyFilters(Builder $query, array $filters): void + private function applyFilters(Builder $query, array $filters, ?string $statusAlias = null): void { $query->where('r.as_date', '>=', $filters['from'] . ' 00:00:00') ->where('r.as_date', '<', Carbon::parse($filters['to'])->addDay()->format('Y-m-d 00:00:00')); $status = trim((string) ($filters['status'] ?? '')); if ($status !== '') { - $query->where('r.status', $status); + if ($statusAlias === null) { + $query->where('r.status', $status); + } else { + $query->whereRaw("COALESCE({$statusAlias}.status, r.status) = ?", [$status]); + } } $shopStatus = trim((string) ($filters['shop_status'] ?? '')); if ($shopStatus !== '') { - $query->where('r.shop_status', $shopStatus); + if ($statusAlias === null) { + $query->where('r.shop_status', $shopStatus); + } else { + $query->whereRaw("COALESCE({$statusAlias}.shop_status, r.shop_status) = ?", [$shopStatus]); + } } if ($filters['shop_name'] !== '') { @@ -779,6 +812,13 @@ class NonJingxiRefundMirrorRepository ]); } + private function assertPendingStatusReady(): void + { + if (! $this->pendingConfirmationStatusReady()) { + throw new RuntimeException('business_mirror_pending_status_not_ready'); + } + } + private function normalizePendingConfirmationLabels(object $row): void { $row->status = '待确认'; diff --git a/modules/EcommerceFinance/Services/RefundPendingSyncStatus.php b/modules/EcommerceFinance/Services/RefundPendingSyncStatus.php index d17d1dd1..adab2a19 100644 --- a/modules/EcommerceFinance/Services/RefundPendingSyncStatus.php +++ b/modules/EcommerceFinance/Services/RefundPendingSyncStatus.php @@ -14,6 +14,7 @@ class RefundPendingSyncStatus NonJingxiRefundMirrorRepository::ITEM_DATASET => '售后商品明细', NonJingxiRefundMirrorRepository::SUPPLEMENT_DATASET => '淘系退款清单', NonJingxiRefundMirrorRepository::SUPPLEMENT_ITEM_DATASET => '淘系退款明细', + NonJingxiRefundMirrorRepository::STATUS_DATASET => '聚水潭当前退款状态', ]; public function __construct( diff --git a/tests/Feature/Business/NonJingxiRefundPageTest.php b/tests/Feature/Business/NonJingxiRefundPageTest.php index dfd1fa8a..bf9d8b39 100644 --- a/tests/Feature/Business/NonJingxiRefundPageTest.php +++ b/tests/Feature/Business/NonJingxiRefundPageTest.php @@ -5,11 +5,26 @@ namespace Tests\Feature\Business; use App\Models\Auth\Permission; use App\Models\Auth\Role; use App\Utilities\BusinessOperationPermissions; +use Illuminate\Support\Carbon; use Modules\EcommerceFinance\Repositories\NonJingxiRefundMirrorRepository; use Tests\Feature\FeatureTestCase; class NonJingxiRefundPageTest extends FeatureTestCase { + protected function setUp(): void + { + parent::setUp(); + + Carbon::setTestNow(Carbon::parse('2026-11-04 12:00:00', 'Asia/Shanghai')); + } + + protected function tearDown(): void + { + Carbon::setTestNow(); + + parent::tearDown(); + } + protected function grantAdminPermission(): void { $this->user->attachPermission( @@ -149,6 +164,7 @@ class NonJingxiRefundPageTest extends FeatureTestCase ]); $repository->shouldReceive('ready')->once()->andReturnTrue(); $repository->shouldReceive('queryReady')->once()->andReturnTrue(); + $repository->shouldReceive('pendingConfirmationStatusReady')->once()->andReturnTrue(); $repository->shouldReceive('pendingConfirmationPlatformMonthlySummary') ->once() ->with('2026-10-01', '2026-11-04') @@ -222,6 +238,7 @@ class NonJingxiRefundPageTest extends FeatureTestCase ]); $repository->shouldReceive('ready')->once()->andReturnTrue(); $repository->shouldReceive('queryReady')->once()->andReturnTrue(); + $repository->shouldReceive('pendingConfirmationStatusReady')->once()->andReturnTrue(); $repository->shouldReceive('pendingConfirmationPlatformMonthlySummary') ->once() ->andReturn(['months' => [], 'platforms' => []]); diff --git a/tests/Feature/Console/BusinessMirrorScheduleTest.php b/tests/Feature/Console/BusinessMirrorScheduleTest.php index 020ea52f..9c63ada9 100644 --- a/tests/Feature/Console/BusinessMirrorScheduleTest.php +++ b/tests/Feature/Console/BusinessMirrorScheduleTest.php @@ -23,6 +23,7 @@ class BusinessMirrorScheduleTest extends TestCase 'operations_replica.rpt.jst_returnAndRefundItem', 'operations_replica.rpt.jst_qmcust_refundlist', 'operations_replica.rpt.jst_qmcust_refundlist_item', + 'jiansun.dbo.jst_refund_view', ], config('upstream_mirrors.table_sync.daily_datasets')); } diff --git a/tests/Unit/EcommerceFinance/NonJingxiRefundMirrorRepositoryTest.php b/tests/Unit/EcommerceFinance/NonJingxiRefundMirrorRepositoryTest.php index fb5a0079..ef144077 100644 --- a/tests/Unit/EcommerceFinance/NonJingxiRefundMirrorRepositoryTest.php +++ b/tests/Unit/EcommerceFinance/NonJingxiRefundMirrorRepositoryTest.php @@ -122,6 +122,25 @@ class NonJingxiRefundMirrorRepositoryTest extends TestCase $this->assertSame('initializing', $this->repository->syncStatus($states)['code']); } + public function test_pending_confirmation_requires_the_current_status_mirror(): void + { + DB::connection('business_mirror')->table('business_mirror_table_states') + ->where('dataset_key', NonJingxiRefundMirrorRepository::STATUS_DATASET) + ->update(['initial_completed_at' => null, 'status' => 'running']); + + $this->assertFalse($this->repository->pendingConfirmationStatusReady()); + $this->expectException(\RuntimeException::class); + $this->expectExceptionMessage('business_mirror_pending_status_not_ready'); + $this->repository->pagePendingConfirmation([ + 'from' => '2026-10-01', + 'to' => '2026-10-31', + 'order_no' => '', + 'waybill_no' => '', + 'shop_name' => '', + 'sku_id' => '', + ], 1, 25); + } + public function test_pending_confirmation_filters_both_sources_by_status_and_online_status(): void { $db = DB::connection('business_mirror'); @@ -150,31 +169,41 @@ class NonJingxiRefundMirrorRepositoryTest extends TestCase $supplementOther = $this->supplement(202, '2026-07-06 10:00:00', 'UNKNOWN'); $supplementOther['shop_status'] = 'SUCCESS'; $db->table('ops_jst_qmcust_refunds')->insert([$supplementPending, $supplementOther]); + $db->table('ops_jst_refund_status')->insert([ + ['as_id' => '101', 'status' => 'Confirmed', 'shop_status' => 'SUCCESS'], + ['as_id' => '102', 'status' => 'WaitConfirm', 'shop_status' => 'SUCCESS'], + ['as_id' => '103', 'status' => 'WaitConfirm', 'shop_status' => 'SUCCESS'], + ['as_id' => '201', 'status' => 'Confirmed', 'shop_status' => 'SUCCESS'], + ['as_id' => '202', 'status' => 'WaitConfirm', 'shop_status' => 'SUCCESS'], + ]); $filters = ['from' => '2026-07-01', 'to' => '2026-07-31', 'order_no' => '', 'waybill_no' => '', 'shop_name' => '', 'sku_id' => '']; $result = $this->repository->paginatePendingConfirmation($filters, 1, 25); - $this->assertSame(2, $result['total']); - $this->assertEqualsCanonicalizing([101, 201], array_map(static fn (object $row): int => (int) $row->as_id, $result['data'])); + $this->assertSame(3, $result['total']); + $this->assertEqualsCanonicalizing([102, 103, 202], array_map(static fn (object $row): int => (int) $row->as_id, $result['data'])); foreach ($result['data'] as $row) { $this->assertSame('待确认', $row->status); $this->assertSame('退款成功', $row->shop_status); } $export = iterator_to_array($this->repository->exportPendingConfirmationRows($filters, 1)); - $this->assertEqualsCanonicalizing([101, 201], array_map(static fn (object $row): int => (int) $row->as_id, $export)); + $this->assertEqualsCanonicalizing([102, 103, 202], array_map(static fn (object $row): int => (int) $row->as_id, $export)); foreach ($export as $row) { $this->assertSame('待确认', $row->status); $this->assertSame('退款成功', $row->shop_status); } - $firstPage = $this->repository->pagePendingConfirmation($filters, 1, 1); - $secondPage = $this->repository->pagePendingConfirmation($filters, 2, 1); - $this->assertCount(1, $firstPage['data']); + $firstPage = $this->repository->pagePendingConfirmation($filters, 1, 2); + $secondPage = $this->repository->pagePendingConfirmation($filters, 2, 2); + $this->assertCount(2, $firstPage['data']); $this->assertTrue($firstPage['has_more']); $this->assertCount(1, $secondPage['data']); $this->assertFalse($secondPage['has_more']); - $this->assertNotSame($firstPage['data'][0]->as_id, $secondPage['data'][0]->as_id); + $this->assertEmpty(array_intersect( + array_map(static fn (object $row): int => (int) $row->as_id, $firstPage['data']), + array_map(static fn (object $row): int => (int) $row->as_id, $secondPage['data']), + )); } public function test_pending_confirmation_monthly_summary_combines_unique_source_counts(): void @@ -198,21 +227,27 @@ class NonJingxiRefundMirrorRepositoryTest extends TestCase $supplement['status'] = 'WaitConfirm'; $supplement['shop_status'] = 'SUCCESS'; $db->table('ops_jst_qmcust_refunds')->insert($supplement); + $db->table('ops_jst_refund_status')->insert([ + ['as_id' => '101', 'status' => 'WaitConfirm', 'shop_status' => 'SUCCESS'], + ['as_id' => '102', 'status' => 'WaitConfirm', 'shop_status' => 'SUCCESS'], + ['as_id' => '103', 'status' => 'WaitConfirm', 'shop_status' => 'SUCCESS'], + ['as_id' => '201', 'status' => 'WaitConfirm', 'shop_status' => 'SUCCESS'], + ]); $summary = $this->repository->pendingConfirmationMonthlySummary('2026-10-01', '2026-11-04'); $this->assertSame([ - ['month' => '2026-10', 'total' => 2, 'primary' => 1, 'supplement' => 1], + ['month' => '2026-10', 'total' => 3, 'primary' => 2, 'supplement' => 1], ['month' => '2026-11', 'total' => 1, 'primary' => 1, 'supplement' => 0], ], $summary); $platformSummary = $this->repository->pendingConfirmationPlatformMonthlySummary('2026-10-01', '2026-11-04'); $this->assertSame([ - ['month' => '2026-10', 'total' => 2], + ['month' => '2026-10', 'total' => 3], ['month' => '2026-11', 'total' => 1], ], $platformSummary['months']); $this->assertSame([ - ['platform' => '天猫', 'total' => 2, 'months' => ['2026-10' => 1, '2026-11' => 1]], + ['platform' => '天猫', 'total' => 3, 'months' => ['2026-10' => 2, '2026-11' => 1]], ['platform' => '待确认', 'total' => 1, 'months' => ['2026-10' => 1, '2026-11' => 0]], ], $platformSummary['platforms']); } @@ -240,6 +275,12 @@ class NonJingxiRefundMirrorRepositoryTest extends TestCase $db->table('ops_jst_shop_info')->insert([ ['Id' => 1, 'shop_id' => 'SHOP-JD', 'shop_site' => '京东商城'], ]); + $db->table('ops_jst_refund_status')->insert([ + ['as_id' => '101', 'status' => 'WaitConfirm', 'shop_status' => 'SUCCESS'], + ['as_id' => '102', 'status' => 'WaitConfirm', 'shop_status' => 'SUCCESS'], + ['as_id' => '201', 'status' => 'WaitConfirm', 'shop_status' => 'SUCCESS'], + ['as_id' => '202', 'status' => 'WaitConfirm', 'shop_status' => 'SUCCESS'], + ]); $filters = [ 'from' => '2026-10-01', @@ -414,6 +455,7 @@ class NonJingxiRefundMirrorRepositoryTest extends TestCase NonJingxiRefundMirrorRepository::SUPPLEMENT_DATASET => $this->definition('jst_qmcust_refundlist', 'ops_jst_qmcust_refunds'), NonJingxiRefundMirrorRepository::SUPPLEMENT_ITEM_DATASET => $this->definition('jst_qmcust_refundlist_item', 'ops_jst_qmcust_refund_items'), NonJingxiRefundMirrorRepository::SHOP_DATASET => $this->definition('jst_shopInfo', 'ops_jst_shop_info'), + NonJingxiRefundMirrorRepository::STATUS_DATASET => $this->definition('jst_refund_view', 'ops_jst_refund_status', 'jiansun'), 'operations_replica.rpt.jst_Orders' => $this->definition('jst_Orders', 'ops_jst_orders'), 'operations_replica.rpt.jst_OrderItem' => $this->definition('jst_OrderItem', 'ops_jst_order_item'), 'operations_replica.rpt.jst_sku' => $this->definition('jst_sku', 'ops_jst_sku'), @@ -422,9 +464,15 @@ class NonJingxiRefundMirrorRepositoryTest extends TestCase } /** @return array */ - private function definition(string $object, string $target): array + private function definition(string $object, string $target, string $sourceKey = 'operations_replica'): array { - return ['source_key' => 'operations_replica', 'schema' => 'rpt', 'object' => $object, 'target' => $target, 'keys' => ['Id']]; + return [ + 'source_key' => $sourceKey, + 'schema' => $sourceKey === 'jiansun' ? 'dbo' : 'rpt', + 'object' => $object, + 'target' => $target, + 'keys' => [$sourceKey === 'jiansun' ? 'as_id' : 'Id'], + ]; } private function createTables(): void @@ -482,6 +530,11 @@ class NonJingxiRefundMirrorRepositoryTest extends TestCase $table->integer('Id'); $table->string('shop_id'); $table->string('shop_site')->nullable(); $table->index(['shop_id', 'Id']); }); + $schema->create('ops_jst_refund_status', function (Blueprint $table): void { + $table->string('as_id'); $table->string('status')->nullable(); $table->string('shop_status')->nullable(); + $table->dateTime('confirm_date')->nullable(); $table->dateTime('modified')->nullable(); $table->dateTime('as_date')->nullable(); + $table->index(['as_id']); + }); $schema->create('ops_jst_qmcust_refunds', function (Blueprint $table): void { $table->string('as_id'); $table->dateTime('as_date'); $table->string('outer_as_id')->nullable(); $table->integer('o_id')->nullable(); $table->string('so_id')->nullable(); $table->string('type')->nullable(); diff --git a/tests/Unit/EcommerceFinance/RefundPendingSyncStatusTest.php b/tests/Unit/EcommerceFinance/RefundPendingSyncStatusTest.php index 01c14f72..63cc8619 100644 --- a/tests/Unit/EcommerceFinance/RefundPendingSyncStatusTest.php +++ b/tests/Unit/EcommerceFinance/RefundPendingSyncStatusTest.php @@ -46,7 +46,7 @@ class RefundPendingSyncStatusTest extends TestCase $this->assertSame('warning', $status['state']); $this->assertSame('退款待确认同步未完成', $status['title']); - $this->assertCount(4, $status['issues']); + $this->assertCount(5, $status['issues']); } public function test_success_after_ten_still_reports_a_deadline_warning(): void @@ -61,7 +61,7 @@ class RefundPendingSyncStatusTest extends TestCase $status = $this->service($states)->current(Carbon::parse('2026-11-04 10:30:00')); $this->assertSame('warning', $status['state']); - $this->assertCount(4, $status['issues']); + $this->assertCount(5, $status['issues']); } /** @param array> $states */ @@ -89,6 +89,7 @@ class RefundPendingSyncStatusTest extends TestCase NonJingxiRefundMirrorRepository::ITEM_DATASET => $state, NonJingxiRefundMirrorRepository::SUPPLEMENT_DATASET => $state, NonJingxiRefundMirrorRepository::SUPPLEMENT_ITEM_DATASET => $state, + NonJingxiRefundMirrorRepository::STATUS_DATASET => $state, ]; } }