From 606dc59fe50f10d2232f82083cd99e3c1e250e69 Mon Sep 17 00:00:00 2001 From: ping <1017253325@qq.com> Date: Thu, 6 Nov 2025 11:04:18 +0800 Subject: [PATCH] update --- b/ali/jiajie_get_token_redirect.dspy | 4 +- b/ali/jiajie_sync_user.dspy | 4 +- b/product/baidu_resource_query.dspy | 82 +++++++++++++++++++++++++ b/product/get_firstpage_net_detail.dspy | 4 +- 4 files changed, 88 insertions(+), 6 deletions(-) create mode 100644 b/product/baidu_resource_query.dspy diff --git a/b/ali/jiajie_get_token_redirect.dspy b/b/ali/jiajie_get_token_redirect.dspy index 47e0c75..1a3e680 100644 --- a/b/ali/jiajie_get_token_redirect.dspy +++ b/b/ali/jiajie_get_token_redirect.dspy @@ -4,7 +4,7 @@ async def jiajie_get_token_redirect(ns={}): :return: """ # target_host = 'https://testing.vstecscloud.shop' - target_host = 'https://aliyun.kaiyuancloud.cn' + target_host = 'https://aliyun.opencomputing.cn' if ns.get('userid'): userid = ns.get('userid') @@ -39,7 +39,7 @@ async def jiajie_get_token_redirect(ns={}): # 发送HTTP请求 url = "%s/api/blade-auth/oauth/token" % target_host - if 'kaiyuancloud' in target_host: + if 'opencomputing' in target_host: tenantid = '502332' else: tenantid = '024060' diff --git a/b/ali/jiajie_sync_user.dspy b/b/ali/jiajie_sync_user.dspy index 487ffc0..d0fd294 100644 --- a/b/ali/jiajie_sync_user.dspy +++ b/b/ali/jiajie_sync_user.dspy @@ -15,7 +15,7 @@ async def jiajie_sync_user(ns={}): 'msg': '用户还未登录' } # target_host = 'https://testing.vstecscloud.shop' - target_host = 'https://aliyun.kaiyuancloud.cn' + target_host = 'https://aliyun.opencomputing.cn' db = DBPools() async with db.sqlorContext('kboss') as sor: exits_user = await sor.R('weishijiajie_users', {'user_id': userid}) @@ -71,7 +71,7 @@ async def jiajie_sync_user(ns={}): else: return { '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) diff --git a/b/product/baidu_resource_query.dspy b/b/product/baidu_resource_query.dspy new file mode 100644 index 0000000..9343160 --- /dev/null +++ b/b/product/baidu_resource_query.dspy @@ -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 \ No newline at end of file diff --git a/b/product/get_firstpage_net_detail.dspy b/b/product/get_firstpage_net_detail.dspy index 6e759e3..d605fec 100644 --- a/b/product/get_firstpage_net_detail.dspy +++ b/b/product/get_firstpage_net_detail.dspy @@ -1113,7 +1113,7 @@ detailDataLJS = { { "title": "NVIDIA-4090-48G", "description": "High-performance GPU server with powerful computing capabilities, suitable for AI training, deep learning, etc.", - "price": "8000", + "price": "8800", "pre_price": None, "price_unit": "台/月", "discount": None, @@ -1207,7 +1207,7 @@ detailDataLJS = { { "title": "NVIDIA-4090", "description": "High-performance GPU server with powerful computing capabilities, suitable for AI training, deep learning, etc.", - "price": "6500", + "price": "7200", "pre_price": None, "price_unit": "台/月", "discount": None,