| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- from typing import Annotated
- from agno.agent import AgentSession
- from fastapi import APIRouter, Depends, HTTPException
- from fastapi.responses import JSONResponse
- from app.core.dependencies import db_getter
- from app.plugin.module_payment.apikey.model import TenantApiKeyModel
- from app.common.response import ResponseSchema, SuccessResponse
- from app.core.logger import log
- from app.core.tenant_api_auth import TenantApiKeyAuth
- from app.plugin.module_payment.account.schema import AccountTransferSchema
- from app.plugin.module_payment.account.service import AccountService
- from app.api.v1.module_system.auth.schema import AuthSchema
- from sqlalchemy.ext.asyncio import AsyncSession
- OpenapiRouter = APIRouter(
- prefix="/openapi",
- tags=["开放接口"],
- )
- @OpenapiRouter.post(
- "/account/transfer",
- summary="租户资金专户转账",
- description="从资金专户转账到支付宝账户/银行卡/资金专户(支持API Key认证)",
- response_model=ResponseSchema[dict],
- )
- async def tenant_transfer_controller(
- db: Annotated[AsyncSession, Depends(db_getter)],
- data: AccountTransferSchema,
- api_key: TenantApiKeyModel = Depends(TenantApiKeyAuth()),
- ) -> JSONResponse:
- """
- 租户资金专户转账接口
- 支持通过API Key进行认证,适用于平台租户调用
- """
- # 构建认证信息
- auth = AuthSchema(
- user=None,
- check_data_scope=False,
- tenant_id=api_key.tenant_id,
- db=db,
- )
- # 执行转账
- result = await AccountService.transfer_service(auth=auth, data=data)
- log.info(f"租户资金专户转账发起成功: 企业: {data.enterprise_id}, 金额: {data.amount}")
- return SuccessResponse(data=result, msg="")
|