fix: 物化状态同时校验空值,兼容尚未部署新代码的同步任务
状态表标记已物化、但旧版本同步代码重刷账期时不写物化列,会留下 NULL 导致页面把未物化行当成 0 差额。现在读取状态时同时检查该账期是否还有 has_difference 为 NULL 的行,有则回退实时规则表达式(缓存 10 分钟)。
This commit is contained in:
parent
089c2dd603
commit
6cbfe27afc
@ -133,7 +133,18 @@ class StoreReceiptDifferenceMaterialization
|
||||
->where('report_month', $month)
|
||||
->first();
|
||||
|
||||
return $row !== null && (string) ($row->rule_version ?? '') === self::ruleVersion();
|
||||
if ($row === null || (string) ($row->rule_version ?? '') !== self::ruleVersion()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 过渡期保护:尚未部署新代码的同步任务重刷账期时不会写物化列,
|
||||
// 一旦出现 NULL 就回退实时口径,避免页面把未物化的行当成 0 差额。
|
||||
return ! DB::connection(self::connection())
|
||||
->table(self::TABLE)
|
||||
->where('report_month', $month)
|
||||
->whereNull(self::HAS_DIFFERENCE_COLUMN)
|
||||
->limit(1)
|
||||
->exists();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user