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,
+3 -2
View File
@@ -13,8 +13,9 @@ type Order struct {
Subtotal float64 `gorm:"type:decimal(10,2);not null" json:"subtotal"`
ShippingFee float64 `gorm:"type:decimal(10,2);default:0" json:"shipping_fee"`
ServiceFee float64 `gorm:"type:decimal(10,2);default:0" json:"service_fee"`
Tax float64 `gorm:"type:decimal(10,2);default:0" json:"tax"`
ChannelFee float64 `gorm:"type:decimal(10,2);default:0" json:"channel_fee"` // 支付通道费
ChannelFee float64 `gorm:"type:decimal(10,2);default:0" json:"channel_fee"`
PackagingFee float64 `gorm:"type:decimal(10,2);default:0" json:"packaging_fee"`
InternationalFee float64 `gorm:"type:decimal(10,2);default:0" json:"international_fee"`
TotalAmount float64 `gorm:"type:decimal(10,2);not null" json:"total_amount"`
RefundAmount *float64 `gorm:"type:decimal(10,2)" json:"refund_amount"`
RefundStatus string `gorm:"size:20" json:"refund_status"`
+8 -4
View File
@@ -100,14 +100,18 @@
<span>服务费</span>
<span>¥{{ (currentOrder.service_fee || 0).toFixed(2) }}</span>
</div>
<div class="fee-item" v-if="currentOrder.tax > 0">
<span>税费</span>
<span>¥{{ (currentOrder.tax || 0).toFixed(2) }}</span>
</div>
<div class="fee-item" v-if="currentOrder.channel_fee > 0">
<span>通道费</span>
<span>¥{{ (currentOrder.channel_fee || 0).toFixed(2) }}</span>
</div>
<div class="fee-item" v-if="currentOrder.packaging_fee > 0">
<span>包装费</span>
<span>¥{{ (currentOrder.packaging_fee || 0).toFixed(2) }}</span>
</div>
<div class="fee-item" v-if="currentOrder.international_fee > 0">
<span>国际计算手续费</span>
<span>¥{{ (currentOrder.international_fee || 0).toFixed(2) }}</span>
</div>
<div class="fee-item total">
<span>合计</span>
<span class="total-amount">¥{{ (currentOrder.total_amount || 0).toFixed(2) }}</span>
+3 -1
View File
@@ -14,7 +14,9 @@
<el-descriptions-item label="商品小计">¥{{ order.subtotal || order.total_amount }}</el-descriptions-item>
<el-descriptions-item label="运费">¥{{ order.shipping_fee || 0 }}</el-descriptions-item>
<el-descriptions-item label="服务费">¥{{ order.service_fee || 0 }}</el-descriptions-item>
<el-descriptions-item label="费">¥{{ order.tax || 0 }}</el-descriptions-item>
<el-descriptions-item label="通道费">¥{{ order.channel_fee || 0 }}</el-descriptions-item>
<el-descriptions-item label="包装费">¥{{ order.packaging_fee || 0 }}</el-descriptions-item>
<el-descriptions-item label="国际计算手续费">¥{{ order.international_fee || 0 }}</el-descriptions-item>
<el-descriptions-item label="订单总额">
<span class="total-amount">¥{{ order.total_amount }}</span>
</el-descriptions-item>