From 3934ce4542e6de43a399e8dd9fd237857bfe8faa Mon Sep 17 00:00:00 2001 From: wangqifan Date: Wed, 31 Dec 2025 12:34:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8C=89=E5=B9=B4=E4=BC=98?= =?UTF-8?q?=E6=83=A0=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/.env | 4 +- frontend/src/views/AwsSearchDiscount.vue | 132 ++++++++++++++++++----- 2 files changed, 107 insertions(+), 29 deletions(-) diff --git a/backend/.env b/backend/.env index 8c66992..56177c6 100644 --- a/backend/.env +++ b/backend/.env @@ -3,7 +3,7 @@ AWS_SECRET_ACCESS_KEY=BQjaaHNm5skCN/3k3r/uNdEG9xb49are+hv5fajK AWS_DEFAULT_REGION=us-east-1 # MySQL数据库配置 -MYSQL_HOST=23.140.4.154 +MYSQL_HOST=163.123.183.106 MYSQL_USER=aws_price -MYSQL_PASSWORD=123123 +MYSQL_PASSWORD=YCwjLmHM5dZtwHEw MYSQL_DATABASE=aws_price \ No newline at end of file diff --git a/frontend/src/views/AwsSearchDiscount.vue b/frontend/src/views/AwsSearchDiscount.vue index 8d57b36..ecab016 100644 --- a/frontend/src/views/AwsSearchDiscount.vue +++ b/frontend/src/views/AwsSearchDiscount.vue @@ -361,25 +361,41 @@ @@ -401,8 +417,8 @@
说明事项:
1. 以上价格仅包服务器和磁盘的费用, 以上价格仅包服务器和磁盘的费用, 公共带宽流量按官网价格 均价$0.12USD/GB
-
2. 月付按官网价 {{ formatDiscount(form.monthly_discount) }} 折
-
3. 年付按官网价 {{ formatDiscount(form.yearly_discount) }} 折
+
2. 月付(仅实例部分)按官网价 {{ formatDiscount(form.monthly_discount) }} 折,磁盘不参与优惠
+
3. 年付(仅实例部分)按官网价 {{ formatDiscount(form.yearly_discount) }} 折,磁盘不参与优惠
@@ -605,10 +621,32 @@ // 创建数据行 const dataRows = this.comparisonList.map(instance => { - const officialMonthlyPrice = instance.total_monthly_price - const discountedMonthlyPrice = officialMonthlyPrice * this.form.monthly_discount - const officialYearlyPrice = officialMonthlyPrice * 12 - const discountedYearlyPrice = officialYearlyPrice * this.form.yearly_discount + const officialMonthlyPrice = this.getOfficialMonthlyPrice(instance) + const officialYearlyPrice = this.getOfficialYearlyPrice(instance) + const discountedMonthlyPrice = this.getDiscountedMonthlyPrice(instance) + const discountedYearlyPrice = this.getDiscountedYearlyPrice(instance) + const instanceMonthlyPrice = Number(instance.monthly_price) || 0 + const diskMonthlyPrice = Number(instance.disk_monthly_price) || 0 + const officialMonthlyDetail = [ + `实例: $${instanceMonthlyPrice.toFixed(2)}`, + `磁盘: $${diskMonthlyPrice.toFixed(2)}`, + `共计: $${officialMonthlyPrice.toFixed(2)}` + ].join('\n') + const discountedMonthlyDetail = [ + `实例: $${(instanceMonthlyPrice * Number(this.form.monthly_discount || 0)).toFixed(2)}`, + `磁盘: $${diskMonthlyPrice.toFixed(2)}`, + `共计: $${discountedMonthlyPrice.toFixed(2)}` + ].join('\n') + const officialYearlyDetail = [ + `实例: $${(instanceMonthlyPrice * 12).toFixed(2)}`, + `磁盘: $${(diskMonthlyPrice * 12).toFixed(2)}`, + `共计: $${officialYearlyPrice.toFixed(2)}` + ].join('\n') + const discountedYearlyDetail = [ + `实例: $${(instanceMonthlyPrice * 12 * Number(this.form.yearly_discount || 0)).toFixed(2)}`, + `磁盘: $${(diskMonthlyPrice * 12).toFixed(2)}`, + `共计: $${discountedYearlyPrice.toFixed(2)}` + ].join('\n') return [ 'EC2', @@ -616,10 +654,10 @@ `${instance.disk_gb}G GP3`, this.formatOS(instance.operating_system), this.getRegionName(instance.region), - officialMonthlyPrice.toFixed(2), - discountedMonthlyPrice.toFixed(2), - officialYearlyPrice.toFixed(2), - discountedYearlyPrice.toFixed(2) + officialMonthlyDetail, + discountedMonthlyDetail, + officialYearlyDetail, + discountedYearlyDetail ] }) @@ -628,8 +666,8 @@ emptyRow, ['说明事项:'], ['1. 以上价格仅包服务器和磁盘的费用, 以上价格仅包服务器和磁盘的费用, 公共带宽流量按官网价格 均价$0.12USD/GB'], - [`2. 月付按官网价 ${this.formatDiscount(this.form.monthly_discount)} 折`], - [`3. 年付按官网价 ${this.formatDiscount(this.form.yearly_discount)} 折`] + [`2. 月付(仅实例部分)按官网价 ${this.formatDiscount(this.form.monthly_discount)} 折,磁盘不参与优惠`], + [`3. 年付(仅实例部分)按官网价 ${this.formatDiscount(this.form.yearly_discount)} 折,磁盘不参与优惠`] ] // 合并所有行 @@ -656,6 +694,9 @@ const rowHeights = Array(allRows.length).fill({ hpt: 25 }) rowHeights[0] = { hpt: 35 } // 标题行 rowHeights[4] = { hpt: 30 } // 表头行 + for (let i = 0; i < dataRows.length; i++) { + rowHeights[4 + 1 + i] = { hpt: 55 } + } ws['!rows'] = rowHeights // 设置单元格合并 @@ -736,12 +777,21 @@ ws[cellRef].s.alignment = { horizontal: 'center', vertical: 'center' } } } + + // 说明事项行左对齐并自动换行 + for (let r = noteStartRow; r < noteStartRow + 5; r++) { + for (let c = 0; c < 9; c++) { + const cellRef = XLSX.utils.encode_cell({ r, c }) + if (!ws[cellRef]) ws[cellRef] = { v: '', t: 's' } + if (!ws[cellRef].s) ws[cellRef].s = {} + ws[cellRef].s.alignment = { horizontal: 'left', vertical: 'center', wrapText: true } + } + } // 设置价格列样式 const priceColsStyle = { - numFmt: '0.00', font: { color: { rgb: '1F7B69' } }, - alignment: { horizontal: 'center', vertical: 'center' }, + alignment: { horizontal: 'left', vertical: 'center', wrapText: true }, border: { top: { style: 'thin' }, bottom: { style: 'thin' }, @@ -808,6 +858,26 @@ if (os === 'Windows') return 'Windows' return os }, + getOfficialMonthlyPrice(instance) { + const instancePrice = Number(instance.monthly_price) || 0 + const diskPrice = Number(instance.disk_monthly_price) || 0 + return instancePrice + diskPrice + }, + getOfficialYearlyPrice(instance) { + return this.getOfficialMonthlyPrice(instance) * 12 + }, + getDiscountedMonthlyPrice(instance) { + const instancePrice = Number(instance.monthly_price) || 0 + const diskPrice = Number(instance.disk_monthly_price) || 0 + const discount = Number(this.form.monthly_discount) || 0 + return instancePrice * discount + diskPrice + }, + getDiscountedYearlyPrice(instance) { + const instancePrice = Number(instance.monthly_price) || 0 + const diskPrice = Number(instance.disk_monthly_price) || 0 + const discount = Number(this.form.yearly_discount) || 0 + return instancePrice * 12 * discount + diskPrice * 12 + }, // 计算打折后的价格 calculateDiscountedPrice(originalPrice, discount) { return originalPrice * discount; @@ -956,14 +1026,22 @@ font-weight: 500; } - .price-value.highlight { - color: #2ecc71; - font-weight: 700; - } - - .no-results { - padding: 40px 0; - } +.price-value.highlight { + color: #2ecc71; + font-weight: 700; +} + +.price-breakdown-text { + display: flex; + flex-direction: column; + gap: 2px; + font-size: 12px; + line-height: 1.3; +} + +.no-results { + padding: 40px 0; +} .selected-instance { margin-top: 40px; @@ -1180,4 +1258,4 @@ align-items: center; margin-top: 20px; } - \ No newline at end of file +