From 8be356633854c1fdca7b8d7036a0d408ee08ed15 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Fri, 8 May 2026 14:49:19 +0800 Subject: [PATCH] fix: DBPools(config.databases) instead of DBPools() for subprocess context --- customer_management/core.py | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/customer_management/core.py b/customer_management/core.py index daa16f9..cb8af3f 100644 --- a/customer_management/core.py +++ b/customer_management/core.py @@ -6,6 +6,7 @@ import re from ahserver.serverenv import ServerEnv from appPublic.worker import awaitify from sqlor.dbpools import DBPools +from appPublic.jsonConfig import getConfig async def create_customer( @@ -21,7 +22,9 @@ async def create_customer( region: str = None ) -> Dict: """创建客户档案""" - db = DBPools() + config = getConfig() + + db = DBPools(config.databases) async with db.sqlorContext('customer_management') as sor: customer_id = str(uuid.uuid4()).replace('-', '') @@ -73,7 +76,9 @@ async def initiate_handover( reviewer_id: str = None ) -> Dict: """发起客户交接流程""" - db = DBPools() + config = getConfig() + + db = DBPools(config.databases) async with db.sqlorContext('customer_management') as sor: # 获取客户信息 customer_records = await sor.R("customers", {"filters": [{"field": "id", "op": "=", "value": customer_id}]}) @@ -203,7 +208,9 @@ async def generate_handover_items(sor, handover_id: str, customer_id: str): async def complete_handover_preparation(handover_id: str) -> Dict: """完成交接准备阶段""" - db = DBPools() + config = getConfig() + + db = DBPools(config.databases) 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: @@ -229,7 +236,9 @@ async def complete_handover_preparation(handover_id: str) -> Dict: async def approve_handover(handover_id: str, approver_id: str = None) -> Dict: """审核交接清单""" - db = DBPools() + config = getConfig() + + db = DBPools(config.databases) async with db.sqlorContext('customer_management') as sor: approver_id = approver_id or get_current_user_id() @@ -257,7 +266,9 @@ 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() + config = getConfig() + + db = DBPools(config.databases) async with db.sqlorContext('customer_management') as sor: confirm_by = confirm_by or get_current_user_id() @@ -316,7 +327,9 @@ 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() + config = getConfig() + + db = DBPools(config.databases) 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: @@ -357,7 +370,9 @@ 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() + config = getConfig() + + db = DBPools(config.databases) async with db.sqlorContext('customer_management') as sor: new_owner_id = new_owner_id or get_current_user_id() @@ -398,7 +413,9 @@ 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() + config = getConfig() + + db = DBPools(config.databases) async with db.sqlorContext('customer_management') as sor: # 客户基本信息 customer_records = await sor.R("customers", {"filters": [{"field": "id", "op": "=", "value": customer_id}]})