MCPcopy Create free account
hub / github.com/TruthHun/BookStack / InitCreditRule

Function InitCreditRule

models/credit.go:45–71  ·  view source on GitHub ↗

InitCreditRule 如果还没存在积分规则,则初始化积分规则

()

Source from the content-addressed store, hash-verified

43
44// InitCreditRule 如果还没存在积分规则,则初始化积分规则
45func InitCreditRule() {
46 // 积分榜单增加 壕榜(积分排行)
47 // 一个勤奋的用户,每个月大概能获取到的奖励金额:0.005x30(签到, 0.15) + 0.005(注册,0.005) + 0.008x30(邀请注册,0.24) + 0.032x30(日榜上榜, 0.96) + 0.064x4(周榜上榜0.26) + 1.0(月榜前十) = 3
48 rules := []CreditRule{
49 {Identify: "sign", Title: "签到奖励", Intro: "用户每天签到的奖励", CycleType: cycleTypeDay, RewardTimes: 1, Score: 5}, // 每天签到奖励, 0.005 元
50 {Identify: "reg", Title: "注册奖励", Intro: "新用户注册奖励", CycleType: cycleTypeOnce, RewardTimes: 1, Score: 8}, // 注册奖励
51 {Identify: "read", Title: "阅读奖励", Intro: "重在参与,学习有奖!用户每天阅读时长超过5分钟的奖励", CycleType: cycleTypeDay, RewardTimes: 1, Score: 5}, // 重在参与,阅读有奖。 0.005 元
52 {Identify: "invite", Title: "邀请注册", Intro: "邀请别人注册,获得奖励", CycleType: cycleTypeDay, RewardTimes: 1, Score: 8}, // 0.008 元
53 {Identify: "rank_day", Title: "阅读日榜前五十奖励", Intro: "用户阅读日榜上榜(前50)奖励", CycleType: cycleTypeDay, RewardTimes: 1, Score: 32}, // 0.032 x 50 x 30 = 48 / 月
54 {Identify: "rank_week", Title: "阅读周榜前五十奖励", Intro: "用户阅读周榜上榜(前50)奖励", CycleType: cycleTypeWeek, RewardTimes: 1, Score: 64}, // 0.128 x 50 x 4 = 12.8 / 月
55 {Identify: "rank_mon_top50", Title: "阅读月榜前五十奖励", Intro: "用户阅读月榜前五十奖励", CycleType: cycleTypeMonth, RewardTimes: 1, Score: 256}, // 0.256 x 30 = 7.68 / 月
56 {Identify: "rank_mon_top20", Title: "阅读月榜前二十奖励", Intro: "用户阅读月榜前二十奖励", CycleType: cycleTypeMonth, RewardTimes: 1, Score: 512}, // 0.5 x 10 = 5 / 月
57 {Identify: "rank_mon_top10", Title: "阅读月榜前十奖励", Intro: "用户阅读月榜前十奖励", CycleType: cycleTypeMonth, RewardTimes: 1, Score: 1024}, // 1.0 x 10 = 10 / 月
58
59 {Identify: "donate", Title: "打赏书籍", Intro: "用户打赏书籍消费", CycleType: cycleTypeDay, RewardTimes: 10, Score: 0}, // score 为0,表示隐藏这条积分记录
60 {Identify: "exchange", Title: "积分兑换", Intro: "用户积分兑换奖品", CycleType: cycleTypeMonth, RewardTimes: 20, Score: -10240}, // score 为0,表示隐藏这条积分记录
61
62 {Identify: "submit", Title: "收录奖励", Intro: "提交未被收录的书籍获得的奖励", CycleType: cycleTypeDay, RewardTimes: 10, Score: 5}, // 收录奖励, 0.005 元
63 {Identify: "charge", Title: "充值奖励", Intro: "用户充值", CycleType: cycleTypeDay, RewardTimes: 0, Score: 0}, // 手工充值 0.005 元
64
65 {Identify: "market_value", Title: "网站积分市值", Intro: "整站所产生的积分", CycleType: cycleTypeOnce, RewardTimes: 0, Score: 0}, // 网站积分总市值 0.005 元
66 }
67 o := orm.NewOrm()
68 for _, rule := range rules {
69 o.Insert(&rule)
70 }
71}
72
73func NewCreditRule() *CreditRule {
74 return &CreditRule{}

Callers

nothing calls this directly

Calls 1

InsertMethod · 0.45

Tested by

no test coverage detected