diff --git a/jcloud/api/domain_west.py b/jcloud/api/domain_west.py index 8be3604..89f1b71 100644 --- a/jcloud/api/domain_west.py +++ b/jcloud/api/domain_west.py @@ -402,6 +402,17 @@ class WestDomain: return self._make_request('/audit/', 'POST', body_params=encoded_data) +def format_date(date): + """格式化域名到期时间""" + if not date: + return None + + if isinstance(date, str): + return date + + return date.strftime('%Y-%m-%d') + + def get_west_client() -> WestDomain: """获取西部数码域名API客户端实例""" try: @@ -884,9 +895,16 @@ def create_domain_renew_order(**kwargs): if current_team.name != team: jingrow.throw("您没有权限为此域名创建续费订单") - # 计算续费金额 + # 计算续费金额 - 使用现有的价格获取函数保持统一 renewal_years = int(renewal_years) - yearly_price = domain_pg.price or 0 + + # 调用现有的价格获取函数 + price_data = get_west_domain_renew_price(domain_pg.domain, 1) + if price_data.get("data", {}).get("price"): + yearly_price = price_data["data"]["price"] + else: + yearly_price = domain_pg.price or 0 + total_amount = yearly_price * renewal_years # 生成唯一订单号 @@ -901,7 +919,7 @@ def create_domain_renew_order(**kwargs): "domain_owner": domain_pg.domain_owner, # 续费域名所需参数 "year": renewal_years, - "expire_date": None, + "expire_date": format_date(domain_pg.end_date), "client_price": None } @@ -1029,6 +1047,10 @@ def renew_domain_from_order(order_name): if not client: raise Exception("API客户端初始化失败") + # 验证域名到期时间 + if not biz_params.get("expire_date"): + raise Exception("无法获取域名到期时间") + result = client.renew_domain( domain_name, biz_params.get("year", renewal_years),