fix: use get_module_dbname for discount db in init_free_customers

This commit is contained in:
yumoqing 2026-07-14 10:44:23 +08:00
parent e4b746be5c
commit f6c29c8c38

View File

@ -5,6 +5,7 @@ if not userorgid:
return {'widgettype': 'Error', 'options': {'title': 'Error', 'message': '请先登录', 'timeout': 3}}
count = 0
disc_dbname = get_module_dbname('discount')
async with DBPools().sqlorContext('sage') as sor:
# Get all users (filtered by org if not owner)
if userorgid == '0':
@ -17,7 +18,7 @@ async with DBPools().sqlorContext('sage') as sor:
if not users:
return {'widgettype': 'Message', 'options': {'title': '提示', 'message': '该机构下无用户', 'type': 'warning', 'timeout': 3}}
async with DBPools().sqlorContext('discount') as disc_sor:
async with DBPools().sqlorContext(disc_dbname) as disc_sor:
for u in users:
existing = await disc_sor.sqlExe(
'SELECT id FROM discount_customer_bind WHERE customerid = ${cid}$',