feat:新增投顾agent和nl2sqlagent
This commit is contained in:
@@ -11,6 +11,7 @@ from decimal import Decimal
|
||||
|
||||
from sqlalchemy import func, or_, select
|
||||
|
||||
from common.common_const import CUSTOMER_REL_STATUS_SIGNED, CUSTOMER_REL_STATUS_UNSIGNED
|
||||
from model.customer_relation import CustomerRelation
|
||||
from model.fin_customer_profile import FinCustomerProfile
|
||||
from model.fin_holdings import FinHoldings
|
||||
@@ -24,6 +25,23 @@ _HOLDING_STATUS = "持有中"
|
||||
class CustomerRelationRepo(BaseRepository):
|
||||
model = CustomerRelation
|
||||
|
||||
async def get_active_relation(
|
||||
self, *, customer_id: int, advisor_id: int
|
||||
) -> CustomerRelation | None:
|
||||
"""读取投顾可访问的当前关系,排除已结束关系。"""
|
||||
return await self.db.scalar(
|
||||
select(CustomerRelation)
|
||||
.where(
|
||||
CustomerRelation.customer_id == customer_id,
|
||||
CustomerRelation.advisor_id == advisor_id,
|
||||
CustomerRelation.status.in_(
|
||||
[CUSTOMER_REL_STATUS_UNSIGNED, CUSTOMER_REL_STATUS_SIGNED]
|
||||
),
|
||||
)
|
||||
.order_by(CustomerRelation.id.desc())
|
||||
.limit(1)
|
||||
)
|
||||
|
||||
async def get_by_customer_advisor(
|
||||
self, customer_id: int, advisor_id: int
|
||||
) -> CustomerRelation | None:
|
||||
|
||||
Reference in New Issue
Block a user