fix(purchase): user_org_id获取崩溃——DictObject的hasattr恒True导致await None()
- dspy侧显式取get_userorgid()传入(与purchase_confirm同款) - core侧hasattr判断改callable检查,兜底_get_current_org_id
This commit is contained in:
parent
c32fa00c62
commit
ff501c13b5
@ -1464,9 +1464,10 @@ class ProductManager:
|
||||
if not user_id:
|
||||
user_id = await env.get_user()
|
||||
if not user_org_id:
|
||||
user_org_id = await env.get_userorgid() if hasattr(env, 'get_userorgid') \
|
||||
else self._get_current_org_id()
|
||||
user_org_id = user_org_id or '0'
|
||||
fn = getattr(env, 'get_userorgid', None)
|
||||
if callable(fn):
|
||||
user_org_id = await fn()
|
||||
user_org_id = user_org_id or self._get_current_org_id() or '0'
|
||||
|
||||
quantity = int(quantity or 1)
|
||||
storage_gb = float(storage_gb or 0)
|
||||
|
||||
@ -13,9 +13,11 @@ try:
|
||||
raise Exception('缺少产品ID')
|
||||
|
||||
env = ServerEnv()
|
||||
user_org_id = (await get_userorgid()) or '0'
|
||||
r = await env.purchase_realtime(
|
||||
product_id=product_id,
|
||||
user_id=userid,
|
||||
user_org_id=user_org_id,
|
||||
charge_mode=params_kw.get('charge_mode') or None,
|
||||
quantity=int(params_kw.get('quantity', 1) or 1),
|
||||
storage_gb=float(params_kw.get('storage_gb', 0) or 0),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user