supplychain/wwwroot/api/supply_contract_items_create.dspy
yumoqing 0049db58e5 fix: move product_org_auth sync to distribution_agreement_items (not supply_contract_items)
- supply_contract_items: revert — products already belong to reseller's own org
- distribution_agreement_items: create → insert product_org_auth for sub_reseller
- distribution_agreement_items: delete → remove product_org_auth
- org_id in product_org_auth = sub_reseller_id (二级分销商)
2026-07-10 15:48:27 +08:00

23 lines
785 B
Plaintext

result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid', 'type': 'error'}}
try:
user_id = await get_user()
user_orgid = (await get_userorgid()) or '0'
dbname = get_module_dbname('supplychain')
data = dict(params_kw)
data['id'] = getID()
data['resellerid'] = user_orgid
data['created_at'] = timestampstr()
data['updated_at'] = timestampstr()
async with DBPools().sqlorContext(dbname) as sor:
await sor.C('supply_contract_items', data)
result = {'widgettype': 'Message', 'options': {'title': 'Success', 'message': '供应合同项目创建成功', 'type': 'success'}}
except Exception as e:
result['options'] = {'title': 'Error', 'message': '创建失败: ' + str(e), 'type': 'error'}
return result