customer

package
v0.4.6 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: AGPL-3.0 Imports: 39 Imported by: 1

Documentation

Overview

Nging is a toolbox for webmasters Copyright (C) 2018-present Wenhui Shen <[email protected]>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.

Index

Constants

View Source
const (
	GroupPackageTimeDay     = `day`
	GroupPackageTimeWeek    = `week`
	GroupPackageTimeMonth   = `month`
	GroupPackageTimeYear    = `year`
	GroupPackageTimeForever = `forever`
)
View Source
const (
	AssetTypeMoney      = `money`
	AssetTypeIntegral   = `integral`
	AssetTypeCredit     = `credit`
	AssetTypePoint      = `point`
	AssetTypeGold       = `gold`
	AssetTypeSilver     = `silver`
	AssetTypeCopper     = `copper`
	AssetTypeExperience = `experience`
)

资产类型

View Source
const (
	AmountTypeBalance = `balance`
	AmountTypeFreeze  = `freeze`
)

金额类型

View Source
const (
	//状态(pending-待确认;confirmed-已确认;canceled-已取消)
	FlowStatusPending   = `pending`
	FlowStatusConfirmed = `confirmed`
	FlowStatusCanceled  = `canceled`
)

资金流水记录状态

Variables

View Source
var (
	ComplaintTypes   = echo.NewKVData()
	ComplaintTargets = echo.NewKVData()
)
View Source
var (
	PrivateFields = []string{
		`session_id`,
		`id_card_no`,
		`real_name`,
		`password`,
		`salt`,
		`safe_pwd`,
		`created`,
		`updated`,
		`file_num`,
		`file_size`,
	}

	PrivateFieldsWithMobileEmail = append([]string{
		`mobile_bind`,
		`mobile`,
		`email_bind`,
		`email`,
	}, PrivateFields...)

	//CusomterSafeFields 可公开的客户信息字段
	CusomterSafeFields = []interface{}{
		`id`,
		`name`,
		`gender`,
		`uid`,
		`group_id`,
		`avatar`,
		`online`,
		`following`,
		`followers`,
		`agent_level`,
	}

	CusomterSafeFieldsSelector = func(sel sqlbuilder.Selector) sqlbuilder.Selector {
		return sel.Columns(CusomterSafeFields...)
	}

	//UserSafeFields 可公开的后台用户信息字段
	UserSafeFields = []interface{}{
		`id`,
		`username`,
		`gender`,
		`avatar`,
		`online`,
	}

	UserSafeFieldsSelector = func(sel sqlbuilder.Selector) sqlbuilder.Selector {
		return sel.Columns(UserSafeFields...)
	}
)
View Source
var (
	// CustomerPasswordMinLength 客户登录密码最小长度
	CustomerPasswordMinLength = 8
	// CustomerSafePwdMinLength 客户安全密码最小长度
	CustomerSafePwdMinLength = 6
)
View Source
var (
	DevicePlatforms       = echo.NewKVData()
	DeviceScenses         = echo.NewKVData()
	DefaultDevicePlatform = `pc`
	DefaultDeviceScense   = `web`
)
View Source
var (
	// AssetTypes 资产类型
	AssetTypes = echo.NewKVData()
	// AmountTypes 金额类型
	AmountTypes = echo.NewKVData()
	// 资金流水记录状态
	FlowStatus = echo.NewKVData()
)
View Source
var (
	ComplaintProcesses = echo.NewKVData()
)
View Source
var ErrCardNumberAlreadyExists = errors.New(`Card number already exists`)
View Source
var ErrInvalidSession = errors.New(`invalid session`)
View Source
var ErrSameDay = errors.New("same day")

ErrSameDay 同一天不能领取两次奖励

View Source
var GroupPackageTimeUnits = echo.NewKVData().
	Add(GroupPackageTimeDay, `天`).
	Add(GroupPackageTimeWeek, `周`).
	Add(GroupPackageTimeMonth, `月`).
	Add(GroupPackageTimeYear, `年`).
	Add(GroupPackageTimeForever, `永久`)
View Source
var JWTMaxLifeTime int64 = 90 * 86400

JWTMaxLifeTime JWT寿命(单位:秒)

Functions

func AssetTypeIsIgnoreAccumulated added in v0.2.9

func AssetTypeIsIgnoreAccumulated(assetType string) bool

AssetTypeIsIgnoreAccumulated 判断某种资产类型是否不支持累计历史值

func AssetTypeList

func AssetTypeList() []*echo.KV

func ClearPasswordData

