Pārlūkot izejas kodu

查研观向3.2新增的需求

xingzai 1 gadu atpakaļ
vecāks
revīzija
9393e63caa

+ 45 - 19
controllers/report_selection.go

@@ -37,19 +37,21 @@ func (this *ReportSelectionController) Detail() {
 	//uid := user.UserId
 	articleId, _ := this.GetInt("ArticleId")
 	isBestNew, _ := this.GetBool("IsBestNew")
-	isBestNew = true
-	if isBestNew {
-		tbdb := "cygx_report_selection"
-		condition := ` AND publish_status = 1  `
-		var pars []interface{}
-		list, err := models.GetReportSelectionListPublic(condition, "1", tbdb, pars, 0, 1)
-		if err != nil {
-			br.Msg = "获取失败"
-			br.ErrMsg = "获取失败,Err:" + err.Error()
-			return
-		}
-		for _, v := range list {
-			articleId = v.ArticleId
+	if articleId == 0 {
+		isBestNew = true
+		if isBestNew {
+			tbdb := "cygx_report_selection"
+			condition := ` AND publish_status = 1  `
+			var pars []interface{}
+			list, err := models.GetReportSelectionListPublic(condition, "1", tbdb, pars, 0, 1)
+			if err != nil {
+				br.Msg = "获取失败"
+				br.ErrMsg = "获取失败,Err:" + err.Error()
+				return
+			}
+			for _, v := range list {
+				articleId = v.ArticleId
+			}
 		}
 	}
 	if articleId < 1 {
@@ -327,7 +329,7 @@ func (this *ReportSelectionController) List() {
 		br.Ret = 408
 		return
 	}
-	resp := new(models.GetCygxProductInteriorResp)
+	resp := new(models.CygxReportSelectionListPublicRep)
 	pageSize, _ := this.GetInt("PageSize")
 	currentIndex, _ := this.GetInt("CurrentIndex")
 
@@ -341,22 +343,46 @@ func (this *ReportSelectionController) List() {
 	startSize = utils.StartIndex(currentIndex, pageSize)
 	var condition string
 	var pars []interface{}
-	condition += ` AND art.status = 1 `
-	total, err := models.GetCygxProductInteriorCount(condition, pars)
+	condition += ` AND art.publish_status = 1 AND article_id >= 16 `
+	total, err := models.GetCygxReportSelectionCount(condition, pars)
 	if err != nil {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取失败,Err:" + err.Error()
 		return
 	}
-	condition += "	ORDER BY art.publish_time DESC , art.product_interior_id DESC "
-	list, err := models.GetCygxProductInteriorList(condition, pars, startSize, pageSize)
+	condition += "	ORDER BY art.publish_date  DESC "
+	list, err := models.GetReportSelectionList(condition, pars, startSize, pageSize)
 	if err != nil {
 		br.Msg = "获取失败"
 		br.ErrMsg = "获取失败,Err:" + err.Error()
 		return
 	}
+
+	var articleIdArr []int
+	for _, v := range list {
+		v.PublishDate = utils.TimeRemoveHms2(v.PublishDate)
+		articleIdArr = append(articleIdArr, v.ArticleId)
+	}
+
+	lenarticleIdArr := len(articleIdArr)
+	maplabel := make(map[int]string)
+	if lenarticleIdArr > 0 {
+		condition = ""
+		pars = make([]interface{}, 0)
+		condition = ` AND is_new = 1  AND article_id IN (` + utils.GetOrmInReplace(lenarticleIdArr) + `)`
+		pars = append(pars, articleIdArr)
+		listLog, err := models.GetCygxReportSelectionLog(condition, pars, 0, 9999)
+		if err != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取失败,GetCygxReportSelectionLogErr:" + err.Error()
+			return
+		}
+		for _, v := range listLog {
+			maplabel[v.ArticleId] += v.SubjectName + ","
+		}
+	}
 	for _, v := range list {
-		v.PublishTime = utils.TimeRemoveHms(v.PublishTime)
+		v.SubjectName = strings.TrimRight(maplabel[v.ArticleId], ",")
 	}
 	page := paging.GetPaging(currentIndex, pageSize, total)
 	resp.List = list

+ 34 - 0
controllers/user.go

@@ -1774,3 +1774,37 @@ func (this *UserController) Tracking() {
 	br.Ret = 200
 	br.Success = true
 }
+
+// @Title 未付费申请试用详情
+// @Description 未付费申请试用详情接口
+// @Param   ApplyRecordId    query   int true       "申请ID"
+// @Success 200 {object} models.ArticleCollectListResp
+// @Success 200
+// @router /apply/detail [get]
+func (this *UserController) ApplyDetail() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+	resp := new(models.CygxApplyRecordResp)
+	applyRecordId, _ := this.GetInt("ApplyRecordId")
+	detail, err := models.GetCygxApplyRecordById(applyRecordId)
+	if err != nil {
+		br.Msg = "获取数据失败"
+		br.ErrMsg = "获取数据失败,Err:" + err.Error()
+		return
+	}
+	resp.Detail = detail
+	br.Msg = "申请成功!"
+	br.Ret = 200
+	br.Success = true
+	br.Data = resp
+}

+ 21 - 7
models/apply_record.go

@@ -6,13 +6,15 @@ import (
 )
 
 type CygxApplyRecord struct {
-	ApplyRecordId   int       `orm:"column(apply_record_id);pk" description:"申请试用id"`
-	BusinessCardUrl string    `description:"名片地址"`
-	RealName        string    `description:"姓名"`
-	CompanyName     string    `description:"公司名称"`
-	Mobile          string    `description:"手机号"`
-	CreateTime      time.Time `description:"创建时间"`
-	ApplyMethod     int       `description:"1:已付费客户申请试用,2:非客户申请试用"`
+	ApplyRecordId    int       `orm:"column(apply_record_id);pk" description:"申请试用id"`
+	BusinessCardUrl  string    `description:"名片地址"`
+	RealName         string    `description:"姓名"`
+	CompanyName      string    `description:"公司名称"`
+	CompanyNamePay   string    `description:"公司名称"`
+	Mobile           string    `description:"手机号"`
+	CreateTime       time.Time `description:"创建时间"`
+	ApplyMethod      int       `description:"1:已付费客户申请试用,2:非客户申请试用"`
+	RegisterPlatform int       `description:"来源 1小程序,2:网页"`
 }
 
 func AddApplyRecord(item *ApplyTryReq, mobile, companyNamePay string, userId, companyIdPay, CompanyIdType int) (err error) {
@@ -52,3 +54,15 @@ func GetApplyRecordCount(userId int) (count int, err error) {
 	err = o.Raw(sql, userId).QueryRow(&count)
 	return
 }
+
+// 通过纪要ID获取详情
+func GetCygxApplyRecordById(applyRecordId int) (item *CygxApplyRecord, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_apply_record  WHERE apply_record_id=?  `
+	err = o.Raw(sql, applyRecordId).QueryRow(&item)
+	return
+}
+
+type CygxApplyRecordResp struct {
+	Detail *CygxApplyRecord
+}

+ 24 - 17
models/report_selection.go

@@ -3,7 +3,6 @@ package models
 import (
 	"github.com/beego/beego/v2/client/orm"
 	"github.com/rdlucklib/rdluck_tools/paging"
-	"time"
 )
 
 type CygxReportSelectionRep struct {
@@ -16,6 +15,7 @@ type CygxReportSelectionRep struct {
 	UpdateDescription string `description:"更新说明"`
 	IsRed             bool   `description:"是否标记红点"`
 	ReadNum           int    `description:"阅读次数"`
+	SubjectName       string `description:"标的名称"`
 }
 
 type CygxReportSelectionListPublicRep struct {
@@ -100,6 +100,29 @@ func GetCygxReportSelectionPublic(condition, tbdb string, pars []interface{}) (c
 	return
 }
 
+// 获取数量
+func GetCygxReportSelectionCount(condition string, pars []interface{}) (count int, err error) {
+	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_report_selection as art WHERE 1= 1 AND art.publish_status = 1   `
+	if condition != "" {
+		sqlCount += condition
+	}
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, pars).QueryRow(&count)
+	return
+}
+
+// 列表
+func GetReportSelectionList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxReportSelectionRep, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_report_selection  as art WHERE 1= 1 AND art.publish_status = 1  `
+	if condition != "" {
+		sql += condition
+	}
+	sql += `   LIMIT ?,?`
+	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	return
+}
+
 // 通过ID获取详情
 func GetCygxReportSelectionInfoById(articleId int) (item *DetailCygxReportSelectionRep, err error) {
 	o := orm.NewOrm()
@@ -140,22 +163,6 @@ func GetReportSelectionListHome(condition, tbdb string, pars []interface{}, star
 	return
 }
 
-type CygxReportSelectionLog struct {
-	ArticleSunId           int       `description:"子级报告id"`
-	ArticleId              int       `description:"父级报告Id"`
-	ChartPermissionId      int       `description:"行业ID"`
-	PermissionName         string    `description:"行业ID"`
-	CreateTime             time.Time `description:"创建时间"`
-	Body                   string    `description:"内容"`
-	IndustrialSubjectId    int       `description:"标的ID"`
-	IndustrialManagementId string    `description:"产业资源包Id  多个用 , 隔开"`
-	SubjectName            string    `description:"标的名称"`
-	IcoLink                string    `orm:"column(image_url)"description:"图标链接"`
-	CompanyLabel           []string  `description:"公司标签"`
-	Label                  string    `description:"公司标签"`
-	OverviewArticleId      int       `description:"综述报告Id"`
-}
-
 // 列表
 func GetReportSelectionlogListAll(articleId int) (items []*CygxReportSelectionLog, err error) {
 	o := orm.NewOrm()

+ 34 - 0
models/report_selection_log.go

@@ -0,0 +1,34 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxReportSelectionLog struct {
+	ArticleSunId           int       `description:"子级报告id"`
+	ArticleId              int       `description:"父级报告Id"`
+	ChartPermissionId      int       `description:"行业ID"`
+	PermissionName         string    `description:"行业ID"`
+	CreateTime             time.Time `description:"创建时间"`
+	Body                   string    `description:"内容"`
+	IndustrialSubjectId    int       `description:"标的ID"`
+	IndustrialManagementId string    `description:"产业资源包Id  多个用 , 隔开"`
+	SubjectName            string    `description:"标的名称"`
+	IcoLink                string    `orm:"column(image_url)"description:"图标链接"`
+	CompanyLabel           []string  `description:"公司标签"`
+	Label                  string    `description:"公司标签"`
+	OverviewArticleId      int       `description:"综述报告Id"`
+}
+
+// 列表
+func GetCygxReportSelectionLog(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxReportSelectionLog, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_report_selection_log as art WHERE 1= 1 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` LIMIT ?,?  `
+	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	return
+}

+ 18 - 0
routers/commentsRouter.go

@@ -1087,6 +1087,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportSelectionController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ReportSelectionController"],
+        beego.ControllerComments{
+            Method: "List",
+            Router: `/list`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ResearchController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ResearchController"],
         beego.ControllerComments{
             Method: "ArticleHotList",
@@ -1267,6 +1276,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:UserController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:UserController"],
+        beego.ControllerComments{
+            Method: "ApplyDetail",
+            Router: `/apply/detail`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:UserController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:UserController"],
         beego.ControllerComments{
             Method: "ApplyTryOut",