Ver código fonte

uipdate

master
dengbiao 7 meses atrás
pai
commit
1d08cd229b
2 arquivos alterados com 22 adições e 1 exclusões
  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 Ver arquivo

@@ -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 Ver arquivo

@@ -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
}


Carregando…
Cancelar
Salvar