main #34

Merged
charles merged 191 commits from main into prod 2025-11-19 16:18:39 +08:00
4 changed files with 88 additions and 6 deletions
Showing only changes of commit 606dc59fe5 - Show all commits

View File

@ -4,7 +4,7 @@ async def jiajie_get_token_redirect(ns={}):
:return: :return:
""" """
# target_host = 'https://testing.vstecscloud.shop' # target_host = 'https://testing.vstecscloud.shop'
target_host = 'https://aliyun.kaiyuancloud.cn' target_host = 'https://aliyun.opencomputing.cn'
if ns.get('userid'): if ns.get('userid'):
userid = ns.get('userid') userid = ns.get('userid')
@ -39,7 +39,7 @@ async def jiajie_get_token_redirect(ns={}):
# 发送HTTP请求 # 发送HTTP请求
url = "%s/api/blade-auth/oauth/token" % target_host url = "%s/api/blade-auth/oauth/token" % target_host
if 'kaiyuancloud' in target_host: if 'opencomputing' in target_host:
tenantid = '502332' tenantid = '502332'
else: else:
tenantid = '024060' tenantid = '024060'

View File

@ -15,7 +15,7 @@ async def jiajie_sync_user(ns={}):
'msg': '用户还未登录' 'msg': '用户还未登录'
} }
# target_host = 'https://testing.vstecscloud.shop' # target_host = 'https://testing.vstecscloud.shop'
target_host = 'https://aliyun.kaiyuancloud.cn' target_host = 'https://aliyun.opencomputing.cn'
db = DBPools() db = DBPools()
async with db.sqlorContext('kboss') as sor: async with db.sqlorContext('kboss') as sor:
exits_user = await sor.R('weishijiajie_users', {'user_id': userid}) exits_user = await sor.R('weishijiajie_users', {'user_id': userid})
@ -71,7 +71,7 @@ async def jiajie_sync_user(ns={}):
else: else:
return { return {
'status': False, 'status': False,
'msg': f"请求失败,状态码: {result.get('code')},响应内容: {result.get('msg')}" 'msg': f"用户手机号:{phone}, 请求失败,状态码: {result.get('code')},响应内容: {result.get('msg')}"
} }
ret = await jiajie_sync_user(params_kw) ret = await jiajie_sync_user(params_kw)

View File

@ -0,0 +1,82 @@
async def baidu_resource_query(ns={}):
"""
用户资源查询
:param ns:
:return:
"""
if ns.get('userid'):
userid = ns.get('userid')
else:
userid = await get_user()
db = DBPools()
async with db.sqlorContext('kboss') as sor:
baiduids = await sor.R('baidu_users', {'user_id': userid})
if baiduids:
baiduid = baiduids[0]['baidu_id']
else:
return {
'status': False,
'msg': 'User not synchronized'
}
ns['queryAccountId'] = baiduid
ns['pageSize'] = 200
method = 'POST'
ns_format = '&'.join(['%s=%s' % (k, v) for k, v in ns.items()])
url = 'https://billing.baidubce.com/v1/resource/query?%s' % ns_format
header = {
"Host": "billing.baidubce.com"
}
header = await get_auth_header(method=method, url=url, header=header)
async with aiohttp_client.request(
method=method,
url=url,
headers=header,
json=ns) as res:
result = await res.json()
return {'1': result}
result_new = []
for i in result['result']:
if i.get('status') != 'STOPPED':
result_new.append(i)
result['result'] = result_new
return {
'status': True,
'msg': 'get resource success',
'data': result
}
async def resource_overview(ns={}):
if ns.get('userid'):
userid = ns.get('userid')
else:
userid = await get_user()
init_data = [
{'id': 1, 'name': '云服务器', 'count': 0, 'unit': '实例'},
{'id': 2, 'name': '私有网络', 'count': 0, 'unit': 'VPC'},
{'id': 3, 'name': '负载均衡', 'count': 0, 'unit': '负载均衡'},
{'id': 4, 'name': '弹性块存储', 'count': 0, 'unit': '云盘'},
{'id': 5, 'name': 'NAT网关', 'count': 0, 'unit': '实例'},
{'id': 6, 'name': 'VPN连接', 'count': 0, 'unit': 'VPN网关'},
]
baidu_resource_data = await baidu_resource_query({'userid': userid})
print(baidu_resource_data)
if baidu_resource_data and baidu_resource_data.get('data') and baidu_resource_data['data'].get('result'):
for baidu_resource in baidu_resource_data['data']['result']:
if baidu_resource.get('serviceType') == 'CDS' and baidu_resource['status'] == 'RUNNING':
init_data[3]['count'] += 1
elif baidu_resource.get('serviceType') == 'EIP' and baidu_resource['status'] == 'RUNNING':
init_data[1]['count'] += 1
elif (baidu_resource.get('serviceType') == 'BCC' or baidu_resource.get('serviceType') == 'LS') and baidu_resource['status'] == 'RUNNING':
init_data[0]['count'] += 1
return {
'status': True,
'msg': 'get resource success',
'data': init_data
}
ret = await baidu_resource_query(params_kw)
return ret

View File

@ -1113,7 +1113,7 @@ detailDataLJS = {
{ {
"title": "NVIDIA-4090-48G", "title": "NVIDIA-4090-48G",
"description": "High-performance GPU server with powerful computing capabilities, suitable for AI training, deep learning, etc.", "description": "High-performance GPU server with powerful computing capabilities, suitable for AI training, deep learning, etc.",
"price": "8000", "price": "8800",
"pre_price": None, "pre_price": None,
"price_unit": "台/月", "price_unit": "台/月",
"discount": None, "discount": None,
@ -1207,7 +1207,7 @@ detailDataLJS = {
{ {
"title": "NVIDIA-4090", "title": "NVIDIA-4090",
"description": "High-performance GPU server with powerful computing capabilities, suitable for AI training, deep learning, etc.", "description": "High-performance GPU server with powerful computing capabilities, suitable for AI training, deep learning, etc.",
"price": "6500", "price": "7200",
"pre_price": None, "pre_price": None,
"price_unit": "台/月", "price_unit": "台/月",
"discount": None, "discount": None,