diff --git a/json/discount_detail_list.json b/json/discount_detail_list.json index 75beead..8d59c74 100644 --- a/json/discount_detail_list.json +++ b/json/discount_detail_list.json @@ -1,52 +1,62 @@ { - "tblname": "discount_detail", - "alias": "discount_detail_list", - "title": "折扣产品明细", - "params": { - "sortby": ["prodtypeid", "productid"], - "browserfields": { - "exclouded": ["id", "resellerid"], - "alters": { - "discountid": { - "uitype": "code", - "dataurl": "/get_code.dspy", - "datamethod": "GET", - "dataparams": { - "dbname": "sage", - "table": "discount", - "tblvalue": "id", - "tbltext": "name" - } - }, - "prodtypeid": { - "uitype": "code", - "dataurl": "/get_code.dspy", - "datamethod": "GET", - "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" - } - } - } + "tblname": "discount_detail", + "alias": "discount_detail_list", + "title": "折扣产品明细", + "params": { + "sortby": [ + "prodtypeid", + "productid" + ], + "browserfields": { + "exclouded": [ + "id", + "resellerid" + ], + "alters": { + "discountid": { + "uitype": "code", + "dataurl": "/appbase/get_code.dspy", + "datamethod": "GET", + "dataparams": { + "dbname": "sage", + "table": "discount", + "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')}}" + "prodtypeid": { + "uitype": "code", + "dataurl": "/appbase/get_code.dspy", + "datamethod": "GET", + "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')}}" } + } } diff --git a/json/discount_list.json b/json/discount_list.json index 8f6ecd5..fd174fa 100644 --- a/json/discount_list.json +++ b/json/discount_list.json @@ -1,41 +1,39 @@ { - "tblname": "discount", - "alias": "discount_list", - "title": "折扣管理", - "params": { - "sortby": ["enabled_date desc"], - "browserfields": { - "exclouded": ["id"], - "alters": { - "resellerid": { - "uitype": "code", - "dataurl": "/get_code.dspy", - "datamethod": "GET", - "dataparams": { - "dbname": "sage", - "table": "organization", - "tblvalue": "id", - "tbltext": "orgname" - } - }, - "customerid": { - "uitype": "code", - "dataurl": "/get_code.dspy", - "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')}}" + "tblname": "discount", + "alias": "discount_list", + "title": "折扣管理", + "params": { + "sortby": [ + "enabled_date desc" + ], + "browserfields": { + "exclouded": [ + "id", + "resellerid" + ], + "alters": { + "customerid": { + "uitype": "code", + "dataurl": "/appbase/get_code.dspy", + "datamethod": "GET", + "dataparams": { + "dbname": "sage", + "table": "organization", + "tblvalue": "id", + "tbltext": "orgname" + } } - } + } + }, + "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" + } } diff --git a/scripts/load_path.py b/scripts/load_path.py index 4e3c4ce..339c2af 100644 --- a/scripts/load_path.py +++ b/scripts/load_path.py @@ -101,6 +101,12 @@ PATHS_LOGINED = [ f"/{MOD}/discount_customer_bind_list/update_discount_customer_bind.dspy", f"/{MOD}/discount_customer_bind_list/delete_discount_customer_bind.dspy", # 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_update.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_update.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 可查看促销码和客户归属 diff --git a/wwwroot/api/discount_create.dspy b/wwwroot/api/discount_create.dspy new file mode 100644 index 0000000..48fe2fc --- /dev/null +++ b/wwwroot/api/discount_create.dspy @@ -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) diff --git a/wwwroot/api/discount_delete.dspy b/wwwroot/api/discount_delete.dspy new file mode 100644 index 0000000..870ad55 --- /dev/null +++ b/wwwroot/api/discount_delete.dspy @@ -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) diff --git a/wwwroot/api/discount_detail_create.dspy b/wwwroot/api/discount_detail_create.dspy new file mode 100644 index 0000000..026a323 --- /dev/null +++ b/wwwroot/api/discount_detail_create.dspy @@ -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) diff --git a/wwwroot/api/discount_detail_delete.dspy b/wwwroot/api/discount_detail_delete.dspy new file mode 100644 index 0000000..53ba8c9 --- /dev/null +++ b/wwwroot/api/discount_detail_delete.dspy @@ -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) diff --git a/wwwroot/api/discount_detail_update.dspy b/wwwroot/api/discount_detail_update.dspy new file mode 100644 index 0000000..2212bc1 --- /dev/null +++ b/wwwroot/api/discount_detail_update.dspy @@ -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) diff --git a/wwwroot/api/discount_update.dspy b/wwwroot/api/discount_update.dspy new file mode 100644 index 0000000..9dfd6e6 --- /dev/null +++ b/wwwroot/api/discount_update.dspy @@ -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)