Roc 1 рік тому
батько
коміт
c07ae9ca1e
3 змінених файлів з 15 додано та 14 видалено
  1. 8 11
      controllers/company_user.go
  2. 3 3
      models/user_report_view_record.go
  3. 4 0
      models/wx_user.go

+ 8 - 11
controllers/company_user.go

@@ -2917,7 +2917,6 @@ Loop:
 // @Param   UserId   query   int  true       "用户id"
 // @Param   TxtType   query   int  true       "类型0全部,1权益,2ficc"
 // @Param   PageSize   query   int  true       "每页数据条数"
-// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
 // @Param   LastViewTime   query   string  true       "最近一次的阅读时间,没有的话,那就是获取最新数据"
 // @Success 200 {object} company.ViewReportListResp
 // @router /view/report/list [get]
@@ -2937,21 +2936,15 @@ func (this *CompanyUserController) ViewReportList() {
 	userId, _ := this.GetInt("UserId")
 	txtType, _ := this.GetInt("TxtType")
 	pageSize, _ := this.GetInt("PageSize")
-	currentIndex, _ := this.GetInt("CurrentIndex")
 	lastViewTime := this.GetString("LastViewTime")
 	if userId <= 0 {
 		br.Msg = "参数错误"
 		return
 	}
-
-	var startSize int
+	// 默认20条数据
 	if pageSize <= 0 {
 		pageSize = utils.PageSize20
 	}
-	if currentIndex <= 0 {
-		currentIndex = 1
-	}
-	startSize = paging.StartIndex(currentIndex, pageSize)
 
 	item, err := models.GetWxUserByUserId(userId)
 	if err != nil {
@@ -2988,14 +2981,18 @@ func (this *CompanyUserController) ViewReportList() {
 		basePars = append(basePars, item.Email)
 	}
 
+	// 阅读记录汇总数
+	total := item.FiccViewTotal + item.RaiViewTotal
 	switch txtType {
 	case 1:
 		baseCondition = ` AND source = ? `
 		basePars = append(basePars, 4)
+		total = item.FiccViewTotal
 	// 权益
 	case 2: // ficc
 		baseCondition = ` AND source in (?,?,?) `
 		basePars = append(basePars, 1, 2, 3)
+		total = item.RaiViewTotal
 	}
 
 	// 开始实际的查询
@@ -3006,7 +3003,7 @@ func (this *CompanyUserController) ViewReportList() {
 		condition += `AND create_time <  ?`
 		pars = append(pars, lastViewTime)
 
-		total, items, err := obj.GetViewReportList(lastViewTimeT.Year(), condition, pars, startSize, pageSize)
+		total, items, err := obj.GetViewReportList(lastViewTimeT.Year(), condition, pars, pageSize)
 		if err != nil {
 			br.Msg = "获取失败"
 			br.Msg = "获取失败,Err:" + err.Error()
@@ -3023,7 +3020,7 @@ func (this *CompanyUserController) ViewReportList() {
 			secondCondition += `AND create_time <  ?`
 			secondPars = append(secondPars, lastViewTime)
 
-			_, items, err := obj.GetViewReportList(lastViewTimeT.Year(), secondCondition, secondPars, 0, int(total)-pageSize)
+			_, items, err := obj.GetViewReportList(lastViewTimeT.Year(), secondCondition, secondPars, int(total)-pageSize)
 			if err != nil {
 				br.Msg = "获取失败"
 				br.Msg = "获取失败,Err:" + err.Error()
@@ -3167,7 +3164,7 @@ func (this *CompanyUserController) ViewReportList() {
 	}
 	resp := new(company.ViewReportListResp)
 	resp.List = list
-	resp.Total = len(list)
+	resp.Total = total
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "获取成功"

+ 3 - 3
models/user_report_view_record.go

@@ -29,7 +29,7 @@ func (obj UserReportViewRecord) TableName() string {
 }
 
 // GetViewReportList 单条记录插入
-func (obj UserReportViewRecord) GetViewReportList(year int, condition string, pars []interface{}, startSize, pageSize int) (total int64, items []*UserReportViewRecord, err error) {
+func (obj UserReportViewRecord) GetViewReportList(year int, condition string, pars []interface{}, pageSize int) (total int64, items []*UserReportViewRecord, err error) {
 	tableName := obj.GetTableName(year)
 
 	o := orm.NewOrm()
@@ -37,8 +37,8 @@ func (obj UserReportViewRecord) GetViewReportList(year int, condition string, pa
 	if condition != "" {
 		sql += condition
 	}
-	sql += ` ORDER BY create_time DESC,id DESC LIMIT ?,? `
-	total, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	sql += ` ORDER BY create_time DESC,id DESC LIMIT ? `
+	total, err = o.Raw(sql, pars, pageSize).QueryRows(&items)
 
 	return
 

+ 4 - 0
models/wx_user.go

@@ -32,6 +32,10 @@ type WxUser struct {
 	OpenId              string    `orm:"column(open_id)" description:"微信openid"`
 	Headimgurl          string    `description:"用户头像,最后一个数值代表正方形头像大小(有0、46、64、96、132数值可选,0代表640*640正方形头像),用户没有头像时该项为空"`
 	UserLabel           string    `description:"查研观向用户标签"`
+	FiccViewTotal       int       `description:"ficc报告的阅读次数"`
+	FiccLastViewTime    string    `description:"ficc报告最近一次阅读时间"`
+	RaiViewTotal        int       `description:"权益报告的阅读次数"`
+	RaiLastViewTime     string    `description:"权益报告的最近一次阅读时间"`
 }
 
 func AddWxUser(item *WxUser) (lastId int64, err error) {