291 lines
10 KiB
Go
291 lines
10 KiB
Go
package model
|
||
|
||
import (
|
||
"time"
|
||
|
||
"git.rosy.net.cn/baseapi/utils"
|
||
)
|
||
|
||
const (
|
||
UserStatusNormal = 1
|
||
UserStatusDisabled = 2
|
||
)
|
||
|
||
const (
|
||
UserTypeConsumer = 1
|
||
UserTypeStoreBoss = 2
|
||
UserTypeOperator = 4
|
||
UserTypeBoss = 8
|
||
UserTypeRole = 16
|
||
RoleUpdateSettle = 19 //修改市场权限
|
||
|
||
UserTypeNonConsumer = ^1
|
||
|
||
MemberTypeDiscountCard = 1 //会员折扣卡
|
||
)
|
||
|
||
var (
|
||
UserTypeName = map[int]string{
|
||
UserTypeConsumer: "消费者",
|
||
UserTypeStoreBoss: "门店老板",
|
||
UserTypeOperator: "运营",
|
||
UserTypeBoss: "老板",
|
||
UserTypeRole: "受权限管理",
|
||
}
|
||
)
|
||
|
||
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"`
|
||
LastBrandID int `orm:"column(last_brand_id)" json:"lastBrandID"`
|
||
LastStoreID int `orm:"column(last_store_id)" json:"lastStoreID"` //上次浏览过的店铺
|
||
ParentMobile string `orm:"size(32)" json:"parentMobile"`
|
||
DividePercentage int `json:"dividePercentage"`
|
||
Profit int `json:"profit"`
|
||
ProfitSum int `json:"profitSum"`
|
||
Arrears int `json:"arrears"`
|
||
BindStoreID string `orm:"column(bind_store_id)" json:"bindStoreID"` //门店老板账号用,表示绑的哪个门店,后权限用
|
||
BindStoreUser string `json:"bindStoreUser"` //表示绑的哪个账号,密码同这个账号
|
||
CID string `orm:"column(c_id);size(48)"json:"c_id"`
|
||
}
|
||
|
||
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 StoreBoss struct {
|
||
ModelIDCULD
|
||
UserID string `orm:"size(48);column(user_id);unique" json:"userID"` // 内部唯一标识
|
||
BossName string `orm:"size(48);index" json:"bossName"` // 门店老板真实姓名
|
||
StoreID int `orm:"column(store_id)" json:"storeID"`
|
||
ParentUserID string `orm:"size(48);column(parent_user_id)" json:"-"`
|
||
|
||
ReferrerID string `orm:"size(48);index" json:"referrerID"` // 推荐人ID
|
||
ReferrerName string `orm:"size(48);index" json:"referrerName"` // 推荐人姓名
|
||
|
||
CityCode int `json:"cityCode"` // 期望开店所在的城市
|
||
IDCardFront string `orm:"size(255);column(id_card_front)" json:"idCardFront"`
|
||
IDCardBack string `orm:"size(255);column(id_card_back)" json:"idCardBack"`
|
||
IDCardHand string `orm:"size(255);column(id_card_hand)" json:"idCardHand"`
|
||
Licence string `orm:"size(255)" json:"licence"`
|
||
LicenceCode string `orm:"size(32);index" json:"licenceCode"`
|
||
Remark string `orm:"type(text)" json:"-"`
|
||
}
|
||
|
||
// const (
|
||
// PaymentType
|
||
// )
|
||
type UserPayment struct {
|
||
ModelIDCULD
|
||
UserID string `orm:"size(48);column(user_id)" json:"userID"` // 内部唯一标识
|
||
Type int8 //
|
||
}
|
||
|
||
type UserDeliveryAddress struct {
|
||
ModelIDCULD
|
||
|
||
UserID string `orm:"size(48);column(user_id)" json:"userID"` // 内部唯一标识
|
||
|
||
Tag string `orm:"size(32)" json:"tag"`
|
||
ConsigneeName string `orm:"size(32)" json:"consigneeName"`
|
||
ConsigneeMobile string `orm:"size(32)" json:"consigneeMobile"`
|
||
Address string `orm:"size(255)" json:"address"` // 地址(区县以下,门牌号以上的地址信息)
|
||
DetailAddress string `orm:"size(255)" json:"detailAddress"` // 门牌号
|
||
Lng float64 `orm:"digits(10);decimals(6)" json:"lng"`
|
||
Lat float64 `orm:"digits(10);decimals(6)" json:"lat"`
|
||
|
||
AutoAddress string `orm:"size(255)" json:"autoAddress"` // 这个是通过坐标自动获取的结构化的地址
|
||
CityCode int `orm:"default(0);null" json:"cityCode"` // 根据坐标获得
|
||
DistrictCode int `orm:"default(0);null" json:"districtCode"` // 根据坐标获得
|
||
|
||
Remark string `orm:"type(text)" json:"remark"`
|
||
IsDefault int8 `json:"isDefault"`
|
||
}
|
||
|
||
func (*UserDeliveryAddress) TableUnique() [][]string {
|
||
return [][]string{
|
||
// []string{"UserID", "ConsigneeMobile", "DeletedAt"},
|
||
}
|
||
}
|
||
|
||
type UserCartItem struct {
|
||
ID int64 `orm:"column(id)" json:"-"`
|
||
CreatedAt time.Time `orm:"auto_now_add;type(datetime)" json:"createdAt"`
|
||
UpdatedAt time.Time `orm:"auto_now;type(datetime)" json:"-"`
|
||
LastOperator string `orm:"size(32)" json:"-"` // 最后操作员
|
||
|
||
UserID string `orm:"size(48);column(user_id)" json:"userID"`
|
||
StoreID int `orm:"column(store_id)" json:"storeID"`
|
||
SkuID int `orm:"column(sku_id)" json:"skuID"`
|
||
ActID int `orm:"column(act_id)" json:"actID"`
|
||
|
||
Count int `json:"count"`
|
||
Price int `json:"price"`
|
||
IsChecked int8 `json:"isChecked"`
|
||
}
|
||
|
||
func (*UserCartItem) TableUnique() [][]string {
|
||
return [][]string{
|
||
[]string{"UserID", "StoreID", "SkuID", "ActID"},
|
||
}
|
||
}
|
||
|
||
type UserAgreement struct {
|
||
ModelIDCULD
|
||
Name string `orm:"size(32);index" json:"name"` // 外部显示标识(当前可以重复)
|
||
Mobile string `orm:"size(32)" json:"mobile"`
|
||
IDNumber string `orm:"column(id_number);size(20)" json:"idNumber"`
|
||
BankNumber string `orm:"size(32)" json:"bankNumber"`
|
||
}
|
||
|
||
type UserOrderSms struct {
|
||
ID int64 `orm:"column(id)" json:"-"`
|
||
CreatedAt time.Time `orm:"auto_now_add;type(datetime)" json:"createdAt"`
|
||
UpdatedAt time.Time `orm:"auto_now;type(datetime)" json:"-"`
|
||
LastOperator string `orm:"size(32)" json:"-"` // 最后操作员
|
||
|
||
Mobile string `orm:"size(32)" json:"mobile"`
|
||
Name string `orm:"size(32)" json:"name"`
|
||
VendorUserID string `orm:"column(vendor_user_id)" json:"vendorUserID"`
|
||
SMSMark int `orm:"column(sms_mark)" json:"smsMark"`
|
||
TotalCount int `json:"totalCount"`
|
||
}
|
||
|
||
func (*UserOrderSms) TableUnique() [][]string {
|
||
return [][]string{
|
||
[]string{"Mobile"},
|
||
}
|
||
}
|
||
|
||
type UserMember struct {
|
||
ModelIDCULD
|
||
|
||
VendorOrderID string `orm:"column(vendor_order_id);size(48)" json:"vendorOrderID"` //和order_pay关联的,不知道有没用,先加上把
|
||
VendorID int `orm:"column(vendor_id)" json:"vendorID"`
|
||
UserID string `orm:"size(48);column(user_id)" json:"userID"` //内部唯一标识
|
||
Mobile string `orm:"size(48)" json:"mobile"` //内部唯一标识
|
||
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"},
|
||
}
|
||
}
|
||
|
||
type Role struct {
|
||
ModelIDCULD
|
||
|
||
Name string `json:"name"` //角色名
|
||
BrandID int `orm:"column(brand_id)" json:"brandID"`
|
||
CityCodes string `orm:"type(text)" json:"cityCodes"`
|
||
StoreIDs string `orm:"column(store_ids);type(text)" json:"storeIDs"`
|
||
CityInfo []*Place `orm:"-" json:"cityInfo"`
|
||
Stores []*Store `orm:"-" json:"storeInfo"`
|
||
}
|
||
|
||
func (*Role) TableUnique() [][]string {
|
||
return [][]string{
|
||
[]string{"Name", "DeletedAt"},
|
||
}
|
||
}
|
||
|
||
type UserRole struct {
|
||
ModelIDCULD
|
||
|
||
UserID string `orm:"column(user_id)" json:"userID"` //用户ID
|
||
RoleID int `orm:"column(role_id)" json:"roleID"` //角色ID
|
||
}
|
||
|
||
func (*UserRole) TableUnique() [][]string {
|
||
return [][]string{
|
||
[]string{"UserID", "RoleID", "DeletedAt"},
|
||
}
|
||
}
|
||
|
||
type Menu struct {
|
||
ModelIDCULD
|
||
|
||
Name string `json:"name"` //功能名
|
||
URL string `orm:"column(url)" json:"url"` //路径
|
||
ImgURL string `orm:"column(img_url)" json:"imgURL"` //图标
|
||
Level int `json:"level"` //级别
|
||
ParentID int `orm:"column(parent_id)" json:"parentID"` //父功能ID
|
||
Color string `json:"color"` //颜色
|
||
Type int `json:"type"` //0为功能菜单,1为权限菜单
|
||
}
|
||
|
||
func (*Menu) TableUnique() [][]string {
|
||
return [][]string{
|
||
[]string{"Name", "DeletedAt"},
|
||
}
|
||
}
|
||
|
||
type RoleMenu struct {
|
||
ModelIDCULD
|
||
|
||
RoleID int `orm:"column(role_id)" json:"roleID"` //角色ID
|
||
MenuID int `orm:"column(menu_id)" json:"menuID"` //功能ID
|
||
}
|
||
|
||
func (*RoleMenu) TableUnique() [][]string {
|
||
return [][]string{
|
||
[]string{"MenuID", "RoleID", "DeletedAt"},
|
||
}
|
||
}
|