func ClearPasswordData(rawCustomer *dbschema.OfficialCustomer) dbschema.OfficialCustomer

func ComplaintProcessAdd

func ComplaintProcessAdd(key, name string)

func ComplaintProcessList

func ComplaintProcessList() []*echo.KV

func ComplaintTargetAdd

func ComplaintTargetAdd(key, name string, fn ComplaintFunc, urlFormat func(*dbschema.OfficialCommonComplaint) string)

func ComplaintTargetList

func ComplaintTargetList() []*echo.KV

func ComplaintTypeAdd

func ComplaintTypeAdd(key, name string, fn ComplaintFunc)

func ComplaintTypeList

func ComplaintTypeList() []*echo.KV

func CustomerPermTTL

func CustomerPermTTL(c echo.Context) int64

func CustomerPermission

func CustomerPermission(c echo.Context, customers ...*dbschema.OfficialCustomer) *xrole.RolePermission

func CustomerRolePermissionForBehavior added in v0.2.18

func CustomerRolePermissionForBehavior(c echo.Context, behaviorName string, customer ...*dbschema.OfficialCustomer) interface{}

func CustomerRoles

func CustomerRoles(c echo.Context, customers ...*dbschema.OfficialCustomer) (roleList []*xrole.CustomerRoleWithPermissions)

func ExecComplaintTargetFunc

func ExecComplaintTargetFunc(key string, mdl *dbschema.OfficialCommonComplaint) error

func ExecComplaintTypeFunc

func ExecComplaintTypeFunc(key string, mdl *dbschema.OfficialCommonComplaint) error

func FireSignIn

func FireSignIn(customer *dbschema.OfficialCustomer) error

func FireSignOut

func FireSignOut(customer *dbschema.OfficialCustomer) error

func GroupPackageTimeUnitSuffix added in v0.2.9

func GroupPackageTimeUnitSuffix(c echo.Context, n uint, unit string) string

func OnSignIn

func OnSignIn(f Event)

func OnSignOut

func OnSignOut(f Event)

Types

type Complaint

type Complaint struct {
	*dbschema.OfficialCommonComplaint
}

func NewComplaint

func NewComplaint(ctx echo.Context) *Complaint

func (*Complaint) Add

func (f *Complaint) Add() (pk interface{}, err error)

func (*Complaint) Delete

func (f *Complaint) Delete(mw func(db.Result) db.Result, args ...interface{}) error

func (*Complaint) Edit

func (f *Complaint) Edit(mw func(db.Result) db.Result, args ...interface{}) error

func (*Complaint) ListPage

func (f *Complaint) ListPage(cond *db.Compounds, orderby ...interface{}) ([]*ComplaintExt, error)

type ComplaintExt

type ComplaintExt struct {
	*dbschema.OfficialCommonComplaint
	Customer       *dbschema.OfficialCustomer `db:"-,relation=id:customer_id"`
	TypeName       string                     `db:"-"`
	TargetTypeName string                     `db:"-"`
	// contains filtered or unexported fields
}

func (*ComplaintExt) SetURLFormat

func (c *ComplaintExt) SetURLFormat(fn func(*dbschema.OfficialCommonComplaint) string) *ComplaintExt

func (*ComplaintExt) URLFormat

func (c *ComplaintExt) URLFormat() string

type ComplaintFunc

type ComplaintFunc func(*dbschema.OfficialCommonComplaint) error

type Counter

type Counter struct {
	*dbschema.OfficialCustomerCounter
}

func NewCounter

func NewCounter(ctx echo.Context) *Counter

func (*Counter) Add

func (u *Counter) Add() (interface{}, error)

func (*Counter) Decr

func (u *Counter) Decr(target string, n uint64) error

func (*Counter) Exists

func (u *Counter) Exists() (bool, error)

func (*Counter) GetTotal

func (u *Counter) GetTotal(target string) (uint64, error)

func (*Counter) GetTotals

func (u *Counter) GetTotals(targets ...string) (map[string]uint64, error)

func (*Counter) Incr

func (u *Counter) Incr(target string, n uint64) error

type Customer

type Customer struct {
	*dbschema.OfficialCustomer
}

func NewCustomer

func NewCustomer(ctx echo.Context) *Customer

func (*Customer) APIData

func (f *Customer) APIData(customers ...*dbschema.OfficialCustomer) echo.H

APIData 返回给API接口的数据

func (*Customer) Add

func (f *Customer) Add() (pk interface{}, err error)

func (*Customer) AddExperience

