This commit is contained in:
ping 2026-05-19 18:05:41 +08:00
parent 314aaa9d85
commit 0b7c9088ad
5 changed files with 127 additions and 85 deletions

View File

@ -6,6 +6,7 @@ async def get_user_balance(ns={}):
:return: 账户余额(与 getCustomerBalance 返回值一致)
"""
apikey = ns.get('apikey')
userid = ns.get('userid')
db = DBPools()
async with db.sqlorContext('kboss') as sor:
if not apikey:
@ -17,10 +18,15 @@ async def get_user_balance(ns={}):
if not userid_li:
return {
'status': False,
'msg': '用户未同步到系统'
'msg': 'apikey无效请联系管理员'
}
userid = userid_li[0]['userid']
# userid = userid_li[0]['userid']
user = await sor.R('users', {'id': userid})
if not user:
return {
'status': False,
'msg': '用户不存在'
}
orgid = await sor.R('organization', {'id': user[0]['orgid']})
balance = await getCustomerBalance(sor, orgid[0]['id'])
return {

View File

@ -224,20 +224,13 @@ async def process_user_billing(ns={}):
:return: dict含 status、msg成功时含 orderid、amount
"""
apikey = ns.get('apikey')
userid = ns.get('userid')
providername = ns.get('providername')
productname = ns.get('productname')
amount = ns.get('amount')
use_saleprotocol = ns.get('use_saleprotocol', False)
quantity = int(ns.get('quantity', 1))
userid_li = await sor.R('user_api_keys', {'opc_apikey': apikey})
if not userid_li:
return {
'status': False,
'msg': '用户未同步到系统'
}
userid = userid_li[0]['userid']
try:
amount = round(float(amount), 2)
except (TypeError, ValueError):
@ -252,6 +245,14 @@ async def process_user_billing(ns={}):
if not provider_list:
return {'status': False, 'msg': '厂商不存在 %s' % providername}
userid_li = await sor.R('user_api_keys', {'opc_apikey': apikey})
if not userid_li:
return {
'status': False,
'msg': 'apikey无效请联系管理员'
}
# userid = userid_li[0]['userid']
user_list = await sor.R('users', {'id': userid})
if not user_list:
return {'status': False, 'msg': '用户不存在 %s' % userid}

View File

@ -18,10 +18,10 @@ async def sync_cn_ai_user(ns={}):
name = user_info[0]['name']
email = user_info[0]['email']
debug(f"sync_cn_ai_user同步用户: {userid}, {orgid}, {username}, {name}, {email}")
already_sync_user_key = '2i68AZ81di_q5f8AySDrJ'
already_sync_user_dappid = 'cndemo'
# 目标URL
url = "https://ai.atvoe.com/rbac/usersync"
# url = 'https://ai.atvoe.com/tmp/env.dspy'
@ -52,11 +52,11 @@ async def sync_cn_ai_user(ns={}):
# 发送POST请求
async with session.post(url, headers=headers, data=json.dumps(payload)) as response:
# 打印响应状态码
print(f"状态码: {response.status}")
debug(f"sync_cn_ai_user状态码: {response.status}")
result_sysnc = await response.json()
if not result_sysnc.get('status') == 'success':
print(f"同步用户失败: {result_sysnc}")
debug(f"sync_cn_ai_user同步用户失败: {result_sysnc}")
return {
'status': False
}
@ -71,30 +71,31 @@ async def sync_cn_ai_user(ns={}):
records = await sor.R('user_api_keys', {'opc_apikey': apikey})
if records:
print(f"用户{payload['user']['id']}已存在")
debug(f"sync_cn_ai_user用户{payload['user']['id']}已存在")
return {
'status': False,
'msg': f'用户opc_apikey已存在, {result_sysnc}'
'msg': '用户opc_apikey已存在'
}
print(f"{result_sysnc}")
await sor.C('user_api_keys', {
'userid': userid,
'opc_apikey': apikey,
'appid': appid,
'secretkey': secretkey,
'action': 'sync',
'expire_time': None,
})
debug(f"sync_cn_ai_user用户{payload['user']['id']}同步成功")
return {
'status': True,
'msg': '用户同步成功'
}
except Exception as e:
print(f"同步用户失败: {e}")
debug(f"sync_cn_ai_user{userid}同步用户失败: {e}")
return {
'status': False,
'msg': f"同步用户失败: {e}"
'msg': f"sync_cn_ai_user{userid}同步用户失败: {e}"
}

View File

@ -113,7 +113,7 @@ async def registerUser(ns):
if ns.get('password'):
# 至少8位包含大小写字母、特殊字符、数字
if len(ns.get('password')) < 8 or not re.search(r'[a-zA-Z]', ns.get('password')) or not re.search(r'[0-9]', ns.get('password')) or not re.search(r'[!@#$%^&*()_+{}|:"<>?]', ns.get('password')):
if len(ns.get('password')) < 8 or not re.search(r'[a-zA-Z]', ns.get('password')) or not re.search(r'[0-9]', ns.get('password')):
return {'status': False, 'msg': '密码至少8位包含大小写字母、特殊字符、数字'}
if not ns.get('codeid'):

