diff --git a/server/backtask/service/user.go b/server/backtask/service/user.go index f59ff6dc..96bfebe4 100644 --- a/server/backtask/service/user.go +++ b/server/backtask/service/user.go @@ -127,3 +127,64 @@ func AddGameLog(accountId string, logType string, subType string, func (err error, lastInsertId int64, rowsAffected int64) { }) } + +func UserAddDiamond(accountId string, diamondNum int32, netId int32, tokenId string, reason int32) bool { + var oldDiamond 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() { + oldDiamond = q5.ToFloat64(ds.GetByName("diamond")) + AddGameLog(accountId, jccommon.GAME_LOG_TYPE_BACKTASK_USER_ADD_DIAMOND_START, + q5.ToString(reason), + q5.ToString(netId), tokenId, q5.ToString(oldDiamond), q5.ToString(diamondNum)) + } + }) + } + result := false + f5.GetGoStyleDb().Update( + constant.GAME_DB, + "t_user", + [][]string { + {"account_id", accountId}, + }, + [][]string { + {"!diamond", func () string { + return fmt.Sprintf("diamond + %d", diamondNum) + }()}, + }, + func (err error, lastInsertId int64, rowsAffected int64) { + result = err == nil + if err != nil { + 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() { + newDiamond := q5.ToFloat64(ds.GetByName("diamond")) + AddGameLog(accountId, jccommon.GAME_LOG_TYPE_BACKTASK_USER_ADD_DIAMOND_END, + q5.ToString(reason), + q5.ToString(netId), tokenId, q5.ToString(oldDiamond), q5.ToString(newDiamond)) + } + }) + } + return result +} diff --git a/server/jccommon/constant.go b/server/jccommon/constant.go index 7a4323c6..438938ef 100644 --- a/server/jccommon/constant.go +++ b/server/jccommon/constant.go @@ -96,6 +96,8 @@ const ( 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" + GAME_LOG_TYPE_BACKTASK_USER_ADD_DIAMOND_START = "backtask.user_add_diamond.begin" + GAME_LOG_TYPE_BACKTASK_USER_ADD_DIAMOND_END = "backtask.user_add_diamond.end" ) const (