24 lines
1.1 KiB
Plaintext
24 lines
1.1 KiB
Plaintext
pptid = params_kw.id
|
|
env = request._run_ns
|
|
orgid = await get_userorgid()
|
|
async with get_sor_context(env, 'pricing') as sor:
|
|
recs = await sor.R('pricing_program_timing', {'id': pptid})
|
|
if len(recs) == 0:
|
|
return UiError(title='下载定价信息', message=f'{pptid} 在pricing_program_timing中没找到')
|
|
ppt = recs[0]
|
|
recs = await sor.R('pricing_program', {'id': ppt.ppid})
|
|
if len(recs) == 0:
|
|
return UiError(title='下载定价信息', message=f'{ppt.ppid} 在pricing_program中没找到')
|
|
pp = recs[0]
|
|
if pp.ownerid != orgid:
|
|
return UiError(title='下载定价信息', message=f'{userorgid} != {pp.ownerid}非本机构定价')
|
|
data = json.loads(ppt.prcing_data)
|
|
fields = data.get('fields')
|
|
if fields is None:
|
|
return UiError(title='下载定价信息', message=f'{pptid} 定价字段数据为空')
|
|
pricing_data = data.get('pricings')
|
|
if pricing_data is None:
|
|
return UiError(title='下载定价信息', message=f'{pptid} 定价数据为空')
|
|
fpath = write_pattern_xlsx(name, fields, data=pricing_data)
|
|
return await file_response(request, fpath, download=True)
|