feat(client): 购买模型/仓库切 pay v2 契约(render_type 多态 + 分金额 + 订单列表)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
wangjia
2026-07-10 23:34:21 +08:00
parent 45a43c20a4
commit 179051a8fa
6 changed files with 536 additions and 8 deletions
@@ -74,6 +74,46 @@ class LicenseRepository {
}
}
/// 取消一笔未支付订单(防 pending 单堆积)。仅管理员可用。
/// 返回 true=已取消;订单不存在(404)或不可取消(409,如已支付/已取消)
/// 视为业务性「取消不了」,返回 false 而非抛异常。
Future<bool> cancelPurchase(String outTradeNo) async {
try {
final resp = await _client.post('/license/purchase/$outTradeNo/cancel');
final data = resp.data['data'] as Map<String, dynamic>?;
return data?['canceled'] as bool? ?? false;
} on DioException catch (e) {
final status = e.response?.statusCode;
if (status == 404 || status == 409) return false;
throw AppException(
e.response?.data?['error'] as String? ?? '取消订单失败,请稍后重试',
statusCode: status,
);
}
}
/// 购买订单列表(订单管理 tab,分页 + 状态筛选)。仅管理员可用。
Future<PurchaseListResult> listPurchases({
int page = 1,
int pageSize = 20,
String? status,
}) async {
try {
final resp = await _client.get('/license/purchases', params: {
'page': page,
'page_size': pageSize,
if (status != null) 'status': status,
});
return PurchaseListResult.fromJson(
resp.data['data'] as Map<String, dynamic>);
} on DioException catch (e) {
throw AppException(
e.response?.data?['error'] as String? ?? '获取订单列表失败',
statusCode: e.response?.statusCode,
);
}
}
/// 本店首月特惠是否已享用(购买弹窗据此置灰特惠档)。
Future<bool> promoUsed() async {
try {