订单售后费用明细:筛选未命中时返回空结果并缓存商品利润分页 #535
@ -251,6 +251,17 @@ class GoodsProfitAfsRepository
|
||||
* @return array{rows:list<array<string,mixed>>,has_more:bool}
|
||||
*/
|
||||
public function paginate(array $filters, int $page, int $limit): array
|
||||
{
|
||||
$cacheKey = 'goods-profit-afs:page:' . sha1((string) json_encode([$filters, $page, $limit]));
|
||||
|
||||
return cache()->remember($cacheKey, now()->addMinutes(2), fn (): array => $this->paginateUncached($filters, $page, $limit));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string,mixed> $filters
|
||||
* @return array{rows:list<array<string,mixed>>,has_more:bool}
|
||||
*/
|
||||
private function paginateUncached(array $filters, int $page, int $limit): array
|
||||
{
|
||||
$page = max($page, 1);
|
||||
$limit = min(max($limit, 1), 100);
|
||||
|
||||
@ -197,6 +197,16 @@ class OrderDataPageData
|
||||
];
|
||||
}
|
||||
|
||||
// 已经按单号或商品编码筛选、但两个正式数据源都没有命中时,返回空结果。
|
||||
// 旧订单镜像的粒度是组合行,回退过去会显示与筛选无关的组合编码(历史问题)。
|
||||
if (trim((string) ($filters['order_no'] ?? '')) !== '' || trim((string) ($filters['sku_id'] ?? '')) !== '') {
|
||||
return [
|
||||
'rows' => [],
|
||||
'has_more' => false,
|
||||
'status' => ['X-Caiwu-Data-Status' => 'empty'],
|
||||
];
|
||||
}
|
||||
|
||||
$mirror = $this->mirrorOrders ?? app(OrderDataMirrorRepository::class);
|
||||
if ($mirror->ready()) {
|
||||
$result = $mirror->afterSales($filters, $page, $limit);
|
||||
|
||||
@ -307,7 +307,7 @@
|
||||
<div class="upstream-data-pagination">
|
||||
<span>
|
||||
当前页 {{ $rows?->count() ?? 0 }} 条
|
||||
@if ($status) · {{ ['imported' => '聚水潭导入', 'goods_profit' => '聚水潭商品利润'][$status] ?? strtoupper($status) }} @endif
|
||||
@if ($status) · {{ ['imported' => '聚水潭导入', 'goods_profit' => '聚水潭商品利润', 'empty' => '无匹配数据'][$status] ?? strtoupper($status) }} @endif
|
||||
</span>
|
||||
<div class="upstream-data-pagination__controls">
|
||||
<a
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user