fix(stats/self_input): 唯一索引含 delete_time,软删后可重新录入

去掉「同日+同渠道」全局唯一,回到按录入人判重;唯一索引补 delete_time 避免软删占键导致 1062;错误提示带冲突记录 ID,迁移脚本兼容多次执行。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-05-22 17:01:58 +08:00
co-authored by Cursor
parent 003810114b
commit 679e61057b
6 changed files with 71 additions and 26 deletions
@@ -22,8 +22,9 @@ class PersonalAccountCostLogic extends BaseLogic
return false;
}
if (self::isCostDuplicate($adminId, $costDate, $mediaSource)) {
self::setError('您在该日期下已录入过该渠道的账户消耗,请直接编辑');
$dupId = self::findCostDuplicateId($adminId, $costDate, $mediaSource);
if ($dupId > 0) {
self::setError("您在 {$costDate} 已录入过【{$mediaSource}】账户消耗(记录#{$dupId}),请直接编辑该记录");
return false;
}
@@ -42,7 +43,11 @@ class PersonalAccountCostLogic extends BaseLogic
return true;
} catch (\Throwable $e) {
self::setError($e->getMessage());
if (self::isUniqueConstraintViolation($e)) {
self::setError('该日期下该渠道的账户消耗已存在(唯一索引冲突),请刷新列表后直接编辑');
} else {
self::setError($e->getMessage());
}
return false;
}