Browse Source

temp commit

hsun 2 years ago
parent
commit
02786c9151

+ 64 - 29
logic/yb_community_question/yb_community_question_comment.go

@@ -6,6 +6,7 @@ import (
 	"hongze/hongze_yb/global"
 	"hongze/hongze_yb/global"
 	"hongze/hongze_yb/models/response"
 	"hongze/hongze_yb/models/response"
 	"hongze/hongze_yb/models/tables/admin"
 	"hongze/hongze_yb/models/tables/admin"
+	"hongze/hongze_yb/models/tables/chart_permission"
 	"hongze/hongze_yb/models/tables/company"
 	"hongze/hongze_yb/models/tables/company"
 	"hongze/hongze_yb/models/tables/company_product"
 	"hongze/hongze_yb/models/tables/company_product"
 	"hongze/hongze_yb/models/tables/wx_user"
 	"hongze/hongze_yb/models/tables/wx_user"
@@ -13,6 +14,7 @@ import (
 	"hongze/hongze_yb/models/tables/yb_community_question"
 	"hongze/hongze_yb/models/tables/yb_community_question"
 	"hongze/hongze_yb/models/tables/yb_community_question_comment"
 	"hongze/hongze_yb/models/tables/yb_community_question_comment"
 	"hongze/hongze_yb/models/tables/yb_community_video"
 	"hongze/hongze_yb/models/tables/yb_community_video"
+	"hongze/hongze_yb/models/tables/yb_road_video"
 	"hongze/hongze_yb/services/alarm_msg"
 	"hongze/hongze_yb/services/alarm_msg"
 	"hongze/hongze_yb/services/company_approval_message"
 	"hongze/hongze_yb/services/company_approval_message"
 	"hongze/hongze_yb/services/user"
 	"hongze/hongze_yb/services/user"
@@ -20,6 +22,7 @@ import (
 	"hongze/hongze_yb/services/wx_app"
 	"hongze/hongze_yb/services/wx_app"
 	"hongze/hongze_yb/utils"
 	"hongze/hongze_yb/utils"
 	"strconv"
 	"strconv"
+	"strings"
 	"time"
 	"time"
 )
 )
 
 
@@ -391,13 +394,69 @@ func systemMessageToAdmin(adminInfo admin.Admin, wxUser user.UserInfo, community
 	receiveUserId := int(adminInfo.AdminID)
 	receiveUserId := int(adminInfo.AdminID)
 
 
 	var msgType, sourceType, approvalStatus int8
 	var msgType, sourceType, approvalStatus int8
+	var remark, content, msgContent, extra, messageSource string
 	msgType = company_approval_message.CompanyApprovalMessageMessageTypeByApply
 	msgType = company_approval_message.CompanyApprovalMessageMessageTypeByApply
-	// 消息来源: 6-问答社区; 7-视频社区
-	if communityQuestionComment.Source == 1 {
+
+	// 消息来源: 6-问答社区; 7-视频社区; 8-线上路演;
+	switch communityQuestionComment.Source {
+	case 1:
 		sourceType = company_approval_message.CompanyApprovalMessageSourceTypeByQuestionComment
 		sourceType = company_approval_message.CompanyApprovalMessageSourceTypeByQuestionComment
-	} else {
+		remark = `您有新的问答评论待查阅`
+		content = `您有新的问答评论待查阅`
+		messageSource = `问答社区`
+
+		// 获取评论对应的问答/视频信息
+		communityQuestion, e := yb_community_question.GetItemById(int(communityQuestionComment.CommunityQuestionID))
+		if e != nil {
+			err = errors.New("获取评论对应的问答失败,err:" + e.Error())
+			return
+		}
+		msgContent = communityQuestion.QuestionContent
+	case 2:
 		sourceType = company_approval_message.CompanyApprovalMessageSourceTypeByVideoComment
 		sourceType = company_approval_message.CompanyApprovalMessageSourceTypeByVideoComment
+		remark = `您有新的视频评论待查阅`
+		content = `您有新的视频评论待查阅`
+		messageSource = `视频社区`
+
+		communityVideo, e := yb_community_video.GetItemById(int(communityQuestionComment.CommunityQuestionID))
+		if e != nil {
+			err = errors.New("获取评论对应的视频失败,err:" + e.Error())
+			return
+		}
+		msgContent = communityVideo.Title
+		extra = communityVideo.VarietyTagName
+	case 3:
+		sourceType = company_approval_message.CompanyApprovalMessageSourceTypeByRoadVideoComment
+		remark = `您有新的视频评论待查阅`
+		content = `您有新的视频评论待查阅`
+		messageSource = `线上路演`
+
+		communityVideo, e := yb_road_video.GetItemById(int(communityQuestionComment.CommunityQuestionID))
+		if e != nil {
+			err = errors.New("获取评论对应的路演视频失败,err:" + e.Error())
+			return
+		}
+		msgContent = communityVideo.Title
+		// 路演视频品种
+		if communityVideo.ChartPermissionIds != "" {
+			cpIds := utils.JoinStr2IntArr(communityVideo.ChartPermissionIds, ",")
+			if len(cpIds) > 0 {
+				cpList, e := chart_permission.GetListByIds(cpIds)
+				if e != nil {
+					err = errors.New("获取路演视频品种失败, Err: " + e.Error())
+					return
+				}
+				cpArr := make([]string, 0)
+				for i := range cpList {
+					cpArr = append(cpArr, cpList[i].PermissionName)
+				}
+				extra = strings.Join(cpArr, ",")
+			}
+		}
+	default:
+		return
 	}
 	}
+
 	approvalStatus = company_approval_message.CompanyApprovalMessageApprovalStatusByPending
 	approvalStatus = company_approval_message.CompanyApprovalMessageApprovalStatusByPending
 
 
 	companyInfo, err := company.GetByCompanyId(wxUser.CompanyID)
 	companyInfo, err := company.GetByCompanyId(wxUser.CompanyID)
@@ -412,32 +471,7 @@ func systemMessageToAdmin(adminInfo admin.Admin, wxUser user.UserInfo, community
 	}
 	}
 
 
 	companyName := companyInfo.CompanyName
 	companyName := companyInfo.CompanyName
-	remark := `您有新的问答评论待查阅`
-	content := `您有新的问答评论待查阅`
-	if communityQuestionComment.Source == 2 {
-		remark = `您有新的视频评论待查阅`
-		content = `您有新的视频评论待查阅`
-	}
 
 
-	// 获取评论对应的问答/视频信息
-	msgContent := ``
-	extra := ``
-	if communityQuestionComment.Source == 1 {
-		communityQuestion, e := yb_community_question.GetItemById(int(communityQuestionComment.CommunityQuestionID))
-		if e != nil {
-			err = errors.New("获取评论对应的问答失败,err:" + e.Error())
-			return
-		}
-		msgContent = communityQuestion.QuestionContent
-	} else {
-		communityVideo, e := yb_community_video.GetItemById(int(communityQuestionComment.CommunityQuestionID))
-		if e != nil {
-			err = errors.New("获取评论对应的视频失败,err:" + e.Error())
-			return
-		}
-		msgContent = communityVideo.Title
-		extra = communityVideo.VarietyTagName
-	}
 	messageInfo := company_approval_message.MessageInfo{
 	messageInfo := company_approval_message.MessageInfo{
 		CompanyName:          companyInfo.CompanyName,
 		CompanyName:          companyInfo.CompanyName,
 		ProductId:            productId,
 		ProductId:            productId,
@@ -447,7 +481,8 @@ func systemMessageToAdmin(adminInfo admin.Admin, wxUser user.UserInfo, community
 		UserId:               wxUser.UserID,
 		UserId:               wxUser.UserID,
 		UserName:             communityQuestionComment.RealName,
 		UserName:             communityQuestionComment.RealName,
 		CreateTime:           communityQuestionComment.CreateTime,
 		CreateTime:           communityQuestionComment.CreateTime,
-		Extra:                extra,	// 附加字段
+		Extra:                extra,         // 附加字段
+		MessageSource:        messageSource, // 消息来源
 	}
 	}
 	//客户添加消息
 	//客户添加消息
 	err = company_approval_message.AddCompanyApprovalMessage(utils.AdminId, receiveUserId, int(wxUser.CompanyID), int(communityQuestionComment.CommunityQuestionCommentID), msgType, sourceType, approvalStatus, companyName, remark, content, messageInfo)
 	err = company_approval_message.AddCompanyApprovalMessage(utils.AdminId, receiveUserId, int(wxUser.CompanyID), int(communityQuestionComment.CommunityQuestionCommentID), msgType, sourceType, approvalStatus, companyName, remark, content, messageInfo)

+ 10 - 8
services/company_approval_message/company_approval_message.go

@@ -6,15 +6,16 @@ import (
 	"time"
 	"time"
 )
 )
 
 
-//消息来源类型,1:客户,2:合同,3:用印,4:指标替换,5:问答社区,6:问答评论,7:视频评论
+//消息来源类型,1:客户,2:合同,3:用印,4:指标替换,5:问答社区,6:问答评论,7:视频评论,8:线上路演评论
 const (
 const (
-	CompanyApprovalMessageSourceTypeByCompany         = 1
-	CompanyApprovalMessageSourceTypeByContract        = 2
-	CompanyApprovalMessageSourceTypeBySeal            = 3
-	CompanyApprovalMessageSourceTypeByEdbInfo         = 4
-	CompanyApprovalMessageSourceTypeByQuestion        = 5
-	CompanyApprovalMessageSourceTypeByQuestionComment = 6
-	CompanyApprovalMessageSourceTypeByVideoComment    = 7
+	CompanyApprovalMessageSourceTypeByCompany          = 1
+	CompanyApprovalMessageSourceTypeByContract         = 2
+	CompanyApprovalMessageSourceTypeBySeal             = 3
+	CompanyApprovalMessageSourceTypeByEdbInfo          = 4
+	CompanyApprovalMessageSourceTypeByQuestion         = 5
+	CompanyApprovalMessageSourceTypeByQuestionComment  = 6
+	CompanyApprovalMessageSourceTypeByVideoComment     = 7
+	CompanyApprovalMessageSourceTypeByRoadVideoComment = 8
 )
 )
 
 
 // 1:申请消息,2:审批结果,3:消息通知
 // 1:申请消息,2:审批结果,3:消息通知
@@ -42,6 +43,7 @@ type MessageInfo struct {
 	UserName             string    `json:"user_name"`
 	UserName             string    `json:"user_name"`
 	CreateTime           time.Time `json:"create_time"`
 	CreateTime           time.Time `json:"create_time"`
 	Extra                string    `json:"extra" description:"附加字段"`
 	Extra                string    `json:"extra" description:"附加字段"`
+	MessageSource        string    `json:"message_source" description:"消息来源:问答社区/视频社区/线上路演"`
 }
 }
 
 
 // AddCompanyApprovalMessage 添加系统消息
 // AddCompanyApprovalMessage 添加系统消息

+ 24 - 0
utils/common.go

@@ -977,4 +977,28 @@ func SubStr(str string, subLen int) string {
 	}
 	}
 	str = string(strRune[:bodyRuneLen])
 	str = string(strRune[:bodyRuneLen])
 	return str
 	return str
+}
+
+// JoinStr2IntArr 拼接字符串转[]int
+func JoinStr2IntArr(str, sep string) (arr []int) {
+	arr = make([]int, 0)
+	if str == "" {
+		return
+	}
+	if sep == "" {
+		sep = ","
+	}
+	strArr := strings.Split(str, sep)
+	if len(strArr) == 0 {
+		return
+	}
+	for i := range strArr {
+		v, e := strconv.Atoi(strArr[i])
+		// int2str此处过滤掉无效int
+		if e != nil {
+			continue
+		}
+		arr = append(arr, v)
+	}
+	return
 }
 }