feat(订单): 实现推荐奖励系统支持佣金和赠送天数两种模式
Build docker and publish / build (20.15.1) (push) Failing after 9m13s

重构推荐奖励处理逻辑,新增支持根据配置选择佣金奖励或赠送天数奖励
修改Discount相关字段类型为float64以支持小数折扣
添加GiftDays配置项控制赠送天数
新增FindActiveSubscribe方法查询用户有效订阅
This commit is contained in:
2025-10-17 06:01:29 -07:00
parent 7da63ade5c
commit bfbc675e1a
12 changed files with 139 additions and 27 deletions
+2 -2
View File
@@ -3,7 +3,7 @@ package order
import "github.com/perfect-panel/server/internal/types"
func getDiscount(discounts []types.SubscribeDiscount, inputMonths int64) float64 {
var finalDiscount int64 = 100
var finalDiscount float64 = 1.0
for _, discount := range discounts {
if inputMonths >= discount.Quantity && discount.Discount < finalDiscount {
@@ -11,5 +11,5 @@ func getDiscount(discounts []types.SubscribeDiscount, inputMonths int64) float64
}
}
return float64(finalDiscount) / float64(100)
return finalDiscount
}
+2 -2
View File
@@ -7,14 +7,14 @@ import (
)
func getDiscount(discounts []types.SubscribeDiscount, inputMonths int64) float64 {
var finalDiscount int64 = 100
var finalDiscount float64 = 1.0
for _, discount := range discounts {
if inputMonths >= discount.Quantity && discount.Discount < finalDiscount {
finalDiscount = discount.Discount
}
}
return float64(finalDiscount) / float64(100)
return finalDiscount
}
func calculateCoupon(amount int64, couponInfo *coupon.Coupon) int64 {