func (f *Customer) AddExperience(amount float64, customerID uint64, sourceType string, sourceTable string, sourceID uint64, description string) error

AddExperience 增加经验值

func (*Customer) AddIntegral

func (f *Customer) AddIntegral(amount float64, customerID uint64, sourceType string, sourceTable string, sourceID uint64, description string) error

AddIntegral 增加消费积分

func (*Customer) AddRewardOnSignIn

func (f *Customer) AddRewardOnSignIn(amount float64) error

AddRewardOnSignIn 登录时奖励

func (*Customer) AddRewardOnSignUp

func (f *Customer) AddRewardOnSignUp(amount float64) error

AddRewardOnSignUp 注册时奖励

func (*Customer) CheckNewPassword

func (f *Customer) CheckNewPassword(pass string) error

func (*Customer) CheckNewSafePwd

func (f *Customer) CheckNewSafePwd(pass string) error

func (*Customer) CheckSafePassword

func (f *Customer) CheckSafePassword(pass string) error

func (*Customer) CheckSignInPassword

func (f *Customer) CheckSignInPassword(pass string) error

func (*Customer) ClearPasswordData

func (f *Customer) ClearPasswordData(customers ...*dbschema.OfficialCustomer) dbschema.OfficialCustomer

func (*Customer) DecrFileSizeAndNum

func (f *Customer) DecrFileSizeAndNum(customerID uint64, fileSize uint64, fileNum uint64) error

func (*Customer) Edit

func (f *Customer) Edit(mw func(db.Result) db.Result, args ...interface{}) error

func (*Customer) Exists

func (f *Customer) Exists(name string, fields ...string) (bool, error)

func (*Customer) ExistsOther

func (f *Customer) ExistsOther(name string, id uint64, fields ...string) (bool, error)

func (*Customer) FireSignInSuccess

func (f *Customer) FireSignInSuccess(co *CustomerOptions, authType string, options ...CustomerOption) (err error)

func (*Customer) FireSignUpSuccess

func (f *Customer) FireSignUpSuccess(co *CustomerOptions, authType string, options ...CustomerOption) (err error)

func (*Customer) GetByJWT

func (f *Customer) GetByJWT() (*dbschema.OfficialCustomer, error)

func (*Customer) GetDetail

func (f *Customer) GetDetail(cond db.Compound) (*CustomerAndGroup, error)

func (*Customer) GetUploadConfig added in v0.2.18

func (f *Customer) GetUploadConfig(customer *dbschema.OfficialCustomer) *xroleupload.CustomerUpload

func (*Customer) IncrFileSizeAndNum

func (f *Customer) IncrFileSizeAndNum(customerID uint64, fileSize uint64, fileNum uint64) error

func (*Customer) IncrLoginFails

func (f *Customer) IncrLoginFails() error

func (*Customer) IsSameDay

func (f *Customer) IsSameDay(assetType string, sourceType string) error

IsSameDay 是否为同一天领取第二次

func (*Customer) JWTClaims

func (f *Customer) JWTClaims(customers ...*dbschema.OfficialCustomer) *jwt.RegisteredClaims

func (*Customer) JWTSignedString

func (f *Customer) JWTSignedString(key interface{}, customers ...*dbschema.OfficialCustomer) (string, error)

func (*Customer) LevelUpOnSignIn

func (f *Customer) LevelUpOnSignIn(set echo.H) error

LevelUpOnSignIn 登录时检查是否可升级

func (*Customer) LinkOAuthUser

func (f *Customer) LinkOAuthUser() error

func (*Customer) ListPage

func (f *Customer) ListPage(cond *db.Compounds, orderby ...interface{}) ([]*CustomerAndGroup, error)

func (*Customer) NewLoginLog

func (f *Customer) NewLoginLog(username string, authType string) *model.LoginLog

func (*Customer) RecountFile added in v0.2.18

func (f *Customer) RecountFile(customerId ...uint64) (totalNum uint64, totalSize uint64, err error)

RecountFile 重新统计客户上传的文件数量和尺寸

func (*Customer) ResetLoginFails

func (f *Customer) ResetLoginFails() error

func (*Customer) SafeDecrFileSizeAndNum added in v0.2.18

func (f *Customer) SafeDecrFileSizeAndNum(customerID uint64, fileSize uint64, fileNum uint64) error

func (*Customer) SetSession

func (f *Customer) SetSession(customers ...*dbschema.OfficialCustomer)

SetSession 记录登录信息

func (*Customer) SignIn

