Browse Source

uipdate

master
dengbiao 7 months ago
parent
commit
1d08cd229b
2 changed files with 22 additions and 1 deletions
  1. +21
    -0
      db/db_user_virtual_amount.go
  2. +1
    -1
      svc/svc_block_star_chain_settlement.go

+ 21
- 0
db/db_user_virtual_amount.go View File

@@ -95,6 +95,27 @@ func GetUserVirtualWalletWithSession(session *xorm.Session, uid, coinId int) (*m
return nil, errors.New("获取用户虚拟币钱包失败")
}

func GetUserVirtualWallet(session *xorm.Engine, uid, coinId int) (*model.UserVirtualAmount, error) {
var UserVirtualWallet model.UserVirtualAmount
get, err := session.Where("uid = ? AND coin_id = ?", uid, coinId).Get(&UserVirtualWallet)
if err != nil {
return nil, err
}
if get {
return &UserVirtualWallet, nil
} else {
UserVirtualWallet.Amount = "0"
UserVirtualWallet.CoinId = coinId
UserVirtualWallet.Uid = uid
one, err := session.InsertOne(&UserVirtualWallet)
if err != nil || one == 0 {
return nil, err
}
return &UserVirtualWallet, nil
}
return nil, errors.New("获取用户虚拟币钱包失败")
}

// UserVirtualAmountGetOneByParams 通过传入的参数查询数据(单条)
func UserVirtualAmountGetOneByParams(Db *xorm.Engine, params map[string]interface{}) (*model.UserVirtualAmount, error) {
var m model.UserVirtualAmount


+ 1
- 1
svc/svc_block_star_chain_settlement.go View File

@@ -16,7 +16,7 @@ func GetUserCoinAmount(session *xorm.Session, masterId string, coinId, uid int)
amount, err = cache.GetString(redisKey)
if err != nil {
if err.Error() == "redigo: nil returned" {
userVirtualAmount, err := db.GetUserVirtualWalletWithSession(session, uid, coinId)
userVirtualAmount, err := db.GetUserVirtualWallet(session.Engine(), uid, coinId)
if err != nil {
return amount, err
}


Loading…
Cancel
Save