|
@@ -0,0 +1,103 @@
|
|
|
+package models
|
|
|
+
|
|
|
+import (
|
|
|
+ "rdluck_tools/orm"
|
|
|
+ "time"
|
|
|
+)
|
|
|
+
|
|
|
+type WxUser struct {
|
|
|
+ UserId int `orm:"column(user_id);pk"`
|
|
|
+ OpenId string `description:"open_id"`
|
|
|
+ UnionId string `description:"union_id"`
|
|
|
+ Subscribe string `description:"是否关注"`
|
|
|
+ CompanyId int `description:"客户id"`
|
|
|
+ NickName string `description:"用户昵称"`
|
|
|
+ RealName string `description:"用户实际名称"`
|
|
|
+ UserCode string `description:"用户编码"`
|
|
|
+ Mobile string `description:"手机号码"`
|
|
|
+ BindAccount string `description:"绑定时的账号"`
|
|
|
+ WxCode string `description:"微信号"`
|
|
|
+ Profession string `description:"职业"`
|
|
|
+ Email string `description:"邮箱"`
|
|
|
+ Telephone string `description:"座机"`
|
|
|
+ Sex int `description:"普通用户性别,1为男性,2为女性"`
|
|
|
+ Province string `description:"普通用户个人资料填写的省份"`
|
|
|
+ City string `description:"普通用户个人资料填写的城市"`
|
|
|
+ Country string `description:"国家,如中国为CN"`
|
|
|
+ SubscribeTime int `description:"关注时间"`
|
|
|
+ Remark string `description:"备注"`
|
|
|
+ Headimgurl string `description:"用户头像,最后一个数值代表正方形头像大小(有0、46、64、96、132数值可选,0代表640*640正方形头像),用户没有头像时该项为空"`
|
|
|
+ Privilege string `description:"用户特权信息,json数组,如微信沃卡用户为(chinaunicom)"`
|
|
|
+ Unionid string `description:"用户统一标识。针对一个微信开放平台帐号下的应用,同一用户的unionid是唯一的。"`
|
|
|
+ FirstLogin int `description:"是否第一次登陆"`
|
|
|
+ Enabled int `description:"是否可用"`
|
|
|
+ CreatedTime time.Time `description:"创建时间"`
|
|
|
+ LastUpdatedTime time.Time `description:"最新一次修改时间"`
|
|
|
+ Seller string `description:"销售员"`
|
|
|
+ Note string `description:"客户备份信息"`
|
|
|
+ IsNote int `description:"是否备注过信息"`
|
|
|
+ FromType string `description:"report' COMMENT 'report:研报,teleconference:电话会"`
|
|
|
+ ApplyMethod int `description:"0:未申请,1:已付费客户申请试用,2:非客户申请试用"`
|
|
|
+ RegisterTime time.Time `description:"注册时间"`
|
|
|
+ RegisterPlatform int `description:"注册平台,1:微信端,2:PC网页端"`
|
|
|
+ IsFreeLogin bool `description:"是否免登陆,true:免登陆,false:非免登陆"`
|
|
|
+ LoginTime time.Time `description:"最近一次登录时间"`
|
|
|
+}
|
|
|
+
|
|
|
+//添加用户信息
|
|
|
+func AddWxUser(item *WxUser) (lastId int64, err error) {
|
|
|
+ o := orm.NewOrm()
|
|
|
+ lastId, err = o.Insert(item)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+type WxUserItem struct {
|
|
|
+ UserId int `description:"用户id"`
|
|
|
+ OpenId string `description:"open_id"`
|
|
|
+ UnionId string `description:"union_id"`
|
|
|
+ CompanyId int `description:"客户id"`
|
|
|
+ NickName string `description:"用户昵称"`
|
|
|
+ RealName string `description:"用户实际名称"`
|
|
|
+ Mobile string `description:"手机号码"`
|
|
|
+ BindAccount string `description:"绑定时的账号"`
|
|
|
+ Email string `description:"邮箱"`
|
|
|
+ Headimgurl string `description:"用户头像,最后一个数值代表正方形头像大小(有0、46、64、96、132数值可选,0代表640*640正方形头像),用户没有头像时该项为空"`
|
|
|
+ ApplyMethod int `description:"0:未申请,1:已付费客户申请试用,2:非客户申请试用"`
|
|
|
+ FirstLogin int `description:"是否第一次登陆"`
|
|
|
+ IsFreeLogin int `description:"是否免登陆,true:免登陆,false:非免登陆"`
|
|
|
+ LoginTime time.Time `description:"登录时间"`
|
|
|
+ CreatedTime time.Time `description:"创建时间"`
|
|
|
+ LastUpdatedTime time.Time `description:"最近一次修改时间"`
|
|
|
+}
|
|
|
+
|
|
|
+func GetWxUserItemByUnionid(unionid string) (item *WxUserItem, err error) {
|
|
|
+ sql := `SELECT * FROM wx_user WHERE union_id=? `
|
|
|
+ err = orm.NewOrm().Raw(sql, unionid).QueryRow(&item)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+func GetWxUserItemByUserId(userId int) (item *WxUserItem, err error) {
|
|
|
+ sql := `SELECT * FROM wx_user WHERE user_id=? `
|
|
|
+ err = orm.NewOrm().Raw(sql, userId).QueryRow(&item)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+func GetWxUserItemByOpenId(openId string) (item *WxUserItem, err error) {
|
|
|
+ sql := `SELECT * FROM wx_user WHERE open_id=? `
|
|
|
+ err = orm.NewOrm().Raw(sql, openId).QueryRow(&item)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+type WxLoginResp struct {
|
|
|
+ Authorization string
|
|
|
+ UserId int
|
|
|
+ FirstLogin int
|
|
|
+ Headimgurl string `description:"用户头像"`
|
|
|
+ Mobile string `description:"手机号"`
|
|
|
+ Email string `description:"邮箱"`
|
|
|
+ CompanyName string `description:"客户名称"`
|
|
|
+ Status string `description:"状态"`
|
|
|
+ EndDate string `description:"到期日期"`
|
|
|
+ ProductName string `description:"客户类型名称"`
|
|
|
+}
|