feat: update order model with packaging_fee and international_fee, remove tax
Build and Push Docker Image / build-and-push (push) Successful in 1m6s
Build and Push Docker Image / deploy (push) Successful in 8s

This commit is contained in:
nuyue
2026-07-16 18:17:29 +08:00
parent 74420e687b
commit 13768f5f5b
4 changed files with 25 additions and 14 deletions
+11 -7
View File
@@ -378,22 +378,25 @@ func (h *OrderHandler) Create(c *gin.Context) {
}
// 获取其他费率
var serviceFeeRate, taxRate, channelFeeRate float64
var serviceFeeRate, channelFeeRate, packagingFee, internationalFeeRate float64
var setting models.SystemSetting
if err := utils.DB.Where("`key` = ?", "service_fee_rate").First(&setting).Error; err == nil {
serviceFeeRate, _ = strconv.ParseFloat(setting.Value, 64)
}
if err := utils.DB.Where("`key` = ?", "tax_rate").First(&setting).Error; err == nil {
taxRate, _ = strconv.ParseFloat(setting.Value, 64)
}
if err := utils.DB.Where("`key` = ?", "payment_channel_fee_rate").First(&setting).Error; err == nil {
channelFeeRate, _ = strconv.ParseFloat(setting.Value, 64)
}
if err := utils.DB.Where("`key` = ?", "packaging_fee").First(&setting).Error; err == nil {
packagingFee, _ = strconv.ParseFloat(setting.Value, 64)
}
if err := utils.DB.Where("`key` = ?", "international_fee_rate").First(&setting).Error; err == nil {
internationalFeeRate, _ = strconv.ParseFloat(setting.Value, 64)
}
serviceFee := subtotal * serviceFeeRate / 100
tax := subtotal * taxRate / 100
channelFee := subtotal * channelFeeRate / 100
totalAmount := subtotal + shippingFee + serviceFee + tax + channelFee
internationalFee := subtotal * internationalFeeRate / 100
totalAmount := subtotal + shippingFee + serviceFee + channelFee + packagingFee + internationalFee
order := models.Order{
UserID: userID,
@@ -401,8 +404,9 @@ func (h *OrderHandler) Create(c *gin.Context) {
Subtotal: subtotal,
ShippingFee: shippingFee,
ServiceFee: serviceFee,
Tax: tax,
ChannelFee: channelFee,
PackagingFee: packagingFee,
InternationalFee: internationalFee,
TotalAmount: totalAmount,
Status: models.OrderStatusPendingPayment,
ShippingAddressID: &req.ShippingAddressID,