You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

92 lines
4.0 KiB

4 years ago
package user
import (
3 years ago
"database/sql"
4 years ago
"recook/internal/libs/phonedata"
4 years ago
"github.com/golangkit/formatime"
3 years ago
"github.com/jinzhu/gorm"
4 years ago
)
type Information struct {
ID uint `gorm:"column:id;primary_key" json:"id"`
AncestorID uint `gorm:"column:ancestor_id" json:"-"`
Nickname string `gorm:"column:nickname" json:"nickname"`
HeadImgUrl string `gorm:"column:head_img_url" json:"headImgUrl"`
WxUnionId string `gorm:"column:wx_union_id" json:"wxUnionId"`
WxAppOpenId string `gorm:"column:wx_app_open_id" json:"-"`
WxMiniOpenId string `gorm:"wx_mini_open_id" json:"-"`
WxGzhOpenId string `gorm:"wx_gzh_open_id" json:"-"`
Mobile string `gorm:"column:mobile" json:"mobile"`
Gender uint `gorm:"column:gender;default:0" json:"gender"`
Birthday formatime.Second `gorm:"column:birthday" json:"birthday"`
InvitationNo string `gorm:"column:invitation_no" json:"invitationNo"`
//Role uint `gorm:"column:role" json:"role"`
Type uint `gorm:"column:type" json:"type"`
CreatedAt formatime.Second `gorm:"column:created_at" json:"createdAt"`
UpdatedAt formatime.Second `gorm:"column:updated_at" json:"-"`
3 years ago
Address string `gorm:"column:address;size:300" json:"addr"`
Phone string `gorm:"column:phone;size:20" json:"phone"`
WechatNo string `gorm:"column:wechat_no;size:30" json:"wechatNo"`
RemarkName string `gorm:"column:remark_name;size:32" json:"remarkName"`
IntroCode string `gorm:"column:intro_code" json:"introCode" `
UpgradeCode string `gorm:"column:upgrade_code" json:"upgradeCode" `
Audit int8 `gorm:"column:audit" json:"audit"` // 用户审核状态, 1 待审核, 2 通过, 3 拒绝了
RealName string `gorm:"column:real_name" json:"realName"`
IDCard string `gorm:"column:id_card" json:"idCard"`
RealInfoStatus int64 `gorm:"column:realinfo_status" json:"realInfoStatus"`
SeqNo string `gorm:"column:seq_no" json:"seqNo"`
AssessBegin formatime.Second `gorm:"column:assess_begin" json:"assessBegin"`
AssessEnd formatime.Date `gorm:"column:assess_end" json:"assessEnd"`
Identifier string `gorm:"column:identifier" json:"identifier"` //用户编号
LevelId uint `json:"levelId"`
Secret uint `json:"secret"`
Province string `json:"province"`
City string `json:"city"`
Level int `json:"level"`
ParentID uint `json:"parent_id"`
UpgradeTime1 formatime.Second `json:"upgrade_time1"`
UpgradeTime2 formatime.Second `json:"upgrade_time2"`
RootID uint `json:"root_id"`
LoginApp bool `json:"login_app"`
IsOffline bool `json:"is_offline"`
VipUpgradeStart sql.NullTime `json:"vip_upgrade_start"`
VipUpgradeEnd sql.NullTime `json:"vip_upgrade_end"`
OldParentID int `json:"old_parent_id"`
OldRootID int `json:"old_root_id"`
OldLevel int `json:"old_level"`
IsEnterprise bool `json:"is_enterprise"`
4 years ago
}
const (
AuditWait = 1
AuditPass = 2
AuditDecline = 3
// 结果1验证一致计费2验证不一致计费3异常情况不计费
RealInfoErr = 1
RealInfoPass = 2
)
// TableName sets the insert table name for this struct type
func (i *Information) TableName() string {
return "recook_user_info"
}
func (i *Information) IsVip() bool {
return i.Level == 10 || (i.Level == 2 && i.IsOffline && !i.VipUpgradeEnd.Valid)
}
3 years ago
func (i *Information) BeforeCreate(*gorm.DB) (err error) {
4 years ago
if len(i.Mobile) == 11 {
pr, e := phonedata.Find(i.Mobile)
if e != nil {
return
}
i.Province = pr.Province
i.City = pr.City
}
return
}