From 670414aee5849a9eca9e6bd733b9b9ee45e594fe Mon Sep 17 00:00:00 2001 From: yumoqing Date: Sat, 12 Jul 2025 23:18:42 +0800 Subject: [PATCH] bugfix --- wwwroot/add_provider.dspy | 36 +++++++++ wwwroot/add_reseller.dspy | 26 +++++++ wwwroot/get_provider.dspy | 151 ++++++++++++++++++++++++++++++++++++++ wwwroot/get_reseller.dspy | 151 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 364 insertions(+) create mode 100644 wwwroot/add_provider.dspy create mode 100644 wwwroot/add_reseller.dspy create mode 100644 wwwroot/get_provider.dspy create mode 100644 wwwroot/get_reseller.dspy diff --git a/wwwroot/add_provider.dspy b/wwwroot/add_provider.dspy new file mode 100644 index 0000000..7a44acc --- /dev/null +++ b/wwwroot/add_provider.dspy @@ -0,0 +1,36 @@ +ns = params_kw.copy() +id = params_kw.id +if not id or len(id) > 32: + id = uuid() +ns['id'] = id +db = DBPools() +dbname = get_module_dbname('rbac') +async with db.sqlorContext(dbname) as sor: + ownerid = await get_userorgid() + await create_org(sor, ns, orgtypes=['customer', 'provider']) + if openCustomerAccounts: + await openCustomerAccounts(sor, ownerid, orgid) + if openProviderAccounts: + await openProviderAccounts(sor, ownerid, id) + return { + "widgettype":"Message", + "options":{ + "user_data":ns, + "cwidth":16, + "cheight":9, + "title":"Add Success", + "timeout":3, + "message":"ok" + } + } + +return { + "widgettype":"Error", + "options":{ + "title":"Add Error", + "cwidth":16, + "cheight":9, + "timeout":3, + "message":"failed" + } +} diff --git a/wwwroot/add_reseller.dspy b/wwwroot/add_reseller.dspy new file mode 100644 index 0000000..cd8de33 --- /dev/null +++ b/wwwroot/add_reseller.dspy @@ -0,0 +1,26 @@ +ns = params_kw.copy() +id = params_kw.id +if not id or len(id) > 32: + id = uuid() +ns['id'] = id +db = DBPools() +dbname = get_module_dbname('rbac') +async with db.sqlorContext(dbname) as sor: + ownerid = await get_userorgid() + await create_org(sor, ns, orgtypes=['customer', 'reseller']) + if openCustomerAccounts: + await openCustomerAccounts(sor, ownerid, orgid) + if openResellerAccounts: + await openResellerAccounts(sor, ownerid, id) + return UiMessage(title="Success", message="add reseller success") + +return { + "widgettype":"Error", + "options":{ + "title":"Add reseller Error", + "cwidth":16, + "cheight":9, + "timeout":3, + "message":"failed" + } +} diff --git a/wwwroot/get_provider.dspy b/wwwroot/get_provider.dspy new file mode 100644 index 0000000..3d61294 --- /dev/null +++ b/wwwroot/get_provider.dspy @@ -0,0 +1,151 @@ +ns = params_kw.copy() +debug(f'get_organization.dspy:{ns=}') +if not ns.get('page'): + ns['page'] = 1 +if not ns.get('sort'): + ns['sort'] = 'orgname' + +sql = '''select a.*, b.province_id_text, c.city_id_text, d.distinct_id_text +from (select x.* from (select * from organization where 1=1 [[filterstr]]) x, orgtypes y where x.id = y.orgid and y.orgtypeid='provider') a left join (select k as province_id, + v as province_id_text from appcodes_kv where parentid='chnaddr') b on a.province_id = b.province_id left join (select k as city_id, + v as city_id_text from appcodes_kv where parentid='city') c on a.city_id = c.city_id left join (select k as distinct_id, + v as distinct_id_text from appcodes_kv where parentid='distinct') d on a.distinct_id = d.distinct_id''' + +filterjson = params_kw.get('data_filter') +if not filterjson: + fields = [ f['name'] for f in [ + { + "name": "id", + "title": "机构编码", + "type": "str", + "length": 32 + }, + { + "name": "orgname", + "title": "机构名称", + "type": "str", + "length": 100 + }, + { + "name": "alias_name", + "title": "机构别名", + "type": "str", + "length": 100 + }, + { + "name": "contactor", + "title": "联系人", + "type": "str", + "length": 32 + }, + { + "name": "contactor_phone", + "title": "联系人电话", + "type": "str", + "length": 100 + }, + { + "name": "province_id", + "title": "所在省id", + "type": "str", + "length": 32 + }, + { + "name": "city_id", + "title": "所在城市id", + "type": "str", + "length": 32 + }, + { + "name": "distinct_id", + "title": "所在地区id", + "type": "str", + "length": 32 + }, + { + "name": "emailaddress", + "title": "邮箱", + "type": "str", + "length": 256 + }, + { + "name": "address", + "title": "地址", + "type": "str", + "length": 400 + }, + { + "name": "main_business", + "title": "主营业务描述", + "type": "str", + "length": 1000 + }, + { + "name": "orgcode", + "title": "组织结构代码", + "type": "str", + "length": 100, + "comments": "个人客户存身份证" + }, + { + "name": "license_img", + "title": "营业执照", + "type": "str", + "length": 400, + "comments": "个人客户存身份证照片" + }, + { + "name": "id_img", + "title": "身份证", + "type": "str", + "length": 400, + "comments": "个人客户存身份证背面照片" + }, + { + "name": "parentid", + "title": "父机构id", + "type": "str", + "length": 32 + }, + { + "name": "org_type", + "title": "机构类型", + "type": "str", + "length": 32, + "comments": "0:业主机构;1:分销商;2:公司客户;3:个人客户;4:供应商" + }, + { + "name": "accountid", + "title": "账号", + "type": "str", + "length": 32 + } +] ] + filterjson = default_filterjson(fields, ns) +filterdic = ns.copy() +filterdic['filterstr'] = '' +filterdic['userorgid'] = '${userorgid}$' +filterdic['userid'] = '${userid}$' +if filterjson: + dbf = DBFilter(filterjson) + conds = dbf.gen(ns) + if conds: + ns.update(dbf.consts) + conds = f' and {conds}' + filterdic['filterstr'] = conds +ac = ArgsConvert('[[', ']]') +vars = ac.findAllVariables(sql) +NameSpace = {v:'${' + v + '}$' for v in vars if v != 'filterstr' } +filterdic.update(NameSpace) +sql = ac.convert(sql, filterdic) + +debug(f'{sql=}') +db = DBPools() +dbname = get_module_dbname('rbac') +async with db.sqlorContext(dbname) as sor: + r = await sor.sqlPaging(sql, ns) + return r +return { + "total":0, + "rows":[] +} diff --git a/wwwroot/get_reseller.dspy b/wwwroot/get_reseller.dspy new file mode 100644 index 0000000..898ec19 --- /dev/null +++ b/wwwroot/get_reseller.dspy @@ -0,0 +1,151 @@ +ns = params_kw.copy() +debug(f'get_organization.dspy:{ns=}') +if not ns.get('page'): + ns['page'] = 1 +if not ns.get('sort'): + ns['sort'] = 'orgname' + +sql = '''select a.*, b.province_id_text, c.city_id_text, d.distinct_id_text +from (select x.* from (select * from organization where 1=1 [[filterstr]]) x, orgtypes y where x.id = y.orgid and y.orgtypeid='reseller') a left join (select k as province_id, + v as province_id_text from appcodes_kv where parentid='chnaddr') b on a.province_id = b.province_id left join (select k as city_id, + v as city_id_text from appcodes_kv where parentid='city') c on a.city_id = c.city_id left join (select k as distinct_id, + v as distinct_id_text from appcodes_kv where parentid='distinct') d on a.distinct_id = d.distinct_id''' + +filterjson = params_kw.get('data_filter') +if not filterjson: + fields = [ f['name'] for f in [ + { + "name": "id", + "title": "机构编码", + "type": "str", + "length": 32 + }, + { + "name": "orgname", + "title": "机构名称", + "type": "str", + "length": 100 + }, + { + "name": "alias_name", + "title": "机构别名", + "type": "str", + "length": 100 + }, + { + "name": "contactor", + "title": "联系人", + "type": "str", + "length": 32 + }, + { + "name": "contactor_phone", + "title": "联系人电话", + "type": "str", + "length": 100 + }, + { + "name": "province_id", + "title": "所在省id", + "type": "str", + "length": 32 + }, + { + "name": "city_id", + "title": "所在城市id", + "type": "str", + "length": 32 + }, + { + "name": "distinct_id", + "title": "所在地区id", + "type": "str", + "length": 32 + }, + { + "name": "emailaddress", + "title": "邮箱", + "type": "str", + "length": 256 + }, + { + "name": "address", + "title": "地址", + "type": "str", + "length": 400 + }, + { + "name": "main_business", + "title": "主营业务描述", + "type": "str", + "length": 1000 + }, + { + "name": "orgcode", + "title": "组织结构代码", + "type": "str", + "length": 100, + "comments": "个人客户存身份证" + }, + { + "name": "license_img", + "title": "营业执照", + "type": "str", + "length": 400, + "comments": "个人客户存身份证照片" + }, + { + "name": "id_img", + "title": "身份证", + "type": "str", + "length": 400, + "comments": "个人客户存身份证背面照片" + }, + { + "name": "parentid", + "title": "父机构id", + "type": "str", + "length": 32 + }, + { + "name": "org_type", + "title": "机构类型", + "type": "str", + "length": 32, + "comments": "0:业主机构;1:分销商;2:公司客户;3:个人客户;4:供应商" + }, + { + "name": "accountid", + "title": "账号", + "type": "str", + "length": 32 + } +] ] + filterjson = default_filterjson(fields, ns) +filterdic = ns.copy() +filterdic['filterstr'] = '' +filterdic['userorgid'] = '${userorgid}$' +filterdic['userid'] = '${userid}$' +if filterjson: + dbf = DBFilter(filterjson) + conds = dbf.gen(ns) + if conds: + ns.update(dbf.consts) + conds = f' and {conds}' + filterdic['filterstr'] = conds +ac = ArgsConvert('[[', ']]') +vars = ac.findAllVariables(sql) +NameSpace = {v:'${' + v + '}$' for v in vars if v != 'filterstr' } +filterdic.update(NameSpace) +sql = ac.convert(sql, filterdic) + +debug(f'{sql=}') +db = DBPools() +dbname = get_module_dbname('rbac') +async with db.sqlorContext(dbname) as sor: + r = await sor.sqlPaging(sql, ns) + return r +return { + "total":0, + "rows":[] +}