Explorar o código

推送开关调整

wangchuanjin %!s(int64=2) %!d(string=hai) anos
pai
achega
36efb336e1
Modificáronse 2 ficheiros con 84 adicións e 16 borrados
  1. 63 11
      p/public.go
  2. 21 5
      p/struct.go

+ 63 - 11
p/public.go

@@ -245,13 +245,70 @@ func GetKeySets(a_key interface{}) ([]*KeySet, error) {
 	return keySets, err
 }
 
-//解析用户的订阅词
-func GetSubSet(isFreeUser bool, userId string, obj map[string]interface{}) *SubSet {
-	mailpush := util.IntAll(obj["i_mailpush"])
-	email := strings.TrimSpace(util.ObjToString(obj["s_email"]))
-	if mailpush == 1 && !MailReg.MatchString(email) {
-		mailpush = -1
+//解析用户的推送设置
+func GetPushSet(userId string, obj map[string]interface{}) *PushSet {
+	subSet, _ := obj["o_subset"].(map[string]interface{})
+	times, _ := subSet["a_times"].([]interface{})
+	weekReport, _ := obj["o_week_report"].(map[string]interface{})
+	monthReport, _ := obj["o_month_report"].(map[string]interface{})
+	newprojectForecast, _ := obj["o_newproject_forecast"].(map[string]interface{})
+	entInfo, _ := obj["o_entinfo"].(map[string]interface{})
+	followProject, _ := obj["o_follow_project"].(map[string]interface{})
+	followEnt, _ := obj["o_follow_ent"].(map[string]interface{})
+	pushSet := &PushSet{
+		Email: strings.TrimSpace(util.ObjToString(obj["s_email"])),
+		SubSet: &PushSetChild{
+			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),
+		},
+		WeekReport: &PushSetChild{
+			WxPush:   util.IntAllDef(weekReport["i_wxpush"], 1),
+			AppPush:  util.IntAllDef(weekReport["i_apppush"], 1),
+			MailPush: util.IntAll(weekReport["i_mailpush"]),
+		},
+		MonthReport: &PushSetChild{
+			WxPush:   util.IntAllDef(monthReport["i_wxpush"], 1),
+			AppPush:  util.IntAllDef(monthReport["i_apppush"], 1),
+			MailPush: util.IntAll(monthReport["i_mailpush"]),
+		},
+		NewprojectForecast: &PushSetChild{
+			WxPush:   util.IntAllDef(newprojectForecast["i_wxpush"], 1),
+			AppPush:  util.IntAllDef(newprojectForecast["i_apppush"], 1),
+			MailPush: util.IntAll(newprojectForecast["i_mailpush"]),
+		},
+		EntInfo: &PushSetChild{
+			WxPush:   util.IntAllDef(entInfo["i_wxpush"], 1),
+			AppPush:  util.IntAllDef(entInfo["i_apppush"], 1),
+			MailPush: util.IntAll(entInfo["i_mailpush"]),
+		},
+		FollowProject: &PushSetChild{
+			WxPush:   util.IntAllDef(followProject["i_wxpush"], 1),
+			AppPush:  util.IntAllDef(followProject["i_apppush"], 1),
+			MailPush: util.IntAll(followProject["i_mailpush"]),
+		},
+		FollowEnt: &PushSetChild{
+			WxPush:   util.IntAllDef(followEnt["i_wxpush"], 1),
+			AppPush:  util.IntAllDef(followEnt["i_apppush"], 1),
+			MailPush: util.IntAll(followEnt["i_mailpush"]),
+		},
+	}
+	if !MailReg.MatchString(pushSet.Email) {
+		pushSet.SubSet.MailPush = -1
+		pushSet.WeekReport.MailPush = -1
+		pushSet.MonthReport.MailPush = -1
+		pushSet.NewprojectForecast.MailPush = -1
+		pushSet.EntInfo.MailPush = -1
+		pushSet.FollowProject.MailPush = -1
+		pushSet.FollowEnt.MailPush = -1
 	}
+	return pushSet
+}
+
+//解析用户的订阅设置
+func GetSubSet(isFreeUser bool, userId string, obj map[string]interface{}) *SubSet {
 	subSet := &SubSet{
 		Keys:                  []string{},
 		Notkeys:               []string{},
@@ -263,14 +320,9 @@ func GetSubSet(isFreeUser bool, userId string, obj map[string]interface{}) *SubS
 		Areas:                 []string{},
 		Subtypes:              []string{},
 		Buyerclasss:           []string{},
-		WxPush:                util.IntAllDef(obj["i_wxpush"], 1),
-		AppPush:               util.IntAllDef(obj["i_apppush"], 1),
-		MailPush:              mailpush,
-		Email:                 email,
 		MatchWay:              util.IntAllDef(obj["i_matchway"], 1),
 		Matchbuyerclass_other: util.IntAllDef(obj["i_matchbuyerclass_other"], 1),
 		ProjectMatch:          util.IntAll(obj["i_projectmatch"]),
-		RateMode:              util.IntAllDef(obj["i_ratemode"], 2),
 		MaxPushSize:           util.IntAll(obj["i_maxpushsize"]),
 		MaxMailSize:           util.IntAll(obj["i_maxmailsize"]),
 	}

+ 21 - 5
p/struct.go

@@ -65,11 +65,6 @@ type KeySet struct {
 
 //解析订阅词
 type SubSet struct {
-	WxPush                int                        //是否开启微信推送
-	AppPush               int                        //是否开启app推送
-	MailPush              int                        //是否开启邮箱推送
-	RateMode              int                        //推送时间
-	Email                 string                     //邮箱
 	MatchWay              int                        //匹配方式 1-标题 2-正文
 	Matchbuyerclass_other int                        //是否开启其他按钮
 	ProjectMatch          int                        //项目关联推送
@@ -92,6 +87,26 @@ type SubSet struct {
 	MaxMailSize           int                        //邮件最大条数
 }
 
+//推送设置
+type PushSet struct {
+	Email              string        //邮箱
+	SubSet             *PushSetChild //订阅推送设置
+	WeekReport         *PushSetChild //周报推送设置
+	MonthReport        *PushSetChild //月报推送设置
+	NewprojectForecast *PushSetChild //潜在项目预测推送设置
+	EntInfo            *PushSetChild //企业情报监控-企业工商变动推送设置
+	FollowProject      *PushSetChild //项目进度监控推送设置
+	FollowEnt          *PushSetChild //企业情报监控-企业中标动态推送设置
+}
+
+type PushSetChild struct {
+	RateMode int      //推送时间
+	Times    []string //自定义推送时间
+	WxPush   int      //是否开启微信推送
+	AppPush  int      //是否开启app推送
+	MailPush int      //是否开启邮箱推送
+}
+
 //用户基本信息
 type UserInfo struct {
 	Id               string //mongoid
@@ -115,6 +130,7 @@ type UserInfo struct {
 	MemberMainid     string
 	WxTplMsg         *WxTplMsg
 	SubSet           *SubSet
+	PushSet          *PushSet
 	Extend           *UserInfoExtend
 }