1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- package models
- import "github.com/beego/beego/v2/client/orm"
- type SendTemplateResponse struct {
- Errcode int `json:"errcode"`
- Errmsg string `json:"errmsg"`
- MsgID int `json:"msgid"`
- }
- type OpenIdList struct {
- OpenId string
- }
- func GetOpenIdList() (items []*OpenIdList, err error) {
- openIdstr := WxUsersGet()
- sql := `SELECT open_id FROM wx_user AS wu
- INNER JOIN company AS c ON c.company_id = wu.company_id
- WHERE wu.open_id IS NOT NULL AND c.type IN (1,2) `
- if openIdstr != "" {
- sql += ` AND open_id in (` + openIdstr + `) `
- }
- _, err = orm.NewOrm().Raw(sql).QueryRows(&items)
- return
- }
- func GetWxOpenIdList() (items []*OpenIdList, err error) {
- sql := `SELECT open_id FROM wx_user AS wu
- INNER JOIN company AS c ON c.company_id = wu.company_id
- WHERE open_id=? `
- openId := "oW3Gts7V3hj-sTAE1VDi0MhGlee8"
- _, err = orm.NewOrm().Raw(sql, openId).QueryRows(&items)
- return
- }
- func DeleteTemplateRecordByDate(date string) (err error) {
- sql := `DELETE FROM user_template_record WHERE create_time<? `
- o := orm.NewOrm()
- _, err = o.Raw(sql, date).Exec()
- return
- }
- // GetOpenIdListV2 2022-08-18从hongze_admin复制过来的最新的代码
- func GetOpenIdListV2() (items []*OpenIdList, err error) {
- sql := `SELECT DISTINCT
- ur.open_id,
- wu.user_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.subscribe = 1 AND ur.create_platform = 1 AND d. STATUS IN ('正式', '试用', '永续') `
- _, err = orm.NewOrm().Raw(sql).QueryRows(&items)
- return
- }
- func GetOpenIdArr() (items []string, 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.subscribe=1 AND ur.create_platform=1 AND d.status IN('正式','试用','永续')
- ORDER BY FIELD(c.company_id, 16) desc, ur.user_record_id asc`
- o := orm.NewOrm()
- _, err = o.Raw(sql).QueryRows(&items)
- return
- }
- func GetOpenIdArrByClassifyNameSecond(classifyNameSecond string) (items []string, 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
- INNER JOIN company_report_permission AS e ON d.company_id=e.company_id
- INNER JOIN chart_permission AS f ON e.chart_permission_id=f.chart_permission_id
- INNER JOIN chart_permission_search_key_word_mapping AS g ON f.chart_permission_id=g.chart_permission_id
- WHERE ur.open_id != "" AND ur.subscribe=1 AND ur.create_platform=1 AND d.status IN('正式','试用','永续') AND e.status IN('正式','试用','永续')
- AND g.from='rddp'
- AND g.key_word=?
- ORDER BY FIELD(c.company_id, 16) DESC, ur.user_record_id ASC `
- o := orm.NewOrm()
- _, err = o.Raw(sql, classifyNameSecond).QueryRows(&items)
- return
- }
|