feat: 接入退款待确认数据 #858
@ -4715,6 +4715,7 @@ class Pages extends Controller
|
||||
'marketing-account-balance' => $this->contentForMarketingAccountBalance($tab),
|
||||
'jingxi-refund-data' => $this->contentForJingxiRefundData(),
|
||||
'non-jingxi-refund-data' => $this->contentForNonJingxiRefundData(),
|
||||
'refund-pending' => $this->contentForRefundPending(),
|
||||
'small-payment-work-orders' => $this->contentForSmallPaymentWorkOrders(),
|
||||
'zhongcai-reconciliation' => $this->contentForZhongcaiReconciliation(),
|
||||
'normal-products' => $this->contentForNormalProducts(),
|
||||
@ -7012,6 +7013,16 @@ class Pages extends Controller
|
||||
}
|
||||
|
||||
protected function contentForNonJingxiRefundData(): array
|
||||
{
|
||||
return $this->contentForRefundData(false);
|
||||
}
|
||||
|
||||
protected function contentForRefundPending(): array
|
||||
{
|
||||
return $this->contentForRefundData(true);
|
||||
}
|
||||
|
||||
private function contentForRefundData(bool $pendingConfirmation): array
|
||||
{
|
||||
$request = request();
|
||||
$defaultTo = now()->toDateString();
|
||||
@ -7027,10 +7038,13 @@ class Pages extends Controller
|
||||
$error = null;
|
||||
$pending = false;
|
||||
$indexPending = false;
|
||||
$pageLabel = $pendingConfirmation ? '退款待确认' : '售后(退货退款)';
|
||||
|
||||
try {
|
||||
if (! $this->nonJingxiRefunds->available()) {
|
||||
$error = '共享业务镜像尚未建立,非京喜退款数据暂时无法读取。';
|
||||
$error = $pendingConfirmation
|
||||
? '共享业务镜像尚未建立,退款待确认数据暂时无法读取。'
|
||||
: '共享业务镜像尚未建立,非京喜退款数据暂时无法读取。';
|
||||
} else {
|
||||
$states = $this->nonJingxiRefunds->states();
|
||||
$syncStatus = $this->nonJingxiRefunds->syncStatus($states);
|
||||
@ -7039,7 +7053,9 @@ class Pages extends Controller
|
||||
} elseif (! $this->nonJingxiRefunds->queryReady()) {
|
||||
$indexPending = true;
|
||||
} else {
|
||||
$result = $this->nonJingxiRefunds->paginate($filters, $page, $limit);
|
||||
$result = $pendingConfirmation
|
||||
? $this->nonJingxiRefunds->paginatePendingConfirmation($filters, $page, $limit)
|
||||
: $this->nonJingxiRefunds->paginate($filters, $page, $limit);
|
||||
$rows = new LengthAwarePaginator(
|
||||
Collection::make($result['data'] ?? []),
|
||||
(int) ($result['total'] ?? 0),
|
||||
@ -7051,7 +7067,7 @@ class Pages extends Controller
|
||||
}
|
||||
} catch (Throwable $exception) {
|
||||
report($exception);
|
||||
$error = '非京喜退款数据暂时无法读取,请稍后重试。';
|
||||
$error = $pageLabel . '数据暂时无法读取,请稍后重试。';
|
||||
}
|
||||
|
||||
return [
|
||||
@ -7062,6 +7078,14 @@ class Pages extends Controller
|
||||
'refundError' => $error,
|
||||
'refundPending' => $pending,
|
||||
'refundIndexPending' => $indexPending,
|
||||
'refundPageSection' => 'refunds',
|
||||
'refundPageSlug' => $pendingConfirmation ? 'refund-pending' : 'non-jingxi-refund-data',
|
||||
'refundPageLabel' => $pageLabel,
|
||||
'refundPendingConfirmationMode' => $pendingConfirmation,
|
||||
'refundOnlineStatusLabel' => $pendingConfirmation ? '线上状态' : '店铺状态',
|
||||
'refundExportRouteName' => $pendingConfirmation
|
||||
? 'business.refunds.refund-pending.export'
|
||||
: 'business.refunds.non-jingxi-refund-data.export',
|
||||
];
|
||||
}
|
||||
|
||||
@ -7088,6 +7112,17 @@ class Pages extends Controller
|
||||
);
|
||||
}
|
||||
|
||||
public function exportRefundPending(Request $request)
|
||||
{
|
||||
return $this->exportRefundRows(
|
||||
$request,
|
||||
'refunds',
|
||||
'refund-pending',
|
||||
'refund_pending',
|
||||
true,
|
||||
);
|
||||
}
|
||||
|
||||
public function exportAfterSalesReturnRefunds(Request $request)
|
||||
{
|
||||
return $this->exportRefundRows(
|
||||
@ -7098,9 +7133,16 @@ class Pages extends Controller
|
||||
);
|
||||
}
|
||||
|
||||
private function exportRefundRows(Request $request, string $section, string $page, string $filenamePrefix)
|
||||
private function exportRefundRows(
|
||||
Request $request,
|
||||
string $section,
|
||||
string $page,
|
||||
string $filenamePrefix,
|
||||
bool $pendingConfirmation = false,
|
||||
)
|
||||
{
|
||||
$filters = $this->nonJingxiRefundFilters($request);
|
||||
$pageLabel = $pendingConfirmation ? '退款待确认' : '售后(退货退款)';
|
||||
$redirectParameters = array_filter([
|
||||
'section' => $section,
|
||||
'page' => $page,
|
||||
@ -7110,31 +7152,36 @@ class Pages extends Controller
|
||||
try {
|
||||
if (! $this->nonJingxiRefunds->available()) {
|
||||
return redirect()->route('business.pages.show', $redirectParameters)
|
||||
->with('error', '共享业务镜像尚未建立,售后(退货退款)暂时不能导出。');
|
||||
->with('error', '共享业务镜像尚未建立,' . $pageLabel . '暂时不能导出。');
|
||||
}
|
||||
|
||||
if (! $this->nonJingxiRefunds->ready()) {
|
||||
return redirect()->route('business.pages.show', $redirectParameters)
|
||||
->with('error', '业务镜像首次同步尚未完成,售后(退货退款)暂时不能导出。');
|
||||
->with('error', '业务镜像首次同步尚未完成,' . $pageLabel . '暂时不能导出。');
|
||||
}
|
||||
|
||||
if (! $this->nonJingxiRefunds->queryReady()) {
|
||||
return redirect()->route('business.pages.show', $redirectParameters)
|
||||
->with('error', '页面查询索引尚未就绪,售后(退货退款)暂时不能导出。');
|
||||
->with('error', '页面查询索引尚未就绪,' . $pageLabel . '暂时不能导出。');
|
||||
}
|
||||
|
||||
$exportRows = $pendingConfirmation
|
||||
? $this->nonJingxiRefunds->exportPendingConfirmationRows($filters)
|
||||
: $this->nonJingxiRefunds->exportRows($filters);
|
||||
|
||||
return $this->streamNonJingxiRefundCsv(
|
||||
$this->nonJingxiRefunds->exportRows($filters),
|
||||
$exportRows,
|
||||
$filters,
|
||||
$redirectParameters,
|
||||
$request->query('columns'),
|
||||
$filenamePrefix,
|
||||
$pendingConfirmation ? '线上状态' : '店铺状态',
|
||||
);
|
||||
} catch (Throwable $exception) {
|
||||
report($exception);
|
||||
|
||||
return redirect()->route('business.pages.show', $redirectParameters)
|
||||
->with('error', '售后(退货退款)导出暂时无法完成,请稍后重试。');
|
||||
->with('error', $pageLabel . '导出暂时无法完成,请稍后重试。');
|
||||
}
|
||||
}
|
||||
|
||||
@ -7168,6 +7215,7 @@ class Pages extends Controller
|
||||
array $redirectParameters,
|
||||
mixed $requestedFields = null,
|
||||
string $filenamePrefix = 'after_sales_refunds',
|
||||
string $onlineStatusLabel = '店铺状态',
|
||||
)
|
||||
{
|
||||
$columns = [
|
||||
@ -7204,7 +7252,7 @@ class Pages extends Controller
|
||||
['label' => '售后金额', 'field' => 'AfSalesMoney', 'number' => true],
|
||||
['label' => '创建时间', 'field' => 'createTime', 'date' => true],
|
||||
['label' => '状态', 'field' => 'status'],
|
||||
['label' => '店铺状态', 'field' => 'shop_status'],
|
||||
['label' => $onlineStatusLabel, 'field' => 'shop_status'],
|
||||
['label' => '创建记录/创建时间', 'field' => 'created', 'date' => true],
|
||||
['label' => '确认日期', 'field' => 'confirm_date', 'date' => true],
|
||||
];
|
||||
|
||||
@ -77,6 +77,8 @@
|
||||
|
||||
售后(退货退款)页面及其导出共同读取上述两套售后主单、各自商品明细与店铺镜像,按 `as_date` 筛选。原售后资料优先;退款清单按 `as_id`、或非空的 `(shop_id, outer_as_id)` 排除已存在的业务单。无商品明细的主单仍显示,商品数量、明细金额及成本留空;店铺平台无法唯一确认时标为“待确认”,不推断平台。两个来源的订单关联不得混用。订单号筛选按完整内部订单号、线上订单号或平台售后单号精确查询,避免长文本标识的全表扫描;店铺和商品仍支持包含搜索。分页先限制各来源的候选主单及行标识,再加载当前页明细;导出使用同一筛选及稳定游标。
|
||||
|
||||
“退款待确认”复用同一套售后查询,并在两个来源的 SQL 中固定筛选 `status=WaitConfirm`、`shop_status=SUCCESS`;页面分别显示为“待确认”和“退款成功”。筛选与导出始终保留该固定条件。
|
||||
|
||||
`jst_returnAndRefundItem` 没有更新时间,除按 `Id` 追加外,每 168 小时通过现有调度分批执行可续传全量校准,覆盖历史编号变化及删除;全量完成后才清理上一代残留。人工历史校准前须备份相关镜像、目录及同步状态,并持有生产上游同步互斥锁。退款清单两表继续按 `local_updated` 使用重叠增量,不新建重复镜像。
|
||||
|
||||
售后页面及导出保留 2026 年起的数据。按用户明确要求,以上四个售后数据集排除退款日期 `2025-01-01 <= as_date < 2026-01-01` 的主单及专属明细;增量和全量校准使用相同的参数化排除条件,避免历史数据回灌。跨年共用的明细、孤立明细和日期为空的记录不按年份推断删除。生产清理须在同步锁内备份原行和同步状态,先删专属明细再删主单,核对 2026 年计数及金额不变;不删除上游原始记录。订单售后费用、财务运营售后费用和业绩差额说明共用这四张镜像,因此不再提供对应的 2025 年售后证据。
|
||||
|
||||
@ -23,6 +23,10 @@ class NonJingxiRefundMirrorRepository
|
||||
|
||||
public const SHOP_DATASET = 'operations_replica.rpt.jst_shopInfo';
|
||||
|
||||
private const PENDING_CONFIRMATION_STATUS = 'WaitConfirm';
|
||||
|
||||
private const PENDING_CONFIRMATION_ONLINE_STATUS = 'SUCCESS';
|
||||
|
||||
private const AUXILIARY_DATASETS = [
|
||||
'operations_replica.rpt.jst_Orders',
|
||||
'operations_replica.rpt.jst_OrderItem',
|
||||
@ -173,6 +177,22 @@ class NonJingxiRefundMirrorRepository
|
||||
return ['data' => $rows->all(), 'total' => $total];
|
||||
}
|
||||
|
||||
/**
|
||||
* 售后状态为待确认、且线上退款已成功的记录。
|
||||
*
|
||||
* @param array{from:string,to:string,order_no:string,waybill_no:string,shop_name:string,sku_id:string} $filters
|
||||
* @return array{data:list<object>,total:int}
|
||||
*/
|
||||
public function paginatePendingConfirmation(array $filters, int $page, int $perPage): array
|
||||
{
|
||||
$result = $this->paginate($this->pendingConfirmationFilters($filters), $page, $perPage);
|
||||
foreach ($result['data'] as $row) {
|
||||
$this->normalizePendingConfirmationLabels($row);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Export all rows matching the supplied filters in the same order and
|
||||
* shape as the paginated page data, without loading the full result set.
|
||||
@ -200,6 +220,18 @@ class NonJingxiRefundMirrorRepository
|
||||
} while ($keys->count() === $chunkSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array{from:string,to:string,order_no:string,waybill_no:string,shop_name:string,sku_id:string} $filters
|
||||
* @return iterable<int,object>
|
||||
*/
|
||||
public function exportPendingConfirmationRows(array $filters, int $chunkSize = 1000): iterable
|
||||
{
|
||||
foreach ($this->exportRows($this->pendingConfirmationFilters($filters), $chunkSize) as $row) {
|
||||
$this->normalizePendingConfirmationLabels($row);
|
||||
yield $row;
|
||||
}
|
||||
}
|
||||
|
||||
/** @return list<string> */
|
||||
private function selectColumns(): array
|
||||
{
|
||||
@ -440,6 +472,16 @@ class NonJingxiRefundMirrorRepository
|
||||
$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);
|
||||
}
|
||||
|
||||
$shopStatus = trim((string) ($filters['shop_status'] ?? ''));
|
||||
if ($shopStatus !== '') {
|
||||
$query->where('r.shop_status', $shopStatus);
|
||||
}
|
||||
|
||||
if ($filters['shop_name'] !== '') {
|
||||
$query->whereRaw("r.shop_name LIKE ? ESCAPE '!'", [$this->contains($filters['shop_name'])]);
|
||||
}
|
||||
@ -449,6 +491,24 @@ class NonJingxiRefundMirrorRepository
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array{from:string,to:string,order_no:string,waybill_no:string,shop_name:string,sku_id:string} $filters
|
||||
* @return array{from:string,to:string,order_no:string,waybill_no:string,shop_name:string,sku_id:string,status:string,shop_status:string}
|
||||
*/
|
||||
private function pendingConfirmationFilters(array $filters): array
|
||||
{
|
||||
return array_replace($filters, [
|
||||
'status' => self::PENDING_CONFIRMATION_STATUS,
|
||||
'shop_status' => self::PENDING_CONFIRMATION_ONLINE_STATUS,
|
||||
]);
|
||||
}
|
||||
|
||||
private function normalizePendingConfirmationLabels(object $row): void
|
||||
{
|
||||
$row->status = '待确认';
|
||||
$row->shop_status = '退款成功';
|
||||
}
|
||||
|
||||
private function applySkuFilter(Builder $query, string $value): void
|
||||
{
|
||||
$needle = $this->contains($value);
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
@php
|
||||
$refundOnlineStatusLabel = $refundOnlineStatusLabel ?? '店铺状态';
|
||||
$columns = [
|
||||
['label' => '序号/主键ID', 'field' => 'Id'],
|
||||
['label' => '退款日期', 'field' => 'refundDate'],
|
||||
@ -33,7 +34,7 @@
|
||||
['label' => '售后金额', 'field' => 'AfSalesMoney', 'number' => true],
|
||||
['label' => '创建时间', 'field' => 'createTime'],
|
||||
['label' => '状态', 'field' => 'status'],
|
||||
['label' => '店铺状态', 'field' => 'shop_status'],
|
||||
['label' => $refundOnlineStatusLabel, 'field' => 'shop_status'],
|
||||
['label' => '创建记录/创建时间', 'field' => 'created'],
|
||||
['label' => '确认日期', 'field' => 'confirm_date'],
|
||||
];
|
||||
@ -53,6 +54,7 @@
|
||||
$refundPageSlug = $refundPageSlug ?? 'non-jingxi-refund-data';
|
||||
$refundPageLabel = $refundPageLabel ?? '售后(退货退款)';
|
||||
$refundWarningMode = $refundWarningMode ?? false;
|
||||
$refundPendingConfirmationMode = $refundPendingConfirmationMode ?? false;
|
||||
$refundShowExport = $refundShowExport ?? true;
|
||||
$refundExportRouteName = $refundExportRouteName ?? 'business.refunds.non-jingxi-refund-data.export';
|
||||
$refundPageUrl = route('business.pages.show', [
|
||||
@ -76,7 +78,7 @@
|
||||
|
||||
<div
|
||||
class="upstream-data-page upstream-data-page--spaced"
|
||||
data-refund-page="{{ $refundWarningMode ? 'after-sales-warning' : 'non-jingxi' }}"
|
||||
data-refund-page="{{ $refundPendingConfirmationMode ? 'pending-confirmation' : ($refundWarningMode ? 'after-sales-warning' : 'non-jingxi') }}"
|
||||
>
|
||||
@include('business.pages.partials.upstream-data-styles')
|
||||
@include('business.pages.partials.date-range-picker')
|
||||
@ -146,6 +148,16 @@
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@if ($refundPendingConfirmationMode)
|
||||
<div class="refund-warning-source" role="note">
|
||||
<span class="material-icons-outlined" aria-hidden="true">filter_alt</span>
|
||||
<div class="refund-warning-source__copy">
|
||||
<strong>固定筛选:状态“待确认” · 线上状态“退款成功”</strong>
|
||||
<span>数据来自聚水潭售后共享镜像;日期、订单号、运单号、店铺和商品编码筛选均会在此基础上生效。</span>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div class="refund-data-sync" role="status" data-sync-state="{{ $syncCode }}">
|
||||
<span class="material-icons-outlined" aria-hidden="true">sync</span>
|
||||
<span>{{ $syncLabel }}</span>
|
||||
@ -317,6 +329,8 @@
|
||||
页面查询索引尚未就绪,当前不会执行高压力查询。
|
||||
@elseif ($refundError)
|
||||
数据暂时无法读取。
|
||||
@elseif ($refundPendingConfirmationMode)
|
||||
当前退款日期范围内没有待确认记录。
|
||||
@else
|
||||
当前筛选范围暂无数据。
|
||||
@endif
|
||||
|
||||
@ -484,6 +484,10 @@ Route::get('workspace/refunds/non-jingxi-refund-data/export', 'Business\Pages@ex
|
||||
->middleware('business.page:refunds,non-jingxi-refund-data')
|
||||
->name('business.refunds.non-jingxi-refund-data.export');
|
||||
|
||||
Route::get('workspace/refunds/refund-pending/export', 'Business\Pages@exportRefundPending')
|
||||
->middleware('business.page:refunds,refund-pending')
|
||||
->name('business.refunds.refund-pending.export');
|
||||
|
||||
Route::get('workspace/other/after-sales-return-refund/export', 'Business\Pages@exportAfterSalesReturnRefunds')
|
||||
->middleware('business.page:other,after-sales-return-refund')
|
||||
->name('business.other.after-sales-return-refund.export');
|
||||
|
||||
@ -128,6 +128,67 @@ class NonJingxiRefundPageTest extends FeatureTestCase
|
||||
], json_decode(html_entity_decode($exportQuery[1], ENT_QUOTES | ENT_HTML5, 'UTF-8'), true, 512, JSON_THROW_ON_ERROR));
|
||||
}
|
||||
|
||||
public function test_refund_pending_page_uses_fixed_confirmation_filter_and_online_status_label(): void
|
||||
{
|
||||
$this->grantAdminPermission();
|
||||
setting()->set('default.list_limit', 25);
|
||||
|
||||
$states = [
|
||||
NonJingxiRefundMirrorRepository::INFO_DATASET => ['status' => 'succeeded', 'initial_completed_at' => '2026-08-15 00:00:00'],
|
||||
NonJingxiRefundMirrorRepository::ITEM_DATASET => ['status' => 'succeeded', 'initial_completed_at' => '2026-08-15 00:00:00'],
|
||||
];
|
||||
$repository = \Mockery::mock(NonJingxiRefundMirrorRepository::class);
|
||||
$repository->shouldReceive('available')->once()->andReturnTrue();
|
||||
$repository->shouldReceive('states')->once()->andReturn($states);
|
||||
$repository->shouldReceive('syncStatus')->once()->with($states)->andReturn([
|
||||
'code' => 'healthy',
|
||||
'last_succeeded_at' => '2026-08-21 12:00:00',
|
||||
]);
|
||||
$repository->shouldReceive('ready')->once()->andReturnTrue();
|
||||
$repository->shouldReceive('queryReady')->once()->andReturnTrue();
|
||||
$repository->shouldReceive('paginatePendingConfirmation')->once()->withArgs(
|
||||
static fn (array $filters, int $page, int $limit): bool =>
|
||||
$filters === [
|
||||
'from' => '2026-11-01',
|
||||
'to' => '2026-11-04',
|
||||
'order_no' => '743478803',
|
||||
'waybill_no' => '',
|
||||
'shop_name' => '京东-米客米家旗舰店',
|
||||
'sku_id' => '',
|
||||
] && $page === 1 && $limit === 25
|
||||
)->andReturn([
|
||||
'data' => [(object) [
|
||||
'Id' => 743478803,
|
||||
'refundDate' => '2026-11-04 14:12:06',
|
||||
'as_id' => 743478803,
|
||||
'outer_as_id' => '743478803',
|
||||
'o_id' => 9765753,
|
||||
'shop_name' => '京东-米客米家旗舰店',
|
||||
'status' => '待确认',
|
||||
'shop_status' => '退款成功',
|
||||
]],
|
||||
'total' => 1,
|
||||
]);
|
||||
$this->app->instance(NonJingxiRefundMirrorRepository::class, $repository);
|
||||
|
||||
$this->loginAs()->get(route('business.pages.show', [
|
||||
'section' => 'refunds',
|
||||
'page' => 'refund-pending',
|
||||
'from' => '2026-11-01',
|
||||
'to' => '2026-11-04',
|
||||
'order_no' => '743478803',
|
||||
'shop_name' => '京东-米客米家旗舰店',
|
||||
]))
|
||||
->assertOk()
|
||||
->assertSeeText('固定筛选:状态“待确认” · 线上状态“退款成功”')
|
||||
->assertSeeText('线上状态')
|
||||
->assertSeeText('743478803')
|
||||
->assertSeeText('待确认')
|
||||
->assertSeeText('退款成功')
|
||||
->assertSee('workspace/refunds/refund-pending/export', false)
|
||||
->assertSee('data-refund-page="pending-confirmation"', false);
|
||||
}
|
||||
|
||||
public function test_refund_export_downloads_filtered_csv(): void
|
||||
{
|
||||
$this->grantAdminPermission();
|
||||
@ -199,6 +260,46 @@ class NonJingxiRefundPageTest extends FeatureTestCase
|
||||
$this->assertStringContainsString('99.5', $content);
|
||||
}
|
||||
|
||||
public function test_refund_pending_export_uses_fixed_confirmation_rows(): void
|
||||
{
|
||||
$this->grantAdminPermission();
|
||||
$repository = \Mockery::mock(NonJingxiRefundMirrorRepository::class);
|
||||
$repository->shouldReceive('available')->once()->andReturnTrue();
|
||||
$repository->shouldReceive('ready')->once()->andReturnTrue();
|
||||
$repository->shouldReceive('queryReady')->once()->andReturnTrue();
|
||||
$repository->shouldReceive('exportPendingConfirmationRows')->once()->with([
|
||||
'from' => '2026-11-01',
|
||||
'to' => '2026-11-04',
|
||||
'order_no' => '743478803',
|
||||
'waybill_no' => '',
|
||||
'shop_name' => '',
|
||||
'sku_id' => '',
|
||||
])->andReturn([(object) [
|
||||
'Id' => 743478803,
|
||||
'refundDate' => '2026-11-04 14:12:06',
|
||||
'as_id' => 743478803,
|
||||
'outer_as_id' => '743478803',
|
||||
'o_id' => 9765753,
|
||||
'shop_name' => '京东-米客米家旗舰店',
|
||||
'status' => '待确认',
|
||||
'shop_status' => '退款成功',
|
||||
]]);
|
||||
$this->app->instance(NonJingxiRefundMirrorRepository::class, $repository);
|
||||
|
||||
$response = $this->loginAs()->get(route('business.refunds.refund-pending.export', [
|
||||
'from' => '2026-11-01',
|
||||
'to' => '2026-11-04',
|
||||
'order_no' => '743478803',
|
||||
]));
|
||||
|
||||
$response->assertOk()->assertDownload('refund_pending_2026-11-01_2026-11-04.csv');
|
||||
$content = $response->streamedContent();
|
||||
$this->assertStringContainsString('线上状态', $content);
|
||||
$this->assertStringContainsString('待确认', $content);
|
||||
$this->assertStringContainsString('退款成功', $content);
|
||||
$this->assertStringContainsString('743478803', $content);
|
||||
}
|
||||
|
||||
public function test_refund_export_accepts_only_declared_columns_in_requested_order(): void
|
||||
{
|
||||
$this->grantAdminPermission();
|
||||
|
||||
@ -46,8 +46,8 @@ class NavigationTest extends FeatureTestCase
|
||||
]))
|
||||
->assertOk()
|
||||
->assertSeeText('退款待确认')
|
||||
->assertSeeText('退款待确认页面已创建')
|
||||
->assertSeeText('退款数据源接入后,待确认的退款记录将在这里展示。');
|
||||
->assertSeeText('固定筛选:状态“待确认” · 线上状态“退款成功”')
|
||||
->assertSeeText('数据来自聚水潭售后共享镜像');
|
||||
}
|
||||
|
||||
public function testInventoryReportMenuPageIsAvailable(): void
|
||||
|
||||
@ -122,6 +122,53 @@ class NonJingxiRefundMirrorRepositoryTest extends TestCase
|
||||
$this->assertSame('initializing', $this->repository->syncStatus($states)['code']);
|
||||
}
|
||||
|
||||
public function test_pending_confirmation_filters_both_sources_by_status_and_online_status(): void
|
||||
{
|
||||
$db = DB::connection('business_mirror');
|
||||
$db->table('ops_jst_return_refund_info')->insert([
|
||||
array_replace($this->refundInfo(1, 101, '2026-07-02 10:00:00', '天猫', '测试店'), [
|
||||
'status' => 'WaitConfirm',
|
||||
'shop_status' => 'SUCCESS',
|
||||
]),
|
||||
array_replace($this->refundInfo(2, 102, '2026-07-03 10:00:00', '天猫', '测试店'), [
|
||||
'status' => 'WaitConfirm',
|
||||
'shop_status' => 'WAIT_BUYER_RETURN_GOODS',
|
||||
]),
|
||||
array_replace($this->refundInfo(3, 103, '2026-07-04 10:00:00', '天猫', '测试店'), [
|
||||
'status' => 'Confirmed',
|
||||
'shop_status' => 'SUCCESS',
|
||||
]),
|
||||
]);
|
||||
$db->table('ops_jst_return_refund_item')->insert([
|
||||
$this->refundItem(11, 101, 'SKU-1', 'SUB-1'),
|
||||
$this->refundItem(12, 102, 'SKU-2', 'SUB-2'),
|
||||
$this->refundItem(13, 103, 'SKU-3', 'SUB-3'),
|
||||
]);
|
||||
$supplementPending = $this->supplement(201, '2026-07-05 10:00:00', 'UNKNOWN');
|
||||
$supplementPending['status'] = 'WaitConfirm';
|
||||
$supplementPending['shop_status'] = 'SUCCESS';
|
||||
$supplementOther = $this->supplement(202, '2026-07-06 10:00:00', 'UNKNOWN');
|
||||
$supplementOther['shop_status'] = 'SUCCESS';
|
||||
$db->table('ops_jst_qmcust_refunds')->insert([$supplementPending, $supplementOther]);
|
||||
|
||||
$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']));
|
||||
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));
|
||||
foreach ($export as $row) {
|
||||
$this->assertSame('待确认', $row->status);
|
||||
$this->assertSame('退款成功', $row->shop_status);
|
||||
}
|
||||
}
|
||||
|
||||
public function test_supplement_and_header_only_refunds_survive_without_invented_details(): void
|
||||
{
|
||||
$db = DB::connection('business_mirror');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user