liuxiaolong
2020-09-08 f58d6c7e121dc6a16f6b1e12e5beba1e6ce1b992
service/msgPush.go
@@ -184,6 +184,7 @@
   androidPush := map[string]map[string]map[string]string {
      "ups": {
         "notification": {
            "title": title,
            "body": msg,
            "big_text": msg,
            "click_type": "intent",
@@ -193,8 +194,10 @@
   }
   iosPush := map[string]interface{}{
      "type":"notify",
      "payload": "育英中学停车",
      "aps":map[string]interface{}{
         "alert":map[string]string{
            "title": title,
            "body": msg,
         },
         "content-available":0,
@@ -207,6 +210,7 @@
      },
      "push_message": map[string]map[string]string {
         "notification": {
            "title": title,
            "body": msg,
            "click_type": "intent",
            "intent": intent,
@@ -557,10 +561,14 @@
               if personId,ok := carPersonM[inCnPlateNo];ok {
                  if v,ex := hikPersonMap[personId]; ex {
                     carOwners = append(carOwners, v.PersonName)
                     carOwners = append(carOwners, sn.PlateNo+"("+v.PersonName+")")
                  }
               } else { //找不到车主,即视为临时车,将车牌作为车主姓名推送
                  carOwners = append(carOwners, sn.PlateNo)
                  if sn.PlateNo == "无车牌" {
                     carOwners = append(carOwners, sn.PlateNo)
                  } else {
                     carOwners = append(carOwners, sn.PlateNo+"()")
                  }
               }
            }
         }
@@ -585,14 +593,19 @@
}
//如果夜间有给车库内的车主推送“请尽快驶离”的消息,则告知管理员 有哪些车尚停在车库内
func Push2Manager(title string, msg string) (bool, error, []string) {
func Push2Manager(title string, msg string, isTest bool) (bool, error, []string) {
   if len(msg) > 256 {
      fmt.Println("夜间停留车太多,message:", msg)
      r := []rune(msg)
      msg = string(r[:125])+"..."
   }
   managers := beego.AppConfig.String("nightManagerPhones")
   managers := ""
   if isTest {
      managers = beego.AppConfig.String("testPushPhones")
   } else {
      managers = beego.AppConfig.String("nightManagerPhones")
   }
   if managers == "" {
      return false, errors.New("夜间推送管理员手机号未配置"), []string{}
   }