From d736ab0fd39f779ed63f108e59a9754edc636d65 Mon Sep 17 00:00:00 2001 From: chenxi Date: Sun, 4 Oct 2026 15:19:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E4=BB=B7=E6=A0=BC=E6=9C=80?= =?UTF-8?q?=E7=BB=88=E8=A7=84=E5=88=99=EF=BC=9A=E7=A9=BA=E5=80=BC=E5=85=9C?= =?UTF-8?q?=E5=BA=95(=E8=AE=B0=E5=BD=95=E6=97=B6=E9=97=B4=E7=A9=BA?= =?UTF-8?q?=E8=A7=86=E4=B8=BA=E2=89=A4=E6=AC=A1=E6=9C=882=E5=8F=B7?= =?UTF-8?q?=E3=80=81=E7=94=9F=E6=95=88=E6=97=A5=E6=9C=9F=E7=A9=BA=E8=A7=86?= =?UTF-8?q?=E4=B8=BA=E6=9C=AA=E5=8C=B9=E9=85=8D)=E3=80=81=E7=94=9F?= =?UTF-8?q?=E6=95=88>=E6=9C=AC=E6=9C=88=E6=88=96=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E6=97=B6=E9=97=B4>=E6=AC=A1=E6=9C=882=E5=8F=B7=E5=8F=96?= =?UTF-8?q?=E5=8F=98=E4=BB=B7=E5=89=8D=E4=BB=B7=E6=A0=BC=E3=80=81=E6=88=90?= =?UTF-8?q?=E6=9C=AC=E4=BB=B7=E6=9C=89=E5=80=BC=E8=A7=86=E4=B8=BA=E5=B7=B2?= =?UTF-8?q?=E5=AE=9A=E4=BB=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ComputeProductMonthlyWeightedAverage.php | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/app/Console/Commands/ComputeProductMonthlyWeightedAverage.php b/app/Console/Commands/ComputeProductMonthlyWeightedAverage.php index e4e9648e..064fe38f 100644 --- a/app/Console/Commands/ComputeProductMonthlyWeightedAverage.php +++ b/app/Console/Commands/ComputeProductMonthlyWeightedAverage.php @@ -196,38 +196,39 @@ class ComputeProductMonthlyWeightedAverage extends Command $previousStatus = trim((string) ($row->previous_pricing_status ?? '')); $changePrice = $change['price'] ?? null; $workPrice = $work['price'] ?? null; - // 方案乙:生效开始日期或记录时间为空 → 视为未匹配(用原始价格、保持预估价); - // 记录时间 > 次月2号(新价当月未生效)→ 取变价前价格、状态保持原状态;其余取变价后价格。 + // 最终规则:生效开始日期为空 → 未匹配到工作平台价格; + // 生效开始日期 > 本月,或记录时间 > 次月2号(记录时间为空视为 ≤ 次月2号)→ 新价当月未生效,取变价前价格。 $changeTime = $change['time'] ?? null; $changeCreated = $change['created'] ?? null; + $monthStart = $deadline->startOfMonth(); + $hasWorkPlatformRecord = $changePrice !== null && $changeTime !== null; $newPricePending = false; - if ($changePrice !== null && ($changeTime === null || $changeCreated === null)) { - $changePrice = null; - } elseif ($changePrice !== null && CarbonImmutable::parse($changeCreated)->greaterThan($deadline)) { - $newPricePending = true; - $changePrice = $change['before'] ?? $changePrice; + if ($hasWorkPlatformRecord) { + $newPricePending = CarbonImmutable::parse($changeTime)->greaterThanOrEqualTo($monthStart) + || ($changeCreated !== null && CarbonImmutable::parse($changeCreated)->greaterThan($deadline)); + $changePrice = $newPricePending ? ($change['before'] ?? $changePrice) : $changePrice; } + $previousStatus = in_array($previousStatus, ['预估价', '未定价'], true) ? '未定价' : $previousStatus; // 更改价格 + 定价状态(表2 第10条) if ($openingUnitPrice !== null) { - if ($previousStatus !== '预估价') { + if ($previousStatus !== '未定价') { $adjusted = $openingUnitPrice; $status = $previousStatus !== '' ? $previousStatus : '已定价'; - } elseif ($changePrice !== null) { + } elseif ($hasWorkPlatformRecord) { $adjusted = $changePrice; $status = $newPricePending ? '未定价' : '已定价'; } else { $adjusted = $openingUnitPrice; - // 未匹配到工作平台价格 → 用原始价格,状态统一记为「未定价」(原「预估价」)。 $status = '未定价'; } - } elseif ($changePrice !== null) { + } elseif ($hasWorkPlatformRecord) { $adjusted = $changePrice; - $status = '已定价'; + $status = $newPricePending ? '未定价' : '已定价'; } elseif ($cost !== null) { + // 方案①:能取到成本价即视为"有生效开始日期" → 已定价。 $adjusted = $cost; - // 无原始价格、未匹配工作平台价格但匹配到成本价 → 定价状态「未定价」。 - $status = '未定价'; + $status = '已定价'; } else { $adjusted = null; $status = '待人工核查';