10 Commits

Author SHA1 Message Date
wangjia da8bbefe2e merge: P8 订阅/recurring + 拒付 chargeback 并入(订阅生命周期/续费/取消/past_due/chargeback/事件集收口)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013nMthbVEmQquxBRKb9Fj8u

# Conflicts:
#	internal/model/testdb.go
#	internal/provider/provider.go
#	internal/router/router.go
#	internal/store/order_query_test.go
#	main.go
2026-07-10 19:43:32 +08:00
wangjia b0714ca758 feat(pay-v2): P8 Task6 拒付 chargeback 记录 + chargeback.received 2026-07-10 18:52:13 +08:00
wangjia 727ed74899 feat(v2): crypto 孤儿到账发现——OrphanScanner 扫链核对 + orphan_payments 落表告警(对账兜底) 2026-07-10 17:52:10 +08:00
wangjia 799d74668d feat(pay-v2): P8 Task1 Subscription 模型 + 三态状态机 + store 2026-07-10 17:45:10 +08:00
wangjia aa14204640 fix(v2): 超退守卫事务化 CreateRefundGuarded(锁单行+求和+插入单事务)+ sqlite DSN 补 _txlock=immediate
Task 3 计划的 RefundSum→比较→CreateRefund 两段式裸读写在并发下会超退(两个请求都读到
reserved=0、都通过、都插入)。仿 store/order.go::MarkAttemptPaid 的模式,把锁订单行
(clause.Locking FOR UPDATE,MySQL 真锁/SQLite 由 glebarez 静默丢弃)+ 求和 + 校验 + 插入
收进单个 s.db.Transaction。SQLite 侧真正的串行化靠 DSN _txlock=immediate(BEGIN IMMEDIATE
在事务开始就抢写锁)+ busy_timeout,补进 testdb.go 与 main.go 的 sqlite DSN 构造。
2026-07-10 17:08:25 +08:00
wangjia 00e032f577 fix(v2): uq_delivery 索引显式升级迁移(AutoMigrate 不改同名索引)+ refund_id NOT NULL DEFAULT ''
AutoMigrate 只按名字判断索引是否存在,P2 时代库升级后同名 uq_delivery 仍停在
2 列,store.EnqueueDelivery 的 3 列 ON CONFLICT 每次调用(含普通 payment
webhook)都报 "ON CONFLICT clause does not match any PRIMARY KEY or UNIQUE
constraint"(reviewer 在 glebarez/sqlite 上实测复现)。新增
model.UpgradeWebhookDeliveryIndex,AutoMigrate 后显式检测/加宽索引 +
backfill refund_id,main.go 与 OpenTestDB 两处调用点接入;RefundID 补
not null;default:'' 补上 NULL/"" 语义缺口。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013nMthbVEmQquxBRKb9Fj8u
2026-07-10 16:42:29 +08:00
wangjia 585133532c feat(v2): 多币种 product(ProductPrice 分币价目 + v1 元回退)+ 结算币种由渠道能力驱动
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013nMthbVEmQquxBRKb9Fj8u
2026-07-10 14:20:12 +08:00
wangjia 3f5e44581f feat(v2): webhook v2 outbox + Notifier(event_type + HMAC 双向 + 重试兜底) 2026-07-10 11:25:14 +08:00
wangjia af15f4736e fix(v2): MarkAttemptPaid 按单scope+校验attempt命中 + OpenTestDB 唯一库名
- attempt UPDATE 加 out_trade_no 过滤并检查 RowsAffected,防止 order 已翻
  paid 但 providerRef 错配导致没有对应 attempt 被标记的账本背离(未命中
  时返回 error 触发事务回滚,order 保持 pending)
- 补测试覆盖 providerRef 错配场景:断言返回 error 且回滚后订单仍 pending
- OpenTestDB 改为每次调用生成唯一内存库名(atomic 计数器),避免同包多
  测试共享 file::memory:?cache=shared 导致数据串扰

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-10 08:35:22 +08:00
wangjia 01887dd571 feat(v2): Order/Attempt/Account/Refund 模型 + 状态枚举 + :memory: 测试约定
v2 OrderStatus 三个值(Pending/Paid/Refunded)与 v1 model.OrderStatus 撞名,
统一加 V2 后缀(OrderPendingV2 等)规避包内重名;AttemptStatus/RefundStatus
无此冲突,原样保留。
2026-07-10 08:14:27 +08:00