This commit is contained in:
aozhiwei 2024-07-27 09:31:22 +08:00
parent 79a8a1d676
commit d00f10c2d0

View File

@ -1,6 +1,10 @@
package task
import (
"q5"
"f5"
"main/constant"
"fmt"
"mt"
"jccommon"
)
@ -8,14 +12,50 @@ import (
type recharge struct {
}
func (this* recharge) init() {
func (this *recharge) init() {
mt.Table.Contract.Traverse(func (ele *mt.Contract) bool {
if ele.GetName() == jccommon.CONTRACT_NAME_GameItemMall {
//go this.processLockAndUnLockEvent(ele.GetNetId(), ele.GetAddress())
//go this.process(ele.GetNetId(), ele.GetAddress())
}
return true
})
}
func (this* recharge) unInit() {
func (this *recharge) unInit() {
}
func (this *recharge) process(netId int32, contractAddress string) {
key := fmt.Sprintf("recharge.lastIdx.%d.%s", netId, contractAddress)
if dbLastIdxStr, err := jccommon.GetDbParam(constant.BCEVENT_DB, key); err == nil {
f5.GetGoStyleDb().IncrementLoad(
constant.BCEVENT_DB,
"recharge." + q5.ToString(netId) + "." + contractAddress,
"t_blockchain_event",
q5.ToInt64(dbLastIdxStr),
func (lastIdx int64, maxIdx int64) (string, []string) {
sql := fmt.Sprintf(`
SELECT * FROM t_blockchain_event
WHERE idx > %d AND idx <= %d AND net_id = %d AND contract_address = ? AND event_name IN (?, ?)
ORDER BY idx LIMIT 1000
`,
lastIdx,
maxIdx,
netId)
params := []string{
contractAddress,
"ItemSoldOut",
}
return sql, params
},
func (newLastIdx int64) {
jccommon.SaveDbParam(constant.BCEVENT_DB, key, q5.ToString(newLastIdx))
},
this.saveToDb)
} else {
panic(fmt.Sprintf("recharge.process getDBParam error %s", err))
}
}
func (this *recharge) saveToDb(ds *f5.DataSet) bool {
return true
}