Compare commits

..

3 Commits

Author SHA1 Message Date
6b902f68f1 Merge branch 'main' of http://1.117.67.95:3000/team/tyapi-server 2026-01-14 16:00:32 +08:00
745fbc05d5 f 2026-01-14 16:00:27 +08:00
6618e35869 -f 2026-01-14 15:59:15 +08:00
3 changed files with 75 additions and 65 deletions

View File

@@ -571,6 +571,7 @@ func (s *ComponentReportOrderService) createFreeOrder(
ProductName: product.Name,
OrderID: &createdPurchaseOrder.ID, // 关联购买订单ID
OrderNumber: &createdPurchaseOrder.OrderNo, // 外部订单号
DownloadPrice: finalPrice, // 设置下载价格
ExpiresAt: calculateExpiryTime(), // 30天后过期
}
@@ -785,6 +786,7 @@ func (s *ComponentReportOrderService) DownloadFile(ctx context.Context, orderID
ProductName: product.Name,
OrderID: &purchaseOrder.ID,
OrderNumber: &purchaseOrder.OrderNo,
DownloadPrice: purchaseOrder.Amount, // 设置下载价格(从订单获取)
ExpiresAt: calculateExpiryTime(),
}
@@ -924,6 +926,7 @@ func (s *ComponentReportOrderService) createDownloadRecordForPaidOrder(ctx conte
ProductName: product.Name,
OrderID: &purchaseOrder.ID,
OrderNumber: &purchaseOrder.OrderNo,
DownloadPrice: purchaseOrder.Amount, // 设置下载价格(从订单获取)
ExpiresAt: calculateExpiryTime(), // 30天后过期
}

View File

@@ -4,6 +4,7 @@ import (
"time"
"github.com/google/uuid"
"github.com/shopspring/decimal"
"gorm.io/gorm"
)
@@ -22,6 +23,9 @@ type ComponentReportDownload struct {
SubProductIDs string `gorm:"type:text" comment:"子产品ID列表JSON数组组合包使用"`
SubProductCodes string `gorm:"type:text" comment:"子产品编号列表JSON数组"`
// 价格相关字段
DownloadPrice decimal.Decimal `gorm:"type:decimal(10,2);not null" comment:"实际支付价格"`
// 下载相关信息
FilePath *string `gorm:"type:varchar(500)" comment:"生成的ZIP文件路径用于二次下载"`
FileHash *string `gorm:"type:varchar(64)" comment:"文件哈希值(用于缓存验证)"`

View File

@@ -989,6 +989,7 @@ func (h *ComponentReportHandler) CreatePaymentOrder(c *gin.Context) {
// 关联购买订单ID
OrderID: &createdPurchaseOrder.ID,
OrderNumber: &outTradeNo,
DownloadPrice: finalPrice, // 设置下载价格
}
// 记录创建前的详细信息用于调试
@@ -1390,6 +1391,7 @@ func (h *ComponentReportHandler) createDownloadRecordIfEligible(ctx context.Cont
ProductName: product.Name,
OrderID: &validOrder.ID, // 添加OrderID字段
OrderNumber: &validOrder.OrderNo, // 使用OrderNumber字段
DownloadPrice: validOrder.Amount, // 设置下载价格(从订单获取)
ExpiresAt: calculateExpiryTime(), // 从创建日起30天
}
@@ -1568,6 +1570,7 @@ func (h *ComponentReportHandler) createDownloadRecordForPaidOrder(ctx context.Co
ProductName: order.ProductName,
OrderID: &order.ID,
OrderNumber: &order.OrderNo,
DownloadPrice: order.Amount, // 设置下载价格(从订单获取)
ExpiresAt: calculateExpiryTime(),
}