dao

package
v0.0.0-...-83adff0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 6, 2020 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ModifyUrl            = "http://api.bilibili.co/x/internal/v1/coin/user/modify"
	InfoUrl              = "http://api.bilibili.co/x/internal/v1/coin/user/count"
	ExchangeSilverReason = "兑换直播银瓜子 %d"
	ExchangeMetalReason  = "银瓜子兑换硬币"
)

Variables

View Source
var (
	UnLockGetWrong   = "UnLockGetWrong"
	LockFailed       = "LockFailed"
	UserWalletPrefix = "user_wallet_lock_uid_"
	ErrUnLockGet     = errors.New(UnLockGetWrong)
	ErrLockFailed    = errors.New(LockFailed)
)

Functions

func GetTid

func GetTid(serviceType model.ServiceType, v interface{}) string

Types

type Dao

type Dao struct {
	// contains filtered or unexported fields
}

func New

func New(c *conf.Config) (dao *Dao)

New init mysql db

func (*Dao) AddGold

func (d *Dao) AddGold(c context.Context, uid int64, num int) (affect int64, err error)

AddGold 添加金瓜子

func (*Dao) AddIapGold

func (d *Dao) AddIapGold(c context.Context, uid int64, num int) (affect int64, err error)

RechargeGold 添加IOS金瓜子

func (*Dao) AddSilver

func (d *Dao) AddSilver(c context.Context, uid int64, num int) (affect int64, err error)

AddSilver 添加银瓜子

func (*Dao) BeginTx

func (d *Dao) BeginTx(c context.Context) (conn *sql.Tx, err error)

开启事务

func (*Dao) CacheVersion

func (d *Dao) CacheVersion(c context.Context) int32

func (*Dao) ChangeCostBase

func (d *Dao) ChangeCostBase(c context.Context, uid int64, num int64) (affect int64, err error)

func (*Dao) Close

func (d *Dao) Close()

Close close the resource.

func (*Dao) ConsumeCoin

func (d *Dao) ConsumeCoin(c context.Context, coinNum int, uid int64, coinTypeNo int32, seeds int64, delCache bool, reason interface{}) (success bool, err error)

func (*Dao) ConsumeGold

func (d *Dao) ConsumeGold(c context.Context, uid int64, num int) (affect int64, err error)

AddSilver 消费金瓜子 记入消费总值

func (*Dao) ConsumeIapGold

func (d *Dao) ConsumeIapGold(c context.Context, uid int64, num int) (affect int64, err error)

AddSilver 消费IOS金瓜子 记入消费总值

func (*Dao) ConsumeSilver

func (d *Dao) ConsumeSilver(c context.Context, uid int64, num int) (affect int64, err error)

ConsumeSilver 消费银瓜子 记入消费总值

func (*Dao) DelWalletCache

func (d *Dao) DelWalletCache(c context.Context, uid int64) (err error)

DelWalletCache 删除等级缓存

func (*Dao) Detail

func (d *Dao) Detail(c context.Context, uid int64) (detail *model.Detail, err error)

Detail 详细数据

func (*Dao) DetailWithoutDefault

func (d *Dao) DetailWithoutDefault(c context.Context, uid int64) (detail *model.Detail, err error)

func (*Dao) DoTx

func (d *Dao) DoTx(c context.Context, doFunc func(conn *sql.Tx) (v interface{}, err error)) (v interface{}, err error)

func (*Dao) ExchangeCoinInTx

func (d *Dao) ExchangeCoinInTx(conn *sql.Tx, uid int64, srcSysCoinTypeNo int32, srcNum int64, destSysCoinTypeNo int32, destNum int64, originWallet *model.DetailWithSnapShot) (affect int64, err error)

func (*Dao) ForceUnLock

func (d *Dao) ForceUnLock(ctx context.Context, key string) (err error)

func (*Dao) GetCoin

func (d *Dao) GetCoin(c context.Context, coinTypeNo int32, uid int64) (interface{}, error)

func (*Dao) GetCoinStreamByTid

func (d *Dao) GetCoinStreamByTid(c context.Context, tid string) (record *model.CoinStreamRecord, err error)

func (*Dao) GetCoinStreamByTidAndOffset

func (d *Dao) GetCoinStreamByTidAndOffset(c context.Context, tid string, offset int) (record *model.CoinStreamRecord, err error)

func (*Dao) GetCoinStreamByUidTid

func (d *Dao) GetCoinStreamByUidTid(c context.Context, uid int64, tid string) (record *model.CoinStreamRecord, err error)

func (*Dao) GetDetailByCache

func (d *Dao) GetDetailByCache(c context.Context, uid int64) (wallet *model.Detail, err error)

func (*Dao) GetMelonseedByCache

func (d *Dao) GetMelonseedByCache(c context.Context, uid int64) (wallet *model.Melonseed, err error)

Melonseed 获取瓜子数

func (*Dao) GetMetal

func (d *Dao) GetMetal(c context.Context, uid int64) (metal float64, err error)

func (*Dao) InitWallet

func (d *Dao) InitWallet(c context.Context, uid int64, gold int64, iap_gold int64, silver int64) (row int64, err error)

