12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- 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
- UserId int
- }
- 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 GetWxOpenIdByMobileList(mobile string) (items []*OpenIdList, err error) {
- //sql := `SELECT * FROM user_record WHERE bind_account IN (` + utils.WxMsgTemplateIdAskMsgMobile + `) AND create_platform = 1`
- sql := `SELECT cr.*,user_id FROM user_record as c
- INNER JOIN cygx_user_record AS cr ON cr.union_id = c.union_id
- WHERE bind_account IN (` + mobile + `) AND create_platform = 4`
- _, err = orm.NewOrm().Raw(sql).QueryRows(&items)
- return
- }
- type AdminOpenIdList struct {
- OpenId string `description:"OpenId"`
- UserId int `description:"UserId"`
- Mobile string `description:"手机号"`
- CompanyId int `description:"手机号"`
- }
- // GetAdminOpendidByCompany 通过用户公司ID获取对应销售的openid
- func GetAdminOpendidByCompany(condition string, pars []interface{}) (list []*AdminOpenIdList, err error) {
- sql := `SELECT
- cr.open_id,a.mobile,p.company_id,cr.union_id
- FROM
- company_product AS p
- INNER JOIN admin AS a ON a.admin_id = p.seller_id
- INNER JOIN user_record as c ON c.bind_account = a.mobile
- INNER JOIN cygx_user_record AS cr ON cr.union_id = c.union_id
- WHERE
- 1 = 1
- AND p.product_id = 2
- AND create_platform = 4 ` + condition
- _, err = orm.NewOrm().Raw(sql, pars).QueryRows(&list)
- return
- }
|