Initial commit

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-15 13:57:10 +08:00
co-authored by Claude Opus 5
commit 8679200f41
1897 changed files with 257900 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
package common
import "math/rand"
// CanDeductByProbability 扣量指标的未完成度和今日时间进度递增 能扣量的概率递增 [0,100]
func CanDeductByProbability(probability float64) bool {
if probability <= 0 {
return false
}
if probability == 0 {
return false
}
if probability >= 1 {
return true //绝对扣量
}
canDeduct := probability > rand.Float64() //根据 probability 概率决定是否扣量
return canDeduct
}
// ConDeductionRatio 格式:%
func ConsumeDeductionRatio(optDividendRatio, dividendRatio float64) float64 {
if optDividendRatio == 0 {
return dividendRatio
}
return (1 - dividendRatio/optDividendRatio)
}