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: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dao

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

Dao dao

func New

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

New init mysql db

func (*Dao) AccountInfo

func (d *Dao) AccountInfo(c context.Context, mid int64) (ai *api.Info, err error)

AccountInfo queries account info by user id.

func (*Dao) AddCachePayParam

func (d *Dao) AddCachePayParam(c context.Context, id string, val *model.PayParam) (err error)

AddCachePayParam Set data to mc

func (*Dao) AddCacheUserInfoByMid

func (d *Dao) AddCacheUserInfoByMid(c context.Context, id int64, val *model.UserInfo) (err error)

AddCacheUserInfoByMid Set data to mc

func (*Dao) BeginTran

func (d *Dao) BeginTran(c context.Context) (*xsql.Tx, error)

BeginTran begins transaction.

func (*Dao) CachePayParamByToken

func (d *Dao) CachePayParamByToken(c context.Context, id string) (res *model.PayParam, err error)

CachePayParamByToken get data from mc

func (*Dao) CachePayParamsByTokens

func (d *Dao) CachePayParamsByTokens(c context.Context, ids []string) (res map[string]*model.PayParam, err error)

CachePayParamsByTokens get data from mc

func (*Dao) CacheUserInfoByMid

func (d *Dao) CacheUserInfoByMid(c context.Context, id int64) (res *model.UserInfo, err error)

CacheUserInfoByMid get data from mc

func (*Dao) Close

func (d *Dao) Close()

Close close the resource.

func (*Dao) CreateYstOrder

func (d *Dao) CreateYstOrder(c context.Context, req *model.YstCreateOrderReq) (res *model.YstCreateOrderReply, err error)

CreateYstOrder creates one yst order.

func (*Dao) DelCacheUserInfoByMid

func (d *Dao) DelCacheUserInfoByMid(c context.Context, id int64) (err error)

DelCacheUserInfoByMid delete data from mc

func (*Dao) EndTran

func (d *Dao) EndTran(tx *xsql.Tx, err error) error

EndTran ends transaction.

func (*Dao) GiveMVipGift

func (d *Dao) GiveMVipGift(c context.Context, mid int64, batchId int, orderNo string) error

GiveMVipGift gives bilibili vip to user.

func (*Dao) Lock

func (d *Dao) Lock(c context.Context, key string, val string) (err error)

func (*Dao) MainVip

func (d *Dao) MainVip(c context.Context, mid int64) (mv *model.MainVip, err error)

MainVip returns main vip info.

func (*Dao) PayOrderByID

func (d *Dao) PayOrderByID(c context.Context, id int) (po *model.PayOrder, err error)

PayOrderByID quires one row from tv_pay_order.

func (*Dao) PayOrderByOrderNo

func (d *Dao) PayOrderByOrderNo(c context.Context, orderNo string) (po *model.PayOrder, err error)

PayOrderByOrderNo quires one row from tv_pay_order.

func (*Dao) PayOrdersByMid

func (d *Dao) PayOrdersByMid(c context.Context, mid int, pn, ps int) (res []*model.PayOrder, total int, err error)

PayOrdersByMid quires rows from tv_pay_order.

func (*Dao) PayOrdersByMidAndStatus

func (d *Dao) PayOrdersByMidAndStatus(c context.Context, mid int, status int8, pn, ps int) (res []*model.PayOrder, total int, err error)

PayOrdersByMidAndStatus quires rows from tv_pay_order.

func (*Dao) PayOrdersByMidAndStatusAndCtime

func (d *Dao) PayOrdersByMidAndStatusAndCtime(c context.Context, mid int64, status int8, from, to xtime.Time, pn, ps int) (res []*model.PayOrder, total int, err error)

PayOrdersByMidAndStatusAndCtime quires rows from tv_pay_order.

func (*Dao) Ping

func (d *Dao) Ping(ctx context.Context) error

Ping dao ping

func (*Dao) PriceConfigsByStatus

func (d *Dao) PriceConfigsByStatus(c context.Context, status int8) (res []*model.PriceConfig, total int, err error)

PriceConfigsByStatus quires rows from tv_price_config.

func (*Dao) RawUserInfoByMid

func (d *Dao) RawUserInfoByMid(c context.Context, mid int64) (ui *model.UserInfo, err error)

UserInfoByMid quires one row from tv_user_info.

func (*Dao) RenewYstOrder

func (d *Dao) RenewYstOrder(c context.Context, req *model.YstRenewOrderReq) (res *model.YstRenewOrderReply, err error)

RenewYstOrder creates one renew order.

func (*Dao) SaledPriceConfigsByStatus

func (d *Dao) SaledPriceConfigsByStatus(c context.Context, status int8) (res []*model.PriceConfig, total int, err error)

SaledPriceConfigsByStatus quires rows from tv_price_config.

func (*Dao) Signer

func (d *Dao) Signer() *pkg.Signer

Signer returns yst signer.

func (*Dao) TxDeleteUserContract

func (d *Dao) TxDeleteUserContract(ctx context.Context, tx *xsql.Tx, id int32) (err error)

