浏览代码

用户阅读记录

kobe6258 6 月之前
父节点
当前提交
156c29858d

+ 160 - 0
controllers/merchant.go

@@ -1,5 +1,165 @@
 package controllers
 
+import (
+	"encoding/json"
+	"errors"
+	"eta/eta_mini_crm_ht/models"
+	"eta/eta_mini_crm_ht/models/request"
+	"github.com/shopspring/decimal"
+)
+
 type MerchantController struct {
 	BaseAuthController
 }
+
+// AddProduct
+// @Title 新增产品
+// @Description 获取报告作者
+// @Success 200 {object} models.ReportAuthorResp
+// @router /addProduct [post]
+func (this *MerchantController) AddProduct() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+
+	var req request.ProductReq
+	if err := json.Unmarshal(this.Ctx.Input.RequestBody, &req); err != nil {
+		br.Msg = "参数解析失败"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	if !checkProductRiskLevel(req.RiskLevel) {
+		br.Msg = "产品风险等级不合法"
+		br.ErrMsg = "产品风险等级不合法:" + req.RiskLevel
+		return
+	}
+	if !checkProductType(req.Type) {
+		br.Msg = "产品类型不合法"
+		br.ErrMsg = "产品类型不合法:" + req.Type
+		return
+	}
+	if req.ProductName == "" {
+		br.Msg = "产品名称不能为空"
+		br.ErrMsg = "产品名称不能为空"
+		return
+	}
+	price, err := decimal.NewFromString(req.Price)
+	if err != nil {
+		br.Msg = "产品价格格式不正确"
+		br.ErrMsg = "产品价格格式不正确,err:" + err.Error()
+		return
+	}
+	productType, err := transProductType(req.Type)
+	if err != nil {
+		br.Msg = "产品类型不正确"
+		br.ErrMsg = "产品类型不正确,err:" + err.Error()
+		return
+	}
+	product := models.MerchantProduct{
+		Deleted:     false,
+		SourceId:    req.SourceId,
+		Title:       req.ProductName,
+		Price:       price,
+		RiskLevel:   req.RiskLevel,
+		Type:        productType,
+		IsPermanent: true,
+		SaleStatus:  models.OnSale,
+	}
+	err = product.Insert()
+	if err != nil {
+		br.Msg = "新增产品失败"
+		br.ErrMsg = "新增产品失败,err:" + err.Error()
+		return
+	}
+	br.Msg = "新增产品成功"
+	br.Ret = 200
+	br.Success = true
+}
+
+// AddPackage
+// @Title 新增产品
+// @Description 获取报告作者
+// @Success 200 {object} models.ReportAuthorResp
+// @router /addPackage [post]
+func (this *MerchantController) AddPackage() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+
+	var req request.PackageReq
+	if err := json.Unmarshal(this.Ctx.Input.RequestBody, &req); err != nil {
+		br.Msg = "参数解析失败"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	if !checkProductRiskLevel(req.RiskLevel) {
+		br.Msg = "产品风险等级不合法"
+		br.ErrMsg = "产品风险等级不合法:" + req.RiskLevel
+		return
+	}
+	if req.ProductName == "" {
+		br.Msg = "产品名称不能为空"
+		br.ErrMsg = "产品名称不能为空"
+		return
+	}
+	price, err := decimal.NewFromString(req.Price)
+	if err != nil {
+		br.Msg = "产品价格格式不正确"
+		br.ErrMsg = "产品价格格式不正确,err:" + err.Error()
+		return
+	}
+	//开始事务
+	product := models.MerchantProduct{
+		Deleted:     false,
+		Title:       req.ProductName,
+		Price:       price,
+		RiskLevel:   req.RiskLevel,
+		Type:        models.ProductPackage,
+		IsPermanent: false,
+		ValidDays:   req.ValidDays,
+		SaleStatus:  models.OnSale,
+	}
+	err = product.Insert()
+	if err != nil {
+		br.Msg = "新增产品失败"
+		br.ErrMsg = "新增产品失败,err:" + err.Error()
+		return
+	}
+	br.Msg = "新增产品成功"
+	br.Ret = 200
+	br.Success = true
+}
+func checkProductType(productType string) bool {
+	if productType == "" {
+		return false
+	}
+	if productType != Report && productType != Video && productType != Audio {
+		return false
+	}
+	return true
+}
+
+func transProductType(tansType string) (productType models.MerchantProductType, err error) {
+	if tansType == "" {
+		err = errors.New("产品类型为空")
+		return
+	}
+	switch tansType {
+	case Report:
+		productType = models.ProductReport
+		return
+	case Video:
+		productType = models.ProductVideo
+		return
+	case Audio:
+		productType = models.ProductAudio
+		return
+	default:
+		err = errors.New("产品类型不合法")
+		return
+	}
+}

+ 0 - 99
controllers/sys_message_report.go

@@ -1,99 +0,0 @@
-package controllers
-
-import (
-	"eta/eta_mini_crm_ht/models"
-	"eta/eta_mini_crm_ht/models/response"
-	"eta/eta_mini_crm_ht/utils"
-	"github.com/rdlucklib/rdluck_tools/paging"
-)
-
-type SysMessageReportController struct {
-	BaseAuthController
-}
-
-// @Title 阅读消息
-// @Description 阅读消息
-// @Param	request	body system.SysRoleDeleteReq true "type json string"
-// @Success 200 查看成功
-// @router /read [post]
-func (this *SysMessageReportController) Read() {
-	br := new(models.BaseResponse).Init()
-	defer func() {
-		this.Data["json"] = br
-		this.ServeJSON()
-	}()
-
-	err := models.UpdateReadSysMessageReportByUserId(this.SysUser.SysUserId)
-	if err != nil {
-		br.Msg = "更新消息状态失败"
-		br.ErrMsg = "更新消息状态失败,系统错误,Err:" + err.Error()
-		return
-	}
-
-	br.Msg = "查看成功"
-	br.Success = true
-	br.Ret = 200
-}
-
-// List
-// @Title 系统消息列表
-// @Description 系统消息列表
-// @Param   PageSize   query   int  true       "每页数据条数"
-// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
-// @Success 200 {object} response.SysRoleListResp
-// @router /list [get]
-func (this *SysMessageReportController) List() {
-	br := new(models.BaseResponse).Init()
-	defer func() {
-		this.Data["json"] = br
-		this.ServeJSON()
-	}()
-
-	pageSize, _ := this.GetInt("PageSize")
-	currentIndex, _ := this.GetInt("CurrentIndex")
-
-	var startSize int
-	if pageSize <= 0 {
-		pageSize = utils.PageSize20
-	}
-	if currentIndex <= 0 {
-		currentIndex = 1
-	}
-	startSize = utils.StartIndex(currentIndex, pageSize)
-
-	total, err := models.GetSysMessageReportCountBySysUserId(this.SysUser.SysUserId)
-	if err != nil {
-		br.Msg = "获取失败"
-		br.ErrMsg = "获取失败,Err:" + err.Error()
-		return
-	}
-	list, err := models.GetSysMessageReportBySysUserId(this.SysUser.SysUserId, startSize, pageSize)
-	if err != nil {
-		br.Msg = "获取失败"
-		br.ErrMsg = "获取失败,Err:" + err.Error()
-		return
-	}
-	messageList := make([]*models.SysMessageReportView, 0)
-	for _, v := range list {
-		messageList = append(messageList, &models.SysMessageReportView{
-			SysMessageReportId: v.SysMessageReportId,
-			UserId:             v.UserId,
-			ReceiveSysUserId:   v.ReceiveSysUserId,
-			MessageType:        v.MessageType,
-			Content:            v.Content,
-			Remark:             v.Remark,
-			IsRead:             v.IsRead,
-			CreateTime:         v.CreateTime.Format(utils.FormatDateTime),
-			ModifyTime:         v.ModifyTime.Format(utils.FormatDateTime),
-		})
-
-	}
-	page := paging.GetPaging(currentIndex, pageSize, total)
-	resp := new(response.SysMessageListResp)
-	resp.List = messageList
-	resp.Paging = page
-	br.Ret = 200
-	br.Success = true
-	br.Msg = "获取成功"
-	br.Data = resp
-}

文件差异内容过多而无法显示
+ 4 - 1252
controllers/user.go


+ 0 - 451
controllers/user_read_record.go

