35 lines
1.7 KiB
Plaintext
35 lines
1.7 KiB
Plaintext
async def get_cpcc_provider(ns={}):
|
|
db = DBPools()
|
|
async with db.sqlorContext('kboss') as sor:
|
|
cpcc_list = await sor.R('cpclist', {'orgid': ns.get('orgid')})
|
|
data = []
|
|
for cpcc in cpcc_list:
|
|
if ns.get('cpccid') and cpcc['id'] != ns.get('cpccid'):
|
|
continue
|
|
init_data = {}
|
|
init_data['cpccid'] = cpcc['id']
|
|
init_data['cpccname'] = cpcc['name']
|
|
init_data['provider_convert_state'] = False
|
|
init_data['init_product_state'] = False
|
|
provider_state = await sor.R('organization', {'orgcode': init_data['cpccid'], 'del_flg': '0'})
|
|
if provider_state:
|
|
init_data['provider_convert_state'] = True
|
|
init_data['provider_info'] = {
|
|
'providerid': provider_state[0]['id'],
|
|
'name': provider_state[0]['orgname'],
|
|
}
|
|
cpcc_init_product = await sor.R('product', {'providerid': provider_state[0]['id'], 'classify': 'CPCC-CUSTOMIZE', 'del_flg': '0'})
|
|
init_data['init_product_state'] = True if cpcc_init_product else False
|
|
combination_product_sql = """select * from product where providerid = '%s' and classify = 'CPCC-COMBINATION' and del_flg = '0' order by create_at desc;""" % provider_state[0]['id']
|
|
combination_product = await sor.sqlExe(combination_product_sql, {})
|
|
init_data['combination_product'] = combination_product
|
|
data.append(init_data)
|
|
return {
|
|
'status': True,
|
|
'msg': 'get cpcc success',
|
|
'data': data
|
|
}
|
|
|
|
|
|
ret = await get_cpcc_provider(params_kw)
|
|
return ret |