|
@@ -52,7 +52,7 @@ type WxUser struct {
|
|
|
TripartiteCode string `description:"第三方给过来的用户编码,判断用户是否存在"`
|
|
|
}
|
|
|
|
|
|
-//添加用户信息
|
|
|
+// 添加用户信息
|
|
|
func AddWxUser(item *WxUser) (lastId int64, err error) {
|
|
|
o := orm.NewOrm()
|
|
|
lastId, err = o.Insert(item)
|
|
@@ -94,7 +94,7 @@ func GetWxUserItemByUnionid(unionid string) (item *WxUserItem, err error) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//根据用户ID获取相关信息
|
|
|
+// 根据用户ID获取相关信息
|
|
|
func GetWxUserItemByUserId(userId int) (item *WxUserItem, err error) {
|
|
|
sql := `SELECT a.*,b.company_name FROM wx_user AS a
|
|
|
LEFT JOIN company AS b on a.company_id=b.company_id
|
|
@@ -129,7 +129,7 @@ type WxGetUserInfoReq struct {
|
|
|
Iv string `description:"iv"`
|
|
|
}
|
|
|
|
|
|
-//修改用户会话key
|
|
|
+// 修改用户会话key
|
|
|
func ModifyWxUserSessionKey(sessionKey string, userId int) (err error) {
|
|
|
o := orm.NewOrm()
|
|
|
sql := `UPDATE wx_user SET session_key=? WHERE user_id=? `
|
|
@@ -137,7 +137,7 @@ func ModifyWxUserSessionKey(sessionKey string, userId int) (err error) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//添加用户信息
|
|
|
+// 添加用户信息
|
|
|
func ModifyWxUserInfo(unionId, nickName, province, city, country, avatar string, gender, userId int) (err error) {
|
|
|
o := orm.NewOrm()
|
|
|
sql := `UPDATE wx_user SET union_id=?,unionid=?,nick_name=?,sex=?,province=?,city=?,country=?,headimgurl=? WHERE user_id=? `
|
|
@@ -145,7 +145,7 @@ func ModifyWxUserInfo(unionId, nickName, province, city, country, avatar string,
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//修改用户会话key
|
|
|
+// 修改用户会话key
|
|
|
func DeleteWxUserByUserId(userId int) (err error) {
|
|
|
o := orm.NewOrm()
|
|
|
sql := `DELETE FROM wx_user WHERE user_id=? `
|
|
@@ -188,7 +188,7 @@ type WxGetPhoneNumberResp struct {
|
|
|
CountryCode string `description:"区号"`
|
|
|
}
|
|
|
|
|
|
-//根据用户手机号获取相关信息
|
|
|
+// 根据用户手机号获取相关信息
|
|
|
func GetWxUserItemByMobile(mobile string) (item *WxUserItem, err error) {
|
|
|
sql := `SELECT a.*,b.company_name FROM wx_user AS a
|
|
|
LEFT JOIN company AS b on a.company_id=b.company_id
|
|
@@ -197,7 +197,7 @@ func GetWxUserItemByMobile(mobile string) (item *WxUserItem, err error) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//根据用户手机号获取相关信息
|
|
|
+// 根据用户手机号获取相关信息
|
|
|
func GetWxUserAouthByMobile(mobile string) (item *WxUserItem, err error) {
|
|
|
sql := `SELECT
|
|
|
a.*,
|
|
@@ -229,7 +229,7 @@ func ModifyReportLastViewTime(uid int) (err error) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//变更联系人是否已注册状态
|
|
|
+// 变更联系人是否已注册状态
|
|
|
func ModifyWxUserRegisterStatus(userId int) (err error) {
|
|
|
o := orm.NewOrm()
|
|
|
sql := `UPDATE wx_user SET is_register=?,source=3,register_time=NOW() WHERE user_id = ? `
|
|
@@ -237,7 +237,7 @@ func ModifyWxUserRegisterStatus(userId int) (err error) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//修改用户是否绑定外呼手机号弹窗
|
|
|
+// 修改用户是否绑定外呼手机号弹窗
|
|
|
func ModifyWxUserIsMsgOutboundMobile(userId int) (err error) {
|
|
|
o := orm.NewOrm()
|
|
|
sql := `UPDATE wx_user SET is_msg_outbound_mobile=1 WHERE user_id=? `
|
|
@@ -245,7 +245,7 @@ func ModifyWxUserIsMsgOutboundMobile(userId int) (err error) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//列表
|
|
|
+// 列表
|
|
|
func GetUserListAll() (items []*WxUserItem, err error) {
|
|
|
o := orm.NewOrm()
|
|
|
sql := `SELECT * FROM wx_user WHERE mobile <>'' AND outbound_mobile = ''`
|
|
@@ -253,7 +253,7 @@ func GetUserListAll() (items []*WxUserItem, err error) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//修改手机号区号 8位号码+852,9位号码+886,10位号码+1,11位及以上号码+86
|
|
|
+// 修改手机号区号 8位号码+852,9位号码+886,10位号码+1,11位及以上号码+86
|
|
|
func UPdateUserCountryCode(item *WxUserItem) (err error) {
|
|
|
o := orm.NewOrm()
|
|
|
if item.CountryCode == "" && len(item.Mobile) >= 11 {
|
|
@@ -276,28 +276,28 @@ func UPdateUserCountryCode(item *WxUserItem) (err error) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//判断公司下用户名称是否存在
|
|
|
+// 判断公司下用户名称是否存在
|
|
|
func GetUserCountByName(companyId int, name string) (count int, err error) {
|
|
|
sql := `SELECT COUNT(1) AS count FROM wx_user WHERE company_id = ? AND real_name = ?`
|
|
|
err = orm.NewOrm().Raw(sql, companyId, name).QueryRow(&count)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//判断这个用户是否被设置消息提醒
|
|
|
+// 判断这个用户是否被设置消息提醒
|
|
|
func GetUserRemind(uid int) (count int, err error) {
|
|
|
sql := `SELECT COUNT(1) AS count FROM cygx_user_remind WHERE user_id = ? `
|
|
|
err = orm.NewOrm().Raw(sql, uid).QueryRow(&count)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//判断公司下用户名称是否存在
|
|
|
+// 判断公司下用户名称是否存在
|
|
|
func GetUserCountByThirdName(companyId int, name string) (count int, err error) {
|
|
|
sql := `SELECT COUNT(1) AS count FROM wx_user WHERE company_id = ? AND tripartite_code = ?`
|
|
|
err = orm.NewOrm().Raw(sql, companyId, name).QueryRow(&count)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//获取公司下一共有多少用户
|
|
|
+// 获取公司下一共有多少用户
|
|
|
func GetUserCountByCompanyId(companyId int) (count int, err error) {
|
|
|
sql := `SELECT COUNT(1) AS count FROM wx_user WHERE company_id = ? `
|
|
|
err = orm.NewOrm().Raw(sql, companyId).QueryRow(&count)
|
|
@@ -311,7 +311,7 @@ func UpdateUserMobile(uid int, mobile string) (err error) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//获取公司下用户详情详情详情
|
|
|
+// 获取公司下用户详情详情详情
|
|
|
func GetUserByName(companyId int, name string) (item *WxUser, err error) {
|
|
|
o := orm.NewOrm()
|
|
|
sql := `SELECT * FROM wx_user WHERE company_id = ? AND real_name = ? `
|
|
@@ -319,7 +319,7 @@ func GetUserByName(companyId int, name string) (item *WxUser, err error) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//获取公司下用户详情详情详情
|
|
|
+// 获取公司下用户详情详情详情
|
|
|
func GetUserByThirdName(companyId int, name string) (item *WxUser, err error) {
|
|
|
o := orm.NewOrm()
|
|
|
sql := `SELECT * FROM wx_user WHERE company_id = ? AND tripartite_code = ? `
|
|
@@ -327,7 +327,7 @@ func GetUserByThirdName(companyId int, name string) (item *WxUser, err error) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//获取所有注册的权益用户
|
|
|
+// 获取所有注册的权益用户
|
|
|
func GetUserRegisterList() (items []*WxUser, err error) {
|
|
|
o := orm.NewOrm()
|
|
|
sql := `SELECT
|
|
@@ -370,7 +370,7 @@ type UserLabel struct {
|
|
|
Label string `description:"标签 多个用 , 隔开"`
|
|
|
}
|
|
|
|
|
|
-//对获取关注的产业
|
|
|
+// 对获取关注的产业
|
|
|
func GetCygxCompanyUserListSplit(userIds string) (labels string, err error) {
|
|
|
o := orm.NewOrm()
|
|
|
sql := `SELECT
|
|
@@ -388,7 +388,7 @@ func GetCygxCompanyUserListSplit(userIds string) (labels string, err error) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//阅读记录
|
|
|
+// 阅读记录
|
|
|
type ArticlePvCountResp struct {
|
|
|
ArticleId int `description:"文章ID"`
|
|
|
Pv int `description:"Pv"`
|
|
@@ -462,7 +462,7 @@ func GetCygxArticleCollectId(uid int, dateTime string) (articleIds string, err e
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//活动标签记录
|
|
|
+// 活动标签记录
|
|
|
type ActivityLabelCountResp struct {
|
|
|
Label string `description:"标签"`
|
|
|
Pv int `description:"Pv"`
|
|
@@ -520,7 +520,7 @@ type CygxUserInteractionNumDetail struct {
|
|
|
TryStage int `description:"试用客户子标签:0全部、1未分类、2 推进、3 跟踪、4 预备"`
|
|
|
}
|
|
|
|
|
|
-//获取用户的互动量
|
|
|
+// 获取用户的互动量
|
|
|
func GetCygxCompanyUserUserInteraction(userIds string) (items []*CygxUserInteractionNumDetail, err error) {
|
|
|
o := orm.NewOrm()
|
|
|
sql := `SELECT
|
|
@@ -584,3 +584,10 @@ func GetWxUserByMobiles(mobiles []string) (items []*WxUser, err error) {
|
|
|
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+func UserSubscribe(subscribeTime string, userId int) (err error) {
|
|
|
+ o := orm.NewOrm()
|
|
|
+ sql := `UPDATE wx_user SET cygx_subscribe=1,cygx_subscribe_time=? WHERE user_id = ? `
|
|
|
+ _, err = o.Raw(sql, subscribeTime, userId).Exec()
|
|
|
+ return
|
|
|
+}
|