Documentation
¶
Overview ¶
Package affiliate is an Arandu module for an affiliate program: referral links, a referral tree that is for life, commission plans of one to four levels, commissions paid into arandu-wallet the moment a referred user pays, and withdrawals by request.
The files are laid out by role rather than by layer, so the whole package reads top to bottom:
module.go -> registration, routes, handlers and migrations config.go -> what the application passes in model.go -> the entities policy.go -> who may do what service.go -> the affiliates plan_service.go -> the commission plans referral_service.go -> the link, the referral and the tree commission_service.go -> payments, commissions, reversals withdrawal_service.go -> balance, payout accounts and withdrawals screens.go, views.go -> what the screens show, and the files published
An application registers it explicitly. There is no service provider, no container and no discovery.
Index ¶
- Constants
- Variables
- func CommissionOf(amount, rateBps int64) int64
- func Locales() []string
- func PublishedPaths() []string
- func ViewNames() []string
- func ViewPackages() []string
- type AccountOption
- type AccountRequest
- type AdminAffiliatePageData
- type AdminAffiliatesPageData
- type AdminCommissionsPageData
- type AdminPlansPageData
- type AdminWithdrawalsPageData
- type Affiliate
- type AffiliateCollection
- func (c AffiliateCollection) Contains(key any) bool
- func (c AffiliateCollection) Except(keys ...any) AffiliateCollection
- func (c AffiliateCollection) Find(key any) *Affiliate
- func (c AffiliateCollection) FindOrFail(key any) (*Affiliate, error)
- func (c AffiliateCollection) Fresh(ctx context.Context, g auth.Grant, with ...string) (AffiliateCollection, error)
- func (c AffiliateCollection) Load(ctx context.Context, g auth.Grant, relations ...string) error
- func (c AffiliateCollection) LoadCount(ctx context.Context, g auth.Grant, relations ...string) error
- func (c AffiliateCollection) LoadMissing(ctx context.Context, g auth.Grant, relations ...string) error
- func (c AffiliateCollection) ModelKeys() []any
- func (c AffiliateCollection) Only(keys ...any) AffiliateCollection
- func (c AffiliateCollection) Pluck(column string) []any
- func (c AffiliateCollection) Rows() model.Rows
- func (c AffiliateCollection) ToArray() []map[string]any
- func (c AffiliateCollection) Unique() AffiliateCollection
- type AffiliatePolicy
- type AffiliateQuery
- func (q *AffiliateQuery) AddSelect(columns ...any) *AffiliateQuery
- func (q *AffiliateQuery) Avg(ctx context.Context, g auth.Grant, column any) (any, error)
- func (q *AffiliateQuery) Base() *model.Builder
- func (q *AffiliateQuery) Chunk(ctx context.Context, g auth.Grant, count int, ...) error
- func (q *AffiliateQuery) Clone() *AffiliateQuery
- func (q *AffiliateQuery) Count(ctx context.Context, g auth.Grant, columns ...any) (int64, error)
- func (q *AffiliateQuery) Create(ctx context.Context, g auth.Grant, attributes map[string]any) (*Affiliate, error)
- func (q *AffiliateQuery) Cursor(ctx context.Context, g auth.Grant) iter.Seq2[*Affiliate, error]
- func (q *AffiliateQuery) CursorPaginate(ctx context.Context, g auth.Grant, perPage int, cursor *pagination.Cursor, ...) (AffiliateCollection, *pagination.CursorPage, error)
- func (q *AffiliateQuery) Decrement(ctx context.Context, g auth.Grant, column string, amount any, ...) (int64, error)
- func (q *AffiliateQuery) Delete(ctx context.Context, g auth.Grant) (int64, error)
- func (q *AffiliateQuery) DoesntExist(ctx context.Context, g auth.Grant) (bool, error)
- func (q *AffiliateQuery) DoesntHave(relation, boolean string, callback func(*query.Builder)) *AffiliateQuery
- func (q *AffiliateQuery) Each(ctx context.Context, g auth.Grant, count int, ...) error
- func (q *AffiliateQuery) Exists(ctx context.Context, g auth.Grant) (bool, error)
- func (q *AffiliateQuery) Find(ctx context.Context, g auth.Grant, id any, columns ...any) (*Affiliate, error)
- func (q *AffiliateQuery) FindMany(ctx context.Context, g auth.Grant, ids []any, columns ...any) (AffiliateCollection, error)
- func (q *AffiliateQuery) FindOrFail(ctx context.Context, g auth.Grant, id any, columns ...any) (*Affiliate, error)
- func (q *AffiliateQuery) FindOrNew(ctx context.Context, g auth.Grant, id any, columns ...any) (*Affiliate, error)
- func (q *AffiliateQuery) First(ctx context.Context, g auth.Grant, columns ...any) (*Affiliate, error)
- func (q *AffiliateQuery) FirstOrCreate(ctx context.Context, g auth.Grant, attributes, values map[string]any) (*Affiliate, error)
- func (q *AffiliateQuery) FirstOrFail(ctx context.Context, g auth.Grant, columns ...any) (*Affiliate, error)
- func (q *AffiliateQuery) FirstOrNew(ctx context.Context, g auth.Grant, attributes, values map[string]any) (*Affiliate, error)
- func (q *AffiliateQuery) FirstWhere(ctx context.Context, g auth.Grant, column any, args ...any) (*Affiliate, error)
- func (q *AffiliateQuery) ForPage(page, perPage int) *AffiliateQuery
- func (q *AffiliateQuery) ForceCreate(ctx context.Context, g auth.Grant, attributes map[string]any) (*Affiliate, error)
- func (q *AffiliateQuery) Get(ctx context.Context, g auth.Grant, columns ...any) (AffiliateCollection, error)
- func (q *AffiliateQuery) GroupBy(groups ...any) *AffiliateQuery
- func (q *AffiliateQuery) Has(relation, operator string, count int, boolean string, ...) *AffiliateQuery
- func (q *AffiliateQuery) Increment(ctx context.Context, g auth.Grant, column string, amount any, ...) (int64, error)
- func (q *AffiliateQuery) Insert(ctx context.Context, g auth.Grant, values ...map[string]any) (bool, error)
- func (q *AffiliateQuery) InsertOrIgnore(ctx context.Context, g auth.Grant, values ...map[string]any) (bool, error)
- func (q *AffiliateQuery) Join(table any, first any, args ...any) *AffiliateQuery
- func (q *AffiliateQuery) Latest(column ...string) *AffiliateQuery
- func (q *AffiliateQuery) Limit(value int) *AffiliateQuery
- func (q *AffiliateQuery) Max(ctx context.Context, g auth.Grant, column any) (any, error)
- func (q *AffiliateQuery) Min(ctx context.Context, g auth.Grant, column any) (any, error)
- func (q *AffiliateQuery) New() (*Affiliate, error)
- func (q *AffiliateQuery) Offset(value int) *AffiliateQuery
- func (q *AffiliateQuery) Oldest(column ...string) *AffiliateQuery
- func (q *AffiliateQuery) OrDoesntHave(relation string) *AffiliateQuery
- func (q *AffiliateQuery) OrHas(relation, operator string, count int) *AffiliateQuery
- func (q *AffiliateQuery) OrWhere(column any, args ...any) *AffiliateQuery
- func (q *AffiliateQuery) OrWhereDoesntHave(relation string, callback func(*query.Builder)) *AffiliateQuery
- func (q *AffiliateQuery) OrWhereHas(relation string, callback func(*query.Builder)) *AffiliateQuery
- func (q *AffiliateQuery) OrWhereNot(column any, args ...any) *AffiliateQuery
- func (q *AffiliateQuery) OrWhereRelation(relation string, column any, args ...any) *AffiliateQuery
- func (q *AffiliateQuery) OrderBy(column any, direction ...string) *AffiliateQuery
- func (q *AffiliateQuery) OrderByDesc(column any) *AffiliateQuery
- func (q *AffiliateQuery) Paginate(ctx context.Context, g auth.Grant, perPage, page int, opts pagination.Options, ...) (AffiliateCollection, *pagination.LengthAwarePage, error)
- func (q *AffiliateQuery) Pluck(ctx context.Context, g auth.Grant, column string) ([]any, error)
- func (q *AffiliateQuery) Select(columns ...any) *AffiliateQuery
- func (q *AffiliateQuery) SelectRaw(expression string, bindings ...any) *AffiliateQuery
- func (q *AffiliateQuery) SimplePaginate(ctx context.Context, g auth.Grant, perPage, page int, opts pagination.Options, ...) (AffiliateCollection, *pagination.Page, error)
- func (q *AffiliateQuery) Sole(ctx context.Context, g auth.Grant, columns ...any) (*Affiliate, error)
- func (q *AffiliateQuery) SoleValue(ctx context.Context, g auth.Grant, column string) (any, error)
- func (q *AffiliateQuery) Sum(ctx context.Context, g auth.Grant, column any) (any, error)
- func (q *AffiliateQuery) Touch(ctx context.Context, g auth.Grant, column ...string) (int64, error)
- func (q *AffiliateQuery) Update(ctx context.Context, g auth.Grant, values map[string]any) (int64, error)
- func (q *AffiliateQuery) UpdateOrCreate(ctx context.Context, g auth.Grant, attributes, values map[string]any) (*Affiliate, error)
- func (q *AffiliateQuery) Upsert(ctx context.Context, g auth.Grant, values []map[string]any, ...) (int64, error)
- func (q *AffiliateQuery) Value(ctx context.Context, g auth.Grant, column string) (any, error)
- func (q *AffiliateQuery) ValueOrFail(ctx context.Context, g auth.Grant, column string) (any, error)
- func (q *AffiliateQuery) Where(column any, args ...any) *AffiliateQuery
- func (q *AffiliateQuery) WhereBelongsTo(relationshipName string, related ...model.Entity) *AffiliateQuery
- func (q *AffiliateQuery) WhereBetween(column any, from, to any) *AffiliateQuery
- func (q *AffiliateQuery) WhereColumn(first any, args ...any) *AffiliateQuery
- func (q *AffiliateQuery) WhereDoesntHave(relation string, callback func(*query.Builder)) *AffiliateQuery
- func (q *AffiliateQuery) WhereExists(callback func(*query.Builder)) *AffiliateQuery
- func (q *AffiliateQuery) WhereHas(relation string, callback func(*query.Builder)) *AffiliateQuery
- func (q *AffiliateQuery) WhereHasCount(relation string, callback func(*query.Builder), operator string, count int) *AffiliateQuery
- func (q *AffiliateQuery) WhereIn(column any, values []any) *AffiliateQuery
- func (q *AffiliateQuery) WhereKey(id any) *AffiliateQuery
- func (q *AffiliateQuery) WhereNot(column any, args ...any) *AffiliateQuery
- func (q *AffiliateQuery) WhereNotExists(callback func(*query.Builder)) *AffiliateQuery
- func (q *AffiliateQuery) WhereNotIn(column any, values []any) *AffiliateQuery
- func (q *AffiliateQuery) WhereNotNull(columns ...any) *AffiliateQuery
- func (q *AffiliateQuery) WhereNull(columns ...any) *AffiliateQuery
- func (q *AffiliateQuery) WhereRelation(relation string, column any, args ...any) *AffiliateQuery
- func (q *AffiliateQuery) With(relations ...string) *AffiliateQuery
- func (q *AffiliateQuery) WithAvg(relation, column string) *AffiliateQuery
- func (q *AffiliateQuery) WithCount(relations ...string) *AffiliateQuery
- func (q *AffiliateQuery) WithExists(relation string) *AffiliateQuery
- func (q *AffiliateQuery) WithMax(relation, column string) *AffiliateQuery
- func (q *AffiliateQuery) WithMin(relation, column string) *AffiliateQuery
- func (q *AffiliateQuery) WithSum(relation, column string) *AffiliateQuery
- func (q *AffiliateQuery) Without(relations ...string) *AffiliateQuery
- func (q *AffiliateQuery) WithoutGlobalScope(identifier string) *AffiliateQuery
- func (q *AffiliateQuery) WithoutGlobalScopes(identifiers ...string) *AffiliateQuery
- type AffiliateRow
- type AffiliateService
- func (s *AffiliateService) ActivatePlan(ctx context.Context, actor security.Subject, id string) (*PlanView, error)
- func (s *AffiliateService) ActivePlan(ctx context.Context, actor security.Subject) (*PlanView, error)
- func (s *AffiliateService) AddPayoutAccount(ctx context.Context, actor security.Subject, in AccountRequest) (*wallet.PayoutAccount, error)
- func (s *AffiliateService) AffiliatesPage(ctx context.Context, actor security.Subject, q AffiliatesQuery) ([]*Affiliate, int, error)
- func (s *AffiliateService) Attribute(ctx context.Context, actor security.Subject, in AttributeRequest) (*Referral, error)
- func (s *AffiliateService) BalanceOf(ctx context.Context, actor security.Subject, affiliateID string) (Balance, error)
- func (s *AffiliateService) CommissionsPage(ctx context.Context, actor security.Subject, q CommissionsQuery) ([]CommissionView, int, error)
- func (s *AffiliateService) Create(ctx context.Context, actor security.Subject, in CreateRequest) (*Affiliate, error)
- func (s *AffiliateService) CreatePlan(ctx context.Context, actor security.Subject, in PlanRequest, activate bool) (*PlanView, error)
- func (s *AffiliateService) Find(ctx context.Context, actor security.Subject, id string) (*Affiliate, error)
- func (s *AffiliateService) Mine(ctx context.Context, actor security.Subject) (*Affiliate, error)
- func (s *AffiliateService) MyWithdrawals(ctx context.Context, actor security.Subject) ([]*wallet.WithdrawalRequest, error)
- func (s *AffiliateService) PayWithdrawal(ctx context.Context, actor security.Subject, in wallet.PaymentInput, ...) (*wallet.WithdrawalRequest, error)
- func (s *AffiliateService) PayoutAccounts(ctx context.Context, actor security.Subject, affiliateID string) ([]*wallet.PayoutAccount, error)
- func (s *AffiliateService) Plans(ctx context.Context, actor security.Subject) ([]PlanView, error)
- func (s *AffiliateService) RecordClick(ctx context.Context, actor security.Subject, in ClickRequest) (*Affiliate, int, error)
- func (s *AffiliateService) RecordConversion(ctx context.Context, actor security.Subject, in ConversionRequest) (*Conversion, []*Commission, error)
- func (s *AffiliateService) RecordRefund(ctx context.Context, actor security.Subject, orderRef, reason string) (*Conversion, error)
- func (s *AffiliateService) RejectWithdrawal(ctx context.Context, actor security.Subject, requestID, reason string) (*wallet.WithdrawalRequest, error)
- func (s *AffiliateService) RequestWithdrawal(ctx context.Context, actor security.Subject, in WithdrawalRequest) (*wallet.WithdrawalRequest, error)
- func (s *AffiliateService) ReverseCommission(ctx context.Context, actor security.Subject, commissionID, reason string) (*Commission, error)
- func (s *AffiliateService) SetBlocked(ctx context.Context, actor security.Subject, id string, blocked bool) (*Affiliate, error)
- func (s *AffiliateService) StartPaying(ctx context.Context, actor security.Subject, requestID string) (*wallet.WithdrawalRequest, error)
- func (s *AffiliateService) StatsOf(ctx context.Context, actor security.Subject, affiliateID string, from, to Day) (Stats, error)
- func (s *AffiliateService) Tree(ctx context.Context, actor security.Subject, affiliateID string) ([]TreeNode, error)
- func (s *AffiliateService) Upline(ctx context.Context, actor security.Subject, userID string) ([]*Affiliate, error)
- func (s *AffiliateService) WithdrawalReceipt(ctx context.Context, actor security.Subject, requestID string) (*wallet.WithdrawalRequest, filesystem.File, error)
- func (s *AffiliateService) Withdrawals(ctx context.Context, actor security.Subject, status wallet.WithdrawalStatus) ([]AffiliateWithdrawal, error)
- func (s *AffiliateService) WriteOff(ctx context.Context, actor security.Subject, affiliateID, reason string) (int64, error)
- type AffiliateStatus
- type AffiliateWithdrawal
- type AffiliatesQuery
- type AttributeRequest
- type Balance
- type CellInput
- type Click
- type ClickCollection
- func (c ClickCollection) Contains(key any) bool
- func (c ClickCollection) Except(keys ...any) ClickCollection
- func (c ClickCollection) Find(key any) *Click
- func (c ClickCollection) FindOrFail(key any) (*Click, error)
- func (c ClickCollection) Fresh(ctx context.Context, g auth.Grant, with ...string) (ClickCollection, error)
- func (c ClickCollection) Load(ctx context.Context, g auth.Grant, relations ...string) error
- func (c ClickCollection) LoadCount(ctx context.Context, g auth.Grant, relations ...string) error
- func (c ClickCollection) LoadMissing(ctx context.Context, g auth.Grant, relations ...string) error
- func (c ClickCollection) ModelKeys() []any
- func (c ClickCollection) Only(keys ...any) ClickCollection
- func (c ClickCollection) Pluck(column string) []any
- func (c ClickCollection) Rows() model.Rows
- func (c ClickCollection) ToArray() []map[string]any
- func (c ClickCollection) Unique() ClickCollection
- type ClickQuery
- func (q *ClickQuery) AddSelect(columns ...any) *ClickQuery
- func (q *ClickQuery) Avg(ctx context.Context, g auth.Grant, column any) (any, error)
- func (q *ClickQuery) Base() *model.Builder
- func (q *ClickQuery) Chunk(ctx context.Context, g auth.Grant, count int, ...) error
- func (q *ClickQuery) Clone() *ClickQuery
- func (q *ClickQuery) Count(ctx context.Context, g auth.Grant, columns ...any) (int64, error)
- func (q *ClickQuery) Create(ctx context.Context, g auth.Grant, attributes map[string]any) (*Click, error)
- func (q *ClickQuery) Cursor(ctx context.Context, g auth.Grant) iter.Seq2[*Click, error]
- func (q *ClickQuery) CursorPaginate(ctx context.Context, g auth.Grant, perPage int, cursor *pagination.Cursor, ...) (ClickCollection, *pagination.CursorPage, error)
- func (q *ClickQuery) Decrement(ctx context.Context, g auth.Grant, column string, amount any, ...) (int64, error)
- func (q *ClickQuery) Delete(ctx context.Context, g auth.Grant) (int64, error)
- func (q *ClickQuery) DoesntExist(ctx context.Context, g auth.Grant) (bool, error)
- func (q *ClickQuery) DoesntHave(relation, boolean string, callback func(*query.Builder)) *ClickQuery
- func (q *ClickQuery) Each(ctx context.Context, g auth.Grant, count int, ...) error
- func (q *ClickQuery) Exists(ctx context.Context, g auth.Grant) (bool, error)
- func (q *ClickQuery) Find(ctx context.Context, g auth.Grant, id any, columns ...any) (*Click, error)
- func (q *ClickQuery) FindMany(ctx context.Context, g auth.Grant, ids []any, columns ...any) (ClickCollection, error)
- func (q *ClickQuery) FindOrFail(ctx context.Context, g auth.Grant, id any, columns ...any) (*Click, error)
- func (q *ClickQuery) FindOrNew(ctx context.Context, g auth.Grant, id any, columns ...any) (*Click, error)
- func (q *ClickQuery) First(ctx context.Context, g auth.Grant, columns ...any) (*Click, error)
- func (q *ClickQuery) FirstOrCreate(ctx context.Context, g auth.Grant, attributes, values map[string]any) (*Click, error)
- func (q *ClickQuery) FirstOrFail(ctx context.Context, g auth.Grant, columns ...any) (*Click, error)
- func (q *ClickQuery) FirstOrNew(ctx context.Context, g auth.Grant, attributes, values map[string]any) (*Click, error)
- func (q *ClickQuery) FirstWhere(ctx context.Context, g auth.Grant, column any, args ...any) (*Click, error)
- func (q *ClickQuery) ForPage(page, perPage int) *ClickQuery
- func (q *ClickQuery) ForceCreate(ctx context.Context, g auth.Grant, attributes map[string]any) (*Click, error)
- func (q *ClickQuery) Get(ctx context.Context, g auth.Grant, columns ...any) (ClickCollection, error)
- func (q *ClickQuery) GroupBy(groups ...any) *ClickQuery
- func (q *ClickQuery) Has(relation, operator string, count int, boolean string, ...) *ClickQuery
- func (q *ClickQuery) Increment(ctx context.Context, g auth.Grant, column string, amount any, ...) (int64, error)
- func (q *ClickQuery) Insert(ctx context.Context, g auth.Grant, values ...map[string]any) (bool, error)
- func (q *ClickQuery) InsertOrIgnore(ctx context.Context, g auth.Grant, values ...map[string]any) (bool, error)
- func (q *ClickQuery) Join(table any, first any, args ...any) *ClickQuery
- func (q *ClickQuery) Latest(column ...string) *ClickQuery
- func (q *ClickQuery) Limit(value int) *ClickQuery
- func (q *ClickQuery) Max(ctx context.Context, g auth.Grant, column any) (any, error)
- func (q *ClickQuery) Min(ctx context.Context, g auth.Grant, column any) (any, error)
- func (q *ClickQuery) New() (*Click, error)
- func (q *ClickQuery) Offset(value int) *ClickQuery
- func (q *ClickQuery) Oldest(column ...string) *ClickQuery
- func (q *ClickQuery) OrDoesntHave(relation string) *ClickQuery
- func (q *ClickQuery) OrHas(relation, operator string, count int) *ClickQuery
- func (q *ClickQuery) OrWhere(column any, args ...any) *ClickQuery
- func (q *ClickQuery) OrWhereDoesntHave(relation string, callback func(*query.Builder)) *ClickQuery
- func (q *ClickQuery) OrWhereHas(relation string, callback func(*query.Builder)) *ClickQuery
- func (q *ClickQuery) OrWhereNot(column any, args ...any) *ClickQuery
- func (q *ClickQuery) OrWhereRelation(relation string, column any, args ...any) *ClickQuery
- func (q *ClickQuery) OrderBy(column any, direction ...string) *ClickQuery
- func (q *ClickQuery) OrderByDesc(column any) *ClickQuery
- func (q *ClickQuery) Paginate(ctx context.Context, g auth.Grant, perPage, page int, opts pagination.Options, ...) (ClickCollection, *pagination.LengthAwarePage, error)
- func (q *ClickQuery) Pluck(ctx context.Context, g auth.Grant, column string) ([]any, error)
- func (q *ClickQuery) Select(columns ...any) *ClickQuery
- func (q *ClickQuery) SelectRaw(expression string, bindings ...any) *ClickQuery
- func (q *ClickQuery) SimplePaginate(ctx context.Context, g auth.Grant, perPage, page int, opts pagination.Options, ...) (ClickCollection, *pagination.Page, error)
- func (q *ClickQuery) Sole(ctx context.Context, g auth.Grant, columns ...any) (*Click, error)
- func (q *ClickQuery) SoleValue(ctx context.Context, g auth.Grant, column string) (any, error)
- func (q *ClickQuery) Sum(ctx context.Context, g auth.Grant, column any) (any, error)
- func (q *ClickQuery) Touch(ctx context.Context, g auth.Grant, column ...string) (int64, error)
- func (q *ClickQuery) Update(ctx context.Context, g auth.Grant, values map[string]any) (int64, error)
- func (q *ClickQuery) UpdateOrCreate(ctx context.Context, g auth.Grant, attributes, values map[string]any) (*Click, error)
- func (q *ClickQuery) Upsert(ctx context.Context, g auth.Grant, values []map[string]any, ...) (int64, error)
- func (q *ClickQuery) Value(ctx context.Context, g auth.Grant, column string) (any, error)
- func (q *ClickQuery) ValueOrFail(ctx context.Context, g auth.Grant, column string) (any, error)
- func (q *ClickQuery) Where(column any, args ...any) *ClickQuery
- func (q *ClickQuery) WhereBelongsTo(relationshipName string, related ...model.Entity) *ClickQuery
- func (q *ClickQuery) WhereBetween(column any, from, to any) *ClickQuery
- func (q *ClickQuery) WhereColumn(first any, args ...any) *ClickQuery
- func (q *ClickQuery) WhereDoesntHave(relation string, callback func(*query.Builder)) *ClickQuery
- func (q *ClickQuery) WhereExists(callback func(*query.Builder)) *ClickQuery
- func (q *ClickQuery) WhereHas(relation string, callback func(*query.Builder)) *ClickQuery
- func (q *ClickQuery) WhereHasCount(relation string, callback func(*query.Builder), operator string, count int) *ClickQuery
- func (q *ClickQuery) WhereIn(column any, values []any) *ClickQuery
- func (q *ClickQuery) WhereKey(id any) *ClickQuery
- func (q *ClickQuery) WhereNot(column any, args ...any) *ClickQuery
- func (q *ClickQuery) WhereNotExists(callback func(*query.Builder)) *ClickQuery
- func (q *ClickQuery) WhereNotIn(column any, values []any) *ClickQuery
- func (q *ClickQuery) WhereNotNull(columns ...any) *ClickQuery
- func (q *ClickQuery) WhereNull(columns ...any) *ClickQuery
- func (q *ClickQuery) WhereRelation(relation string, column any, args ...any) *ClickQuery
- func (q *ClickQuery) With(relations ...string) *ClickQuery
- func (q *ClickQuery) WithAvg(relation, column string) *ClickQuery
- func (q *ClickQuery) WithCount(relations ...string) *ClickQuery
- func (q *ClickQuery) WithExists(relation string) *ClickQuery
- func (q *ClickQuery) WithMax(relation, column string) *ClickQuery
- func (q *ClickQuery) WithMin(relation, column string) *ClickQuery
- func (q *ClickQuery) WithSum(relation, column string) *ClickQuery
- func (q *ClickQuery) Without(relations ...string) *ClickQuery
- func (q *ClickQuery) WithoutGlobalScope(identifier string) *ClickQuery
- func (q *ClickQuery) WithoutGlobalScopes(identifiers ...string) *ClickQuery
- type ClickRequest
- type Commission
- type CommissionCollection
- func (c CommissionCollection) Contains(key any) bool
- func (c CommissionCollection) Except(keys ...any) CommissionCollection
- func (c CommissionCollection) Find(key any) *Commission
- func (c CommissionCollection) FindOrFail(key any) (*Commission, error)
- func (c CommissionCollection) Fresh(ctx context.Context, g auth.Grant, with ...string) (CommissionCollection, error)
- func (c CommissionCollection) Load(ctx context.Context, g auth.Grant, relations ...string) error
- func (c CommissionCollection) LoadCount(ctx context.Context, g auth.Grant, relations ...string) error
- func (c CommissionCollection) LoadMissing(ctx context.Context, g auth.Grant, relations ...string) error
- func (c CommissionCollection) ModelKeys() []any
- func (c CommissionCollection) Only(keys ...any) CommissionCollection
- func (c CommissionCollection) Pluck(column string) []any
- func (c CommissionCollection) Rows() model.Rows
- func (c CommissionCollection) ToArray() []map[string]any
- func (c CommissionCollection) Unique() CommissionCollection
- type CommissionQuery
- func (q *CommissionQuery) AddSelect(columns ...any) *CommissionQuery
- func (q *CommissionQuery) Avg(ctx context.Context, g auth.Grant, column any) (any, error)
- func (q *CommissionQuery) Base() *model.Builder
- func (q *CommissionQuery) Chunk(ctx context.Context, g auth.Grant, count int, ...) error
- func (q *CommissionQuery) Clone() *CommissionQuery
- func (q *CommissionQuery) Count(ctx context.Context, g auth.Grant, columns ...any) (int64, error)
- func (q *CommissionQuery) Create(ctx context.Context, g auth.Grant, attributes map[string]any) (*Commission, error)
- func (q *CommissionQuery) Cursor(ctx context.Context, g auth.Grant) iter.Seq2[*Commission, error]
- func (q *CommissionQuery) CursorPaginate(ctx context.Context, g auth.Grant, perPage int, cursor *pagination.Cursor, ...) (CommissionCollection, *pagination.CursorPage, error)
- func (q *CommissionQuery) Decrement(ctx context.Context, g auth.Grant, column string, amount any, ...) (int64, error)
- func (q *CommissionQuery) Delete(ctx context.Context, g auth.Grant) (int64, error)
- func (q *CommissionQuery) DoesntExist(ctx context.Context, g auth.Grant) (bool, error)
- func (q *CommissionQuery) DoesntHave(relation, boolean string, callback func(*query.Builder)) *CommissionQuery
- func (q *CommissionQuery) Each(ctx context.Context, g auth.Grant, count int, ...) error
- func (q *CommissionQuery) Exists(ctx context.Context, g auth.Grant) (bool, error)
- func (q *CommissionQuery) Find(ctx context.Context, g auth.Grant, id any, columns ...any) (*Commission, error)
- func (q *CommissionQuery) FindMany(ctx context.Context, g auth.Grant, ids []any, columns ...any) (CommissionCollection, error)
- func (q *CommissionQuery) FindOrFail(ctx context.Context, g auth.Grant, id any, columns ...any) (*Commission, error)
- func (q *CommissionQuery) FindOrNew(ctx context.Context, g auth.Grant, id any, columns ...any) (*Commission, error)
- func (q *CommissionQuery) First(ctx context.Context, g auth.Grant, columns ...any) (*Commission, error)
- func (q *CommissionQuery) FirstOrCreate(ctx context.Context, g auth.Grant, attributes, values map[string]any) (*Commission, error)
- func (q *CommissionQuery) FirstOrFail(ctx context.Context, g auth.Grant, columns ...any) (*Commission, error)
- func (q *CommissionQuery) FirstOrNew(ctx context.Context, g auth.Grant, attributes, values map[string]any) (*Commission, error)
- func (q *CommissionQuery) FirstWhere(ctx context.Context, g auth.Grant, column any, args ...any) (*Commission, error)
- func (q *CommissionQuery) ForPage(page, perPage int) *CommissionQuery
- func (q *CommissionQuery) ForceCreate(ctx context.Context, g auth.Grant, attributes map[string]any) (*Commission, error)
- func (q *CommissionQuery) Get(ctx context.Context, g auth.Grant, columns ...any) (CommissionCollection, error)
- func (q *CommissionQuery) GroupBy(groups ...any) *CommissionQuery
- func (q *CommissionQuery) Has(relation, operator string, count int, boolean string, ...) *CommissionQuery
- func (q *CommissionQuery) Increment(ctx context.Context, g auth.Grant, column string, amount any, ...) (int64, error)
- func (q *CommissionQuery) Insert(ctx context.Context, g auth.Grant, values ...map[string]any) (bool, error)
- func (q *CommissionQuery) InsertOrIgnore(ctx context.Context, g auth.Grant, values ...map[string]any) (bool, error)
- func (q *CommissionQuery) Join(table any, first any, args ...any) *CommissionQuery
- func (q *CommissionQuery) Latest(column ...string) *CommissionQuery
- func (q *CommissionQuery) Limit(value int) *CommissionQuery
- func (q *CommissionQuery) Max(ctx context.Context, g auth.Grant, column any) (any, error)
- func (q *CommissionQuery) Min(ctx context.Context, g auth.Grant, column any) (any, error)
- func (q *CommissionQuery) New() (*Commission, error)
- func (q *CommissionQuery) Offset(value int) *CommissionQuery
- func (q *CommissionQuery) Oldest(column ...string) *CommissionQuery
- func (q *CommissionQuery) OrDoesntHave(relation string) *CommissionQuery
- func (q *CommissionQuery) OrHas(relation, operator string, count int) *CommissionQuery
- func (q *CommissionQuery) OrWhere(column any, args ...any) *CommissionQuery
- func (q *CommissionQuery) OrWhereDoesntHave(relation string, callback func(*query.Builder)) *CommissionQuery
- func (q *CommissionQuery) OrWhereHas(relation string, callback func(*query.Builder)) *CommissionQuery
- func (q *CommissionQuery) OrWhereNot(column any, args ...any) *CommissionQuery
- func (q *CommissionQuery) OrWhereRelation(relation string, column any, args ...any) *CommissionQuery
- func (q *CommissionQuery) OrderBy(column any, direction ...string) *CommissionQuery
- func (q *CommissionQuery) OrderByDesc(column any) *CommissionQuery
- func (q *CommissionQuery) Paginate(ctx context.Context, g auth.Grant, perPage, page int, opts pagination.Options, ...) (CommissionCollection, *pagination.LengthAwarePage, error)
- func (q *CommissionQuery) Pluck(ctx context.Context, g auth.Grant, column string) ([]any, error)
- func (q *CommissionQuery) Select(columns ...any) *CommissionQuery
- func (q *CommissionQuery) SelectRaw(expression string, bindings ...any) *CommissionQuery
- func (q *CommissionQuery) SimplePaginate(ctx context.Context, g auth.Grant, perPage, page int, opts pagination.Options, ...) (CommissionCollection, *pagination.Page, error)
- func (q *CommissionQuery) Sole(ctx context.Context, g auth.Grant, columns ...any) (*Commission, error)
- func (q *CommissionQuery) SoleValue(ctx context.Context, g auth.Grant, column string) (any, error)
- func (q *CommissionQuery) Sum(ctx context.Context, g auth.Grant, column any) (any, error)
- func (q *CommissionQuery) Touch(ctx context.Context, g auth.Grant, column ...string) (int64, error)
- func (q *CommissionQuery) Update(ctx context.Context, g auth.Grant, values map[string]any) (int64, error)
- func (q *CommissionQuery) UpdateOrCreate(ctx context.Context, g auth.Grant, attributes, values map[string]any) (*Commission, error)
- func (q *CommissionQuery) Upsert(ctx context.Context, g auth.Grant, values []map[string]any, ...) (int64, error)
- func (q *CommissionQuery) Value(ctx context.Context, g auth.Grant, column string) (any, error)
- func (q *CommissionQuery) ValueOrFail(ctx context.Context, g auth.Grant, column string) (any, error)
- func (q *CommissionQuery) Where(column any, args ...any) *CommissionQuery
- func (q *CommissionQuery) WhereBelongsTo(relationshipName string, related ...model.Entity) *CommissionQuery
- func (q *CommissionQuery) WhereBetween(column any, from, to any) *CommissionQuery
- func (q *CommissionQuery) WhereColumn(first any, args ...any) *CommissionQuery
- func (q *CommissionQuery) WhereDoesntHave(relation string, callback func(*query.Builder)) *CommissionQuery
- func (q *CommissionQuery) WhereExists(callback func(*query.Builder)) *CommissionQuery
- func (q *CommissionQuery) WhereHas(relation string, callback func(*query.Builder)) *CommissionQuery
- func (q *CommissionQuery) WhereHasCount(relation string, callback func(*query.Builder), operator string, count int) *CommissionQuery
- func (q *CommissionQuery) WhereIn(column any, values []any) *CommissionQuery
- func (q *CommissionQuery) WhereKey(id any) *CommissionQuery
- func (q *CommissionQuery) WhereNot(column any, args ...any) *CommissionQuery
- func (q *CommissionQuery) WhereNotExists(callback func(*query.Builder)) *CommissionQuery
- func (q *CommissionQuery) WhereNotIn(column any, values []any) *CommissionQuery
- func (q *CommissionQuery) WhereNotNull(columns ...any) *CommissionQuery
- func (q *CommissionQuery) WhereNull(columns ...any) *CommissionQuery
- func (q *CommissionQuery) WhereRelation(relation string, column any, args ...any) *CommissionQuery
- func (q *CommissionQuery) With(relations ...string) *CommissionQuery
- func (q *CommissionQuery) WithAvg(relation, column string) *CommissionQuery
- func (q *CommissionQuery) WithCount(relations ...string) *CommissionQuery
- func (q *CommissionQuery) WithExists(relation string) *CommissionQuery
- func (q *CommissionQuery) WithMax(relation, column string) *CommissionQuery
- func (q *CommissionQuery) WithMin(relation, column string) *CommissionQuery
- func (q *CommissionQuery) WithSum(relation, column string) *CommissionQuery
- func (q *CommissionQuery) Without(relations ...string) *CommissionQuery
- func (q *CommissionQuery) WithoutGlobalScope(identifier string) *CommissionQuery
- func (q *CommissionQuery) WithoutGlobalScopes(identifiers ...string) *CommissionQuery
- type CommissionRow
- type CommissionStatus
- type CommissionView
- type CommissionsQuery
- type Config
- type Conversion
- type ConversionCollection
- func (c ConversionCollection) Contains(key any) bool
- func (c ConversionCollection) Except(keys ...any) ConversionCollection
- func (c ConversionCollection) Find(key any) *Conversion
- func (c ConversionCollection) FindOrFail(key any) (*Conversion, error)
- func (c ConversionCollection) Fresh(ctx context.Context, g auth.Grant, with ...string) (ConversionCollection, error)
- func (c ConversionCollection) Load(ctx context.Context, g auth.Grant, relations ...string) error
- func (c ConversionCollection) LoadCount(ctx context.Context, g auth.Grant, relations ...string) error
- func (c ConversionCollection) LoadMissing(ctx context.Context, g auth.Grant, relations ...string) error
- func (c ConversionCollection) ModelKeys() []any
- func (c ConversionCollection) Only(keys ...any) ConversionCollection
- func (c ConversionCollection) Pluck(column string) []any
- func (c ConversionCollection) Rows() model.Rows
- func (c ConversionCollection) ToArray() []map[string]any
- func (c ConversionCollection) Unique() ConversionCollection
- type ConversionQuery
- func (q *ConversionQuery) AddSelect(columns ...any) *ConversionQuery
- func (q *ConversionQuery) Avg(ctx context.Context, g auth.Grant, column any) (any, error)
- func (q *ConversionQuery) Base() *model.Builder
- func (q *ConversionQuery) Chunk(ctx context.Context, g auth.Grant, count int, ...) error
- func (q *ConversionQuery) Clone() *ConversionQuery
- func (q *ConversionQuery) Count(ctx context.Context, g auth.Grant, columns ...any) (int64, error)
- func (q *ConversionQuery) Create(ctx context.Context, g auth.Grant, attributes map[string]any) (*Conversion, error)
- func (q *ConversionQuery) Cursor(ctx context.Context, g auth.Grant) iter.Seq2[*Conversion, error]
- func (q *ConversionQuery) CursorPaginate(ctx context.Context, g auth.Grant, perPage int, cursor *pagination.Cursor, ...) (ConversionCollection, *pagination.CursorPage, error)
- func (q *ConversionQuery) Decrement(ctx context.Context, g auth.Grant, column string, amount any, ...) (int64, error)
- func (q *ConversionQuery) Delete(ctx context.Context, g auth.Grant) (int64, error)
- func (q *ConversionQuery) DoesntExist(ctx context.Context, g auth.Grant) (bool, error)
- func (q *ConversionQuery) DoesntHave(relation, boolean string, callback func(*query.Builder)) *ConversionQuery
- func (q *ConversionQuery) Each(ctx context.Context, g auth.Grant, count int, ...) error
- func (q *ConversionQuery) Exists(ctx context.Context, g auth.Grant) (bool, error)
- func (q *ConversionQuery) Find(ctx context.Context, g auth.Grant, id any, columns ...any) (*Conversion, error)
- func (q *ConversionQuery) FindMany(ctx context.Context, g auth.Grant, ids []any, columns ...any) (ConversionCollection, error)
- func (q *ConversionQuery) FindOrFail(ctx context.Context, g auth.Grant, id any, columns ...any) (*Conversion, error)
- func (q *ConversionQuery) FindOrNew(ctx context.Context, g auth.Grant, id any, columns ...any) (*Conversion, error)
- func (q *ConversionQuery) First(ctx context.Context, g auth.Grant, columns ...any) (*Conversion, error)
- func (q *ConversionQuery) FirstOrCreate(ctx context.Context, g auth.Grant, attributes, values map[string]any) (*Conversion, error)
- func (q *ConversionQuery) FirstOrFail(ctx context.Context, g auth.Grant, columns ...any) (*Conversion, error)
- func (q *ConversionQuery) FirstOrNew(ctx context.Context, g auth.Grant, attributes, values map[string]any) (*Conversion, error)
- func (q *ConversionQuery) FirstWhere(ctx context.Context, g auth.Grant, column any, args ...any) (*Conversion, error)
- func (q *ConversionQuery) ForPage(page, perPage int) *ConversionQuery
- func (q *ConversionQuery) ForceCreate(ctx context.Context, g auth.Grant, attributes map[string]any) (*Conversion, error)
- func (q *ConversionQuery) Get(ctx context.Context, g auth.Grant, columns ...any) (ConversionCollection, error)
- func (q *ConversionQuery) GroupBy(groups ...any) *ConversionQuery
- func (q *ConversionQuery) Has(relation, operator string, count int, boolean string, ...) *ConversionQuery
- func (q *ConversionQuery) Increment(ctx context.Context, g auth.Grant, column string, amount any, ...) (int64, error)
- func (q *ConversionQuery) Insert(ctx context.Context, g auth.Grant, values ...map[string]any) (bool, error)
- func (q *ConversionQuery) InsertOrIgnore(ctx context.Context, g auth.Grant, values ...map[string]any) (bool, error)
- func (q *ConversionQuery) Join(table any, first any, args ...any) *ConversionQuery
- func (q *ConversionQuery) Latest(column ...string) *ConversionQuery
- func (q *ConversionQuery) Limit(value int) *ConversionQuery
- func (q *ConversionQuery) Max(ctx context.Context, g auth.Grant, column any) (any, error)
- func (q *ConversionQuery) Min(ctx context.Context, g auth.Grant, column any) (any, error)
- func (q *ConversionQuery) New() (*Conversion, error)
- func (q *ConversionQuery) Offset(value int) *ConversionQuery
- func (q *ConversionQuery) Oldest(column ...string) *ConversionQuery
- func (q *ConversionQuery) OrDoesntHave(relation string) *ConversionQuery
- func (q *ConversionQuery) OrHas(relation, operator string, count int) *ConversionQuery
- func (q *ConversionQuery) OrWhere(column any, args ...any) *ConversionQuery
- func (q *ConversionQuery) OrWhereDoesntHave(relation string, callback func(*query.Builder)) *ConversionQuery
- func (q *ConversionQuery) OrWhereHas(relation string, callback func(*query.Builder)) *ConversionQuery
- func (q *ConversionQuery) OrWhereNot(column any, args ...any) *ConversionQuery
- func (q *ConversionQuery) OrWhereRelation(relation string, column any, args ...any) *ConversionQuery
- func (q *ConversionQuery) OrderBy(column any, direction ...string) *ConversionQuery
- func (q *ConversionQuery) OrderByDesc(column any) *ConversionQuery
- func (q *ConversionQuery) Paginate(ctx context.Context, g auth.Grant, perPage, page int, opts pagination.Options, ...) (ConversionCollection, *pagination.LengthAwarePage, error)
- func (q *ConversionQuery) Pluck(ctx context.Context, g auth.Grant, column string) ([]any, error)
- func (q *ConversionQuery) Select(columns ...any) *ConversionQuery
- func (q *ConversionQuery) SelectRaw(expression string, bindings ...any) *ConversionQuery
- func (q *ConversionQuery) SimplePaginate(ctx context.Context, g auth.Grant, perPage, page int, opts pagination.Options, ...) (ConversionCollection, *pagination.Page, error)
- func (q *ConversionQuery) Sole(ctx context.Context, g auth.Grant, columns ...any) (*Conversion, error)
- func (q *ConversionQuery) SoleValue(ctx context.Context, g auth.Grant, column string) (any, error)
- func (q *ConversionQuery) Sum(ctx context.Context, g auth.Grant, column any) (any, error)
- func (q *ConversionQuery) Touch(ctx context.Context, g auth.Grant, column ...string) (int64, error)
- func (q *ConversionQuery) Update(ctx context.Context, g auth.Grant, values map[string]any) (int64, error)
- func (q *ConversionQuery) UpdateOrCreate(ctx context.Context, g auth.Grant, attributes, values map[string]any) (*Conversion, error)
- func (q *ConversionQuery) Upsert(ctx context.Context, g auth.Grant, values []map[string]any, ...) (int64, error)
- func (q *ConversionQuery) Value(ctx context.Context, g auth.Grant, column string) (any, error)
- func (q *ConversionQuery) ValueOrFail(ctx context.Context, g auth.Grant, column string) (any, error)
- func (q *ConversionQuery) Where(column any, args ...any) *ConversionQuery
- func (q *ConversionQuery) WhereBelongsTo(relationshipName string, related ...model.Entity) *ConversionQuery
- func (q *ConversionQuery) WhereBetween(column any, from, to any) *ConversionQuery
- func (q *ConversionQuery) WhereColumn(first any, args ...any) *ConversionQuery
- func (q *ConversionQuery) WhereDoesntHave(relation string, callback func(*query.Builder)) *ConversionQuery
- func (q *ConversionQuery) WhereExists(callback func(*query.Builder)) *ConversionQuery
- func (q *ConversionQuery) WhereHas(relation string, callback func(*query.Builder)) *ConversionQuery
- func (q *ConversionQuery) WhereHasCount(relation string, callback func(*query.Builder), operator string, count int) *ConversionQuery
- func (q *ConversionQuery) WhereIn(column any, values []any) *ConversionQuery
- func (q *ConversionQuery) WhereKey(id any) *ConversionQuery
- func (q *ConversionQuery) WhereNot(column any, args ...any) *ConversionQuery
- func (q *ConversionQuery) WhereNotExists(callback func(*query.Builder)) *ConversionQuery
- func (q *ConversionQuery) WhereNotIn(column any, values []any) *ConversionQuery
- func (q *ConversionQuery) WhereNotNull(columns ...any) *ConversionQuery
- func (q *ConversionQuery) WhereNull(columns ...any) *ConversionQuery
- func (q *ConversionQuery) WhereRelation(relation string, column any, args ...any) *ConversionQuery
- func (q *ConversionQuery) With(relations ...string) *ConversionQuery
- func (q *ConversionQuery) WithAvg(relation, column string) *ConversionQuery
- func (q *ConversionQuery) WithCount(relations ...string) *ConversionQuery
- func (q *ConversionQuery) WithExists(relation string) *ConversionQuery
- func (q *ConversionQuery) WithMax(relation, column string) *ConversionQuery
- func (q *ConversionQuery) WithMin(relation, column string) *ConversionQuery
- func (q *ConversionQuery) WithSum(relation, column string) *ConversionQuery
- func (q *ConversionQuery) Without(relations ...string) *ConversionQuery
- func (q *ConversionQuery) WithoutGlobalScope(identifier string) *ConversionQuery
- func (q *ConversionQuery) WithoutGlobalScopes(identifiers ...string) *ConversionQuery
- type ConversionRequest
- type ConversionStatus
- type CreateRequest
- type DashboardPageData
- type Day
- type Flag
- type FormState
- type Labels
- type LevelRow
- type Module
- func (m *Module) Boot(context.Context) error
- func (m *Module) CodeFrom(r *stdhttp.Request) string
- func (m *Module) Labels(locale string) Labels
- func (m *Module) Migrations() []foundation.Migration
- func (m *Module) Name() string
- func (m *Module) Publishes() []foundation.Publication
- func (m *Module) Routes(r *fhttp.Router)
- func (m *Module) Service() *AffiliateService
- type OptionalText
- type Plan
- type PlanCollection
- func (c PlanCollection) Contains(key any) bool
- func (c PlanCollection) Except(keys ...any) PlanCollection
- func (c PlanCollection) Find(key any) *Plan
- func (c PlanCollection) FindOrFail(key any) (*Plan, error)
- func (c PlanCollection) Fresh(ctx context.Context, g auth.Grant, with ...string) (PlanCollection, error)
- func (c PlanCollection) Load(ctx context.Context, g auth.Grant, relations ...string) error
- func (c PlanCollection) LoadCount(ctx context.Context, g auth.Grant, relations ...string) error
- func (c PlanCollection) LoadMissing(ctx context.Context, g auth.Grant, relations ...string) error
- func (c PlanCollection) ModelKeys() []any
- func (c PlanCollection) Only(keys ...any) PlanCollection
- func (c PlanCollection) Pluck(column string) []any
- func (c PlanCollection) Rows() model.Rows
- func (c PlanCollection) ToArray() []map[string]any
- func (c PlanCollection) Unique() PlanCollection
- type PlanKind
- type PlanLevel
- type PlanLevelCollection
- func (c PlanLevelCollection) Contains(key any) bool
- func (c PlanLevelCollection) Except(keys ...any) PlanLevelCollection
- func (c PlanLevelCollection) Find(key any) *PlanLevel
- func (c PlanLevelCollection) FindOrFail(key any) (*PlanLevel, error)
- func (c PlanLevelCollection) Fresh(ctx context.Context, g auth.Grant, with ...string) (PlanLevelCollection, error)
- func (c PlanLevelCollection) Load(ctx context.Context, g auth.Grant, relations ...string) error
- func (c PlanLevelCollection) LoadCount(ctx context.Context, g auth.Grant, relations ...string) error
- func (c PlanLevelCollection) LoadMissing(ctx context.Context, g auth.Grant, relations ...string) error
- func (c PlanLevelCollection) ModelKeys() []any
- func (c PlanLevelCollection) Only(keys ...any) PlanLevelCollection
- func (c PlanLevelCollection) Pluck(column string) []any
- func (c PlanLevelCollection) Rows() model.Rows
- func (c PlanLevelCollection) ToArray() []map[string]any
- func (c PlanLevelCollection) Unique() PlanLevelCollection
- type PlanLevelQuery
- func (q *PlanLevelQuery) AddSelect(columns ...any) *PlanLevelQuery
- func (q *PlanLevelQuery) Avg(ctx context.Context, g auth.Grant, column any) (any, error)
- func (q *PlanLevelQuery) Base() *model.Builder
- func (q *PlanLevelQuery) Chunk(ctx context.Context, g auth.Grant, count int, ...) error
- func (q *PlanLevelQuery) Clone() *PlanLevelQuery
- func (q *PlanLevelQuery) Count(ctx context.Context, g auth.Grant, columns ...any) (int64, error)
- func (q *PlanLevelQuery) Create(ctx context.Context, g auth.Grant, attributes map[string]any) (*PlanLevel, error)
- func (q *PlanLevelQuery) Cursor(ctx context.Context, g auth.Grant) iter.Seq2[*PlanLevel, error]
- func (q *PlanLevelQuery) CursorPaginate(ctx context.Context, g auth.Grant, perPage int, cursor *pagination.Cursor, ...) (PlanLevelCollection, *pagination.CursorPage, error)
- func (q *PlanLevelQuery) Decrement(ctx context.Context, g auth.Grant, column string, amount any, ...) (int64, error)
- func (q *PlanLevelQuery) Delete(ctx context.Context, g auth.Grant) (int64, error)
- func (q *PlanLevelQuery) DoesntExist(ctx context.Context, g auth.Grant) (bool, error)
- func (q *PlanLevelQuery) DoesntHave(relation, boolean string, callback func(*query.Builder)) *PlanLevelQuery
- func (q *PlanLevelQuery) Each(ctx context.Context, g auth.Grant, count int, ...) error
- func (q *PlanLevelQuery) Exists(ctx context.Context, g auth.Grant) (bool, error)
- func (q *PlanLevelQuery) Find(ctx context.Context, g auth.Grant, id any, columns ...any) (*PlanLevel, error)
- func (q *PlanLevelQuery) FindMany(ctx context.Context, g auth.Grant, ids []any, columns ...any) (PlanLevelCollection, error)
- func (q *PlanLevelQuery) FindOrFail(ctx context.Context, g auth.Grant, id any, columns ...any) (*PlanLevel, error)
- func (q *PlanLevelQuery) FindOrNew(ctx context.Context, g auth.Grant, id any, columns ...any) (*PlanLevel, error)
- func (q *PlanLevelQuery) First(ctx context.Context, g auth.Grant, columns ...any) (*PlanLevel, error)
- func (q *PlanLevelQuery) FirstOrCreate(ctx context.Context, g auth.Grant, attributes, values map[string]any) (*PlanLevel, error)
- func (q *PlanLevelQuery) FirstOrFail(ctx context.Context, g auth.Grant, columns ...any) (*PlanLevel, error)
- func (q *PlanLevelQuery) FirstOrNew(ctx context.Context, g auth.Grant, attributes, values map[string]any) (*PlanLevel, error)
- func (q *PlanLevelQuery) FirstWhere(ctx context.Context, g auth.Grant, column any, args ...any) (*PlanLevel, error)
- func (q *PlanLevelQuery) ForPage(page, perPage int) *PlanLevelQuery
- func (q *PlanLevelQuery) ForceCreate(ctx context.Context, g auth.Grant, attributes map[string]any) (*PlanLevel, error)
- func (q *PlanLevelQuery) Get(ctx context.Context, g auth.Grant, columns ...any) (PlanLevelCollection, error)
- func (q *PlanLevelQuery) GroupBy(groups ...any) *PlanLevelQuery
- func (q *PlanLevelQuery) Has(relation, operator string, count int, boolean string, ...) *PlanLevelQuery
- func (q *PlanLevelQuery) Increment(ctx context.Context, g auth.Grant, column string, amount any, ...) (int64, error)
- func (q *PlanLevelQuery) Insert(ctx context.Context, g auth.Grant, values ...map[string]any) (bool, error)
- func (q *PlanLevelQuery) InsertOrIgnore(ctx context.Context, g auth.Grant, values ...map[string]any) (bool, error)
- func (q *PlanLevelQuery) Join(table any, first any, args ...any) *PlanLevelQuery
- func (q *PlanLevelQuery) Latest(column ...string) *PlanLevelQuery
- func (q *PlanLevelQuery) Limit(value int) *PlanLevelQuery
- func (q *PlanLevelQuery) Max(ctx context.Context, g auth.Grant, column any) (any, error)
- func (q *PlanLevelQuery) Min(ctx context.Context, g auth.Grant, column any) (any, error)
- func (q *PlanLevelQuery) New() (*PlanLevel, error)
- func (q *PlanLevelQuery) Offset(value int) *PlanLevelQuery
- func (q *PlanLevelQuery) Oldest(column ...string) *PlanLevelQuery
- func (q *PlanLevelQuery) OrDoesntHave(relation string) *PlanLevelQuery
- func (q *PlanLevelQuery) OrHas(relation, operator string, count int) *PlanLevelQuery
- func (q *PlanLevelQuery) OrWhere(column any, args ...any) *PlanLevelQuery
- func (q *PlanLevelQuery) OrWhereDoesntHave(relation string, callback func(*query.Builder)) *PlanLevelQuery
- func (q *PlanLevelQuery) OrWhereHas(relation string, callback func(*query.Builder)) *PlanLevelQuery
- func (q *PlanLevelQuery) OrWhereNot(column any, args ...any) *PlanLevelQuery
- func (q *PlanLevelQuery) OrWhereRelation(relation string, column any, args ...any) *PlanLevelQuery
- func (q *PlanLevelQuery) OrderBy(column any, direction ...string) *PlanLevelQuery
- func (q *PlanLevelQuery) OrderByDesc(column any) *PlanLevelQuery
- func (q *PlanLevelQuery) Paginate(ctx context.Context, g auth.Grant, perPage, page int, opts pagination.Options, ...) (PlanLevelCollection, *pagination.LengthAwarePage, error)
- func (q *PlanLevelQuery) Pluck(ctx context.Context, g auth.Grant, column string) ([]any, error)
- func (q *PlanLevelQuery) Select(columns ...any) *PlanLevelQuery
- func (q *PlanLevelQuery) SelectRaw(expression string, bindings ...any) *PlanLevelQuery
- func (q *PlanLevelQuery) SimplePaginate(ctx context.Context, g auth.Grant, perPage, page int, opts pagination.Options, ...) (PlanLevelCollection, *pagination.Page, error)
- func (q *PlanLevelQuery) Sole(ctx context.Context, g auth.Grant, columns ...any) (*PlanLevel, error)
- func (q *PlanLevelQuery) SoleValue(ctx context.Context, g auth.Grant, column string) (any, error)
- func (q *PlanLevelQuery) Sum(ctx context.Context, g auth.Grant, column any) (any, error)
- func (q *PlanLevelQuery) Touch(ctx context.Context, g auth.Grant, column ...string) (int64, error)
- func (q *PlanLevelQuery) Update(ctx context.Context, g auth.Grant, values map[string]any) (int64, error)
- func (q *PlanLevelQuery) UpdateOrCreate(ctx context.Context, g auth.Grant, attributes, values map[string]any) (*PlanLevel, error)
- func (q *PlanLevelQuery) Upsert(ctx context.Context, g auth.Grant, values []map[string]any, ...) (int64, error)
- func (q *PlanLevelQuery) Value(ctx context.Context, g auth.Grant, column string) (any, error)
- func (q *PlanLevelQuery) ValueOrFail(ctx context.Context, g auth.Grant, column string) (any, error)
- func (q *PlanLevelQuery) Where(column any, args ...any) *PlanLevelQuery
- func (q *PlanLevelQuery) WhereBelongsTo(relationshipName string, related ...model.Entity) *PlanLevelQuery
- func (q *PlanLevelQuery) WhereBetween(column any, from, to any) *PlanLevelQuery
- func (q *PlanLevelQuery) WhereColumn(first any, args ...any) *PlanLevelQuery
- func (q *PlanLevelQuery) WhereDoesntHave(relation string, callback func(*query.Builder)) *PlanLevelQuery
- func (q *PlanLevelQuery) WhereExists(callback func(*query.Builder)) *PlanLevelQuery
- func (q *PlanLevelQuery) WhereHas(relation string, callback func(*query.Builder)) *PlanLevelQuery
- func (q *PlanLevelQuery) WhereHasCount(relation string, callback func(*query.Builder), operator string, count int) *PlanLevelQuery
- func (q *PlanLevelQuery) WhereIn(column any, values []any) *PlanLevelQuery
- func (q *PlanLevelQuery) WhereKey(id any) *PlanLevelQuery
- func (q *PlanLevelQuery) WhereNot(column any, args ...any) *PlanLevelQuery
- func (q *PlanLevelQuery) WhereNotExists(callback func(*query.Builder)) *PlanLevelQuery
- func (q *PlanLevelQuery) WhereNotIn(column any, values []any) *PlanLevelQuery
- func (q *PlanLevelQuery) WhereNotNull(columns ...any) *PlanLevelQuery
- func (q *PlanLevelQuery) WhereNull(columns ...any) *PlanLevelQuery
- func (q *PlanLevelQuery) WhereRelation(relation string, column any, args ...any) *PlanLevelQuery
- func (q *PlanLevelQuery) With(relations ...string) *PlanLevelQuery
- func (q *PlanLevelQuery) WithAvg(relation, column string) *PlanLevelQuery
- func (q *PlanLevelQuery) WithCount(relations ...string) *PlanLevelQuery
- func (q *PlanLevelQuery) WithExists(relation string) *PlanLevelQuery
- func (q *PlanLevelQuery) WithMax(relation, column string) *PlanLevelQuery
- func (q *PlanLevelQuery) WithMin(relation, column string) *PlanLevelQuery
- func (q *PlanLevelQuery) WithSum(relation, column string) *PlanLevelQuery
- func (q *PlanLevelQuery) Without(relations ...string) *PlanLevelQuery
- func (q *PlanLevelQuery) WithoutGlobalScope(identifier string) *PlanLevelQuery
- func (q *PlanLevelQuery) WithoutGlobalScopes(identifiers ...string) *PlanLevelQuery
- type PlanQuery
- func (q *PlanQuery) AddSelect(columns ...any) *PlanQuery
- func (q *PlanQuery) Avg(ctx context.Context, g auth.Grant, column any) (any, error)
- func (q *PlanQuery) Base() *model.Builder
- func (q *PlanQuery) Chunk(ctx context.Context, g auth.Grant, count int, ...) error
- func (q *PlanQuery) Clone() *PlanQuery
- func (q *PlanQuery) Count(ctx context.Context, g auth.Grant, columns ...any) (int64, error)
- func (q *PlanQuery) Create(ctx context.Context, g auth.Grant, attributes map[string]any) (*Plan, error)
- func (q *PlanQuery) Cursor(ctx context.Context, g auth.Grant) iter.Seq2[*Plan, error]
- func (q *PlanQuery) CursorPaginate(ctx context.Context, g auth.Grant, perPage int, cursor *pagination.Cursor, ...) (PlanCollection, *pagination.CursorPage, error)
- func (q *PlanQuery) Decrement(ctx context.Context, g auth.Grant, column string, amount any, ...) (int64, error)
- func (q *PlanQuery) Delete(ctx context.Context, g auth.Grant) (int64, error)
- func (q *PlanQuery) DoesntExist(ctx context.Context, g auth.Grant) (bool, error)
- func (q *PlanQuery) DoesntHave(relation, boolean string, callback func(*query.Builder)) *PlanQuery
- func (q *PlanQuery) Each(ctx context.Context, g auth.Grant, count int, ...) error
- func (q *PlanQuery) Exists(ctx context.Context, g auth.Grant) (bool, error)
- func (q *PlanQuery) Find(ctx context.Context, g auth.Grant, id any, columns ...any) (*Plan, error)
- func (q *PlanQuery) FindMany(ctx context.Context, g auth.Grant, ids []any, columns ...any) (PlanCollection, error)
- func (q *PlanQuery) FindOrFail(ctx context.Context, g auth.Grant, id any, columns ...any) (*Plan, error)
- func (q *PlanQuery) FindOrNew(ctx context.Context, g auth.Grant, id any, columns ...any) (*Plan, error)
- func (q *PlanQuery) First(ctx context.Context, g auth.Grant, columns ...any) (*Plan, error)
- func (q *PlanQuery) FirstOrCreate(ctx context.Context, g auth.Grant, attributes, values map[string]any) (*Plan, error)
- func (q *PlanQuery) FirstOrFail(ctx context.Context, g auth.Grant, columns ...any) (*Plan, error)
- func (q *PlanQuery) FirstOrNew(ctx context.Context, g auth.Grant, attributes, values map[string]any) (*Plan, error)
- func (q *PlanQuery) FirstWhere(ctx context.Context, g auth.Grant, column any, args ...any) (*Plan, error)
- func (q *PlanQuery) ForPage(page, perPage int) *PlanQuery
- func (q *PlanQuery) ForceCreate(ctx context.Context, g auth.Grant, attributes map[string]any) (*Plan, error)
- func (q *PlanQuery) Get(ctx context.Context, g auth.Grant, columns ...any) (PlanCollection, error)
- func (q *PlanQuery) GroupBy(groups ...any) *PlanQuery
- func (q *PlanQuery) Has(relation, operator string, count int, boolean string, ...) *PlanQuery
- func (q *PlanQuery) Increment(ctx context.Context, g auth.Grant, column string, amount any, ...) (int64, error)
- func (q *PlanQuery) Insert(ctx context.Context, g auth.Grant, values ...map[string]any) (bool, error)
- func (q *PlanQuery) InsertOrIgnore(ctx context.Context, g auth.Grant, values ...map[string]any) (bool, error)
- func (q *PlanQuery) Join(table any, first any, args ...any) *PlanQuery
- func (q *PlanQuery) Latest(column ...string) *PlanQuery
- func (q *PlanQuery) Limit(value int) *PlanQuery
- func (q *PlanQuery) Max(ctx context.Context, g auth.Grant, column any) (any, error)
- func (q *PlanQuery) Min(ctx context.Context, g auth.Grant, column any) (any, error)
- func (q *PlanQuery) New() (*Plan, error)
- func (q *PlanQuery) Offset(value int) *PlanQuery
- func (q *PlanQuery) Oldest(column ...string) *PlanQuery
- func (q *PlanQuery) OrDoesntHave(relation string) *PlanQuery
- func (q *PlanQuery) OrHas(relation, operator string, count int) *PlanQuery
- func (q *PlanQuery) OrWhere(column any, args ...any) *PlanQuery
- func (q *PlanQuery) OrWhereDoesntHave(relation string, callback func(*query.Builder)) *PlanQuery
- func (q *PlanQuery) OrWhereHas(relation string, callback func(*query.Builder)) *PlanQuery
- func (q *PlanQuery) OrWhereNot(column any, args ...any) *PlanQuery
- func (q *PlanQuery) OrWhereRelation(relation string, column any, args ...any) *PlanQuery
- func (q *PlanQuery) OrderBy(column any, direction ...string) *PlanQuery
- func (q *PlanQuery) OrderByDesc(column any) *PlanQuery
- func (q *PlanQuery) Paginate(ctx context.Context, g auth.Grant, perPage, page int, opts pagination.Options, ...) (PlanCollection, *pagination.LengthAwarePage, error)
- func (q *PlanQuery) Pluck(ctx context.Context, g auth.Grant, column string) ([]any, error)
- func (q *PlanQuery) Select(columns ...any) *PlanQuery
- func (q *PlanQuery) SelectRaw(expression string, bindings ...any) *PlanQuery
- func (q *PlanQuery) SimplePaginate(ctx context.Context, g auth.Grant, perPage, page int, opts pagination.Options, ...) (PlanCollection, *pagination.Page, error)
- func (q *PlanQuery) Sole(ctx context.Context, g auth.Grant, columns ...any) (*Plan, error)
- func (q *PlanQuery) SoleValue(ctx context.Context, g auth.Grant, column string) (any, error)
- func (q *PlanQuery) Sum(ctx context.Context, g auth.Grant, column any) (any, error)
- func (q *PlanQuery) Touch(ctx context.Context, g auth.Grant, column ...string) (int64, error)
- func (q *PlanQuery) Update(ctx context.Context, g auth.Grant, values map[string]any) (int64, error)
- func (q *PlanQuery) UpdateOrCreate(ctx context.Context, g auth.Grant, attributes, values map[string]any) (*Plan, error)
- func (q *PlanQuery) Upsert(ctx context.Context, g auth.Grant, values []map[string]any, ...) (int64, error)
- func (q *PlanQuery) Value(ctx context.Context, g auth.Grant, column string) (any, error)
- func (q *PlanQuery) ValueOrFail(ctx context.Context, g auth.Grant, column string) (any, error)
- func (q *PlanQuery) Where(column any, args ...any) *PlanQuery
- func (q *PlanQuery) WhereBelongsTo(relationshipName string, related ...model.Entity) *PlanQuery
- func (q *PlanQuery) WhereBetween(column any, from, to any) *PlanQuery
- func (q *PlanQuery) WhereColumn(first any, args ...any) *PlanQuery
- func (q *PlanQuery) WhereDoesntHave(relation string, callback func(*query.Builder)) *PlanQuery
- func (q *PlanQuery) WhereExists(callback func(*query.Builder)) *PlanQuery
- func (q *PlanQuery) WhereHas(relation string, callback func(*query.Builder)) *PlanQuery
- func (q *PlanQuery) WhereHasCount(relation string, callback func(*query.Builder), operator string, count int) *PlanQuery
- func (q *PlanQuery) WhereIn(column any, values []any) *PlanQuery
- func (q *PlanQuery) WhereKey(id any) *PlanQuery
- func (q *PlanQuery) WhereNot(column any, args ...any) *PlanQuery
- func (q *PlanQuery) WhereNotExists(callback func(*query.Builder)) *PlanQuery
- func (q *PlanQuery) WhereNotIn(column any, values []any) *PlanQuery
- func (q *PlanQuery) WhereNotNull(columns ...any) *PlanQuery
- func (q *PlanQuery) WhereNull(columns ...any) *PlanQuery
- func (q *PlanQuery) WhereRelation(relation string, column any, args ...any) *PlanQuery
- func (q *PlanQuery) With(relations ...string) *PlanQuery
- func (q *PlanQuery) WithAvg(relation, column string) *PlanQuery
- func (q *PlanQuery) WithCount(relations ...string) *PlanQuery
- func (q *PlanQuery) WithExists(relation string) *PlanQuery
- func (q *PlanQuery) WithMax(relation, column string) *PlanQuery
- func (q *PlanQuery) WithMin(relation, column string) *PlanQuery
- func (q *PlanQuery) WithSum(relation, column string) *PlanQuery
- func (q *PlanQuery) Without(relations ...string) *PlanQuery
- func (q *PlanQuery) WithoutGlobalScope(identifier string) *PlanQuery
- func (q *PlanQuery) WithoutGlobalScopes(identifiers ...string) *PlanQuery
- type PlanRequest
- type PlanRow
- type PlanView
- type Referral
- type ReferralCollection
- func (c ReferralCollection) Contains(key any) bool
- func (c ReferralCollection) Except(keys ...any) ReferralCollection
- func (c ReferralCollection) Find(key any) *Referral
- func (c ReferralCollection) FindOrFail(key any) (*Referral, error)
- func (c ReferralCollection) Fresh(ctx context.Context, g auth.Grant, with ...string) (ReferralCollection, error)
- func (c ReferralCollection) Load(ctx context.Context, g auth.Grant, relations ...string) error
- func (c ReferralCollection) LoadCount(ctx context.Context, g auth.Grant, relations ...string) error
- func (c ReferralCollection) LoadMissing(ctx context.Context, g auth.Grant, relations ...string) error
- func (c ReferralCollection) ModelKeys() []any
- func (c ReferralCollection) Only(keys ...any) ReferralCollection
- func (c ReferralCollection) Pluck(column string) []any
- func (c ReferralCollection) Rows() model.Rows
- func (c ReferralCollection) ToArray() []map[string]any
- func (c ReferralCollection) Unique() ReferralCollection
- type ReferralQuery
- func (q *ReferralQuery) AddSelect(columns ...any) *ReferralQuery
- func (q *ReferralQuery) Avg(ctx context.Context, g auth.Grant, column any) (any, error)
- func (q *ReferralQuery) Base() *model.Builder
- func (q *ReferralQuery) Chunk(ctx context.Context, g auth.Grant, count int, ...) error
- func (q *ReferralQuery) Clone() *ReferralQuery
- func (q *ReferralQuery) Count(ctx context.Context, g auth.Grant, columns ...any) (int64, error)
- func (q *ReferralQuery) Create(ctx context.Context, g auth.Grant, attributes map[string]any) (*Referral, error)
- func (q *ReferralQuery) Cursor(ctx context.Context, g auth.Grant) iter.Seq2[*Referral, error]
- func (q *ReferralQuery) CursorPaginate(ctx context.Context, g auth.Grant, perPage int, cursor *pagination.Cursor, ...) (ReferralCollection, *pagination.CursorPage, error)
- func (q *ReferralQuery) Decrement(ctx context.Context, g auth.Grant, column string, amount any, ...) (int64, error)
- func (q *ReferralQuery) Delete(ctx context.Context, g auth.Grant) (int64, error)
- func (q *ReferralQuery) DoesntExist(ctx context.Context, g auth.Grant) (bool, error)
- func (q *ReferralQuery) DoesntHave(relation, boolean string, callback func(*query.Builder)) *ReferralQuery
- func (q *ReferralQuery) Each(ctx context.Context, g auth.Grant, count int, ...) error
- func (q *ReferralQuery) Exists(ctx context.Context, g auth.Grant) (bool, error)
- func (q *ReferralQuery) Find(ctx context.Context, g auth.Grant, id any, columns ...any) (*Referral, error)
- func (q *ReferralQuery) FindMany(ctx context.Context, g auth.Grant, ids []any, columns ...any) (ReferralCollection, error)
- func (q *ReferralQuery) FindOrFail(ctx context.Context, g auth.Grant, id any, columns ...any) (*Referral, error)
- func (q *ReferralQuery) FindOrNew(ctx context.Context, g auth.Grant, id any, columns ...any) (*Referral, error)
- func (q *ReferralQuery) First(ctx context.Context, g auth.Grant, columns ...any) (*Referral, error)
- func (q *ReferralQuery) FirstOrCreate(ctx context.Context, g auth.Grant, attributes, values map[string]any) (*Referral, error)
- func (q *ReferralQuery) FirstOrFail(ctx context.Context, g auth.Grant, columns ...any) (*Referral, error)
- func (q *ReferralQuery) FirstOrNew(ctx context.Context, g auth.Grant, attributes, values map[string]any) (*Referral, error)
- func (q *ReferralQuery) FirstWhere(ctx context.Context, g auth.Grant, column any, args ...any) (*Referral, error)
- func (q *ReferralQuery) ForPage(page, perPage int) *ReferralQuery
- func (q *ReferralQuery) ForceCreate(ctx context.Context, g auth.Grant, attributes map[string]any) (*Referral, error)
- func (q *ReferralQuery) Get(ctx context.Context, g auth.Grant, columns ...any) (ReferralCollection, error)
- func (q *ReferralQuery) GroupBy(groups ...any) *ReferralQuery
- func (q *ReferralQuery) Has(relation, operator string, count int, boolean string, ...) *ReferralQuery
- func (q *ReferralQuery) Increment(ctx context.Context, g auth.Grant, column string, amount any, ...) (int64, error)
- func (q *ReferralQuery) Insert(ctx context.Context, g auth.Grant, values ...map[string]any) (bool, error)
- func (q *ReferralQuery) InsertOrIgnore(ctx context.Context, g auth.Grant, values ...map[string]any) (bool, error)
- func (q *ReferralQuery) Join(table any, first any, args ...any) *ReferralQuery
- func (q *ReferralQuery) Latest(column ...string) *ReferralQuery
- func (q *ReferralQuery) Limit(value int) *ReferralQuery
- func (q *ReferralQuery) Max(ctx context.Context, g auth.Grant, column any) (any, error)
- func (q *ReferralQuery) Min(ctx context.Context, g auth.Grant, column any) (any, error)
- func (q *ReferralQuery) New() (*Referral, error)
- func (q *ReferralQuery) Offset(value int) *ReferralQuery
- func (q *ReferralQuery) Oldest(column ...string) *ReferralQuery
- func (q *ReferralQuery) OrDoesntHave(relation string) *ReferralQuery
- func (q *ReferralQuery) OrHas(relation, operator string, count int) *ReferralQuery
- func (q *ReferralQuery) OrWhere(column any, args ...any) *ReferralQuery
- func (q *ReferralQuery) OrWhereDoesntHave(relation string, callback func(*query.Builder)) *ReferralQuery
- func (q *ReferralQuery) OrWhereHas(relation string, callback func(*query.Builder)) *ReferralQuery
- func (q *ReferralQuery) OrWhereNot(column any, args ...any) *ReferralQuery
- func (q *ReferralQuery) OrWhereRelation(relation string, column any, args ...any) *ReferralQuery
- func (q *ReferralQuery) OrderBy(column any, direction ...string) *ReferralQuery
- func (q *ReferralQuery) OrderByDesc(column any) *ReferralQuery
- func (q *ReferralQuery) Paginate(ctx context.Context, g auth.Grant, perPage, page int, opts pagination.Options, ...) (ReferralCollection, *pagination.LengthAwarePage, error)
- func (q *ReferralQuery) Pluck(ctx context.Context, g auth.Grant, column string) ([]any, error)
- func (q *ReferralQuery) Select(columns ...any) *ReferralQuery
- func (q *ReferralQuery) SelectRaw(expression string, bindings ...any) *ReferralQuery
- func (q *ReferralQuery) SimplePaginate(ctx context.Context, g auth.Grant, perPage, page int, opts pagination.Options, ...) (ReferralCollection, *pagination.Page, error)
- func (q *ReferralQuery) Sole(ctx context.Context, g auth.Grant, columns ...any) (*Referral, error)
- func (q *ReferralQuery) SoleValue(ctx context.Context, g auth.Grant, column string) (any, error)
- func (q *ReferralQuery) Sum(ctx context.Context, g auth.Grant, column any) (any, error)
- func (q *ReferralQuery) Touch(ctx context.Context, g auth.Grant, column ...string) (int64, error)
- func (q *ReferralQuery) Update(ctx context.Context, g auth.Grant, values map[string]any) (int64, error)
- func (q *ReferralQuery) UpdateOrCreate(ctx context.Context, g auth.Grant, attributes, values map[string]any) (*Referral, error)
- func (q *ReferralQuery) Upsert(ctx context.Context, g auth.Grant, values []map[string]any, ...) (int64, error)
- func (q *ReferralQuery) Value(ctx context.Context, g auth.Grant, column string) (any, error)
- func (q *ReferralQuery) ValueOrFail(ctx context.Context, g auth.Grant, column string) (any, error)
- func (q *ReferralQuery) Where(column any, args ...any) *ReferralQuery
- func (q *ReferralQuery) WhereBelongsTo(relationshipName string, related ...model.Entity) *ReferralQuery
- func (q *ReferralQuery) WhereBetween(column any, from, to any) *ReferralQuery
- func (q *ReferralQuery) WhereColumn(first any, args ...any) *ReferralQuery
- func (q *ReferralQuery) WhereDoesntHave(relation string, callback func(*query.Builder)) *ReferralQuery
- func (q *ReferralQuery) WhereExists(callback func(*query.Builder)) *ReferralQuery
- func (q *ReferralQuery) WhereHas(relation string, callback func(*query.Builder)) *ReferralQuery
- func (q *ReferralQuery) WhereHasCount(relation string, callback func(*query.Builder), operator string, count int) *ReferralQuery
- func (q *ReferralQuery) WhereIn(column any, values []any) *ReferralQuery
- func (q *ReferralQuery) WhereKey(id any) *ReferralQuery
- func (q *ReferralQuery) WhereNot(column any, args ...any) *ReferralQuery
- func (q *ReferralQuery) WhereNotExists(callback func(*query.Builder)) *ReferralQuery
- func (q *ReferralQuery) WhereNotIn(column any, values []any) *ReferralQuery
- func (q *ReferralQuery) WhereNotNull(columns ...any) *ReferralQuery
- func (q *ReferralQuery) WhereNull(columns ...any) *ReferralQuery
- func (q *ReferralQuery) WhereRelation(relation string, column any, args ...any) *ReferralQuery
- func (q *ReferralQuery) With(relations ...string) *ReferralQuery
- func (q *ReferralQuery) WithAvg(relation, column string) *ReferralQuery
- func (q *ReferralQuery) WithCount(relations ...string) *ReferralQuery
- func (q *ReferralQuery) WithExists(relation string) *ReferralQuery
- func (q *ReferralQuery) WithMax(relation, column string) *ReferralQuery
- func (q *ReferralQuery) WithMin(relation, column string) *ReferralQuery
- func (q *ReferralQuery) WithSum(relation, column string) *ReferralQuery
- func (q *ReferralQuery) Without(relations ...string) *ReferralQuery
- func (q *ReferralQuery) WithoutGlobalScope(identifier string) *ReferralQuery
- func (q *ReferralQuery) WithoutGlobalScopes(identifiers ...string) *ReferralQuery
- type Screen
- func (s Screen) AdminNav(current string) template.HTML
- func (s Screen) AffiliateStatusOptions() []components.SelectOption
- func (s Screen) CellForm(action, label, variant string, inputs ...CellInput) template.HTML
- func (s Screen) CommissionStatusOptions() []components.SelectOption
- func (s Screen) Form() FormState
- func (s Screen) LevelOptions() []components.SelectOption
- func (s Screen) PayoutKindOptions() []components.SelectOption
- func (s Screen) PixKeyOptions() []components.SelectOption
- func (s Screen) PlanKindOptions() []components.SelectOption
- func (s Screen) TableLines() components.DataTableLines
- func (s Screen) WithdrawalStatusOptions() []components.SelectOption
- type Stats
- type TableState
- type TreeNode
- type TreeRow
- type WithdrawalDay
- type WithdrawalDayCollection
- func (c WithdrawalDayCollection) Contains(key any) bool
- func (c WithdrawalDayCollection) Except(keys ...any) WithdrawalDayCollection
- func (c WithdrawalDayCollection) Find(key any) *WithdrawalDay
- func (c WithdrawalDayCollection) FindOrFail(key any) (*WithdrawalDay, error)
- func (c WithdrawalDayCollection) Fresh(ctx context.Context, g auth.Grant, with ...string) (WithdrawalDayCollection, error)
- func (c WithdrawalDayCollection) Load(ctx context.Context, g auth.Grant, relations ...string) error
- func (c WithdrawalDayCollection) LoadCount(ctx context.Context, g auth.Grant, relations ...string) error
- func (c WithdrawalDayCollection) LoadMissing(ctx context.Context, g auth.Grant, relations ...string) error
- func (c WithdrawalDayCollection) ModelKeys() []any
- func (c WithdrawalDayCollection) Only(keys ...any) WithdrawalDayCollection
- func (c WithdrawalDayCollection) Pluck(column string) []any
- func (c WithdrawalDayCollection) Rows() model.Rows
- func (c WithdrawalDayCollection) ToArray() []map[string]any
- func (c WithdrawalDayCollection) Unique() WithdrawalDayCollection
- type WithdrawalDayQuery
- func (q *WithdrawalDayQuery) AddSelect(columns ...any) *WithdrawalDayQuery
- func (q *WithdrawalDayQuery) Avg(ctx context.Context, g auth.Grant, column any) (any, error)
- func (q *WithdrawalDayQuery) Base() *model.Builder
- func (q *WithdrawalDayQuery) Chunk(ctx context.Context, g auth.Grant, count int, ...) error
- func (q *WithdrawalDayQuery) Clone() *WithdrawalDayQuery
- func (q *WithdrawalDayQuery) Count(ctx context.Context, g auth.Grant, columns ...any) (int64, error)
- func (q *WithdrawalDayQuery) Create(ctx context.Context, g auth.Grant, attributes map[string]any) (*WithdrawalDay, error)
- func (q *WithdrawalDayQuery) Cursor(ctx context.Context, g auth.Grant) iter.Seq2[*WithdrawalDay, error]
- func (q *WithdrawalDayQuery) CursorPaginate(ctx context.Context, g auth.Grant, perPage int, cursor *pagination.Cursor, ...) (WithdrawalDayCollection, *pagination.CursorPage, error)
- func (q *WithdrawalDayQuery) Decrement(ctx context.Context, g auth.Grant, column string, amount any, ...) (int64, error)
- func (q *WithdrawalDayQuery) Delete(ctx context.Context, g auth.Grant) (int64, error)
- func (q *WithdrawalDayQuery) DoesntExist(ctx context.Context, g auth.Grant) (bool, error)
- func (q *WithdrawalDayQuery) DoesntHave(relation, boolean string, callback func(*query.Builder)) *WithdrawalDayQuery
- func (q *WithdrawalDayQuery) Each(ctx context.Context, g auth.Grant, count int, ...) error
- func (q *WithdrawalDayQuery) Exists(ctx context.Context, g auth.Grant) (bool, error)
- func (q *WithdrawalDayQuery) Find(ctx context.Context, g auth.Grant, id any, columns ...any) (*WithdrawalDay, error)
- func (q *WithdrawalDayQuery) FindMany(ctx context.Context, g auth.Grant, ids []any, columns ...any) (WithdrawalDayCollection, error)
- func (q *WithdrawalDayQuery) FindOrFail(ctx context.Context, g auth.Grant, id any, columns ...any) (*WithdrawalDay, error)
- func (q *WithdrawalDayQuery) FindOrNew(ctx context.Context, g auth.Grant, id any, columns ...any) (*WithdrawalDay, error)
- func (q *WithdrawalDayQuery) First(ctx context.Context, g auth.Grant, columns ...any) (*WithdrawalDay, error)
- func (q *WithdrawalDayQuery) FirstOrCreate(ctx context.Context, g auth.Grant, attributes, values map[string]any) (*WithdrawalDay, error)
- func (q *WithdrawalDayQuery) FirstOrFail(ctx context.Context, g auth.Grant, columns ...any) (*WithdrawalDay, error)
- func (q *WithdrawalDayQuery) FirstOrNew(ctx context.Context, g auth.Grant, attributes, values map[string]any) (*WithdrawalDay, error)
- func (q *WithdrawalDayQuery) FirstWhere(ctx context.Context, g auth.Grant, column any, args ...any) (*WithdrawalDay, error)
- func (q *WithdrawalDayQuery) ForPage(page, perPage int) *WithdrawalDayQuery
- func (q *WithdrawalDayQuery) ForceCreate(ctx context.Context, g auth.Grant, attributes map[string]any) (*WithdrawalDay, error)
- func (q *WithdrawalDayQuery) Get(ctx context.Context, g auth.Grant, columns ...any) (WithdrawalDayCollection, error)
- func (q *WithdrawalDayQuery) GroupBy(groups ...any) *WithdrawalDayQuery
- func (q *WithdrawalDayQuery) Has(relation, operator string, count int, boolean string, ...) *WithdrawalDayQuery
- func (q *WithdrawalDayQuery) Increment(ctx context.Context, g auth.Grant, column string, amount any, ...) (int64, error)
- func (q *WithdrawalDayQuery) Insert(ctx context.Context, g auth.Grant, values ...map[string]any) (bool, error)
- func (q *WithdrawalDayQuery) InsertOrIgnore(ctx context.Context, g auth.Grant, values ...map[string]any) (bool, error)
- func (q *WithdrawalDayQuery) Join(table any, first any, args ...any) *WithdrawalDayQuery
- func (q *WithdrawalDayQuery) Latest(column ...string) *WithdrawalDayQuery
- func (q *WithdrawalDayQuery) Limit(value int) *WithdrawalDayQuery
- func (q *WithdrawalDayQuery) Max(ctx context.Context, g auth.Grant, column any) (any, error)
- func (q *WithdrawalDayQuery) Min(ctx context.Context, g auth.Grant, column any) (any, error)
- func (q *WithdrawalDayQuery) New() (*WithdrawalDay, error)
- func (q *WithdrawalDayQuery) Offset(value int) *WithdrawalDayQuery
- func (q *WithdrawalDayQuery) Oldest(column ...string) *WithdrawalDayQuery
- func (q *WithdrawalDayQuery) OrDoesntHave(relation string) *WithdrawalDayQuery
- func (q *WithdrawalDayQuery) OrHas(relation, operator string, count int) *WithdrawalDayQuery
- func (q *WithdrawalDayQuery) OrWhere(column any, args ...any) *WithdrawalDayQuery
- func (q *WithdrawalDayQuery) OrWhereDoesntHave(relation string, callback func(*query.Builder)) *WithdrawalDayQuery
- func (q *WithdrawalDayQuery) OrWhereHas(relation string, callback func(*query.Builder)) *WithdrawalDayQuery
- func (q *WithdrawalDayQuery) OrWhereNot(column any, args ...any) *WithdrawalDayQuery
- func (q *WithdrawalDayQuery) OrWhereRelation(relation string, column any, args ...any) *WithdrawalDayQuery
- func (q *WithdrawalDayQuery) OrderBy(column any, direction ...string) *WithdrawalDayQuery
- func (q *WithdrawalDayQuery) OrderByDesc(column any) *WithdrawalDayQuery
- func (q *WithdrawalDayQuery) Paginate(ctx context.Context, g auth.Grant, perPage, page int, opts pagination.Options, ...) (WithdrawalDayCollection, *pagination.LengthAwarePage, error)
- func (q *WithdrawalDayQuery) Pluck(ctx context.Context, g auth.Grant, column string) ([]any, error)
- func (q *WithdrawalDayQuery) Select(columns ...any) *WithdrawalDayQuery
- func (q *WithdrawalDayQuery) SelectRaw(expression string, bindings ...any) *WithdrawalDayQuery
- func (q *WithdrawalDayQuery) SimplePaginate(ctx context.Context, g auth.Grant, perPage, page int, opts pagination.Options, ...) (WithdrawalDayCollection, *pagination.Page, error)
- func (q *WithdrawalDayQuery) Sole(ctx context.Context, g auth.Grant, columns ...any) (*WithdrawalDay, error)
- func (q *WithdrawalDayQuery) SoleValue(ctx context.Context, g auth.Grant, column string) (any, error)
- func (q *WithdrawalDayQuery) Sum(ctx context.Context, g auth.Grant, column any) (any, error)
- func (q *WithdrawalDayQuery) Touch(ctx context.Context, g auth.Grant, column ...string) (int64, error)
- func (q *WithdrawalDayQuery) Update(ctx context.Context, g auth.Grant, values map[string]any) (int64, error)
- func (q *WithdrawalDayQuery) UpdateOrCreate(ctx context.Context, g auth.Grant, attributes, values map[string]any) (*WithdrawalDay, error)
- func (q *WithdrawalDayQuery) Upsert(ctx context.Context, g auth.Grant, values []map[string]any, ...) (int64, error)
- func (q *WithdrawalDayQuery) Value(ctx context.Context, g auth.Grant, column string) (any, error)
- func (q *WithdrawalDayQuery) ValueOrFail(ctx context.Context, g auth.Grant, column string) (any, error)
- func (q *WithdrawalDayQuery) Where(column any, args ...any) *WithdrawalDayQuery
- func (q *WithdrawalDayQuery) WhereBelongsTo(relationshipName string, related ...model.Entity) *WithdrawalDayQuery
- func (q *WithdrawalDayQuery) WhereBetween(column any, from, to any) *WithdrawalDayQuery
- func (q *WithdrawalDayQuery) WhereColumn(first any, args ...any) *WithdrawalDayQuery
- func (q *WithdrawalDayQuery) WhereDoesntHave(relation string, callback func(*query.Builder)) *WithdrawalDayQuery
- func (q *WithdrawalDayQuery) WhereExists(callback func(*query.Builder)) *WithdrawalDayQuery
- func (q *WithdrawalDayQuery) WhereHas(relation string, callback func(*query.Builder)) *WithdrawalDayQuery
- func (q *WithdrawalDayQuery) WhereHasCount(relation string, callback func(*query.Builder), operator string, count int) *WithdrawalDayQuery
- func (q *WithdrawalDayQuery) WhereIn(column any, values []any) *WithdrawalDayQuery
- func (q *WithdrawalDayQuery) WhereKey(id any) *WithdrawalDayQuery
- func (q *WithdrawalDayQuery) WhereNot(column any, args ...any) *WithdrawalDayQuery
- func (q *WithdrawalDayQuery) WhereNotExists(callback func(*query.Builder)) *WithdrawalDayQuery
- func (q *WithdrawalDayQuery) WhereNotIn(column any, values []any) *WithdrawalDayQuery
- func (q *WithdrawalDayQuery) WhereNotNull(columns ...any) *WithdrawalDayQuery
- func (q *WithdrawalDayQuery) WhereNull(columns ...any) *WithdrawalDayQuery
- func (q *WithdrawalDayQuery) WhereRelation(relation string, column any, args ...any) *WithdrawalDayQuery
- func (q *WithdrawalDayQuery) With(relations ...string) *WithdrawalDayQuery
- func (q *WithdrawalDayQuery) WithAvg(relation, column string) *WithdrawalDayQuery
- func (q *WithdrawalDayQuery) WithCount(relations ...string) *WithdrawalDayQuery
- func (q *WithdrawalDayQuery) WithExists(relation string) *WithdrawalDayQuery
- func (q *WithdrawalDayQuery) WithMax(relation, column string) *WithdrawalDayQuery
- func (q *WithdrawalDayQuery) WithMin(relation, column string) *WithdrawalDayQuery
- func (q *WithdrawalDayQuery) WithSum(relation, column string) *WithdrawalDayQuery
- func (q *WithdrawalDayQuery) Without(relations ...string) *WithdrawalDayQuery
- func (q *WithdrawalDayQuery) WithoutGlobalScope(identifier string) *WithdrawalDayQuery
- func (q *WithdrawalDayQuery) WithoutGlobalScopes(identifiers ...string) *WithdrawalDayQuery
- type WithdrawalRequest
- type WithdrawalRow
Constants ¶
const ( // DefaultPrefix is where the panels are mounted when Config leaves Prefix // empty. DefaultPrefix = "/affiliate" // DefaultReferralPath is where the referral link answers: /r/{code}. DefaultReferralPath = "/r" // DefaultCookieName is the cookie the link sets and the sign-up reads. DefaultCookieName = "affiliate_ref" // DefaultCookieDays is how long the cookie lives when no plan is active. DefaultCookieDays = 30 // DefaultMinWithdrawal is the smallest withdrawal, in centavos, when no // plan is active: R$ 100,00. DefaultMinWithdrawal = 10000 // DefaultPageSize is how many rows one page answers with. DefaultPageSize = 25 // MaxPageSize is the most a page may be configured to answer with. MaxPageSize = 200 )
const ( // DashboardView is an affiliate reading their own panel: the link, the // plan, the numbers, the commissions, the balance and the withdrawals -- // and asking for a withdrawal or declaring a payout account of their own. DashboardView security.Action = "affiliate.dashboard.view" // PlansManage is defining the commission plans. PlansManage security.Action = "affiliate.plans.manage" // AffiliatesManage is the admin's side of the program: the affiliates, the // tree, blocking, the commissions and their reversal, the write-off of a // negative balance, the queue of withdrawals, and recording the payments // the commissions are paid on. AffiliatesManage security.Action = "affiliate.affiliates.manage" // ReferralRecord is recording what a visitor did with a referral link: the // click on /r/{code}, and the referral of the user who signed up with it. // The visitor has no session; the application's sign-up is the caller. ReferralRecord security.Action = "affiliate.referrals.record" )
The actions of the affiliate program. Constants rather than strings at the call site: a typo in an action name would silently authorize nothing, or worse, everything.
const ( // TranslationGroup is the file every key of this package lives in, and the // prefix of every key: "affiliate.screen.dashboard_title". TranslationGroup = "affiliate" // FallbackLocale answers a request that negotiated no locale. The package // is Brazilian first. FallbackLocale = "pt-BR" )
const ( ViewDashboard = "modules.affiliate.dashboard" ViewAdminPlans = "modules.affiliate.admin.plans" ViewAdminAffiliates = "modules.affiliate.admin.affiliates" ViewAdminAffiliate = "modules.affiliate.admin.affiliate" ViewAdminCommissions = "modules.affiliate.admin.commissions" ViewAdminWithdrawals = "modules.affiliate.admin.withdrawals" )
The screens this package renders, by the name their path gives them.
const AdminRole = "affiliate.admin"
AdminRole is the role that runs the program in its tenant. The application gives it through arandu-permission, which fills the Subject's roles.
const DayLayout = "2006-01-02"
DayLayout is how a Day is written.
const DefaultLocation = "America/Sao_Paulo"
DefaultLocation is the timezone days are counted in when Config leaves Location nil.
const MaxLevels = 4
MaxLevels is the deepest level a plan pays.
const PayoutVia = "affiliate"
PayoutVia is the name this package asks for its affiliates' withdrawals under, and the one their wallets are opened with: arandu-wallet refuses a request for those wallets that does not carry it, so the minimum, the maximum and one request a day cannot be stepped around.
const PublishCommand = "aru vendor:publish --apply"
PublishCommand is what an application runs to take ownership of the views.
const WalletSlug = "affiliate"
WalletSlug is the slug of the affiliate's wallet in arandu-wallet.
Variables ¶
var ( // ErrSelfReferral is an affiliate signing up with their own code. ErrSelfReferral = validation.Errors{"code": {"an affiliate cannot refer themselves"}} // ErrSameTree is a document, or a user, already in the referrer's tree. ErrSameTree = validation.Errors{"document": {"this person is already in the referrer's tree"}} // ErrDocumentReferred is a document another referral already carries. ErrDocumentReferred = validation.Errors{"document": {"this document was already referred"}} )
The refusals of a referral, each a reason the sign-up keeps going without one. They are validation errors: the application decides whether to tell the person.
var ( // ErrOnePerDay is a second withdrawal on a day that already has one. ErrOnePerDay = validation.Errors{"amount": {"one withdrawal a day; ask again tomorrow"}} // ErrNegativeBalance is a withdrawal while a reversed commission left the // balance below zero. ErrNegativeBalance = validation.Errors{"amount": {"the balance is below zero after a reversed commission; withdrawals open again once it is covered"}} // ErrBlocked is a blocked affiliate asking for money. ErrBlocked = forbidden("affiliate: a blocked affiliate cannot withdraw") )
The refusals of a withdrawal.
var ErrNotFound = fmt.Errorf("affiliate: record not found: %w", model.ErrModelNotFound)
ErrNotFound is a record the caller may not see or that does not exist. It wraps model.ErrModelNotFound, which the router answers with 404.
var ErrTaken = validation.Errors{"code": {"the user, the document or the code is already an affiliate's"}}
ErrTaken is a user, a document or a code that already belongs to an affiliate of the tenant.
var PayoutKindNames = []string{"pix", "bank", "crypto", "other"}
PayoutKindNames are PayoutKinds' keys in the order a form lists them.
var PayoutKinds = map[string][]string{
"pix": {"key_type", "key"},
"bank": {"bank", "agency", "account", "account_type"},
"crypto": {"network", "address"},
"other": {"description"},
}
PayoutKinds are the kinds of account an affiliate can be paid into, and the details each one takes.
Functions ¶
func CommissionOf ¶
CommissionOf is what a rate in basis points pays on an amount in centavos, rounded half up to the centavo.
func PublishedPaths ¶
func PublishedPaths() []string
PublishedPaths are the files in the archive, each relative to the root of the application, sorted.
func ViewNames ¶
func ViewNames() []string
ViewNames are the names the published views are rendered by, sorted.
The name is the path under the view root with its separators turned into dots, which is what the view compiler writes into the registration call. It is derived from the same archive the publication carries, so a view that was renamed cannot keep an old name here.
func ViewPackages ¶
func ViewPackages() []string
ViewPackages are the directories the compiled views land in, each relative to the root of the application, sorted and without repeats.
Importing one is what puts its views in the binary: a compiled view calls the registry from init(), and a package nothing imports is not linked at all. The import is named rather than written into bootstrap/app.go, because one line somebody reads beats a file that changed while they were not looking.
Types ¶
type AccountOption ¶
type AccountOption struct{ ID, Label string }
AccountOption is one payout account a withdrawal can be paid into.
type AccountRequest ¶
AccountRequest is a payout account an affiliate declares.
type AdminAffiliatePageData ¶
type AdminAffiliatePageData struct {
Screen
Affiliate AffiliateRow
Link string
Balance, Held, Available string
Negative bool
Clicks, Signups, Sales int64
Commissions string
Tree []TreeRow
BlockURL, WriteOffURL, CommissionsURL string
}
AdminAffiliatePageData is one affiliate, for the admin.
type AdminAffiliatesPageData ¶
type AdminAffiliatesPageData struct {
Screen
Rows []AffiliateRow
Status string
Table TableState
StoreURL string
}
AdminAffiliatesPageData is the admin's list of affiliates.
type AdminCommissionsPageData ¶
type AdminCommissionsPageData struct {
Screen
Rows []CommissionRow
Level, Status string
AffiliateID string
Table TableState
}
AdminCommissionsPageData is every commission, for the admin.
type AdminPlansPageData ¶
AdminPlansPageData is the plans, for the admin.
type AdminWithdrawalsPageData ¶
type AdminWithdrawalsPageData struct {
Screen
Rows []WithdrawalRow
Status string
URL string
}
AdminWithdrawalsPageData is the queue of affiliates' withdrawals.
type Affiliate ¶
type Affiliate struct {
model.Model
ID string `db:"id"`
TenantID string `db:"tenant_id"`
// UserID is the login user who signs in to the panel, unique per tenant.
UserID string `db:"user_id"`
// Code is what the referral link carries, unique per tenant.
Code string `db:"code"`
// Document is the CPF or the CNPJ, digits only, unique per tenant.
Document string `db:"document"`
// Name is how the affiliate is called on the screens and on a payout.
Name string `db:"name"`
// Status is whether the affiliate earns and withdraws. A blocked
// affiliate keeps their history and their place in the tree; their level
// is skipped when a commission is paid, and the levels above them still
// earn.
Status AffiliateStatus `db:"status"`
CreatedBy string `db:"created_by"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
}
Affiliate is somebody who refers people to the application and earns a commission on every payment those people make, and on the payments of the people they referred in turn, up to the levels the plan pays.
An affiliate is a login user with a code. The code is what the referral link carries -- /r/{code} -- and it is unique in its tenant. The document is the affiliate's CPF or CNPJ: it is what keeps one person from appearing twice in a referral tree, and the name every payout account of theirs has to be in.
func (*Affiliate) Fresh ¶
Fresh reads the row again, as a new Affiliate; it shadows the untyped one the embedded model promotes.
type AffiliateCollection ¶
type AffiliateCollection []*Affiliate
AffiliateCollection is rows of Affiliate, as a query returns them.
func AffiliateCollectionOf ¶
func AffiliateCollectionOf(rows model.Rows) AffiliateCollection
AffiliateCollectionOf converts rows of the table of Affiliate. A nil input is a nil collection.
func (AffiliateCollection) Contains ¶
func (c AffiliateCollection) Contains(key any) bool
func (AffiliateCollection) Except ¶
func (c AffiliateCollection) Except(keys ...any) AffiliateCollection
func (AffiliateCollection) Find ¶
func (c AffiliateCollection) Find(key any) *Affiliate
func (AffiliateCollection) FindOrFail ¶
func (c AffiliateCollection) FindOrFail(key any) (*Affiliate, error)
func (AffiliateCollection) Fresh ¶
func (c AffiliateCollection) Fresh(ctx context.Context, g auth.Grant, with ...string) (AffiliateCollection, error)
func (AffiliateCollection) LoadMissing ¶
func (AffiliateCollection) ModelKeys ¶
func (c AffiliateCollection) ModelKeys() []any
func (AffiliateCollection) Only ¶
func (c AffiliateCollection) Only(keys ...any) AffiliateCollection
func (AffiliateCollection) Pluck ¶
func (c AffiliateCollection) Pluck(column string) []any
func (AffiliateCollection) Rows ¶
func (c AffiliateCollection) Rows() model.Rows
Rows converts the collection back to the core's rows.
func (AffiliateCollection) ToArray ¶
func (c AffiliateCollection) ToArray() []map[string]any
func (AffiliateCollection) Unique ¶
func (c AffiliateCollection) Unique() AffiliateCollection
type AffiliatePolicy ¶
type AffiliatePolicy struct{}
AffiliatePolicy is the only authority over who does what in the program.
It denies unless a rule below allows. The admin role manages the program in its own tenant; an affiliate reads only their own row; a visitor -- with or without a session -- may record a click and a referral and nothing else.
func (AffiliatePolicy) Can ¶
func (AffiliatePolicy) Can(ctx context.Context, s security.Subject, a security.Action, record Affiliate) error
Can decides whether the subject may perform the action on the record.
It is the only place that decides. The service reaches the Model only after Authorize turns this method's nil result into a Grant.
type AffiliateQuery ¶
type AffiliateQuery struct {
// contains filtered or unexported fields
}
AffiliateQuery is a query on the table of Affiliate.
The methods that build return the query, so they chain. The methods that run take a context and an auth.Grant, and return Affiliate rows or a value; there is no way to run one without a Grant.
func Affiliates ¶
func Affiliates(db model.DB) *AffiliateQuery
Affiliates starts a query on the table of Affiliate, through db.
Global scopes are on and, unless the table is Global, every statement is filtered by the tenant of the Grant its terminal takes.
func (*AffiliateQuery) AddSelect ¶
func (q *AffiliateQuery) AddSelect(columns ...any) *AffiliateQuery
func (*AffiliateQuery) Base ¶
func (q *AffiliateQuery) Base() *model.Builder
Base returns the core builder the query forwards to. It is for code in this package -- a local scope in the custom block of model.go -- and for the factory, which builds rows through it.
func (*AffiliateQuery) Clone ¶
func (q *AffiliateQuery) Clone() *AffiliateQuery
Clone returns an independent copy of the query.
func (*AffiliateQuery) CursorPaginate ¶
func (q *AffiliateQuery) CursorPaginate(ctx context.Context, g auth.Grant, perPage int, cursor *pagination.Cursor, opts pagination.Options, columns ...any) (AffiliateCollection, *pagination.CursorPage, error)
func (*AffiliateQuery) DoesntExist ¶
func (*AffiliateQuery) DoesntHave ¶
func (q *AffiliateQuery) DoesntHave(relation, boolean string, callback func(*query.Builder)) *AffiliateQuery
func (*AffiliateQuery) FindMany ¶
func (q *AffiliateQuery) FindMany(ctx context.Context, g auth.Grant, ids []any, columns ...any) (AffiliateCollection, error)
func (*AffiliateQuery) FindOrFail ¶
func (*AffiliateQuery) First ¶
func (q *AffiliateQuery) First(ctx context.Context, g auth.Grant, columns ...any) (*Affiliate, error)
First returns the first row, or nil and no error when there is none.
func (*AffiliateQuery) FirstOrCreate ¶
func (*AffiliateQuery) FirstOrFail ¶
func (*AffiliateQuery) FirstOrNew ¶
func (*AffiliateQuery) FirstWhere ¶
func (*AffiliateQuery) ForPage ¶
func (q *AffiliateQuery) ForPage(page, perPage int) *AffiliateQuery
func (*AffiliateQuery) ForceCreate ¶
func (*AffiliateQuery) Get ¶
func (q *AffiliateQuery) Get(ctx context.Context, g auth.Grant, columns ...any) (AffiliateCollection, error)
Get runs the query and returns the rows.
func (*AffiliateQuery) GroupBy ¶
func (q *AffiliateQuery) GroupBy(groups ...any) *AffiliateQuery
func (*AffiliateQuery) Has ¶
func (q *AffiliateQuery) Has(relation, operator string, count int, boolean string, callback func(*query.Builder)) *AffiliateQuery
func (*AffiliateQuery) InsertOrIgnore ¶
func (*AffiliateQuery) Join ¶
func (q *AffiliateQuery) Join(table any, first any, args ...any) *AffiliateQuery
func (*AffiliateQuery) Latest ¶
func (q *AffiliateQuery) Latest(column ...string) *AffiliateQuery
func (*AffiliateQuery) Limit ¶
func (q *AffiliateQuery) Limit(value int) *AffiliateQuery
func (*AffiliateQuery) New ¶
func (q *AffiliateQuery) New() (*Affiliate, error)
New returns an empty Affiliate on the query's connection, not yet saved, filled with what WithAttributes recorded on the query.
func (*AffiliateQuery) Offset ¶
func (q *AffiliateQuery) Offset(value int) *AffiliateQuery
func (*AffiliateQuery) Oldest ¶
func (q *AffiliateQuery) Oldest(column ...string) *AffiliateQuery
func (*AffiliateQuery) OrDoesntHave ¶
func (q *AffiliateQuery) OrDoesntHave(relation string) *AffiliateQuery
func (*AffiliateQuery) OrHas ¶
func (q *AffiliateQuery) OrHas(relation, operator string, count int) *AffiliateQuery
func (*AffiliateQuery) OrWhere ¶
func (q *AffiliateQuery) OrWhere(column any, args ...any) *AffiliateQuery
OrWhere adds an or-where clause; a func(*AffiliateQuery) in place of the column adds a group.
func (*AffiliateQuery) OrWhereDoesntHave ¶
func (q *AffiliateQuery) OrWhereDoesntHave(relation string, callback func(*query.Builder)) *AffiliateQuery
func (*AffiliateQuery) OrWhereHas ¶
func (q *AffiliateQuery) OrWhereHas(relation string, callback func(*query.Builder)) *AffiliateQuery
func (*AffiliateQuery) OrWhereNot ¶
func (q *AffiliateQuery) OrWhereNot(column any, args ...any) *AffiliateQuery
OrWhereNot adds an or-joined negated where clause, or a negated group.
func (*AffiliateQuery) OrWhereRelation ¶
func (q *AffiliateQuery) OrWhereRelation(relation string, column any, args ...any) *AffiliateQuery
func (*AffiliateQuery) OrderBy ¶
func (q *AffiliateQuery) OrderBy(column any, direction ...string) *AffiliateQuery
func (*AffiliateQuery) OrderByDesc ¶
func (q *AffiliateQuery) OrderByDesc(column any) *AffiliateQuery
func (*AffiliateQuery) Paginate ¶
func (q *AffiliateQuery) Paginate(ctx context.Context, g auth.Grant, perPage, page int, opts pagination.Options, columns ...any) (AffiliateCollection, *pagination.LengthAwarePage, error)
func (*AffiliateQuery) Select ¶
func (q *AffiliateQuery) Select(columns ...any) *AffiliateQuery
func (*AffiliateQuery) SelectRaw ¶
func (q *AffiliateQuery) SelectRaw(expression string, bindings ...any) *AffiliateQuery
func (*AffiliateQuery) SimplePaginate ¶
func (q *AffiliateQuery) SimplePaginate(ctx context.Context, g auth.Grant, perPage, page int, opts pagination.Options, columns ...any) (AffiliateCollection, *pagination.Page, error)
func (*AffiliateQuery) UpdateOrCreate ¶
func (*AffiliateQuery) ValueOrFail ¶
func (*AffiliateQuery) Where ¶
func (q *AffiliateQuery) Where(column any, args ...any) *AffiliateQuery
Where adds a where clause; a func(*AffiliateQuery) in place of the column adds a group.
func (*AffiliateQuery) WhereBelongsTo ¶
func (q *AffiliateQuery) WhereBelongsTo(relationshipName string, related ...model.Entity) *AffiliateQuery
func (*AffiliateQuery) WhereBetween ¶
func (q *AffiliateQuery) WhereBetween(column any, from, to any) *AffiliateQuery
func (*AffiliateQuery) WhereColumn ¶
func (q *AffiliateQuery) WhereColumn(first any, args ...any) *AffiliateQuery
func (*AffiliateQuery) WhereDoesntHave ¶
func (q *AffiliateQuery) WhereDoesntHave(relation string, callback func(*query.Builder)) *AffiliateQuery
func (*AffiliateQuery) WhereExists ¶
func (q *AffiliateQuery) WhereExists(callback func(*query.Builder)) *AffiliateQuery
func (*AffiliateQuery) WhereHas ¶
func (q *AffiliateQuery) WhereHas(relation string, callback func(*query.Builder)) *AffiliateQuery
func (*AffiliateQuery) WhereHasCount ¶
func (q *AffiliateQuery) WhereHasCount(relation string, callback func(*query.Builder), operator string, count int) *AffiliateQuery
func (*AffiliateQuery) WhereIn ¶
func (q *AffiliateQuery) WhereIn(column any, values []any) *AffiliateQuery
func (*AffiliateQuery) WhereKey ¶
func (q *AffiliateQuery) WhereKey(id any) *AffiliateQuery
func (*AffiliateQuery) WhereNot ¶
func (q *AffiliateQuery) WhereNot(column any, args ...any) *AffiliateQuery
WhereNot adds a negated where clause, or a negated group.
func (*AffiliateQuery) WhereNotExists ¶
func (q *AffiliateQuery) WhereNotExists(callback func(*query.Builder)) *AffiliateQuery
func (*AffiliateQuery) WhereNotIn ¶
func (q *AffiliateQuery) WhereNotIn(column any, values []any) *AffiliateQuery
func (*AffiliateQuery) WhereNotNull ¶
func (q *AffiliateQuery) WhereNotNull(columns ...any) *AffiliateQuery
func (*AffiliateQuery) WhereNull ¶
func (q *AffiliateQuery) WhereNull(columns ...any) *AffiliateQuery
func (*AffiliateQuery) WhereRelation ¶
func (q *AffiliateQuery) WhereRelation(relation string, column any, args ...any) *AffiliateQuery
func (*AffiliateQuery) With ¶
func (q *AffiliateQuery) With(relations ...string) *AffiliateQuery
func (*AffiliateQuery) WithAvg ¶
func (q *AffiliateQuery) WithAvg(relation, column string) *AffiliateQuery
func (*AffiliateQuery) WithCount ¶
func (q *AffiliateQuery) WithCount(relations ...string) *AffiliateQuery
func (*AffiliateQuery) WithExists ¶
func (q *AffiliateQuery) WithExists(relation string) *AffiliateQuery
func (*AffiliateQuery) WithMax ¶
func (q *AffiliateQuery) WithMax(relation, column string) *AffiliateQuery
func (*AffiliateQuery) WithMin ¶
func (q *AffiliateQuery) WithMin(relation, column string) *AffiliateQuery
func (*AffiliateQuery) WithSum ¶
func (q *AffiliateQuery) WithSum(relation, column string) *AffiliateQuery
func (*AffiliateQuery) Without ¶
func (q *AffiliateQuery) Without(relations ...string) *AffiliateQuery
func (*AffiliateQuery) WithoutGlobalScope ¶
func (q *AffiliateQuery) WithoutGlobalScope(identifier string) *AffiliateQuery
func (*AffiliateQuery) WithoutGlobalScopes ¶
func (q *AffiliateQuery) WithoutGlobalScopes(identifiers ...string) *AffiliateQuery
type AffiliateRow ¶
type AffiliateRow struct {
ID, Name, Code, Document, User, Status, StatusKey, Created, URL string
Active bool
}
AffiliateRow is one affiliate in the admin's list.
type AffiliateService ¶
type AffiliateService struct {
// contains filtered or unexported fields
}
AffiliateService is the program's use cases. It owns the database handle; every exported method asks the policy before it reads or writes, and every statement carries the tenant of the Grant the policy issued.
func NewAffiliateService ¶
func NewAffiliateService(db *data.DB) *AffiliateService
NewAffiliateService returns the use cases over a database handle. New wires the rest; a test may build one directly.
func (*AffiliateService) ActivatePlan ¶
func (s *AffiliateService) ActivatePlan(ctx context.Context, actor security.Subject, id string) (*PlanView, error)
ActivatePlan makes a plan the one new conversions are paid by.
func (*AffiliateService) ActivePlan ¶
func (s *AffiliateService) ActivePlan(ctx context.Context, actor security.Subject) (*PlanView, error)
ActivePlan is the plan in force, for anybody who reads a panel: an affiliate consults it, never changes it. Nil when no plan is active.
func (*AffiliateService) AddPayoutAccount ¶
func (s *AffiliateService) AddPayoutAccount(ctx context.Context, actor security.Subject, in AccountRequest) (*wallet.PayoutAccount, error)
AddPayoutAccount declares an account the asking affiliate is paid into, in the name and the document of their registration: an affiliate is paid into an account of their own, never a third party's.
func (*AffiliateService) AffiliatesPage ¶
func (s *AffiliateService) AffiliatesPage(ctx context.Context, actor security.Subject, q AffiliatesQuery) ([]*Affiliate, int, error)
AffiliatesPage is a page of the admin's list and how many rows it has.
func (*AffiliateService) Attribute ¶
func (s *AffiliateService) Attribute(ctx context.Context, actor security.Subject, in AttributeRequest) (*Referral, error)
Attribute links a user who signed up with a referral code to the affiliate who owns it, for life. It is called by the application's sign-up, with whatever subject it signs up as -- a guest of the tenant included.
A user who already has a referrer keeps them: the answer is the existing referral, unchanged. An empty code records nothing and answers nil. A code that is no active affiliate's, an affiliate's own code, or a person already in the referrer's tree is refused, and the sign-up goes on without a referrer.
func (*AffiliateService) BalanceOf ¶
func (s *AffiliateService) BalanceOf(ctx context.Context, actor security.Subject, affiliateID string) (Balance, error)
BalanceOf is an affiliate's balance, for themselves and for the admin.
func (*AffiliateService) CommissionsPage ¶
func (s *AffiliateService) CommissionsPage(ctx context.Context, actor security.Subject, q CommissionsQuery) ([]CommissionView, int, error)
CommissionsPage is a page of commissions and how many the list has: an affiliate's own, or, for the admin, anybody's.
func (*AffiliateService) Create ¶
func (s *AffiliateService) Create(ctx context.Context, actor security.Subject, in CreateRequest) (*Affiliate, error)
Create registers an affiliate.
func (*AffiliateService) CreatePlan ¶
func (s *AffiliateService) CreatePlan(ctx context.Context, actor security.Subject, in PlanRequest, activate bool) (*PlanView, error)
CreatePlan defines a plan, and makes it the active one when activate is set. A plan is never edited: a new one is defined and activated, and every commission keeps the plan that paid it.
func (*AffiliateService) Find ¶
func (s *AffiliateService) Find(ctx context.Context, actor security.Subject, id string) (*Affiliate, error)
Find answers one affiliate, for the admin.
func (*AffiliateService) MyWithdrawals ¶
func (s *AffiliateService) MyWithdrawals(ctx context.Context, actor security.Subject) ([]*wallet.WithdrawalRequest, error)
MyWithdrawals are the asking affiliate's withdrawal requests, newest first.
func (*AffiliateService) PayWithdrawal ¶
func (s *AffiliateService) PayWithdrawal(ctx context.Context, actor security.Subject, in wallet.PaymentInput, receipt io.Reader) (*wallet.WithdrawalRequest, error)
PayWithdrawal records that the operator paid an affiliate's withdrawal, with the end-to-end identifier and the receipt.
func (*AffiliateService) PayoutAccounts ¶
func (s *AffiliateService) PayoutAccounts(ctx context.Context, actor security.Subject, affiliateID string) ([]*wallet.PayoutAccount, error)
PayoutAccounts are an affiliate's accounts, for themselves and the admin.
func (*AffiliateService) RecordClick ¶
func (s *AffiliateService) RecordClick(ctx context.Context, actor security.Subject, in ClickRequest) (*Affiliate, int, error)
RecordClick records that a referral link was opened and answers the affiliate it belongs to and how many days the cookie lives. A code that is no active affiliate's records nothing and answers no affiliate: the link still lands, and sets no cookie.
func (*AffiliateService) RecordConversion ¶
func (s *AffiliateService) RecordConversion(ctx context.Context, actor security.Subject, in ConversionRequest) (*Conversion, []*Commission, error)
RecordConversion records a payment of a user and pays every level of the tree above them, by the plan active now: the buyer's referrer is level one, the referrer's referrer level two, and so on. A blocked affiliate's level is skipped and the levels above still earn. Each commission is deposited in the affiliate's wallet at once.
It is idempotent by OrderRef: a payment reported again answers what the first report recorded. A buyer with no referrer, or a payment with no plan active, is recorded and pays nothing.
func (*AffiliateService) RecordRefund ¶
func (s *AffiliateService) RecordRefund(ctx context.Context, actor security.Subject, orderRef, reason string) (*Conversion, error)
RecordRefund records that a payment was given back, and reverses every commission it paid. The money leaves each wallet whatever its balance: a commission already withdrawn leaves the balance below zero, which blocks withdrawals until later commissions, or the admin's write-off, cover it. Refunding twice changes nothing.
func (*AffiliateService) RejectWithdrawal ¶
func (s *AffiliateService) RejectWithdrawal(ctx context.Context, actor security.Subject, requestID, reason string) (*wallet.WithdrawalRequest, error)
RejectWithdrawal refuses an affiliate's withdrawal with the reason they read. The amount goes back to the balance, and the day is free again.
func (*AffiliateService) RequestWithdrawal ¶
func (s *AffiliateService) RequestWithdrawal(ctx context.Context, actor security.Subject, in WithdrawalRequest) (*wallet.WithdrawalRequest, error)
RequestWithdrawal asks for an affiliate's money: any amount between the plan's minimum and maximum, up to what is available, at most once a day, never while the balance is below zero. arandu-wallet holds the amount until the operator pays it or refuses it; a refused or cancelled request frees the day.
func (*AffiliateService) ReverseCommission ¶
func (s *AffiliateService) ReverseCommission(ctx context.Context, actor security.Subject, commissionID, reason string) (*Commission, error)
ReverseCommission takes one commission back, by the admin's hand, with the reason the affiliate reads.
func (*AffiliateService) SetBlocked ¶
func (s *AffiliateService) SetBlocked(ctx context.Context, actor security.Subject, id string, blocked bool) (*Affiliate, error)
SetBlocked blocks an affiliate, or unblocks one. A blocked affiliate earns nothing new and cannot withdraw; their history and their place in the tree stay.
func (*AffiliateService) StartPaying ¶
func (s *AffiliateService) StartPaying(ctx context.Context, actor security.Subject, requestID string) (*wallet.WithdrawalRequest, error)
StartPaying is the operator taking an affiliate's withdrawal to pay it.
func (*AffiliateService) StatsOf ¶
func (s *AffiliateService) StatsOf(ctx context.Context, actor security.Subject, affiliateID string, from, to Day) (Stats, error)
StatsOf counts an affiliate's clicks, sign-ups and sales in [from, to], and sums the commissions they earned in it.
func (*AffiliateService) Tree ¶
func (s *AffiliateService) Tree(ctx context.Context, actor security.Subject, affiliateID string) ([]TreeNode, error)
Tree is an affiliate's tree, down to MaxLevels: the users they referred, and, for those who are affiliates themselves, the users those referred.
func (*AffiliateService) Upline ¶
func (s *AffiliateService) Upline(ctx context.Context, actor security.Subject, userID string) ([]*Affiliate, error)
Upline is who earns on a user's payments: the user's referrer first, then the referrer's, up to MaxLevels. Empty for a user nobody referred.
func (*AffiliateService) WithdrawalReceipt ¶
func (s *AffiliateService) WithdrawalReceipt(ctx context.Context, actor security.Subject, requestID string) (*wallet.WithdrawalRequest, filesystem.File, error)
WithdrawalReceipt opens the receipt of a paid withdrawal, for the affiliate it paid and for the admin. The caller closes the body.
func (*AffiliateService) Withdrawals ¶
func (s *AffiliateService) Withdrawals(ctx context.Context, actor security.Subject, status wallet.WithdrawalStatus) ([]AffiliateWithdrawal, error)
Withdrawals is the operator's queue of affiliates' withdrawals: the requests arandu-wallet holds that this package asked for.
func (*AffiliateService) WriteOff ¶
func (s *AffiliateService) WriteOff(ctx context.Context, actor security.Subject, affiliateID, reason string) (int64, error)
WriteOff forgives an affiliate's negative balance: a deposit of what is missing, recorded in the ledger with the admin's reason. It answers the centavos written off, zero when the balance was not negative.
type AffiliateStatus ¶
type AffiliateStatus string
AffiliateStatus is whether an affiliate earns and withdraws.
const ( // AffiliateActive earns commissions and withdraws them. AffiliateActive AffiliateStatus = "active" // AffiliateBlocked earns nothing new and cannot withdraw. AffiliateBlocked AffiliateStatus = "blocked" )
type AffiliateWithdrawal ¶
type AffiliateWithdrawal struct {
Request *wallet.WithdrawalRequest
Affiliate *Affiliate
}
AffiliateWithdrawal is one affiliate's withdrawal request in the operator's queue.
type AffiliatesQuery ¶
type AffiliatesQuery struct {
Search string
Status AffiliateStatus
Sort string
Dir string
Page int
PerPage int
}
AffiliatesQuery narrows the admin's list. Page counts from one.
type AttributeRequest ¶
type AttributeRequest struct {
// UserID is the user who just signed up.
UserID string
// Code is the referral code, from the cookie the link set (CodeFrom).
Code string
// Document is the user's CPF or CNPJ, when the application has it.
// Without it, the tree is guarded by the user alone.
Document string
}
AttributeRequest is what a sign-up with a referral code records.
type Balance ¶
type Balance struct {
// Balance is what the wallet holds, negative after a reversal of money
// already withdrawn.
Balance int64
// Held is what open withdrawal requests set aside.
Held int64
// Available is what can be asked for now.
Available int64
}
Balance is an affiliate's money as the panel shows it, in centavos.
type Click ¶
type Click struct {
model.Model
ID string `db:"id"`
TenantID string `db:"tenant_id"`
AffiliateID string `db:"affiliate_id"`
At time.Time `db:"at"`
LandingURL string `db:"landing_url"`
IPHash string `db:"ip_hash"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
}
Click is one opening of a referral link. The address is kept only as a hash, with the tenant in it, so a click can be told apart from another and nobody's address is stored.
type ClickCollection ¶
type ClickCollection []*Click
ClickCollection is rows of Click, as a query returns them.
func ClickCollectionOf ¶
func ClickCollectionOf(rows model.Rows) ClickCollection
ClickCollectionOf converts rows of the table of Click. A nil input is a nil collection.
func (ClickCollection) Contains ¶
func (c ClickCollection) Contains(key any) bool
func (ClickCollection) Except ¶
func (c ClickCollection) Except(keys ...any) ClickCollection
func (ClickCollection) Find ¶
func (c ClickCollection) Find(key any) *Click
func (ClickCollection) FindOrFail ¶
func (c ClickCollection) FindOrFail(key any) (*Click, error)
func (ClickCollection) Fresh ¶
func (c ClickCollection) Fresh(ctx context.Context, g auth.Grant, with ...string) (ClickCollection, error)
func (ClickCollection) LoadMissing ¶
func (ClickCollection) ModelKeys ¶
func (c ClickCollection) ModelKeys() []any
func (ClickCollection) Only ¶
func (c ClickCollection) Only(keys ...any) ClickCollection
func (ClickCollection) Pluck ¶
func (c ClickCollection) Pluck(column string) []any
func (ClickCollection) Rows ¶
func (c ClickCollection) Rows() model.Rows
Rows converts the collection back to the core's rows.
func (ClickCollection) ToArray ¶
func (c ClickCollection) ToArray() []map[string]any
func (ClickCollection) Unique ¶
func (c ClickCollection) Unique() ClickCollection
type ClickQuery ¶
type ClickQuery struct {
// contains filtered or unexported fields
}
ClickQuery is a query on the table of Click.
The methods that build return the query, so they chain. The methods that run take a context and an auth.Grant, and return Click rows or a value; there is no way to run one without a Grant.
func Clicks ¶
func Clicks(db model.DB) *ClickQuery
Clicks starts a query on the table of Click, through db.
Global scopes are on and, unless the table is Global, every statement is filtered by the tenant of the Grant its terminal takes.
func (*ClickQuery) AddSelect ¶
func (q *ClickQuery) AddSelect(columns ...any) *ClickQuery
func (*ClickQuery) Base ¶
func (q *ClickQuery) Base() *model.Builder
Base returns the core builder the query forwards to. It is for code in this package -- a local scope in the custom block of referral.go -- and for the factory, which builds rows through it.
func (*ClickQuery) Clone ¶
func (q *ClickQuery) Clone() *ClickQuery
Clone returns an independent copy of the query.
func (*ClickQuery) CursorPaginate ¶
func (q *ClickQuery) CursorPaginate(ctx context.Context, g auth.Grant, perPage int, cursor *pagination.Cursor, opts pagination.Options, columns ...any) (ClickCollection, *pagination.CursorPage, error)
func (*ClickQuery) DoesntExist ¶
func (*ClickQuery) DoesntHave ¶
func (q *ClickQuery) DoesntHave(relation, boolean string, callback func(*query.Builder)) *ClickQuery
func (*ClickQuery) FindMany ¶
func (q *ClickQuery) FindMany(ctx context.Context, g auth.Grant, ids []any, columns ...any) (ClickCollection, error)
func (*ClickQuery) FindOrFail ¶
func (*ClickQuery) FirstOrCreate ¶
func (*ClickQuery) FirstOrFail ¶
func (*ClickQuery) FirstOrNew ¶
func (*ClickQuery) FirstWhere ¶
func (*ClickQuery) ForPage ¶
func (q *ClickQuery) ForPage(page, perPage int) *ClickQuery
func (*ClickQuery) ForceCreate ¶
func (*ClickQuery) Get ¶
func (q *ClickQuery) Get(ctx context.Context, g auth.Grant, columns ...any) (ClickCollection, error)
Get runs the query and returns the rows.
func (*ClickQuery) GroupBy ¶
func (q *ClickQuery) GroupBy(groups ...any) *ClickQuery
func (*ClickQuery) Has ¶
func (q *ClickQuery) Has(relation, operator string, count int, boolean string, callback func(*query.Builder)) *ClickQuery
func (*ClickQuery) InsertOrIgnore ¶
func (*ClickQuery) Join ¶
func (q *ClickQuery) Join(table any, first any, args ...any) *ClickQuery
func (*ClickQuery) Latest ¶
func (q *ClickQuery) Latest(column ...string) *ClickQuery
func (*ClickQuery) Limit ¶
func (q *ClickQuery) Limit(value int) *ClickQuery
func (*ClickQuery) New ¶
func (q *ClickQuery) New() (*Click, error)
New returns an empty Click on the query's connection, not yet saved, filled with what WithAttributes recorded on the query.
func (*ClickQuery) Offset ¶
func (q *ClickQuery) Offset(value int) *ClickQuery
func (*ClickQuery) Oldest ¶
func (q *ClickQuery) Oldest(column ...string) *ClickQuery
func (*ClickQuery) OrDoesntHave ¶
func (q *ClickQuery) OrDoesntHave(relation string) *ClickQuery
func (*ClickQuery) OrHas ¶
func (q *ClickQuery) OrHas(relation, operator string, count int) *ClickQuery
func (*ClickQuery) OrWhere ¶
func (q *ClickQuery) OrWhere(column any, args ...any) *ClickQuery
OrWhere adds an or-where clause; a func(*ClickQuery) in place of the column adds a group.
func (*ClickQuery) OrWhereDoesntHave ¶
func (q *ClickQuery) OrWhereDoesntHave(relation string, callback func(*query.Builder)) *ClickQuery
func (*ClickQuery) OrWhereHas ¶
func (q *ClickQuery) OrWhereHas(relation string, callback func(*query.Builder)) *ClickQuery
func (*ClickQuery) OrWhereNot ¶
func (q *ClickQuery) OrWhereNot(column any, args ...any) *ClickQuery
OrWhereNot adds an or-joined negated where clause, or a negated group.
func (*ClickQuery) OrWhereRelation ¶
func (q *ClickQuery) OrWhereRelation(relation string, column any, args ...any) *ClickQuery
func (*ClickQuery) OrderBy ¶
func (q *ClickQuery) OrderBy(column any, direction ...string) *ClickQuery
func (*ClickQuery) OrderByDesc ¶
func (q *ClickQuery) OrderByDesc(column any) *ClickQuery
func (*ClickQuery) Paginate ¶
func (q *ClickQuery) Paginate(ctx context.Context, g auth.Grant, perPage, page int, opts pagination.Options, columns ...any) (ClickCollection, *pagination.LengthAwarePage, error)
func (*ClickQuery) Select ¶
func (q *ClickQuery) Select(columns ...any) *ClickQuery
func (*ClickQuery) SelectRaw ¶
func (q *ClickQuery) SelectRaw(expression string, bindings ...any) *ClickQuery
func (*ClickQuery) SimplePaginate ¶
func (q *ClickQuery) SimplePaginate(ctx context.Context, g auth.Grant, perPage, page int, opts pagination.Options, columns ...any) (ClickCollection, *pagination.Page, error)
func (*ClickQuery) UpdateOrCreate ¶
func (*ClickQuery) ValueOrFail ¶
func (*ClickQuery) Where ¶
func (q *ClickQuery) Where(column any, args ...any) *ClickQuery
Where adds a where clause; a func(*ClickQuery) in place of the column adds a group.
func (*ClickQuery) WhereBelongsTo ¶
func (q *ClickQuery) WhereBelongsTo(relationshipName string, related ...model.Entity) *ClickQuery
func (*ClickQuery) WhereBetween ¶
func (q *ClickQuery) WhereBetween(column any, from, to any) *ClickQuery
func (*ClickQuery) WhereColumn ¶
func (q *ClickQuery) WhereColumn(first any, args ...any) *ClickQuery
func (*ClickQuery) WhereDoesntHave ¶
func (q *ClickQuery) WhereDoesntHave(relation string, callback func(*query.Builder)) *ClickQuery
func (*ClickQuery) WhereExists ¶
func (q *ClickQuery) WhereExists(callback func(*query.Builder)) *ClickQuery
func (*ClickQuery) WhereHas ¶
func (q *ClickQuery) WhereHas(relation string, callback func(*query.Builder)) *ClickQuery
func (*ClickQuery) WhereHasCount ¶
func (q *ClickQuery) WhereHasCount(relation string, callback func(*query.Builder), operator string, count int) *ClickQuery
func (*ClickQuery) WhereIn ¶
func (q *ClickQuery) WhereIn(column any, values []any) *ClickQuery
func (*ClickQuery) WhereKey ¶
func (q *ClickQuery) WhereKey(id any) *ClickQuery
func (*ClickQuery) WhereNot ¶
func (q *ClickQuery) WhereNot(column any, args ...any) *ClickQuery
WhereNot adds a negated where clause, or a negated group.
func (*ClickQuery) WhereNotExists ¶
func (q *ClickQuery) WhereNotExists(callback func(*query.Builder)) *ClickQuery
func (*ClickQuery) WhereNotIn ¶
func (q *ClickQuery) WhereNotIn(column any, values []any) *ClickQuery
func (*ClickQuery) WhereNotNull ¶
func (q *ClickQuery) WhereNotNull(columns ...any) *ClickQuery
func (*ClickQuery) WhereNull ¶
func (q *ClickQuery) WhereNull(columns ...any) *ClickQuery
func (*ClickQuery) WhereRelation ¶
func (q *ClickQuery) WhereRelation(relation string, column any, args ...any) *ClickQuery
func (*ClickQuery) With ¶
func (q *ClickQuery) With(relations ...string) *ClickQuery
func (*ClickQuery) WithAvg ¶
func (q *ClickQuery) WithAvg(relation, column string) *ClickQuery
func (*ClickQuery) WithCount ¶
func (q *ClickQuery) WithCount(relations ...string) *ClickQuery
func (*ClickQuery) WithExists ¶
func (q *ClickQuery) WithExists(relation string) *ClickQuery
func (*ClickQuery) WithMax ¶
func (q *ClickQuery) WithMax(relation, column string) *ClickQuery
func (*ClickQuery) WithMin ¶
func (q *ClickQuery) WithMin(relation, column string) *ClickQuery
func (*ClickQuery) WithSum ¶
func (q *ClickQuery) WithSum(relation, column string) *ClickQuery
func (*ClickQuery) Without ¶
func (q *ClickQuery) Without(relations ...string) *ClickQuery
func (*ClickQuery) WithoutGlobalScope ¶
func (q *ClickQuery) WithoutGlobalScope(identifier string) *ClickQuery
func (*ClickQuery) WithoutGlobalScopes ¶
func (q *ClickQuery) WithoutGlobalScopes(identifiers ...string) *ClickQuery
type ClickRequest ¶
type ClickRequest struct {
Code string
LandingURL string
// Address is the visitor's address. Only its hash, with the tenant in it,
// is stored.
Address string
}
ClickRequest is what opening a referral link records.
type Commission ¶
type Commission struct {
model.Model
ID string `db:"id"`
TenantID string `db:"tenant_id"`
ConversionID string `db:"conversion_id"`
AffiliateID string `db:"affiliate_id"`
Level int `db:"level"`
RateBps int64 `db:"rate_bps"`
Amount int64 `db:"amount"`
Status CommissionStatus `db:"status"`
// WalletOperationID is the deposit; ReversalOperationID the withdrawal
// that undid it.
WalletOperationID string `db:"wallet_operation_id"`
ReversalOperationID string `db:"reversal_operation_id"`
ReversedReason string `db:"reversed_reason"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
}
Commission is what one level of the tree earned on one conversion. It is deposited in the affiliate's wallet the moment it is created -- no waiting period -- and stays there until they withdraw it. A refund, or the admin, reverses it: the same amount leaves the wallet again, and the balance may go below zero, which blocks withdrawals until later commissions, or the admin, bring it back.
func (*Commission) Fresh ¶
func (row *Commission) Fresh(ctx context.Context, g auth.Grant, with ...string) (*Commission, error)
Fresh reads the row again, as a new Commission; it shadows the untyped one the embedded model promotes.
func (*Commission) Replicate ¶
func (row *Commission) Replicate(except ...string) (*Commission, error)
Replicate returns an unsaved copy of the row without its key; it shadows the untyped one the embedded model promotes.
type CommissionCollection ¶
type CommissionCollection []*Commission
CommissionCollection is rows of Commission, as a query returns them.
func CommissionCollectionOf ¶
func CommissionCollectionOf(rows model.Rows) CommissionCollection
CommissionCollectionOf converts rows of the table of Commission. A nil input is a nil collection.
func (CommissionCollection) Contains ¶
func (c CommissionCollection) Contains(key any) bool
func (CommissionCollection) Except ¶
func (c CommissionCollection) Except(keys ...any) CommissionCollection
func (CommissionCollection) Find ¶
func (c CommissionCollection) Find(key any) *Commission
func (CommissionCollection) FindOrFail ¶
func (c CommissionCollection) FindOrFail(key any) (*Commission, error)
func (CommissionCollection) Fresh ¶
func (c CommissionCollection) Fresh(ctx context.Context, g auth.Grant, with ...string) (CommissionCollection, error)
func (CommissionCollection) LoadMissing ¶
func (CommissionCollection) ModelKeys ¶
func (c CommissionCollection) ModelKeys() []any
func (CommissionCollection) Only ¶
func (c CommissionCollection) Only(keys ...any) CommissionCollection
func (CommissionCollection) Pluck ¶
func (c CommissionCollection) Pluck(column string) []any
func (CommissionCollection) Rows ¶
func (c CommissionCollection) Rows() model.Rows
Rows converts the collection back to the core's rows.
func (CommissionCollection) ToArray ¶
func (c CommissionCollection) ToArray() []map[string]any
func (CommissionCollection) Unique ¶
func (c CommissionCollection) Unique() CommissionCollection
type CommissionQuery ¶
type CommissionQuery struct {
// contains filtered or unexported fields
}
CommissionQuery is a query on the table of Commission.
The methods that build return the query, so they chain. The methods that run take a context and an auth.Grant, and return Commission rows or a value; there is no way to run one without a Grant.
func Commissions ¶
func Commissions(db model.DB) *CommissionQuery
Commissions starts a query on the table of Commission, through db.
Global scopes are on and, unless the table is Global, every statement is filtered by the tenant of the Grant its terminal takes.
func (*CommissionQuery) AddSelect ¶
func (q *CommissionQuery) AddSelect(columns ...any) *CommissionQuery
func (*CommissionQuery) Base ¶
func (q *CommissionQuery) Base() *model.Builder
Base returns the core builder the query forwards to. It is for code in this package -- a local scope in the custom block of ledger.go -- and for the factory, which builds rows through it.
func (*CommissionQuery) Clone ¶
func (q *CommissionQuery) Clone() *CommissionQuery
Clone returns an independent copy of the query.
func (*CommissionQuery) Create ¶
func (q *CommissionQuery) Create(ctx context.Context, g auth.Grant, attributes map[string]any) (*Commission, error)
func (*CommissionQuery) Cursor ¶
func (q *CommissionQuery) Cursor(ctx context.Context, g auth.Grant) iter.Seq2[*Commission, error]
func (*CommissionQuery) CursorPaginate ¶
func (q *CommissionQuery) CursorPaginate(ctx context.Context, g auth.Grant, perPage int, cursor *pagination.Cursor, opts pagination.Options, columns ...any) (CommissionCollection, *pagination.CursorPage, error)
func (*CommissionQuery) DoesntExist ¶
func (*CommissionQuery) DoesntHave ¶
func (q *CommissionQuery) DoesntHave(relation, boolean string, callback func(*query.Builder)) *CommissionQuery
func (*CommissionQuery) Find ¶
func (q *CommissionQuery) Find(ctx context.Context, g auth.Grant, id any, columns ...any) (*Commission, error)
func (*CommissionQuery) FindMany ¶
func (q *CommissionQuery) FindMany(ctx context.Context, g auth.Grant, ids []any, columns ...any) (CommissionCollection, error)
func (*CommissionQuery) FindOrFail ¶
func (q *CommissionQuery) FindOrFail(ctx context.Context, g auth.Grant, id any, columns ...any) (*Commission, error)
func (*CommissionQuery) FindOrNew ¶
func (q *CommissionQuery) FindOrNew(ctx context.Context, g auth.Grant, id any, columns ...any) (*Commission, error)
func (*CommissionQuery) First ¶
func (q *CommissionQuery) First(ctx context.Context, g auth.Grant, columns ...any) (*Commission, error)
First returns the first row, or nil and no error when there is none.
func (*CommissionQuery) FirstOrCreate ¶
func (q *CommissionQuery) FirstOrCreate(ctx context.Context, g auth.Grant, attributes, values map[string]any) (*Commission, error)
func (*CommissionQuery) FirstOrFail ¶
func (q *CommissionQuery) FirstOrFail(ctx context.Context, g auth.Grant, columns ...any) (*Commission, error)
func (*CommissionQuery) FirstOrNew ¶
func (q *CommissionQuery) FirstOrNew(ctx context.Context, g auth.Grant, attributes, values map[string]any) (*Commission, error)
func (*CommissionQuery) FirstWhere ¶
func (q *CommissionQuery) FirstWhere(ctx context.Context, g auth.Grant, column any, args ...any) (*Commission, error)
func (*CommissionQuery) ForPage ¶
func (q *CommissionQuery) ForPage(page, perPage int) *CommissionQuery
func (*CommissionQuery) ForceCreate ¶
func (q *CommissionQuery) ForceCreate(ctx context.Context, g auth.Grant, attributes map[string]any) (*Commission, error)
func (*CommissionQuery) Get ¶
func (q *CommissionQuery) Get(ctx context.Context, g auth.Grant, columns ...any) (CommissionCollection, error)
Get runs the query and returns the rows.
func (*CommissionQuery) GroupBy ¶
func (q *CommissionQuery) GroupBy(groups ...any) *CommissionQuery
func (*CommissionQuery) Has ¶
func (q *CommissionQuery) Has(relation, operator string, count int, boolean string, callback func(*query.Builder)) *CommissionQuery
func (*CommissionQuery) InsertOrIgnore ¶
func (*CommissionQuery) Join ¶
func (q *CommissionQuery) Join(table any, first any, args ...any) *CommissionQuery
func (*CommissionQuery) Latest ¶
func (q *CommissionQuery) Latest(column ...string) *CommissionQuery
func (*CommissionQuery) Limit ¶
func (q *CommissionQuery) Limit(value int) *CommissionQuery
func (*CommissionQuery) New ¶
func (q *CommissionQuery) New() (*Commission, error)
New returns an empty Commission on the query's connection, not yet saved, filled with what WithAttributes recorded on the query.
func (*CommissionQuery) Offset ¶
func (q *CommissionQuery) Offset(value int) *CommissionQuery
func (*CommissionQuery) Oldest ¶
func (q *CommissionQuery) Oldest(column ...string) *CommissionQuery
func (*CommissionQuery) OrDoesntHave ¶
func (q *CommissionQuery) OrDoesntHave(relation string) *CommissionQuery
func (*CommissionQuery) OrHas ¶
func (q *CommissionQuery) OrHas(relation, operator string, count int) *CommissionQuery
func (*CommissionQuery) OrWhere ¶
func (q *CommissionQuery) OrWhere(column any, args ...any) *CommissionQuery
OrWhere adds an or-where clause; a func(*CommissionQuery) in place of the column adds a group.
func (*CommissionQuery) OrWhereDoesntHave ¶
func (q *CommissionQuery) OrWhereDoesntHave(relation string, callback func(*query.Builder)) *CommissionQuery
func (*CommissionQuery) OrWhereHas ¶
func (q *CommissionQuery) OrWhereHas(relation string, callback func(*query.Builder)) *CommissionQuery
func (*CommissionQuery) OrWhereNot ¶
func (q *CommissionQuery) OrWhereNot(column any, args ...any) *CommissionQuery
OrWhereNot adds an or-joined negated where clause, or a negated group.
func (*CommissionQuery) OrWhereRelation ¶
func (q *CommissionQuery) OrWhereRelation(relation string, column any, args ...any) *CommissionQuery
func (*CommissionQuery) OrderBy ¶
func (q *CommissionQuery) OrderBy(column any, direction ...string) *CommissionQuery
func (*CommissionQuery) OrderByDesc ¶
func (q *CommissionQuery) OrderByDesc(column any) *CommissionQuery
func (*CommissionQuery) Paginate ¶
func (q *CommissionQuery) Paginate(ctx context.Context, g auth.Grant, perPage, page int, opts pagination.Options, columns ...any) (CommissionCollection, *pagination.LengthAwarePage, error)
func (*CommissionQuery) Select ¶
func (q *CommissionQuery) Select(columns ...any) *CommissionQuery
func (*CommissionQuery) SelectRaw ¶
func (q *CommissionQuery) SelectRaw(expression string, bindings ...any) *CommissionQuery
func (*CommissionQuery) SimplePaginate ¶
func (q *CommissionQuery) SimplePaginate(ctx context.Context, g auth.Grant, perPage, page int, opts pagination.Options, columns ...any) (CommissionCollection, *pagination.Page, error)
func (*CommissionQuery) Sole ¶
func (q *CommissionQuery) Sole(ctx context.Context, g auth.Grant, columns ...any) (*Commission, error)
func (*CommissionQuery) UpdateOrCreate ¶
func (q *CommissionQuery) UpdateOrCreate(ctx context.Context, g auth.Grant, attributes, values map[string]any) (*Commission, error)
func (*CommissionQuery) ValueOrFail ¶
func (*CommissionQuery) Where ¶
func (q *CommissionQuery) Where(column any, args ...any) *CommissionQuery
Where adds a where clause; a func(*CommissionQuery) in place of the column adds a group.
func (*CommissionQuery) WhereBelongsTo ¶
func (q *CommissionQuery) WhereBelongsTo(relationshipName string, related ...model.Entity) *CommissionQuery
func (*CommissionQuery) WhereBetween ¶
func (q *CommissionQuery) WhereBetween(column any, from, to any) *CommissionQuery
func (*CommissionQuery) WhereColumn ¶
func (q *CommissionQuery) WhereColumn(first any, args ...any) *CommissionQuery
func (*CommissionQuery) WhereDoesntHave ¶
func (q *CommissionQuery) WhereDoesntHave(relation string, callback func(*query.Builder)) *CommissionQuery
func (*CommissionQuery) WhereExists ¶
func (q *CommissionQuery) WhereExists(callback func(*query.Builder)) *CommissionQuery
func (*CommissionQuery) WhereHas ¶
func (q *CommissionQuery) WhereHas(relation string, callback func(*query.Builder)) *CommissionQuery
func (*CommissionQuery) WhereHasCount ¶
func (q *CommissionQuery) WhereHasCount(relation string, callback func(*query.Builder), operator string, count int) *CommissionQuery
func (*CommissionQuery) WhereIn ¶
func (q *CommissionQuery) WhereIn(column any, values []any) *CommissionQuery
func (*CommissionQuery) WhereKey ¶
func (q *CommissionQuery) WhereKey(id any) *CommissionQuery
func (*CommissionQuery) WhereNot ¶
func (q *CommissionQuery) WhereNot(column any, args ...any) *CommissionQuery
WhereNot adds a negated where clause, or a negated group.
func (*CommissionQuery) WhereNotExists ¶
func (q *CommissionQuery) WhereNotExists(callback func(*query.Builder)) *CommissionQuery
func (*CommissionQuery) WhereNotIn ¶
func (q *CommissionQuery) WhereNotIn(column any, values []any) *CommissionQuery
func (*CommissionQuery) WhereNotNull ¶
func (q *CommissionQuery) WhereNotNull(columns ...any) *CommissionQuery
func (*CommissionQuery) WhereNull ¶
func (q *CommissionQuery) WhereNull(columns ...any) *CommissionQuery
func (*CommissionQuery) WhereRelation ¶
func (q *CommissionQuery) WhereRelation(relation string, column any, args ...any) *CommissionQuery
func (*CommissionQuery) With ¶
func (q *CommissionQuery) With(relations ...string) *CommissionQuery
func (*CommissionQuery) WithAvg ¶
func (q *CommissionQuery) WithAvg(relation, column string) *CommissionQuery
func (*CommissionQuery) WithCount ¶
func (q *CommissionQuery) WithCount(relations ...string) *CommissionQuery
func (*CommissionQuery) WithExists ¶
func (q *CommissionQuery) WithExists(relation string) *CommissionQuery
func (*CommissionQuery) WithMax ¶
func (q *CommissionQuery) WithMax(relation, column string) *CommissionQuery
func (*CommissionQuery) WithMin ¶
func (q *CommissionQuery) WithMin(relation, column string) *CommissionQuery
func (*CommissionQuery) WithSum ¶
func (q *CommissionQuery) WithSum(relation, column string) *CommissionQuery
func (*CommissionQuery) Without ¶
func (q *CommissionQuery) Without(relations ...string) *CommissionQuery
func (*CommissionQuery) WithoutGlobalScope ¶
func (q *CommissionQuery) WithoutGlobalScope(identifier string) *CommissionQuery
func (*CommissionQuery) WithoutGlobalScopes ¶
func (q *CommissionQuery) WithoutGlobalScopes(identifiers ...string) *CommissionQuery
type CommissionRow ¶
type CommissionRow struct {
ID, Date, Rate, Amount, AmountSort, Status, StatusKey string
Order, Buyer, Product, Affiliate, AffiliateURL string
Reason, ReverseURL string
Level int
Reversible bool
}
CommissionRow is one commission as a screen shows it.
type CommissionStatus ¶
type CommissionStatus string
CommissionStatus is where a commission stands.
const ( // CommissionAvailable is in the wallet. CommissionAvailable CommissionStatus = "available" // CommissionReversed was taken back out. CommissionReversed CommissionStatus = "reversed" )
type CommissionView ¶
type CommissionView struct {
Commission Commission
Conversion *Conversion
Affiliate *Affiliate
}
CommissionView is a commission with the payment it was paid on and the affiliate who earned it.
type CommissionsQuery ¶
type CommissionsQuery struct {
AffiliateID string
Level int
Status CommissionStatus
From, To Day
Sort string
Dir string
Page int
PerPage int
}
CommissionsQuery narrows a list of commissions. Page counts from one.
type Config ¶
type Config struct {
// Prefix is the path the panels are mounted under. Empty means
// DefaultPrefix.
Prefix string
// ReferralPath is the path the referral link answers under, outside the
// prefix and outside the sign-in guard: /r/{code}. Empty means
// DefaultReferralPath.
ReferralPath string
// Tenant is the customer a visitor with no session is read as when they
// open a referral link. Required: the click has to belong to some tenant,
// and it cannot be one the request names.
Tenant string
// LandingPath is where the referral link sends the visitor after setting
// the cookie, unless the link carries ?to= with a path of the same site.
// Empty means "/".
LandingPath string
// CookieName is the cookie the link sets and CodeFrom reads. Empty means
// DefaultCookieName.
CookieName string
// SecureCookie marks the cookie Secure. Leave it on in production; a
// development server over plain HTTP turns it off.
SecureCookie bool
// PageSize is how many rows one page answers with. Zero means
// DefaultPageSize; anything above MaxPageSize is refused.
PageSize int
// Location is the timezone a day is counted in: the day of a withdrawal,
// the period of the panel's numbers. Nil means DefaultLocation.
Location *time.Location
// Wallet is arandu-wallet's service, the application's one instance
// (walletModule.Service()). Required: the commissions are deposited in the
// affiliate's wallet and withdrawn from it, and this package keeps no
// balance of its own.
Wallet *wallet.WalletService
// Translator is the application's own catalogue, asked before the one this
// package ships, key by key: "affiliate.screen.dashboard_title". Optional.
Translator *translation.Translator
}
Config is everything the module needs from the application, checked by New before the module exists.
type Conversion ¶
type Conversion struct {
model.Model
ID string `db:"id"`
TenantID string `db:"tenant_id"`
// OrderRef is the application's identifier of the payment, unique per
// tenant: reporting the same payment twice records it once.
OrderRef string `db:"order_ref"`
BuyerUserID string `db:"buyer_user_id"`
ProductID string `db:"product_id"`
// Amount is the payment in centavos, what the rates apply to.
Amount int64 `db:"amount"`
Renewal Flag `db:"renewal"`
// AffiliateID is the buyer's referrer, the first level, empty when the
// buyer was referred by nobody. PlanID is the plan that paid it, empty
// when no plan was active.
AffiliateID string `db:"affiliate_id"`
PlanID string `db:"plan_id"`
Status ConversionStatus `db:"status"`
OccurredAt time.Time `db:"occurred_at"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
}
Conversion is one payment of a referred user -- a first purchase or a renewal -- as the application reported it. It is recorded once per order reference, and it is what the commissions of every level point at.
func (*Conversion) Fresh ¶
func (row *Conversion) Fresh(ctx context.Context, g auth.Grant, with ...string) (*Conversion, error)
Fresh reads the row again, as a new Conversion; it shadows the untyped one the embedded model promotes.
func (*Conversion) Replicate ¶
func (row *Conversion) Replicate(except ...string) (*Conversion, error)
Replicate returns an unsaved copy of the row without its key; it shadows the untyped one the embedded model promotes.
type ConversionCollection ¶
type ConversionCollection []*Conversion
ConversionCollection is rows of Conversion, as a query returns them.
func ConversionCollectionOf ¶
func ConversionCollectionOf(rows model.Rows) ConversionCollection
ConversionCollectionOf converts rows of the table of Conversion. A nil input is a nil collection.
func (ConversionCollection) Contains ¶
func (c ConversionCollection) Contains(key any) bool
func (ConversionCollection) Except ¶
func (c ConversionCollection) Except(keys ...any) ConversionCollection
func (ConversionCollection) Find ¶
func (c ConversionCollection) Find(key any) *Conversion
func (ConversionCollection) FindOrFail ¶
func (c ConversionCollection) FindOrFail(key any) (*Conversion, error)
func (ConversionCollection) Fresh ¶
func (c ConversionCollection) Fresh(ctx context.Context, g auth.Grant, with ...string) (ConversionCollection, error)
func (ConversionCollection) LoadMissing ¶
func (ConversionCollection) ModelKeys ¶
func (c ConversionCollection) ModelKeys() []any
func (ConversionCollection) Only ¶
func (c ConversionCollection) Only(keys ...any) ConversionCollection
func (ConversionCollection) Pluck ¶
func (c ConversionCollection) Pluck(column string) []any
func (ConversionCollection) Rows ¶
func (c ConversionCollection) Rows() model.Rows
Rows converts the collection back to the core's rows.
func (ConversionCollection) ToArray ¶
func (c ConversionCollection) ToArray() []map[string]any
func (ConversionCollection) Unique ¶
func (c ConversionCollection) Unique() ConversionCollection
type ConversionQuery ¶
type ConversionQuery struct {
// contains filtered or unexported fields
}
ConversionQuery is a query on the table of Conversion.
The methods that build return the query, so they chain. The methods that run take a context and an auth.Grant, and return Conversion rows or a value; there is no way to run one without a Grant.
func Conversions ¶
func Conversions(db model.DB) *ConversionQuery
Conversions starts a query on the table of Conversion, through db.
Global scopes are on and, unless the table is Global, every statement is filtered by the tenant of the Grant its terminal takes.
func (*ConversionQuery) AddSelect ¶
func (q *ConversionQuery) AddSelect(columns ...any) *ConversionQuery
func (*ConversionQuery) Base ¶
func (q *ConversionQuery) Base() *model.Builder
Base returns the core builder the query forwards to. It is for code in this package -- a local scope in the custom block of ledger.go -- and for the factory, which builds rows through it.
func (*ConversionQuery) Clone ¶
func (q *ConversionQuery) Clone() *ConversionQuery
Clone returns an independent copy of the query.
func (*ConversionQuery) Create ¶
func (q *ConversionQuery) Create(ctx context.Context, g auth.Grant, attributes map[string]any) (*Conversion, error)
func (*ConversionQuery) Cursor ¶
func (q *ConversionQuery) Cursor(ctx context.Context, g auth.Grant) iter.Seq2[*Conversion, error]
func (*ConversionQuery) CursorPaginate ¶
func (q *ConversionQuery) CursorPaginate(ctx context.Context, g auth.Grant, perPage int, cursor *pagination.Cursor, opts pagination.Options, columns ...any) (ConversionCollection, *pagination.CursorPage, error)
func (*ConversionQuery) DoesntExist ¶
func (*ConversionQuery) DoesntHave ¶
func (q *ConversionQuery) DoesntHave(relation, boolean string, callback func(*query.Builder)) *ConversionQuery
func (*ConversionQuery) Find ¶
func (q *ConversionQuery) Find(ctx context.Context, g auth.Grant, id any, columns ...any) (*Conversion, error)
func (*ConversionQuery) FindMany ¶
func (q *ConversionQuery) FindMany(ctx context.Context, g auth.Grant, ids []any, columns ...any) (ConversionCollection, error)
func (*ConversionQuery) FindOrFail ¶
func (q *ConversionQuery) FindOrFail(ctx context.Context, g auth.Grant, id any, columns ...any) (*Conversion, error)
func (*ConversionQuery) FindOrNew ¶
func (q *ConversionQuery) FindOrNew(ctx context.Context, g auth.Grant, id any, columns ...any) (*Conversion, error)
func (*ConversionQuery) First ¶
func (q *ConversionQuery) First(ctx context.Context, g auth.Grant, columns ...any) (*Conversion, error)
First returns the first row, or nil and no error when there is none.
func (*ConversionQuery) FirstOrCreate ¶
func (q *ConversionQuery) FirstOrCreate(ctx context.Context, g auth.Grant, attributes, values map[string]any) (*Conversion, error)
func (*ConversionQuery) FirstOrFail ¶
func (q *ConversionQuery) FirstOrFail(ctx context.Context, g auth.Grant, columns ...any) (*Conversion, error)
func (*ConversionQuery) FirstOrNew ¶
func (q *ConversionQuery) FirstOrNew(ctx context.Context, g auth.Grant, attributes, values map[string]any) (*Conversion, error)
func (*ConversionQuery) FirstWhere ¶
func (q *ConversionQuery) FirstWhere(ctx context.Context, g auth.Grant, column any, args ...any) (*Conversion, error)
func (*ConversionQuery) ForPage ¶
func (q *ConversionQuery) ForPage(page, perPage int) *ConversionQuery
func (*ConversionQuery) ForceCreate ¶
func (q *ConversionQuery) ForceCreate(ctx context.Context, g auth.Grant, attributes map[string]any) (*Conversion, error)
func (*ConversionQuery) Get ¶
func (q *ConversionQuery) Get(ctx context.Context, g auth.Grant, columns ...any) (ConversionCollection, error)
Get runs the query and returns the rows.
func (*ConversionQuery) GroupBy ¶
func (q *ConversionQuery) GroupBy(groups ...any) *ConversionQuery
func (*ConversionQuery) Has ¶
func (q *ConversionQuery) Has(relation, operator string, count int, boolean string, callback func(*query.Builder)) *ConversionQuery
func (*ConversionQuery) InsertOrIgnore ¶
func (*ConversionQuery) Join ¶
func (q *ConversionQuery) Join(table any, first any, args ...any) *ConversionQuery
func (*ConversionQuery) Latest ¶
func (q *ConversionQuery) Latest(column ...string) *ConversionQuery
func (*ConversionQuery) Limit ¶
func (q *ConversionQuery) Limit(value int) *ConversionQuery
func (*ConversionQuery) New ¶
func (q *ConversionQuery) New() (*Conversion, error)
New returns an empty Conversion on the query's connection, not yet saved, filled with what WithAttributes recorded on the query.
func (*ConversionQuery) Offset ¶
func (q *ConversionQuery) Offset(value int) *ConversionQuery
func (*ConversionQuery) Oldest ¶
func (q *ConversionQuery) Oldest(column ...string) *ConversionQuery
func (*ConversionQuery) OrDoesntHave ¶
func (q *ConversionQuery) OrDoesntHave(relation string) *ConversionQuery
func (*ConversionQuery) OrHas ¶
func (q *ConversionQuery) OrHas(relation, operator string, count int) *ConversionQuery
func (*ConversionQuery) OrWhere ¶
func (q *ConversionQuery) OrWhere(column any, args ...any) *ConversionQuery
OrWhere adds an or-where clause; a func(*ConversionQuery) in place of the column adds a group.
func (*ConversionQuery) OrWhereDoesntHave ¶
func (q *ConversionQuery) OrWhereDoesntHave(relation string, callback func(*query.Builder)) *ConversionQuery
func (*ConversionQuery) OrWhereHas ¶
func (q *ConversionQuery) OrWhereHas(relation string, callback func(*query.Builder)) *ConversionQuery
func (*ConversionQuery) OrWhereNot ¶
func (q *ConversionQuery) OrWhereNot(column any, args ...any) *ConversionQuery
OrWhereNot adds an or-joined negated where clause, or a negated group.
func (*ConversionQuery) OrWhereRelation ¶
func (q *ConversionQuery) OrWhereRelation(relation string, column any, args ...any) *ConversionQuery
func (*ConversionQuery) OrderBy ¶
func (q *ConversionQuery) OrderBy(column any, direction ...string) *ConversionQuery
func (*ConversionQuery) OrderByDesc ¶
func (q *ConversionQuery) OrderByDesc(column any) *ConversionQuery
func (*ConversionQuery) Paginate ¶
func (q *ConversionQuery) Paginate(ctx context.Context, g auth.Grant, perPage, page int, opts pagination.Options, columns ...any) (ConversionCollection, *pagination.LengthAwarePage, error)
func (*ConversionQuery) Select ¶
func (q *ConversionQuery) Select(columns ...any) *ConversionQuery
func (*ConversionQuery) SelectRaw ¶
func (q *ConversionQuery) SelectRaw(expression string, bindings ...any) *ConversionQuery
func (*ConversionQuery) SimplePaginate ¶
func (q *ConversionQuery) SimplePaginate(ctx context.Context, g auth.Grant, perPage, page int, opts pagination.Options, columns ...any) (ConversionCollection, *pagination.Page, error)
func (*ConversionQuery) Sole ¶
func (q *ConversionQuery) Sole(ctx context.Context, g auth.Grant, columns ...any) (*Conversion, error)
func (*ConversionQuery) UpdateOrCreate ¶
func (q *ConversionQuery) UpdateOrCreate(ctx context.Context, g auth.Grant, attributes, values map[string]any) (*Conversion, error)
func (*ConversionQuery) ValueOrFail ¶
func (*ConversionQuery) Where ¶
func (q *ConversionQuery) Where(column any, args ...any) *ConversionQuery
Where adds a where clause; a func(*ConversionQuery) in place of the column adds a group.
func (*ConversionQuery) WhereBelongsTo ¶
func (q *ConversionQuery) WhereBelongsTo(relationshipName string, related ...model.Entity) *ConversionQuery
func (*ConversionQuery) WhereBetween ¶
func (q *ConversionQuery) WhereBetween(column any, from, to any) *ConversionQuery
func (*ConversionQuery) WhereColumn ¶
func (q *ConversionQuery) WhereColumn(first any, args ...any) *ConversionQuery
func (*ConversionQuery) WhereDoesntHave ¶
func (q *ConversionQuery) WhereDoesntHave(relation string, callback func(*query.Builder)) *ConversionQuery
func (*ConversionQuery) WhereExists ¶
func (q *ConversionQuery) WhereExists(callback func(*query.Builder)) *ConversionQuery
func (*ConversionQuery) WhereHas ¶
func (q *ConversionQuery) WhereHas(relation string, callback func(*query.Builder)) *ConversionQuery
func (*ConversionQuery) WhereHasCount ¶
func (q *ConversionQuery) WhereHasCount(relation string, callback func(*query.Builder), operator string, count int) *ConversionQuery
func (*ConversionQuery) WhereIn ¶
func (q *ConversionQuery) WhereIn(column any, values []any) *ConversionQuery
func (*ConversionQuery) WhereKey ¶
func (q *ConversionQuery) WhereKey(id any) *ConversionQuery
func (*ConversionQuery) WhereNot ¶
func (q *ConversionQuery) WhereNot(column any, args ...any) *ConversionQuery
WhereNot adds a negated where clause, or a negated group.
func (*ConversionQuery) WhereNotExists ¶
func (q *ConversionQuery) WhereNotExists(callback func(*query.Builder)) *ConversionQuery
func (*ConversionQuery) WhereNotIn ¶
func (q *ConversionQuery) WhereNotIn(column any, values []any) *ConversionQuery
func (*ConversionQuery) WhereNotNull ¶
func (q *ConversionQuery) WhereNotNull(columns ...any) *ConversionQuery
func (*ConversionQuery) WhereNull ¶
func (q *ConversionQuery) WhereNull(columns ...any) *ConversionQuery
func (*ConversionQuery) WhereRelation ¶
func (q *ConversionQuery) WhereRelation(relation string, column any, args ...any) *ConversionQuery
func (*ConversionQuery) With ¶
func (q *ConversionQuery) With(relations ...string) *ConversionQuery
func (*ConversionQuery) WithAvg ¶
func (q *ConversionQuery) WithAvg(relation, column string) *ConversionQuery
func (*ConversionQuery) WithCount ¶
func (q *ConversionQuery) WithCount(relations ...string) *ConversionQuery
func (*ConversionQuery) WithExists ¶
func (q *ConversionQuery) WithExists(relation string) *ConversionQuery
func (*ConversionQuery) WithMax ¶
func (q *ConversionQuery) WithMax(relation, column string) *ConversionQuery
func (*ConversionQuery) WithMin ¶
func (q *ConversionQuery) WithMin(relation, column string) *ConversionQuery
func (*ConversionQuery) WithSum ¶
func (q *ConversionQuery) WithSum(relation, column string) *ConversionQuery
func (*ConversionQuery) Without ¶
func (q *ConversionQuery) Without(relations ...string) *ConversionQuery
func (*ConversionQuery) WithoutGlobalScope ¶
func (q *ConversionQuery) WithoutGlobalScope(identifier string) *ConversionQuery
func (*ConversionQuery) WithoutGlobalScopes ¶
func (q *ConversionQuery) WithoutGlobalScopes(identifiers ...string) *ConversionQuery
type ConversionRequest ¶
type ConversionRequest struct {
// OrderRef is the application's identifier of the payment, unique per
// tenant: reporting it twice records it once.
OrderRef string
BuyerUserID string
ProductID string
// Amount is the payment in centavos.
Amount int64
// Renewal is a payment of something the buyer already had. It pays
// commissions like a first purchase: they are for life.
Renewal bool
OccurredAt time.Time
}
ConversionRequest is a payment of a user, as the application reports it.
func (ConversionRequest) Validate ¶
func (r ConversionRequest) Validate() validation.Errors
Validate reports the errors per field.
type ConversionStatus ¶
type ConversionStatus string
ConversionStatus is whether a payment still stands.
const ( // ConversionCounted stands, and its commissions with it. ConversionCounted ConversionStatus = "counted" // ConversionRefunded was given back, and its commissions reversed. ConversionRefunded ConversionStatus = "refunded" )
type CreateRequest ¶
type CreateRequest struct {
// UserID is the login user who will sign in to the panel.
UserID string
// Name is how the affiliate is called.
Name string
// Document is the CPF or the CNPJ.
Document string
// Code is the referral code. Empty draws one.
Code string
}
CreateRequest is what registering an affiliate takes.
func (CreateRequest) Validate ¶
func (r CreateRequest) Validate() validation.Errors
Validate reports the errors per field.
type DashboardPageData ¶
type DashboardPageData struct {
Screen
Name, Code, Link, Document string
Blocked bool
Plan *PlanRow
From, To string
Clicks, Signups, Sales int64
Commissions string
Balance, Held, Available string
Negative bool
Min, Max string
Rows []CommissionRow
Level, Status string
Table TableState
Accounts []AccountOption
Withdrawals []WithdrawalRow
WithdrawURL, AccountURL string
}
DashboardPageData is the affiliate's own panel.
type Day ¶
type Day string
Day is a calendar day, as YYYY-MM-DD, in the application's timezone.
type Flag ¶
type Flag bool
Flag is a yes-or-no stored as 0 or 1, which every engine reads the same.
type FormState ¶
FormState is what a form field reads from the page it is drawn on: what was typed before a refusal, and the message for each field.
func (FormState) FieldError ¶
FieldError is the first message for one field, empty when it was accepted.
type Labels ¶
type Labels struct {
Locale string
// contains filtered or unexported fields
}
Labels are the sentences of this package's screens in one locale.
type Module ¶
type Module struct {
// contains filtered or unexported fields
}
Module is what the application registers.
func (*Module) CodeFrom ¶
CodeFrom is the referral code the visitor's cookie carries, for the application's sign-up to pass to Attribute. Empty when there is none.
func (*Module) Migrations ¶
func (m *Module) Migrations() []foundation.Migration
Migrations declares the schema this module owns, in the order the names sort in.
func (*Module) Publishes ¶
func (m *Module) Publishes() []foundation.Publication
Publishes declares the files this package offers, each at the path it takes relative to the root of the project.
One tree, under one tag. A publication may carry a page, a component, a configuration file, a migration, a catalogue of sentences or an asset, and this package offers the first of those and nothing else. Each absence is a decision rather than an omission:
- configuration is the Config struct New is handed, checked by the compiler and validated before the module exists. A file copied into the project beside it would be a second place to say the same thing, and only one of the two could be the one the code reads.
- a stylesheet, a script or any other asset is registered with the view layer and served from an address derived from its own bytes. Copying one into the project would put a second copy of those bytes under a second address, and a page can only reference one of them.
- translations are overridden by writing the lines the application wants into its own override tree, which the catalogue loader already reads. A copy of every line this package ships is a copy that goes stale, and it goes stale without saying so.
- migrations are declared and collected, never copied. A copy in the project's own migration directory is found by the runner as well, so one schema change applies twice under two names.
What is left is the markup, and it is here for the reason the others are not: it is the one thing the project is expected to edit. A package cannot know what a screen should say in a product it has never seen.
func (*Module) Routes ¶
Routes registers the module's routes.
The referral link is the one route a visitor with no session reaches, and it is registered on the router the application handed in, outside the prefix: /r/{code}. Every other route is registered on the guarded group, which is mounted before the first registration.
func (*Module) Service ¶
func (m *Module) Service() *AffiliateService
Service is the use cases, for an application that calls them from its own code: the sign-up that attributes a referral, the place payments are confirmed. Every method asks the policy, so handing it out opens nothing.
type OptionalText ¶
type OptionalText string
OptionalText is a text column that is NULL when empty, so a unique index over it holds among the rows that have a value and lets every row without one through: two users whose document nobody knows are not the same person.
func (*OptionalText) Scan ¶
func (t *OptionalText) Scan(value any) error
Scan reads NULL as the empty text.
type Plan ¶
type Plan struct {
model.Model
ID string `db:"id"`
TenantID string `db:"tenant_id"`
Name string `db:"name"`
Kind PlanKind `db:"kind"`
// CookieDays is how long the referral cookie set by /r/{code} lives.
CookieDays int `db:"cookie_days"`
// MinWithdrawal and MaxWithdrawal are centavos. A max of zero is no max.
MinWithdrawal int64 `db:"min_withdrawal"`
MaxWithdrawal int64 `db:"max_withdrawal"`
Active Flag `db:"active"`
CreatedBy string `db:"created_by"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
}
Plan is how commissions are paid: how many levels up the tree, at which rate each, how long a referral cookie lives, and the limits of a withdrawal. The admin defines plans; one is active at a time, and a conversion is paid by the plan active when it arrived.
type PlanCollection ¶
type PlanCollection []*Plan
PlanCollection is rows of Plan, as a query returns them.
func PlanCollectionOf ¶
func PlanCollectionOf(rows model.Rows) PlanCollection
PlanCollectionOf converts rows of the table of Plan. A nil input is a nil collection.
func (PlanCollection) Contains ¶
func (c PlanCollection) Contains(key any) bool
func (PlanCollection) Except ¶
func (c PlanCollection) Except(keys ...any) PlanCollection
func (PlanCollection) Find ¶
func (c PlanCollection) Find(key any) *Plan
func (PlanCollection) FindOrFail ¶
func (c PlanCollection) FindOrFail(key any) (*Plan, error)
func (PlanCollection) Fresh ¶
func (c PlanCollection) Fresh(ctx context.Context, g auth.Grant, with ...string) (PlanCollection, error)
func (PlanCollection) LoadMissing ¶
func (PlanCollection) ModelKeys ¶
func (c PlanCollection) ModelKeys() []any
func (PlanCollection) Only ¶
func (c PlanCollection) Only(keys ...any) PlanCollection
func (PlanCollection) Pluck ¶
func (c PlanCollection) Pluck(column string) []any
func (PlanCollection) Rows ¶
func (c PlanCollection) Rows() model.Rows
Rows converts the collection back to the core's rows.
func (PlanCollection) ToArray ¶
func (c PlanCollection) ToArray() []map[string]any
func (PlanCollection) Unique ¶
func (c PlanCollection) Unique() PlanCollection
type PlanLevel ¶
type PlanLevel struct {
model.Model
ID string `db:"id"`
TenantID string `db:"tenant_id"`
PlanID string `db:"plan_id"`
Level int `db:"level"`
RateBps int64 `db:"rate_bps"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
}
PlanLevel is the rate one level of a plan pays, in basis points of the payment: 150 is 1,5%.
type PlanLevelCollection ¶
type PlanLevelCollection []*PlanLevel
PlanLevelCollection is rows of PlanLevel, as a query returns them.
func PlanLevelCollectionOf ¶
func PlanLevelCollectionOf(rows model.Rows) PlanLevelCollection
PlanLevelCollectionOf converts rows of the table of PlanLevel. A nil input is a nil collection.
func (PlanLevelCollection) Contains ¶
func (c PlanLevelCollection) Contains(key any) bool
func (PlanLevelCollection) Except ¶
func (c PlanLevelCollection) Except(keys ...any) PlanLevelCollection
func (PlanLevelCollection) Find ¶
func (c PlanLevelCollection) Find(key any) *PlanLevel
func (PlanLevelCollection) FindOrFail ¶
func (c PlanLevelCollection) FindOrFail(key any) (*PlanLevel, error)
func (PlanLevelCollection) Fresh ¶
func (c PlanLevelCollection) Fresh(ctx context.Context, g auth.Grant, with ...string) (PlanLevelCollection, error)
func (PlanLevelCollection) LoadMissing ¶
func (PlanLevelCollection) ModelKeys ¶
func (c PlanLevelCollection) ModelKeys() []any
func (PlanLevelCollection) Only ¶
func (c PlanLevelCollection) Only(keys ...any) PlanLevelCollection
func (PlanLevelCollection) Pluck ¶
func (c PlanLevelCollection) Pluck(column string) []any
func (PlanLevelCollection) Rows ¶
func (c PlanLevelCollection) Rows() model.Rows
Rows converts the collection back to the core's rows.
func (PlanLevelCollection) ToArray ¶
func (c PlanLevelCollection) ToArray() []map[string]any
func (PlanLevelCollection) Unique ¶
func (c PlanLevelCollection) Unique() PlanLevelCollection
type PlanLevelQuery ¶
type PlanLevelQuery struct {
// contains filtered or unexported fields
}
PlanLevelQuery is a query on the table of PlanLevel.
The methods that build return the query, so they chain. The methods that run take a context and an auth.Grant, and return PlanLevel rows or a value; there is no way to run one without a Grant.
func PlanLevels ¶
func PlanLevels(db model.DB) *PlanLevelQuery
PlanLevels starts a query on the table of PlanLevel, through db.
Global scopes are on and, unless the table is Global, every statement is filtered by the tenant of the Grant its terminal takes.
func (*PlanLevelQuery) AddSelect ¶
func (q *PlanLevelQuery) AddSelect(columns ...any) *PlanLevelQuery
func (*PlanLevelQuery) Base ¶
func (q *PlanLevelQuery) Base() *model.Builder
Base returns the core builder the query forwards to. It is for code in this package -- a local scope in the custom block of plan.go -- and for the factory, which builds rows through it.
func (*PlanLevelQuery) Clone ¶
func (q *PlanLevelQuery) Clone() *PlanLevelQuery
Clone returns an independent copy of the query.
func (*PlanLevelQuery) CursorPaginate ¶
func (q *PlanLevelQuery) CursorPaginate(ctx context.Context, g auth.Grant, perPage int, cursor *pagination.Cursor, opts pagination.Options, columns ...any) (PlanLevelCollection, *pagination.CursorPage, error)
func (*PlanLevelQuery) DoesntExist ¶
func (*PlanLevelQuery) DoesntHave ¶
func (q *PlanLevelQuery) DoesntHave(relation, boolean string, callback func(*query.Builder)) *PlanLevelQuery
func (*PlanLevelQuery) FindMany ¶
func (q *PlanLevelQuery) FindMany(ctx context.Context, g auth.Grant, ids []any, columns ...any) (PlanLevelCollection, error)
func (*PlanLevelQuery) FindOrFail ¶
func (*PlanLevelQuery) First ¶
func (q *PlanLevelQuery) First(ctx context.Context, g auth.Grant, columns ...any) (*PlanLevel, error)
First returns the first row, or nil and no error when there is none.
func (*PlanLevelQuery) FirstOrCreate ¶
func (*PlanLevelQuery) FirstOrFail ¶
func (*PlanLevelQuery) FirstOrNew ¶
func (*PlanLevelQuery) FirstWhere ¶
func (*PlanLevelQuery) ForPage ¶
func (q *PlanLevelQuery) ForPage(page, perPage int) *PlanLevelQuery
func (*PlanLevelQuery) ForceCreate ¶
func (*PlanLevelQuery) Get ¶
func (q *PlanLevelQuery) Get(ctx context.Context, g auth.Grant, columns ...any) (PlanLevelCollection, error)
Get runs the query and returns the rows.
func (*PlanLevelQuery) GroupBy ¶
func (q *PlanLevelQuery) GroupBy(groups ...any) *PlanLevelQuery
func (*PlanLevelQuery) Has ¶
func (q *PlanLevelQuery) Has(relation, operator string, count int, boolean string, callback func(*query.Builder)) *PlanLevelQuery
func (*PlanLevelQuery) InsertOrIgnore ¶
func (*PlanLevelQuery) Join ¶
func (q *PlanLevelQuery) Join(table any, first any, args ...any) *PlanLevelQuery
func (*PlanLevelQuery) Latest ¶
func (q *PlanLevelQuery) Latest(column ...string) *PlanLevelQuery
func (*PlanLevelQuery) Limit ¶
func (q *PlanLevelQuery) Limit(value int) *PlanLevelQuery
func (*PlanLevelQuery) New ¶
func (q *PlanLevelQuery) New() (*PlanLevel, error)
New returns an empty PlanLevel on the query's connection, not yet saved, filled with what WithAttributes recorded on the query.
func (*PlanLevelQuery) Offset ¶
func (q *PlanLevelQuery) Offset(value int) *PlanLevelQuery
func (*PlanLevelQuery) Oldest ¶
func (q *PlanLevelQuery) Oldest(column ...string) *PlanLevelQuery
func (*PlanLevelQuery) OrDoesntHave ¶
func (q *PlanLevelQuery) OrDoesntHave(relation string) *PlanLevelQuery
func (*PlanLevelQuery) OrHas ¶
func (q *PlanLevelQuery) OrHas(relation, operator string, count int) *PlanLevelQuery
func (*PlanLevelQuery) OrWhere ¶
func (q *PlanLevelQuery) OrWhere(column any, args ...any) *PlanLevelQuery
OrWhere adds an or-where clause; a func(*PlanLevelQuery) in place of the column adds a group.
func (*PlanLevelQuery) OrWhereDoesntHave ¶
func (q *PlanLevelQuery) OrWhereDoesntHave(relation string, callback func(*query.Builder)) *PlanLevelQuery
func (*PlanLevelQuery) OrWhereHas ¶
func (q *PlanLevelQuery) OrWhereHas(relation string, callback func(*query.Builder)) *PlanLevelQuery
func (*PlanLevelQuery) OrWhereNot ¶
func (q *PlanLevelQuery) OrWhereNot(column any, args ...any) *PlanLevelQuery
OrWhereNot adds an or-joined negated where clause, or a negated group.
func (*PlanLevelQuery) OrWhereRelation ¶
func (q *PlanLevelQuery) OrWhereRelation(relation string, column any, args ...any) *PlanLevelQuery
func (*PlanLevelQuery) OrderBy ¶
func (q *PlanLevelQuery) OrderBy(column any, direction ...string) *PlanLevelQuery
func (*PlanLevelQuery) OrderByDesc ¶
func (q *PlanLevelQuery) OrderByDesc(column any) *PlanLevelQuery
func (*PlanLevelQuery) Paginate ¶
func (q *PlanLevelQuery) Paginate(ctx context.Context, g auth.Grant, perPage, page int, opts pagination.Options, columns ...any) (PlanLevelCollection, *pagination.LengthAwarePage, error)
func (*PlanLevelQuery) Select ¶
func (q *PlanLevelQuery) Select(columns ...any) *PlanLevelQuery
func (*PlanLevelQuery) SelectRaw ¶
func (q *PlanLevelQuery) SelectRaw(expression string, bindings ...any) *PlanLevelQuery
func (*PlanLevelQuery) SimplePaginate ¶
func (q *PlanLevelQuery) SimplePaginate(ctx context.Context, g auth.Grant, perPage, page int, opts pagination.Options, columns ...any) (PlanLevelCollection, *pagination.Page, error)
func (*PlanLevelQuery) UpdateOrCreate ¶
func (*PlanLevelQuery) ValueOrFail ¶
func (*PlanLevelQuery) Where ¶
func (q *PlanLevelQuery) Where(column any, args ...any) *PlanLevelQuery
Where adds a where clause; a func(*PlanLevelQuery) in place of the column adds a group.
func (*PlanLevelQuery) WhereBelongsTo ¶
func (q *PlanLevelQuery) WhereBelongsTo(relationshipName string, related ...model.Entity) *PlanLevelQuery
func (*PlanLevelQuery) WhereBetween ¶
func (q *PlanLevelQuery) WhereBetween(column any, from, to any) *PlanLevelQuery
func (*PlanLevelQuery) WhereColumn ¶
func (q *PlanLevelQuery) WhereColumn(first any, args ...any) *PlanLevelQuery
func (*PlanLevelQuery) WhereDoesntHave ¶
func (q *PlanLevelQuery) WhereDoesntHave(relation string, callback func(*query.Builder)) *PlanLevelQuery
func (*PlanLevelQuery) WhereExists ¶
func (q *PlanLevelQuery) WhereExists(callback func(*query.Builder)) *PlanLevelQuery
func (*PlanLevelQuery) WhereHas ¶
func (q *PlanLevelQuery) WhereHas(relation string, callback func(*query.Builder)) *PlanLevelQuery
func (*PlanLevelQuery) WhereHasCount ¶
func (q *PlanLevelQuery) WhereHasCount(relation string, callback func(*query.Builder), operator string, count int) *PlanLevelQuery
func (*PlanLevelQuery) WhereIn ¶
func (q *PlanLevelQuery) WhereIn(column any, values []any) *PlanLevelQuery
func (*PlanLevelQuery) WhereKey ¶
func (q *PlanLevelQuery) WhereKey(id any) *PlanLevelQuery
func (*PlanLevelQuery) WhereNot ¶
func (q *PlanLevelQuery) WhereNot(column any, args ...any) *PlanLevelQuery
WhereNot adds a negated where clause, or a negated group.
func (*PlanLevelQuery) WhereNotExists ¶
func (q *PlanLevelQuery) WhereNotExists(callback func(*query.Builder)) *PlanLevelQuery
func (*PlanLevelQuery) WhereNotIn ¶
func (q *PlanLevelQuery) WhereNotIn(column any, values []any) *PlanLevelQuery
func (*PlanLevelQuery) WhereNotNull ¶
func (q *PlanLevelQuery) WhereNotNull(columns ...any) *PlanLevelQuery
func (*PlanLevelQuery) WhereNull ¶
func (q *PlanLevelQuery) WhereNull(columns ...any) *PlanLevelQuery
func (*PlanLevelQuery) WhereRelation ¶
func (q *PlanLevelQuery) WhereRelation(relation string, column any, args ...any) *PlanLevelQuery
func (*PlanLevelQuery) With ¶
func (q *PlanLevelQuery) With(relations ...string) *PlanLevelQuery
func (*PlanLevelQuery) WithAvg ¶
func (q *PlanLevelQuery) WithAvg(relation, column string) *PlanLevelQuery
func (*PlanLevelQuery) WithCount ¶
func (q *PlanLevelQuery) WithCount(relations ...string) *PlanLevelQuery
func (*PlanLevelQuery) WithExists ¶
func (q *PlanLevelQuery) WithExists(relation string) *PlanLevelQuery
func (*PlanLevelQuery) WithMax ¶
func (q *PlanLevelQuery) WithMax(relation, column string) *PlanLevelQuery
func (*PlanLevelQuery) WithMin ¶
func (q *PlanLevelQuery) WithMin(relation, column string) *PlanLevelQuery
func (*PlanLevelQuery) WithSum ¶
func (q *PlanLevelQuery) WithSum(relation, column string) *PlanLevelQuery
func (*PlanLevelQuery) Without ¶
func (q *PlanLevelQuery) Without(relations ...string) *PlanLevelQuery
func (*PlanLevelQuery) WithoutGlobalScope ¶
func (q *PlanLevelQuery) WithoutGlobalScope(identifier string) *PlanLevelQuery
func (*PlanLevelQuery) WithoutGlobalScopes ¶
func (q *PlanLevelQuery) WithoutGlobalScopes(identifiers ...string) *PlanLevelQuery
type PlanQuery ¶
type PlanQuery struct {
// contains filtered or unexported fields
}
PlanQuery is a query on the table of Plan.
The methods that build return the query, so they chain. The methods that run take a context and an auth.Grant, and return Plan rows or a value; there is no way to run one without a Grant.
func Plans ¶
Plans starts a query on the table of Plan, through db.
Global scopes are on and, unless the table is Global, every statement is filtered by the tenant of the Grant its terminal takes.
func (*PlanQuery) Base ¶
Base returns the core builder the query forwards to. It is for code in this package -- a local scope in the custom block of plan.go -- and for the factory, which builds rows through it.
func (*PlanQuery) CursorPaginate ¶
func (q *PlanQuery) CursorPaginate(ctx context.Context, g auth.Grant, perPage int, cursor *pagination.Cursor, opts pagination.Options, columns ...any) (PlanCollection, *pagination.CursorPage, error)
func (*PlanQuery) DoesntExist ¶
func (*PlanQuery) DoesntHave ¶
func (*PlanQuery) FindOrFail ¶
func (*PlanQuery) FirstOrCreate ¶
func (*PlanQuery) FirstOrFail ¶
func (*PlanQuery) FirstOrNew ¶
func (*PlanQuery) FirstWhere ¶
func (*PlanQuery) ForceCreate ¶
func (*PlanQuery) InsertOrIgnore ¶
func (*PlanQuery) New ¶
New returns an empty Plan on the query's connection, not yet saved, filled with what WithAttributes recorded on the query.
func (*PlanQuery) OrDoesntHave ¶
func (*PlanQuery) OrWhere ¶
OrWhere adds an or-where clause; a func(*PlanQuery) in place of the column adds a group.
func (*PlanQuery) OrWhereDoesntHave ¶
func (*PlanQuery) OrWhereHas ¶
func (*PlanQuery) OrWhereNot ¶
OrWhereNot adds an or-joined negated where clause, or a negated group.
func (*PlanQuery) OrWhereRelation ¶
func (*PlanQuery) OrderByDesc ¶
func (*PlanQuery) Paginate ¶
func (q *PlanQuery) Paginate(ctx context.Context, g auth.Grant, perPage, page int, opts pagination.Options, columns ...any) (PlanCollection, *pagination.LengthAwarePage, error)
func (*PlanQuery) SimplePaginate ¶
func (q *PlanQuery) SimplePaginate(ctx context.Context, g auth.Grant, perPage, page int, opts pagination.Options, columns ...any) (PlanCollection, *pagination.Page, error)
func (*PlanQuery) UpdateOrCreate ¶
func (*PlanQuery) ValueOrFail ¶
func (*PlanQuery) Where ¶
Where adds a where clause; a func(*PlanQuery) in place of the column adds a group.
func (*PlanQuery) WhereBelongsTo ¶
func (*PlanQuery) WhereBetween ¶
func (*PlanQuery) WhereDoesntHave ¶
func (*PlanQuery) WhereExists ¶
func (*PlanQuery) WhereHasCount ¶
func (*PlanQuery) WhereNotExists ¶
func (*PlanQuery) WhereNotNull ¶
func (*PlanQuery) WhereRelation ¶
func (*PlanQuery) WithExists ¶
func (*PlanQuery) WithoutGlobalScope ¶
func (*PlanQuery) WithoutGlobalScopes ¶
type PlanRequest ¶
type PlanRequest struct {
Name string
Kind PlanKind
// Rates are the basis points of each level, the first level first: one
// for a linear plan, one to MaxLevels for a multilevel one.
Rates []int64
// CookieDays is how long the referral cookie lives. Zero means
// DefaultCookieDays.
CookieDays int
// MinWithdrawal and MaxWithdrawal are centavos; a max of zero is no max.
MinWithdrawal int64
MaxWithdrawal int64
}
PlanRequest is what defining a commission plan takes.
func (PlanRequest) Validate ¶
func (r PlanRequest) Validate() validation.Errors
Validate reports the errors per field.
type PlanRow ¶
type PlanRow struct {
ID, Name, Kind, KindKey, Min, Max, Created, ActivateURL string
CookieDays int
Levels []LevelRow
Active bool
}
PlanRow is a plan as a screen shows it.
type Referral ¶
type Referral struct {
model.Model
ID string `db:"id"`
TenantID string `db:"tenant_id"`
// UserID is the user who was referred, unique per tenant: a user has one
// referrer, for life.
UserID string `db:"user_id"`
// AffiliateID is the affiliate who referred them.
AffiliateID string `db:"affiliate_id"`
// Document is the user's CPF or CNPJ when the application knows it, digits
// only and unique per tenant when present, so one person is not referred
// twice under two accounts.
Document OptionalText `db:"document"`
// Code is the code the user signed up with.
Code string `db:"code"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
}
Referral is the lifelong link of a user to the affiliate who referred them.
It is written once, when the user signs up with a referral code, and never changes: the cookie that carried the code only decides who the referrer is at that moment. Every payment of the user afterwards -- the first purchase and every renewal -- pays a commission up the tree that starts here.
type ReferralCollection ¶
type ReferralCollection []*Referral
ReferralCollection is rows of Referral, as a query returns them.
func ReferralCollectionOf ¶
func ReferralCollectionOf(rows model.Rows) ReferralCollection
ReferralCollectionOf converts rows of the table of Referral. A nil input is a nil collection.
func (ReferralCollection) Contains ¶
func (c ReferralCollection) Contains(key any) bool
func (ReferralCollection) Except ¶
func (c ReferralCollection) Except(keys ...any) ReferralCollection
func (ReferralCollection) Find ¶
func (c ReferralCollection) Find(key any) *Referral
func (ReferralCollection) FindOrFail ¶
func (c ReferralCollection) FindOrFail(key any) (*Referral, error)
func (ReferralCollection) Fresh ¶
func (c ReferralCollection) Fresh(ctx context.Context, g auth.Grant, with ...string) (ReferralCollection, error)
func (ReferralCollection) LoadMissing ¶
func (ReferralCollection) ModelKeys ¶
func (c ReferralCollection) ModelKeys() []any
func (ReferralCollection) Only ¶
func (c ReferralCollection) Only(keys ...any) ReferralCollection
func (ReferralCollection) Pluck ¶
func (c ReferralCollection) Pluck(column string) []any
func (ReferralCollection) Rows ¶
func (c ReferralCollection) Rows() model.Rows
Rows converts the collection back to the core's rows.
func (ReferralCollection) ToArray ¶
func (c ReferralCollection) ToArray() []map[string]any
func (ReferralCollection) Unique ¶
func (c ReferralCollection) Unique() ReferralCollection
type ReferralQuery ¶
type ReferralQuery struct {
// contains filtered or unexported fields
}
ReferralQuery is a query on the table of Referral.
The methods that build return the query, so they chain. The methods that run take a context and an auth.Grant, and return Referral rows or a value; there is no way to run one without a Grant.
func Referrals ¶
func Referrals(db model.DB) *ReferralQuery
Referrals starts a query on the table of Referral, through db.
Global scopes are on and, unless the table is Global, every statement is filtered by the tenant of the Grant its terminal takes.
func (*ReferralQuery) AddSelect ¶
func (q *ReferralQuery) AddSelect(columns ...any) *ReferralQuery
func (*ReferralQuery) Base ¶
func (q *ReferralQuery) Base() *model.Builder
Base returns the core builder the query forwards to. It is for code in this package -- a local scope in the custom block of referral.go -- and for the factory, which builds rows through it.
func (*ReferralQuery) Clone ¶
func (q *ReferralQuery) Clone() *ReferralQuery
Clone returns an independent copy of the query.
func (*ReferralQuery) CursorPaginate ¶
func (q *ReferralQuery) CursorPaginate(ctx context.Context, g auth.Grant, perPage int, cursor *pagination.Cursor, opts pagination.Options, columns ...any) (ReferralCollection, *pagination.CursorPage, error)
func (*ReferralQuery) DoesntExist ¶
func (*ReferralQuery) DoesntHave ¶
func (q *ReferralQuery) DoesntHave(relation, boolean string, callback func(*query.Builder)) *ReferralQuery
func (*ReferralQuery) FindMany ¶
func (q *ReferralQuery) FindMany(ctx context.Context, g auth.Grant, ids []any, columns ...any) (ReferralCollection, error)
func (*ReferralQuery) FindOrFail ¶
func (*ReferralQuery) FirstOrCreate ¶
func (*ReferralQuery) FirstOrFail ¶
func (*ReferralQuery) FirstOrNew ¶
func (*ReferralQuery) FirstWhere ¶
func (*ReferralQuery) ForPage ¶
func (q *ReferralQuery) ForPage(page, perPage int) *ReferralQuery
func (*ReferralQuery) ForceCreate ¶
func (*ReferralQuery) Get ¶
func (q *ReferralQuery) Get(ctx context.Context, g auth.Grant, columns ...any) (ReferralCollection, error)
Get runs the query and returns the rows.
func (*ReferralQuery) GroupBy ¶
func (q *ReferralQuery) GroupBy(groups ...any) *ReferralQuery
func (*ReferralQuery) Has ¶
func (q *ReferralQuery) Has(relation, operator string, count int, boolean string, callback func(*query.Builder)) *ReferralQuery
func (*ReferralQuery) InsertOrIgnore ¶
func (*ReferralQuery) Join ¶
func (q *ReferralQuery) Join(table any, first any, args ...any) *ReferralQuery
func (*ReferralQuery) Latest ¶
func (q *ReferralQuery) Latest(column ...string) *ReferralQuery
func (*ReferralQuery) Limit ¶
func (q *ReferralQuery) Limit(value int) *ReferralQuery
func (*ReferralQuery) New ¶
func (q *ReferralQuery) New() (*Referral, error)
New returns an empty Referral on the query's connection, not yet saved, filled with what WithAttributes recorded on the query.
func (*ReferralQuery) Offset ¶
func (q *ReferralQuery) Offset(value int) *ReferralQuery
func (*ReferralQuery) Oldest ¶
func (q *ReferralQuery) Oldest(column ...string) *ReferralQuery
func (*ReferralQuery) OrDoesntHave ¶
func (q *ReferralQuery) OrDoesntHave(relation string) *ReferralQuery
func (*ReferralQuery) OrHas ¶
func (q *ReferralQuery) OrHas(relation, operator string, count int) *ReferralQuery
func (*ReferralQuery) OrWhere ¶
func (q *ReferralQuery) OrWhere(column any, args ...any) *ReferralQuery
OrWhere adds an or-where clause; a func(*ReferralQuery) in place of the column adds a group.
func (*ReferralQuery) OrWhereDoesntHave ¶
func (q *ReferralQuery) OrWhereDoesntHave(relation string, callback func(*query.Builder)) *ReferralQuery
func (*ReferralQuery) OrWhereHas ¶
func (q *ReferralQuery) OrWhereHas(relation string, callback func(*query.Builder)) *ReferralQuery
func (*ReferralQuery) OrWhereNot ¶
func (q *ReferralQuery) OrWhereNot(column any, args ...any) *ReferralQuery
OrWhereNot adds an or-joined negated where clause, or a negated group.
func (*ReferralQuery) OrWhereRelation ¶
func (q *ReferralQuery) OrWhereRelation(relation string, column any, args ...any) *ReferralQuery
func (*ReferralQuery) OrderBy ¶
func (q *ReferralQuery) OrderBy(column any, direction ...string) *ReferralQuery
func (*ReferralQuery) OrderByDesc ¶
func (q *ReferralQuery) OrderByDesc(column any) *ReferralQuery
func (*ReferralQuery) Paginate ¶
func (q *ReferralQuery) Paginate(ctx context.Context, g auth.Grant, perPage, page int, opts pagination.Options, columns ...any) (ReferralCollection, *pagination.LengthAwarePage, error)
func (*ReferralQuery) Select ¶
func (q *ReferralQuery) Select(columns ...any) *ReferralQuery
func (*ReferralQuery) SelectRaw ¶
func (q *ReferralQuery) SelectRaw(expression string, bindings ...any) *ReferralQuery
func (*ReferralQuery) SimplePaginate ¶
func (q *ReferralQuery) SimplePaginate(ctx context.Context, g auth.Grant, perPage, page int, opts pagination.Options, columns ...any) (ReferralCollection, *pagination.Page, error)
func (*ReferralQuery) UpdateOrCreate ¶
func (*ReferralQuery) ValueOrFail ¶
func (*ReferralQuery) Where ¶
func (q *ReferralQuery) Where(column any, args ...any) *ReferralQuery
Where adds a where clause; a func(*ReferralQuery) in place of the column adds a group.
func (*ReferralQuery) WhereBelongsTo ¶
func (q *ReferralQuery) WhereBelongsTo(relationshipName string, related ...model.Entity) *ReferralQuery
func (*ReferralQuery) WhereBetween ¶
func (q *ReferralQuery) WhereBetween(column any, from, to any) *ReferralQuery
func (*ReferralQuery) WhereColumn ¶
func (q *ReferralQuery) WhereColumn(first any, args ...any) *ReferralQuery
func (*ReferralQuery) WhereDoesntHave ¶
func (q *ReferralQuery) WhereDoesntHave(relation string, callback func(*query.Builder)) *ReferralQuery
func (*ReferralQuery) WhereExists ¶
func (q *ReferralQuery) WhereExists(callback func(*query.Builder)) *ReferralQuery
func (*ReferralQuery) WhereHas ¶
func (q *ReferralQuery) WhereHas(relation string, callback func(*query.Builder)) *ReferralQuery
func (*ReferralQuery) WhereHasCount ¶
func (q *ReferralQuery) WhereHasCount(relation string, callback func(*query.Builder), operator string, count int) *ReferralQuery
func (*ReferralQuery) WhereIn ¶
func (q *ReferralQuery) WhereIn(column any, values []any) *ReferralQuery
func (*ReferralQuery) WhereKey ¶
func (q *ReferralQuery) WhereKey(id any) *ReferralQuery
func (*ReferralQuery) WhereNot ¶
func (q *ReferralQuery) WhereNot(column any, args ...any) *ReferralQuery
WhereNot adds a negated where clause, or a negated group.
func (*ReferralQuery) WhereNotExists ¶
func (q *ReferralQuery) WhereNotExists(callback func(*query.Builder)) *ReferralQuery
func (*ReferralQuery) WhereNotIn ¶
func (q *ReferralQuery) WhereNotIn(column any, values []any) *ReferralQuery
func (*ReferralQuery) WhereNotNull ¶
func (q *ReferralQuery) WhereNotNull(columns ...any) *ReferralQuery
func (*ReferralQuery) WhereNull ¶
func (q *ReferralQuery) WhereNull(columns ...any) *ReferralQuery
func (*ReferralQuery) WhereRelation ¶
func (q *ReferralQuery) WhereRelation(relation string, column any, args ...any) *ReferralQuery
func (*ReferralQuery) With ¶
func (q *ReferralQuery) With(relations ...string) *ReferralQuery
func (*ReferralQuery) WithAvg ¶
func (q *ReferralQuery) WithAvg(relation, column string) *ReferralQuery
func (*ReferralQuery) WithCount ¶
func (q *ReferralQuery) WithCount(relations ...string) *ReferralQuery
func (*ReferralQuery) WithExists ¶
func (q *ReferralQuery) WithExists(relation string) *ReferralQuery
func (*ReferralQuery) WithMax ¶
func (q *ReferralQuery) WithMax(relation, column string) *ReferralQuery
func (*ReferralQuery) WithMin ¶
func (q *ReferralQuery) WithMin(relation, column string) *ReferralQuery
func (*ReferralQuery) WithSum ¶
func (q *ReferralQuery) WithSum(relation, column string) *ReferralQuery
func (*ReferralQuery) Without ¶
func (q *ReferralQuery) Without(relations ...string) *ReferralQuery
func (*ReferralQuery) WithoutGlobalScope ¶
func (q *ReferralQuery) WithoutGlobalScope(identifier string) *ReferralQuery
func (*ReferralQuery) WithoutGlobalScopes ¶
func (q *ReferralQuery) WithoutGlobalScopes(identifiers ...string) *ReferralQuery
type Screen ¶
Screen is what every page of this package carries: the application's chrome, the sentences, and where the package is mounted.
func (Screen) AffiliateStatusOptions ¶
func (s Screen) AffiliateStatusOptions() []components.SelectOption
AffiliateStatusOptions are where an affiliate can stand.
func (Screen) CellForm ¶
CellForm is a small form posted from a table cell: the CSRF token of the page, the fields given, and one button. Every value is escaped.
func (Screen) CommissionStatusOptions ¶
func (s Screen) CommissionStatusOptions() []components.SelectOption
CommissionStatusOptions are where a commission can stand.
func (Screen) LevelOptions ¶
func (s Screen) LevelOptions() []components.SelectOption
LevelOptions are the levels a commission can be of.
func (Screen) PayoutKindOptions ¶
func (s Screen) PayoutKindOptions() []components.SelectOption
PayoutKindOptions are the kinds of payout account.
func (Screen) PixKeyOptions ¶
func (s Screen) PixKeyOptions() []components.SelectOption
PixKeyOptions are the kinds of PIX key.
func (Screen) PlanKindOptions ¶
func (s Screen) PlanKindOptions() []components.SelectOption
PlanKindOptions are the kinds of plan.
func (Screen) TableLines ¶
func (s Screen) TableLines() components.DataTableLines
TableLines are the sentences a data table on these screens says.
func (Screen) WithdrawalStatusOptions ¶
func (s Screen) WithdrawalStatusOptions() []components.SelectOption
WithdrawalStatusOptions are where a withdrawal request can stand.
type TableState ¶
TableState is a server-paged list: the filters in force and where the page is.
type TreeNode ¶
type TreeNode struct {
Level int
UserID string
ParentID string
AffiliateID string
Name string
Code string
Status AffiliateStatus
JoinedAt time.Time
}
TreeNode is one person in an affiliate's tree.
type WithdrawalDay ¶
type WithdrawalDay struct {
model.Model
ID string `db:"id"`
TenantID string `db:"tenant_id"`
AffiliateID string `db:"affiliate_id"`
Day Day `db:"day"`
WithdrawalRequestID string `db:"withdrawal_request_id"`
Attempt int `db:"attempt"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
}
WithdrawalDay is the one withdrawal an affiliate asked for on a day. Its unique index is what holds the rule of one a day under two requests sent at once; a request of the day that was rejected or cancelled frees the day.
func (*WithdrawalDay) Fresh ¶
func (row *WithdrawalDay) Fresh(ctx context.Context, g auth.Grant, with ...string) (*WithdrawalDay, error)
Fresh reads the row again, as a new WithdrawalDay; it shadows the untyped one the embedded model promotes.
func (*WithdrawalDay) Replicate ¶
func (row *WithdrawalDay) Replicate(except ...string) (*WithdrawalDay, error)
Replicate returns an unsaved copy of the row without its key; it shadows the untyped one the embedded model promotes.
type WithdrawalDayCollection ¶
type WithdrawalDayCollection []*WithdrawalDay
WithdrawalDayCollection is rows of WithdrawalDay, as a query returns them.
func WithdrawalDayCollectionOf ¶
func WithdrawalDayCollectionOf(rows model.Rows) WithdrawalDayCollection
WithdrawalDayCollectionOf converts rows of the table of WithdrawalDay. A nil input is a nil collection.
func (WithdrawalDayCollection) Contains ¶
func (c WithdrawalDayCollection) Contains(key any) bool
func (WithdrawalDayCollection) Except ¶
func (c WithdrawalDayCollection) Except(keys ...any) WithdrawalDayCollection
func (WithdrawalDayCollection) Find ¶
func (c WithdrawalDayCollection) Find(key any) *WithdrawalDay
func (WithdrawalDayCollection) FindOrFail ¶
func (c WithdrawalDayCollection) FindOrFail(key any) (*WithdrawalDay, error)
func (WithdrawalDayCollection) Fresh ¶
func (c WithdrawalDayCollection) Fresh(ctx context.Context, g auth.Grant, with ...string) (WithdrawalDayCollection, error)
func (WithdrawalDayCollection) LoadMissing ¶
func (WithdrawalDayCollection) ModelKeys ¶
func (c WithdrawalDayCollection) ModelKeys() []any
func (WithdrawalDayCollection) Only ¶
func (c WithdrawalDayCollection) Only(keys ...any) WithdrawalDayCollection
func (WithdrawalDayCollection) Pluck ¶
func (c WithdrawalDayCollection) Pluck(column string) []any
func (WithdrawalDayCollection) Rows ¶
func (c WithdrawalDayCollection) Rows() model.Rows
Rows converts the collection back to the core's rows.
func (WithdrawalDayCollection) ToArray ¶
func (c WithdrawalDayCollection) ToArray() []map[string]any
func (WithdrawalDayCollection) Unique ¶
func (c WithdrawalDayCollection) Unique() WithdrawalDayCollection
type WithdrawalDayQuery ¶
type WithdrawalDayQuery struct {
// contains filtered or unexported fields
}
WithdrawalDayQuery is a query on the table of WithdrawalDay.
The methods that build return the query, so they chain. The methods that run take a context and an auth.Grant, and return WithdrawalDay rows or a value; there is no way to run one without a Grant.
func WithdrawalDays ¶
func WithdrawalDays(db model.DB) *WithdrawalDayQuery
WithdrawalDays starts a query on the table of WithdrawalDay, through db.
Global scopes are on and, unless the table is Global, every statement is filtered by the tenant of the Grant its terminal takes.
func (*WithdrawalDayQuery) AddSelect ¶
func (q *WithdrawalDayQuery) AddSelect(columns ...any) *WithdrawalDayQuery
func (*WithdrawalDayQuery) Base ¶
func (q *WithdrawalDayQuery) Base() *model.Builder
Base returns the core builder the query forwards to. It is for code in this package -- a local scope in the custom block of ledger.go -- and for the factory, which builds rows through it.
func (*WithdrawalDayQuery) Clone ¶
func (q *WithdrawalDayQuery) Clone() *WithdrawalDayQuery
Clone returns an independent copy of the query.
func (*WithdrawalDayQuery) Create ¶
func (q *WithdrawalDayQuery) Create(ctx context.Context, g auth.Grant, attributes map[string]any) (*WithdrawalDay, error)
func (*WithdrawalDayQuery) Cursor ¶
func (q *WithdrawalDayQuery) Cursor(ctx context.Context, g auth.Grant) iter.Seq2[*WithdrawalDay, error]
func (*WithdrawalDayQuery) CursorPaginate ¶
func (q *WithdrawalDayQuery) CursorPaginate(ctx context.Context, g auth.Grant, perPage int, cursor *pagination.Cursor, opts pagination.Options, columns ...any) (WithdrawalDayCollection, *pagination.CursorPage, error)
func (*WithdrawalDayQuery) DoesntExist ¶
func (*WithdrawalDayQuery) DoesntHave ¶
func (q *WithdrawalDayQuery) DoesntHave(relation, boolean string, callback func(*query.Builder)) *WithdrawalDayQuery
func (*WithdrawalDayQuery) Find ¶
func (q *WithdrawalDayQuery) Find(ctx context.Context, g auth.Grant, id any, columns ...any) (*WithdrawalDay, error)
func (*WithdrawalDayQuery) FindMany ¶
func (q *WithdrawalDayQuery) FindMany(ctx context.Context, g auth.Grant, ids []any, columns ...any) (WithdrawalDayCollection, error)
func (*WithdrawalDayQuery) FindOrFail ¶
func (q *WithdrawalDayQuery) FindOrFail(ctx context.Context, g auth.Grant, id any, columns ...any) (*WithdrawalDay, error)
func (*WithdrawalDayQuery) FindOrNew ¶
func (q *WithdrawalDayQuery) FindOrNew(ctx context.Context, g auth.Grant, id any, columns ...any) (*WithdrawalDay, error)
func (*WithdrawalDayQuery) First ¶
func (q *WithdrawalDayQuery) First(ctx context.Context, g auth.Grant, columns ...any) (*WithdrawalDay, error)
First returns the first row, or nil and no error when there is none.
func (*WithdrawalDayQuery) FirstOrCreate ¶
func (q *WithdrawalDayQuery) FirstOrCreate(ctx context.Context, g auth.Grant, attributes, values map[string]any) (*WithdrawalDay, error)
func (*WithdrawalDayQuery) FirstOrFail ¶
func (q *WithdrawalDayQuery) FirstOrFail(ctx context.Context, g auth.Grant, columns ...any) (*WithdrawalDay, error)
func (*WithdrawalDayQuery) FirstOrNew ¶
func (q *WithdrawalDayQuery) FirstOrNew(ctx context.Context, g auth.Grant, attributes, values map[string]any) (*WithdrawalDay, error)
func (*WithdrawalDayQuery) FirstWhere ¶
func (q *WithdrawalDayQuery) FirstWhere(ctx context.Context, g auth.Grant, column any, args ...any) (*WithdrawalDay, error)
func (*WithdrawalDayQuery) ForPage ¶
func (q *WithdrawalDayQuery) ForPage(page, perPage int) *WithdrawalDayQuery
func (*WithdrawalDayQuery) ForceCreate ¶
func (q *WithdrawalDayQuery) ForceCreate(ctx context.Context, g auth.Grant, attributes map[string]any) (*WithdrawalDay, error)
func (*WithdrawalDayQuery) Get ¶
func (q *WithdrawalDayQuery) Get(ctx context.Context, g auth.Grant, columns ...any) (WithdrawalDayCollection, error)
Get runs the query and returns the rows.
func (*WithdrawalDayQuery) GroupBy ¶
func (q *WithdrawalDayQuery) GroupBy(groups ...any) *WithdrawalDayQuery
func (*WithdrawalDayQuery) Has ¶
func (q *WithdrawalDayQuery) Has(relation, operator string, count int, boolean string, callback func(*query.Builder)) *WithdrawalDayQuery
func (*WithdrawalDayQuery) InsertOrIgnore ¶
func (*WithdrawalDayQuery) Join ¶
func (q *WithdrawalDayQuery) Join(table any, first any, args ...any) *WithdrawalDayQuery
func (*WithdrawalDayQuery) Latest ¶
func (q *WithdrawalDayQuery) Latest(column ...string) *WithdrawalDayQuery
func (*WithdrawalDayQuery) Limit ¶
func (q *WithdrawalDayQuery) Limit(value int) *WithdrawalDayQuery
func (*WithdrawalDayQuery) New ¶
func (q *WithdrawalDayQuery) New() (*WithdrawalDay, error)
New returns an empty WithdrawalDay on the query's connection, not yet saved, filled with what WithAttributes recorded on the query.
func (*WithdrawalDayQuery) Offset ¶
func (q *WithdrawalDayQuery) Offset(value int) *WithdrawalDayQuery
func (*WithdrawalDayQuery) Oldest ¶
func (q *WithdrawalDayQuery) Oldest(column ...string) *WithdrawalDayQuery
func (*WithdrawalDayQuery) OrDoesntHave ¶
func (q *WithdrawalDayQuery) OrDoesntHave(relation string) *WithdrawalDayQuery
func (*WithdrawalDayQuery) OrHas ¶
func (q *WithdrawalDayQuery) OrHas(relation, operator string, count int) *WithdrawalDayQuery
func (*WithdrawalDayQuery) OrWhere ¶
func (q *WithdrawalDayQuery) OrWhere(column any, args ...any) *WithdrawalDayQuery
OrWhere adds an or-where clause; a func(*WithdrawalDayQuery) in place of the column adds a group.
func (*WithdrawalDayQuery) OrWhereDoesntHave ¶
func (q *WithdrawalDayQuery) OrWhereDoesntHave(relation string, callback func(*query.Builder)) *WithdrawalDayQuery
func (*WithdrawalDayQuery) OrWhereHas ¶
func (q *WithdrawalDayQuery) OrWhereHas(relation string, callback func(*query.Builder)) *WithdrawalDayQuery
func (*WithdrawalDayQuery) OrWhereNot ¶
func (q *WithdrawalDayQuery) OrWhereNot(column any, args ...any) *WithdrawalDayQuery
OrWhereNot adds an or-joined negated where clause, or a negated group.
func (*WithdrawalDayQuery) OrWhereRelation ¶
func (q *WithdrawalDayQuery) OrWhereRelation(relation string, column any, args ...any) *WithdrawalDayQuery
func (*WithdrawalDayQuery) OrderBy ¶
func (q *WithdrawalDayQuery) OrderBy(column any, direction ...string) *WithdrawalDayQuery
func (*WithdrawalDayQuery) OrderByDesc ¶
func (q *WithdrawalDayQuery) OrderByDesc(column any) *WithdrawalDayQuery
func (*WithdrawalDayQuery) Paginate ¶
func (q *WithdrawalDayQuery) Paginate(ctx context.Context, g auth.Grant, perPage, page int, opts pagination.Options, columns ...any) (WithdrawalDayCollection, *pagination.LengthAwarePage, error)
func (*WithdrawalDayQuery) Select ¶
func (q *WithdrawalDayQuery) Select(columns ...any) *WithdrawalDayQuery
func (*WithdrawalDayQuery) SelectRaw ¶
func (q *WithdrawalDayQuery) SelectRaw(expression string, bindings ...any) *WithdrawalDayQuery
func (*WithdrawalDayQuery) SimplePaginate ¶
func (q *WithdrawalDayQuery) SimplePaginate(ctx context.Context, g auth.Grant, perPage, page int, opts pagination.Options, columns ...any) (WithdrawalDayCollection, *pagination.Page, error)
func (*WithdrawalDayQuery) Sole ¶
func (q *WithdrawalDayQuery) Sole(ctx context.Context, g auth.Grant, columns ...any) (*WithdrawalDay, error)
func (*WithdrawalDayQuery) UpdateOrCreate ¶
func (q *WithdrawalDayQuery) UpdateOrCreate(ctx context.Context, g auth.Grant, attributes, values map[string]any) (*WithdrawalDay, error)
func (*WithdrawalDayQuery) ValueOrFail ¶
func (*WithdrawalDayQuery) Where ¶
func (q *WithdrawalDayQuery) Where(column any, args ...any) *WithdrawalDayQuery
Where adds a where clause; a func(*WithdrawalDayQuery) in place of the column adds a group.
func (*WithdrawalDayQuery) WhereBelongsTo ¶
func (q *WithdrawalDayQuery) WhereBelongsTo(relationshipName string, related ...model.Entity) *WithdrawalDayQuery
func (*WithdrawalDayQuery) WhereBetween ¶
func (q *WithdrawalDayQuery) WhereBetween(column any, from, to any) *WithdrawalDayQuery
func (*WithdrawalDayQuery) WhereColumn ¶
func (q *WithdrawalDayQuery) WhereColumn(first any, args ...any) *WithdrawalDayQuery
func (*WithdrawalDayQuery) WhereDoesntHave ¶
func (q *WithdrawalDayQuery) WhereDoesntHave(relation string, callback func(*query.Builder)) *WithdrawalDayQuery
func (*WithdrawalDayQuery) WhereExists ¶
func (q *WithdrawalDayQuery) WhereExists(callback func(*query.Builder)) *WithdrawalDayQuery
func (*WithdrawalDayQuery) WhereHas ¶
func (q *WithdrawalDayQuery) WhereHas(relation string, callback func(*query.Builder)) *WithdrawalDayQuery
func (*WithdrawalDayQuery) WhereHasCount ¶
func (q *WithdrawalDayQuery) WhereHasCount(relation string, callback func(*query.Builder), operator string, count int) *WithdrawalDayQuery
func (*WithdrawalDayQuery) WhereIn ¶
func (q *WithdrawalDayQuery) WhereIn(column any, values []any) *WithdrawalDayQuery
func (*WithdrawalDayQuery) WhereKey ¶
func (q *WithdrawalDayQuery) WhereKey(id any) *WithdrawalDayQuery
func (*WithdrawalDayQuery) WhereNot ¶
func (q *WithdrawalDayQuery) WhereNot(column any, args ...any) *WithdrawalDayQuery
WhereNot adds a negated where clause, or a negated group.
func (*WithdrawalDayQuery) WhereNotExists ¶
func (q *WithdrawalDayQuery) WhereNotExists(callback func(*query.Builder)) *WithdrawalDayQuery
func (*WithdrawalDayQuery) WhereNotIn ¶
func (q *WithdrawalDayQuery) WhereNotIn(column any, values []any) *WithdrawalDayQuery
func (*WithdrawalDayQuery) WhereNotNull ¶
func (q *WithdrawalDayQuery) WhereNotNull(columns ...any) *WithdrawalDayQuery
func (*WithdrawalDayQuery) WhereNull ¶
func (q *WithdrawalDayQuery) WhereNull(columns ...any) *WithdrawalDayQuery
func (*WithdrawalDayQuery) WhereRelation ¶
func (q *WithdrawalDayQuery) WhereRelation(relation string, column any, args ...any) *WithdrawalDayQuery
func (*WithdrawalDayQuery) With ¶
func (q *WithdrawalDayQuery) With(relations ...string) *WithdrawalDayQuery
func (*WithdrawalDayQuery) WithAvg ¶
func (q *WithdrawalDayQuery) WithAvg(relation, column string) *WithdrawalDayQuery
func (*WithdrawalDayQuery) WithCount ¶
func (q *WithdrawalDayQuery) WithCount(relations ...string) *WithdrawalDayQuery
func (*WithdrawalDayQuery) WithExists ¶
func (q *WithdrawalDayQuery) WithExists(relation string) *WithdrawalDayQuery
func (*WithdrawalDayQuery) WithMax ¶
func (q *WithdrawalDayQuery) WithMax(relation, column string) *WithdrawalDayQuery
func (*WithdrawalDayQuery) WithMin ¶
func (q *WithdrawalDayQuery) WithMin(relation, column string) *WithdrawalDayQuery
func (*WithdrawalDayQuery) WithSum ¶
func (q *WithdrawalDayQuery) WithSum(relation, column string) *WithdrawalDayQuery
func (*WithdrawalDayQuery) Without ¶
func (q *WithdrawalDayQuery) Without(relations ...string) *WithdrawalDayQuery
func (*WithdrawalDayQuery) WithoutGlobalScope ¶
func (q *WithdrawalDayQuery) WithoutGlobalScope(identifier string) *WithdrawalDayQuery
func (*WithdrawalDayQuery) WithoutGlobalScopes ¶
func (q *WithdrawalDayQuery) WithoutGlobalScopes(identifiers ...string) *WithdrawalDayQuery
type WithdrawalRequest ¶
type WithdrawalRequest struct {
// Amount is centavos; zero asks for everything available.
Amount int64
AccountID string
}
WithdrawalRequest is what an affiliate asks for.
type WithdrawalRow ¶
type WithdrawalRow struct {
ID, Affiliate, AffiliateURL, Amount, Account, Status, StatusKey, RequestedAt, Reason string
Open, Processing, Paid bool
ProcessURL, PayURL, RejectURL, ReceiptURL string
}
WithdrawalRow is one withdrawal request as a screen shows it.
Source Files
¶
- AffiliateQuery.go
- ClickQuery.go
- CommissionQuery.go
- ConversionQuery.go
- PlanLevelQuery.go
- PlanQuery.go
- ReferralQuery.go
- WithdrawalDayQuery.go
- commission_service.go
- config.go
- ledger.go
- model.go
- module.go
- plan.go
- plan_service.go
- policy.go
- referral.go
- referral_service.go
- resources.go
- screens.go
- service.go
- translation.go
- views.go
- withdrawal_service.go