32 lines
1.4 KiB
Plaintext
32 lines
1.4 KiB
Plaintext
async def getuserproduct(ns):
|
|
"""展示没有配置过促销的产品"""
|
|
db = DBPools()
|
|
async with db.sqlorContext('kboss') as sor:
|
|
try:
|
|
userid = await sor.R('users',{'id':ns['userid']})
|
|
sql = """select * from saleprotocol where del_flg = '0' and offer_orgid = ${userid}$ and (salemode = '0' or salemode = '1' )"""
|
|
saleprotocol = await sor.sqlExe(sql,{'page':ns['page'],'userid':userid[0]['orgid']})
|
|
productid = []
|
|
for i in saleprotocol:
|
|
saleprotocol = await sor.R('product_salemode',{'protocolid':i['id']})
|
|
for j in saleprotocol:
|
|
if j not in productid:
|
|
productid.append(j['productid'])
|
|
|
|
datalist = []
|
|
total = 0
|
|
for i in set(productid):
|
|
productreacs = await sor.R('product', {'id':i,'del_flg':'0'})
|
|
for j in productreacs:
|
|
userreacs = await sor.R('promote_discount',
|
|
{'del_flg': '0', 'productid': j['id'], 'promotingid': ns['promotingid']})
|
|
if len(userreacs) < 1:
|
|
total += 1
|
|
datalist.append(j)
|
|
data = {'total': total, 'rows': datalist}
|
|
return {'status': True, 'data': data}
|
|
except:
|
|
return {'status': False, 'msg': '获取失败'}
|
|
|
|
ret = await getuserproduct(params_kw)
|
|
return ret |