wechat_send_msg.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. )
  5. type OpenIdList struct {
  6. OpenId string
  7. UserId int
  8. }
  9. func GetOpenIdArr() (items []string, 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.subscribe=1 AND ur.create_platform=1 AND d.status IN('正式','试用','永续')
  15. ORDER BY FIELD(c.company_id, 16) desc, ur.user_record_id asc`
  16. o := orm.NewOrmUsingDB("weekly")
  17. _, err = o.Raw(sql).QueryRows(&items)
  18. return
  19. }
  20. func GetOpenIdArrByClassifyNameSecond(classifyNameSecond string) (items []string, err error) {
  21. sql := ` SELECT DISTINCT ur.open_id FROM wx_user AS wu
  22. INNER JOIN company AS c ON c.company_id = wu.company_id
  23. INNER JOIN company_product AS d ON c.company_id=d.company_id
  24. INNER JOIN user_record AS ur ON wu.user_id=ur.user_id
  25. INNER JOIN company_report_permission AS e ON d.company_id=e.company_id
  26. INNER JOIN chart_permission AS f ON e.chart_permission_id=f.chart_permission_id
  27. INNER JOIN chart_permission_search_key_word_mapping AS g ON f.chart_permission_id=g.chart_permission_id
  28. WHERE ur.open_id != "" AND ur.subscribe=1 AND ur.create_platform=1 AND d.status IN('正式','试用','永续') AND e.status IN('正式','试用','永续')
  29. AND g.from='rddp'
  30. AND g.key_word=?
  31. ORDER BY FIELD(c.company_id, 16) DESC, ur.user_record_id ASC `
  32. o := orm.NewOrmUsingDB("weekly")
  33. _, err = o.Raw(sql, classifyNameSecond).QueryRows(&items)
  34. return
  35. }