123456789101112131415161718192021222324252627282930313233343536 |
- package wx_user
- import (
- "rdluck_tools/orm"
- )
- type OpenIdList struct {
- OpenId string
- }
- //获取所有的用户openid列表
- func GetOpenIdList(openIdStr string) (items []*OpenIdList, err error) {
- sql := `SELECT DISTINCT ur.open_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.create_platform=1 AND d.status IN('正式','试用','永续') `
- if openIdStr != "" {
- sql += ` AND ur.open_id in (` + openIdStr + `) `
- }
- _, err = orm.NewOrm().Raw(sql).QueryRows(&items)
- return
- }
- //根据手机号获取用户的openid列表
- func GetOpenIdListByMobile(mobile, openIdStr string) (items []*OpenIdList, err error) {
- sql := `SELECT DISTINCT ur.open_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=? `
- if openIdStr != "" {
- sql += ` AND ur.open_id in (` + openIdStr + `) `
- }
- _, err = orm.NewOrm().Raw(sql, mobile).QueryRows(&items)
- return
- }
|