41 lines
2.0 KiB
Plaintext
41 lines
2.0 KiB
Plaintext
async def getinvitecode(ns):
|
|
"""
|
|
邀请码展示列表
|
|
"""
|
|
db = DBPools()
|
|
async with db.sqlorContext('kboss') as sor:
|
|
if ns:
|
|
date = datetime.datetime.now()
|
|
sql = """select * from invitecode where del_flg = 0 and expire_date > ${date}$ order by create_at desc"""
|
|
reacs = await sor.sqlExe(sql, {'date':date})
|
|
#搜索
|
|
if ns.get('id'):
|
|
dicts = {}
|
|
promoting = await sor.R('promoting', {'id': reacs[0]['promotingid']})
|
|
for i in promoting:
|
|
if len(promoting) >= 1:
|
|
reacs[0]['promoting'] = promoting
|
|
promote_discount = await sor.R('promote_discount', {'promotingid': i['promotingid']})
|
|
for j in promote_discount:
|
|
product = await sor.R('product', {'id': j['productid']})
|
|
dicts[product[0]['name']] = j['discount']
|
|
i['discount'] = dicts
|
|
i['promoting'] = promoting
|
|
reacs[0]['invitecode'] = ns.get('host')[:30] + '#/registrationPage/?invitecode=' + reacs[0]['invitecode']
|
|
return {'status': True, 'data': reacs}
|
|
for i in reacs:
|
|
dicts = {}
|
|
promoting = await sor.R('promoting', {'id': i['promotingid']})
|
|
if len(promoting) >= 1:
|
|
promote_discount = await sor.R('promote_discount', {'promotingid': i['promotingid']})
|
|
for j in promote_discount:
|
|
product = await sor.R('product', {'id': j['productid']})
|
|
dicts[product[0]['name']] = j['discount']
|
|
i['discount'] = dicts
|
|
i['promoting'] = promoting
|
|
i['invitecode'] = ns.get('host')[:30] + '#/registrationPage/?invitecode=' + i['invitecode']
|
|
return {'status': True, 'data': reacs}
|
|
return {'status': False}
|
|
|
|
ret = await getinvitecode(params_kw)
|
|
return ret |