From 95611089ed28373897b8a26c7a2b50d1297bc7b1 Mon Sep 17 00:00:00 2001 From: jingrow Date: Thu, 2 Oct 2025 17:13:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=9F=9F=E5=90=8D=E7=BB=AD?= =?UTF-8?q?=E8=B4=B9=E6=97=B6=E8=B4=AD=E4=B9=B0=E6=97=B6=E9=95=BF=E7=9A=84?= =?UTF-8?q?=E4=BB=B7=E6=A0=BC=E8=AE=A1=E7=AE=97=E6=BC=8F=E6=B4=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/JsiteDomainRenewalDialog.vue | 60 ++++++++++--------- jcloud/api/domain_west.py | 12 ++-- 2 files changed, 38 insertions(+), 34 deletions(-) diff --git a/dashboard/src2/components/JsiteDomainRenewalDialog.vue b/dashboard/src2/components/JsiteDomainRenewalDialog.vue index 720e122..c78bb45 100644 --- a/dashboard/src2/components/JsiteDomainRenewalDialog.vue +++ b/dashboard/src2/components/JsiteDomainRenewalDialog.vue @@ -17,7 +17,7 @@ @@ -254,6 +247,7 @@ export default { paymentQrCodeImage: null, checkInterval: null, domainPrice: null, + renewPrice: null, // 当前选择年限的总价 renewalPeriods: [ { years: 1, name: '1年', discount: 0 }, { years: 2, name: '2年', discount: 0 }, @@ -269,17 +263,15 @@ export default { return period ? period.discount : 0; }, totalAmount() { - if (!this.domainPrice) return ''; - - const basePrice = this.domainPrice * this.renewalPeriod; - const discount = basePrice * (this.discountPercentage / 100); - return (basePrice - discount).toFixed(2); + if (!this.renewPrice) return '0.00'; + const discount = this.renewPrice * (this.discountPercentage / 100); + return (this.renewPrice - discount).toFixed(2); }, isLoading() { return this.$resources.createRenewalOrder.loading; }, isPriceLoading() { - return this.$resources.getDomainPrice.loading; + return this.$resources.getRenewPrice.loading; } }, resources: { @@ -414,15 +406,16 @@ export default { } }; }, - getDomainPrice() { + getRenewPrice() { return { url: 'jcloud.api.domain_west.get_west_domain_renew_price', params: { - domain: this.domainDoc?.domain + domain: this.domainDoc?.domain, + year: 1 }, onSuccess(data) { if (data.data?.price) { - this.domainPrice = data.data.price; + this.renewPrice = data.data.price; } }, onError(error) { @@ -432,12 +425,25 @@ export default { } }, async mounted() { - // 获取域名续费价格 + // 获取当前选择年限的续费价格 if (this.domainDoc?.domain) { - await this.$resources.getDomainPrice.submit(); + await this.$resources.getRenewPrice.submit({ + domain: this.domainDoc.domain, + year: this.renewalPeriod + }); } }, methods: { + async onRenewalPeriodChange(years) { + this.renewalPeriod = years; + // 立即获取对应年限的价格 + if (this.domainDoc?.domain) { + await this.$resources.getRenewPrice.submit({ + domain: this.domainDoc.domain, + year: years + }); + } + }, cancel() { this.stopPaymentCheck(); this.show = false; diff --git a/jcloud/api/domain_west.py b/jcloud/api/domain_west.py index f159363..2737bb2 100644 --- a/jcloud/api/domain_west.py +++ b/jcloud/api/domain_west.py @@ -1540,14 +1540,12 @@ def create_domain_renew_order(**kwargs): # 计算续费金额 - 使用现有的价格获取函数保持统一 renewal_years = int(renewal_years) - # 调用现有的价格获取函数 - price_data = get_west_domain_renew_price(domain_pg.domain, 1) + # 根据实际续费年限直接获取价格 + price_data = get_west_domain_renew_price(domain_pg.domain, renewal_years) if price_data.get("data", {}).get("price"): - yearly_price = price_data["data"]["price"] + total_amount = price_data["data"]["price"] else: - yearly_price = domain_pg.price or 0 - - total_amount = yearly_price * renewal_years + return {"success": False, "message": "获取续费价格失败"} # 生成唯一订单号 order_id = f"{datetime.now().strftime('%Y%m%d%H%M%S%f')[:-3] + ''.join(random.choices('0123456789', k=6))}" @@ -1557,7 +1555,7 @@ def create_domain_renew_order(**kwargs): "domain": domain_pg.domain, "domain_name": domain, "renewal_years": renewal_years, - "yearly_price": yearly_price, + "total_price": total_amount, "domain_owner": domain_pg.domain_owner, # 续费域名所需参数 "year": renewal_years,