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