@@ -1,451 +0,0 @@
-package controllers
-
-import (
-	"eta/eta_mini_crm_ht/models"
-	"eta/eta_mini_crm_ht/models/response"
-	"eta/eta_mini_crm_ht/utils"
-	"fmt"
-	"strconv"
-	"strings"
-	"time"
-
-	"github.com/rdlucklib/rdluck_tools/paging"
-)
-
-type UserReadRecordController struct {
-	BaseAuthController
-}
-
-// List
-// @Title 用户阅读统计列表
-// @Description 用户阅读统计列表
-// @Param   PageSize   query   int  true       "每页数据条数"
-// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
-// @Param   SellerId   query   int  true       "销售id"
-// @Param   Status   query   string  true       "用户状态"
-// @Param   KeyWord   query   string  true       "手机号/邮箱/姓名"
-// @Param   IsRegistered   query   string  true       "是否注册"
-// @Param   IsSubscribed   query   string  true       "是否关注"
-// @Param   RegisterStartDate   query   string  true       "注册开始时间"
-// @Param   RegisterEndDate   query   string  true       "注册结束时间"
-// @Param   CreateStartDate   query   string  true       "创建开始时间"
-// @Param   CreateEndDate   query   string  true       "创建结束时间"
-// @Param   SortParam   query   string  true       "排序字段"
-// @Param   SortType   query   string  true       "排序方式"
-// @Success 200 {object} response.UserListResp
-// @router /list [get]
-func (this *UserReadRecordController) List() {
-	br := new(models.BaseResponse).Init()
-	defer func() {
-		this.Data["json"] = br
-		this.ServeJSON()
-	}()
-
-	pageSize, _ := this.GetInt("PageSize")
-	currentIndex, _ := this.GetInt("CurrentIndex")
-	sellerIdStr := this.GetString("SellerId")
-	status := this.GetString("Status")
-	keyWord := this.GetString("KeyWord")
-	IsRegistered := this.GetString("IsRegisterd")
-	IsSubscribed := this.GetString("IsSubscribed")
-	registerStartDate := this.GetString("RegisterStartDate")
-	registerEndDate := this.GetString("RegisterEndDate")
-	createStartDate := this.GetString("CreateStartDate")
-	createEndDate := this.GetString("CreateEndDate")
-	sortParam := this.GetString("SortParam")
-	sortType := this.GetString("SortType")
-
-	var condition string
-	var sortCondition string
-	var pars []interface{}
-
-	if keyWord != "" {
-		condition += ` AND (u.real_name LIKE ? OR u.phone LIKE ? OR u.email LIKE ? OR u.company LIKE ?) `
-		pars = utils.GetLikeKeywordPars(pars, keyWord, 4)
-	}
-
-	if pageSize <= 0 {
-		pageSize = utils.PageSize20
-	} else if pageSize > utils.PageSize100 {
-		pageSize = utils.PageSize100
-	}
-	if currentIndex <= 0 {
-		currentIndex = 1
-	}
-
-	if sellerIdStr != "" {
-		sellerIds := strings.Split(sellerIdStr, ",")
-		if len(sellerIds) != 0 {
-			condition += ` AND ( `
-			for i, id := range sellerIds {
-				if i == 0 {
-					condition += ` u.seller_id = ? `
-					pars = append(pars, id)
-				} else {
-					condition += ` OR u.seller_id = ? `
-					pars = append(pars, id)
-				}
-			}
-			condition += `) `
-		}
-	}
-	if sortParam != "" && sortType != "" {
-		sortCondition = " ORDER BY "
-		var param, sort string
-		switch sortParam {
-		case "LastUpdateTime":
-			param = "last_update_time"
-		case "ReadCnt":
-			param = "read_cnt"
-		}
-		switch sortType {
-		case "asc":
-			sort = " ASC "
-		case "desc":
-			sort = " DESC "
-		}
-		if param != "" && sort != "" {
-			sortCondition += param + " " + sort
-		} else {
-			sortCondition = ""
-		}
-	}
-
-	switch status {
-	case fmt.Sprint(utils.UserStatusNo):
-		condition += " AND u.status=? "
-		pars = append(pars, 0)
-	case fmt.Sprint(1):
-		condition += " AND u.status=? "
-		pars = append(pars, 2)
-	default:
-		condition += " AND (u.status=? OR u.status=?) "
-		pars = append(pars, 0, 2)
-	}
-	switch IsRegistered {
-	case "是":
-		condition += " AND u.is_registered=? "
-		pars = append(pars, true)
-	case "否":
-		condition += " AND u.is_registered=? "
-		pars = append(pars, false)
-	}
-	switch IsSubscribed {
-	case "是":
-		condition += " AND u.is_subscribed=? "
-		pars = append(pars, true)
-	case "否":
-		condition += " AND u.is_subscribed=? "
-		pars = append(pars, false)
-	}
-	if registerStartDate != "" {
-		registerStartTime, er := time.Parse(utils.FormatDate, registerStartDate)
-		if er != nil {
-			br.Msg = "日期格式有误"
-			return
-		}
-		condition += " AND u.register_time>=? "
-		registerStartDateStr := registerStartTime.Format(utils.FormatDateTime)
-		pars = append(pars, registerStartDateStr)
-	}
-	if registerEndDate != "" {
-		registerEndTime, er := time.Parse(utils.FormatDate, registerEndDate)
-		if er != nil {
-			br.Msg = "日期格式有误"
-			return
-		}
-		condition += " AND u.register_time<=? "
-		// 结束时间包含今天
-		registerEndTime = registerEndTime.Add(23*time.Hour + 59*time.Minute + 59*time.Second)
-		registerEndDateStr := registerEndTime.Format(utils.FormatDateTime)
-		pars = append(pars, registerEndDateStr)
-	}
-	if createStartDate != "" {
-		createStartTime, er := time.Parse(utils.FormatDate, createStartDate)
-		if er != nil {
-			br.Msg = "日期格式有误"
-			return
-		}
-		condition += " AND u.create_time>=? "
-		createStartDateStr := createStartTime.Format(utils.FormatDateTime)
-		pars = append(pars, createStartDateStr)
-	}
-	if createEndDate != "" {
-		createEndTime, er := time.Parse(utils.FormatDate, createEndDate)
-		if er != nil {
-			br.Msg = "日期格式有误"
-			return
-		}
-		condition += " AND u.create_time<=? "
-		// 结束时间包含今天
-		createEndTime = createEndTime.Add(23*time.Hour + 59*time.Minute + 59*time.Second)
-		createEndDateStr := createEndTime.Format(utils.FormatDateTime)
-		pars = append(pars, createEndDateStr)
-	}
-	if pageSize <= 0 {
-		pageSize = utils.PageSize20
-	} else if pageSize > utils.PageSize100 {
-		pageSize = utils.PageSize100
-	}
-	if currentIndex <= 0 {
-		currentIndex = 1
-	}
-	startSize := utils.StartIndex(currentIndex, pageSize)
-
-	total, err := models.GetUserReadCount(condition, pars)
-	if err != nil {
-		br.Msg = "获取失败"
-		br.ErrMsg = "获取失败,Err:" + err.Error()
-		return
-	}
-	userList, err := models.GetUserReadList(condition, sortCondition, pars, startSize, pageSize)
-	if err != nil {
-		br.Msg = "查询用户失败"
-		br.Msg = "查询用户失败,系统错误,Err:" + err.Error()
-		return
-	}
-	page := paging.GetPaging(currentIndex, pageSize, total)
-	resp := new(response.UserListResp)
-	resp.Paging = page
-	resp.List = userList
-
-	br.Data = resp
-	br.Ret = 200
-	br.Success = true
-	br.Msg = "获取成功"
-}
-
-// Detail
-// @Title 用户阅读记录详情
-// @Description 用户阅读记录详情信息
-// @Param   PageSize   query   int  true       "每页数据条数"
-// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
-// @Param   ChartPermissionIds   query   string  true       "品种列表"
-// @Param   ClassifyIds   query   string  true       "品种列表"
-// @Success 200 {object} models.LoginResp
-// @router /detail [get]
-func (this *UserReadRecordController) Detail() {
-	br := new(models.BaseResponse).Init()
-	defer func() {
-		this.Data["json"] = br
-		this.ServeJSON()
-	}()
-	UserId, _ := this.GetInt("UserId")
-	pageSize, _ := this.GetInt("PageSize")
-	currentIndex, _ := this.GetInt("CurrentIndex")
-	chartPermissionids := this.GetString("ChartPermissionIds")
-	classifyIds := this.GetString("ClassifyIds")
-	if UserId <= 0 {
-		br.Msg = "查询用户不存在"
-		return
-	}
-	if pageSize <= 0 {
-		pageSize = utils.PageSize20
-	} else if pageSize > utils.PageSize100 {
-		pageSize = utils.PageSize100
-	}
-	if currentIndex <= 0 {
-		currentIndex = 1
-	}
-	startSize := utils.StartIndex(currentIndex, pageSize)
-	user, err := models.GetUserById(UserId)
-	if err != nil {
-		if err.Error() == utils.ErrNoRow() {
-			br.Msg = "用户不存在或已删除,请刷新页面"
-			return
-		}
-		br.Msg = "查询用户失败"
-		br.ErrMsg = "查询用户失败,系统错误,Err:" + err.Error()
-		return
-	}
-	if user == nil {
-		br.Msg = "用户不存在或已删除,请刷新页面"
-		return
-	}
-	var condition string
-	var pars []interface{}
-
-	if chartPermissionids != "" {
-		ids := strings.Split(chartPermissionids, ",")
-		if len(ids) != 0 {
-			condition += ` AND ( `
-			for i, id := range ids {
-				if i == 0 {
-					condition += ` urp2.chart_permission_id = ? `
-					pars = append(pars, id)
-				} else {
-					condition += ` OR urp2.chart_permission_id = ? `
-					pars = append(pars, id)
-				}
-			}
-			condition += `) `
-		}
-	}
-
-	var firstClassifyIds, secondClassifyIds, thirdClassifyIds []int
-	if classifyIds != "" {
-		ids := strings.Split(classifyIds, ",")
-		classifyList, err := models.GetClassifyListByIds(ids)
-		if err != nil {
-			br.Msg = "查询失败"
-			br.Msg = "分类查询失败,系统错误,Err:" + err.Error()
-			return
-		}
-		for _, v := range classifyList {
-			switch v.Level {
-			case 1:
-				firstClassifyIds = append(firstClassifyIds, v.Id)
-			case 2:
-				secondClassifyIds = append(secondClassifyIds, v.Id)
-			case 3:
-				thirdClassifyIds = append(thirdClassifyIds, v.Id)
-			}
-		}
-	}
-
-	total, err := models.GetUserReadRecordCountByUserId(firstClassifyIds, secondClassifyIds, thirdClassifyIds, UserId, condition, pars)
-	if err != nil {
-		br.Msg = "查询阅读记录失败"
-		br.ErrMsg = "查询阅读记录失败,Err:" + err.Error()
-		return
-	}
-	readList, err := models.GetUserReadRecordByUserId(firstClassifyIds, secondClassifyIds, thirdClassifyIds, UserId, condition, pars, startSize, pageSize)
-	if err != nil {
-		br.Msg = "查询阅读记录失败"
-		br.ErrMsg = "查询阅读记录失败,系统错误,Err:" + err.Error()
-		return
-	}
-	page := paging.GetPaging(currentIndex, pageSize, total)
-	resp := new(response.UserReadRecordListResp)
-	resp.Paging = page
-	resp.List = readList
-
-	br.Msg = "获取成功"
-	br.Data = resp
-	br.Success = true
-	br.Ret = 200
-}
-
-// ReadCntChart
-// @Title 用户阅读量统计图信息
-// @Description 用户阅读量统计图信息
-// @Param   ChartPermissionIds   query   string  true       "品种列表"
-// @Param   ClassifyIds   query   string  true       "品种列表"
-// @Param   StartDate   query   string  true       "开始时间"
-// @Param   EndDate   query   string  true       "结束时间"
-// @Param   UserId   query   int  true       "用户id"
-// @Success 200 {object} models.LoginResp
-// @router /readCntChart [get]
-func (this *UserReadRecordController) ReadCntChart() {
-	br := new(models.BaseResponse).Init()
-	defer func() {
-		this.Data["json"] = br
-		this.ServeJSON()
-	}()
-	userId, _ := this.GetInt("UserId")
-	startDate := this.GetString("StartDate")
-	endDate := this.GetString("EndDate")
-	chartPermissionIds := this.GetString("ChartPermissionIds")
-	classifyIds := this.GetString("ClassifyIds")
-	var condition string
-	var pars []interface{}
-
-	if chartPermissionIds != "" {
-		ids := strings.Split(chartPermissionIds, ",")
-		if len(ids) != 0 {
-			condition += ` AND ( `
-			for i, id := range ids {
-				if i == 0 {
-					condition += ` urp.chart_permission_id = ? `
-					pars = append(pars, id)
-				} else {
-					condition += ` OR urp.chart_permission_id = ? `
-					pars = append(pars, id)
-				}
-			}
-			condition += `) `
-		}
-	}
-	if classifyIds != "" {
-		ids := strings.Split(classifyIds, ",")
-		if len(ids) != 0 {
-			condition += ` AND ( `
-			for i, id := range ids {
-				if i == 0 {
-					condition += ` classify_id2 = ? `
-					pars = append(pars, id)
-				} else {
-					condition += ` OR classify_id2 = ? `
-					pars = append(pars, id)
-				}
-			}
-			condition += `) `
-		}
-	}
-
-	if startDate == "" {
-		startDate = time.Now().AddDate(-1, 0, 0).Format(utils.FormatDate)
-	}
-	if endDate == "" {
-		endDate = time.Now().AddDate(0, 0, 1).Format(utils.FormatDate)
-	}
-	if userId > 0 {
-		condition += ` AND ur.user_id = ? `
-		pars = append(pars, userId)
-	}
-	readCnts, err := models.GetStaticReadCnt(condition, pars, startDate, endDate)
-	if err != nil {
-		br.Msg = "获取阅读统计失败"
-		br.ErrMsg = "获取阅读统计失败,系统错误,Err:" + err.Error()
-		return
-	}
-
-	br.Msg = "查询成功"
-	br.Data = readCnts
-	br.Ret = 200
-	br.Success = true
-}
-
-// readPermissionChart
-// @Title 用户阅读品种图信息
-// @Description 用户阅读品种图信息
-// @Param   UserId   query   string  true       "用户id"
-// @Success 200 {object} models.LoginResp
-// @router /readPermissionChart [get]
-func (this *UserReadRecordController) ReadPermissionChart() {
-	br := new(models.BaseResponse).Init()
-	defer func() {
-		this.Data["json"] = br
-		this.ServeJSON()
-	}()
-	userId, _ := this.GetInt("UserId")
-
-	var condition string
-	var pars []interface{}
-	if userId > 0 {
-		condition += ` AND ur.user_id = ? `
-		pars = append(pars, userId)
-	}
-
-	permissionCnts, err := models.GetStaticPermissionCnt(condition, pars)
-	if err != nil {
-		br.Msg = "获取品种阅读统计失败"
-		br.ErrMsg = "获取品种阅读统计失败,系统错误,Err:" + err.Error()
-		return
-	}
-	var sum int
-	for _, v := range permissionCnts {
-		sum += v.Count
-	}
-	for _, v := range permissionCnts {
-		percent := float64(v.Count) / float64(sum) * 100
-		percentStr := fmt.Sprintf("%.0f", percent)
-		parsedFloat, _ := strconv.ParseFloat(percentStr, 64)
-		v.Percent = parsedFloat
-	}
-
-	br.Msg = "查询成功"
-	br.Data = permissionCnts
-	br.Ret = 200
-	br.Success = true
-}

