Преглед изворни кода

Merge branch 'yb/11.2' into debug

hsun пре 2 година
родитељ
комит
120e0dccc0

+ 20 - 10
controllers/message.go

@@ -36,10 +36,19 @@ func (c *MessageCommon) SummaryMessageList() {
 	sourceTypeList := [...]int{1, 2, 3, 5, 6}
 	messageMap := make(map[int]message.SummaryMessage)
 	timeList := make([]int, 0)
+	var err error
 	for _, sourceType := range sourceTypeList {
 		//最近一条消息
 		tmpMessage := ``
-		messageInfo, err := company_approval_message.GetLastMessage(sysUserId, sourceType)
+
+		messageInfo := new(company_approval_message.CompanyApprovalMessageList)
+		// 来源类型为6-评论时, 查询6,7,8最近的一条消息
+		if sourceType == 6 {
+			messageInfo, err = company_approval_message.GetLastMessageBySourceTypes(sysUserId, []int{6, 7, 8})
+		} else {
+			messageInfo, err = company_approval_message.GetLastMessage(sysUserId, sourceType)
+		}
+
 		if err != nil {
 			if err.Error() == utils.ErrNoRow() {
 				continue
@@ -59,7 +68,7 @@ func (c *MessageCommon) SummaryMessageList() {
 
 				}
 				tmpMessage = fmt.Sprint("待分配提问:", content)
-			case 6:
+			case 6,7,8:
 				content := messageInfo.Content
 				var tmpMessageInfo services.MessageInfo
 				if messageInfo.MessageInfo != `` {
@@ -161,10 +170,10 @@ func (c *MessageCommon) MessageList() {
 		c.FailWithMessage("获取失败", "获取消息总数失败,Err:"+err.Error())
 		return
 	}
-	// 消息类型为6-评论时, 查询6-问答评论,7-视频评论
+	// 消息类型为6-评论时, 查询6-问答评论,7-视频评论,8-路演视频
 	sourceTypeStr := strconv.Itoa(sourceType)
 	if sourceType == services.CompanyApprovalMessageSourceTypeByQuestionComment {
-		sourceTypeStr = fmt.Sprintf("%d,%d", services.CompanyApprovalMessageSourceTypeByQuestionComment, services.CompanyApprovalMessageSourceTypeByVideoComment)
+		sourceTypeStr = fmt.Sprintf("%d,%d,%d", services.CompanyApprovalMessageSourceTypeByQuestionComment, services.CompanyApprovalMessageSourceTypeByVideoComment, services.CompanyApprovalMessageSourceTypeByRoadVideoComment)
 	}
 	list, err := company_approval_message.GetCompanyApprovalMessageList(sysUserId, startSize, pageSize, sourceTypeStr)
 	if err != nil {
@@ -377,12 +386,13 @@ func getMessageInfo(companyApprovalMessageList []*company_approval_message.Compa
 
 		createTime, _ := time.ParseInLocation(utils.FormatDateTime, tmpMessageInfo.CreateTime.Format(utils.FormatDateTime), time.Local)
 		approvalInfo := company_approval_message.ApprovalInfo{
-			ApplyName:   tmpMessageInfo.UserName,
-			Title:       tmpMessageInfo.Title,
-			ApplyTime:   createTime,
-			Content:     tmpMessageInfo.Content,
-			CompanyName: tmpMessageInfo.CompanyName,
-			Extra:       tmpMessageInfo.Extra,
+			ApplyName:     tmpMessageInfo.UserName,
+			Title:         tmpMessageInfo.Title,
+			ApplyTime:     createTime,
+			Content:       tmpMessageInfo.Content,
+			CompanyName:   tmpMessageInfo.CompanyName,
+			Extra:         tmpMessageInfo.Extra,
+			MessageSource: tmpMessageInfo.MessageSource,
 		}
 		v.ApprovalInfo = approvalInfo
 	}

+ 3 - 1
models/db_init.go

@@ -8,6 +8,7 @@ import (
 	"hongze/hongze_mobile_admin/models/tables/admin_record"
 	"hongze/hongze_mobile_admin/models/tables/approval_flow"
 	"hongze/hongze_mobile_admin/models/tables/approval_flow_node"
+	"hongze/hongze_mobile_admin/models/tables/chart_permission"
 	"hongze/hongze_mobile_admin/models/tables/company"
 	"hongze/hongze_mobile_admin/models/tables/company_approval"
 	"hongze/hongze_mobile_admin/models/tables/company_approval_message"
@@ -98,13 +99,14 @@ func init() {
 		new(wx_user.WxUser),
 		new(seal.Seal),                //用印表
 		new(seal.SealOperationRecord), // 用印操作记录表
-		new(seal.Attachment),         //用印附件
+		new(seal.Attachment),          //用印附件
 		new(roadshow.RsCalendar),
 		new(roadshow.RsCalendarResearcher),
 		new(roadshow.RsMatters),
 		new(roadshow.RsCalendarRelation),
 		new(company_product_update_log.CompanyProductUpdateLog), //客户产品状态变更记录表
 		new(user_template_record.UserTemplateRecord),            //模版消息记录表
+		new(chart_permission.ChartPermission),                   // 品种权限表
 	)
 
 	// 社区问答相关

+ 132 - 0
models/tables/chart_permission/chart_permission.go

@@ -0,0 +1,132 @@
+package chart_permission
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+// ChartPermission 报告权限表
+type ChartPermission struct {
+	ChartPermissionId   int       `orm:"column(chart_permission_id);pk" description:"问题ID"`
+	ChartPermissionName string    `description:"名称"`
+	PermissionName      string    `description:"权限名"`
+	Sort                int       `description:"排序"`
+	Enabled             int       `description:"是否可用"`
+	CreatedTime         time.Time `description:"创建时间"`
+	LastUpdatedTime     time.Time `description:"更新时间"`
+	TeleconferenceSort  int       `description:"电话会类型排序"`
+	Remark              string    `description:"备注"`
+	ClassifyName        string    `description:"分类名称"`
+	ProductName         string    `description:"产品名称"`
+	ProductID           int       `description:"产品ID"`
+	ImageURL            string    `description:"图片地址"`
+	ShowType            int       `description:"1:查研观向小程序展示"`
+	IsOther             int       `description:"是否是其他,用于查研观向小程序后台展示"`
+	IsReport            int       `description:"是否是报告,用于查研观向小程序前台报告展示"`
+	CygxAuth            int       `description:"是否是权限,用于查研观向小程序前台权限校验"`
+	YbImgUrl            string    `description:"研报小程序报告列表icon"`
+	PriceDrivenState    int       `description:"品种价格驱动开启状态 0-关闭 1-开启"`
+}
+
+// GetChartPermissionById 主键获取权限
+func GetChartPermissionById(permissionId int) (item *ChartPermission, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM chart_permission WHERE chart_permission_id = ? LIMIT 1`
+	err = o.Raw(sql, permissionId).QueryRow(&item)
+	return
+}
+
+// Update 更新
+func (chartPermissionInfo *ChartPermission) Update(cols []string) (err error) {
+	o := orm.NewOrm()
+	_, err = o.Update(chartPermissionInfo, cols...)
+	return
+}
+
+// YbChartPermissionFirst 研报一级品种分类
+type YbChartPermissionFirst struct {
+	Id           int
+	ClassifyName string `description:"权限一级分类名称,与chart_permission的classify_name一致"`
+	YbIndexShow  int    `description:"是否展示在研报小程序首页页面  1-展示;0-不展示"`
+	YbIndexName  string `description:"研报小程序首页简称"`
+	YbIndexSort  string `description:"研报小程序首页排序"`
+	YbIndexIcon  string `description:"研报小程序首页图标地址"`
+}
+
+// GetYbChartPermissionFirst 获取研报一级品种分类
+func GetYbChartPermissionFirst() (list []*YbChartPermissionFirst, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM chart_permission_first ORDER BY yb_index_sort ASC`
+	_, err = o.Raw(sql).QueryRows(&list)
+	return
+}
+
+// GetFiccPermissionExceptTactic 获取除了市场策略外的ficc权限
+func GetFiccPermissionExceptTactic() (items []*ChartPermission, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM chart_permission WHERE enabled = 1 AND permission_type = 0 AND product_id = 1 and classify_name != '市场策略' ORDER BY sort ASC`
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}
+
+// GetPermissionByProductIdAndClassifyName 获取子分类
+func GetPermissionByProductIdAndClassifyName(productId int, classifyName string) (items []*ChartPermission, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM chart_permission WHERE enabled = 1 AND product_id = ? AND classify_name = ? AND permission_type = 0 ORDER BY sort ASC`
+	_, err = o.Raw(sql, productId, classifyName).QueryRows(&items)
+	return
+}
+
+// GetYbChartPermissionFirstByName 根据分类名称获取一级分类
+func GetYbChartPermissionFirstByName(classifyName string) (item *YbChartPermissionFirst, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM chart_permission_first WHERE classify_name = ? LIMIT 1`
+	err = o.Raw(sql, classifyName).QueryRow(&item)
+	return
+}
+
+// GetChartPermissionById 主键获取权限
+func GetChartPermissionByRemark(remark string) (item *ChartPermission, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM chart_permission WHERE remark = ? LIMIT 1`
+	err = o.Raw(sql, remark).QueryRow(&item)
+	return
+}
+
+// GetChartPermissionByIds 主键获取权限
+func GetChartPermissionByIds(permissionIds []string) (list []*ChartPermission, err error) {
+	qb, _ := orm.NewQueryBuilder("mysql")
+	// 构建查询对象
+	qb.Select("*").From("chart_permission").
+		Where("chart_permission_id").In(permissionIds...)
+	// 导出 SQL 语句
+	sql := qb.String()
+
+	// 执行 SQL 语句
+	o := orm.NewOrm()
+	_, err = o.Raw(sql).QueryRows(&list)
+	return
+}
+
+// GetChartPermissionByIds 主键获取权限
+func GetChartPermissionByNames(permissionNames []string) (list []*ChartPermission, err error) {
+	qb, _ := orm.NewQueryBuilder("mysql")
+	// 构建查询对象
+	qb.Select("*").From("chart_permission").
+		Where("chart_permission_name").In(permissionNames...)
+	// 导出 SQL 语句
+	sql := qb.String()
+
+	// 执行 SQL 语句
+	o := orm.NewOrm()
+	_, err = o.Raw(sql).QueryRows(&list)
+	return
+}
+
+// GetChartPermissionList 获取品种权限列表
+func GetChartPermissionList() (list []*ChartPermission, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM chart_permission `
+	_, err = o.Raw(sql).QueryRows(&list)
+	return
+}

+ 26 - 8
models/tables/company_approval_message/company_approval_message.go

@@ -2,6 +2,7 @@ package company_approval_message
 
 import (
 	"github.com/beego/beego/v2/client/orm"
+	"hongze/hongze_mobile_admin/utils"
 	"time"
 )
 
@@ -60,14 +61,15 @@ type CompanyApprovalMessageList struct {
 
 //消息审批单信息
 type ApprovalInfo struct {
-	ApplyName    string    `description:"申请人姓名"`
-	Type         string    `description:"类型"`
-	Title        string    `description:"主题内容"`
-	Content      string    `description:"主体内容"`
-	CompanyName  string    `description:"客户信息"`
-	ApplyTime    time.Time `description:"提交时间"`
-	ApprovalTime time.Time `description:"审批时间"`
-	Extra        string    `description:"附加字段: 比如视频评论的标签"`
+	ApplyName     string    `description:"申请人姓名"`
+	Type          string    `description:"类型"`
+	Title         string    `description:"主题内容"`
+	Content       string    `description:"主体内容"`
+	CompanyName   string    `description:"客户信息"`
+	ApplyTime     time.Time `description:"提交时间"`
+	ApprovalTime  time.Time `description:"审批时间"`
+	Extra         string    `description:"附加字段: 比如视频评论的标签"`
+	MessageSource string    `description:"消息来源:问答社区/视频社区/线上路演"`
 }
 
 type CompanyApprovalMessageListResp struct {
@@ -117,6 +119,22 @@ func GetLastMessage(sysUserId, sourceType int) (item *CompanyApprovalMessageList
 	return
 }
 
+//获取最近一条消息
+func GetLastMessageBySourceTypes(sysUserId int, sourceType []int) (item *CompanyApprovalMessageList, err error) {
+	sql := `SELECT
+				a.*, b.real_name
+			FROM
+				company_approval_message AS a
+			INNER JOIN admin AS b ON a.create_user_id = b.admin_id
+			WHERE
+				receive_user_id = ? AND message_status != 2 AND source_type IN (` + utils.GetOrmInReplace(len(sourceType)) + `)
+			ORDER BY
+				create_time DESC`
+	o := orm.NewOrm()
+	err = o.Raw(sql, sysUserId, sourceType).QueryRow(&item)
+	return
+}
+
 //获取未读消息数
 func GetNotReadMessageTotal(sysUserId, sourceType int) (total int64, err error) {
 	sql := `SELECT count(*) total FROM company_approval_message AS a

+ 27 - 1
models/tables/yb_community_question_comment/yb_community_question_comment.go

@@ -60,9 +60,10 @@ type YbCommunityQuestionCommentAndQuestion struct {
 	HotTime                    time.Time `orm:"column(hot_time)" description:"设置精选的时间"`
 	ModifyTime                 time.Time `orm:"column(modify_time)" description:"修改时间"`
 	CreateTime                 time.Time `orm:"column(create_time)" description:"创建时间"`
-	Source                     int       `orm:"column(source)" description:"来源:1-问答社区; 2-视频社区"`
+	Source                     int       `orm:"column(source)" description:"来源:1-问答社区; 2-视频社区; 3-视频社区"`
 	QuestionContent            string    `description:"问题内容"`
 	TagName                    string    `description:"标签名称"`
+	ChartPermissionIds         string    `description:"品种标签IDs"`
 }
 
 // GetCommunityQuestionCommentList 获取问答列表
@@ -118,3 +119,28 @@ func GetCommunityVideoCommentList(condition string, pars []interface{}, startSiz
 	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&list)
 	return
 }
+
+// GetRoadVideoCommentList 获取路演视频评论列表
+func GetRoadVideoCommentList(condition string, pars []interface{}, startSize, pageSize int) (total int, list []*YbCommunityQuestionCommentAndQuestion, err error) {
+	o := orm.NewOrm()
+
+	//汇总数据
+	totalSQl := `SELECT COUNT(1) total FROM yb_community_question_comment a JOIN yb_road_video b ON a.community_question_id = b.road_video_id WHERE a.enabled = 1 AND b.is_deleted = 0 AND source = 3 `
+	totalSQl += condition
+	if err = o.Raw(totalSQl, pars).QueryRow(&total); err != nil {
+		return
+	}
+
+	// 列表数据
+	sql := `SELECT
+				a.*, b.title AS question_content, b.chart_permission_ids
+			FROM
+				yb_community_question_comment a
+			JOIN yb_road_video b ON a.community_question_id = b.road_video_id
+			WHERE
+				a.enabled = 1 AND b.is_deleted = 0 AND source = 3 `
+	sql += condition
+	sql += ` ORDER BY a.create_time DESC LIMIT ?,?`
+	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&list)
+	return
+}

+ 10 - 8
services/company_approval_message.go

@@ -8,15 +8,16 @@ import (
 	"time"
 )
 
-//消息来源类型,1:客户,2:合同,3:用印,4:指标替换,5:问答社区,6:问答评论,7:视频评论
+//消息来源类型,1:客户,2:合同,3:用印,4:指标替换,5:问答社区,6:问答评论,7:视频评论,8:线上路演评论
 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:消息通知
@@ -44,6 +45,7 @@ type MessageInfo struct {
 	UserName             string    `json:"user_name"`
 	CreateTime           time.Time `json:"create_time"`
 	Extra                string    `json:"extra" description:"附加字段"`
+	MessageSource        string    `json:"message_source" description:"消息来源:问答社区/视频社区/线上路演"`
 }
 
 // AddCompanyApprovalMessage 添加待办消息

+ 45 - 2
services/yb/community_question_comment.go

@@ -4,6 +4,7 @@ import (
 	"errors"
 	"fmt"
 	ybResponse "hongze/hongze_mobile_admin/models/response/yb"
+	"hongze/hongze_mobile_admin/models/tables/chart_permission"
 	"hongze/hongze_mobile_admin/models/tables/company_approval_message"
 	"hongze/hongze_mobile_admin/models/tables/wx_user"
 	"hongze/hongze_mobile_admin/models/tables/yb_community_question_comment"
@@ -18,8 +19,11 @@ import (
 func GetCommunityQuestionCommentList(condition string, pars []interface{}, startSize, pageSize, source int) (total int, commentList []*ybResponse.CommunityQuestionCommentItem, err error) {
 	commentList = make([]*ybResponse.CommunityQuestionCommentItem, 0)
 	list := make([]*yb_community_question_comment.YbCommunityQuestionCommentAndQuestion, 0)
+
 	// 来源
-	if source == 1 {
+	switch source {
+	case 1:
+		// 问答社区
 		qaTotal, qaList, e := yb_community_question_comment.GetCommunityQuestionCommentList(condition, pars, startSize, pageSize)
 		if e != nil {
 			err = errors.New("获取问题列表失败 Err:" + e.Error())
@@ -27,7 +31,7 @@ func GetCommunityQuestionCommentList(condition string, pars []interface{}, start
 		}
 		list = qaList
 		total = qaTotal
-	} else {
+	case 2:
 		// 视频社区
 		vcTotal, vcList, e := yb_community_question_comment.GetCommunityVideoCommentList(condition, pars, startSize, pageSize)
 		if e != nil {
@@ -36,6 +40,45 @@ func GetCommunityQuestionCommentList(condition string, pars []interface{}, start
 		}
 		list = vcList
 		total = vcTotal
+	case 3:
+		// 路演视频
+		rvTotal, rvList, e := yb_community_question_comment.GetRoadVideoCommentList(condition, pars, startSize, pageSize)
+		if e != nil {
+			err = errors.New("获取路演视频评论列表失败 Err:" + e.Error())
+			return
+		}
+		// 品种名称
+		if len(rvList) > 0 {
+			cpList, e := chart_permission.GetChartPermissionList()
+			if e != nil {
+				err = errors.New("获取路演视频品种失败 Err:" + e.Error())
+				return
+			}
+			cpMap := make(map[int]string, 0)
+			for i := range cpList {
+				cpMap[cpList[i].ChartPermissionId] = cpList[i].PermissionName
+			}
+
+			for i := range rvList {
+				if rvList[i].ChartPermissionIds == "" {
+					continue
+				}
+				ids := utils.JoinStr2IntArr(strings.ReplaceAll(rvList[i].ChartPermissionIds, `'`, ``), ",")
+				if len(ids) == 0 {
+					continue
+				}
+				cpArr := make([]string, 0)
+				for s := range ids {
+					if cpMap[ids[s]] != "" {
+						cpArr = append(cpArr, cpMap[ids[s]])
+					}
+				}
+				rvList[i].TagName = strings.Join(cpArr, ",")
+			}
+		}
+
+		list = rvList
+		total = rvTotal
 	}
 
 	if len(list) == 0 {

+ 33 - 0
utils/common.go

@@ -780,4 +780,37 @@ func InArrayByInt(idIntList []int, searchId int) (has bool) {
 		}
 	}
 	return
+}
+
+// GetOrmInReplace 获取orm的in查询替换?的方法
+func GetOrmInReplace(num int) string {
+	template := make([]string, num)
+	for i := 0; i < num; i++ {
+		template[i] = "?"
+	}
+	return strings.Join(template, ",")
+}
+
+// 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
 }