wechat_send_msg.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "hongze/hongze_mobile_admin/utils"
  5. )
  6. type OpenIdList struct {
  7. OpenId string
  8. UserId int
  9. }
  10. func GetAdminOpenIdByMobile(mobile string) (items []*OpenIdList, err error) {
  11. sql := `SELECT DISTINCT ur.open_id,wu.user_id FROM wx_user AS wu
  12. INNER JOIN company AS c ON c.company_id = wu.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 wu.mobile=? `
  15. _, err = orm.NewOrm().Raw(sql, mobile).QueryRows(&items)
  16. return
  17. }
  18. // 根据手机号获取用户的openid查研观向小助手专用
  19. func GetUserRecordListByMobile(platform int, bindAccount string) (items []*OpenIdList, err error) {
  20. var sql string
  21. if utils.RunMode == "release" {
  22. sql = `SELECT cr.open_id FROM user_record as u
  23. INNER JOIN cygx_user_record AS cr ON cr.union_id = u.union_id
  24. WHERE create_platform=? AND bind_account IN (` + bindAccount + `)`
  25. } else {
  26. platform = 1
  27. sql = `SELECT open_id FROM user_record WHERE create_platform =? AND bind_account IN (` + bindAccount + `)`
  28. }
  29. _, err = orm.NewOrm().Raw(sql, platform).QueryRows(&items)
  30. return
  31. }