fix: dataurl改为/appbase/get_code.dspy,补全CRUD API
- json/discount_list.json: dataurl→/appbase/, resellerid隐藏+自动填充, customerid保留下拉 - json/discount_detail_list.json: dataurl→/appbase/ - 新增6个API: discount和discount_detail的create/update/delete - load_path.py: 注册新API路径到logined和operator
This commit is contained in:
parent
1ba7e0e031
commit
0fcc34c235
@ -1,52 +1,62 @@
|
|||||||
{
|
{
|
||||||
"tblname": "discount_detail",
|
"tblname": "discount_detail",
|
||||||
"alias": "discount_detail_list",
|
"alias": "discount_detail_list",
|
||||||
"title": "折扣产品明细",
|
"title": "折扣产品明细",
|
||||||
"params": {
|
"params": {
|
||||||
"sortby": ["prodtypeid", "productid"],
|
"sortby": [
|
||||||
"browserfields": {
|
"prodtypeid",
|
||||||
"exclouded": ["id", "resellerid"],
|
"productid"
|
||||||
"alters": {
|
],
|
||||||
"discountid": {
|
"browserfields": {
|
||||||
"uitype": "code",
|
"exclouded": [
|
||||||
"dataurl": "/get_code.dspy",
|
"id",
|
||||||
"datamethod": "GET",
|
"resellerid"
|
||||||
"dataparams": {
|
],
|
||||||
"dbname": "sage",
|
"alters": {
|
||||||
"table": "discount",
|
"discountid": {
|
||||||
"tblvalue": "id",
|
"uitype": "code",
|
||||||
"tbltext": "name"
|
"dataurl": "/appbase/get_code.dspy",
|
||||||
}
|
"datamethod": "GET",
|
||||||
},
|
"dataparams": {
|
||||||
"prodtypeid": {
|
"dbname": "sage",
|
||||||
"uitype": "code",
|
"table": "discount",
|
||||||
"dataurl": "/get_code.dspy",
|
"tblvalue": "id",
|
||||||
"datamethod": "GET",
|
"tbltext": "name"
|
||||||
"dataparams": {
|
}
|
||||||
"dbname": "sage",
|
|
||||||
"table": "prodtype",
|
|
||||||
"tblvalue": "id",
|
|
||||||
"tbltext": "name"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"productid": {
|
|
||||||
"uitype": "code",
|
|
||||||
"dataurl": "/get_code.dspy",
|
|
||||||
"datamethod": "GET",
|
|
||||||
"dataparams": {
|
|
||||||
"dbname": "sage",
|
|
||||||
"table": "product",
|
|
||||||
"tblvalue": "id",
|
|
||||||
"tbltext": "name"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"editexclouded": ["id", "discountid", "resellerid"],
|
"prodtypeid": {
|
||||||
"editable": {
|
"uitype": "code",
|
||||||
"new_data_url": "{{entire_url('../api/discount_detail_create.dspy')}}",
|
"dataurl": "/appbase/get_code.dspy",
|
||||||
"update_data_url": "{{entire_url('../api/discount_detail_update.dspy')}}",
|
"datamethod": "GET",
|
||||||
"delete_data_url": "{{entire_url('../api/discount_detail_delete.dspy')}}"
|
"dataparams": {
|
||||||
|
"dbname": "sage",
|
||||||
|
"table": "prodtype",
|
||||||
|
"tblvalue": "id",
|
||||||
|
"tbltext": "name"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"productid": {
|
||||||
|
"uitype": "code",
|
||||||
|
"dataurl": "/appbase/get_code.dspy",
|
||||||
|
"datamethod": "GET",
|
||||||
|
"dataparams": {
|
||||||
|
"dbname": "sage",
|
||||||
|
"table": "product",
|
||||||
|
"tblvalue": "id",
|
||||||
|
"tbltext": "name"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"editexclouded": [
|
||||||
|
"id",
|
||||||
|
"discountid",
|
||||||
|
"resellerid"
|
||||||
|
],
|
||||||
|
"editable": {
|
||||||
|
"new_data_url": "{{entire_url('../api/discount_detail_create.dspy')}}",
|
||||||
|
"update_data_url": "{{entire_url('../api/discount_detail_update.dspy')}}",
|
||||||
|
"delete_data_url": "{{entire_url('../api/discount_detail_delete.dspy')}}"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,41 +1,39 @@
|
|||||||
{
|
{
|
||||||
"tblname": "discount",
|
"tblname": "discount",
|
||||||
"alias": "discount_list",
|
"alias": "discount_list",
|
||||||
"title": "折扣管理",
|
"title": "折扣管理",
|
||||||
"params": {
|
"params": {
|
||||||
"sortby": ["enabled_date desc"],
|
"sortby": [
|
||||||
"browserfields": {
|
"enabled_date desc"
|
||||||
"exclouded": ["id"],
|
],
|
||||||
"alters": {
|
"browserfields": {
|
||||||
"resellerid": {
|
"exclouded": [
|
||||||
"uitype": "code",
|
"id",
|
||||||
"dataurl": "/get_code.dspy",
|
"resellerid"
|
||||||
"datamethod": "GET",
|
],
|
||||||
"dataparams": {
|
"alters": {
|
||||||
"dbname": "sage",
|
"customerid": {
|
||||||
"table": "organization",
|
"uitype": "code",
|
||||||
"tblvalue": "id",
|
"dataurl": "/appbase/get_code.dspy",
|
||||||
"tbltext": "orgname"
|
"datamethod": "GET",
|
||||||
}
|
"dataparams": {
|
||||||
},
|
"dbname": "sage",
|
||||||
"customerid": {
|
"table": "organization",
|
||||||
"uitype": "code",
|
"tblvalue": "id",
|
||||||
"dataurl": "/get_code.dspy",
|
"tbltext": "orgname"
|
||||||
"datamethod": "GET",
|
}
|
||||||
"dataparams": {
|
|
||||||
"dbname": "sage",
|
|
||||||
"table": "organization",
|
|
||||||
"tblvalue": "id",
|
|
||||||
"tbltext": "orgname"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"editexclouded": ["id"],
|
|
||||||
"editable": {
|
|
||||||
"new_data_url": "{{entire_url('../api/discount_create.dspy')}}",
|
|
||||||
"update_data_url": "{{entire_url('../api/discount_update.dspy')}}",
|
|
||||||
"delete_data_url": "{{entire_url('../api/discount_delete.dspy')}}"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"editexclouded": [
|
||||||
|
"id",
|
||||||
|
"resellerid"
|
||||||
|
],
|
||||||
|
"editable": {
|
||||||
|
"new_data_url": "{{entire_url('../api/discount_create.dspy')}}",
|
||||||
|
"update_data_url": "{{entire_url('../api/discount_update.dspy')}}",
|
||||||
|
"delete_data_url": "{{entire_url('../api/discount_delete.dspy')}}"
|
||||||
|
},
|
||||||
|
"logined_userorgid": "resellerid"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -101,6 +101,12 @@ PATHS_LOGINED = [
|
|||||||
f"/{MOD}/discount_customer_bind_list/update_discount_customer_bind.dspy",
|
f"/{MOD}/discount_customer_bind_list/update_discount_customer_bind.dspy",
|
||||||
f"/{MOD}/discount_customer_bind_list/delete_discount_customer_bind.dspy",
|
f"/{MOD}/discount_customer_bind_list/delete_discount_customer_bind.dspy",
|
||||||
# CRUD API (json/ defined)
|
# CRUD API (json/ defined)
|
||||||
|
f"/{MOD}/api/discount_create.dspy",
|
||||||
|
f"/{MOD}/api/discount_update.dspy",
|
||||||
|
f"/{MOD}/api/discount_delete.dspy",
|
||||||
|
f"/{MOD}/api/discount_detail_create.dspy",
|
||||||
|
f"/{MOD}/api/discount_detail_update.dspy",
|
||||||
|
f"/{MOD}/api/discount_detail_delete.dspy",
|
||||||
f"/{MOD}/api/marketing_create.dspy",
|
f"/{MOD}/api/marketing_create.dspy",
|
||||||
f"/{MOD}/api/marketing_update.dspy",
|
f"/{MOD}/api/marketing_update.dspy",
|
||||||
f"/{MOD}/api/marketing_delete.dspy",
|
f"/{MOD}/api/marketing_delete.dspy",
|
||||||
@ -158,6 +164,13 @@ PATHS_OPERATOR = [
|
|||||||
f"/{MOD}/api/customer_bind_create.dspy",
|
f"/{MOD}/api/customer_bind_create.dspy",
|
||||||
f"/{MOD}/api/customer_bind_update.dspy",
|
f"/{MOD}/api/customer_bind_update.dspy",
|
||||||
f"/{MOD}/api/customer_bind_delete.dspy",
|
f"/{MOD}/api/customer_bind_delete.dspy",
|
||||||
|
# 折扣方案和明细 API
|
||||||
|
f"/{MOD}/api/discount_create.dspy",
|
||||||
|
f"/{MOD}/api/discount_update.dspy",
|
||||||
|
f"/{MOD}/api/discount_delete.dspy",
|
||||||
|
f"/{MOD}/api/discount_detail_create.dspy",
|
||||||
|
f"/{MOD}/api/discount_detail_update.dspy",
|
||||||
|
f"/{MOD}/api/discount_detail_delete.dspy",
|
||||||
]
|
]
|
||||||
|
|
||||||
# 角色专属权限 — sale 可查看促销码和客户归属
|
# 角色专属权限 — sale 可查看促销码和客户归属
|
||||||
|
|||||||
19
wwwroot/api/discount_create.dspy
Normal file
19
wwwroot/api/discount_create.dspy
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid', 'type': 'error'}}
|
||||||
|
|
||||||
|
try:
|
||||||
|
user_orgid = (await get_userorgid()) or '0'
|
||||||
|
dbname = get_module_dbname('discount')
|
||||||
|
|
||||||
|
data = dict(params_kw)
|
||||||
|
data['id'] = getID()
|
||||||
|
data['resellerid'] = user_orgid
|
||||||
|
|
||||||
|
async with DBPools().sqlorContext(dbname) as sor:
|
||||||
|
await sor.C('discount', data)
|
||||||
|
|
||||||
|
result = {'widgettype': 'Message', 'options': {'title': 'Success', 'message': '折扣方案创建成功', 'type': 'success'}}
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
result['options'] = {'title': 'Error', 'message': '创建失败: ' + str(e), 'type': 'error'}
|
||||||
|
|
||||||
|
return json.dumps(result, ensure_ascii=False)
|
||||||
15
wwwroot/api/discount_delete.dspy
Normal file
15
wwwroot/api/discount_delete.dspy
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid', 'type': 'error'}}
|
||||||
|
|
||||||
|
try:
|
||||||
|
dbname = get_module_dbname('discount')
|
||||||
|
id = params_kw.get('id')
|
||||||
|
|
||||||
|
async with DBPools().sqlorContext(dbname) as sor:
|
||||||
|
await sor.D('discount', {'id': id})
|
||||||
|
|
||||||
|
result = {'widgettype': 'Message', 'options': {'title': 'Success', 'message': '折扣方案删除成功', 'type': 'success'}}
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
result['options'] = {'title': 'Error', 'message': '删除失败: ' + str(e), 'type': 'error'}
|
||||||
|
|
||||||
|
return json.dumps(result, ensure_ascii=False)
|
||||||
19
wwwroot/api/discount_detail_create.dspy
Normal file
19
wwwroot/api/discount_detail_create.dspy
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid', 'type': 'error'}}
|
||||||
|
|
||||||
|
try:
|
||||||
|
user_orgid = (await get_userorgid()) or '0'
|
||||||
|
dbname = get_module_dbname('discount')
|
||||||
|
|
||||||
|
data = dict(params_kw)
|
||||||
|
data['id'] = getID()
|
||||||
|
data['resellerid'] = user_orgid
|
||||||
|
|
||||||
|
async with DBPools().sqlorContext(dbname) as sor:
|
||||||
|
await sor.C('discount_detail', data)
|
||||||
|
|
||||||
|
result = {'widgettype': 'Message', 'options': {'title': 'Success', 'message': '折扣明细创建成功', 'type': 'success'}}
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
result['options'] = {'title': 'Error', 'message': '创建失败: ' + str(e), 'type': 'error'}
|
||||||
|
|
||||||
|
return json.dumps(result, ensure_ascii=False)
|
||||||
15
wwwroot/api/discount_detail_delete.dspy
Normal file
15
wwwroot/api/discount_detail_delete.dspy
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid', 'type': 'error'}}
|
||||||
|
|
||||||
|
try:
|
||||||
|
dbname = get_module_dbname('discount')
|
||||||
|
id = params_kw.get('id')
|
||||||
|
|
||||||
|
async with DBPools().sqlorContext(dbname) as sor:
|
||||||
|
await sor.D('discount_detail', {'id': id})
|
||||||
|
|
||||||
|
result = {'widgettype': 'Message', 'options': {'title': 'Success', 'message': '折扣明细删除成功', 'type': 'success'}}
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
result['options'] = {'title': 'Error', 'message': '删除失败: ' + str(e), 'type': 'error'}
|
||||||
|
|
||||||
|
return json.dumps(result, ensure_ascii=False)
|
||||||
15
wwwroot/api/discount_detail_update.dspy
Normal file
15
wwwroot/api/discount_detail_update.dspy
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid', 'type': 'error'}}
|
||||||
|
|
||||||
|
try:
|
||||||
|
data = dict(params_kw)
|
||||||
|
dbname = get_module_dbname('discount')
|
||||||
|
|
||||||
|
async with DBPools().sqlorContext(dbname) as sor:
|
||||||
|
await sor.U('discount_detail', data)
|
||||||
|
|
||||||
|
result = {'widgettype': 'Message', 'options': {'title': 'Success', 'message': '折扣明细更新成功', 'type': 'success'}}
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
result['options'] = {'title': 'Error', 'message': '更新失败: ' + str(e), 'type': 'error'}
|
||||||
|
|
||||||
|
return json.dumps(result, ensure_ascii=False)
|
||||||
15
wwwroot/api/discount_update.dspy
Normal file
15
wwwroot/api/discount_update.dspy
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid', 'type': 'error'}}
|
||||||
|
|
||||||
|
try:
|
||||||
|
data = dict(params_kw)
|
||||||
|
dbname = get_module_dbname('discount')
|
||||||
|
|
||||||
|
async with DBPools().sqlorContext(dbname) as sor:
|
||||||
|
await sor.U('discount', data)
|
||||||
|
|
||||||
|
result = {'widgettype': 'Message', 'options': {'title': 'Success', 'message': '折扣方案更新成功', 'type': 'success'}}
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
result['options'] = {'title': 'Error', 'message': '更新失败: ' + str(e), 'type': 'error'}
|
||||||
|
|
||||||
|
return json.dumps(result, ensure_ascii=False)
|
||||||
Loading…
x
Reference in New Issue
Block a user