wx_template_msg.go 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. )
  5. type SendTemplateResponse struct {
  6. Errcode int `json:"errcode"`
  7. Errmsg string `json:"errmsg"`
  8. MsgID int `json:"msgid"`
  9. }
  10. type OpenIdList struct {
  11. OpenId string
  12. UserId int
  13. }
  14. func GetOpenIdList() (items []*OpenIdList, err error) {
  15. openIdstr := WxUsersGet()
  16. sql := `SELECT open_id FROM wx_user AS wu
  17. INNER JOIN company AS c ON c.company_id = wu.company_id
  18. WHERE wu.open_id IS NOT NULL AND c.type IN (1,2) `
  19. if openIdstr != "" {
  20. sql += ` AND open_id in (` + openIdstr + `) `
  21. }
  22. _, err = orm.NewOrm().Raw(sql).QueryRows(&items)
  23. return
  24. }
  25. func GetWxOpenIdList() (items []*OpenIdList, err error) {
  26. sql := `SELECT open_id FROM wx_user AS wu
  27. INNER JOIN company AS c ON c.company_id = wu.company_id
  28. WHERE open_id=? `
  29. openId := "oW3Gts7V3hj-sTAE1VDi0MhGlee8"
  30. _, err = orm.NewOrm().Raw(sql, openId).QueryRows(&items)
  31. return
  32. }
  33. func GetWxOpenIdByMobileList(mobile string) (items []*OpenIdList, err error) {
  34. //sql := `SELECT * FROM user_record WHERE bind_account IN (` + utils.WxMsgTemplateIdAskMsgMobile + `) AND create_platform = 1`
  35. sql := `SELECT cr.*,user_id FROM user_record as c
  36. INNER JOIN cygx_user_record AS cr ON cr.union_id = c.union_id
  37. WHERE bind_account IN (` + mobile + `) AND create_platform = 4`
  38. _, err = orm.NewOrm().Raw(sql).QueryRows(&items)
  39. return
  40. }