123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252 |
- package models
- import (
- "eta/eta_pub/utils"
- "github.com/beego/beego/v2/client/orm"
- "strings"
- )
- type OpenIdList struct {
- OpenId string
- UserId int
- }
- func GetOpenIdList() (items []*OpenIdList, err error) {
- sql := `SELECT DISTINCT ur.open_id,wu.user_id FROM wx_user AS wu
- INNER JOIN company AS c ON c.company_id = wu.company_id
- INNER JOIN company_product AS d ON c.company_id=d.company_id
- INNER join user_record as ur on wu.user_id=ur.user_id
- WHERE ur.open_id != "" AND ur.subscribe=1 and ur.create_platform=1 AND d.status IN('正式','试用','永续') `
- _, err = orm.NewOrm().Raw(sql).QueryRows(&items)
- return
- }
- func GetOpenIdListByMobile(mobile string) (items []*OpenIdList, err error) {
- sql := `SELECT DISTINCT ur.open_id,wu.user_id FROM wx_user AS wu
- INNER JOIN company AS c ON c.company_id = wu.company_id
- INNER join user_record as ur on wu.user_id=ur.user_id
- WHERE ur.open_id != "" AND ur.subscribe=1 and ur.create_platform=1 AND wu.mobile=? `
- _, err = orm.NewOrm().Raw(sql, mobile).QueryRows(&items)
- return
- }
- // 获取预约活动的用户的openID
- func GetActivityOpenIdList(activityId int) (items []*OpenIdList, err error) {
- sql := `SELECT DISTINCT cr.open_id,u.user_id
- FROM
- cygx_my_schedule AS m
- INNER JOIN user_record AS u ON u.bind_account = m.mobile
- INNER JOIN cygx_user_record AS cr ON cr.union_id = u.union_id
- WHERE m.activity_id = ? AND u.create_platform = 4 `
- _, err = orm.NewOrm().Raw(sql, activityId).QueryRows(&items)
- return
- }
- // 获取预约活动的用户的openID测试环境
- func GetActivityOpenIdListByDeBug(activityId int) (items []*OpenIdList, err error) {
- sql := `SELECT
- u.open_id,
- u.user_id
- FROM
- cygx_my_schedule AS s
- INNER JOIN wx_user AS wx ON wx.user_id = s.user_id
- INNER JOIN user_record AS u ON u.bind_account = wx.mobile
- INNER JOIN company_product AS p ON p.company_id = wx.company_id
- WHERE
- s.activity_id = ?
- AND u.create_platform = 1
- AND p.STATUS IN ( '正式', '试用', '永续' )
- GROUP BY
- u.open_id`
- _, err = orm.NewOrm().Raw(sql, activityId).QueryRows(&items)
- return
- }
- // 获取预约活动的用户的openID
- func GetActivitySpecialOpenIdList() (items []*OpenIdList, err error) {
- sql := `SELECT DISTINCT cr.open_id,u.user_id
- FROM
- cygx_user_follow_special AS m
- INNER JOIN user_record AS u ON u.bind_account = m.mobile
- INNER JOIN cygx_user_record AS cr ON cr.union_id = u.union_id
- WHERE u.create_platform = 4 `
- _, err = orm.NewOrm().Raw(sql).QueryRows(&items)
- return
- }
- // 获取预约活动的用户的openID测试环境
- func GetActivitySpecialOpenIdListByDeBug() (items []*OpenIdList, err error) {
- sql := `SELECT
- u.open_id,
- u.user_id
- FROM
- cygx_user_follow_special AS s
- INNER JOIN wx_user AS wx ON wx.user_id = s.user_id
- INNER JOIN user_record AS u ON u.bind_account = wx.mobile
- INNER JOIN company_product AS p ON p.company_id = wx.company_id
- WHERE
- u.create_platform = 1
- AND p.STATUS IN ( '正式', '试用', '永续' )
- GROUP BY
- u.open_id`
- _, err = orm.NewOrm().Raw(sql).QueryRows(&items)
- return
- }
- // 获取关注作者的用户的openID
- func GetFollowDepartmentOpenIdList(departmentId int) (items []*OpenIdList, err error) {
- sql := `SELECT cr.open_id,u.user_id
- FROM
- cygx_article_department_follow AS f
- INNER JOIN user_record AS u ON u.bind_account = f.mobile
- INNER JOIN wx_user AS wx ON wx.user_id = f.user_id
- INNER JOIN company_product AS p ON p.company_id = wx.company_id
- INNER JOIN cygx_user_record AS cr ON cr.union_id = u.union_id
- WHERE
- f.department_id = ?
- AND u.create_platform = 4
- AND f.type = 1
- AND p.status IN ('正式','试用','永续')
- GROUP BY
- cr.open_id `
- _, err = orm.NewOrm().Raw(sql, departmentId).QueryRows(&items)
- return
- }
- // 获取关注作者的用户的openID测试环境
- func GetFollowDepartmentOpenIdListByDeBug(departmentId int) (items []*OpenIdList, err error) {
- sql := `SELECT
- u.open_id,
- u.user_id
- FROM
- cygx_article_department_follow AS f
- INNER JOIN wx_user AS wx ON wx.user_id = f.user_id
- INNER JOIN user_record AS u ON u.bind_account = wx.mobile
- INNER JOIN company_product AS p ON p.company_id = wx.company_id
- WHERE
- f.department_id = ?
- AND u.create_platform = 1
- AND f.type = 1
- AND p.STATUS IN ( '正式', '试用', '永续' )
- GROUP BY
- u.open_id`
- _, err = orm.NewOrm().Raw(sql, departmentId).QueryRows(&items)
- return
- }
- // 获取关注产业的用户的openID
- func GetFollowindustrialOpenIdList(industrialManagementId int) (items []*OpenIdList, err error) {
- sql := `SELECT cr.open_id,u.user_id
- FROM
- cygx_industry_fllow AS f
- INNER JOIN wx_user AS wx ON wx.user_id = f.user_id
- INNER JOIN user_record AS u ON u.bind_account = wx.mobile
- INNER JOIN cygx_user_record AS cr ON cr.union_id = u.union_id
- WHERE
- f.industrial_management_id = ?
- AND u.create_platform = 4
- AND f.type = 1 GROUP BY cr.open_id `
- _, err = orm.NewOrm().Raw(sql, industrialManagementId).QueryRows(&items)
- return
- }
- // 获取关注产业的用户的openID 测试环境
- func GetFollowindustrialOpenIdListByDeBug(industrialManagementId int) (items []*OpenIdList, err error) {
- sql := `SELECT
- u.open_id,
- u.user_id
- FROM
- cygx_industry_fllow AS f
- INNER JOIN wx_user AS wx ON wx.user_id = f.user_id
- INNER JOIN user_record AS u ON u.bind_account = wx.mobile
- WHERE
- f.industrial_management_id = ?
- AND u.create_platform = 1
- AND u.bind_account != ""
- AND f.type = 1
- GROUP BY
- u.open_id`
- _, err = orm.NewOrm().Raw(sql, industrialManagementId).QueryRows(&items)
- return
- }
- // GetUserOpenidListByUserIds 根据用户id字符串集合来获取他的openid列表集合
- func GetUserOpenidListByUserIds(userIdStr []string) (list []*OpenIdList, err error) {
- if len(userIdStr) <= 0 {
- return
- }
- sql := `SELECT open_id,u.user_id FROM user_record WHERE user_id in (` + strings.Join(userIdStr, ",") + `) and create_platform = 1`
- _, err = orm.NewOrm().Raw(sql).QueryRows(&list)
- return
- }
- func GetAdminOpenIdByMobile(mobile string) (items []*OpenIdList, err error) {
- sql := `SELECT DISTINCT ur.open_id,wu.user_id FROM wx_user AS wu
- INNER JOIN company AS c ON c.company_id = wu.company_id
- INNER join user_record as ur on wu.user_id=ur.user_id
- WHERE ur.open_id != "" and ur.create_platform=1 AND wu.mobile=? `
- _, err = orm.NewOrm().Raw(sql, mobile).QueryRows(&items)
- return
- }
- // 根据手机号获取用户的openid查研观向小助手专用
- func GetUserRecordListByMobile(platform int, bindAccount string) (items []*OpenIdList, err error) {
- var sql string
- if utils.RunMode == "release" {
- sql = `SELECT cr.open_id FROM user_record as u
- INNER JOIN cygx_user_record AS cr ON cr.union_id = u.union_id
- WHERE create_platform=? AND bind_account IN (` + bindAccount + `)`
- } else {
- platform = 1
- sql = `SELECT open_id FROM user_record WHERE create_platform =? AND bind_account IN (` + bindAccount + `)`
- }
- _, err = orm.NewOrm().Raw(sql, platform).QueryRows(&items)
- return
- }
- type SendWxTemplate struct {
- WxAppId string `description:"公众号appId"`
- First string `description:"模板消息first字段"`
- Keyword1 string `description:"模板消息keyword1字段"`
- Keyword2 string `description:"模板消息keyword2字段"`
- Keyword3 string `description:"模板消息keyword3字段"`
- Keyword4 string `description:"模板消息keyword4字段"`
- Keyword5 string `description:"模板消息keyword5字段"`
- Productname string `description:"模板消息productname字段"`
- Date string `description:"模板消息date字段"`
- Remark string `description:"模板消息remark字段"`
- TemplateId string `description:"模板id"`
- RedirectUrl string `description:"跳转地址"`
- RedirectTarget int `description:"小程序跳转目标:1:弘则研报小程序,2:随手办公小程序,3:查研观向"`
- Resource string `description:"资源唯一标识"`
- SendType int `description:"发送的消息类型:1:报告,2:指标更新提醒,3:审批通知,4:销售领取客户通知,5:活动取消通知,6活动更改时间通知,7:关注的作者发布报告通知,8:发送日报(周报、双周报、月报)模板消息,9:活动预约/报名时间通知"`
- OpenIdArr []string `description:"消息接收者openid"`
- }
- type WxTokenReq struct {
- WxAppId string `description:"公众号appId"`
- WxAppSecret string `description:"公众号appSecret"`
- }
- type WxTokenResp struct {
- AccessToken string `description:"微信token"`
- }
- // 跳小程序所需数据
- type MiniprogramReq struct {
- Appid string `json:"appid" ;description:"所需跳转到的小程序appid(该小程序appid必须与发模板消息的公众号是绑定关联关系,暂不支持小游戏`
- Pagepath string `json:"pagepath" ;description:"所需跳转到小程序的具体页面路径,支持带参数,(示例index?foo=bar),要求该小程序已发布,暂不支持小游戏`
- }
- type SendWxCategoryTemplate struct {
- WxAppId string `description:"公众号appId"`
- Keywords []string `description:"模板消息keyword字段"`
- TemplateId string `description:"模板id"`
- Miniprogram *MiniprogramReq `description:"跳小程序所需数据,不需跳小程序可不用传该数据"`
- RedirectUrl string `description:"跳转地址"`
- RedirectTarget int `description:"小程序跳转目标:1:弘则研报小程序,2:随手办公小程序,3:查研观向"`
- Resource string `description:"资源唯一标识"`
- SendType int `description:"发送的消息类型:1:报告,2:指标更新提醒,3:审批通知,4:销售领取客户通知,5:活动取消通知,6活动更改时间通知,7:关注的作者发布报告通知,8:发送日报(周报、双周报、月报)模板消息,9:活动预约/报名时间通知"`
- OpenIdArr []string `description:"消息接收者openid"`
- }
|