voucher/wwwroot/api/get_available.dspy

15 lines
595 B
Plaintext

# get_available.dspy — 内部查询可用券(带规则预校验过滤;供结算方/调试)
customer_id = (params_kw.get('customer_id') or '').strip()
if not customer_id:
customer_id = await get_userorgid() or ''
context = {}
for k in ('product_type', 'product_name'):
if params_kw.get(k):
context[k] = params_kw.get(k)
if params_kw.get('request_amount'):
try:
context['request_amount'] = float(params_kw.get('request_amount'))
except (ValueError, TypeError):
pass
return await get_available_vouchers_api(customer_id, context if context else None)