123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- package service
- import (
- "context"
- "encoding/json"
- "fmt"
- "log"
- qu "app.yhyue.com/moapp/jybase/common"
- "app.yhyue.com/moapp/jybase/date"
- cm "bp.jydev.jianyu360.cn/CRM/application/api/common"
- "github.com/gogf/gf/v2/frame/g"
- )
- //将用户格式化成 123,456 格式
- func FormatUserId(useridArr []string) (userids string) {
- userids = ""
- for k, v := range useridArr {
- userids += v
- if k+1 != len(useridArr) {
- userids += ","
- }
- }
- return
- }
- //站内信推送
- func StationMailPush(userIds, positionIds, title, content, pcLandingPage, appLandingPage, wxLandingPage string) {
- href := fmt.Sprintf("%s?_action=%s&userIds=%s&msgType=11&title=%s&content=%s&link=%s&sendMode=2&sendTime=%s&androidUrl=%s&iosUrl=%s&weChatUrl=%s&_token=12311&reqSource=1&callPlatform=crm&menuname=message&positionIds=%s",
- cm.C.StationMailHref, cm.C.StationMailAction, userIds, title, content, pcLandingPage, date.NowFormat(date.Date_Short_Layout), appLandingPage, appLandingPage, wxLandingPage, positionIds)
- log.Println(href)
- resp := Get(href, nil)
- log.Println(resp)
- ret := map[string]interface{}{}
- err := json.Unmarshal([]byte(resp), &ret)
- if err != nil {
- log.Println(err)
- return
- }
- if ret != nil && len(ret) > 0 {
- if data := qu.ObjToMap(ret["data"]); data != nil && len(*data) > 0 {
- if qu.Int64All((*data)["status"]) != 1 {
- log.Println("推送失败")
- }
- }
- }
- return
- }
- //公共get方法
- func Get(url string, param map[string]interface{}) (str string) {
- ctx := context.Background()
- if r, err := g.Client().Get(ctx, url, param); err != nil {
- g.Log().Error(ctx, err)
- } else {
- defer r.Close()
- str = r.ReadAllString()
- }
- return
- }
|