func (f *Customer) SignIn(user, pass, signInType string, options ...CustomerOption) error

SignIn 用户登录

func (*Customer) SignUp

func (f *Customer) SignUp(user, pass, mobile, email string, options ...CustomerOption) error

SignUp 注册用户

func (*Customer) UnsetSession

func (f *Customer) UnsetSession() error

UnsetSession 退出登录

func (*Customer) UpdateSafePassword

func (f *Customer) UpdateSafePassword(pass string) error

func (*Customer) UpdateSignInPassword

func (f *Customer) UpdateSignInPassword(pass string) error

func (*Customer) VerifySession

func (f *Customer) VerifySession(customers ...*dbschema.OfficialCustomer) error

type CustomerAndGroup

type CustomerAndGroup struct {
	*dbschema.OfficialCustomer
	Group       *dbschema.OfficialCommonGroup        `db:"-,relation=id:group_id|gtZero"`
	Level       *dbschema.OfficialCustomerLevel      `db:"-,relation=id:level_id|gtZero"`
	LevelExtend []*modelLevel.RelationExt            `db:"-" json:",omitempty"`
	Agent       *dbschema.OfficialCustomerAgentLevel `db:"-,relation=id:agent_level|gtZero"`
	Roles       []*dbschema.OfficialCustomerRole     `db:"-,relation=id:role_ids|notEmpty|split"`
}

func (*CustomerAndGroup) AsMap

func (d *CustomerAndGroup) AsMap() param.Store

type CustomerOption

type CustomerOption func(*CustomerOptions)

func CustomerDeviceNo

func CustomerDeviceNo(deviceNo string) CustomerOption

func CustomerEmail

func CustomerEmail(email string) CustomerOption

func CustomerMaxAge

func CustomerMaxAge(maxAge time.Duration) CustomerOption

func CustomerMaxAgeSeconds

func CustomerMaxAgeSeconds(maxAgeSeconds int) CustomerOption

func CustomerMobile

func CustomerMobile(mobile string) CustomerOption

func CustomerName

func CustomerName(name string) CustomerOption

func CustomerPassword

func CustomerPassword(password string) CustomerOption

func CustomerPlatform

func CustomerPlatform(platform string) CustomerOption

func CustomerScense

func CustomerScense(scense string) CustomerOption

func CustomerSignInType

func CustomerSignInType(signInType string) CustomerOption

func GenerateOptionsFromHeader

func GenerateOptionsFromHeader(c echo.Context, maxAge ...int) []CustomerOption

type CustomerOptions

type CustomerOptions struct {
	*dbschema.OfficialCustomer
	MaxAge     time.Duration // 登录状态有效时长
	SignInType string        // 登录方式
	Scense     string        // 场景
	Platform   string        // 系统平台
	DeviceNo   string        // 设备编号
}

func NewCustomerOptions

func NewCustomerOptions(customerM *dbschema.OfficialCustomer, noClear ...bool) *CustomerOptions

type Device

type Device struct {
	*dbschema.OfficialCustomerDevice
}

func NewDevice

func NewDevice(ctx echo.Context) *Device

NewDevice 客户登录设备

func (*Device) Add

func (f *Device) Add() (pk interface{}, err error)

func (*Device) CleanCustomer

func (f *Device) CleanCustomer(customer *dbschema.OfficialCustomer, options ...CustomerOption) (err error)

func (*Device) CleanExceedLimit

func (f *Device) CleanExceedLimit(customerID uint64, multideviceSignin *multidivicesignin.MultideviceSignin) error

func (*Device) CleanExpired

func (f *Device) CleanExpired() (err error)

func (*Device) Delete

func (f *Device) Delete(mw func(db.Result) db.Result, args ...interface{}) error

func (*Device) Edit

func (f *Device) Edit(mw func(db.Result) db.Result, args ...interface{}) error

func (*Device) Exists

func (f *Device) Exists(customerID uint64, scense, platform, deviceNo string) (bool, error)

func (*Device) ExistsOther

func (f *Device) ExistsOther(customerID uint64, scense, platform, deviceNo string, excludeIDs uint64) (bool, error)

func (*Device) Kick

func (f *Device) Kick(customerID uint64) (err error)

func (*Device) SetDefaults

func (f *Device) SetDefaults()

func (*Device) SetOptions

func (f *Device) SetOptions(options *CustomerOptions) *Device

func (*Device) SignOut

func (f *Device) SignOut(mw func(db.Result) db.Result, args ...interface{}) error

func (*Device) Upsert

func (f *Device) Upsert() (pk interface{}, err error)

