1
This commit is contained in:
parent
19794eae8b
commit
c2bfbc6403
@ -13,6 +13,24 @@ type NftHomeMeta struct {
|
||||
ExternalLink string `json:"external_link"`
|
||||
}
|
||||
|
||||
type ActivitySaleEvent struct {
|
||||
EventName string `json:"event_name"`
|
||||
EventId string `json:"event_id"`
|
||||
Chain string `json:"chain"`
|
||||
Data struct {
|
||||
Details struct {
|
||||
To string `json:"to"`
|
||||
From string `json:"from"`
|
||||
OrderId string `json:"order_id"`
|
||||
Asset struct {
|
||||
TokenId string `json:"token_id"`
|
||||
ContractType string `json:"contract_type"`
|
||||
ContractAddress string `json:"contract_address"`
|
||||
} `json:"asset"`
|
||||
} `json:"details"`
|
||||
} `json:"data"`
|
||||
}
|
||||
|
||||
type OrderUpdatedEvent struct {
|
||||
EventName string `json:"event_name"`
|
||||
EventId string `json:"event_id"`
|
||||
|
@ -14,6 +14,7 @@ type taskMgr struct {
|
||||
|
||||
func (this* taskMgr) Init() {
|
||||
go this.loadWebHookEvent(constant.ORDER_UPDATE_EVENT, this.orderUpdatedCb)
|
||||
go this.loadWebHookEvent(constant.ACTIVITY_SALE_EVENT, this.activitySaleCb)
|
||||
}
|
||||
|
||||
func (this* taskMgr) UnInit() {
|
||||
@ -161,3 +162,45 @@ func (this* taskMgr) orderUpdatedCb(ds *f5.DataSet) bool {
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (this* taskMgr) activitySaleCb(ds *f5.DataSet) bool {
|
||||
nowTime := f5.GetApp().GetRealSeconds()
|
||||
rawData := ds.GetByName("raw_data")
|
||||
p := new(common.ActivitySaleEvent)
|
||||
err := q5.DecodeJson(rawData, &p)
|
||||
netId := 13473
|
||||
if err == nil {
|
||||
updateFields := [][]string{
|
||||
}
|
||||
insertFields := [][]string{
|
||||
{"order_id", p.Data.Details.OrderId},
|
||||
{"chain", p.Chain},
|
||||
{"net_id", q5.ToString(netId)},
|
||||
{"token_id", p.Data.Details.Asset.TokenId},
|
||||
{"contract_address", p.Data.Details.Asset.ContractAddress},
|
||||
{"buyer", p.Data.Details.From},
|
||||
{"seller", p.Data.Details.To},
|
||||
{"event_id", p.EventId},
|
||||
{"event_data", rawData},
|
||||
{"createtime", q5.ToString(nowTime)},
|
||||
{"modifytime", q5.ToString(nowTime)},
|
||||
}
|
||||
f5.GetGoStyleDb().UpsertEx(
|
||||
constant.BCNFT_DB,
|
||||
"t_sale",
|
||||
[][]string{
|
||||
{"order_id", p.Data.Details.OrderId},
|
||||
},
|
||||
updateFields,
|
||||
insertFields,
|
||||
func (err error, lastInsertId int64, rowsAffected int64) {
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
},
|
||||
func (ds *f5.DataSet) bool {
|
||||
return p.EventId > ds.GetByName("event_id")
|
||||
})
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user