rdluck 4 years ago
parent
commit
c9bcc79df4
8 changed files with 470 additions and 55 deletions
  1. 51 11
      controllers/bill.go
  2. 40 4
      controllers/home_pc.go
  3. 41 3
      controllers/report_pc.go
  4. 306 9
      models/bill.go
  5. 4 2
      models/classify.go
  6. 3 2
      models/home.go
  7. 1 1
      models/report_pc.go
  8. 24 23
      models/wx_user.go

+ 51 - 11
controllers/bill.go

@@ -1,7 +1,10 @@
 package controllers
 
 import (
+	"fmt"
 	"hongze/hongze_api/models"
+	"hongze/hongze_api/utils"
+	"time"
 )
 
 //年度账单
@@ -26,7 +29,8 @@ func (this *WechatCommonController) Detail() {
 		br.Ret = 408
 		return
 	}
-	var realName string
+	uid := user.UserId
+	var realName, togetherDay, createDate string
 
 	resp := new(models.BillDetailResp)
 	if user.RealName == "" {
@@ -34,17 +38,45 @@ func (this *WechatCommonController) Detail() {
 	} else {
 		realName = user.RealName
 	}
-	
+	if !user.CreatedTime.IsZero() {
+		sub := time.Now().Sub(user.CreatedTime)
+		if sub < 0 {
+			sub = 0
+		}
+		expireDay := fmt.Sprintf("%v", int(sub.Hours()/24))
+		togetherDay = expireDay
+		createDate = user.CreatedTime.Format(utils.FormatDate)
+	} else {
+		sub := time.Now().Sub(user.LastUpdatedTime)
+		if sub < 0 {
+			sub = 0
+		}
+		expireDay := fmt.Sprintf("%v", int(sub.Hours()/24))
+		togetherDay = expireDay
+		createDate = user.LastUpdatedTime.Format(utils.FormatDate)
+	}
+
+	uid = 41555
+
+	firstReadReportType, firstReadReportTitle, err := models.GetFirstReportInfo(uid)
+	if err != nil {
+		br.Msg = "获取数据失败"
+		br.ErrMsg = "获取数据失败GetFirstReportInfo,Err:" + err.Error()
+		return
+	}
+	listenCount, listenVideoPlaySeconds, err := models.GetListenInfo(uid)
+	if err != nil {
+		br.Msg = "获取数据失败"
+		br.ErrMsg = "获取数据失败GetListenInfo,Err:" + err.Error()
+		return
+	}
+	maxReadReportCount, maxReadReportDate, err := models.GetMaxReadReportInfo(uid)
+	if err != nil {
+		br.Msg = "获取数据失败"
+		br.ErrMsg = "获取数据失败GetListenInfo,Err:" + err.Error()
+		return
+	}
 	/*
-	   RealName                     string  `description:"用户实际名称"`
-	   TogetherDay                  int     `description:"相伴天数"`
-	   CreateDate                   string  `description:"创建时间"`
-	   FirstReadReportType          string  `description:"首次阅读报告类型"`
-	   FirstReadReportTitle         string  `description:"首次阅读报告标题"`
-	   ListenReportCount            int     `description:"收听报告次数"`
-	   ListenReportDuration         float64 `description:"收听报告时长"`
-	   MaxReadReportDate            string  `description:"阅读报告最多的一天"`
-	   MaxReadReportCount           int     `description:"阅读报告最多的一天,报告数量"`
 	   LatestReadReportDate         string  `description:"阅读报告时间最晚的一天"`
 	   LatestReadReportTime         string  `description:"阅读报告时间最晚的一天,最晚的时间"`
 	   LatestReadReportDateDuration string  `description:"阅读报告时间最晚的一天,总共阅读报告的时长"`
@@ -59,6 +91,14 @@ func (this *WechatCommonController) Detail() {
 	   LearnDay                     int     `description:"连续学习天数"`
 	*/
 	resp.RealName = realName
+	resp.TogetherDay = togetherDay
+	resp.CreateDate = createDate
+	resp.FirstReadReportType = firstReadReportType
+	resp.FirstReadReportTitle = firstReadReportTitle
+	resp.ListenReportCount = listenCount
+	resp.ListenReportDuration = utils.FixFloat((listenVideoPlaySeconds / 60.00), 2)
+	resp.MaxReadReportCount = maxReadReportCount
+	resp.MaxReadReportDate = maxReadReportDate.Format(utils.FormatDate)
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "获取成功"

+ 40 - 4
controllers/home_pc.go

@@ -68,16 +68,16 @@ func (this *HomeCommonController) ListHome() {
 		return
 	}
 
-	endDate:=time.Now().AddDate(0,-1,0).Format(utils.FormatDate)
+	endDate := time.Now().AddDate(0, -1, 0).Format(utils.FormatDate)
 
-	total, err := models.PcListHomeCount(classifyId,endDate)
+	total, err := models.PcListHomeCount(classifyId, endDate)
 	if err != nil {
 		br.Msg = "获取数据失败"
 		br.ErrMsg = "获取数据条数失败,Err:" + err.Error()
 		return
 	}
 
-	list, err := models.PcListHome(classifyId, uid, startSize, pageSize,endDate)
+	list, err := models.PcListHome(classifyId, uid, startSize, pageSize, endDate)
 	if err != nil {
 		br.Msg = "获取数据失败"
 		br.ErrMsg = "获取数据失败,Err:" + err.Error()
@@ -85,7 +85,7 @@ func (this *HomeCommonController) ListHome() {
 	}
 	var hasPermission bool
 	if this.Token != "" && this.User != nil {
-		userPermission, err := services.CheckUserPermission(this.User.UserId)
+		userPermission, err := services.CheckUserPermission(uid)
 		if err != nil {
 			br.Msg = "获取失败"
 			br.ErrMsg = "判断权限失败,判断权限失败:" + err.Error()
@@ -97,8 +97,44 @@ func (this *HomeCommonController) ListHome() {
 		}
 	}
 
+	reportType := "rddp"
+	reportPermissionList, err := models.GetReportVarietyListByUserIdExt(uid, reportType) //获取客户拥有权限的报告id
+	if err != nil {
+		if err.Error() != utils.ErrNoRow() {
+			br.Msg = "获取报告详情失败"
+			br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
+			return
+		} else {
+			hasPermission = false
+		}
+	}
+	if len(reportPermissionList) == 0 {
+		hasPermission = false
+	}
+	permissionMap := make(map[int]int)
+	for _, v := range reportPermissionList {
+		if _, ok := permissionMap[v.ReportChapterTypeId]; !ok {
+			permissionMap[v.ReportChapterTypeId] = v.ReportChapterTypeId
+		}
+	}
+
 	for i := 0; i < len(list); i++ {
 		item := list[i]
+		if uid > 0 {
+			count, err := models.GetReportPermission(uid, item.ClassifyNameSecond)
+			if err != nil && err.Error() != utils.ErrNoRow() {
+				br.Msg = "获取失败"
+				br.ErrMsg = "判断报告是否拥有权限失败,Err:" + err.Error()
+				return
+			}
+			if count <= 0 {
+				list[i].VideoUrl = ""
+				list[i].VideoName = ""
+				list[i].VideoPlaySeconds = ""
+				list[i].VideoSize = ""
+			}
+		}
+
 		if item.ClassifyName == "权益研报" {
 			list[i].TitleType = "权益"
 		} else {

+ 41 - 3
controllers/report_pc.go

@@ -2,6 +2,7 @@ package controllers
 
 import (
 	"hongze/hongze_api/models"
+	"hongze/hongze_api/utils"
 )
 
 // @Title 研报列表
@@ -93,6 +94,31 @@ func (this *ReportCommonController) PcSearchReportList() {
 	//	br.ErrMsg = "获取数据失败,Err:" + err.Error()
 	//	return
 	//}
+	var uid int
+	if this.Token != "" && this.User != nil {
+		uid = this.User.UserId
+	}
+	var hasPermission bool
+	reportType := "rddp"
+	reportPermissionList, err := models.GetReportVarietyListByUserIdExt(uid, reportType) //获取客户拥有权限的报告id
+	if err != nil {
+		if err.Error() != utils.ErrNoRow() {
+			br.Msg = "获取报告详情失败"
+			br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
+			return
+		} else {
+			hasPermission = false
+		}
+	}
+	if len(reportPermissionList) == 0 {
+		hasPermission = false
+	}
+	permissionMap := make(map[int]int)
+	for _, v := range reportPermissionList {
+		if _, ok := permissionMap[v.ReportChapterTypeId]; !ok {
+			permissionMap[v.ReportChapterTypeId] = v.ReportChapterTypeId
+		}
+	}
 
 	list, err := models.GetSearchReportList(condition)
 	if err != nil {
@@ -104,16 +130,28 @@ func (this *ReportCommonController) PcSearchReportList() {
 	for i := 0; i < listLen; i++ {
 		item := list[i]
 		if this.Token != "" {
-			count, err := models.GetReportPermission(this.User.UserId, item.ClassifyNameSecond)
-			if err != nil {
+			count, err := models.GetReportPermission(uid, item.ClassifyNameSecond)
+			if err != nil && err.Error()!=utils.ErrNoRow() {
 				br.Msg = "获取失败"
 				br.ErrMsg = "判断报告是否拥有权限失败,Err:" + err.Error()
 				return
 			}
 			if count > 0 {
 				list[i].HasPermission = 1
+			} else {
+				list[i].VideoUrl = ""
+				list[i].VideoName = ""
+				list[i].VideoPlaySeconds = ""
+				list[i].VideoSize = ""
 			}
-		}else{
+		} else {
+			list[i].VideoUrl = ""
+			list[i].VideoName = ""
+			list[i].VideoPlaySeconds = ""
+			list[i].VideoSize = ""
+		}
+
+		if hasPermission == false {
 			list[i].VideoUrl = ""
 			list[i].VideoName = ""
 			list[i].VideoPlaySeconds = ""

+ 306 - 9
models/bill.go

@@ -1,25 +1,322 @@
 package models
 
+import (
+	"hongze/hongze_api/utils"
+	"rdluck_tools/orm"
+	"time"
+)
+
 type BillDetailResp struct {
 	RealName                     string  `description:"用户实际名称"`
-	TogetherDay                  int     `description:"相伴天数"`
+	TogetherDay                  string  `description:"相伴天数"`
 	CreateDate                   string  `description:"创建时间"`
 	FirstReadReportType          string  `description:"首次阅读报告类型"`
 	FirstReadReportTitle         string  `description:"首次阅读报告标题"`
 	ListenReportCount            int     `description:"收听报告次数"`
 	ListenReportDuration         float64 `description:"收听报告时长"`
 	MaxReadReportDate            string  `description:"阅读报告最多的一天"`
-	MaxReadReportCount           int     `description:"阅读报告最多的一天,报告数量"`
+	MaxReadReportCount           int  `description:"阅读报告最多的一天,报告数量"`
 	LatestReadReportDate         string  `description:"阅读报告时间最晚的一天"`
 	LatestReadReportTime         string  `description:"阅读报告时间最晚的一天,最晚的时间"`
 	LatestReadReportDateDuration string  `description:"阅读报告时间最晚的一天,总共阅读报告的时长"`
 	MaxOpenReportClassify        string  `description:"打开次数最多报告的栏目"`
 	MaxOpenReportCount           string  `description:"打开次数最多报告的栏目下,用户阅读的报告数"`
-	TotalReadDuration            float64 `description:"总阅读时长"`
-	TotalReportDayCount          int     `description:"总阅读晨报数"`
-	TotalReportWeekCount         int     `description:"总阅读周报数"`
-	TotalReportMonthCount        int     `description:"总阅读月报数"`
-	TotalReportTwoWeekCount      int     `description:"总阅读双周报数"`
-	TotalReportRddpCount         int     `description:"总阅读点评数"`
-	LearnDay                     int     `description:"连续学习天数"`
+	TotalReadDuration            string  `description:"总阅读时长"`
+	TotalReportDayCount          string  `description:"总阅读晨报数"`
+	TotalReportWeekCount         string  `description:"总阅读周报数"`
+	TotalReportMonthCount        string  `description:"总阅读月报数"`
+	TotalReportTwoWeekCount      string  `description:"总阅读双周报数"`
+	TotalReportRddpCount         string  `description:"总阅读点评数"`
+	LearnDay                     string  `description:"连续学习天数"`
+}
+
+type ReadReportType struct {
+	ReportType string
+	CreateTime time.Time
+	Title      string
+	Stage      int
+}
+
+func GetRddpMinReportType(uid int) (item *ReadReportType, err error) {
+	o := orm.NewOrm()
+	o.Using("rddp")
+	sql := `SELECT 'rddp' AS report_type,MIN(a.create_time) AS create_time,b.title,b.stage FROM report_view_record AS a
+			INNER JOIN  report AS b ON a.report_id=b.id
+			WHERE a.user_id=? `
+	err = o.Raw(sql, uid).QueryRow(&item)
+	return
+}
+
+func GetWeekMinReportType(uid int) (item *ReadReportType, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT b.type AS report_type,MIN(a.created_time) AS create_time,b.research_report_name AS title,b.periods AS stage FROM user_view_history AS a
+			INNER JOIN  research_report AS b ON a.research_report_id=b.research_report_id
+			WHERE a.user_id=? `
+	err = o.Raw(sql, uid).QueryRow(&item)
+	return
 }
+
+func GetFirstReportInfo(uid int) (firstReadReportType, firstReadReportTitle string, err error) {
+	rddpFlag := true
+	weekFlag := true
+	rddpMinReportItem, err := GetRddpMinReportType(uid)
+	if err != nil {
+		if err.Error() == utils.ErrNoRow() {
+			rddpFlag = false
+		} else {
+			return
+		}
+	}
+	if rddpMinReportItem == nil {
+		rddpFlag = false
+	}
+	weekMinReportItem, err := GetWeekMinReportType(uid)
+	if err != nil {
+		if err.Error() == utils.ErrNoRow() {
+			weekFlag = false
+		} else {
+			return
+		}
+	}
+	if weekMinReportItem == nil {
+		weekFlag = false
+	}
+
+	if rddpFlag && weekFlag {
+		if rddpMinReportItem.CreateTime.After(weekMinReportItem.CreateTime) {
+			firstReadReportType = rddpMinReportItem.ReportType
+			firstReadReportTitle = rddpMinReportItem.Title
+		} else {
+			firstReadReportType = weekMinReportItem.ReportType
+			firstReadReportTitle = weekMinReportItem.Title
+		}
+	} else {
+		if rddpFlag == false && weekFlag {
+			firstReadReportType = weekMinReportItem.ReportType
+			firstReadReportTitle = weekMinReportItem.Title
+		}
+		if rddpFlag && weekFlag == false {
+			firstReadReportType = rddpMinReportItem.ReportType
+			firstReadReportTitle = rddpMinReportItem.Title
+		}
+	}
+	return
+}
+
+type Listen struct {
+	Count            int
+	VideoPlaySeconds float64
+}
+
+func GetRddpListen(uid int) (item *Listen, err error) {
+	o := orm.NewOrm()
+	o.Using("rddp")
+	sql := ` SELECT COUNT(1),SUM(b.video_play_seconds) FROM  report_audio_record AS a
+			 INNER JOIN report AS b ON a.report_id=b.id
+			 WHERE user_id=? LIMIT 1`
+	err = o.Raw(sql, uid).QueryRow(&item)
+	return
+}
+
+func GetWeekListen(uid int) (item *Listen, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT COUNT(1) AS count,SUM(b.video_play_seconds) AS video_play_seconds FROM voice_record AS a
+			INNER JOIN teleconference AS b ON a.teleconference_id=b.teleconference_id
+			WHERE a.uid=? LIMIT 1`
+	err = o.Raw(sql, uid).QueryRow(&item)
+	return
+}
+
+func GetListenInfo(uid int) (count int, videoPlaySeconds float64, err error) {
+	rddpFlag := true
+	weekFlag := true
+	rddpListenItem, err := GetRddpListen(uid)
+	if err != nil {
+		if err.Error() == utils.ErrNoRow() {
+			rddpFlag = false
+		} else {
+			return
+		}
+	}
+	if rddpListenItem == nil {
+		rddpFlag = false
+	}
+	weekListenItem, err := GetWeekListen(uid)
+	if err != nil {
+		if err.Error() == utils.ErrNoRow() {
+			weekFlag = false
+		} else {
+			return
+		}
+	}
+	if weekListenItem == nil {
+		weekFlag = false
+	}
+
+	if rddpFlag && weekFlag {
+		count = rddpListenItem.Count + weekListenItem.Count
+		videoPlaySeconds = rddpListenItem.VideoPlaySeconds + weekListenItem.VideoPlaySeconds
+	} else {
+		if rddpFlag == false && weekFlag {
+			count = weekListenItem.Count
+			videoPlaySeconds = weekListenItem.VideoPlaySeconds
+		}
+		if rddpFlag && weekFlag == false {
+			count = rddpListenItem.Count
+			videoPlaySeconds = rddpListenItem.VideoPlaySeconds
+		}
+	}
+	return
+}
+
+type MaxReadReportCount struct {
+	Count      int
+	CreateDate time.Time
+}
+
+func GetRddpMaxReadReportCount(uid int) (item *MaxReadReportCount, err error) {
+	o := orm.NewOrm()
+	o.Using("rddp")
+	sql := ` SELECT DATE(create_time)AS create_date,COUNT(1) AS count FROM report_view_record AS a
+				WHERE a.user_id=?
+				GROUP BY DATE(create_time)
+				ORDER BY num DESC
+				LIMIT 1 `
+	err = o.Raw(sql, uid).QueryRow(&item)
+	return
+}
+
+func GetWeekMaxReadReportCount(uid int) (item *MaxReadReportCount, err error) {
+	o := orm.NewOrm()
+	sql := ` SELECT DATE(a.created_time)AS create_date,COUNT(1) AS count  FROM user_view_history AS a
+			WHERE a.user_id=?
+			GROUP BY DATE(created_time)
+			ORDER BY num DESC
+			LIMIT 1 `
+	err = o.Raw(sql, uid).QueryRow(&item)
+	return
+}
+
+func GetMaxReadReportInfo(uid int) (count int, createDate time.Time, err error) {
+	rddpFlag := true
+	weekFlag := true
+	rddpReadReportItem, err := GetRddpMaxReadReportCount(uid)
+	if err != nil {
+		if err.Error() == utils.ErrNoRow() {
+			rddpFlag = false
+		} else {
+			return
+		}
+	}
+	if rddpReadReportItem == nil {
+		rddpFlag = false
+	}
+	weekReadReportItem, err := GetWeekMaxReadReportCount(uid)
+	if err != nil {
+		if err.Error() == utils.ErrNoRow() {
+			weekFlag = false
+		} else {
+			return
+		}
+	}
+	if weekReadReportItem == nil {
+		weekFlag = false
+	}
+
+	if rddpFlag && weekFlag {
+		if rddpReadReportItem.Count>weekReadReportItem.Count {
+			count=rddpReadReportItem.Count
+			createDate=rddpReadReportItem.CreateDate
+		}else{
+			count=weekReadReportItem.Count
+			createDate=weekReadReportItem.CreateDate
+		}
+	} else {
+		if rddpFlag == false && weekFlag {
+			count=weekReadReportItem.Count
+			createDate=weekReadReportItem.CreateDate
+		}
+		if rddpFlag && weekFlag == false {
+			count=rddpReadReportItem.Count
+			createDate=rddpReadReportItem.CreateDate
+		}
+	}
+	return
+}
+
+//
+//
+//type MaxReadReportCount struct {
+//	Count      int
+//	CreateDate time.Time
+//}
+//
+//func GetRddpMaxReadReportCount(uid int) (item *MaxReadReportCount, err error) {
+//	o := orm.NewOrm()
+//	o.Using("rddp")
+//	sql := ` SELECT DATE(create_time)AS create_date,COUNT(1) AS count FROM report_view_record AS a
+//				WHERE a.user_id=?
+//				GROUP BY DATE(create_time)
+//				ORDER BY num DESC
+//				LIMIT 1 `
+//	err = o.Raw(sql, uid).QueryRow(&item)
+//	return
+//}
+//
+//func GetWeekMaxReadReportCount(uid int) (item *MaxReadReportCount, err error) {
+//	o := orm.NewOrm()
+//	sql := ` SELECT DATE(a.created_time)AS create_date,COUNT(1) AS count  FROM user_view_history AS a
+//			WHERE a.user_id=?
+//			GROUP BY DATE(created_time)
+//			ORDER BY num DESC
+//			LIMIT 1 `
+//	err = o.Raw(sql, uid).QueryRow(&item)
+//	return
+//}
+//
+//func GetMaxReadReportInfo(uid int) (count int, createDate time.Time, err error) {
+//	rddpFlag := true
+//	weekFlag := true
+//	rddpReadReportItem, err := GetRddpMaxReadReportCount(uid)
+//	if err != nil {
+//		if err.Error() == utils.ErrNoRow() {
+//			rddpFlag = false
+//		} else {
+//			return
+//		}
+//	}
+//	if rddpReadReportItem == nil {
+//		rddpFlag = false
+//	}
+//	weekReadReportItem, err := GetWeekMaxReadReportCount(uid)
+//	if err != nil {
+//		if err.Error() == utils.ErrNoRow() {
+//			weekFlag = false
+//		} else {
+//			return
+//		}
+//	}
+//	if weekReadReportItem == nil {
+//		weekFlag = false
+//	}
+//
+//	if rddpFlag && weekFlag {
+//		if rddpReadReportItem.Count>weekReadReportItem.Count {
+//			count=rddpReadReportItem.Count
+//			createDate=rddpReadReportItem.CreateDate
+//		}else{
+//			count=weekReadReportItem.Count
+//			createDate=weekReadReportItem.CreateDate
+//		}
+//	} else {
+//		if rddpFlag == false && weekFlag {
+//			count=weekReadReportItem.Count
+//			createDate=weekReadReportItem.CreateDate
+//		}
+//		if rddpFlag && weekFlag == false {
+//			count=rddpReadReportItem.Count
+//			createDate=rddpReadReportItem.CreateDate
+//		}
+//	}
+//	return
+//}

+ 4 - 2
models/classify.go

@@ -20,6 +20,7 @@ type Classify struct {
 	HeadImgUrl     string    `description:"头部banner"`
 	AvatarImgUrl   string    `description:"头像"`
 	ReportImgUrl   string    `description:"报告配图"`
+	HomeImgUrl     string    `description:"首页配图"`
 }
 
 func GetClassifyById(classifyId int) (item *Classify, err error) {
@@ -39,12 +40,12 @@ func GetClassifyList() (item []*Classify, err error) {
 }
 
 func GetClassifySecondList(classifyId int) (item []*ClassifyDetail, err error) {
-	sql := ` SELECT a.id AS classify_id,a.classify_name,a.sort,a.parent_id,a.create_time,a.modify_time,a.abstract,a.descript,a.report_author,a.author_descript,a.report_img_url,a.head_img_url,a.avatar_img_url,a.column_img_url,a.is_home_column,MAX(b.stage) AS stage 
+	sql := ` SELECT a.id AS classify_id,a.classify_name,a.sort,a.parent_id,a.create_time,a.modify_time,a.abstract,a.descript,a.report_author,a.author_descript,a.report_img_url,a.head_img_url,a.avatar_img_url,a.column_img_url,a.home_img_url,a.is_home_column,MAX(b.stage) AS stage 
             FROM classify AS a 
 			LEFT JOIN report AS b ON a.id=b.classify_id_second 
 			WHERE a.parent_id = ?
 			GROUP BY a.id 
-            ORDER BY create_time ASC `
+            ORDER BY sort ASC `
 	o := orm.NewOrm()
 	o.Using("rddp")
 	_, err = o.Raw(sql, classifyId).QueryRows(&item)
@@ -66,6 +67,7 @@ type ClassifyDetail struct {
 	HeadImgUrl     string    `description:"头部banner"`
 	AvatarImgUrl   string    `description:"头像"`
 	ReportImgUrl   string    `description:"报告配图"`
+	HomeImgUrl     string    `description:"首页配图"`
 	Stage          int       `description:"最新期数"`
 	CommentList    []*CustomerComment
 }

+ 3 - 2
models/home.go

@@ -89,6 +89,7 @@ type PcHomeClassifyItem struct {
 	HeadImgUrl     string `description:"头部banner"`
 	AvatarImgUrl   string `description:"头像"`
 	ReportImgUrl   string `description:"报告配图"`
+	HomeImgUrl     string `description:"首页配图"`
 	PcReport
 }
 
@@ -108,7 +109,7 @@ func PcListHome(classifyId, uid, startSize, pageSize int, endDate string) (items
 	o := orm.NewOrm()
 	o.Using("rddp")
 	if uid > 0 {
-		reportSql := ` SELECT a.id AS classify_id,a.head_img_url,a.avatar_img_url,a.column_img_url,a.report_img_url,b.*,
+		reportSql := ` SELECT a.id AS classify_id,a.head_img_url,a.avatar_img_url,a.column_img_url,a.report_img_url,a.home_img_url,b.*,
                 (SELECT COUNT(1) FROM report_view_log AS c WHERE c.user_id=? AND c.report_id=b.id ) AS is_show_new_label,
                 CASE WHEN DATE(b.modify_time)=DATE(NOW()) THEN 1 ELSE 0 END AS is_current_date
                 FROM classify AS a
@@ -117,7 +118,7 @@ func PcListHome(classifyId, uid, startSize, pageSize int, endDate string) (items
                 ORDER BY b.publish_time DESC LIMIT ?,? `
 		_, err = o.Raw(reportSql, uid, classifyId, endDate, startSize, pageSize).QueryRows(&items)
 	} else {
-		reportSql := ` SELECT a.id AS classify_id,a.head_img_url,a.avatar_img_url,a.column_img_url,a.report_img_url,b.*,
+		reportSql := ` SELECT a.id AS classify_id,a.head_img_url,a.avatar_img_url,a.column_img_url,a.report_img_url,a.home_img_url,b.*,
                 CASE WHEN DATE(b.modify_time)=DATE(NOW()) THEN 1 ELSE 0 END AS is_current_date
                  FROM classify AS a
                 INNER JOIN report AS b ON a.id=b.classify_id_second

+ 1 - 1
models/report_pc.go

@@ -50,7 +50,7 @@ func GetSearchReportList(condition string) (items []*ReportList, err error) {
 	o.Using("rddp")
 	sql := ` SELECT a.id,a.add_type,a.classify_id_first,a.classify_name_first,a.classify_id_second,a.classify_name_second,a.title,a.abstract,a.author,a.frequency,
 			a.create_time,a.modify_time,a.state,a.publish_time,a.stage,a.msg_is_send,b.id AS classify_id,b.classify_name,b.descript,b.report_author,b.author_descript,
-            b.report_img_url,b.head_img_url,b.avatar_img_url,b.column_img_url,a.video_url,a.video_name,a.video_play_seconds,a.video_size
+            b.report_img_url,b.head_img_url,b.avatar_img_url,b.column_img_url,b.home_img_url,a.video_url,a.video_name,a.video_play_seconds,a.video_size
             FROM report AS a
 			INNER JOIN  classify AS b ON a.classify_id_second=b.id
 			WHERE a.state=2  `

+ 24 - 23
models/wx_user.go

@@ -47,20 +47,22 @@ type WxUser struct {
 }
 
 type WxUserItem struct {
-	UserId      int       `description:"用户id"`
-	OpenId      string    `description:"open_id"`
-	UnionId     string    `description:"union_id"`
-	CompanyId   int       `description:"客户id"`
-	NickName    string    `description:"用户昵称"`
-	RealName    string    `description:"用户实际名称"`
-	Mobile      string    `description:"手机号码"`
-	BindAccount string    `description:"绑定时的账号"`
-	Email       string    `description:"邮箱"`
-	Headimgurl  string    `description:"用户头像,最后一个数值代表正方形头像大小(有0、46、64、96、132数值可选,0代表640*640正方形头像),用户没有头像时该项为空"`
-	ApplyMethod int       `description:"0:未申请,1:已付费客户申请试用,2:非客户申请试用"`
-	FirstLogin  int       `description:"是否第一次登陆"`
-	IsFreeLogin int       `description:"是否免登陆,true:免登陆,false:非免登陆"`
-	LoginTime   time.Time `description:"登录时间"`
+	UserId          int       `description:"用户id"`
+	OpenId          string    `description:"open_id"`
+	UnionId         string    `description:"union_id"`
+	CompanyId       int       `description:"客户id"`
+	NickName        string    `description:"用户昵称"`
+	RealName        string    `description:"用户实际名称"`
+	Mobile          string    `description:"手机号码"`
+	BindAccount     string    `description:"绑定时的账号"`
+	Email           string    `description:"邮箱"`
+	Headimgurl      string    `description:"用户头像,最后一个数值代表正方形头像大小(有0、46、64、96、132数值可选,0代表640*640正方形头像),用户没有头像时该项为空"`
+	ApplyMethod     int       `description:"0:未申请,1:已付费客户申请试用,2:非客户申请试用"`
+	FirstLogin      int       `description:"是否第一次登陆"`
+	IsFreeLogin     int       `description:"是否免登陆,true:免登陆,false:非免登陆"`
+	LoginTime       time.Time `description:"登录时间"`
+	CreatedTime     time.Time `description:"创建时间"`
+	LastUpdatedTime time.Time `description:"最近一次修改时间"`
 }
 
 func GetWxUserItemByUserId(userId int) (item *WxUserItem, err error) {
@@ -291,8 +293,8 @@ func PcBindMobile(unionId, mobile string, userId, loginType int) (wxUserId int,
 				return
 			}
 
-			utils.FileLog.Info("user.RegisterTime %s",user.RegisterTime.Format(utils.FormatDateTime))
-			utils.FileLog.Info("userInfo.RegisterTime %s",userInfo.RegisterTime.Format(utils.FormatDateTime))
+			utils.FileLog.Info("user.RegisterTime %s", user.RegisterTime.Format(utils.FormatDateTime))
+			utils.FileLog.Info("userInfo.RegisterTime %s", userInfo.RegisterTime.Format(utils.FormatDateTime))
 
 			var maxRegisterTime time.Time
 			if user.RegisterTime.Before(userInfo.RegisterTime) {
@@ -304,11 +306,11 @@ func PcBindMobile(unionId, mobile string, userId, loginType int) (wxUserId int,
 			}
 			var realName string
 			if user.RealName != "" {
-				realName=user.RealName
-			}else{
-				realName=userInfo.RealName
+				realName = user.RealName
+			} else {
+				realName = userInfo.RealName
 			}
-			utils.FileLog.Info("maxRegisterTime %s",maxRegisterTime.Format(utils.FormatDateTime))
+			utils.FileLog.Info("maxRegisterTime %s", maxRegisterTime.Format(utils.FormatDateTime))
 			wxUserId = user.UserId
 			dsql := ` DELETE FROM wx_user WHERE user_id = ? `
 			_, err = o.Raw(dsql, wxUserId).Exec()
@@ -330,9 +332,9 @@ func PcBindMobile(unionId, mobile string, userId, loginType int) (wxUserId int,
 				msql += `  WHERE union_id = ? `
 			}
 			if user.CompanyId > 0 {
-				_, err = o.Raw(msql, mobile, mobile, maxRegisterTime,realName, user.CompanyId, unionId).Exec()
+				_, err = o.Raw(msql, mobile, mobile, maxRegisterTime, realName, user.CompanyId, unionId).Exec()
 			} else {
-				_, err = o.Raw(msql, mobile, mobile, maxRegisterTime,realName, unionId).Exec()
+				_, err = o.Raw(msql, mobile, mobile, maxRegisterTime, realName, unionId).Exec()
 			}
 			wxUserId = userInfo.UserId
 		} else {
@@ -469,4 +471,3 @@ func ModifyWxUserUnionId(unionId string, userId int) (err error) {
 	_, err = o.Raw(sql, unionId, unionId, userId).Exec()
 	return
 }
-