type Event

type Event func(*dbschema.OfficialCustomer) error

type Events

type Events []Event

func (Events) Execute

func (e Events) Execute(customer *dbschema.OfficialCustomer) error

type Following

type Following struct {
	*dbschema.OfficialCustomerFollowing
}

func NewFollowing

func NewFollowing(ctx echo.Context) *Following

func (*Following) Add

func (f *Following) Add() (pk interface{}, err error)

func (*Following) Delete

func (f *Following) Delete(mw func(db.Result) db.Result, args ...interface{}) error

func (*Following) Edit

func (f *Following) Edit(mw func(db.Result) db.Result, args ...interface{}) error

func (*Following) Exists

func (f *Following) Exists(customerA uint64, customerB uint64) (bool, error)

type FollowingAndCustomer

type FollowingAndCustomer struct {
	*dbschema.OfficialCustomerFollowing
	Customer echo.H
}

type GroupPackage added in v0.2.9

type GroupPackage struct {
	*dbschema.OfficialCustomerGroupPackage
}

GroupPackage 等级组套餐价格

func NewGroupPackage added in v0.2.9

func NewGroupPackage(ctx echo.Context) *GroupPackage

func (*GroupPackage) Add added in v0.2.9

func (u *GroupPackage) Add() (interface{}, error)

func (*GroupPackage) Delete added in v0.2.9

func (f *GroupPackage) Delete(mw func(db.Result) db.Result, args ...interface{}) error

func (*GroupPackage) Edit added in v0.2.9

func (f *GroupPackage) Edit(mw func(db.Result) db.Result, args ...interface{}) error

func (*GroupPackage) IncrSold added in v0.2.9

func (u *GroupPackage) IncrSold(id uint, n ...int) error

func (*GroupPackage) ListByGroup added in v0.2.9

func (u *GroupPackage) ListByGroup(group string) error

ListByGroup 列出某个组的套餐信息

func (*GroupPackage) ListGroup added in v0.2.9

func (u *GroupPackage) ListGroup() ([]string, error)

ListGroup 列出设置有套餐的组名称

func (*GroupPackage) MakeExpireTime added in v0.2.9

func (u *GroupPackage) MakeExpireTime(baseTime ...time.Time) time.Time

type Invitation

type Invitation struct {
	*dbschema.OfficialCustomerInvitation
}

func NewInvitation

func NewInvitation(ctx echo.Context) *Invitation

func (*Invitation) Add

func (f *Invitation) Add() (pk interface{}, err error)

func (*Invitation) Delete

func (f *Invitation) Delete(mw func(db.Result) db.Result, args ...interface{}) error

func (*Invitation) Edit

func (f *Invitation) Edit(mw func(db.Result) db.Result, args ...interface{}) error

func (*Invitation) Exists

func (f *Invitation) Exists(code string, excludeIDs ...uint) (bool, error)

func (*Invitation) FindCode

func (f *Invitation) FindCode(invitationCode string) error

func (*Invitation) UseCode

func (f *Invitation) UseCode(invitationID uint, customer *dbschema.OfficialCustomer) error

type InvitationCustomer

type InvitationCustomer struct {
	*dbschema.OfficialCustomerInvitationUsed
}

func NewInvitationCustomer

func NewInvitationCustomer(ctx echo.Context) *InvitationCustomer

func (*InvitationCustomer) ListCustomer

func (f *InvitationCustomer) ListCustomer(cond *db.Compounds, orderby ...interface{}) ([]*InvitationCustomerExt, error)

func (*InvitationCustomer) ListCustomerWithCode

func (f *InvitationCustomer) ListCustomerWithCode(cond *db.Compounds, orderby ...interface{}) ([]*InvitationCustomerWithCode, error)

type InvitationCustomerExt

type InvitationCustomerExt struct {
	*dbschema.OfficialCustomerInvitationUsed
	Customer   *dbschema.OfficialCustomer           `db:"-,relation=id:customer_id|gtZero"`
	Level      *dbschema.OfficialCustomerLevel      `db:"-,relation=id:level_id|gtZero"`
	AgentLevel *dbschema.OfficialCustomerAgentLevel `db:"-,relation=id:agent_level_id|gtZero"`
	RoleList   []*dbschema.OfficialCustomerRole     `db:"-,relation=id:role_ids|split"`
}

type InvitationCustomerWithCode

