fix: init_free_customers allow owner org, use users.orgid as resellerid
This commit is contained in:
parent
9d3c4e0adf
commit
e4b746be5c
@ -1,12 +1,15 @@
|
||||
"""Initialize discount_customer_bind for all users in current org.
|
||||
Users without a bind record get bind_type='3' (domain registration), sale_id=NULL."""
|
||||
"""Initialize discount_customer_bind for all users who don't have a bind record.
|
||||
Each user is bound to their own org (users.orgid) as resellerid, bind_type='3'."""
|
||||
userorgid = await get_userorgid()
|
||||
if not userorgid or userorgid == '0':
|
||||
return {'widgettype': 'Error', 'options': {'title': 'Error', 'message': '仅机构用户可执行', 'timeout': 3}}
|
||||
if not userorgid:
|
||||
return {'widgettype': 'Error', 'options': {'title': 'Error', 'message': '请先登录', 'timeout': 3}}
|
||||
|
||||
count = 0
|
||||
async with DBPools().sqlorContext('sage') as sor:
|
||||
# Get all users in this org
|
||||
# Get all users (filtered by org if not owner)
|
||||
if userorgid == '0':
|
||||
users = await sor.sqlExe('SELECT id, orgid FROM users', {})
|
||||
else:
|
||||
users = await sor.sqlExe(
|
||||
'SELECT id, orgid FROM users WHERE orgid = ${oid}$',
|
||||
{'oid': userorgid}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user