12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- package service
- import (
- "context"
- "encoding/json"
- "fmt"
- "log"
- "strconv"
- "time"
- 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
- }
- //站内信推送 msgType 11待办 2服务通知
- func StationMailPush(userId, positionId, title, content, pcHref, mobileHref string, msgType string) bool {
- pcLandingPage := "/front/sess/" + Se.EncodeString(positionId+",positionId,"+strconv.Itoa(int(time.Now().Unix()))+",") + "__" + Se.EncodeString(pcHref)
- wxLandingPage := "/front/sess/" + Se.EncodeString(positionId+",positionId,"+strconv.Itoa(int(time.Now().Unix()))+",") + "__" + Se.EncodeString(mobileHref)
- appLandingPage := "/jyapp/free/sess/" + Se.EncodeString(positionId+",positionId,"+strconv.Itoa(int(time.Now().Unix()))+",") + "__" + Se.EncodeString(mobileHref)
- href := fmt.Sprintf("%s?_action=%s&userIds=%s&msgType=%s&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.Push.StationMailHref, cm.Push.StationMailAction, userId, msgType, title, content, pcLandingPage, date.NowFormat(date.Date_Short_Layout), appLandingPage, appLandingPage, wxLandingPage, positionId)
- log.Println(href)
- resp := Get(href, nil)
- log.Println("resp:", resp)
- ret := map[string]interface{}{}
- err := json.Unmarshal([]byte(resp), &ret)
- if err != nil {
- return false
- }
- if ret != nil && len(ret) > 0 {
- if data := qu.ObjToMap(ret["data"]); data != nil && len(*data) > 0 {
- if qu.Int64All((*data)["status"]) != 1 {
- return false
- }
- }
- }
- return true
- }
- //公共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 {
- log.Println("get err:", err)
- } else {
- defer r.Close()
- str = r.ReadAllString()
- }
- return
- }
|