调整
This commit is contained in:
parent
40000afc7b
commit
4e934ad899
@ -9,19 +9,23 @@ import (
|
||||
)
|
||||
|
||||
type accountContribution struct {
|
||||
history float64
|
||||
loadhistory bool
|
||||
contribution float64
|
||||
rechargeContri float64
|
||||
gcTime int64
|
||||
loweremail string
|
||||
accountid string
|
||||
history float64
|
||||
loadhistory bool
|
||||
gamecontribution float64
|
||||
rechargeContri float64
|
||||
gcTime int64
|
||||
loweremail string
|
||||
accountid string
|
||||
}
|
||||
|
||||
func (ac *accountContribution) sum() float64 {
|
||||
return ac.history + ac.gamecontribution + ac.rechargeContri
|
||||
}
|
||||
|
||||
type contribution struct {
|
||||
historyContribution float64
|
||||
rechargeContribution float64
|
||||
globalContribution float64
|
||||
gameContribution float64
|
||||
gcTime int64
|
||||
|
||||
accountContributionlist q5.ConcurrentMap[string, *accountContribution]
|
||||
@ -38,10 +42,14 @@ func (this *contribution) unInit() {
|
||||
|
||||
}
|
||||
|
||||
func (c *contribution) sum() float64 {
|
||||
return c.historyContribution + c.rechargeContribution + c.gameContribution
|
||||
}
|
||||
|
||||
func (this *contribution) GetEmailContributionAccountid(email string) (float64, string, error) {
|
||||
info, exist := this.emailContributionlist.Load(email)
|
||||
if exist {
|
||||
return (*info).contribution, (*info).accountid, nil
|
||||
return (*info).sum(), (*info).accountid, nil
|
||||
}
|
||||
|
||||
accountid := ""
|
||||
@ -88,7 +96,7 @@ func (this *contribution) GetAddressContribution(accountAddress string, onlyrech
|
||||
accinfo, exist := this.accountContributionlist.Load(accountAddress)
|
||||
var beforcontribution float64 = 0
|
||||
if exist {
|
||||
beforcontribution = (*accinfo).contribution
|
||||
beforcontribution = (*accinfo).sum()
|
||||
}
|
||||
|
||||
if nowseconds := f5.GetApp().GetRealSeconds(); !exist || (*accinfo).gcTime+60 < nowseconds {
|
||||
@ -97,7 +105,7 @@ func (this *contribution) GetAddressContribution(accountAddress string, onlyrech
|
||||
this.accountContributionlist.Store(accountAddress, info)
|
||||
accinfo = &info
|
||||
}
|
||||
beforcontribution = (*accinfo).contribution
|
||||
beforcontribution = (*accinfo).sum()
|
||||
|
||||
if (*accinfo).loweremail == "" {
|
||||
sql := `SELECT account_id FROM t_user WHERE idx > 0 AND address = ?`
|
||||
@ -131,6 +139,10 @@ func (this *contribution) GetAddressContribution(accountAddress string, onlyrech
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
if (*accinfo).loweremail != "" {
|
||||
this.emailContributionlist.Store((*accinfo).loweremail, *accinfo)
|
||||
}
|
||||
}
|
||||
|
||||
if !(*accinfo).loadhistory {
|
||||
@ -168,7 +180,6 @@ func (this *contribution) GetAddressContribution(accountAddress string, onlyrech
|
||||
(*accinfo).loadhistory = true
|
||||
}
|
||||
|
||||
(*accinfo).contribution = 0
|
||||
if (*accinfo).accountid != "" {
|
||||
sql := `SELECT contribution FROM t_contribution WHERE idx > 0 AND account_id = ?`
|
||||
f5.GetGoStyleDb().RawQuery(
|
||||
@ -181,7 +192,7 @@ func (this *contribution) GetAddressContribution(accountAddress string, onlyrech
|
||||
}
|
||||
|
||||
if ds.Next() {
|
||||
(*accinfo).contribution, _ = q5.ToFloat64Ex(ds.GetByIndex(0))
|
||||
(*accinfo).gamecontribution, _ = q5.ToFloat64Ex(ds.GetByIndex(0))
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -210,15 +221,10 @@ func (this *contribution) GetAddressContribution(accountAddress string, onlyrech
|
||||
})
|
||||
}
|
||||
|
||||
(*accinfo).contribution += (*accinfo).rechargeContri
|
||||
(*accinfo).contribution += (*accinfo).history
|
||||
(*accinfo).gcTime = nowseconds
|
||||
if (*accinfo).loweremail != "" {
|
||||
this.emailContributionlist.Store((*accinfo).loweremail, *accinfo)
|
||||
}
|
||||
}
|
||||
|
||||
if beforcontribution > 0.000001 && (*accinfo).contribution > beforcontribution+0.000001 {
|
||||
if beforcontribution > 0.000001 && (*accinfo).sum() > beforcontribution+0.000001 {
|
||||
this.GetGlobalContribution(true)
|
||||
}
|
||||
|
||||
@ -226,7 +232,7 @@ func (this *contribution) GetAddressContribution(accountAddress string, onlyrech
|
||||
return (*accinfo).rechargeContri, nil
|
||||
}
|
||||
|
||||
return (*accinfo).contribution, nil
|
||||
return (*accinfo).sum(), nil
|
||||
}
|
||||
|
||||
func (this *contribution) GetGlobalContribution(instant bool) (float64, error) {
|
||||
@ -264,7 +270,6 @@ func (this *contribution) GetGlobalContribution(instant bool) (float64, error) {
|
||||
}
|
||||
|
||||
if nowseconds := f5.GetApp().GetRealSeconds(); nowseconds > this.gcTime+60 || instant {
|
||||
this.globalContribution = 0
|
||||
sql := `SELECT SUM(contribution) FROM t_contribution WHERE idx > 0`
|
||||
f5.GetGoStyleDb().RawQuery(
|
||||
constant.GAME_DB,
|
||||
@ -276,7 +281,7 @@ func (this *contribution) GetGlobalContribution(instant bool) (float64, error) {
|
||||
}
|
||||
|
||||
if ds.Next() {
|
||||
this.globalContribution, _ = q5.ToFloat64Ex(ds.GetByIndex(0))
|
||||
this.gameContribution, _ = q5.ToFloat64Ex(ds.GetByIndex(0))
|
||||
}
|
||||
})
|
||||
sql = `SELECT SUM(return_contribution) FROM t_recharge_return_contribution WHERE idx > 0`
|
||||
@ -294,12 +299,10 @@ func (this *contribution) GetGlobalContribution(instant bool) (float64, error) {
|
||||
}
|
||||
})
|
||||
|
||||
this.globalContribution += this.rechargeContribution
|
||||
this.globalContribution += this.historyContribution
|
||||
this.gcTime = nowseconds
|
||||
}
|
||||
|
||||
return this.globalContribution, nil
|
||||
return this.sum(), nil
|
||||
}
|
||||
|
||||
func (this *contribution) checkContributionList() {
|
||||
@ -326,9 +329,10 @@ func (this *contribution) checkContributionList() {
|
||||
}
|
||||
|
||||
f5.GetSysLog().Info("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
|
||||
f5.GetSysLog().Info("contribution cache total:%.2f, recharge:%.2f, history:%.2f",
|
||||
this.globalContribution,
|
||||
f5.GetSysLog().Info("contribution cache total:%.2f, recharge:%.2f, ingame:%.2f, history:%.2f",
|
||||
this.sum(),
|
||||
this.rechargeContribution,
|
||||
this.gameContribution,
|
||||
this.historyContribution)
|
||||
f5.GetSysLog().Info(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
|
||||
time.Sleep((time.Second * 60))
|
||||
|
Loading…
x
Reference in New Issue
Block a user