更改价格最终规则:空值兜底(记录时间空视为≤次月2号、生效日期空视为未匹配)、生效>本月或记录时间>次月2号取变价前价格、成本价有值视为已定价
This commit is contained in:
parent
1ca789807b
commit
d736ab0fd3
@ -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 = '待人工核查';
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user