fix(client/orders): 继续支付改为 retry 恢复原单会话(原误进购买页致重复下单);409 已付自纠刷新
ci-pangolin / Lint — shellcheck (pull_request) Successful in 12s
ci-pangolin / Redline Scan — 脱敏 (UI 文案) (pull_request) Successful in 25s
ci-pangolin / Cleartext Scan — Android 禁明文 (pull_request) Successful in 20s
ci-pangolin / OpenAPI Sync Check (pull_request) Successful in 32s
ci-pangolin / Portable SQL — 可移植性 (mysql/sqlite) (pull_request) Successful in 21s
ci-pangolin / Flutter — analyze + test (pull_request) Successful in 38s
ci-pangolin / Codegen Drift — token 生成物未漂移 (pull_request) Successful in 2s
ci-pangolin / DS-flow — 原型/跨端同源/代码色单源闸 (pull_request) Successful in 5s
ci-pangolin / Go — build + test (pull_request) Failing after 13s
ci-pangolin / E2E Smoke — L4 进程级端到端 (pull_request) Failing after 10s
ci-pangolin / Go — integration (mysql/redis testcontainers) (pull_request) Failing after 4m50s
ci-pangolin / Golden — 视觉回归 (全量:components/auth/desktop/tablet) (pull_request) Failing after 20s

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P9G7E3wmAYL9KeYCVZVsqu
This commit is contained in:
wangjia
2026-07-13 11:29:25 +08:00
parent 07c339c18e
commit 92943258ab
3 changed files with 111 additions and 4 deletions
+35
View File
@@ -112,6 +112,41 @@ class PaymentFlowController extends StateNotifier<PaymentFlowState> {
}
}
/// 恢复 `created` 单的支付会话(订单页「继续支付」)——**不是**新下单。
/// 走 retry 拿回(或续出)同一 orderNo 的支付会话;409 ORDER_NOT_PENDING 说明
/// 订单在这期间已变化(常见:webhook 已到账但列表还没刷新)→ 落 failed 自纠,
/// 由调用方(订单页)据此刷新列表,用户会看到订单其实已开通,不再重复下单。
Future<void> resume(String orderNo, String method) async {
_stopPolling();
state = PaymentFlowState(phase: PaymentPhase.creating, method: method);
try {
final next = await _ref!
.read(paymentApiProvider)
.retry(orderNo, method: method, metadata: _metadata(method));
if (!mounted) return;
state = state.copyWith(phase: PaymentPhase.awaitingPayment, order: next);
_startPolling();
} on AuthApiException catch (e) {
if (!mounted) return;
if (e.code == 'ORDER_NOT_PENDING') {
state = state.copyWith(
phase: PaymentPhase.failed,
errorZh: '订单状态已变化,请刷新查看最新状态',
errorEn: 'Order status has changed, please refresh to see the latest status',
);
return;
}
state = state.copyWith(phase: PaymentPhase.failed, errorZh: e.messageZh, errorEn: e.messageEn);
} catch (_) {
if (!mounted) return;
state = state.copyWith(
phase: PaymentPhase.failed,
errorZh: '下单失败,请检查网络后重试',
errorEn: 'Failed to create order, please check your network and retry',
);
}
}
/// 换支付方式:先 retry;pay 回 409 CURRENCY_MISMATCH(跨结算币种)时,
/// 按契约「换币种必须新单」→ cancel 旧单 + 新 method 重新下单。
Future<void> switchMethod(String method) async {