소스 검색

fix: 使用 auth.user.tenant_id 查询 enterprise_id

alphah 2 달 전
부모
커밋
697abbe16b
1개의 변경된 파일2개의 추가작업 그리고 1개의 파일을 삭제
  1. 2 1
      backend/app/plugin/module_payment/expense/institution/controller.py

+ 2 - 1
backend/app/plugin/module_payment/expense/institution/controller.py

@@ -53,7 +53,8 @@ async def create_institution_controller(
     if not enterprise_id:
         from app.plugin.module_payment.enterprise.model import EnterpriseModel
         from sqlalchemy import select
-        stmt = select(EnterpriseModel).where(EnterpriseModel.tenant_id == auth.tenant_id).limit(1)
+        tenant_id = auth.user.tenant_id if auth.user and auth.user.tenant_id else auth.tenant_id
+        stmt = select(EnterpriseModel).where(EnterpriseModel.tenant_id == tenant_id).limit(1)
         result = await auth.db.execute(stmt)
         enterprise = result.scalar_one_or_none()
         enterprise_id = enterprise.enterprise_id if enterprise else ""