Procházet zdrojové kódy

更新消息通知

wangbin před 3 roky
rodič
revize
0d32993a59
1 změnil soubory, kde provedl 52 přidání a 25 odebrání
  1. 52 25
      service/task/sync_data.go

+ 52 - 25
service/task/sync_data.go

@@ -1014,43 +1014,42 @@ func (s *SyncData) TaskMsgSendRetainedDataUpdate(ctx context.Context, completesI
 				retainedErr = true
 			}
 		}
+		oneErrM := ""
 		// 5分钟数据没动报异常数据
 		if newErr && nm > 4 {
 			eMsg += "\n"
-			eMsg += taskStatistics.GameName
-			eMsg += ",新增"
+			eMsg += s.StrMontage(nm, taskStatistics.GameName, ",新增", 0)
 			if nm >= 60 {
-				eMsg += "("
-				eMsg += strconv.Itoa(nm / 60)
-				eMsg += "小时内)"
-			} else {
-				eMsg += "("
-				eMsg += strconv.Itoa(nm)
-				eMsg += "分钟内)"
+				oneErrM += s.StrMontage(nm, taskStatistics.GameName, ",新增", data["newRate"].AlsoTarget)
 			}
 		}
 		if retainedErr && rm > 4 {
 			if !newErr {
 				eMsg += "\n"
-				eMsg += taskStatistics.GameName
-			}
-			eMsg += ",活跃"
-			if rm >= 60 {
-				eMsg += "("
-				eMsg += strconv.Itoa(rm / 60)
-				eMsg += "小时内)"
+				eMsg += s.StrMontage(rm, taskStatistics.GameName, ",活跃", 0)
+				if rm >= 60 {
+					oneErrM += s.StrMontage(rm, taskStatistics.GameName, ",活跃", data["retainedRate"].AlsoTarget)
+				}
 			} else {
-				eMsg += "("
-				eMsg += strconv.Itoa(rm)
-				eMsg += "分钟内)"
+				eMsg += s.StrMontage(rm, "", ",活跃", 0)
+				if rm >= 60 {
+					if oneErrM != "" {
+						oneErrM += s.StrMontage(rm, "", ",活跃", data["retainedRate"].AlsoTarget)
+					} else {
+						eMsg += "\n"
+						eMsg += s.StrMontage(rm, taskStatistics.GameName, ",活跃", 0)
+					}
+
+				}
 			}
 		}
 		if eMsg != "" {
 			errMsgZ += eMsg
 			errSendMsg[name] += eMsg
 		}
-		if (rm >= 60 || nm >= 60) && eMsg != "" {
-			PErrSendMsg[name] += eMsg
+		if oneErrM != "" {
+			PErrSendMsg[name] += oneErrM
+			PErrSendMsg[name] += "\n"
 		}
 		sendMsg[name] += ","
 		if m >= 60 {
@@ -1129,6 +1128,27 @@ func (s *SyncData) TaskMsgSendRetainedDataUpdate(ctx context.Context, completesI
 	}
 }
 
+// 数据拼接
+func (s *SyncData) StrMontage(minute int, taskName, strType string, diff int) (msg string) {
+	if taskName != "" {
+		msg += taskName
+	}
+	msg += strType
+	if minute >= 60 {
+		msg += "("
+		msg += strconv.Itoa(minute / 60)
+		msg += "小时内)"
+	} else {
+		msg += "("
+		msg += strconv.Itoa(minute)
+		msg += "分钟内)"
+	}
+	if diff > 0 {
+		msg += ",剩余 " + strconv.Itoa(diff)
+	}
+	return msg
+}
+
 func (s *SyncData) TaskMsgSendDirector(ctx context.Context, msgType string, sendMsg map[string]string, mpsPerson map[string]typeManage.ResponsiblePerson, hour int, date string, lt int, isFree bool) {
 	for pName, pMsg := range sendMsg {
 		lastTimeKey := ""
@@ -1144,9 +1164,7 @@ func (s *SyncData) TaskMsgSendDirector(ctx context.Context, msgType string, send
 		lttime := int(time.Now().Unix()) - lastTime
 		if hour >= mpsPerson[pName].StartTime && lttime/60 >= lt {
 			var personMsg = msgType //"# 活跃异常 "
-			if isFree {
-				personMsg += "\n"
-			}
+			personMsg += "\n"
 			personMsg += fmt.Sprintf("<font color=\"warning\">%s</font>", pMsg)
 			url := mpsPerson[pName].Url
 			var sendPersonData SendMsg
@@ -1177,16 +1195,20 @@ func (s *SyncData) TaskMsgSendFreeDataUpdate(ctx context.Context, completesInfo
 		lastPayCompletedUpdateTimeKey := fmt.Sprintf(LastPayCompletedUpdateTimeKey, date, complete.TaskId)
 		lastPayAddUpdateTimeKey := fmt.Sprintf(LastPayAddUpdateTimeKey, date, complete.TaskId)
 		currentPayCompleted := complete.PayComplete + complete.HandPayComplete
+		payErrAddNumKey := fmt.Sprintf(PayErrAddNumKey, date, complete.TaskId)
 		// 付费处理
 		if complete.PayTarget != 0 && complete.PayTarget > currentPayCompleted {
 			lastPayCompleted, _ := s.cache.GetCacheNum(ctx, lastPayCompletedKey)
 			alsoPayTarget := complete.PayTarget - currentPayCompleted
+
 			payRate := 0
 			lastPayCompletedUpdateTime, _ := s.cache.GetCacheNum(ctx, lastPayCompletedUpdateTimeKey)
 			lastPayAddUpdateTime, _ := s.cache.GetCacheNum(ctx, lastPayAddUpdateTimeKey)
 			timeRate := int(ctime) - lastPayCompletedUpdateTime
 			if lastPayCompleted < currentPayCompleted {
 				payRate = currentPayCompleted - lastPayCompleted
+				// 如有效率就初始发累加的付费数量
+				_ = s.cache.SetCacheStr(ctx, payErrAddNumKey, 0)
 				_ = s.cache.SetCacheStr(ctx, lastPayCompletedKey, currentPayCompleted)
 				_ = s.cache.SetCacheStr(ctx, lastPayCompletedUpdateTimeKey, ctime) //上次付费更新时间
 			}
@@ -1281,7 +1303,12 @@ func (s *SyncData) TaskMsgSendFreeDataUpdate(ctx context.Context, completesInfo
 					mobile = append(mobile, mpsPerson[name].MobilePhoneNumber)
 				}
 				if data.TimeRate/60 >= 30 {
-					PErrSendMsg[name] += oneErrM
+					PErrSendMsg[name] += s.StrMontage(data.TimeRate/60, taskStatistics.GameName, ",付费", data.AlsoTarget)
+					PErrSendMsg[name] += ","
+					PErrSendMsg[name] += "最后加付费时间 "
+					PErrSendMsg[name] += t.Format("15:04:05")
+					PErrSendMsg[name] += "(+" + strconv.Itoa(lastAddFeeNumErr) + ")"
+					PErrSendMsg[name] += "\n"
 				}
 			}
 		}