wangchuanjin %!s(int64=2) %!d(string=hai) anos
pai
achega
a1fb3e46dd
Modificáronse 2 ficheiros con 22 adicións e 3 borrados
  1. 9 0
      p/public.go
  2. 13 3
      p/struct.go

+ 9 - 0
p/public.go

@@ -699,3 +699,12 @@ func IdentityByEntUserId(base, main *Mysql, entUserId int64) *IdentityInfo {
 	}
 	return nil
 }
+
+//
+func HourFormat(hour int) string {
+	if hour < 10 {
+		return fmt.Sprintf("0%d:00")
+	} else {
+		return fmt.Sprintf("%d:00")
+	}
+}

+ 13 - 3
p/struct.go

@@ -2,6 +2,7 @@ package p
 
 import (
 	"encoding/json"
+	"sort"
 	"strings"
 
 	util "app.yhyue.com/moapp/jybase/common"
@@ -177,7 +178,16 @@ func NewUserInfo(temp map[string]interface{}, tp int) *UserInfo {
 //解析用户的推送设置
 func (u *UserInfo) GetPushSet(obj map[string]interface{}) {
 	subSet, _ := obj["o_subset"].(map[string]interface{})
-	times, _ := subSet["a_times"].([]interface{})
+	rateMode := util.IntAllDef(subSet["i_ratemode"], 2)
+	a_times, _ := subSet["a_times"].([]interface{})
+	times := []string{}
+	for _, v := range a_times {
+		times = append(times, util.ObjToString(v))
+	}
+	if len(times) == 0 {
+		times = append(times, "09:00", "14:00")
+	}
+	sort.Strings(times)
 	weekReport, _ := obj["o_week_report"].(map[string]interface{})
 	monthReport, _ := obj["o_month_report"].(map[string]interface{})
 	newprojectForecast, _ := obj["o_newproject_forecast"].(map[string]interface{})
@@ -190,8 +200,8 @@ func (u *UserInfo) GetPushSet(obj map[string]interface{}) {
 			WxPush:   util.IntAllDef(subSet["i_wxpush"], 1),
 			AppPush:  util.IntAllDef(subSet["i_apppush"], 1),
 			MailPush: util.IntAll(subSet["i_mailpush"]),
-			RateMode: util.IntAllDef(subSet["i_ratemode"], 5),
-			Times:    util.ObjArrToStringArr(times),
+			RateMode: rateMode,
+			Times:    times,
 		},
 		WeekReport: &PushSetChild{
 			WxPush:   util.IntAllDef(weekReport["i_wxpush"], 1),