kboss/b/product/rebate_search.dspy
2025-07-16 14:27:17 +08:00

45 lines
1.7 KiB
Plaintext

async def rebate_search(ns={}):
db = DBPools()
async with db.sqlorContext('kboss') as sor:
try:
ns['del_flg'] = '0'
rebate_all = {}
# 获取回佣主表所有rebate_cycle
rebate_cycle_all = await sor.R('rebate_cycle', ns)
for rebate_cyc in rebate_cycle_all:
zhu_table_id = rebate_cyc['id']
sette_dp = rebate_cyc['sette_dp']
zhu_table_cycle = rebate_cyc['rebate_cycle']
# 查找子表内容
zi_table_find = {
'rebatecycleid': zhu_table_id,
'sort': 'sale_amount',
'del_flg': '0'
}
zi_table_all = await sor.R('rp_rebate', zi_table_find)
for zi_table in zi_table_all:
zi_table_sigle = {}
zi_table_sigle['rp_rebate_id'] = zi_table['id']
zi_table_sigle['sale_amount'] = zi_table['sale_amount']
zi_table_sigle['rebate_rate'] = zi_table['rebate_rate']
zi_table_sigle['rebate_cycle_id'] = zhu_table_id
zi_table_sigle['sette_dp'] = sette_dp
if zhu_table_cycle in rebate_all.keys():
rebate_all[zhu_table_cycle].append(zi_table_sigle)
else:
rebate_all[zhu_table_cycle] = [zi_table_sigle]
return {
'status': True,
'msg': '回佣查找成功',
'data': rebate_all
}
except Exception as e:
raise e
return {
'status': False,
'msg': '回佣查询失败'
}
ret = await rebate_search(params_kw)
return ret