View File

@ -543,7 +543,7 @@ async def get_firstpage_product_tree(ns={}):
"product_service": [
{
"id": "1",
"firTitle": "云",
"firTitle": "基础云",
"secMenu": [
{
"id": "10",
@ -576,43 +576,77 @@ async def get_firstpage_product_tree(ns={}):
]
},
{
'id': "2", 'firTitle': "算", 'secMenu': [
{
'id': '21', 'secTitle': '智算', 'thrMenu': [
'id': "2", 'firTitle': "TOKEN市集", 'secMenu': [
{
'id': '211',
'thrTitle': None,
'value': [#{'id': '2111', 'name': '容器云'},
{'id': '2113', 'name': '裸金属'},
#{'id': '2114', 'name': '裸金属-910B'},
{'id': '2115', 'name': '一体机-昆仑芯'},
{'id': '2112', 'name': '一体机-天数智芯'},]
},
],
},
]
},
{
"id": "3",
"firTitle": "网",
"secMenu": [
{
"id": "31",
"secTitle": "算力网络",
"thrMenu": [
{
"id": "311",
"thrTitle": None,
"value": [{'id': '3111', 'name': '互联网专线'},
{'id': '3121', 'name': 'SDWAN'},
{'id': '3131', 'name': 'DCI'},
{'id': '3141', 'name': 'AI专线'}
]
}
]
# 'id': '21', 'secTitle': '智算', 'thrMenu': [
# {
# 'id': '211',
# 'thrTitle': None,
# 'value': [#{'id': '2111', 'name': '容器云'},
# {'id': '2113', 'name': '裸金属'},
# #{'id': '2114', 'name': '裸金属-910B'},
# {'id': '2115', 'name': '一体机-昆仑芯'},
# {'id': '2112', 'name': '一体机-天数智芯'},]
# },
# ],
},
]
},
{
'id': "2", 'firTitle': "元境", 'secMenu': [
# {
# 'id': '21', 'secTitle': '智算', 'thrMenu': [
# {
# 'id': '211',
# 'thrTitle': None,
# 'value': [#{'id': '2111', 'name': '容器云'},
# {'id': '2113', 'name': '裸金属'},
# #{'id': '2114', 'name': '裸金属-910B'},
# {'id': '2115', 'name': '一体机-昆仑芯'},
# {'id': '2112', 'name': '一体机-天数智芯'},]
# },
# ],
# },
]
},
# {
# 'id': "2", 'firTitle': "算", 'secMenu': [
# {
# 'id': '21', 'secTitle': '智算', 'thrMenu': [
# {
# 'id': '211',
# 'thrTitle': None,
# 'value': [#{'id': '2111', 'name': '容器云'},
# {'id': '2113', 'name': '裸金属'},
# #{'id': '2114', 'name': '裸金属-910B'},
# {'id': '2115', 'name': '一体机-昆仑芯'},
# {'id': '2112', 'name': '一体机-天数智芯'},]
# },
# ],
# },
# ]
# },
# {
# "id": "3",
# "firTitle": "网",
# "secMenu": [
# {
# "id": "31",
# "secTitle": "算力网络",
# "thrMenu": [
# {
# "id": "311",
# "thrTitle": None,
# "value": [{'id': '3111', 'name': '互联网专线'},
# {'id': '3121', 'name': 'SDWAN'},
# {'id': '3131', 'name': 'DCI'},
# {'id': '3141', 'name': 'AI专线'}
# ]
# }
# ]
# },
# ]
# },
# {
# "id": "4",
# "firTitle": "模型",
@ -623,38 +657,38 @@ async def get_firstpage_product_tree(ns={}):
# "firTitle": "服务",
# "secMenu": []
# },
{
"id": "6",
"firTitle": "用",
"secMenu": [
{
"id": "61",
"secTitle": "AI应用",
"thrMenu": [
{
"id": "611",
"thrTitle": "智慧医疗",
"value": [
{
"id": "6111",
"name": "灵医智能体"
}
]
},
{
"id": "612",
"thrTitle": "智慧客服",
"value": [
{
"id": "6112",
"name": "客悦·智能客服"
}
]
},
]
},
]
}
# {
# "id": "6",
# "firTitle": "用",
# "secMenu": [
# {
# "id": "61",
# "secTitle": "AI应用",
# "thrMenu": [
# {
# "id": "611",
# "thrTitle": "智慧医疗",
# "value": [
# {
# "id": "6111",
# "name": "灵医智能体"
# }
# ]
# },
# {
# "id": "612",
# "thrTitle": "智慧客服",
# "value": [
# {
# "id": "6112",
# "name": "客悦·智能客服"
# }
# ]
# },
# ]
# },
# ]
# }
]
}
db = DBPools()