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,