Bladeren bron

Merge remote-tracking branch 'origin/master'

master
huangjiajun 5 maanden geleden
bovenliggende
commit
cf35d42075
2 gewijzigde bestanden met toevoegingen van 22 en 1 verwijderingen
  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 Bestand weergeven

@@ -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 Bestand weergeven

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


Laden…
Annuleren
Opslaan