feat(entitlement): execute_product_service 返回账号权益信息(有效期/工作空间配额)

This commit is contained in:
ymq 2026-08-26 17:17:22 +08:00
parent f2972dba74
commit 06bcecafa2
2 changed files with 13 additions and 2 deletions

View File

@ -134,10 +134,21 @@ async def execute_product_service(resource_ref_id, user_id, user_org_id, request
getattr(spec, 'spec_code'), charge_mode, user_id, user_org_id,
subscription_id=(request_data or {}).get('subscription_id', ''),
quantity=(request_data or {}).get('quantity', 1))
# 权益信息(供产品层写 product_subscription
days = {'trial': 7, 'month': 30, 'year': 365}.get(charge_mode, 30)
return {'success': True,
'message': '账号开通成功(权益生效逻辑待接入)',
'message': '账号开通成功',
'status': 'SUCCESS',
'usage': rec}
'usage': rec,
'entitlement': {
'charge_mode': charge_mode,
'duration_days': days,
'workspace_max': int(getattr(spec, 'workspace_max', 0) or 0),
'workspace_gb': float(getattr(spec, 'workspace_gb', 0) or 0),
'concurrent_task': int(getattr(spec, 'concurrent_task', 0) or 0),
'member_max': int(getattr(spec, 'member_max', 0) or 0),
'gpu_allowed': getattr(spec, 'gpu_allowed', '') or '',
}}
async def execute_product_service_stream(resource_ref_id, user_id, user_org_id, request_data):