wx_user.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. package wx_user
  2. import (
  3. "rdluck_tools/orm"
  4. )
  5. type OpenIdList struct {
  6. OpenId string
  7. }
  8. //获取所有的用户openid列表
  9. func GetOpenIdList(openIdStr string) (items []*OpenIdList, err error) {
  10. sql := `SELECT DISTINCT ur.open_id FROM wx_user AS wu
  11. INNER JOIN company AS c ON c.company_id = wu.company_id
  12. INNER JOIN company_product AS d ON c.company_id=d.company_id
  13. INNER join user_record as ur on wu.user_id=ur.user_id
  14. WHERE ur.open_id != "" and ur.create_platform=1 AND d.status IN('正式','试用','永续') `
  15. if openIdStr != "" {
  16. sql += ` AND ur.open_id in (` + openIdStr + `) `
  17. }
  18. _, err = orm.NewOrm().Raw(sql).QueryRows(&items)
  19. return
  20. }
  21. //根据手机号获取用户的openid列表
  22. func GetOpenIdListByMobile(mobile, openIdStr string) (items []*OpenIdList, err error) {
  23. sql := `SELECT DISTINCT ur.open_id FROM wx_user AS wu
  24. INNER JOIN company AS c ON c.company_id = wu.company_id
  25. INNER join user_record as ur on wu.user_id=ur.user_id
  26. WHERE ur.open_id != "" and ur.create_platform=1 AND wu.mobile=? `
  27. if openIdStr != "" {
  28. sql += ` AND ur.open_id in (` + openIdStr + `) `
  29. }
  30. _, err = orm.NewOrm().Raw(sql, mobile).QueryRows(&items)
  31. return
  32. }