TxDeleteUserContract deletes one user contract record.

func (*Dao) TxInsertPayOrder

func (d *Dao) TxInsertPayOrder(ctx context.Context, tx *xsql.Tx, po *model.PayOrder) (id int64, err error)

TxInsertPayOrder insert one row into tv_pay_order.

func (*Dao) TxInsertUserChangeHistory

func (d *Dao) TxInsertUserChangeHistory(ctx context.Context, tx *xsql.Tx, uch *model.UserChangeHistory) (id int64, err error)

TxInsertUserChangeHistory insert one row into tv_user_change_history.

func (*Dao) TxInsertUserContract

func (d *Dao) TxInsertUserContract(ctx context.Context, tx *xsql.Tx, uc *model.UserContract) (id int64, err error)

TxInsertUserContract insert one row into tv_user_contract.

func (*Dao) TxInsertUserInfo

func (d *Dao) TxInsertUserInfo(ctx context.Context, tx *xsql.Tx, ui *model.UserInfo) (id int64, err error)

TxInsertUserInfo insert one row into tv_user_info.

func (*Dao) TxUpdatePayOrder

func (d *Dao) TxUpdatePayOrder(ctx context.Context, tx *xsql.Tx, po *model.PayOrder) error

TxUpdatePayOrder updates status, third party no and payment time.

func (*Dao) TxUpdateUserInfo

func (d *Dao) TxUpdateUserInfo(ctx context.Context, tx *xsql.Tx, ui *model.UserInfo) (err error)

TxUpdateUserInfo updates user info.

func (*Dao) TxUpdateUserPayType

func (d *Dao) TxUpdateUserPayType(ctx context.Context, tx *xsql.Tx, ui *model.UserInfo) (err error)

TxUpdateUserPayType updates pay type of user.

func (*Dao) TxUpdateUserStatus

func (d *Dao) TxUpdateUserStatus(ctx context.Context, tx *xsql.Tx, ui *model.UserInfo) (err error)

TxUpdateUserInfo updates vip status of user.

func (*Dao) Unlock

func (d *Dao) Unlock(c context.Context, key string, val string) (err error)

no thread-safe, but it's works. bad case of unlocking: 1, process-a gets lock 2, lock expires 3, process-b gets lock 4, process-a releases lock

func (*Dao) UnpaidNotCallbackOrder

func (d *Dao) UnpaidNotCallbackOrder(c context.Context, stime, etime xtime.Time, pn, ps int) (res []*model.PayOrder, err error)

UnpaidNotCallbackOrder get orders not paid where stime < ctime < etime

func (*Dao) UpdateCachePayParam

func (d *Dao) UpdateCachePayParam(c context.Context, id string, val *model.PayParam) (err error)

UpdateCachePayParam Replace data to mc

func (*Dao) UserChangeHistoryByID

func (d *Dao) UserChangeHistoryByID(c context.Context, id int32) (uch *model.UserChangeHistory, err error)

UserChangeHistoryByID quires one row from tv_user_change_history.

func (*Dao) UserChangeHistorysByMid

func (d *Dao) UserChangeHistorysByMid(c context.Context, mid int64, pn, ps int32) (res []*model.UserChangeHistory, total int, err error)

UserChangeHistorysByMid quires rows from tv_user_change_history.

func (*Dao) UserChangeHistorysByMidAndCtime

func (d *Dao) UserChangeHistorysByMidAndCtime(c context.Context, mid int64, from, to xtime.Time, pn, ps int32) (res []*model.UserChangeHistory, total int, err error)

UserChangeHistorysByMidAndCtime quires rows from tv_user_change_history.

func (*Dao) UserContractByContractId

func (d *Dao) UserContractByContractId(c context.Context, contractId string) (uc *model.UserContract, err error)

UserContractByContractId quires one row from tv_user_contract.

func (*Dao) UserContractByMid

func (d *Dao) UserContractByMid(c context.Context, mid int64) (uc *model.UserContract, err error)

UserContractByMid quires one row from tv_user_contract.

func (*Dao) UserInfoByMid

func (d *Dao) UserInfoByMid(c context.Context, id int64) (res *model.UserInfo, err error)

UserInfoByMid get data from cache if miss will call source method, then add to cache.

func (*Dao) YstOrderState

func (d *Dao) YstOrderState(c context.Context, req *model.YstOrderStateReq) (res *model.YstOrderStateReply, err error)

YstOrderState queries order details from yst.

type YstClient

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

YstClient represents http client for sending requests to yst.

func NewYstClient

func NewYstClient(cli *bm.Client) *YstClient

NewYstClient news a yst client.

func (*YstClient) NewRequest

func (yc *YstClient) NewRequest(uri string, data interface{}) (request *http.Request, err error)

NewRequest news a post request.

func (*YstClient) Post

func (yc *YstClient) Post(c context.Context, uri string, data interface{}, res interface{}) error

Post sends one post request.

Jump to

Keyboard shortcuts

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