+ 1 - 0
go.mod

@@ -14,6 +14,7 @@ require (
 	github.com/minio/minio-go/v7 v7.0.74
 	github.com/olivere/elastic/v7 v7.0.32
 	github.com/rdlucklib/rdluck_tools v1.0.3
+	github.com/shopspring/decimal v1.3.1
 	github.com/silenceper/wechat/v2 v2.1.6
 	github.com/tcolgate/mp3 v0.0.0-20170426193717-e79c5a46d300
 	google.golang.org/grpc v1.65.0

+ 17 - 10
models/chart_permission.go

@@ -1,7 +1,6 @@
 package models
 
 import (
-	"eta/eta_mini_crm_ht/utils"
 	"fmt"
 	"strings"
 	"time"
@@ -9,6 +8,13 @@ import (
 	"github.com/beego/beego/v2/client/orm"
 )
 
+type PermissionClassifyMapping struct {
+	Id           int       `orm:"column(id);pk" description:"ID" json:"id"`
+	PermissionId int       ` description:"品种ID" json:"permissionId"`
+	ClassifyId   int       `description:"分类ID" json:"classifyName"`
+	CreatedTime  time.Time `description:"创建时间" json:"createdTime"`
+	UpdatedTime  time.Time `description:"更新时间" json:"UpdatedTime"`
+}
 type ChartPermission struct {
 	ChartPermissionId     int       `orm:"column(chart_permission_id);pk" description:"问题ID" json:"chart_permission_id"`
 	ChartPermissionName   string    `description:"名称" json:"chart_permission_name"`
@@ -103,8 +109,8 @@ func GetChartPermissionListByIds(chartPermissionIds []int) (items []*ChartPermis
 }
 
 func GetByPermissionIdsByClassifyId(classify int) (permissionIds []int, err error) {
-	o := orm.NewOrmUsingDB("rddp")
-	sql := "select distinct chart_permission_id from chart_permission_search_key_word_mapping where classify_id =?"
+	o := orm.NewOrm()
+	sql := "select distinct permission_id from permission_classify_mapping where classify_id =?"
 	_, err = o.Raw(sql, classify).QueryRows(&permissionIds)
 	return
 }
@@ -115,13 +121,14 @@ func GetChartPermissionList() (items []*ChartPermission, err error) {
 	_, err = o.Raw(sql).QueryRows(&items)
 	return
 }
-func GetPermissionNames(ids []int) (items []string, err error) {
-	o := orm.NewOrmUsingDB("rddp")
-	condition := " AND chart_permission_id in (" + utils.GetOrmReplaceHolder(len(ids)) + ")"
-	sql := `SELECT distinct  permission_name FROM chart_permission WHERE enabled=1 AND product_id=1` + condition
-	_, err = o.Raw(sql, ids).QueryRows(&items)
-	return
-}
+
+//func GetPermissionNames(ids []int) (items []string, err error) {
+//	o := orm.NewOrmUsingDB("rddp")
+//	condition := " AND chart_permission_id in (" + utils.GetOrmReplaceHolder(len(ids)) + ")"
+//	sql := `SELECT distinct  permission_name FROM chart_permission WHERE enabled=1 AND product_id=1` + condition
+//	_, err = o.Raw(sql, ids).QueryRows(&items)
+//	return
+//}
 func GetPermissionNameById(id int) (items string, err error) {
 	o := orm.NewOrmUsingDB("rddp")
 	sql := `SELECT distinct  permission_name FROM chart_permission WHERE enabled=1 AND product_id=1 and chart_permission_id=?`

+ 1 - 2
models/db.go

@@ -38,9 +38,7 @@ func init() {
 		new(ChartPermission),
 		new(UserChartPermissionMapping),
 		new(User),
-		new(SysMessageReport),
 		new(CrmConfig),
-		new(UserChangeRecord),
 		new(ReportPdf),
 		new(TemplateUsers),
 		new(CrmFinancialAnalyst),
@@ -53,5 +51,6 @@ func init() {
 		new(RiskConfig),
 		new(Permission),
 		new(CustomerProductRiskMapping),
+		new(UserSourceClickFlow),
 	)
 }

+ 9 - 0
models/media.go

@@ -95,6 +95,7 @@ func (m *Media) ToMediaView() (message *MediaView) {
 			utils.FileLog.Error("获取品种名称失败:%v", err)
 		}
 		message.PermissionNames = strings.Join(names, ",")
+
 	}
 	return
 }
@@ -318,3 +319,11 @@ func UpdateMedia(m *Media) (updateId int64, err error) {
 	_ = tx.Commit()
 	return
 }
+
+func FilterMediaIdIdsBySourceId(mediaType MediaType, ids []int) (mediaIds []int, err error) {
+	o := orm.NewOrm()
+	condition := "id in (" + utils.GetOrmReplaceHolder(len(ids)) + ")  AND media_type = ? AND deleted=0"
+	sql := `SELECT distinct id FROM media WHERE ` + condition
+	_, err = o.Raw(sql, ids, mediaType).QueryRows(&mediaIds)
+	return
+}

+ 16 - 0
models/media_permission_mapping.go

@@ -1,6 +1,7 @@
 package models
 
 import (
+	"eta/eta_mini_crm_ht/utils"
 	"github.com/beego/beego/v2/client/orm"
 	"time"
 )
@@ -35,3 +36,18 @@ func GetMappingsByCondition(condition string, pars []interface{}) (items []int64
 	_, err = o.Raw(sql, pars).QueryRows(&items)
 	return
 }
+
+func GetPermissionIdsByMediaId(mediaType MediaType, mediaId int) (ids []int, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT distinct  permission_id FROM media_permission_mappings WHERE media_id=? and media_type=? and DELETED=0 `
+	_, err = o.Raw(sql, mediaId, mediaType).QueryRows(&ids)
+	return
+}
+
+func GetMediaIdIdsByPermissionId(permissionIds []int) (ids []int, err error) {
+	o := orm.NewOrm()
+	condition := "  permission_id in (" + utils.GetOrmReplaceHolder(len(permissionIds)) + ")"
+	sql := `SELECT distinct  media_id FROM media_permission_mappings WHERE` + condition + `and DELETED=0 `
+	_, err = o.Raw(sql, permissionIds).QueryRows(&ids)
+	return
+}

+ 12 - 0
models/merchant_package.go

@@ -0,0 +1,12 @@
+package models
+
+import "time"
+
+type MerchantPackage struct {
+	ID              int       `gorm:"column:id;primary_key;autoIncrement;comment:主键"`
+	ReportSourceIds string    `gorm:"column:report_source_ids;type:varchar(255);comment:报告来源"`
+	VideoSourceIds  string    `gorm:"column:video_source_ids;type:varchar(255);comment:视频来源"`
+	AudioSourceIds  string    `gorm:"column:audio_source_ids;type:varchar(255);comment:音频来源"`
+	CreatedTime     time.Time `gorm:"column:created_time;type:datetime;comment:创建时间"`
+	UpdatedTime     time.Time `gorm:"column:updated_time;type:datetime;comment:更新时间"`
+}

+ 56 - 0
models/merchant_product.go

@@ -0,0 +1,56 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"github.com/shopspring/decimal"
+	"time"
+)
+
+type SaleStatus string
+type MerchantProductType string
+
+const (
+	OnSale         SaleStatus          = "on_sale"  //上架
+	OffSale        SaleStatus          = "off_sale" //下架
+	ProductPackage MerchantProductType = "package"
+	ProductReport  MerchantProductType = "report"
+	ProductVideo   MerchantProductType = "video"
+	ProductAudio   MerchantProductType = "audio"
+)
+
+type MerchantProduct struct {
+	Id          int                 `gorm:"column:id;primary_key;autoIncrement;comment:主键"`
+	SourceId    int                 `gorm:"column:source_id;type:int(11);comment:单品或者套餐对应的主键"`
+	Title       string              `gorm:"column:title;type:varchar(255);comment:标题"`
+	CoverSrc    string              `gorm:"column:cover_src;type:varchar(255);comment:封面图片"`
+	Description string              `gorm:"column:description;type:varchar(255);comment:描述"`
+	Price       decimal.Decimal     `gorm:"column:price;type:decimal(10,2);comment:价格"`
+	RiskLevel   string              `gorm:"column:risk_level;type:varchar(255);not null;comment:风险等级"`
+	Type        MerchantProductType `gorm:"column:type;type:enum('report','video','audio','package');not null;comment:类型"`
+	IsPermanent bool                `gorm:"column:is_permanent;type:int(1);not null;default:0;comment:是否永久"`
+	ValidDays   int                 `gorm:"column:valid_days;type:int(11);comment:有效期天数"`
+	SaleStatus  SaleStatus          `gorm:"column:sale_status;type:enum('on_sale','off_sale');not null;default:'on_sale';comment:上架/下架状态"`
+	Deleted     bool                `gorm:"column:deleted;type:tinyint(1);not null;default:0;comment:是否删除"`
+	CreatedTime time.Time           `gorm:"column:created_time;type:datetime;comment:创建时间"`
+	UpdatedTime time.Time           `gorm:"column:updated_time;type:datetime;comment:更新时间;default:CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP"`
+}
+
+func (m *MerchantProduct) TableName() string {
+	return "merchant_products"
+}
+func (m *MerchantProduct) Insert() (err error) {
+	o := orm.NewOrm()
+	_, err = o.Insert(m)
+	return
+}
+
+func (m *MerchantProduct) InsertPackage() (err error) {
+	o := orm.NewOrm()
+	//tx := o.Begin()
+	//merchantPackage := MERCHAT
+	//tx.Insert()
+	//tx.Rollback()
+	//tx.Commit()
+	_, err = o.Insert(m)
+	return
+}

+ 27 - 0
models/permission.go

@@ -1,6 +1,8 @@
 package models
 
 import (
+	"errors"
+	"eta/eta_mini_crm_ht/utils"
 	"github.com/beego/beego/v2/client/orm"
 	"time"
 )
@@ -45,3 +47,28 @@ func (p *Permission) SetPermissionRiskLevel() (err error) {
 	_, err = o.Update(p, "RiskLevel")
 	return
 }
+
+func GetPermissionNames(ids []int) (permissionNameList []string, err error) {
+	o := orm.NewOrm()
+	if len(ids) == 0 {
+		err = errors.New("品种id列表为空")
+		return
+	}
+	condition := " permission_id in (" + utils.GetOrmReplaceHolder(len(ids)) + ")"
+	sql := `SELECT name FROM permissions  where ` + condition + ` order by permission_id asc`
+	_, err = o.Raw(sql, ids).QueryRows(&permissionNameList)
+	if err != nil {
+		return
+	}
+	return
+}
+
+func GetClassifyIdByPermissionIds(permissionIds []int) (classifyIds []int, err error) {
+	o := orm.NewOrm()
+	if len(permissionIds) == 0 {
+		return
+	}
+	sql := `SELECT distinct classify_id FROM permission_classify_mapping  where permission_id in (?) order by permission_id asc`
+	_, err = o.Raw(sql, permissionIds).QueryRows(&classifyIds)
+	return
+}

+ 24 - 2
models/report.go

@@ -1,6 +1,7 @@
 package models
 
 import (
+	"eta/eta_mini_crm_ht/utils"
 	"time"
 
 	"github.com/beego/beego/v2/client/orm"
@@ -86,11 +87,16 @@ func GetReportCountByCondition(condition string, pars []interface{}) (count int,
 
 func GetReportById(id int) (items *Report, err error) {
 	o := orm.NewOrm()
-	sql := `SELECT distinct id ,title,abstract,author,published_time,send_status FROM reports WHERE id =?`
+	sql := `SELECT distinct id ,title,abstract,author,published_time,send_status,source,classify_id,plate_name FROM reports WHERE id =?`
+	err = o.Raw(sql, id).QueryRow(&items)
+	return
+}
+func GetReportIdByPermissionIds(id int) (items *Report, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT distinct id ,title,abstract,author,published_time,send_status,source,classify_id,plate_name FROM reports WHERE id =?`
 	err = o.Raw(sql, id).QueryRow(&items)
 	return
 }
-
 func GetReportByCondition(condition, sortCondition string, pars []interface{}, startPage, pageSize int) (items []*Report, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT * FROM reports WHERE 1=1 `
@@ -127,3 +133,19 @@ func GetETAReportIdByClassifyId(id int) (classifyId int, err error) {
 	err = o.Raw(sql, id).QueryRow(&classifyId)
 	return
 }
+
+func GetReportIdByClassifyId(ids []int) (reportIds []int, err error) {
+	o := orm.NewOrm()
+	condition := "source='ETA' and classify_id  in (" + utils.GetOrmReplaceHolder(len(ids)) + ") "
+	sql := `SELECT distinct id FROM reports WHERE  ` + condition
+	_, err = o.Raw(sql, ids).QueryRows(&reportIds)
+	return
+}
+
+func GetReportIdByPlateName(names []string) (reportIds []int, err error) {
+	o := orm.NewOrm()
+	condition := "source='HT' and plate_name  in (" + utils.GetOrmReplaceHolder(len(names)) + ") "
+	sql := `SELECT distinct id FROM reports WHERE  ` + condition
+	_, err = o.Raw(sql, names).QueryRows(&reportIds)
+	return
+}

+ 21 - 0
models/request/product.go

@@ -0,0 +1,21 @@
+package request
+
+type ProductReq struct {
+	ProductName string
+	SourceId    int
+	Type        string
+	Price       string
+	RiskLevel   string
+}
+
+type PackageReq struct {
+	ProductName     string
+	CoverSrc        string
+	ValidDays       int
+	Description     string
+	Price           string
+	RiskLevel       string
+	ReportSourceIds string
+	VideoSourceIds  string
+	AudioSourceIds  string
+}

+ 0 - 5
models/response/user.go

@@ -15,11 +15,6 @@ type UserCheckResp struct {
 	Status int
 }
 
-type UserChangeRecordResp struct {
-	List []*models.UserChangeRecord
-	// Paging *paging.PagingItem `description:"分页数据"`
-}
-
 type UserDetailResp struct {
 	Detail     *models.UserView
 	Permission map[string][]string

+ 0 - 16
models/response/user_read_record.go

@@ -1,16 +0,0 @@
-package response
-
-import (
-	"eta/eta_mini_crm_ht/models"
-	"github.com/rdlucklib/rdluck_tools/paging"
-)
-
-type UserReadRecordListResp struct {
-	Paging *paging.PagingItem
-	List   []*models.UserReadRecordView
-}
-
-type StaticInfoResp struct {
-	ReadCntList       []*models.ReadCntStaitc
-	PermissionCntList []*models.PermissionCntStaitc
-}

+ 2 - 2
models/response/sys_message_report.go → models/response/user_source_click_flow_resp.go

@@ -5,7 +5,7 @@ import (
 	"github.com/rdlucklib/rdluck_tools/paging"
 )
 
-type SysMessageListResp struct {
-	List   []*models.SysMessageReportView
+type UserSourceClickFlowResp struct {
+	List   []models.UserSourceClickFlowView
 	Paging *paging.PagingItem `description:"分页数据"`
 }

+ 0 - 99
models/sys_message_report.go

@@ -1,99 +0,0 @@
-package models
-
-import (
-	"time"
-
-	"github.com/beego/beego/v2/client/orm"
-)
-
-type SysMessageReport struct {
-	SysMessageReportId int       `orm:"pk" description:"消息id"`
-	UserId             int       `description:"到期用户id"`
-	ReceiveSysUserId   int       `description:"接收系统用户id"`
-	MessageType        int       `description:"消息类型"`
-	Content            string    `description:"内容"`
-	Remark             string    `description:"备注"`
-	IsRead             bool      `description:"是否已读"`
-	CreateTime         time.Time `description:"创建时间"`
-	ModifyTime         time.Time `description:"修改时间"`
-}
-
-type SysMessageReportView struct {
-	SysMessageReportId int    `orm:"pk" description:"消息id"`
-	UserId             int    `description:"到期用户id"`
-	ReceiveSysUserId   int    `description:"接收系统用户id"`
-	MessageType        int    `description:"消息类型"`
-	Content            string `description:"内容"`
-	Remark             string `description:"备注"`
-	IsRead             bool   `description:"是否已读"`
-	CreateTime         string `description:"创建时间"`
-	ModifyTime         string `description:"修改时间"`
-}
-
-func (s *SysMessageReport) Update(cols []string) (err error) {
-	o := orm.NewOrm()
-	_, err = o.Update(s, cols...)
-	return
-}
-
-func UpdateReadSysMessageReportByUserId(userId int) (err error) {
-	o := orm.NewOrm()
-	sql := `UPDATE sys_message_report SET is_read=1 WHERE receive_sys_user_id=? AND is_read=0`
-	_, err = o.Raw(sql, userId).Exec()
-	return
-}
-
-func GetSysMessageReportCountBySysUserId(sysUserId int) (count int, err error) {
-	o := orm.NewOrm()
-	sql := `SELECT COUNT(*) AS count FROM sys_message_report WHERE receive_sys_user_id=?`
-	err = o.Raw(sql, sysUserId).QueryRow(&count)
-	return
-}
-
-func GetSysMessageReportBySysUserId(sysUserId, startSize, pageSize int) (item []*SysMessageReport, err error) {
-	o := orm.NewOrm()
-	sql := `SELECT * FROM sys_message_report WHERE receive_sys_user_id=? ORDER BY is_read ASC, create_time DESC LIMIT ?,?`
-	_, err = o.Raw(sql, sysUserId, startSize, pageSize).QueryRows(&item)
-	return
-}
-
-func InsertMultiSysMessageReport(sysMessageReportList []*SysMessageReport) (err error) {
-	o := orm.NewOrm()
-	_, err = o.InsertMulti(500, sysMessageReportList)
-	return
-}
-
-func GetSysMessageReportListById(sysMessageReportIds []int) (items []*SysMessageReport, err error) {
-	o := orm.NewOrm()
-	_, err = o.QueryTable(&SysMessageReport{}).
-		Filter("sys_message_report_id__in", sysMessageReportIds).
-		All(&items)
-	return
-}
-
-func GetSysMessageReportCount(sysUserId, userId, messageType int) (count int, err error) {
-	o := orm.NewOrm()
-	sql := `SELECT COUNT(*) AS count FROM sys_message_report WHERE user_id=? AND message_type=? `
-	err = o.Raw(sql, userId, messageType).QueryRow(&count)
-	return
-}
-
-func GetSysMessageReportByCondition(condition string, pars []interface{}) (items []*SysMessageReport, err error) {
-	o := orm.NewOrm()
-	sql := `SELECT * FROM sys_message_report WHERE 1=1`
-	if condition != "" {
-		sql += condition
-	}
-	_, err = o.Raw(sql, pars...).QueryRows(&items)
-	return
-}
-
-func GetSysMessageReportCountByCondition(condition string, pars []interface{}) (count int, err error) {
-	o := orm.NewOrm()
-	sql := `SELECT COUNT(*) AS count FROM sys_message_report `
-	if condition != "" {
-		sql += condition
-	}
-	err = o.Raw(sql, pars...).QueryRow(&count)
-	return
-}

+ 29 - 14
models/template_users.go

@@ -6,22 +6,37 @@ import (
 	"time"
 )
 
+const (
+	unOpen AccountStatus = "unOpen"
+
+	open AccountStatus = "open"
+)
+
+var (
+	accountStatusMap = map[AccountStatus]string{
+		open:   "已开户",
+		unOpen: "未开户",
+	}
+)
+
+type AccountStatus string
+
 // TemplateUsers
 // @Description: 临时用户表
 type TemplateUsers struct {
-	Id            int       `orm:"pk" description:"用户id"`
-	UserName      string    `description:"姓名"`
-	Mobile        string    `description:"手机号"`
-	OpenId        string    `description:"用户openid"`
-	UnionId       string    `description:"用户unionid"`
-	IsDeleted     int       `description:"是否已删除"`
-	GzhOpenId     string    `description:"用户公众号openid"`
-	ReadCount     int       `description:"阅读次数"`
-	FollowingGzh  bool      `description:"是否关注公众号"`
-	AccountStatus string    `description:"账号状态"`
-	LastReadTime  time.Time `description:"最近一次阅读时间"`
-	CreatedTime   time.Time `description:"创建时间"`
-	UpdatedTime   time.Time `description:"变更时间"`
+	Id            int           `orm:"pk" description:"用户id"`
+	UserName      string        `description:"姓名"`
+	Mobile        string        `description:"手机号"`
+	OpenId        string        `description:"用户openid"`
+	UnionId       string        `description:"用户unionid"`
+	IsDeleted     int           `description:"是否已删除"`
+	GzhOpenId     string        `description:"用户公众号openid"`
+	ReadCount     int           `description:"阅读次数"`
+	FollowingGzh  bool          `description:"是否关注公众号"`
+	AccountStatus AccountStatus `description:"账号状态"`
+	LastReadTime  time.Time     `description:"最近一次阅读时间"`
+	CreatedTime   time.Time     `description:"创建时间"`
+	UpdatedTime   time.Time     `description:"变更时间"`
 }
 
 // TemplateUsers
@@ -98,7 +113,7 @@ func (m *TemplateUsers) ToItem() (item TemplateUsersItem) {
 		UnionId:       m.UnionId,
 		GzhOpenId:     m.GzhOpenId,
 		ReadCount:     m.ReadCount,
-		AccountStatus: m.AccountStatus,
+		AccountStatus: accountStatusMap[m.AccountStatus],
 		LastReadTime:  "",
 		CreatedTime:   m.CreatedTime.Format(utils.FormatDateTime),
 		UpdatedTime:   m.UpdatedTime.Format(utils.FormatDateTime),

+ 1 - 1
models/user.go

@@ -131,7 +131,7 @@ func GetUserByEmail(email string) (item *User, err error) {
 
 func GetUserById(userId int) (item *User, err error) {
 	o := orm.NewOrm()
-	sql := `SELECT * FROM user WHERE user_id=? `
+	sql := `SELECT * FROM template_users WHERE id=? and is_deleted=0`
 	err = o.Raw(sql, userId).QueryRow(&item)
 	return
 }

+ 0 - 41
models/user_change_record.go

@@ -1,41 +0,0 @@
-package models
-
-import (
-	"time"
-
-	"github.com/beego/beego/v2/client/orm"
-)
-
-type UserChangeRecord struct {
-	UserChangeRecordId int       `orm:"pk" description:"id"`
-	UserId             int       `description:"用户id"`
-	SysUserId          int       `description:"系统用户id"`
-	Content            string    `description:"内容"`
-	CreateTime         time.Time `description:"创建时间"`
-}
-
-func (u *UserChangeRecord) Insert() (err error) {
-	u.CreateTime = time.Now()
-	o := orm.NewOrm()
-	_, err = o.Insert(u)
-	return
-}
-func UserChangeRecordMultiInsert(list []*UserChangeRecord) (err error) {
-	o := orm.NewOrm()
-	_, err = o.InsertMulti(500, list)
-	return
-}
-
-func GetUserChangeRecordListById(userId int) (items []*UserChangeRecord, err error) {
-	sql := `SELECT * FROM user_change_record WHERE user_id=? ORDER BY create_time DESC `
-	o := orm.NewOrm()
-	_, err = o.Raw(sql, userId).QueryRows(&items)
-	return
-}
-
-func GetUserChangeRecordCount() (count int, err error) {
-	sql := `SELECT COUNT(*) AS count FROM user_change_record `
-	o := orm.NewOrm()
-	err = o.Raw(sql).QueryRow(&count)
-	return
-}

+ 0 - 152
models/user_read_record.go

@@ -1,152 +0,0 @@
-package models
-
-import (
-	"eta/eta_mini_crm_ht/utils"
-	"fmt"
-	"time"
-
-	"github.com/beego/beego/v2/client/orm"
-)
-
-type UserReadRecord struct {
-	UserReadRecordId int    `orm:"pk" description:"id"`
-	UserId           int    `description:"用户id"`
-	ReportId         int    `description:"报告id"`
-	ReportTitle      string `description:"报告标题"`
-	// ChartPermissionId1  string    `description:"一级品种id"`
-	// ChartPermissionId2  string    `description:"二级品种id"`
-	ChartPermissionName string    `description:"二级品种名称"`
-	ClassifyId1         int       `description:"一级级分类id"`
-	ClassifyName1       string    `description:"一级分类名称"`
-	ClassifyId2         int       `description:"二级分类id"`
-	ClassifyName2       string    `description:"二级分类名称"`
-	ClassifyId3         int       `description:"三级分类id"`
-	ClassifyName3       string    `description:"三级分类名称"`
-	Timestamp           int       `description:"阅读开始时间戳"`
-	EndTimestamp        int       `description:"阅读结束时间戳"`
-	CreateTime          time.Time `description:"创建时间"`
-	CreateDate          string    `description:"创建日期"`
-	StayTime            string    `description:"停留时间"`
-	StayTimestamp       string    `description:"停留时间戳"`
-	ReportType          int       `description:"报告类型:1-普通研报;2-pdf研报"`
-}
-
-type UserReadRecordView struct {
-	UserReadRecordId int    `orm:"pk" description:"id"`
-	UserId           int    `description:"用户id"`
-	ReportId         int    `description:"报告id"`
-	ReportTitle      string `description:"报告标题"`
-	// ChartPermissionId1  string    `description:"一级品种id"`
-	// ChartPermissionId2  string    `description:"二级品种id"`
-	ChartPermissionName string `description:"二级品种名称"`
-	ClassifyId1         int    `description:"一级级分类id"`
-	ClassifyName1       string `description:"一级分类名称"`
-	ClassifyId2         int    `description:"二级分类id"`
-	ClassifyName2       string `description:"二级分类名称"`
-	ClassifyId3         int    `description:"三级分类id"`
-	ClassifyName3       string `description:"三级分类名称"`
-	Timestamp           int    `description:"阅读开始时间戳"`
-	EndTimestamp        int    `description:"阅读结束时间戳"`
-	CreateTime          string `description:"创建时间"`
-	CreateDate          string `description:"创建日期"`
-	StayTime            string `description:"停留时间"`
-	StayTimestamp       string `description:"停留时间戳"`
-	ReportType          int    `description:"报告类型:1-普通研报;2-pdf研报"`
-}
-
-type ReadCntStaitc struct {
-	CreateDate string
-	Count      int
-}
-type PermissionCntStaitc struct {
-	ChartPermissionId int
-	PermissionName    string
-	Count             int
-	Percent           float64
-}
-
-func GetUserReadRecordByUserId(firstClassifyIds, secondClassifyIds, thirdClassifyIds []int, userId int, condition string, pars []interface{}, startSize, pageSize int) (items []*UserReadRecordView, err error) {
-	o := orm.NewOrm()
-	sql := `SELECT DISTINCT ur.user_read_record_id, ur.report_id, ur.report_title, ur.chart_permission_name, ur.classify_name2, 
-		ur.create_time, ur.stay_time, ur.classify_id2, ur.classify_id3, ur.classify_name3, ur.classify_id1, ur.classify_name1
-	  	FROM user_read_record AS ur
-		LEFT JOIN user_read_permission2 AS urp2
-		ON ur.user_read_record_id = urp2.user_read_record_id
-		WHERE user_id = ? `
-	if condition != "" {
-		sql += condition
-	}
-	if len(firstClassifyIds) != 0 || len(secondClassifyIds) != 0 || len(thirdClassifyIds) != 0 {
-		sql += ` AND (1=2 `
-		if len(firstClassifyIds) > 0 {
-			sql += fmt.Sprintf(" OR ur.classify_id1 IN (%s) ", utils.GetOrmReplaceHolder(len(firstClassifyIds)))
-		}
-		if len(secondClassifyIds) > 0 {
-			sql += fmt.Sprintf(" OR ur.classify_id2 IN (%s) ", utils.GetOrmReplaceHolder(len(secondClassifyIds)))
-		}
-		if len(thirdClassifyIds) > 0 {
-			sql += fmt.Sprintf(" OR ur.classify_id3 IN (%s) ", utils.GetOrmReplaceHolder(len(thirdClassifyIds)))
-		}
-		sql += ` ) `
-	}
-	sql += ` ORDER BY create_time DESC LIMIT ?, ?`
-	_, err = o.Raw(sql, userId, pars, firstClassifyIds, secondClassifyIds, thirdClassifyIds, startSize, pageSize).QueryRows(&items)
-	return
-}
-
-func GetUserReadRecordCountByUserId(firstClassifyIds, secondClassifyIds, thirdClassifyIds []int, userId int, condition string, pars []interface{}) (count int, err error) {
-	o := orm.NewOrm()
-	sql := `SELECT COUNT(DISTINCT ur.user_read_record_id) AS count
-	  	FROM user_read_record AS ur
-		LEFT JOIN user_read_permission2 AS urp2
-		ON ur.user_read_record_id = urp2.user_read_record_id
-		WHERE user_id = ? `
-	if condition != "" {
-		sql += condition
-	}
-	if len(firstClassifyIds) != 0 || len(secondClassifyIds) != 0 || len(thirdClassifyIds) != 0 {
-		sql += ` AND (1=2 `
-		if len(firstClassifyIds) > 0 {
-			sql += fmt.Sprintf(" OR ur.classify_id1 IN (%s) ", utils.GetOrmReplaceHolder(len(firstClassifyIds)))
-		}
-		if len(secondClassifyIds) > 0 {
-			sql += fmt.Sprintf(" OR ur.classify_id2 IN (%s) ", utils.GetOrmReplaceHolder(len(secondClassifyIds)))
-		}
-		if len(thirdClassifyIds) > 0 {
-			sql += fmt.Sprintf(" OR ur.classify_id3 IN (%s) ", utils.GetOrmReplaceHolder(len(thirdClassifyIds)))
-		}
-		sql += ` ) `
-	}
-	err = o.Raw(sql, userId, pars, firstClassifyIds, secondClassifyIds, thirdClassifyIds).QueryRow(&count)
-	return
-}
-
-func GetStaticReadCnt(condition string, pars []interface{}, startDate, endDate string) (items []*ReadCntStaitc, err error) {
-	o := orm.NewOrm()
-	sql := `SELECT create_date, COUNT(*) AS count
-	FROM user_read_record AS ur
-	LEFT JOIN user_read_permission2 AS urp
-	ON ur.user_read_record_id = urp.user_read_record_id
-	WHERE 1=1  `
-	if condition != "" {
-		sql += condition
-	}
-	sql += ` AND (ur.create_date BETWEEN ? AND ?)  GROUP BY ur.create_date`
-	_, err = o.Raw(sql, pars, startDate, endDate).QueryRows(&items)
-	return
-}
-
-func GetStaticPermissionCnt(condition string, pars []interface{}) (items []*PermissionCntStaitc, err error) {
-	o := orm.NewOrm()
-	sql := `SELECT urp.chart_permission_id, urp.permission_name,COUNT(*) AS count
-	FROM user_read_permission1 AS urp
-	LEFT JOIN user_read_record AS ur
-	ON urp.user_read_record_id = ur.user_read_record_id
-	WHERE 1=1 `
-	if condition != "" {
-		sql += condition
-	}
-	sql += ` GROUP BY urp.chart_permission_id`
-	_, err = o.Raw(sql, pars).QueryRows(&items)
-	return
-}

+ 71 - 0
models/user_source_click_flow.go

@@ -0,0 +1,71 @@
+package models
+
+import (
+	"fmt"
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+var (
+	SourceTypeMap = map[SourceType]string{
+		ReportSourceType: "报告",
+		VideoSourceType:  "视频",
+		AudioSourceType:  "音频",
+	}
+)
+
+type UserSourceClickFlow struct {
+	Id                  int
+	TraceId             string
+	UseId               int
+	Mobile              string
+	SourceId            int
+	SourceType          SourceType
+	ClickTime           time.Time
+	ReadDurationSeconds int64
+	IpAddress           string
+	Hidden              int
+	Location            string
+	Referer             string
+	AdditionalData      string
+}
+
+func (m *UserSourceClickFlow) ToView() UserSourceClickFlowView {
+	return UserSourceClickFlowView{
+		ClickTime:           m.ClickTime.Format(time.DateTime),
+		SourceId:            m.SourceId,
+		SourceName:          getSourceName(m.SourceType),
+		ReadDurationMinutes: parseMinutes(m.ReadDurationSeconds),
+	}
+}
+func getSourceName(sourceType SourceType) string {
+	return SourceTypeMap[sourceType]
+}
+func parseMinutes(seconds int64) string {
+	minutesPart := seconds / 60
+	secondsPart := seconds % 60
+	return fmt.Sprintf("%d分%02d秒", minutesPart, secondsPart)
+}
+
+type UserSourceClickFlowView struct {
+	SourceId            int
+	SourceName          string
+	PermissionNames     string
+	ClickTime           string
+	ReadDurationMinutes string
+}
+
+func GetUserSourceClickFlowListByUserId(userId int, condition string, pars []interface{}, startSize, pageSize int) (items []*UserSourceClickFlow, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM user_source_click_flows WHERE user_id=?  ` + condition +
+		` ORDER BY click_time DESC LIMIT ?,?`
+	_, err = o.Raw(sql, userId, pars, startSize, pageSize).QueryRows(&items)
+	return
+}
+
+func GetUserSourceClickFlowListCountByUserId(userId int, condition string, pars []interface{}) (total int, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT count(*) FROM user_source_click_flows WHERE user_id=?  ` + condition
+	err = o.Raw(sql, userId, pars).QueryRow(&total)
+	return
+}

+ 20 - 146
routers/commentsRouter.go

@@ -297,6 +297,24 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:MerchantController"] = append(beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:MerchantController"],
+        beego.ControllerComments{
+            Method: "AddPackage",
+            Router: `/addPackage`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:MerchantController"] = append(beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:MerchantController"],
+        beego.ControllerComments{
+            Method: "AddProduct",
+            Router: `/addProduct`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:MessageController"] = append(beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:MessageController"],
         beego.ControllerComments{
             Method: "AudioList",
@@ -396,24 +414,6 @@ func init() {
             Filters: nil,
             Params: nil})
 
-    beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:SysMessageReportController"] = append(beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:SysMessageReportController"],
-        beego.ControllerComments{
-            Method: "List",
-            Router: `/list`,
-            AllowHTTPMethods: []string{"get"},
-            MethodParams: param.Make(),
-            Filters: nil,
-            Params: nil})
-
-    beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:SysMessageReportController"] = append(beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:SysMessageReportController"],
-        beego.ControllerComments{
-            Method: "Read",
-            Router: `/read`,
-            AllowHTTPMethods: []string{"post"},
-            MethodParams: param.Make(),
-            Filters: nil,
-            Params: nil})
-
     beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:SysRoleController"] = append(beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:SysRoleController"],
         beego.ControllerComments{
             Method: "Add",
@@ -569,98 +569,8 @@ func init() {
 
     beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:UserController"] = append(beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:UserController"],
         beego.ControllerComments{
-            Method: "Add",
-            Router: `/add`,
-            AllowHTTPMethods: []string{"post"},
-            MethodParams: param.Make(),
-            Filters: nil,
-            Params: nil})
-
-    beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:UserController"] = append(beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:UserController"],
-        beego.ControllerComments{
-            Method: "ChangeList",
-            Router: `/change_list`,
-            AllowHTTPMethods: []string{"get"},
-            MethodParams: param.Make(),
-            Filters: nil,
-            Params: nil})
-
-    beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:UserController"] = append(beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:UserController"],
-        beego.ControllerComments{
-            Method: "Check",
-            Router: `/check`,
-            AllowHTTPMethods: []string{"post"},
-            MethodParams: param.Make(),
-            Filters: nil,
-            Params: nil})
-
-    beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:UserController"] = append(beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:UserController"],
-        beego.ControllerComments{
-            Method: "Delete",
-            Router: `/delete`,
-            AllowHTTPMethods: []string{"post"},
-            MethodParams: param.Make(),
-            Filters: nil,
-            Params: nil})
-
-    beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:UserController"] = append(beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:UserController"],
-        beego.ControllerComments{
-            Method: "Detail",
-            Router: `/detail`,
-            AllowHTTPMethods: []string{"get"},
-            MethodParams: param.Make(),
-            Filters: nil,
-            Params: nil})
-
-    beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:UserController"] = append(beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:UserController"],
-        beego.ControllerComments{
-            Method: "Edit",
-            Router: `/edit`,
-            AllowHTTPMethods: []string{"post"},
-            MethodParams: param.Make(),
-            Filters: nil,
-            Params: nil})
-
-    beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:UserController"] = append(beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:UserController"],
-        beego.ControllerComments{
-            Method: "EditEnabled",
-            Router: `/editEnabled`,
-            AllowHTTPMethods: []string{"post"},
-            MethodParams: param.Make(),
-            Filters: nil,
-            Params: nil})
-
-    beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:UserController"] = append(beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:UserController"],
-        beego.ControllerComments{
-            Method: "GlobalSearch",
-            Router: `/global/list`,
-            AllowHTTPMethods: []string{"get"},
-            MethodParams: param.Make(),
-            Filters: nil,
-            Params: nil})
-
-    beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:UserController"] = append(beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:UserController"],
-        beego.ControllerComments{
-            Method: "List",
-            Router: `/list`,
-            AllowHTTPMethods: []string{"get"},
-            MethodParams: param.Make(),
-            Filters: nil,
-            Params: nil})
-
-    beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:UserController"] = append(beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:UserController"],
-        beego.ControllerComments{
-            Method: "PotentialEdit",
-            Router: `/potential/edit`,
-            AllowHTTPMethods: []string{"post"},
-            MethodParams: param.Make(),
-            Filters: nil,
-            Params: nil})
-
-    beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:UserController"] = append(beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:UserController"],
-        beego.ControllerComments{
-            Method: "PotentialList",
-            Router: `/potential/list`,
+            Method: "ReadRecordList",
+            Router: `/readRecordList`,
             AllowHTTPMethods: []string{"get"},
             MethodParams: param.Make(),
             Filters: nil,
@@ -693,42 +603,6 @@ func init() {
             Filters: nil,
             Params: nil})
 
-    beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:UserReadRecordController"] = append(beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:UserReadRecordController"],
-        beego.ControllerComments{
-            Method: "Detail",
-            Router: `/detail`,
-            AllowHTTPMethods: []string{"get"},
-            MethodParams: param.Make(),
-            Filters: nil,
-            Params: nil})
-
-    beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:UserReadRecordController"] = append(beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:UserReadRecordController"],
-        beego.ControllerComments{
-            Method: "List",
-            Router: `/list`,
-            AllowHTTPMethods: []string{"get"},
-            MethodParams: param.Make(),
-            Filters: nil,
-            Params: nil})
-
-    beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:UserReadRecordController"] = append(beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:UserReadRecordController"],
-        beego.ControllerComments{
-            Method: "ReadCntChart",
-            Router: `/readCntChart`,
-            AllowHTTPMethods: []string{"get"},
-            MethodParams: param.Make(),
-            Filters: nil,
-            Params: nil})
-
-    beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:UserReadRecordController"] = append(beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:UserReadRecordController"],
-        beego.ControllerComments{
-            Method: "ReadPermissionChart",
-            Router: `/readPermissionChart`,
-            AllowHTTPMethods: []string{"get"},
-            MethodParams: param.Make(),
-            Filters: nil,
-            Params: nil})
-
     beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:VideoController"] = append(beego.GlobalControllerRouter["eta/eta_mini_crm_ht/controllers:VideoController"],
         beego.ControllerComments{
             Method: "AddVideo",

+ 5 - 11
routers/router.go

@@ -41,22 +41,11 @@ func init() {
 				&controllers.UserController{},
 			),
 		),
-		beego.NSNamespace("/sys_message",
-			beego.NSInclude(
-				&controllers.SysMessageReportController{},
-			),
-		),
-
 		beego.NSNamespace("/classify",
 			beego.NSInclude(
 				&controllers.ClassifyController{},
 			),
 		),
-		beego.NSNamespace("/read",
-			beego.NSInclude(
-				&controllers.UserReadRecordController{},
-			),
-		),
 		beego.NSNamespace("/feedBack",
 			beego.NSInclude(
 				&controllers.FeedBackController{},
@@ -93,6 +82,11 @@ func init() {
 				&controllers.CustomerProductRiskMappingController{},
 			),
 		),
+		beego.NSNamespace("/merchant",
+			beego.NSInclude(
+				&controllers.MerchantController{},
+			),
+		),
 	)
 	beego.AddNamespace(ns)
 }

+ 26 - 0
services/media.go

@@ -0,0 +1,26 @@
+package services
+
+import (
+	"eta/eta_mini_crm_ht/models"
+	"eta/eta_mini_crm_ht/utils"
+)
+
+func GetMediaIdsByPermissionIds(permissionIds []int, mediaType models.MediaType) (mediaIds []int, err error) {
+	mediaIds, err = models.GetMediaIdIdsByPermissionId(permissionIds)
+	if err != nil {
+		utils.FileLog.Error("查询媒体品种信息失败", err.Error())
+		return
+	}
+	if len(mediaIds) == 0 {
+		utils.FileLog.Error("查询媒体品种信息失败:", "没有查询到媒体品种信息")
+		return
+	}
+	//媒体
+	mediaIds, err = models.FilterMediaIdIdsBySourceId(mediaType, mediaIds)
+	if err != nil {
+		utils.FileLog.Error("查询媒体信息失败", err.Error())
+		return
+	}
+
+	return
+}

+ 37 - 0
services/report.go

@@ -0,0 +1,37 @@
+package services
+
+import (
+	"eta/eta_mini_crm_ht/models"
+	"eta/eta_mini_crm_ht/utils"
+)
+
+func GetReportIdsByPermissionIds(permissionIds []int) (reportIds []int, err error) {
+	classifyIds, err := models.GetClassifyIdByPermissionIds(permissionIds)
+	if err != nil {
+		utils.FileLog.Error("查询报告分类信息失败", err.Error())
+		return
+	}
+	if len(classifyIds) == 0 {
+		utils.FileLog.Error("查询报告分类信息失败:", "没有查询到报告分类信息")
+		return
+	}
+	//eta报告
+	etaReportIds, err := models.GetReportIdByClassifyId(classifyIds)
+	if err != nil {
+		utils.FileLog.Error("查询eta报告失败", err.Error())
+		return
+	}
+	//海通
+	permissionNames, err := models.GetPermissionNames(permissionIds)
+	if err != nil {
+		utils.FileLog.Error("查询品种名称失败", err.Error())
+		return etaReportIds, nil
+	}
+	htReportIds, err := models.GetReportIdByPlateName(permissionNames)
+	if err != nil {
+		utils.FileLog.Error("查询品种名称失败", err.Error())
+		return etaReportIds, nil
+	}
+	reportIds = append(etaReportIds, htReportIds...)
+	return
+}

+ 152 - 0
services/user_source_click_flow.go

@@ -0,0 +1,152 @@
+package services
+
+import (
+	"eta/eta_mini_crm_ht/models"
+	"eta/eta_mini_crm_ht/utils"
+	"strings"
+	"sync"
+)
+
+func GetUserSourceClickFlowListCountByUserId(userId int, condition string, pars []interface{}, permissionIds []int, product models.SourceType) (total int, conditionNew string, parsNew []interface{}, err error) {
+	if len(permissionIds) == 0 {
+		total, err = models.GetUserSourceClickFlowListCountByUserId(userId, condition, pars)
+		return
+	}
+	if product == models.AudioSourceType || product == models.VideoSourceType {
+		mediaType := transMediaType(product)
+		videoIds, queryErr := GetMediaIdsByPermissionIds(permissionIds, mediaType)
+		if queryErr != nil || len(videoIds) == 0 {
+			return
+		}
+		condition = condition + " and source_id in (" + utils.GetOrmReplaceHolder(len(videoIds)) + ") "
+		pars = append(pars, videoIds)
+	} else if product == models.ReportSourceType {
+		reportIds, queryErr := GetReportIdsByPermissionIds(permissionIds)
+		if queryErr != nil || len(reportIds) == 0 {
+			return
+		}
+		condition = condition + " and source_id in (" + utils.GetOrmReplaceHolder(len(reportIds)) + ") "
+		pars = append(pars, reportIds)
+	} else {
+		reportIds, reportErr := GetReportIdsByPermissionIds(permissionIds)
+		addReport := false
+		addVideo := false
+		addAudio := false
+		var permissionCondition string
+		var permissionPars []interface{}
+		if reportErr == nil && len(reportIds) > 0 {
+			permissionCondition = permissionCondition + " (source_id in (" + utils.GetOrmReplaceHolder(len(reportIds)) + ") and source_type=?)"
+			permissionPars = append(permissionPars, reportIds)
+			permissionPars = append(permissionPars, models.ReportSourceType)
+			addReport = true
+		}
+		videoIds, videoErr := GetMediaIdsByPermissionIds(permissionIds, models.Video)
+		if videoErr == nil && len(videoIds) > 0 {
+			if addReport {
+				permissionCondition = permissionCondition + "or (source_id in (" + utils.GetOrmReplaceHolder(len(videoIds)) + ") and source_type=?)"
+			} else {
+				permissionCondition = permissionCondition + " (source_id in (" + utils.GetOrmReplaceHolder(len(videoIds)) + ") and source_type=?)"
+			}
+			permissionPars = append(permissionPars, videoIds)
+			permissionPars = append(permissionPars, models.VideoSourceType)
+			addVideo = true
+		}
+		audioIds, audioErr := GetMediaIdsByPermissionIds(permissionIds, models.Audio)
+		if audioErr == nil && len(audioIds) > 0 {
+			if addReport || addVideo {
+				permissionCondition = permissionCondition + "or (source_id in (" + utils.GetOrmReplaceHolder(len(audioIds)) + ") and source_type=?)"
+			} else {
+				permissionCondition = permissionCondition + " (source_id in (" + utils.GetOrmReplaceHolder(len(audioIds)) + ") and source_type=?)"
+			}
+			permissionPars = append(permissionPars, audioIds)
+			permissionPars = append(permissionPars, models.AudioSourceType)
+			addAudio = true
+		}
+		if addReport || addVideo || addAudio {
+			condition = condition + " and ( " + permissionCondition + " ) "
+			pars = append(pars, permissionPars...)
+		}
+	}
+	total, err = models.GetUserSourceClickFlowListCountByUserId(userId, condition, pars)
+	conditionNew = condition
+	parsNew = pars
+	return
+}
+
+func GetUserSourceClickFlowListByUserId(userId int, condition string, pars []interface{}, startSize, pageSize int) (items []models.UserSourceClickFlowView, err error) {
+	list, err := models.GetUserSourceClickFlowListByUserId(userId, condition, pars, startSize, pageSize)
+	if err != nil {
+		return
+	}
+	var wg sync.WaitGroup
+	wg.Add(len(list))
+	for _, item := range list {
+		go func(item *models.UserSourceClickFlow) {
+			defer wg.Done()
+			viewItem := item.ToView()
+			switch item.SourceType {
+			case models.ReportSourceType:
+				viewItem.PermissionNames = getReportPermissionNames(item.SourceId)
+			case models.AudioSourceType, models.VideoSourceType:
+				mediaType := transMediaType(item.SourceType)
+				viewItem.PermissionNames = getMediaPermissionNames(item.SourceId, mediaType)
+			}
+			items = append(items, viewItem)
+		}(item)
+	}
+	wg.Wait()
+	return
+}
+func transMediaType(sourceType models.SourceType) models.MediaType {
+	switch sourceType {
+	case models.AudioSourceType:
+		return models.Audio
+	case models.VideoSourceType:
+		return models.Video
+	default:
+		return ""
+	}
+}
+func getReportPermissionNames(reportId int) (permissionNames string) {
+	report, err := models.GetReportById(reportId)
+	if err != nil {
+		return
+	}
+	if report.Source == models.SourceETA {
+		permissionIds, queryErr := models.GetByPermissionIdsByClassifyId(report.OrgId)
+		if queryErr != nil {
+			return
+		}
+		permissionNameList, nameErr := models.GetPermissionNames(permissionIds)
+		if nameErr != nil {
+			utils.FileLog.Error("获取品种名称列表失败", err.Error())
+			return
+		}
+		permissionNames = strings.Join(permissionNameList, ",")
+		return
+	}
+	if report.Source == models.SourceHT {
+		return report.PlateName
+	}
+	return
+}
+
+func getMediaPermissionNames(mediaId int, mediaType models.MediaType) (permissionNames string) {
+	media, err := models.GetMediaById(mediaType, mediaId)
+	if err != nil {
+		utils.FileLog.Error("获取媒体失败,Err:" + err.Error())
+		return
+	}
+	permissionIds, queryErr := models.GetPermissionIdsByMediaId(media.MediaType, media.Id)
+	if queryErr != nil {
+		utils.FileLog.Error("获取媒体权限失败,Err:" + queryErr.Error())
+		return
+	}
+	permissionNameList, nameErr := models.GetPermissionNames(permissionIds)
+	if nameErr != nil {
+		utils.FileLog.Error("获取品种名称列表信息失败", nameErr.Error())
+		return
+	}
+	permissionNames = strings.Join(permissionNameList, ",")
+	return
+}

部分文件因为文件数量过多而无法显示