renjiaojiao 1 rok temu
rodzic
commit
893bbf67cd

+ 9 - 4
rpc/internal/common/msglistService.go

@@ -185,6 +185,9 @@ func BitmapUserMsgList(this *message.UserMsgListReq) (*message.UserMsgList, *mes
 					end = 0
 				}
 				fmt.Println(end, start)
+				if end < 0 || start < 0 {
+					return data, nil
+				}
 				resArr := userMsgArr[end:start]
 				resData := []*message.Messages{}
 				if len(resArr) > 0 {
@@ -309,9 +312,10 @@ func BitmapCountUnread(userId string, classUnreadCountMap map[int]int, isRedis b
 				}
 				if isRedis {
 					//用户分类未读
-					//fmt.Println(util.IntAll(val["group_id"]))
-					key := fmt.Sprintf(MsgCountKey, userId, util.IntAll(val["group_id"]))
-					redis.Put(redisModule, key, oneClassUnread, 60*60)
+					if oneClassUnread >= 0 {
+						key := fmt.Sprintf(MsgCountKey, userId, util.IntAll(val["group_id"]))
+						redis.Put(redisModule, key, oneClassUnread, 60*60)
+					}
 				}
 				data[common.InterfaceToStr(val["group_id"])] = int64(oneClassUnread)
 				count += int64(oneClassUnread)
@@ -327,6 +331,7 @@ func BitmapCountClassUnread(userId string, groupId int64, classUnreadCountMap ma
 		count int64
 	)
 	data := make(map[string]int64)
+	fmt.Println("=========", groupId, entity.ClassSearchMap)
 	if _, ok := entity.ClassSearchMap[groupId]; !ok {
 		return
 	}
@@ -341,7 +346,7 @@ func BitmapCountClassUnread(userId string, groupId int64, classUnreadCountMap ma
 		} else {
 			//分类所有消息
 			classUnreadCount := classUnreadCountMap[util.IntAll(msgClass.MsgType)]
-			if classUnreadCount != -1 {
+			if classUnreadCount >= 0 {
 				redis.Put(redisModule, key, classCount, -1)
 				data[fmt.Sprintf("%d", msgClass.MsgType)] = int64(classUnreadCount)
 				count += int64(classUnreadCount)

+ 30 - 3
rpc/internal/common/newSendMsgService.go

@@ -22,13 +22,13 @@ var MsgGroupIdMap map[int]int
 func SetMsgSummary(newMsg, groupId, msgType int64) error {
 	//更新所有消息
 	if groupId == 11 {
-		//groupId = msgType
+		groupId = msgType
 		//根据msgType更新待办二级分类汇总
-		err1 := entity.ClickhouseConn.Exec(context.Background(), fmt.Sprintf(`alter table message_summary UPDATE msg_bitmap = bitmapOr(msg_bitmap,bitmapBuild([toUInt64(%d)])) where group_id = %d`, newMsg, msgType))
+		/*err1 := entity.ClickhouseConn.Exec(context.Background(), fmt.Sprintf(`alter table message_summary UPDATE msg_bitmap = bitmapOr(msg_bitmap,bitmapBuild([toUInt64(%d)])) where group_id = %d`, newMsg, msgType))
 		if err1 != nil {
 			//插入失败
 			return err1
-		}
+		}*/
 	}
 	err := entity.ClickhouseConn.Exec(context.Background(), fmt.Sprintf(`alter table message_summary UPDATE msg_bitmap = bitmapOr(msg_bitmap,bitmapBuild([toUInt64(%d)])) where group_id = %d`, newMsg, groupId))
 	if err != nil {
@@ -182,6 +182,33 @@ func UpdateUserMsgSummary(in *message.MultipleSaveMsgReq) error {
 	return nil
 }
 
+//附件下载、剑鱼币活动到期提醒存消息发送记录
+func InsertMsgSendLog(in *message.MultipleSaveMsgReq) int64 {
+	groupId := MsgGroupIdMap[int(in.MsgType)]
+	id := entity.Mysql.Insert("message_send_log", map[string]interface{}{
+		"send_usergroup_id":   "",
+		"send_usergroup_name": "",
+		"msg_type":            in.MsgType,
+		"title":               in.Title,
+		"content":             in.Content,
+		"send_mode":           2,
+		"send_time":           time.Now().Format("2006-01-02 15:04:05"),
+		"send_status":         4,
+		"update_time":         time.Now().Format("2006-01-02 15:04:05"),
+		"link":                in.Link,
+		"isdel":               1,
+		"send_userid":         "",
+		"update_user":         "",
+		"Sign":                5,
+		"menu_name":           "message",
+		"group_id":            groupId,
+	})
+	if id > 0 {
+		return id
+	}
+	return 0
+}
+
 func ConvertToBitmap(num int) (res []uint32) {
 	binary := strconv.FormatInt(int64(num), 2)
 	total := len(binary)

+ 15 - 5
rpc/internal/logic/multiplesavemsglogic.go

@@ -25,14 +25,24 @@ func NewMultipleSaveMsgLogic(ctx context.Context, svcCtx *svc.ServiceContext) *M
 
 // 批量保存消息
 func (l *MultipleSaveMsgLogic) MultipleSaveMsg(in *messageclient.MultipleSaveMsgReq) (*messageclient.MultipleSaveMsgResp, error) {
-	// todo: add your logic here and delete this line
-	var code = 1
-	err := service.UpdateUserMsgSummary(in)
-	if err != nil {
+	var (
+		code = 1
+		msg  = "发送成功"
+	)
+	msgLogId := service.InsertMsgSendLog(in)
+	if msgLogId > 0 {
+		in.MsgLogId = msgLogId
+		err := service.UpdateUserMsgSummary(in)
+		if err != nil {
+			code = 0
+			msg = err.Error()
+		}
+	} else {
 		code = 0
+		msg = "插入message_send_log表出错"
 	}
 	return &messageclient.MultipleSaveMsgResp{
 		Code:    int64(code),
-		Message: err.Error(),
+		Message: msg,
 	}, nil
 }