package models import ( "github.com/beego/beego/v2/client/orm" "hongze/hongze_mobile_admin/utils" ) type OpenIdList struct { OpenId string UserId int } 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 } // 根据手机号获取用户的openid func GetUserRecordListByMobileArr(bindAccount []string) (items []*OpenIdList, err error) { o := orm.NewOrmUsingDB("hz_cygx") lenarr := len(bindAccount) if lenarr == 0 { return } var condition string var pars []interface{} condition = ` AND u.cygx_bind_account IN (` + utils.GetOrmInReplace(lenarr) + `)` pars = append(pars, bindAccount) 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 } // 根据手机号获取用户的openid func GetMfyxUserRecordListByMobileArr(bindAccount []string) (items []*OpenIdList, err error) { o := orm.NewOrmUsingDB("hz_cygx") lenarr := len(bindAccount) if lenarr == 0 { return } var condition string var pars []interface{} condition = ` AND u.cygx_bind_account IN (` + utils.GetOrmInReplace(lenarr) + `)` pars = append(pars, bindAccount) sql := `SELECT u.open_id, u.cygx_user_id AS user_id FROM cygx_mfyx_gzh_user_record AS u WHERE 1 = 1 ` + condition _, err = o.Raw(sql, pars).QueryRows(&items) return }