abiao 2 年之前
父節點
當前提交
874ccbd966

+ 9 - 0
go/gopath/src/fohow.com/apps/controllers/user_controller/user_controller.go

@@ -212,6 +212,13 @@ func (self *UserController) Get() {
 		if user.Pwd == "" {
 			user.SetPwd = false
 		}
+		user.Employ = false
+		if user.Tel == "" {
+			empploy := user_model.GetEmployer(user.Tel, true)
+			if empploy != nil {
+				user.Employ = true
+			}
+		}
 		user.IdentityCardWithStar = user.GetCardNoWithStar()
 	}
 	if wxUser != nil {
@@ -220,11 +227,13 @@ func (self *UserController) Get() {
 		if wxGzhUser != nil {
 			wxUser.Subscribe = wxGzhUser.Subscribe
 		}
+
 		wxUser.CanBind = false
 		//大于某一时间点,可做会员迁移
 		if len(wxUser.UserNo) == 0 {
 			wxUser.CanBind = true
 		}
+
 	}
 
 	type Ret struct {

+ 45 - 0
go/gopath/src/fohow.com/apps/models/user_model/employ.go

@@ -0,0 +1,45 @@
+package user_model
+
+import (
+	"fmt"
+	"fohow.com/cache"
+	"github.com/astaxie/beego"
+	"github.com/astaxie/beego/orm"
+	"time"
+)
+
+const (
+	employs_tablename = "employs"
+)
+
+type Employ struct {
+	Id        int64     `orm:"column(id);pk"                json:"id"`                  // int(11)
+	Mobile    string    `orm:"column(mobile);null"          json:"-"`                   // varchar(64)
+	UserName  int64     `orm:"column(user_name);null"       json:"user_name"`           // tinyint(1)
+	CreatedAt time.Time `orm:"column(created_at);auto_now_add;type(datetime)" json:"-"` // datetime
+	UpdatedAt time.Time `orm:"column(updated_at);auto_now;type(datetime)"     json:"-"` // datetime
+}
+
+func (self *Employ) TableName() string {
+	return employs_tablename
+}
+
+func GetEmployer(mobile string, useCache bool) *Employ {
+	//k := cache.GetKey(cache.GetWxUserById, id)
+	k := fmt.Sprintf("%s%s", "employ_mobile", mobile)
+	if useCache {
+		if usr, ok := cache.Cache.Get(k).(*Employ); ok {
+			return usr
+		}
+	}
+	usr := new(Employ)
+	o := orm.NewOrm()
+	err := o.QueryTable(usr).Filter("mobile", mobile).Limit(1).One(usr)
+	if err != nil {
+		beego.Debug("GetEmployer(%s), err=[%s]", mobile, err)
+		return nil
+	} else {
+		cache.Cache.Put(k, usr, 24*time.Hour)
+		return usr
+	}
+}

+ 5 - 4
go/gopath/src/fohow.com/apps/models/user_model/user.go

@@ -52,6 +52,7 @@ type User struct {
 	//银行信息
 	HasBank     bool      `orm:"-"                  json:"has_bank"`
 	SetPwd      bool      `orm:"-"                  json:"set_pwd"`
+	Employ      bool      `orm:"-"     json:"employ"`
 	BankName    string    `orm:"column(bank_name)"     json:"bank_name"`
 	BankAccount string    `orm:"column(bank_account)"     json:"bank_account"`
 	AccountName string    `orm:"column(account_name)"     json:"account_name"`
@@ -63,7 +64,7 @@ func (self *User) TableName() string {
 	return users_tablename
 }
 
-//创建用户
+// 创建用户
 func Create(tel, signupIp string) *User {
 	item := &User{
 		Tel:      tel,
@@ -189,7 +190,7 @@ func (self *User) GetNickname() string {
 	return wxUser.Nickname
 }
 
-//本地上传头像, 返回头像名称
+// 本地上传头像, 返回头像名称
 func (self *User) UploadHead(file multipart.File) string {
 	if file == nil {
 		return ""
@@ -214,7 +215,7 @@ func (self *User) UploadHead(file multipart.File) string {
 	}
 }
 
-//复制wx_user head to user head(此函数仅在绑定时调用一次,之后user的头像修改使用uploadhead函数),返回user head名称。
+// 复制wx_user head to user head(此函数仅在绑定时调用一次,之后user的头像修改使用uploadhead函数),返回user head名称。
 func (self *User) CopyWxUserHead(imgName string) string {
 	if imgName == "" || self.Head != "" {
 		return ""
@@ -255,7 +256,7 @@ func (self *User) XcxPermitUploadHead(httpPath string) string {
 	}
 }
 
-//名称隐藏第二个字,用*代替(仅试用中文)
+// 名称隐藏第二个字,用*代替(仅试用中文)
 func (self *User) GetNickNameWithStar() string {
 	return tool.ReplaceNameWithStar(self.Nickname)
 }

+ 3 - 3
go/gopath/src/fohow.com/apps/models/user_model/wx_user.go

@@ -120,7 +120,7 @@ func (self *WxUser) Create(openid, unionid, nickname, city, country, province, i
 	return item
 }
 
-//上传wx user头像, 返回头像名称
+// 上传wx user头像, 返回头像名称
 func (self *WxUser) UploadHead(httpPath string) string {
 	if httpPath == "" {
 		return ""
@@ -259,7 +259,7 @@ func GetWxUsersBySql(sql string) (list []*WxUser) {
 	return list
 }
 
-//获取团队成员内部编号
+// 获取团队成员内部编号
 func GetAvailableIntroArea(wxUserId int64) string {
 	var list []*WxUser
 	o := orm.NewOrm()
@@ -471,7 +471,7 @@ func GetAllWxUsersByInviteId(inviteWxId int64, useCache bool) (list []*WxUser) {
 	return list
 }
 
-//名称隐藏第二个字,用*代替(仅试用中文)
+// 名称隐藏第二个字,用*代替(仅试用中文)
 func (self *WxUser) GetNickNameWithStar() string {
 	return tool.ReplaceNameWithStar(self.Nickname)
 }