fix: 不轮询清单审查问题
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 9m31s
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 9m31s
- 写清单 ON CONFLICT 的部分索引谓词改为字面量:预编译语句的通用执行计划下参数化谓词匹配不到部分唯一索引,第 6 次起关闭轮询全部失败 - 轮询开关审计允许 Worker、开放接口、C 端与支付回调来源;导入与自动恢复补审计操作者 - 文件导入按 19/20 位 ICCID 匹配 - 钱包重复支付不再恢复轮询 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,7 @@ package pollingpause
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -68,9 +69,10 @@ func Record(ctx context.Context, tx *gorm.DB, change Change, fallback string) er
|
||||
ClosedBy: origin.OperatorID, ClosedAt: now, ImportTaskID: origin.ImportTaskID, CreatedAt: now, UpdatedAt: now,
|
||||
}
|
||||
// 部分唯一索引 (asset_type, asset_id) WHERE status = 1:已有已关闭记录时保留原记录。
|
||||
// 谓词必须写成字面量:启用预编译语句时,参数化的 WHERE 在通用执行计划下无法匹配部分唯一索引。
|
||||
err := tx.WithContext(ctx).Clauses(clause.OnConflict{
|
||||
Columns: []clause.Column{{Name: "asset_type"}, {Name: "asset_id"}},
|
||||
TargetWhere: clause.Where{Exprs: []clause.Expression{clause.Expr{SQL: "status = ?", Vars: []any{constants.PollingPauseStatusClosed}}}},
|
||||
TargetWhere: clause.Where{Exprs: []clause.Expression{clause.Expr{SQL: closedStatusPredicate}}},
|
||||
DoNothing: true,
|
||||
}).Create(row).Error
|
||||
if err != nil {
|
||||
@@ -119,6 +121,9 @@ func RiskEnableDeniedReason(extend string) string {
|
||||
return "风险停机,不能开启轮询"
|
||||
}
|
||||
|
||||
// closedStatusPredicate 是部分唯一索引 uq_card_polling_pause_open 的谓词字面量。
|
||||
var closedStatusPredicate = "status = " + strconv.Itoa(constants.PollingPauseStatusClosed)
|
||||
|
||||
func truncate(s string, max int) string {
|
||||
runes := []rune(s)
|
||||
if len(runes) <= max {
|
||||
|
||||
Reference in New Issue
Block a user