Files
jx-callback/business/model/user.go
2020-10-12 17:10:57 +08:00

119 lines
3.5 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package model
import (
"time"
"git.rosy.net.cn/baseapi/utils"
)
const (
UserStatusNormal = 1
UserStatusDisabled = 2
)
const (
UserTypeConsumer = 1
UserTypeStoreBoss = 2
UserTypeOperator = 4
UserTypeBoss = 8
UserTypeNonConsumer = ^1
MemberTypeDiscountCard = 1 //会员折扣卡
)
var (
UserTypeName = map[int]string{
UserTypeConsumer: "消费者",
UserTypeStoreBoss: "门店老板",
UserTypeOperator: "运营",
UserTypeBoss: "老板",
}
)
type DiscountCard struct {
ID int `orm:"column(id)" json:"id"`
PicePercentage int `json:"pricePercentage"`
Price int `json:"price"`
}
type User struct {
ModelIDCULD
UserID string `orm:"size(48);column(user_id)" json:"userID" compact:"userID"` // 内部唯一标识
UserID2 string `orm:"size(48);column(user_id2)" json:"userID2" compact:"userID2"` // 外部唯一标识(一般用于登录)
Name string `orm:"size(48);index" json:"name" compact:"name"` // 外部显示标识(当前可以重复)
Mobile *string `orm:"size(32);null" json:"mobile" compact:"mobile"`
Email *string `orm:"size(32);null" json:"email" compact:"email"`
Avatar string `orm:"size(255)" json:"avatar" compact:"avatar"` // 头像
Status int8 `json:"status" compact:"status"`
Type int8 `json:"type" compact:"type"` // 用户类型
CityCode int `orm:"default(0)" json:"cityCode"`
DistrictCode int `orm:"default(0);index" json:"districtCode"`
Address string `orm:"size(255)" json:"address"`
IDCardNo string `orm:"size(18);column(id_card_no)" json:"idCardNo" compact:"idCardNo"` // 身份证号
Remark string `orm:"size(255)" json:"remark"`
LastLoginAt *time.Time `orm:"null" json:"lastLoginAt"`
LastLoginIP string `orm:"size(64);column(last_login_ip)" json:"lastLoginIP"`
LastLoginType string `orm:"size(16)" json:"lastLoginType"`
ParentMobile string `orm:"size(32)" json:"parentMobile"`
DividePercentage int `json:"dividePercentage"`
Profit int `json:"profit"`
ProfitSum int `json:"profitSum"`
Arrears int `json:"arrears"`
}
func (*User) TableUnique() [][]string {
return [][]string{
[]string{"UserID"},
[]string{"UserID2", "DeletedAt"},
[]string{"Mobile", "DeletedAt"},
[]string{"Email", "DeletedAt"},
// []string{"IDCardNo", "DeletedAt"},
}
}
func (user *User) GetID() string {
return user.UserID
}
func (user *User) GetID2() string {
return user.UserID2
}
func (user *User) GetMobile() string {
return utils.Pointer2String(user.Mobile)
}
func (user *User) GetEmail() string {
return utils.Pointer2String(user.Email)
}
func (user *User) GetName() string {
return user.Name
}
func (user *User) GetAvatar() string {
return user.Avatar
}
type UserMember struct {
ModelIDCULD
VendorOrderID string `orm:"column(vendor_order_id);size(48)" json:"vendorOrderID"` //和order_pay关联的不知道有没用先加上把
UserID string `orm:"size(48);column(user_id)" json:"userID"` //内部唯一标识
MemberType int `json:"memberType"` //会员类型, 1为折扣卡
MemberTypeID int `orm:"column(member_type_id)" json:"memberTypeID"` //会员类型ID折扣卡的话代表几档
EndAt time.Time `json:"endAt"` //会员过期时间
IsPay int `json:"isPay"`
}
func (v *UserMember) TableIndex() [][]string {
return [][]string{
[]string{"UserID"},
[]string{"CreatedAt"},
}
}