type InvitationCustomerWithCode struct {
	*dbschema.OfficialCustomerInvitationUsed
	Customer   *dbschema.OfficialCustomer           `db:"-,relation=id:customer_id|gtZero"`
	Level      *dbschema.OfficialCustomerLevel      `db:"-,relation=id:level_id|gtZero"`
	AgentLevel *dbschema.OfficialCustomerAgentLevel `db:"-,relation=id:agent_level_id|gtZero"`
	RoleList   []*dbschema.OfficialCustomerRole     `db:"-,relation=id:role_ids|split"`
	Invitation *dbschema.OfficialCustomerInvitation `db:"-,relation=id:invitation_id|gtZero"`
}

type Level

type Level struct {
	*dbschema.OfficialCustomerLevelRelation
}

func NewLevel

func NewLevel(ctx echo.Context) *Level

NewLevel 客户关联等级信息

func (*Level) Add

func (f *Level) Add() (pk interface{}, err error)

func (*Level) Delete

func (f *Level) Delete(mw func(db.Result) db.Result, args ...interface{}) error

func (*Level) Edit

func (f *Level) Edit(mw func(db.Result) db.Result, args ...interface{}) error

func (*Level) Exists

func (f *Level) Exists(customerID uint64, levelID uint) (bool, error)

func (*Level) GetByCustomerID added in v0.2.9

func (f *Level) GetByCustomerID(group string, customerID uint64) (result *modelLevel.RelationExt, err error)

func (*Level) HasLevel

func (f *Level) HasLevel(customerID uint64, levelIds ...interface{}) (bool, error)

func (*Level) HasPassedDays added in v0.2.9

func (f *Level) HasPassedDays() (days uint)

func (*Level) UpdateAllExpired added in v0.2.9

func (f *Level) UpdateAllExpired() error

type Message

func NewMessage

func NewMessage(ctx echo.Context) *Message

NewMessage 站内信

func (*Message) AddData

func (f *Message) AddData(customer *dbschema.OfficialCustomer, user *dbschemaNging.NgingUser) (pk interface{}, err error)

AddData 添加消息 * customer 操作客户 * user 操作后台用户

func (*Message) CheckRecvCustomerPerm

func (f *Message) CheckRecvCustomerPerm(customer *dbschema.OfficialCustomer) bool

func (*Message) CheckRecvPerm

func (f *Message) CheckRecvPerm(customer *dbschema.OfficialCustomer) bool

CheckRecvPerm 检查是否为收信人权限

func (*Message) CheckRecvUserPerm

func (f *Message) CheckRecvUserPerm(customer *dbschema.OfficialCustomer) bool

func (*Message) CountTodaySends

func (f *Message) CountTodaySends(customerID uint64) int64

func (*Message) CountUnread

func (f *Message) CountUnread(viewerID uint64, groupIDs []uint, isSystemMessage bool, viewerTypes ...string) int64

func (*Message) CustomerMaxPerDay

func (f *Message) CustomerMaxPerDay() (int64, int64)

func (*Message) DecodeContent

func (*Message) Delete

func (f *Message) Delete(args ...interface{}) error

Delete 循环删除

func (*Message) Edit

func (f *Message) Edit(mw func(db.Result) db.Result, args ...interface{}) error

func (*Message) GetWithViewed

func (f *Message) GetWithViewed(row *dbschema.OfficialCommonMessage) (*MessageWithViewed, error)

func (*Message) IsSystemMessage

func (f *Message) IsSystemMessage() bool

func (*Message) LastSend

func (f *Message) LastSend(customerID uint64) (*dbschema.OfficialCommonMessage, error)

func (*Message) ListAll

func (f *Message) ListAll(onlyUnread bool, otherCond db.Compound) ([]*MessageWithViewed, error)

ListAll 列出所有人的消息

func (*Message) ListWithViewedByRecipient

func (f *Message) ListWithViewedByRecipient(viewerID uint64, groupIDs []uint, isSystemMessage bool, onlyUnread bool, otherCond db.Compound, viewerTypes ...string) ([]*MessageWithViewed, error)

ListWithViewedByRecipient 收件箱列表

func (*Message) ListWithViewedBySender

func (f *Message) ListWithViewedBySender(senderID uint64, onlyUnread bool, otherCond db.Compound, viewerTypes ...string) ([]*MessageWithViewed, error)

ListWithViewedBySender 发件箱列表

func (*Message) MsgUser

func (f *Message) MsgUser() *MsgUser

func (*Message) ToTable

func (f *Message) ToTable(m sqlbuilder.Name_) string

func (*Message) View

func (f *Message) View(row *dbschema.OfficialCommonMessage, viewerID uint64, groupIDs []uint, viewerTypes ...string) error

