1
This commit is contained in:
parent
394aea3fe6
commit
446c0f14cc
@ -6,16 +6,25 @@ import (
|
||||
"main/constant"
|
||||
"fmt"
|
||||
"mt"
|
||||
"strings"
|
||||
"jccommon"
|
||||
)
|
||||
|
||||
type itemSoldOut struct {
|
||||
Buyer string `json:"buyer"`
|
||||
Passport string `json:"passport"`
|
||||
OrderId string `json:"orderId"`
|
||||
Currency string `json:"currency"`
|
||||
Amount string `json:"amount"`
|
||||
}
|
||||
|
||||
type recharge struct {
|
||||
}
|
||||
|
||||
func (this *recharge) init() {
|
||||
mt.Table.Contract.Traverse(func (ele *mt.Contract) bool {
|
||||
if ele.GetName() == jccommon.CONTRACT_NAME_GameItemMall {
|
||||
//go this.process(ele.GetNetId(), ele.GetAddress())
|
||||
go this.process(ele.GetNetId(), ele.GetAddress())
|
||||
}
|
||||
return true
|
||||
})
|
||||
@ -57,5 +66,66 @@ ORDER BY idx LIMIT 1000
|
||||
}
|
||||
|
||||
func (this *recharge) saveToDb(ds *f5.DataSet) bool {
|
||||
f5.GetSysLog().Info("load ItemSoldOut idx:%s contract_name:%s event_name:%s",
|
||||
ds.GetByName("idx"),
|
||||
ds.GetByName("contract_name"),
|
||||
ds.GetByName("event_name"))
|
||||
idx := ds.GetByName("idx")
|
||||
txhash := ds.GetByName("txhash")
|
||||
logIndex := ds.GetByName("log_index")
|
||||
netId := ds.GetByName("net_id")
|
||||
eventName := ds.GetByName("event_name")
|
||||
contractAddress := ds.GetByName("contract_address")
|
||||
returnValues := ds.GetByName("return_values")
|
||||
createTime := ds.GetByName("createtime")
|
||||
modifyTime := ds.GetByName("modifytime")
|
||||
|
||||
decodeJsonOk := false
|
||||
p := new(itemSoldOut)
|
||||
if q5.DecodeJson(returnValues, p) == nil {
|
||||
decodeJsonOk = true
|
||||
var dbErr error
|
||||
f5.GetGoStyleDb().Upsert(
|
||||
constant.BCEVENT_DB,
|
||||
"t_recharge",
|
||||
[][]string{
|
||||
{"txhash", txhash},
|
||||
{"log_index", logIndex},
|
||||
{"net_id", netId},
|
||||
{"contract_address", contractAddress},
|
||||
},
|
||||
[][]string{},
|
||||
[][]string{
|
||||
{"txhash", txhash},
|
||||
{"log_index", logIndex},
|
||||
{"net_id", netId},
|
||||
{"event_name", eventName},
|
||||
{"contract_address", strings.ToLower(contractAddress)},
|
||||
{"src_idx", idx},
|
||||
{"buyer", p.Buyer},
|
||||
{"passport", p.Passport},
|
||||
{"order_id", p.OrderId},
|
||||
{"currency", p.Currency},
|
||||
{"amount", p.Amount},
|
||||
{"createtime", createTime},
|
||||
{"modifytime", modifyTime},
|
||||
},
|
||||
func (err error, lastInsertId int64, rowsAffected int64) {
|
||||
dbErr = err
|
||||
})
|
||||
if dbErr != nil {
|
||||
return false
|
||||
}
|
||||
}
|
||||
if !decodeJsonOk {
|
||||
jccommon.AddDbLog(constant.BCEVENT_DB, "recharge", "decodeJsonError",
|
||||
map[string]string{
|
||||
"param1": txhash,
|
||||
"param2": netId,
|
||||
"param3": eventName,
|
||||
"param4": idx,
|
||||
"param5": contractAddress,
|
||||
})
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user