Procházet zdrojové kódy

fix: 用户待回答数

hsun před 2 roky
rodič
revize
70147a3d94
1 změnil soubory, kde provedl 23 přidání a 5 odebrání
  1. 23 5
      services/community/question.go

+ 23 - 5
services/community/question.go

@@ -35,7 +35,13 @@ func GetQuestionList(pageIndex, pageSize, onlyMine, chartPermissionId, replyStat
 		}
 	}
 	if replyStatus > 0 {
-		condition["reply_status ="] = replyStatus
+		if replyStatus == 2 && !isAdmin {
+			// 普通用户待回答为待分配和待回答
+			condition["reply_status >"] = 0
+			condition["reply_status <"] = 3
+		} else {
+			condition["reply_status ="] = replyStatus
+		}
 	} else {
 		// 不展示未分配的
 		condition["reply_status >"] = 1
@@ -194,6 +200,8 @@ func CreateQuestion(userId int, mobile, realName, content string) (err error) {
 		RealName:        realName,
 		QuestionContent: content,
 		ReplyStatus:     1,
+		IsRead:          1,
+		ReplierIsRead:   1,
 	}
 	if e := item.Create(); e != nil {
 		err = errors.New("新增问题失败 Err:" + e.Error())
@@ -218,12 +226,13 @@ func ReplyUserQuestion(replierId, questionId int, audios []*request.ReplyReqAudi
 	}
 	// 问题
 	updateCols := make([]string, 0)
-	updateCols = append(updateCols, "reply_status", "reply_time", "modify_time", "msg_send_status")
+	updateCols = append(updateCols, "reply_status", "reply_time", "modify_time", "msg_send_status", "is_read")
 	nowTime := time.Now().Local()
 	item.ReplyStatus = 3
 	item.ReplyTime = nowTime
 	item.ModifyTime = nowTime
 	item.MsgSendStatus = 2
+	item.IsRead = 0
 	// 音频
 	audioList := make([]*yb_community_question_audio.YbCommunityQuestionAudio, 0)
 	for _, v := range audios {
@@ -295,15 +304,24 @@ func GetQuestionListTotal(userInfo user.UserInfo) (resp *response.CommunityQuest
 		return
 	}
 	resp = new(response.CommunityQuestionListTotal)
+	var distribute, wait, replied int
 	for _, v := range countList {
+		if v.ReplyStatus == 1 {
+			distribute = v.Total
+		}
 		if v.ReplyStatus == 2 {
-			resp.Wait = v.Total
-			continue
+			wait = v.Total
 		}
 		if v.ReplyStatus == 3 {
-			resp.Replied = v.Total
+			replied = v.Total
 		}
 	}
+	if isAdmin {
+		resp.Wait = wait
+	} else {
+		resp.Wait = distribute + wait
+	}
+	resp.Replied = replied
 	resp.Total = resp.Wait + resp.Replied
 	return
 }