Documentation ¶
Index ¶
- Constants
- Variables
- func CreateTableIfNotExist(db *gorm.DB, tables ...interface{}) error
- func HandleUpdateResult(result *gorm.DB, entityName string) error
- type Cockroach
- func (c *Cockroach) AddBalance(ops *types.UserQueryOpts, amount int64) error
- func (c *Cockroach) AddDeductionBalance(ops *types.UserQueryOpts, amount int64) error
- func (c *Cockroach) AddDeductionBalanceWithDB(ops *types.UserQueryOpts, amount int64, tx *gorm.DB) error
- func (c *Cockroach) AddDeductionBalanceWithFunc(ops *types.UserQueryOpts, amount int64, preDo, postDo func() error) error
- func (c *Cockroach) AddRewardBalance(ops *types.UserQueryOpts, amount int64, db *gorm.DB) error
- func (c *Cockroach) Close() error
- func (c *Cockroach) CreateAccount(ops *types.UserQueryOpts, account *types.Account) (*types.Account, error)
- func (c *Cockroach) CreateInvoicePaymentsWithDB(invoicePayments []types.InvoicePayment, DB *gorm.DB) error
- func (c *Cockroach) CreateInvoiceWithDB(i *types.Invoice, DB *gorm.DB) error
- func (c *Cockroach) CreateRegion(region *types.Region) error
- func (c *Cockroach) CreateUser(oAuth *types.OauthProvider, regionUserCr *types.RegionUserCr, user *types.User, ...) error
- func (c *Cockroach) GetAccount(ops *types.UserQueryOpts) (*types.Account, error)
- func (c *Cockroach) GetAccountConfig() (types.AccountConfig, error)
- func (c *Cockroach) GetAccountWithWorkspace(workspace string) (*types.Account, error)
- func (c *Cockroach) GetGiftCodeWithCode(code string) (*types.GiftCode, error)
- func (c *Cockroach) GetInvoice(userID string, req types.LimitReq) ([]types.Invoice, types.LimitResp, error)
- func (c *Cockroach) GetInvoicePayments(invoiceID string) ([]types.InvoicePayment, error)
- func (c *Cockroach) GetInvoiceWithID(invoiceID string) (*types.Invoice, error)
- func (c *Cockroach) GetLocalRegion() types.Region
- func (c *Cockroach) GetPayment(ops *types.UserQueryOpts, startTime, endTime time.Time) ([]types.Payment, error)
- func (c *Cockroach) GetPaymentWithID(paymentID string) (*types.Payment, error)
- func (c *Cockroach) GetPaymentWithInvoice(invoiceID string) ([]types.Payment, error)
- func (c *Cockroach) GetPaymentWithLimit(ops *types.UserQueryOpts, req types.LimitReq, invoiced *bool) ([]types.Payment, types.LimitResp, error)
- func (c *Cockroach) GetRegions() ([]types.Region, error)
- func (c *Cockroach) GetTransfer(ops *types.GetTransfersReq) (*types.GetTransfersResp, error)
- func (c *Cockroach) GetUnInvoicedPaymentListWithIds(ids []string) ([]types.Payment, error)
- func (c *Cockroach) GetUser(ops *types.UserQueryOpts) (*types.User, error)
- func (c *Cockroach) GetUserCr(ops *types.UserQueryOpts) (*types.RegionUserCr, error)
- func (c *Cockroach) GetUserOauthProvider(ops *types.UserQueryOpts) ([]types.OauthProvider, error)
- func (c *Cockroach) GetUserRealNameInfoByUserID(userID string) (*types.UserRealNameInfo, error)
- func (c *Cockroach) GetUserRechargeDiscount(ops *types.UserQueryOpts) (types.UserRechargeDiscount, error)
- func (c *Cockroach) GetUserUID(ops *types.UserQueryOpts) (uuid.UUID, error)
- func (c *Cockroach) GetWorkspace(namespaces ...string) ([]types.Workspace, error)
- func (c *Cockroach) InitTables() error
- func (c *Cockroach) InsertAccountConfig(config *types.AccountConfig) error
- func (c *Cockroach) IsNullRecharge(ops *types.UserQueryOpts) (bool, error)
- func (c *Cockroach) NewAccount(ops *types.UserQueryOpts) (*types.Account, error)
- func (c *Cockroach) Payment(payment *types.Payment) error
- func (c *Cockroach) ProcessPendingTaskRewards() error
- func (c *Cockroach) ReduceBalance(ops *types.UserQueryOpts, amount int64) error
- func (c *Cockroach) ReduceDeductionBalance(ops *types.UserQueryOpts, amount int64) error
- func (c *Cockroach) SavePayment(payment *types.Payment) error
- func (c *Cockroach) SetAccountCreateLocalRegion(account *types.Account, region string) error
- func (c *Cockroach) SetInvoiceStatus(ids []string, stats string) error
- func (c *Cockroach) SetPaymentInvoice(ops *types.UserQueryOpts, paymentIDList []string) error
- func (c *Cockroach) SetPaymentInvoiceWithDB(ops *types.UserQueryOpts, paymentIDList []string, DB *gorm.DB) error
- func (c *Cockroach) TransferAccount(from, to *types.UserQueryOpts, amount int64) error
- func (c *Cockroach) TransferAccountAll(from, to *types.UserQueryOpts) error
- func (c *Cockroach) UseGiftCode(giftCode *types.GiftCode, userID string) error
Constants ¶
View Source
const ( EnvLocalRegion = "LOCAL_REGION" EnvBaseBalance = "BASE_BALANCE" )
View Source
const ( BaseUnit = 1_000_000 MinBalance = 10 * BaseUnit DefaultBaseBalance = 5 * BaseUnit )
Variables ¶
View Source
var (
BaseBalance = int64(DefaultBaseBalance)
)
View Source
var ErrInsufficientBalance = errors.New("insufficient balance")
Functions ¶
func CreateTableIfNotExist ¶
Types ¶
type Cockroach ¶
type Cockroach struct { DB *gorm.DB Localdb *gorm.DB LocalRegion *types.Region ZeroAccount *types.Account // contains filtered or unexported fields }
func NewCockRoach ¶
func (*Cockroach) AddBalance ¶
func (c *Cockroach) AddBalance(ops *types.UserQueryOpts, amount int64) error
func (*Cockroach) AddDeductionBalance ¶
func (c *Cockroach) AddDeductionBalance(ops *types.UserQueryOpts, amount int64) error
func (*Cockroach) AddDeductionBalanceWithDB ¶
func (*Cockroach) AddDeductionBalanceWithFunc ¶
func (*Cockroach) AddRewardBalance ¶
func (*Cockroach) CreateAccount ¶
func (*Cockroach) CreateInvoicePaymentsWithDB ¶
func (c *Cockroach) CreateInvoicePaymentsWithDB(invoicePayments []types.InvoicePayment, DB *gorm.DB) error
create invoicePayments
func (*Cockroach) CreateInvoiceWithDB ¶
func (*Cockroach) CreateUser ¶
func (c *Cockroach) CreateUser(oAuth *types.OauthProvider, regionUserCr *types.RegionUserCr, user *types.User, workspace *types.Workspace, userWorkspace *types.UserWorkspace) error
func (*Cockroach) GetAccount ¶
func (*Cockroach) GetAccountConfig ¶
func (c *Cockroach) GetAccountConfig() (types.AccountConfig, error)
func (*Cockroach) GetAccountWithWorkspace ¶
func (*Cockroach) GetGiftCodeWithCode ¶
func (*Cockroach) GetInvoice ¶
func (*Cockroach) GetInvoicePayments ¶
func (c *Cockroach) GetInvoicePayments(invoiceID string) ([]types.InvoicePayment, error)
func (*Cockroach) GetInvoiceWithID ¶
GetInvoiceWithID
func (*Cockroach) GetLocalRegion ¶
func (*Cockroach) GetPayment ¶
func (*Cockroach) GetPaymentWithID ¶
func (*Cockroach) GetPaymentWithInvoice ¶
func (*Cockroach) GetPaymentWithLimit ¶
func (*Cockroach) GetTransfer ¶
func (c *Cockroach) GetTransfer(ops *types.GetTransfersReq) (*types.GetTransfersResp, error)
func (*Cockroach) GetUnInvoicedPaymentListWithIds ¶
func (*Cockroach) GetUserCr ¶
func (c *Cockroach) GetUserCr(ops *types.UserQueryOpts) (*types.RegionUserCr, error)
func (*Cockroach) GetUserOauthProvider ¶
func (c *Cockroach) GetUserOauthProvider(ops *types.UserQueryOpts) ([]types.OauthProvider, error)
func (*Cockroach) GetUserRealNameInfoByUserID ¶
func (c *Cockroach) GetUserRealNameInfoByUserID(userID string) (*types.UserRealNameInfo, error)
func (*Cockroach) GetUserRechargeDiscount ¶
func (c *Cockroach) GetUserRechargeDiscount(ops *types.UserQueryOpts) (types.UserRechargeDiscount, error)
func (*Cockroach) GetUserUID ¶
func (*Cockroach) GetWorkspace ¶
func (*Cockroach) InitTables ¶
func (*Cockroach) InsertAccountConfig ¶
func (c *Cockroach) InsertAccountConfig(config *types.AccountConfig) error
func (*Cockroach) IsNullRecharge ¶
func (c *Cockroach) IsNullRecharge(ops *types.UserQueryOpts) (bool, error)
func (*Cockroach) NewAccount ¶
NewAccount create a new account
func (*Cockroach) ProcessPendingTaskRewards ¶
func (*Cockroach) ReduceBalance ¶
func (c *Cockroach) ReduceBalance(ops *types.UserQueryOpts, amount int64) error
func (*Cockroach) ReduceDeductionBalance ¶
func (c *Cockroach) ReduceDeductionBalance(ops *types.UserQueryOpts, amount int64) error
func (*Cockroach) SetAccountCreateLocalRegion ¶
func (*Cockroach) SetInvoiceStatus ¶
func (*Cockroach) SetPaymentInvoice ¶
func (c *Cockroach) SetPaymentInvoice(ops *types.UserQueryOpts, paymentIDList []string) error
func (*Cockroach) SetPaymentInvoiceWithDB ¶
func (*Cockroach) TransferAccount ¶
func (c *Cockroach) TransferAccount(from, to *types.UserQueryOpts, amount int64) error
func (*Cockroach) TransferAccountAll ¶
func (c *Cockroach) TransferAccountAll(from, to *types.UserQueryOpts) error
Click to show internal directories.
Click to hide internal directories.