商品月加权平均单价:指定月份的筛选严格按该月取数,不再回退到最新月份

This commit is contained in:
chenxi 2026-09-29 17:07:27 +08:00
parent 538b5e9a10
commit a412fcb12f

View File

@ -403,7 +403,8 @@ class Pages extends Controller
// 筛选栏的月份选择器提交 Y-m,这里补成当月 1 号再匹配。
$requested .= '-01';
}
$month = in_array($requested, $months, true) ? $requested : ($months[0] ?? null);
// 明确指定月份时严格按该月份取数(该月没算出来就显示空表),避免筛选条件与数据不一致。
$month = $requested !== '' ? $requested : ($months[0] ?? null);
$limit = min(max((int) setting('default.list_limit', 25), 1), 50);
$page = max((int) request('page', 1), 1);
@ -493,7 +494,7 @@ class Pages extends Controller
->where('status', 'computed')->orderByDesc('report_month')->pluck('report_month')
->map(static fn ($month): string => substr((string) $month, 0, 10))->all();
$requested = substr(trim((string) $request->query('month', '')), 0, 10);
$month = in_array($requested, $months, true) ? $requested : ($months[0] ?? null);
$month = $requested !== '' ? $requested : ($months[0] ?? null);
$query = DB::connection($connection)->table('product_monthly_weighted_average_rows');
if ($month !== null) {