package models

import "rdluck_tools/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
}
