fix: DBPools(config.databases) instead of DBPools() for subprocess context
This commit is contained in:
parent
8f2292b6f3
commit
8be3566338
@ -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}]})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user