func (*Message) WithViewedByAll

func (f *Message) WithViewedByAll(rows []*dbschema.OfficialCommonMessage) ([]*MessageWithViewed, error)

func (*Message) WithViewedByRecipient

func (f *Message) WithViewedByRecipient(rows []*dbschema.OfficialCommonMessage, viewerID uint64, viewerType string) ([]*MessageWithViewed, error)

func (*Message) WithViewedBySender

func (f *Message) WithViewedBySender(rows []*dbschema.OfficialCommonMessage) ([]*MessageWithViewed, error)

type MessageWithViewed

type MessageWithViewed struct {
	*dbschema.OfficialCommonMessage
	MsgFrom  *MsgUser `json:",omitempty"`
	MsgTo    *MsgUser `json:",omitempty"`
	IsViewed bool
}

func (*MessageWithViewed) MsgUser

func (m *MessageWithViewed) MsgUser() *MsgUser

type MsgUser

type MsgUser struct {
	Name   string
	Id     uint64
	Avatar string
	Type   string //user-后台用户; customer-前台用户
}

type OAuth

type OAuth struct {
	*dbschema.OfficialCustomerOauth
}

func NewOAuth

func NewOAuth(ctx echo.Context) *OAuth

func (*OAuth) Add

func (f *OAuth) Add() (pk interface{}, err error)

func (*OAuth) CopyFrom

func (f *OAuth) CopyFrom(user *goth.User) *OAuth

func (*OAuth) DelSession

func (f *OAuth) DelSession()

func (*OAuth) Edit

func (f *OAuth) Edit(mw func(db.Result) db.Result, args ...interface{}) error

func (*OAuth) Exists

func (f *OAuth) Exists(customerID uint64, unionID string, openID string, typ string) (bool, error)

func (*OAuth) ExistsOtherBinding

func (f *OAuth) ExistsOtherBinding(customerID uint64, id uint64) (bool, error)

func (*OAuth) GetByOutUser

func (f *OAuth) GetByOutUser(user *goth.User) (err error)

func (*OAuth) GetSession

func (f *OAuth) GetSession() (*goth.User, bool, error)

func (*OAuth) OAuthUserGender

func (f *OAuth) OAuthUserGender(ouser *goth.User) string

func (*OAuth) SaveSession

func (f *OAuth) SaveSession(ouser *goth.User) error

func (*OAuth) SignUpCustomer

func (f *OAuth) SignUpCustomer(ouser *goth.User) (*Customer, error)

SignUpCustomer 用户不存在,需要新注册

func (*OAuth) Upsert

func (f *OAuth) Upsert(mw func(db.Result) db.Result, args ...interface{}) (interface{}, error)

type PrepaidCard

type PrepaidCard struct {
	*dbschema.OfficialCustomerPrepaidCard
}

func NewPrepaidCard

func NewPrepaidCard(ctx echo.Context) *PrepaidCard

func (*PrepaidCard) Add

func (f *PrepaidCard) Add() (pk interface{}, err error)

func (*PrepaidCard) BatchGenerate

func (f *PrepaidCard) BatchGenerate(uid uint, count int, amount uint, salePrice float64, start uint, end uint, bgImage string) error

BatchGenerate 批量生成

func (*PrepaidCard) Delete

func (f *PrepaidCard) Delete(mw func(db.Result) db.Result, args ...interface{}) error

func (*PrepaidCard) Edit

func (f *PrepaidCard) Edit(mw func(db.Result) db.Result, args ...interface{}) error

func (*PrepaidCard) Exists

func (f *PrepaidCard) Exists(number string, excludeIDs ...uint64) (bool, error)

func (*PrepaidCard) UseCard

func (f *PrepaidCard) UseCard(customerID uint64, number string, password string) error

type Role

type Role struct {
	*dbschema.OfficialCustomerRole
	// contains filtered or unexported fields
}

func NewRole

func NewRole(ctx echo.Context) *Role

func (*Role) Add

func (u *Role) Add() (interface{}, error)

func (*Role) CancelDefault

func (u *Role) CancelDefault(excludeID ...uint) error

func (*Role) Edit

func (u *Role) Edit(mw func(db.Result) db.Result, args ...interface{}) error

func (*Role) Exists

func (u *Role) Exists(name string) (bool, error)

func (*Role) Exists2

func (u *Role) Exists2(name string, excludeID uint) (bool, error)

func (*Role) GetDefault

func (u *Role) GetDefault() error

