123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- package models
- import (
- "github.com/beego/beego/v2/client/orm"
- "hongze/hongze_cygx/utils"
- )
- 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 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
- }
- func GetWxOpenIdByMobileSliceList(mobiles []string) (items []*OpenIdList, err error) {
- itemsLen := len(mobiles)
- if itemsLen == 0 {
- return
- }
- o := orm.NewOrm()
- 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 (` + utils.GetOrmInReplace(itemsLen) + `) AND create_platform = 4`
- _, err = o.Raw(sql, mobiles).QueryRows(&items)
- return
- }
|