This commit is contained in:
aozhiwei 2024-09-03 16:31:17 +08:00
parent 612a01f38b
commit 7b345d134b

View File

@ -140,28 +140,47 @@ func (this *stackingCec) apply(idx int64, eventName string,
} else {
return false
}
dbErr, ds := f5.GetGoStyleDb().NewOrmSelect(
constant.BCNFT_DB,
"t_staking_cec",
[][]string{
{"account_address", strings.ToLower(p.Account)},
{"token_address", strings.ToLower(p.Token)},
},
)
if dbErr != nil {
return false
}
srcAmount := "0"
if ds.Next() {
if idx <= q5.ToInt64(ds.GetByName("last_apply_record_idx")) {
return true
{
dbErr, ds := f5.GetGoStyleDb().NewOrmSelect(
constant.BCNFT_DB,
"t_staking_cec",
[][]string{
{"account_address", strings.ToLower(p.Account)},
{"token_address", strings.ToLower(p.Token)},
},
)
if dbErr != nil {
return false
}
if ds.Next() {
if idx <= q5.ToInt64(ds.GetByName("last_apply_record_idx")) {
return true
}
srcAmount = ds.GetByName("amount")
}
srcAmount = ds.GetByName("amount")
}
bnNewAmount, ok := new(big.Int).SetString(srcAmount, 10)
if !ok {
return false
}
bnNewAmount.Add(bnNewAmount, bnAmount)
return true
{
nowTime := f5.GetApp().GetRealSeconds()
dbErr, _, _ := f5.GetGoStyleDb().NewUpsert(
constant.BCNFT_DB,
"t_staking_cec",
[][]string{
{"account_address", strings.ToLower(p.Account)},
{"token_address", strings.ToLower(p.Token)},
},
[][]string{},
[][]string{
{"account_address", strings.ToLower(p.Account)},
{"token_address", strings.ToLower(p.Token)},
{"createtime", q5.ToString(nowTime)},
{"modifytime", q5.ToString(nowTime)},
})
return dbErr == nil
}
}