From 6b9ac72cee7b2480f64873f23901ecdd33fe8f34 Mon Sep 17 00:00:00 2001 From: jingrow Date: Thu, 31 Jul 2025 03:13:37 +0800 Subject: [PATCH] =?UTF-8?q?update=5Fserver=5Frecord=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=9B=B4=E6=96=B0plan=5Fprice=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jcloud/api/aliyun_server_light.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/jcloud/api/aliyun_server_light.py b/jcloud/api/aliyun_server_light.py index 182d9b3..a487a75 100644 --- a/jcloud/api/aliyun_server_light.py +++ b/jcloud/api/aliyun_server_light.py @@ -1327,6 +1327,19 @@ def update_server_record(instance_ids): server.disk_size = resource_spec.get('disk_size') server.bandwidth = resource_spec.get('bandwidth') + # 更新套餐价格信息 + plan_id = instance_info.get('plan_id') + if plan_id: + # 获取套餐信息来计算价格 + plans_result = get_aliyun_plans(region_id) + if plans_result and plans_result.get('success') and plans_result.get('data', {}).get('plans'): + for plan in plans_result['data']['plans']: + if plan.get('plan_id') == plan_id: + # 使用调整后的价格(已经包含20%利润) + if 'origin_price' in plan and plan['origin_price'] is not None: + server.plan_price = float(plan['origin_price']) + break + # 保存更新 server.save(ignore_permissions=True) jingrow.db.commit() @@ -1339,7 +1352,8 @@ def update_server_record(instance_ids): "end_date": server.end_date, "status": server.status, "system": server.system, - "os_type": server.os_type + "os_type": server.os_type, + "plan_price": server.plan_price } }