func (*Role) ListByCustomer

func (u *Role) ListByCustomer(customer *dbschema.OfficialCustomer) (roleList []*dbschema.OfficialCustomerRole)

func (*Role) ListRoleIDsByCustomer

func (u *Role) ListRoleIDsByCustomer(customer *dbschema.OfficialCustomer) (roleIDs []uint)

type RolePermission

type RolePermission struct {
	*dbschema.OfficialCustomerRolePermission
}

func NewRolePermission

func NewRolePermission(ctx echo.Context) *RolePermission

func (*RolePermission) Add

func (u *RolePermission) Add() (interface{}, error)

func (*RolePermission) Edit

func (u *RolePermission) Edit(mw func(db.Result) db.Result, args ...interface{}) error

func (*RolePermission) Exists

func (u *RolePermission) Exists(roleID uint, typ string) (bool, error)

type U2F

type U2F struct {
	*dbschema.OfficialCustomerU2f
}

func NewU2F

func NewU2F(ctx echo.Context) *U2F

func (*U2F) Add

func (u *U2F) Add() (interface{}, error)

func (*U2F) HasType

func (u *U2F) HasType(customerID uint64, authType string, step uint) (bool, error)

func (*U2F) ListPageByType

func (u *U2F) ListPageByType(customerID uint64, authType string, step uint, sorts ...interface{}) error

func (*U2F) Unbind

func (u *U2F) Unbind(customerID uint64, authType string, step uint) error

func (*U2F) UnbindByToken

func (u *U2F) UnbindByToken(customerID uint64, authType string, step uint, token string) error

type Wallet

type Wallet struct {
	Wallet *dbschema.OfficialCustomerWallet
	Flow   *dbschema.OfficialCustomerWalletFlow
	// contains filtered or unexported fields
}

func NewWallet

func NewWallet(ctx echo.Context) *Wallet

func (*Wallet) Add

func (f *Wallet) Add() (pk interface{}, err error)

func (*Wallet) AddFlow

func (f *Wallet) AddFlow(flows ...*dbschema.OfficialCustomerWalletFlow) (err error)

AddFlow 添加不允许重复的流水记录

func (*Wallet) AddRepeatableFlow

func (f *Wallet) AddRepeatableFlow(flows ...*dbschema.OfficialCustomerWalletFlow) (err error)

AddRepeatableFlow 添加允许重复的流水记录 unique_key: customer_id, asset_type, amount_type, source_type, source_table, source_id, number

func (*Wallet) Edit

func (f *Wallet) Edit(mw func(db.Result) db.Result, args ...interface{}) error

func (*Wallet) FlowListPage

func (f *Wallet) FlowListPage(cond *db.Compounds, orderby ...interface{}) ([]*WalletFlowExt, error)

func (*Wallet) GetAsset

func (f *Wallet) GetAsset(assetType string, customerID uint64) (*dbschema.OfficialCustomerWallet, error)

func (*Wallet) GetAssetBalance

func (f *Wallet) GetAssetBalance(assetType string, customerID uint64) (float64, error)

func (*Wallet) GetBalance

func (f *Wallet) GetBalance(assetType string, customerID uint64) (float64, error)

func (*Wallet) ListCustomerAllAssets

func (f *Wallet) ListCustomerAllAssets(customerID uint64) (map[string]*dbschema.OfficialCustomerWallet, error)

ListCustomerAllAssets 列出客户所有资产

func (*Wallet) ListPage

func (f *Wallet) ListPage(cond *db.Compounds, orderby ...interface{}) ([]*WalletExt, error)

type WalletExt

type WalletExt struct {
	*dbschema.OfficialCustomerWallet
	Customer      *dbschema.OfficialCustomer `db:"-,relation=id:customer_id"`
	AssetTypeName string                     `db:"-"`
}

type WalletFlowExt

type WalletFlowExt struct {
	*dbschema.OfficialCustomerWalletFlow
	Customer      *dbschema.OfficialCustomer `db:"-,relation=id:customer_id"`
	SrcCustomer   *dbschema.OfficialCustomer `db:"-,relation=id:source_customer|gtZero"`
	AssetTypeName string                     `db:"-"`
}

type WalletSettings

type WalletSettings struct {
	On            bool
	MinAmount     float64
	DefaultAmount float64
}

func NewWalletSettings

func NewWalletSettings() *WalletSettings

func (*WalletSettings) FromStore

func (s *WalletSettings) FromStore(r echo.H) *WalletSettings

Jump to

Keyboard shortcuts

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