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:
|
) -> Dict:
|
||||||
"""创建客户档案"""
|
"""创建客户档案"""
|
||||||
db = DBPools()
|
db = DBPools()
|
||||||
async with db.sqlorContext('default') as sor:
|
async with db.sqlorContext('customer_management') as sor:
|
||||||
customer_id = str(uuid.uuid4()).replace('-', '')
|
customer_id = str(uuid.uuid4()).replace('-', '')
|
||||||
|
|
||||||
# 数据校验
|
# 数据校验
|
||||||
@ -74,7 +74,7 @@ async def initiate_handover(
|
|||||||
) -> Dict:
|
) -> Dict:
|
||||||
"""发起客户交接流程"""
|
"""发起客户交接流程"""
|
||||||
db = DBPools()
|
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}]})
|
customer_records = await sor.R("customers", {"filters": [{"field": "id", "op": "=", "value": customer_id}]})
|
||||||
if not customer_records or len(customer_records) == 0:
|
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:
|
async def complete_handover_preparation(handover_id: str) -> Dict:
|
||||||
"""完成交接准备阶段"""
|
"""完成交接准备阶段"""
|
||||||
db = DBPools()
|
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}]})
|
handover_records = await sor.R("customer_handover", {"filters": [{"field": "id", "op": "=", "value": handover_id}]})
|
||||||
if not handover_records or len(handover_records) == 0:
|
if not handover_records or len(handover_records) == 0:
|
||||||
raise ValueError("交接记录不存在")
|
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:
|
async def approve_handover(handover_id: str, approver_id: str = None) -> Dict:
|
||||||
"""审核交接清单"""
|
"""审核交接清单"""
|
||||||
db = DBPools()
|
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()
|
approver_id = approver_id or get_current_user_id()
|
||||||
|
|
||||||
handover_records = await sor.R("customer_handover", {"filters": [{"field": "id", "op": "=", "value": handover_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:
|
async def confirm_handover(handover_id: str, confirm_by: str = None) -> Dict:
|
||||||
"""确认接收客户"""
|
"""确认接收客户"""
|
||||||
db = DBPools()
|
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()
|
confirm_by = confirm_by or get_current_user_id()
|
||||||
|
|
||||||
handover_records = await sor.R("customer_handover", {"filters": [{"field": "id", "op": "=", "value": handover_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"):
|
async def recycle_to_pool(customer_id: str, inactive_days: int = None, reason: str = "inactive_days"):
|
||||||
"""回收客户到公海池"""
|
"""回收客户到公海池"""
|
||||||
db = DBPools()
|
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}]})
|
customer_records = await sor.R("customers", {"filters": [{"field": "id", "op": "=", "value": customer_id}]})
|
||||||
if not customer_records or len(customer_records) == 0:
|
if not customer_records or len(customer_records) == 0:
|
||||||
raise ValueError("客户不存在")
|
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):
|
async def claim_from_pool(pool_id: str, new_owner_id: str = None):
|
||||||
"""从公海池认领客户"""
|
"""从公海池认领客户"""
|
||||||
db = DBPools()
|
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()
|
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}]})
|
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:
|
async def get_customer_360_view(customer_id: str) -> Dict:
|
||||||
"""获取客户360度视图"""
|
"""获取客户360度视图"""
|
||||||
db = DBPools()
|
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}]})
|
customer_records = await sor.R("customers", {"filters": [{"field": "id", "op": "=", "value": customer_id}]})
|
||||||
if not customer_records or len(customer_records) == 0:
|
if not customer_records or len(customer_records) == 0:
|
||||||
|
|||||||
@ -78,21 +78,26 @@
|
|||||||
{
|
{
|
||||||
"field": "customer_id",
|
"field": "customer_id",
|
||||||
"title": "客户360度视图",
|
"title": "客户360度视图",
|
||||||
"url": "{{entire_url('customers')}}",
|
"url": "{{entire_url('../customers')}}",
|
||||||
"subtable": "customers"
|
"subtable": "customers"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"field": "customer_id",
|
"field": "customer_id",
|
||||||
"title": "交接记录",
|
"title": "交接记录",
|
||||||
"url": "{{entire_url('handover_list')}}",
|
"url": "{{entire_url('../handover_list')}}",
|
||||||
"subtable": "customer_handover"
|
"subtable": "customer_handover"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"field": "customer_id",
|
"field": "customer_id",
|
||||||
"title": "公海记录",
|
"title": "公海记录",
|
||||||
"url": "{{entire_url('customer_pool_list')}}",
|
"url": "{{entire_url('../customer_pool_list')}}",
|
||||||
"subtable": "customer_pool"
|
"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",
|
"field": "handover_id",
|
||||||
"title": "交接项目明细",
|
"title": "交接项目明细",
|
||||||
"url": "{{entire_url('handover_items_list')}}",
|
"url": "{{entire_url('../handover_items_list')}}",
|
||||||
"subtable": "customer_handover_items"
|
"subtable": "customer_handover_items"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user