From 3a3297a186e942fb51f10d5338d6a9316d35cf69 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 10 Jul 2024 16:07:55 +0800 Subject: [PATCH] 1 --- server/backtask/service/user.go | 62 +++++++++++++++++++++++++++++++++ server/jccommon/constant.go | 5 +++ 2 files changed, 67 insertions(+) diff --git a/server/backtask/service/user.go b/server/backtask/service/user.go index 5069a411..f59ff6dc 100644 --- a/server/backtask/service/user.go +++ b/server/backtask/service/user.go @@ -1,9 +1,11 @@ package service import ( + "q5" "f5" "main/constant" "fmt" + "jccommon" ) func GetAccountIdByAddress(accountAddress string) string { @@ -45,6 +47,26 @@ func AccountIdExistsAndIgnoreError(accountId string) bool { } func UserAddGold(accountId string, goldNum int32, netId int32, tokenId string, reason int32) bool { + var oldGold float64 + { + f5.GetGoStyleDb().OrmSelectOne( + constant.GAME_DB, + "t_user", + [][]string { + {"account_id", accountId}, + }, + func (err error, ds *f5.DataSet) { + if err != nil { + return + } + if ds.Next() { + oldGold = q5.ToFloat64(ds.GetByName("gold")) + AddGameLog(accountId, jccommon.GAME_LOG_TYPE_BACKTASK_USER_ADD_GOLD_START, + q5.ToString(reason), + q5.ToString(netId), tokenId, q5.ToString(oldGold), q5.ToString(goldNum)) + } + }) + } result := false f5.GetGoStyleDb().Update( constant.GAME_DB, @@ -63,5 +85,45 @@ func UserAddGold(accountId string, goldNum int32, netId int32, tokenId string, r return } }) + { + f5.GetGoStyleDb().OrmSelectOne( + constant.GAME_DB, + "t_user", + [][]string { + {"account_id", accountId}, + }, + func (err error, ds *f5.DataSet) { + if err != nil { + return + } + if ds.Next() { + newGold := q5.ToFloat64(ds.GetByName("gold")) + AddGameLog(accountId, jccommon.GAME_LOG_TYPE_BACKTASK_USER_ADD_GOLD_END, + q5.ToString(reason), + q5.ToString(netId), tokenId, q5.ToString(oldGold), q5.ToString(newGold)) + } + }) + } return result } + +func AddGameLog(accountId string, logType string, subType string, + param1 string, param2 string, param3 string, param4 string) { + nowTime := f5.GetApp().GetRealSeconds() + f5.GetGoStyleDb().Insert( + constant.GAME_DB, + "t_game_log", + [][]string { + {"account_id", accountId}, + {"type", logType}, + {"subtype", subType}, + {"param1", param1}, + {"param2", param2}, + {"param3", param3}, + {"param4", param4}, + {"createtime", q5.ToString(nowTime)}, + {"modifytime", q5.ToString(nowTime)}, + }, + func (err error, lastInsertId int64, rowsAffected int64) { + }) +} diff --git a/server/jccommon/constant.go b/server/jccommon/constant.go index 14f15a3a..8e786b57 100644 --- a/server/jccommon/constant.go +++ b/server/jccommon/constant.go @@ -88,6 +88,11 @@ const ( BC_POLY_POLY_METAKASK = 13 ) +const ( + GAME_LOG_TYPE_BACKTASK_USER_ADD_GOLD_START = "backtask.user_add_gold.begin" + GAME_LOG_TYPE_BACKTASK_USER_ADD_GOLD_END = "backtask.user_add_gold.end" +) + const ( BC_CURRENCY_NAME_ETHEREUM = "Ethereum" BC_CURRENCY_NAME_USDC = "USDC"