InitExp 初始化用户钱包,用于首次查询

func (*Dao) InitWalletInTx

func (d *Dao) InitWalletInTx(conn *sql.Tx, uid int64, gold int64, iap_gold int64, silver int64) (row int64, err error)

InitExp 初始化用户钱包,用于首次查询

func (*Dao) IsLockFailedError

func (d *Dao) IsLockFailedError(err error) bool

func (*Dao) IsNewVersion

func (d *Dao) IsNewVersion(c context.Context, detail *model.McDetail) bool

func (*Dao) Lock

func (d *Dao) Lock(ctx context.Context, key string, ttl int, retry int, retryDelay int) (err error, gotLock bool, lockValue string)

ttl ms retry 重试次数 retryDelay us

func (*Dao) LockTransactionId

func (d *Dao) LockTransactionId(ctx context.Context, tid string) (err error)

func (*Dao) LockUser

func (d *Dao) LockUser(ctx context.Context, uid int64) (err error, gotLock bool, lockValue string)

func (*Dao) Melonseed

func (d *Dao) Melonseed(c context.Context, uid int64) (wallet *model.Melonseed, err error)

Melonseed 获取瓜子数

func (*Dao) ModifyCntInTx

func (d *Dao) ModifyCntInTx(conn *sql.Tx, uid int64, goldPay int, goldRecharge int, silverPay int) (int64, error)

func (*Dao) ModifyCoin

func (d *Dao) ModifyCoin(c context.Context, coinNum int, uid int64, coinTypeNo int32, delCache bool) (bool, error)

func (*Dao) ModifyCoinInTx

func (d *Dao) ModifyCoinInTx(conn *sql.Tx, uid int64, sysCoinTypeNo int32, num int64, originWallet *model.DetailWithSnapShot) (affect int64, err error)

func (*Dao) ModifyMetal

func (d *Dao) ModifyMetal(c context.Context, uid int64, coins int64, seeds int64, reason interface{}) (success bool, code int, err error)

func (*Dao) NewCoinExchangeRecord

func (d *Dao) NewCoinExchangeRecord(c context.Context, record *model.CoinExchangeRecord) (int64, error)

func (*Dao) NewCoinExchangeRecordInTx

func (d *Dao) NewCoinExchangeRecordInTx(conn *sql.Tx, record *model.CoinExchangeRecord) (int64, error)

func (*Dao) NewCoinStreamRecord

func (d *Dao) NewCoinStreamRecord(c context.Context, record *model.CoinStreamRecord) (int64, error)

func (*Dao) NewCoinStreamRecordInTx

func (d *Dao) NewCoinStreamRecordInTx(conn *sql.Tx, record *model.CoinStreamRecord) (int64, error)

func (*Dao) PayCoinInTx

func (d *Dao) PayCoinInTx(conn *sql.Tx, uid int64, sysCoinTypeNo int32, num int64, originWallet *model.DetailWithSnapShot) (affect int64, err error)

func (*Dao) Ping

func (d *Dao) Ping(c context.Context) (err error)

Ping dao ping

func (*Dao) PingRedis

func (d *Dao) PingRedis(c context.Context) (err error)

func (*Dao) Pub

func (d *Dao) Pub(c context.Context, uid int64, msg interface{}) error

func (*Dao) RechargeCoin

func (d *Dao) RechargeCoin(c context.Context, coinNum int, uid int64, coinTypeNo int32, delCache bool) (bool, error)

func (*Dao) RechargeCoinInTx

func (d *Dao) RechargeCoinInTx(conn *sql.Tx, uid int64, sysCoinTypeNo int32, num int64, originWallet *model.DetailWithSnapShot) (affect int64, err error)

RechargeGold 充值IOS金瓜子 记入充值总值

func (*Dao) RechargeGold

func (d *Dao) RechargeGold(c context.Context, uid int64, num int) (affect int64, err error)

RechargeGold 充值金瓜子 记入充值总值

func (*Dao) RechargeIapGold

func (d *Dao) RechargeIapGold(c context.Context, uid int64, num int) (affect int64, err error)

RechargeGold 充值IOS金瓜子 记入充值总值

func (*Dao) SetWalletCache

func (d *Dao) SetWalletCache(c context.Context, detail *model.McDetail, expire int32) (err error)

SetWalletCache 设置钱包缓存

func (*Dao) UnLock

func (d *Dao) UnLock(ctx context.Context, key string, lockValue string) (err error)

func (*Dao) UnLockUser

func (d *Dao) UnLockUser(ctx context.Context, uid int64, lockValue string) error

func (*Dao) UpdateSnapShotTime

func (d *Dao) UpdateSnapShotTime(context context.Context, uid int64, time string) (int64, error)

更新镜像时间 方便测试

func (*Dao) WalletCache

func (d *Dao) WalletCache(c context.Context, uid int64) (detail *model.McDetail, err error)

WalletCache 获取钱包缓存

func (*Dao) WalletForUpdate

func (d *Dao) WalletForUpdate(conn *sql.Tx, uid int64) (wallet *model.DetailWithSnapShot, err error)

为了后续的更新获取数据

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL