From 1e2728b0a91181292ccdce6a432e93fb5f6f0ac7 Mon Sep 17 00:00:00 2001 From: jingrow Date: Sat, 2 Aug 2025 23:29:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=8E=B7=E5=8F=96=E5=9F=9F?= =?UTF-8?q?=E5=90=8D=E7=BB=AD=E8=B4=B9=E4=BB=B7=E6=A0=BC=E7=9A=84api?= =?UTF-8?q?=E7=AB=AF=E7=82=B9=E5=8F=8A=E5=AE=9E=E7=8E=B0=E5=9F=9F=E5=90=8D?= =?UTF-8?q?=E7=BB=AD=E8=B4=B9=E7=9A=84=E5=AF=B9=E8=AF=9D=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/JsiteDomainRenewalDialog.vue | 635 +++++++++++++----- jcloud/api/domain_west.py | 71 +- 2 files changed, 542 insertions(+), 164 deletions(-) diff --git a/dashboard/src2/components/JsiteDomainRenewalDialog.vue b/dashboard/src2/components/JsiteDomainRenewalDialog.vue index 9d10ea1..720e122 100644 --- a/dashboard/src2/components/JsiteDomainRenewalDialog.vue +++ b/dashboard/src2/components/JsiteDomainRenewalDialog.vue @@ -1,110 +1,230 @@ \ No newline at end of file + + + \ No newline at end of file diff --git a/jcloud/api/domain_west.py b/jcloud/api/domain_west.py index f17ecbf..8be3604 100644 --- a/jcloud/api/domain_west.py +++ b/jcloud/api/domain_west.py @@ -124,6 +124,21 @@ class WestDomain: } return self._make_request('/info/?act=getprice', 'POST', body_params=body_params) + def get_domain_renew_price(self, domain: str, year: int = 1) -> Dict[str, Any]: + """ + 获取域名续费价格 + + Args: + domain: 域名 + year: 续费年限 + """ + body_params = { + 'act': 'getrenprice', + 'domain': domain, + 'year': year, + } + return self._make_request('/domain/', 'POST', body_params=body_params) + def query_domain(self, domain: str, suffix: str = '.com') -> Dict[str, Any]: """ 域名查询 @@ -480,9 +495,19 @@ def get_west_domain_price(domain: str, year: int = 1): return {"status": "error", "message": "API查询失败"} data = response.get("data", {}) + original_price = data.get("buyprice", 0) + + # 统一增加10%的利润,参考aliyun_server_light.py的方法 + if original_price and original_price > 0: + # 确保10%利润率且价格为整数 + adjusted_price = int(original_price / (1 - 0.1)) + else: + adjusted_price = original_price + return { "data": { - "price": data.get("buyprice", 0), + "price": adjusted_price, + "original_price": original_price, # 保留原价用于参考 "domain": domain, "year": year } @@ -493,6 +518,50 @@ def get_west_domain_price(domain: str, year: int = 1): return {"status": "error", "message": "域名价格查询响应解析失败"} +@jingrow.whitelist() +def get_west_domain_renew_price(domain: str, year: int = 1): + """获取域名续费价格""" + client = get_west_client() + if not client: + return {"status": "error", "message": "API客户端初始化失败"} + + if not domain: + return {"status": "error", "message": "缺少域名参数"} + + response = client.get_domain_renew_price(domain, year) + + if response.get("status") == "error": + return response + + try: + # 直接检查响应格式 + if response.get("result") != 200: + return {"status": "error", "message": "API查询失败"} + + data = response.get("data", {}) + original_price = data.get("price", 0) + + # 统一增加10%的利润,参考aliyun_server_light.py的方法 + if original_price and original_price > 0: + # 确保10%利润率且价格为整数 + adjusted_price = int(original_price / (1 - 0.1)) + else: + adjusted_price = original_price + + return { + "data": { + "price": adjusted_price, + "domain": domain, + "year": year, + "ispremium": data.get("ispremium", "n") + } + } + + except Exception as e: + jingrow.log_error("域名续费价格查询响应解析失败", error=str(e)) + return {"status": "error", "message": "域名续费价格查询响应解析失败"} + + @jingrow.whitelist() def west_domain_register(domain: str, regyear: int = 1, dns_host1: str = "ns1.myhostadmin.net", dns_host2: str = "ns2.myhostadmin.net", c_sysid: str = None,