fix: DBPools() not in __init__, sqlorContext uses module name not default
This commit is contained in:
parent
d18ba12ff9
commit
8f2292b6f3
@ -22,7 +22,7 @@ async def create_customer(
|
||||
) -> Dict:
|
||||
"""创建客户档案"""
|
||||
db = DBPools()
|
||||
async with db.sqlorContext('default') as sor:
|
||||
async with db.sqlorContext('customer_management') as sor:
|
||||
customer_id = str(uuid.uuid4()).replace('-', '')
|
||||
|
||||
# 数据校验
|
||||
@ -74,7 +74,7 @@ async def initiate_handover(
|
||||
) -> Dict:
|
||||
"""发起客户交接流程"""
|
||||
db = DBPools()
|
||||
async with db.sqlorContext('default') as sor:
|
||||
async with db.sqlorContext('customer_management') as sor:
|
||||
# 获取客户信息
|
||||
customer_records = await sor.R("customers", {"filters": [{"field": "id", "op": "=", "value": customer_id}]})
|
||||
if not customer_records or len(customer_records) == 0:
|
||||
@ -204,7 +204,7 @@ async def generate_handover_items(sor, handover_id: str, customer_id: str):
|
||||
async def complete_handover_preparation(handover_id: str) -> Dict:
|
||||
"""完成交接准备阶段"""
|
||||
db = DBPools()
|
||||
async with db.sqlorContext('default') as sor:
|
||||
async with db.sqlorContext('customer_management') as sor:
|
||||
handover_records = await sor.R("customer_handover", {"filters": [{"field": "id", "op": "=", "value": handover_id}]})
|
||||
if not handover_records or len(handover_records) == 0:
|
||||
raise ValueError("交接记录不存在")
|
||||
@ -230,7 +230,7 @@ async def complete_handover_preparation(handover_id: str) -> Dict:
|
||||
async def approve_handover(handover_id: str, approver_id: str = None) -> Dict:
|
||||
"""审核交接清单"""
|
||||
db = DBPools()
|
||||
async with db.sqlorContext('default') as sor:
|
||||
async with db.sqlorContext('customer_management') as sor:
|
||||
approver_id = approver_id or get_current_user_id()
|
||||
|
||||
handover_records = await sor.R("customer_handover", {"filters": [{"field": "id", "op": "=", "value": handover_id}]})
|
||||
@ -258,7 +258,7 @@ async def approve_handover(handover_id: str, approver_id: str = None) -> Dict:
|
||||
async def confirm_handover(handover_id: str, confirm_by: str = None) -> Dict:
|
||||
"""确认接收客户"""
|
||||
db = DBPools()
|
||||
async with db.sqlorContext('default') as sor:
|
||||
async with db.sqlorContext('customer_management') as sor:
|
||||
confirm_by = confirm_by or get_current_user_id()
|
||||
|
||||
handover_records = await sor.R("customer_handover", {"filters": [{"field": "id", "op": "=", "value": handover_id}]})
|
||||
@ -317,7 +317,7 @@ async def send_customer_notification(sor, customer_id: str, new_owner_id: str):
|
||||
async def recycle_to_pool(customer_id: str, inactive_days: int = None, reason: str = "inactive_days"):
|
||||
"""回收客户到公海池"""
|
||||
db = DBPools()
|
||||
async with db.sqlorContext('default') as sor:
|
||||
async with db.sqlorContext('customer_management') as sor:
|
||||
customer_records = await sor.R("customers", {"filters": [{"field": "id", "op": "=", "value": customer_id}]})
|
||||
if not customer_records or len(customer_records) == 0:
|
||||
raise ValueError("客户不存在")
|
||||
@ -358,7 +358,7 @@ async def recycle_to_pool(customer_id: str, inactive_days: int = None, reason: s
|
||||
async def claim_from_pool(pool_id: str, new_owner_id: str = None):
|
||||
"""从公海池认领客户"""
|
||||
db = DBPools()
|
||||
async with db.sqlorContext('default') as sor:
|
||||
async with db.sqlorContext('customer_management') as sor:
|
||||
new_owner_id = new_owner_id or get_current_user_id()
|
||||
|
||||
pool_records = await sor.R("customer_pool", {"filters": [{"field": "id", "op": "=", "value": pool_id}]})
|
||||
@ -399,7 +399,7 @@ async def claim_from_pool(pool_id: str, new_owner_id: str = None):
|
||||
async def get_customer_360_view(customer_id: str) -> Dict:
|
||||
"""获取客户360度视图"""
|
||||
db = DBPools()
|
||||
async with db.sqlorContext('default') as sor:
|
||||
async with db.sqlorContext('customer_management') as sor:
|
||||
# 客户基本信息
|
||||
customer_records = await sor.R("customers", {"filters": [{"field": "id", "op": "=", "value": customer_id}]})
|
||||
if not customer_records or len(customer_records) == 0:
|
||||
|
||||
@ -78,21 +78,26 @@
|
||||
{
|
||||
"field": "customer_id",
|
||||
"title": "客户360度视图",
|
||||
"url": "{{entire_url('customers')}}",
|
||||
"url": "{{entire_url('../customers')}}",
|
||||
"subtable": "customers"
|
||||
},
|
||||
{
|
||||
"field": "customer_id",
|
||||
"title": "交接记录",
|
||||
"url": "{{entire_url('handover_list')}}",
|
||||
"url": "{{entire_url('../handover_list')}}",
|
||||
"subtable": "customer_handover"
|
||||
},
|
||||
{
|
||||
"field": "customer_id",
|
||||
"title": "公海记录",
|
||||
"url": "{{entire_url('customer_pool_list')}}",
|
||||
"url": "{{entire_url('../customer_pool_list')}}",
|
||||
"subtable": "customer_pool"
|
||||
}
|
||||
]
|
||||
],
|
||||
"editable": {
|
||||
"new_data_url": "{{entire_url('../api/customers_create.dspy')}}",
|
||||
"update_data_url": "{{entire_url('../api/customers_update.dspy')}}",
|
||||
"delete_data_url": "{{entire_url('../api/customers_delete.dspy')}}"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -55,7 +55,7 @@
|
||||
{
|
||||
"field": "handover_id",
|
||||
"title": "交接项目明细",
|
||||
"url": "{{entire_url('handover_items_list')}}",
|
||||
"url": "{{entire_url('../handover_items_list')}}",
|
||||
"subtable": "customer_handover_items"
|
||||
}
|
||||
]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user