salescrm/b/customer/get_search.dspy
2025-10-27 15:50:44 +08:00

33 lines
1.1 KiB
Plaintext

async def get_search(ns):
"""
首页搜索
"""
db = DBPools()
async with db.sqlorContext('kboss') as sor:
# a = await llmchat2json(ns['name'])
nss = {'names': '%' + ns.get('name') + '%'}
sql = """SELECT * FROM product WHERE name like ${names}$"""
products = await sor.sqlExe(sql,nss)
lists = []
for i in products:
dicts = {}
if i['providerpid'][:2] == 'jd':
dicts['type'] = 'jd'
elif i['providerpid'][:2] == 'ba':
dicts['type'] = 'bd'
elif i['providerpid'][:4] == 'sdzx':
dicts['type'] = 'sdzx'
elif i['providerpid'][:6] == 'ucloud':
dicts['type'] = 'ucloud'
dicts['product_name'] = i['name']
dicts['description'] = i['description']
if i['label'] != None:
str2 = i['label'].split(',')
dicts['tags'] = str2
else:
dicts['tags'] = i['label']
lists.append(dicts)
return {'status': True, 'data': lists}
ret = await get_search(params_kw)
return ret