This commit is contained in:
aozhiwei 2024-08-05 11:42:38 +08:00
parent f5cc26c9c2
commit f650fb85ec

View File

@ -84,6 +84,14 @@ func (this *recharge) saveToDb(ds *f5.DataSet) bool {
p := new(itemSoldOut)
if q5.DecodeJson(returnValues, p) == nil {
decodeJsonOk = true
orderExists := false
if this.updateOrderStatus(txhash, p.OrderId, q5.ToInt32(createTime), &orderExists) != nil {
return false
}
status := 0
if orderExists {
status = 1
}
var dbErr error
f5.GetGoStyleDb().Upsert(
constant.BCEVENT_DB,
@ -106,6 +114,7 @@ func (this *recharge) saveToDb(ds *f5.DataSet) bool {
{"order_id", p.OrderId},
{"currency", p.Currency},
{"amount", p.Amount},
{"status", q5.ToString(status)},
{"createtime", createTime},
{"modifytime", modifyTime},
},
@ -128,3 +137,38 @@ func (this *recharge) saveToDb(ds *f5.DataSet) bool {
}
return true
}
func (this *recharge) updateOrderStatus(txhash string, orderId string, payTime int32, orderExists *bool) error {
*orderExists = false
var resultErr error
f5.GetGoStyleDb().OrmSelectOne(
constant.BCNFT_DB,
"t_recharge_order",
[][]string{
{"order_id", orderId},
},
func (err error, ds *f5.DataSet) {
resultErr = err
if err != nil {
return
}
*orderExists = ds.Next()
})
if resultErr == nil && *orderExists {
f5.GetGoStyleDb().Update(
constant.BCNFT_DB,
"t_recharge_order",
[][]string{
{"order_id", orderId},
},
[][]string{
{"txhash", txhash},
{"pay_status", q5.ToString(1)},
{"pay_time", q5.ToString(payTime)},
},
func (err error, lastInsertId int64, rowsAffected int64) {
resultErr = err
})
}
return resultErr
}