package models import ( "github.com/beego/beego/v2/client/orm" "hongze/hongze_mfyx/utils" "strings" ) type SendTemplateResponse struct { Errcode int `json:"errcode"` Errmsg string `json:"errmsg"` MsgID int `json:"msgid"` } type OpenIdList struct { OpenId string UserId int Mobile string `description:"手机号"` } func GetOpenIdList() (items []*OpenIdList, err error) { o := orm.NewOrmUsingDB("weekly_report") openIdstr := WxUsersGet() sql := `SELECT open_id FROM wx_user AS wu INNER JOIN company AS c ON c.company_id = wu.company_id WHERE wu.open_id IS NOT NULL AND c.type IN (1,2) ` if openIdstr != "" { sql += ` AND open_id in (` + openIdstr + `) ` } _, err = o.Raw(sql).QueryRows(&items) return } // 查研观向小助手Openid func GetWxOpenIdByMobileList(mobile string) (items []*OpenIdList, err error) { sliceMobile := strings.Split(mobile, ",") var mobiles []string for _, v := range sliceMobile { mobiles = append(mobiles, v) } o := orm.NewOrm() lenarr := len(mobiles) if lenarr == 0 { return } var condition string var pars []interface{} condition = ` AND u.cygx_bind_account IN (` + utils.GetOrmInReplace(lenarr) + `)` pars = append(pars, mobiles) sql := `SELECT u.open_id, u.cygx_user_id AS user_id FROM cygx_user_record AS u WHERE 1 = 1 ` + condition _, err = o.Raw(sql, pars).QueryRows(&items) return } type AdminOpenIdList struct { OpenId string `description:"OpenId"` UserId int `description:"UserId"` Mobile string `description:"手机号"` CompanyId int `description:"手机号"` } // 根据手机号获取用户的openid func GetWxOpenIdByMobileSliceList(mobiles []string) (items []*OpenIdList, err error) { o := orm.NewOrm() lenarr := len(mobiles) if lenarr == 0 { return } var condition string var pars []interface{} condition = ` AND u.cygx_bind_account IN (` + utils.GetOrmInReplace(lenarr) + `)` pars = append(pars, mobiles) sql := `SELECT u.open_id, u.cygx_user_id AS user_id FROM cygx_user_record AS u WHERE 1 = 1 ` + condition _, err = o.Raw(sql, pars).QueryRows(&items) return }