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