Browse Source

Merge branch 'master' into yb/5.0

hsun 2 years ago
parent
commit
71630e7c1d

+ 633 - 0
controller/pc/pc.go

@@ -0,0 +1,633 @@
+package pc
+
+import (
+	"errors"
+	"fmt"
+	"github.com/gin-gonic/gin"
+	"hongze/hongze_yb/controller/response"
+	pcModels "hongze/hongze_yb/models/response/pc"
+	"hongze/hongze_yb/models/tables/customer_comment"
+	"hongze/hongze_yb/models/tables/rddp/classify"
+	"hongze/hongze_yb/models/tables/rddp/report"
+	"hongze/hongze_yb/models/tables/rddp/report_chapter"
+	"hongze/hongze_yb/models/tables/rddp/session"
+	"hongze/hongze_yb/models/tables/wx_user_log"
+	"hongze/hongze_yb/models/tables/yb_activity"
+	"hongze/hongze_yb/models/tables/yb_pc_suncode"
+	"hongze/hongze_yb/services"
+	"hongze/hongze_yb/services/pc"
+	userService "hongze/hongze_yb/services/user"
+	"hongze/hongze_yb/services/wechat"
+	"hongze/hongze_yb/utils"
+	"strconv"
+	"time"
+)
+
+// LatestNews 研报首页最新资讯
+func LatestNews(c *gin.Context) {
+	reqChartPermissionId := c.DefaultQuery("chart_permission_id", "")
+	if reqChartPermissionId == "" {
+		response.Fail("请输入权限ID", c)
+		return
+	}
+	chartPermissionId, err := strconv.Atoi(reqChartPermissionId)
+	if err != nil {
+		response.Fail("权限ID格式错误", c)
+		return
+	}
+	userinfo := userService.GetInfoByClaims(c)
+
+	list, err := pc.GetLatestReportList(userinfo, chartPermissionId)
+	if err != nil {
+		response.Fail("获取报告失败", c)
+		return
+	}
+
+	//recommendList, err := pcModels.GetLatestReportList()
+	//if err != nil {
+	//	response.Fail("获取报告详情失败"+err.Error(), c)
+	//	return
+	//}
+
+	response.OkData("查询成功", list, c)
+	return
+}
+
+// Banner 上新公告banner图
+func Banner(c *gin.Context) {
+	var resp pcModels.LatestReleaseResp
+	activityItem, err := yb_activity.GetLatestActivity()
+	if err != nil {
+		response.Fail(err.Error(), c)
+		return
+	}
+	reportItem, err := report.GetLatestReport()
+	if err != nil {
+		response.Fail(err.Error(), c)
+		return
+	}
+	imgMap := map[string]string{
+		"晨报":      utils.ALIYUN_YBIMG_HOST + "day.png",
+		"周报":      utils.ALIYUN_YBIMG_HOST + "week.png",
+		"双周报":     utils.ALIYUN_YBIMG_HOST + "two_week.png",
+		"月报":      utils.ALIYUN_YBIMG_HOST + "month.png",
+		"草根调研":    utils.ALIYUN_YBIMG_HOST + "cgdy.png",
+		"需求报告":    utils.ALIYUN_YBIMG_HOST + "xqbg.png",
+		"宏观报告":    utils.ALIYUN_YBIMG_HOST + "hgbg.png",
+		"日度点评":    utils.ALIYUN_YBIMG_HOST + "rddp.png",
+		"数据点评":    utils.ALIYUN_YBIMG_HOST + "sjdp.png",
+		"碳市场价格周报": utils.ALIYUN_YBIMG_HOST + "coal.png",
+		"行业调研":    utils.ALIYUN_YBIMG_HOST + "hydy.png",
+		"百家谈":     utils.ALIYUN_YBIMG_HOST + "bjt.png",
+		"会议纪要":    utils.ALIYUN_YBIMG_HOST + "hyjy.png",
+		"大事点评":    utils.ALIYUN_YBIMG_HOST + "dsdp.png",
+		"年报合集":    utils.ALIYUN_YBIMG_HOST + "nbhj.png",
+	}
+	if activityItem.CreateTime.Before(reportItem.PublishTime) {
+		resp.ActivityOrReport = 1
+		resp.ReportId = reportItem.ReportId
+		resp.ClassifyIdSecond = reportItem.ClassifyIdSecond
+		resp.ImgUrl = imgMap[reportItem.ClassifyNameFirst]
+	} else {
+		resp.ActivityOrReport = 0
+		resp.Activity = activityItem
+		resp.ImgUrl = utils.ALIYUN_YBIMG_HOST + "activity.png"
+	}
+
+	response.OkData("查询成功", resp, c)
+	return
+}
+
+// LatestRelease 上新公告
+func LatestRelease(c *gin.Context) {
+	classifyIdString := c.DefaultQuery("ClassifyId", "")
+	if classifyIdString == "" {
+		response.Fail("请输入classifyId", c)
+		return
+	}
+
+	classifyId, err := strconv.Atoi(classifyIdString)
+	if err != nil {
+		response.Fail("请输入正确classifyId", c)
+		return
+	}
+	classifyInfo, err := classify.GetByClassifyId(classifyId)
+	if err != nil {
+		response.Fail("分类查询出错", c)
+		return
+	}
+
+	response.OkData("查询成功", classifyInfo, c)
+	return
+}
+
+// ClassifyDetail 专栏详情
+func ClassifyDetail(c *gin.Context) {
+	reqClassifyIdSecond := c.DefaultQuery("classify_id_second", "")
+	if reqClassifyIdSecond == "" {
+		response.Fail("请输入二级分类标识", c)
+		return
+	}
+
+	classifyIdSecond, err := strconv.Atoi(reqClassifyIdSecond)
+	if err != nil {
+		response.Fail("请输入正确的二级分类标识", c)
+		return
+	}
+	userinfo := userService.GetInfoByClaims(c)
+
+	detail, err := pc.GetClassifyDetail(userinfo, classifyIdSecond)
+	if err != nil {
+		response.Fail(err.Error(), c)
+		return
+	}
+	response.OkData("查询成功", detail, c)
+	return
+}
+
+// ClassifyDetailBanner 专栏详情banner图
+func ClassifyDetailBanner(c *gin.Context) {
+	reqReportId := c.DefaultQuery("reportId", "")
+	classifyName := c.DefaultQuery("classify_name_first", "")
+	if reqReportId == "" {
+		response.Fail("请输入二级分类标识", c)
+		return
+	}
+	reportId, err := strconv.Atoi(reqReportId)
+	if err != nil {
+		response.Fail("报告ID格式有误", c)
+		return
+	}
+
+	var bannerResp *pcModels.DetailBannerResp
+	if classifyName == "周报" || classifyName == "晨报" {
+		chapterItem, err := report_chapter.GetLatestChapterByClassifyName(classifyName)
+		if err != nil {
+			response.Fail("查询最新一期晨周报失败"+err.Error(), c)
+			return
+		}
+		resp := &pcModels.DetailBannerResp{
+			ReportId:          chapterItem.ReportId,
+			ClassifyNameFirst: chapterItem.ClassifyNameFirst,
+			ClassifyIdFirst:   chapterItem.ClassifyIdFirst,
+			Stage:             chapterItem.Stage,
+			ImgUrl:            "",
+			Type:              "报告合集",
+		}
+		bannerResp = resp
+	} else {
+		reportInfo, err := report.GetByReportId(reportId)
+		if err != nil {
+			response.Fail("报告查询出错", c)
+			return
+		}
+		if reportInfo.Id == 0 {
+			response.Fail("报告不存在", c)
+			return
+		}
+
+		if reportInfo.State != 2 {
+			response.Fail("报告未发布", c)
+			return
+		}
+
+		reportItem, err := report.GetLatestReportByClassifyName(classifyName, reportInfo.ClassifyIdSecond)
+		if err != nil {
+			response.Fail("获取报告详情失败"+err.Error(), c)
+			return
+		}
+		resp := &pcModels.DetailBannerResp{
+			ReportId:           reportItem.ReportId,
+			Stage:              reportItem.Stage,
+			VipTitle:           reportItem.VipTitle,
+			Author:             reportItem.Author,
+			ReportAuthor:       reportItem.ReportAuthor,
+			ImgUrl:             "",
+			ClassifyNameFirst:  reportItem.ClassifyNameFirst,
+			ClassifyIdFirst:    reportItem.ClassifyIdFirst,
+			ClassifyNameSecond: reportItem.ClassifyNameSecond,
+			ClassifyIdSecond:   reportItem.ClassifyIdSecond,
+		}
+		if classifyName == "月报" || classifyName == "双周报" || classifyName == "会议纪要" || classifyName == "大事点评" || classifyName == "年报合集" {
+			resp.Type = "报告合集"
+		} else {
+			resp.Type = "专栏详情"
+		}
+		bannerResp = resp
+	}
+	//有人的用人的底图,和上新公告图片不完全一样
+	firstNameMap := map[string]string{
+		"晨报":  utils.ALIYUN_YBIMG_HOST + "day.png",
+		"周报":  utils.ALIYUN_YBIMG_HOST + "week.png",
+		"双周报": utils.ALIYUN_YBIMG_HOST + "two_week.png",
+		"月报":  utils.ALIYUN_YBIMG_HOST + "month.png",
+
+		"会议纪要": utils.ALIYUN_YBIMG_HOST + "hyjy.png",
+		"大事点评": utils.ALIYUN_YBIMG_HOST + "dsdp.png",
+		"年报合集": utils.ALIYUN_YBIMG_HOST + "nbhj.png",
+
+		//"草根调研":    utils.ALIYUN_YBIMG_HOST + "hy.png",
+		//"需求报告":    utils.ALIYUN_YBIMG_HOST + "lxt.png",
+		//"碳市场价格周报": utils.ALIYUN_YBIMG_HOST + "sjx.png",
+		//"行业调研":    utils.ALIYUN_YBIMG_HOST + "qp.png",
+	}
+	//secondNameMap := map[string]string{
+	//	//宏观报告
+	//	"宏观周期观察":     utils.ALIYUN_YBIMG_HOST + "gx.png",
+	//	"房地产市场跟踪":    utils.ALIYUN_YBIMG_HOST + "gx.png",
+	//	"货币政策跟踪":     utils.ALIYUN_YBIMG_HOST + "gx.png",
+	//	"全球宏观经济周度回顾": utils.ALIYUN_YBIMG_HOST + "ldb.png",
+	//	"宏观点评":       utils.ALIYUN_YBIMG_HOST + "zzh.png",
+	//	//日度点评
+	//	"知白守黑日评":    utils.ALIYUN_YBIMG_HOST + "wxy.png",
+	//	"有声有色日度闲":   utils.ALIYUN_YBIMG_HOST + "qp.png",
+	//	"化里化外日评":    utils.ALIYUN_YBIMG_HOST + "qmz.png",
+	//	"每日经济数据备忘录": utils.ALIYUN_YBIMG_HOST + "ldb.png",
+	//	"股债日评":      utils.ALIYUN_YBIMG_HOST + "zzh.png",
+	//	"贵金属复盘":     utils.ALIYUN_YBIMG_HOST + "hx.png",
+	//	//数据点评
+	//	"钢材周度数据点评":   utils.ALIYUN_YBIMG_HOST + "wxy.png",
+	//	"甲醇开工数据点评":   utils.ALIYUN_YBIMG_HOST + "lqx.png",
+	//	"短纤数据点评":     utils.ALIYUN_YBIMG_HOST + "zyy.png",
+	//	"玻璃数据点评":     utils.ALIYUN_YBIMG_HOST + "gwy.png",
+	//	"聚烯烃数据点评":    utils.ALIYUN_YBIMG_HOST + "lqx.png",
+	//	"铜行业数据点评":    utils.ALIYUN_YBIMG_HOST + "yf.png",
+	//	"国际钢材市场数据点评": utils.ALIYUN_YBIMG_HOST + "bx.png",
+	//	"废钢周度数据点评":   utils.ALIYUN_YBIMG_HOST + "bx.png",
+	//	"PP数据点评":     utils.ALIYUN_YBIMG_HOST + "lqx.png",
+	//	"PVC数据点评":    utils.ALIYUN_YBIMG_HOST + "lyx.png",
+	//	"BOPP数据点评":   utils.ALIYUN_YBIMG_HOST + "lqx.png",
+	//	"塑编数据点评":     utils.ALIYUN_YBIMG_HOST + "lqx.png",
+	//	"铁矿库存数据点评":   utils.ALIYUN_YBIMG_HOST + "hk.png",
+	//	"宏观数据点评":     utils.ALIYUN_YBIMG_HOST + "zzh.png",
+	//	"铝数据点评":      utils.ALIYUN_YBIMG_HOST + "yf.png",
+	//	"甲醇库存数据点评":   utils.ALIYUN_YBIMG_HOST + "lqx.png",
+	//	"玻璃纯碱数据点评":   utils.ALIYUN_YBIMG_HOST + "gwy.png",
+	//	"乙二醇数据点评":    utils.ALIYUN_YBIMG_HOST + "zyy.png",
+	//	"纯碱数据点评":     utils.ALIYUN_YBIMG_HOST + "gwy.png",
+	//	"COVID-19跟踪": utils.ALIYUN_YBIMG_HOST + "lxt.png",
+	//	"双焦数据点评":     utils.ALIYUN_YBIMG_HOST + "zs.png",
+	//	"苯乙烯库存数据点评":  utils.ALIYUN_YBIMG_HOST + "cy.png",
+	//	"苯乙烯数据点评":    utils.ALIYUN_YBIMG_HOST + "cy.png",
+	//	"苯乙烯简评":      utils.ALIYUN_YBIMG_HOST + "cy.png",
+	//	"EIA天然气库存点评": utils.ALIYUN_YBIMG_HOST + "wyy.png",
+	//	"美国油气钻机数据点评": utils.ALIYUN_YBIMG_HOST + "wyy.png",
+	//	"OPEC+产量点评":  utils.ALIYUN_YBIMG_HOST + "hyy.png",
+	//	"原油船期数数据跟踪":  utils.ALIYUN_YBIMG_HOST + "wyy.png",
+	//	"EIA原油库存点评":  utils.ALIYUN_YBIMG_HOST + "hyy.png",
+	//	"苯乙烯开工数据点评":  utils.ALIYUN_YBIMG_HOST + "cy.png",
+	//	"聚酯数据点评":     utils.ALIYUN_YBIMG_HOST + "qc.png",
+	//	"铁矿航运数据点评":   utils.ALIYUN_YBIMG_HOST + "hk.png",
+	//	//百家谈
+	//	"能化百家谈": utils.ALIYUN_YBIMG_HOST + "qmz.png",
+	//	"有色百家谈": utils.ALIYUN_YBIMG_HOST + "qp.png",
+	//	"黑色百家谈": utils.ALIYUN_YBIMG_HOST + "wxy.png",
+	//}
+	authorMap := map[string]string{
+		"白昕":  utils.ALIYUN_YBIMG_HOST + "bx.png",
+		"曹阳":  utils.ALIYUN_YBIMG_HOST + "cy.png",
+		"曾硕":  utils.ALIYUN_YBIMG_HOST + "zs.png",
+		"曾滢月": utils.ALIYUN_YBIMG_HOST + "zyy.png",
+		"程品":  utils.ALIYUN_YBIMG_HOST + "cp.png",
+		"高雯宇": utils.ALIYUN_YBIMG_HOST + "gwy.png",
+		"高昕":  utils.ALIYUN_YBIMG_HOST + "gx.png",
+		"高吟":  utils.ALIYUN_YBIMG_HOST + "gy.png",
+		"陈聪聪": utils.ALIYUN_YBIMG_HOST + "ccc.png",
+		"何凯":  utils.ALIYUN_YBIMG_HOST + "hk.png",
+		"黄鑫":  utils.ALIYUN_YBIMG_HOST + "hx.png",
+		"黄逸赟": utils.ALIYUN_YBIMG_HOST + "hyy.png",
+		"黄溢":  utils.ALIYUN_YBIMG_HOST + "hy.png",
+		"李灵":  utils.ALIYUN_YBIMG_HOST + "ll.png",
+		"林秋馨": utils.ALIYUN_YBIMG_HOST + "lqx.png",
+		"刘鼎邦": utils.ALIYUN_YBIMG_HOST + "ldb.png",
+		"钱鹏":  utils.ALIYUN_YBIMG_HOST + "qp.png",
+		"刘艺羡": utils.ALIYUN_YBIMG_HOST + "lyx.png",
+		"戚明之": utils.ALIYUN_YBIMG_HOST + "qmz.png",
+		"秦钏":  utils.ALIYUN_YBIMG_HOST + "qc.png",
+		"施琪":  utils.ALIYUN_YBIMG_HOST + "sq.png",
+		"王存响": utils.ALIYUN_YBIMG_HOST + "wcx.png",
+		"王沛":  utils.ALIYUN_YBIMG_HOST + "wp.png",
+		"苏畅":  utils.ALIYUN_YBIMG_HOST + "sc.png",
+		"史瑾璇": utils.ALIYUN_YBIMG_HOST + "sjx.png",
+		"王亚丹": utils.ALIYUN_YBIMG_HOST + "wyd.png",
+		"虞风":  utils.ALIYUN_YBIMG_HOST + "yf.png",
+		"魏忻悦": utils.ALIYUN_YBIMG_HOST + "wxy.png",
+		"王艺滢": utils.ALIYUN_YBIMG_HOST + "wyy.png",
+		"姚昕泽": utils.ALIYUN_YBIMG_HOST + "yxz.png",
+		"章左昊": utils.ALIYUN_YBIMG_HOST + "zzh.png",
+		"李晓曈": utils.ALIYUN_YBIMG_HOST + "lxt.png",
+		"弘则FICC无锡调研团队": utils.ALIYUN_YBIMG_HOST + "qp.png",
+		"弘则能化组": utils.ALIYUN_YBIMG_HOST + "qmz.png",
+		"弘则有色团队": utils.ALIYUN_YBIMG_HOST + "qp.png",
+		"弘则黑色团队": utils.ALIYUN_YBIMG_HOST + "wxy.png",
+		"弘则宏观团队": utils.ALIYUN_YBIMG_HOST + "zzh.png",
+	}
+
+	if url, ok := firstNameMap[bannerResp.ClassifyNameFirst]; ok {
+		bannerResp.ImgUrl = url
+	} else if url, ok = authorMap[bannerResp.ReportAuthor]; ok {
+		bannerResp.ImgUrl = url
+	}
+	response.OkData("查询成功", bannerResp, c)
+	return
+}
+
+// Recommend 报告详情页更多推荐
+func Recommend(c *gin.Context) {
+	reqReportId := c.DefaultQuery("reportId", "")
+	classifyName := c.DefaultQuery("classify_name_first", "")
+	if reqReportId == "" {
+		response.Fail("请输入二级分类标识", c)
+		return
+	}
+	reportId, err := strconv.Atoi(reqReportId)
+	if err != nil {
+		response.Fail("报告ID格式有误", c)
+		return
+	}
+
+	var recommendResp []*pcModels.RecommendResp
+	if classifyName == "周报" || classifyName == "晨报" {
+		recommendList, err := report_chapter.GetWeekRecommendList(reportId, classifyName)
+		if err != nil {
+			response.Fail("获取报告详情失败"+err.Error(), c)
+			return
+		}
+		for _, chapter := range recommendList {
+			resp := &pcModels.RecommendResp{
+				ReportId:            chapter.ReportId,
+				ReportChapterID:     chapter.ReportChapterId,
+				Title:               chapter.Title,
+				Stage:               chapter.Stage,
+				ClassifyNameFirst:   chapter.ClassifyNameFirst,
+				ClassifySecondFirst: "",
+			}
+			recommendResp = append(recommendResp, resp)
+		}
+	} else {
+		reportInfo, err := report.GetByReportId(reportId)
+		if err != nil {
+			response.Fail("报告查询出错", c)
+			return
+		}
+		if reportInfo.Id == 0 {
+			response.Fail("报告不存在", c)
+			return
+		}
+
+		if reportInfo.State != 2 {
+			response.Fail("报告未发布", c)
+			return
+		}
+
+		reportType := 0
+		if reportInfo.ClassifyNameFirst == "权益研报" {
+			reportType = 1
+		} else {
+			reportType = 2
+		}
+
+		recommendList, err := pcModels.GetRecommendList(reportId, reportType, reportInfo.ClassifyIdSecond)
+		if err != nil {
+			response.Fail("获取报告详情失败"+err.Error(), c)
+			return
+		}
+		for _, chapter := range recommendList {
+			resp := &pcModels.RecommendResp{
+				ReportId:            chapter.Id,
+				ReportChapterID:     0,
+				Title:               chapter.Title,
+				Stage:               chapter.Stage,
+				ClassifyNameFirst:   chapter.ClassifyNameFirst,
+				ClassifySecondFirst: chapter.ClassifyNameSecond,
+			}
+			recommendResp = append(recommendResp, resp)
+		}
+	}
+	response.OkData("查询成功", recommendResp, c)
+	return
+}
+
+// ClassifyFirstList Ficc 菜单
+func ClassifyFirstList(c *gin.Context) {
+	userinfo := userService.GetInfoByClaims(c)
+
+	classList, err := pc.GetClassifyFirstList(userinfo)
+	if err != nil {
+		response.Fail(err.Error(), c)
+		return
+	}
+	response.OkData("查询成功", classList, c)
+	return
+}
+
+// CustomerComment 客户评价
+func CustomerComment(c *gin.Context) {
+	lists, err := customer_comment.GetCustomerComment()
+	if err != nil {
+		response.Fail(err.Error(), c)
+		return
+	}
+	response.OkData("查询成功", lists, c)
+	return
+}
+
+// GetSunCode 获取太阳码
+// @Tags 公共模块
+// @Summary  获取分享海报
+// @Description 获取分享海报
+// @Param	request	body services.SunCodeReq true "type json string"
+// @Success 200 {object} string "获取成功"
+// @failure 400 {string} string "获取失败"
+// @Router /pc/getSunCode [post]
+func GetSunCode(c *gin.Context) {
+	var req services.SunCodeReq
+	if c.ShouldBind(&req) != nil {
+		response.Fail("参数异常", c)
+		return
+	}
+
+	var sunCodeUrl string
+	//先查,查不到再去生成上传
+	item, err := yb_pc_suncode.GetYbPcSunCode(req.CodeScene, req.CodePage)
+	sunCodeUrl = item.SuncodeURL
+	if err != nil && err != utils.ErrNoRow {
+		response.Fail(err.Error(), c)
+		return
+	}
+
+	if sunCodeUrl == "" {
+		sunCodeUrl, err = services.PcCreateAndUploadSunCode(req.CodeScene, req.CodePage)
+		if err != nil {
+			response.Fail(err.Error(), c)
+			return
+		}
+	}
+
+	response.OkData("查询成功", sunCodeUrl, c)
+	return
+}
+
+// @Title pc端微信登录接口
+// @Description pc端微信登录接口
+// @Param   Code   query   string  true       "微信唯一编码code"
+// @Success 200 {object} models.WxLoginResp
+// @router /pc/login [get]
+func WechatLogin(c *gin.Context) {
+	var resp pcModels.LoginResp
+	var token string
+	var userId int
+	var isBind bool
+	code := c.DefaultQuery("Code", "")
+	if code == "" {
+		response.Fail("code参数错误", c)
+		return
+	}
+	item, err := wechat.PcWxGetUserOpenIdByCode(code)
+	if err != nil {
+		response.Fail(err.Error(), c)
+		return
+	}
+	fmt.Println("token:", item.AccessToken)
+	fmt.Println("token:", item.Errmsg)
+	fmt.Println("token:", item.Errcode)
+	if item.Errcode != 0 {
+		response.Fail(err.Error(), c)
+		return
+	}
+
+	openId := item.Openid
+	//wxUserInfo, err := wx_app.GetSession(code)
+	//if err != nil {
+	//	response.Fail("获取失败,Err:"+err.Error(), c)
+	//	return
+	//}
+
+	//获取用户信息
+	wxPcUserInfo, err := wechat.PcWxGetUserInfo(openId, item.AccessToken)
+	if err != nil {
+		response.Fail(err.Error(), c)
+		return
+	}
+	if wxPcUserInfo.Errcode != 0 {
+		response.Fail(err.Error(), c)
+		return
+	}
+
+	unionId := item.Unionid
+	//sessionKey := wxUserInfo.SessionKey
+	//needUpdateSessionKey := true //是否更新sessionKey
+
+QUERY_WX_USER:
+	wxUser, wxUserErr := userService.GetWxUserItemByOpenId(openId)
+	if wxUserErr == userService.ERR_NO_USER_RECORD { //没有用户openid记录
+		_, recordErr := userService.AddUserRecord(openId, unionId, "", "", "", "", "", "", "", 3, 0, 0)
+		//如果插入失败,那么直接将错误信息返回
+		if recordErr != nil {
+			err = recordErr
+			return
+		}
+		//needUpdateSessionKey = false //因为是新增用户微信信息,所以不需要更新sessionKey的数据了
+
+		//插入成功后,需要重新查询该用户,并进入下面的逻辑
+		goto QUERY_WX_USER
+	} else if wxUserErr == userService.ERR_USER_NOT_BIND {
+		// 未绑定则去查询unionId是否已经绑定了用户(其他平台,不区分平台),有相应的手机号邮箱信息则自动绑定
+		platformUser, platformErr := userService.GetFirstWxUserItemByUnionId(unionId)
+		if platformErr == nil {
+			// 当公众号用户存在时
+			if platformUser.Mobile != "" || platformUser.Email != "" {
+				// 有手机号或邮箱则绑定信息则自动绑定并新增wx_user
+				countryCode := 0
+				if platformUser.CountryCode != "" {
+					countryCode, _ = strconv.Atoi(platformUser.CountryCode)
+				}
+				tempToken, tempUser, tempErr, errMsg := userService.BindWxUser(openId, platformUser.Mobile, platformUser.Email, "", 3, countryCode, 1)
+				if tempErr != nil {
+					err = errors.New("自动绑定公众号用户失败,Err:" + tempErr.Error() + ", errMsg:" + errMsg)
+					return
+				}
+				token = tempToken
+				userId = int(tempUser.UserID)
+				isBind = true
+				return
+			}
+		}
+	} else if wxUserErr != nil {
+		err = wxUserErr
+		return
+	}
+
+	//更新微信用户的sessionKey
+	//if needUpdateSessionKey {
+	//	_ = user_record.ModifySessionKeyByOpenid(openId, sessionKey)
+	//}
+
+	// 如果已经登录注册绑定的情况下/或者首次登录且为弘则研究公众号用户
+	if wxUserErr == nil {
+		userId = int(wxUser.UserID)
+
+		// 如果账户有绑定了手机号或者邮箱,那么标记为已绑定
+		if wxUser.Mobile != "" || wxUser.Email != "" {
+			isBind = true
+		}
+	}
+
+	//获取登录token
+	tokenItem, tokenErr := session.GetTokenByOpenId(openId)
+	if tokenErr != nil && tokenErr != utils.ErrNoRow {
+		err = errors.New("登录失败,获取token失败:" + tokenErr.Error())
+		return
+	}
+	fmt.Println("AccessToken:", item.AccessToken)
+	fmt.Println("tokenItem:", tokenItem.AccessToken)
+	if tokenErr != nil && tokenErr == utils.ErrNoRow {
+		timeUnix := time.Now().Unix()
+		timeUnixStr := strconv.FormatInt(timeUnix, 10)
+		token = utils.MD5(openId) + utils.MD5(timeUnixStr)
+		fmt.Println("token:", tokenItem.AccessToken)
+		//新增session
+		{
+			sessionItem := &session.Session{
+				OpenID:          openId,
+				UserID:          int64(userId),
+				CreatedTime:     time.Now(),
+				LastUpdatedTime: time.Now(),
+				ExpireTime:      time.Now().AddDate(0, 3, 0),
+				AccessToken:     token,
+			}
+			sessionErr := sessionItem.Create()
+			if err != nil {
+				err = errors.New("登录失败,新增用户session信息失败:" + sessionErr.Error())
+				return
+			}
+		}
+	} else {
+		token = tokenItem.AccessToken
+		//如果联系人编号不为空,且联系人编号与session里面的联系人编号不一致的时候,需要做session变更
+		//if userId > 0 && tokenItem.UserID != int64(userId) {
+		//	_ = tokenItem.UpdateSession(int64(userId), time.Now().AddDate(0, 1, 0))
+		//}
+
+		//if userId > 0 {
+		//}
+		_ = tokenItem.UpdateSession(int64(userId), time.Now().AddDate(0, 1, 0))
+	}
+
+	//新增登录日志
+	{
+		loginLog := &wx_user_log.WxUserLog{
+			UserID:     userId,
+			OpenID:     openId,
+			UnionID:    unionId,
+			CreateTime: time.Now(),
+			Handle:     "yb_login",
+			Remark:     token,
+		}
+		go loginLog.Create()
+	}
+	resp.IsBind = isBind
+	resp.Token = token
+	response.OkData("查询成功", resp, c)
+	return
+}

+ 2 - 0
init_serve/router.go

@@ -54,5 +54,7 @@ func InitRouter() (r *gin.Engine) {
 	routers.InitCommunity(r)
 	// 设置静态文件夹件路径
 	r.StaticFS("/static", http.Dir("./static"))
+	//pc相关路由
+	routers.InitPc(r)
 	return
 }

+ 62 - 0
models/response/pc/classify.go

@@ -0,0 +1,62 @@
+package pc
+
+import (
+	"hongze/hongze_yb/models/response"
+	"hongze/hongze_yb/models/tables/rddp/customer_comment"
+	"hongze/hongze_yb/models/tables/yb_activity"
+)
+
+type ClassifyListItem struct {
+	ClassifyIdSecond   int    `json:"classify_id_second"`
+	ClassifyNameSecond string `json:"classify_name_second"`
+	ParentId           int    `json:"parent_id"`
+	ReportAuthor       string `json:"report_author"`
+	AuthorDescript     string `json:"author_descript"`
+	HomeImgUrl         string `json:"home_img_url"`
+	Stage              int    `description:"期数" json:"stage"`
+	ProductName        string `json:"product_name"`
+}
+
+type ClassifyDetail struct {
+	ClassifyListItem
+	Comments        []*customer_comment.CustomerComment
+	AvatarImgUrl    string                        `json:"avatar_img_url"`
+	Abstract        string                        `json:"abstract"`
+	Descript        string                        `json:"descript"`
+	PermissionCheck *response.PermissionCheckInfo `json:"permission_check"`
+	AuthOk          bool                          `json:"auth_ok"`
+	VipTitle        string                        `json:"vip_title"'`
+}
+
+type ClassifyFirstListItem struct {
+	ClassifyIdFirst    int    `description:"一级分类id" json:"classify_id_first"`
+	Latest             int    `description:"最新更新" json:"latest"`
+	ClassifyIdSecond   int    `json:"classify_id_second"`
+	ClassifyNameFirst  string `description:"一级分类名称" json:"classify_name_first"`
+	ClassifyNameSecond string `json:"classify_name_second"`
+	BackImgUrl         string `json:"back_img_url"`
+	Sort               int    `json:"sort"`
+	RedirectType       int    `description:"跳转页面类型:1,专栏列表,2报告列表,3专栏详情" json:"redirect_type"`
+}
+
+type ClassifyFirstList []*ClassifyFirstListItem
+
+func (c ClassifyFirstList) Len() int {
+	return len(c)
+}
+
+func (c ClassifyFirstList) Less(i, j int) bool {
+	return c[i].Sort < c[j].Sort
+}
+
+func (c ClassifyFirstList) Swap(i, j int) {
+	c[i], c[j] = c[j], c[i]
+}
+
+type LatestReleaseResp struct {
+	ActivityOrReport int `description:"活动或专栏:0,活动,1,专栏" json:"redirect_type"`
+	Activity         *yb_activity.YbActivity
+	ReportId         int
+	ClassifyIdSecond   int
+	ImgUrl           string
+}

+ 123 - 0
models/response/pc/report.go

@@ -0,0 +1,123 @@
+package pc
+
+import (
+	"fmt"
+	"hongze/hongze_yb/global"
+	"time"
+)
+
+type Report struct {
+	Id                 int       `description:"报告Id"`
+	AddType            int       `description:"新增方式:1:新增报告,2:继承报告"`
+	ClassifyIdFirst    int       `description:"一级分类id"`
+	ClassifyNameFirst  string    `description:"一级分类名称"`
+	ClassifyIdSecond   int       `description:"二级分类id"`
+	ClassifyNameSecond string    `description:"二级分类名称"`
+	Title              string    `description:"标题"`
+	Abstract           string    `description:"摘要"`
+	Author             string    `description:"作者"`
+	Frequency          string    `description:"频度"`
+	CreateTime         string    `description:"创建时间"`
+	ModifyTime         time.Time `description:"修改时间"`
+	State              int       `description:"1:未发布,2:已发布"`
+	PublishTime        string    `description:"发布时间"`
+	Stage              int       `description:"期数"`
+	MsgIsSend          int       `description:"消息是否已发送,0:否,1:是"`
+	Content            string    `description:"内容"`
+	VideoUrl           string    `description:"音频文件URL"`
+	VideoName          string    `description:"音频文件名称"`
+	VideoPlaySeconds   string    `description:"音频播放时长"`
+	VideoSize          string    `description:"音频文件大小,单位M"`
+	ContentSub         string    `description:"内容前两个章节"`
+	ClassifyName       string    `description:"分类名称"`
+	HasPermission      int       `description:"报告权限:0:无权限,1:有权限"`
+	TitleType          string    `description:"标题类型,FICC或者权益"`
+}
+
+func GetLatestReportList() (items []*Report, err error) {
+	sql := `SELECT * FROM report WHERE state=2 ORDER BY publish_time DESC LIMIT 3 `
+	err = global.MYSQL["rddp"].Raw(sql).Scan(&items).Error
+	return
+}
+
+func GetRecommendList(reportId, reportType, secondId int) (items []*Report, err error) {
+	sql := `SELECT * FROM report WHERE state=2 AND id<> %v AND classify_id_second=%v `
+	sql = fmt.Sprintf(sql, reportId, secondId)
+	if reportType == 1 {
+		sql += ` AND classify_name_first='权益研报' `
+	} else {
+		sql += ` AND classify_name_first<>'权益研报' `
+	}
+	sql += ` ORDER BY publish_time DESC LIMIT 3`
+	err = global.MYSQL["rddp"].Raw(sql).Scan(&items).Error
+	return
+}
+
+type LatestReport struct {
+	Id                 int       `orm:"column(id)" description:"报告Id" json:"_"`
+	ClassifyNameFirst  string    `description:"一级分类名称" json:"classify_name_first"`
+	ClassifyNameSecond string    `description:"二级分类名称" json:"classify_name_second"`
+	ClassifyIdSecond   int       `description:"二级分类id" json:"classify_id_second"`
+	Title              string    `description:"标题" json:"title"`
+	State              int       `description:"1:未发布,2:已发布" json:"state"`
+	PublishTime        time.Time `description:"发布时间" json:"publish_time"`
+	Stage              int       `description:"期数" json:"stage"`
+	ReportId           int
+}
+
+func GetLatestStage(classifyNames []string) (items []*LatestReport, err error) {
+	sql := `SELECT * FROM(SELECT DISTINCT
+	classify_name_first,
+	id,
+	title,
+	state,
+	publish_time,
+	stage 
+FROM
+	report 
+WHERE
+	classify_name_first IN  (?) 
+AND state = 2 
+ORDER BY
+	publish_time DESC) t GROUP BY t.classify_name_first`
+	err = global.MYSQL["rddp"].Raw(sql, classifyNames).Scan(&items).Error
+	return
+}
+
+type RecommendResp struct {
+	ReportId            int
+	ReportChapterID     int
+	Title               string
+	Stage               int
+	ClassifyNameFirst   string
+	ClassifySecondFirst string
+}
+
+type DetailBannerResp struct {
+	ReportId           int
+	Stage              int
+	VipTitle           string
+	Author             string
+	ReportAuthor       string
+	ImgUrl             string
+	ClassifyNameFirst  string
+	ClassifyIdFirst    int
+	ClassifyNameSecond string
+	ClassifyIdSecond   int
+	Type               string
+}
+
+type LatestReportBanner struct {
+	ReportId           int `orm:"column(id)" description:"报告Id" json:"reportId"`
+	ClassifyIdFirst    int
+	ClassifyIdSecond   int
+	ClassifyNameFirst  string    `description:"一级分类名称" json:"classify_name_first"`
+	ClassifyNameSecond string    `description:"二级分类名称" json:"classify_name_second"`
+	Title              string    `description:"标题" json:"title"`
+	State              int       `description:"1:未发布,2:已发布" json:"state"`
+	PublishTime        time.Time `description:"发布时间" json:"publish_time"`
+	Stage              int       `description:"期数" json:"stage"`
+	VipTitle           string
+	Author             string
+	ReportAuthor       string
+}

+ 31 - 0
models/response/pc/wechat.go

@@ -0,0 +1,31 @@
+package pc
+
+type WxAccessToken struct {
+	AccessToken  string `json:"access_token"`
+	ExpiresIn    int    `json:"expires_in"`
+	RefreshToken string `json:"refresh_token"`
+	Openid       string `json:"openid"`
+	Unionid      string `json:"unionid"`
+	Scope        string `json:"scope"`
+	Errcode      int    `json:"errcode"`
+	Errmsg       string `json:"errmsg"`
+}
+
+type WxUserInfo struct {
+	Openid     string `json:"openid"`
+	Nickname   string `json:"nickname"`
+	Sex        int    `json:"sex"`
+	Language   string `json:"language"`
+	City       string `json:"city"`
+	Province   string `json:"province"`
+	Country    string `json:"country"`
+	Headimgurl string `json:"headimgurl"`
+	Unionid    string `json:"unionid"`
+	Errcode    int    `json:"errcode"`
+	Errmsg     string `json:"errmsg"`
+}
+
+type LoginResp struct {
+	Token  string `json:"authorization"`
+	IsBind bool   `json:"is_bind"`
+}

+ 20 - 16
models/response/report.go

@@ -34,20 +34,22 @@ type ReportItem struct {
 	Author             string    `description:"作者" json:"author"`
 	Frequency          string    `description:"频度" json:"frequency"`
 	PublishTime        time.Time `description:"发布时间" json:"publish_time"`
-	Stage              int       `description:"期数" json:"stage"`
-	Content            string    `description:"内容" json:"content"`
-	VideoUrl           string    `description:"音频文件URL" json:"video_url"`
-	VideoName          string    `description:"音频文件名称" json:"video_name"`
-	VideoPlaySeconds   string    `description:"音频播放时长" json:"video_play_seconds"`
+	Stage              int    `description:"期数" json:"stage"`
+	Content            string `description:"内容" json:"content"`
+	VideoUrl           string `description:"音频文件URL" json:"video_url"`
+	VideoName          string `description:"音频文件名称" json:"video_name"`
+	VideoSize          string `description:"音频文件大小,单位M" json:"video_size"`
+	VideoPlaySeconds   string `description:"音频播放时长" json:"video_play_seconds"`
 	VideoImg           string    `description:"音频播放条的图片" json:"video_img"`
-	ContentSub         string    `description:"内容前两个章节" json:"content_sub"`
-	BannerUrl          string    `description:"详情页banner" json:"banner_url"`
+	ContentSub         string `description:"内容前两个章节" json:"content_sub"`
+	BannerUrl          string `description:"详情页banner" json:"banner_url"`
 }
 
 type ReportChapterItem struct {
 	ReportChapterId       int       `json:"report_chapter_id"`
 	ReportId              int       `json:"report_id"`
 	Title                 string    `json:"title"`
+	Abstract string `json:"abstract"`
 	TypeId                int       `json:"type_id"`
 	TypeName              string    `json:"type_name"`
 	Trend                 string    `json:"trend"`
@@ -67,18 +69,20 @@ type ReportChapterItem struct {
 }
 
 type ReportChapterDetail struct {
-	ReportChapterItem     *ReportChapterItem   `json:"report_chapter_item"`
-	PermissionCheck       *PermissionCheckInfo `json:"permission_check"`
-	ReportChapterMenuList []*ReportChapterMenu `json:"report_chapter_menu_list"`
-	AuthOk                bool                 `json:"auth_ok"`
+	ReportChapterItem      *ReportChapterItem      `json:"report_chapter_item"`
+	PermissionCheck        *PermissionCheckInfo    `json:"permission_check"`
+	ReportChapterMenuList  []*ReportChapterMenu    `json:"report_chapter_menu_list"`
+	AuthOk                 bool                    `json:"auth_ok"`
 }
 
 type ReportChapterMenu struct {
-	ReportChapterId        int    `json:"report_chapter_id"`
-	ReportId               int    `json:"report_id"`
-	ReportChapterTypeName  string `json:"report_chapter_type_name"`
-	ReportChapterTypeThumb string `json:"report_chapter_type_thumb"`
-	Sort                   int    `json:"sort"`
+	ReportChapterId    int    `json:"report_chapter_id"`
+	ReportId        int    `json:"report_id"`
+	ReportChapterTypeName   string       `json:"report_chapter_type_name"`
+	ReportChapterTypeThumb  string	    `json:"report_chapter_type_thumb"`
+	PcSelectedThumb  string	    `json:"pc_selected_thumb"`
+	PcUnselectedThumb  string	    `json:"pc_unselected_thumb"`
+	Sort             int  `json:"sort"`
 }
 
 type ReportListItem struct {

+ 14 - 0
models/tables/customer_comment/customer_comment.go

@@ -0,0 +1,14 @@
+package customer_comment
+
+type CustomerComment struct {
+	Id           int `orm:"customer_comment(id)" `
+	HeadImgUrl   string
+	CustomerName string
+	CompanyName  string
+	Comment      string
+}
+
+func (d *CustomerComment) TableName() string  {
+	return "customer_comment"
+}
+

+ 9 - 0
models/tables/customer_comment/query.go

@@ -0,0 +1,9 @@
+package customer_comment
+
+import "hongze/hongze_yb/global"
+
+func GetCustomerComment() (items []*CustomerComment, err error) {
+	sql := ` SELECT * FROM customer_comment `
+	err = global.MYSQL["rddp"].Raw(sql).Scan(&items).Error
+	return
+}

+ 3 - 3
models/tables/edb_data/query.go

@@ -15,7 +15,7 @@ func GetEdbDataTableName(source int) (tableName string) {
 		tableName = "edb_data_ths"
 	case utils.DATA_SOURCE_WIND:
 		tableName = "edb_data_wind"
-	case utils.DATA_SOURCE_PB:
+	case utils.DATA_SOURCE_PB, utils.DATA_SOURCE_PB_FINANCE:
 		tableName = "edb_data_pb"
 	case utils.DATA_SOURCE_CALCULATE:
 		tableName = "edb_data_calculate"
@@ -119,7 +119,7 @@ func GetEdbDataList(source, endInfoId int, startDate, endDate string) (list []*E
 	if len(list) > 0 {
 		for _, row := range list {
 			if row.DataTime != "" {
-				row.DataTime = row.DataTime[:10]	// 此处获取的字符串row.DataTime长度有长有短,截取年月日
+				row.DataTime = row.DataTime[:10] // 此处获取的字符串row.DataTime长度有长有短,截取年月日
 				//tempTime, _ := time.Parse("2006-01-02T00:00:00+08:00", row.DataTime)
 				//row.DataTime = tempTime.Format(utils.FormatDate)
 			}
@@ -150,4 +150,4 @@ func GetEdbInfoMaxAndMinInfo(source int, edbCode string) (item *EdbInfoMaxAndMin
 	err = global.MYSQL["data"].Raw(sql, edbCode).Scan(&latest_value).Error
 	item.LatestValue = latest_value
 	return
-}
+}

+ 26 - 0
models/tables/rddp/banner/banner.go

@@ -0,0 +1,26 @@
+package banner
+
+import "time"
+
+type Banner struct {
+	Id             int       `orm:"column(id);pk"`
+	ClassifyId     int       `description:"分类id"`
+	ImageUrl       string    `description:"图片路径"`
+	BannerType     int       `description:"类型 1:轮播图,2:头部海报"`
+	CreateTime     time.Time `description:"创建时间"`
+	ModifyTime     time.Time `description:"修改时间"`
+	ClassifyName   string    `description:"分类名称"`
+	JumpUrl        string    `description:"跳转地址"`
+	Abstract       string    `description:"栏目简介"`
+	Descript       string    `description:"分享描述"`
+	ReportAuthor   string    `description:"栏目作者"`
+	AuthorDescript string    `description:"作者简介"`
+	ColumnImgUrl   string    `description:"栏目配图"`
+	HeadImgUrl     string    `description:"头部banner"`
+	AvatarImgUrl   string    `description:"头像"`
+	ReportImgUrl   string    `description:"报告配图"`
+}
+
+func (c *Banner) TableName() string  {
+	return "banner"
+}

+ 11 - 0
models/tables/rddp/banner/query.go

@@ -0,0 +1,11 @@
+package banner
+
+import (
+	"hongze/hongze_yb/global"
+)
+
+// GetHomeBannerList 获取最新的轮播图
+func GetHomeBannerList() (item *Banner, err error) {
+	err = global.MYSQL["rddp"].Model(Banner{}).Where("banner_type=1").Order("modify_time DESC").First(&item).Error
+	return
+}

+ 13 - 0
models/tables/rddp/customer_comment/customer_comment.go

@@ -0,0 +1,13 @@
+package customer_comment
+
+type CustomerComment struct {
+	Id           int
+	HeadImgUrl   string
+	CustomerName string
+	CompanyName  string
+	Comment      string
+}
+
+func (c *CustomerComment) TableName() string  {
+	return "customer_comment"
+}

+ 9 - 0
models/tables/rddp/customer_comment/query.go

@@ -0,0 +1,9 @@
+package customer_comment
+
+import "hongze/hongze_yb/global"
+
+// GetCustomerComment 获取客户评价
+func GetCustomerComment() (item []*CustomerComment, err error) {
+	err = global.MYSQL["rddp"].Model(CustomerComment{}).Find(&item).Error
+	return
+}

+ 84 - 0
models/tables/rddp/report/query.go

@@ -1,8 +1,10 @@
 package report
 
 import (
+	"fmt"
 	"hongze/hongze_yb/global"
 	"hongze/hongze_yb/models/response"
+	"hongze/hongze_yb/models/response/pc"
 	"hongze/hongze_yb/utils"
 )
 
@@ -311,4 +313,86 @@ WHERE
 	`
 	err = global.MYSQL["rddp"].Raw(sql, classifyIdSeconds, typeIds).Count(&total).Error
 	return
+}
+
+// GetLatestReportByPermission 根据权限相关的分类查询最新的三篇专栏报告
+func GetLatestReportByPermission(classifyIdSeconds []int) (list []*pc.LatestReport, err error)  {
+	sql := `SELECT
+id AS report_id,
+0 AS report_chapter_id,
+classify_id_first,
+classify_id_second,
+classify_name_first,
+classify_name_second,
+0 as report_chapter_type_id,
+title,
+content_sub,
+stage,
+publish_time 
+FROM
+	report
+WHERE
+	classify_name_first != "晨报" 
+	AND classify_name_first != "周报" 
+	AND classify_id_second in ?
+	AND state = 2
+	ORDER BY publish_time DESC LIMIT 3
+	`
+	err = global.MYSQL["rddp"].Raw(sql, classifyIdSeconds).Scan(&list).Error
+	return
+}
+
+// GetLatestReport 获取最新专栏信息
+func GetLatestReport() (list *pc.LatestReport, err error)  {
+	sql := `SELECT
+r.id AS report_id,
+0 AS report_chapter_id,
+classify_id_first,
+classify_id_second,
+classify_name_first,
+classify_name_second,
+0 as report_chapter_type_id,
+title,
+content_sub,
+stage,
+publish_time 
+FROM
+	report AS r
+	INNER JOIN
+	classify AS c
+WHERE
+	r.classify_name_first = c.classify_name
+	AND c.show_type = 2
+	AND c.is_show = 1
+	AND state = 2
+	ORDER BY publish_time DESC LIMIT 1
+	`
+	err = global.MYSQL["rddp"].Raw(sql).First(&list).Error
+	return
+}
+
+func GetLatestReportByClassifyName(firstName string, secondId int) (items *pc.LatestReportBanner, err error) {
+	sql := `SELECT
+	a.id AS report_id,
+	classify_name_second,
+	classify_id_second,
+	classify_name_first,
+	classify_id_first,
+	author,
+	stage,
+	report_author,
+	vip_title 
+FROM
+	report as a
+	JOIN classify as b
+WHERE
+	a.state = 2 
+	AND a.classify_name_first = "%v" 
+	AND a.classify_id_second = %v 
+	AND a.classify_id_second = b.id
+ORDER BY
+	publish_time DESC `
+	sql = fmt.Sprintf(sql, firstName, secondId)
+	err = global.MYSQL["rddp"].Raw(sql).First(&items).Error
+	return
 }

+ 1 - 0
models/tables/rddp/report/report.go

@@ -22,6 +22,7 @@ type Report struct {
 	Content            string `description:"内容" json:"content"`
 	VideoUrl           string `description:"音频文件URL" json:"video_url"`
 	VideoName          string `description:"音频文件名称" json:"video_name"`
+	VideoSize          string `description:"音频文件大小,单位M" json:"video_size"`
 	VideoPlaySeconds   string `description:"音频播放时长" json:"video_play_seconds"`
 	ContentSub         string `description:"内容前两个章节" json:"content_sub"`
 	ThsMsgIsSend       int    `description:"客户群消息是否已发送,0:否,1:是" json:"ths_msg_is_send"`

+ 46 - 1
models/tables/rddp/report_chapter/query.go

@@ -1,6 +1,7 @@
 package report_chapter
 
 import (
+	"fmt"
 	"hongze/hongze_yb/global"
 	"hongze/hongze_yb/utils"
 )
@@ -58,7 +59,7 @@ func GetListByReportIdTypeIds(reportId int, typeIds []int, classifyNameFirst str
 
 // GetContentById 根据ID获取章节详情
 func GetContentById(id int, typeIds []int) (info *ReportChapter, err error)  {
-	err = global.MYSQL["rddp"].Model(ReportChapter{}).Select("report_chapter_id, report_id,  is_edit, classify_name_first, classify_id_first, content, trend, type_id, type_name, abstract, title, author, stage, publish_time, content, content_sub, video_url, video_name, video_play_seconds, video_size, report_type").
+	err = global.MYSQL["rddp"].Model(ReportChapter{}).Select("report_chapter_id, report_id,  is_edit, classify_name_first, classify_id_first, content, trend, type_id, type_name, abstract, title, author, stage, publish_time, content, content_sub, video_url, video_name, video_play_seconds, video_size, report_type, video_size").
 		Where("report_chapter_id = ? and type_id in (?) AND publish_state = 2 ", id, typeIds).
 		First(&info).Error
 	if err == utils.ErrNoRow {
@@ -113,4 +114,48 @@ func GetByTypeIdsAndReportIds(typeIds []int,  reportIds []int, classifyNameFirst
 		reportIds = append(reportIds, v.ReportId)
 	}
 	return
+}
+
+func GetWeekRecommendList(reportId int, firstName string) (items []*ReportChapter, err error) {
+	sql := `SELECT * FROM (SELECT
+	a.report_id,
+	a.report_chapter_id,
+	a.classify_name_first,
+	a.title,
+	a.stage,
+	a.publish_time 
+FROM
+	report_chapter AS a,
+	report AS b
+WHERE
+	a.publish_state = 2 
+	AND a.report_id <> %v
+	AND a.classify_name_first = "%v"
+	AND a.report_id=b.id
+	AND b.state = 2
+ORDER BY
+	publish_time DESC) t
+	GROUP BY report_id 
+	ORDER BY publish_time desc LIMIT 3 `
+	sql = fmt.Sprintf(sql, reportId, firstName)
+	err = global.MYSQL["rddp"].Raw(sql).Scan(&items).Error
+	return
+}
+
+func GetLatestChapterByClassifyName(firstName string) (items *ReportChapter, err error) {
+	sql := `SELECT
+	report_id,
+	classify_name_first,
+	classify_id_first,
+	stage 
+FROM
+	report_chapter 
+WHERE
+	publish_state = 2 
+	AND classify_name_first = "%v" 
+ORDER BY
+	publish_time DESC `
+	sql = fmt.Sprintf(sql, firstName)
+	err = global.MYSQL["rddp"].Raw(sql).First(&items).Error
+	return
 }

+ 23 - 21
models/tables/report_chapter_type/report_chapter_type.go

@@ -3,28 +3,30 @@ package report_chapter_type
 import "time"
 
 type ReportChapterType struct {
-	ReportChapterTypeId    uint64    	  `gorm:"primaryKey;column:report_chapter_type_id;type:bigint(20) unsigned;not null" json:"-"`        //研究报告章节id
-	ReportChapterTypeKey   string         `gorm:"column:report_chapter_type_key;type:varchar(32)" json:"report_chapter_type_key"`            //章节key
-	ReportChapterTypeThumb string         `gorm:"column:report_chapter_type_thumb;type:varchar(512)" json:"report_chapter_type_thumb"`        //H5展示的图片
-	BannerUrl              string         `gorm:"column:banner_url;type:varchar(512)" json:"banner_url"`                                      //banner显示图片
-	ReportChapterTypeName  string         `gorm:"column:report_chapter_type_name;type:varchar(32)" json:"report_chapter_type_name"`          //报告章节类型名称
-	Sort                   int            `gorm:"column:sort;type:int(10);not null;default:0" json:"sort"`                                  //排序字段
-	Enabled                int            `gorm:"column:enabled;type:tinyint(1)" json:"enabled"`                                            //报告类型状态
-	CreatedTime            time.Time      `gorm:"column:created_time;type:datetime" json:"created_time"`                                  //创建时间
-	LastUpdatedTime        time.Time      `gorm:"column:last_updated_time;type:datetime" json:"last_updated_time"`                        //更新时间
-	ResearchType           string         `gorm:"column:research_type;type:varchar(30)" json:"research_type"`                                //研报类型
-	SelectedImage          string         `gorm:"column:selected_image;type:varchar(512)" json:"selected_image"`                              //选中时的图片
-	UnselectedImage        string         `gorm:"column:unselected_image;type:varchar(512)" json:"unselected_image"`                          //没选中时的图片
-	EditImgUrl             string         `gorm:"column:edit_img_url;type:varchar(512)" json:"edit_img_url"`                                  //管理后台编辑时选用的图
-	TickerTitle            string         `gorm:"column:ticker_title;type:varchar(128)" json:"ticker_title"`                                  //指标列的标题
-	IsShow                 int            `gorm:"column:is_show;type:tinyint(1);default:1" json:"is_show"`                                    //是否显示
-	PauseStartTime         time.Time      `gorm:"column:pause_start_time;type:datetime" json:"pause_start_time"`                          //暂停开始日期
-	PauseEndTime           time.Time      `gorm:"column:pause_end_time;type:datetime" json:"pause_end_time"`                              //暂停结束日期
-	IsSet                  int            `gorm:"column:is_set;type:tinyint(4);default:0" json:"is_set"`
-	YbIconUrl              string    `gorm:"column:yb_icon_url;type:varchar(255) json:"yb_icon_url"`                                     //研报小程序3.0图标
-	YbBottomIcon              string    `gorm:"column:yb_bottom_icon;type:varchar(255) json:"yb_bottom_icon"`                                     //研报小程序3.0底部菜单图标
+	ReportChapterTypeId    uint64    `gorm:"primaryKey;column:report_chapter_type_id;type:bigint(20) unsigned;not null" json:"-"` //研究报告章节id
+	ReportChapterTypeKey   string    `gorm:"column:report_chapter_type_key;type:varchar(32)" json:"report_chapter_type_key"`      //章节key
+	ReportChapterTypeThumb string    `gorm:"column:report_chapter_type_thumb;type:varchar(512)" json:"report_chapter_type_thumb"` //H5展示的图片
+	BannerUrl              string    `gorm:"column:banner_url;type:varchar(512)" json:"banner_url"`                               //banner显示图片
+	ReportChapterTypeName  string    `gorm:"column:report_chapter_type_name;type:varchar(32)" json:"report_chapter_type_name"`    //报告章节类型名称
+	Sort                   int       `gorm:"column:sort;type:int(10);not null;default:0" json:"sort"`                             //排序字段
+	Enabled                int       `gorm:"column:enabled;type:tinyint(1)" json:"enabled"`                                       //报告类型状态
+	CreatedTime            time.Time `gorm:"column:created_time;type:datetime" json:"created_time"`                               //创建时间
+	LastUpdatedTime        time.Time `gorm:"column:last_updated_time;type:datetime" json:"last_updated_time"`                     //更新时间
+	ResearchType           string    `gorm:"column:research_type;type:varchar(30)" json:"research_type"`                          //研报类型
+	SelectedImage          string    `gorm:"column:selected_image;type:varchar(512)" json:"selected_image"`                       //选中时的图片
+	PcSelectedImage        string    `gorm:"column:pc_selected_image;type:varchar(512)" json:"pc_selected_image"`                 //pc选中时的图片
+	UnselectedImage        string    `gorm:"column:unselected_image;type:varchar(512)" json:"unselected_image"`                   //没选中时的图片
+	PcUnselectedImage      string    `gorm:"column:pc_unselected_image;type:varchar(512)" json:"pc_unselected_image"`             //pc没选中时的图片
+	EditImgUrl             string    `gorm:"column:edit_img_url;type:varchar(512)" json:"edit_img_url"`                           //管理后台编辑时选用的图
+	TickerTitle            string    `gorm:"column:ticker_title;type:varchar(128)" json:"ticker_title"`                           //指标列的标题
+	IsShow                 int       `gorm:"column:is_show;type:tinyint(1);default:1" json:"is_show"`                             //是否显示
+	PauseStartTime         time.Time `gorm:"column:pause_start_time;type:datetime" json:"pause_start_time"`                       //暂停开始日期
+	PauseEndTime           time.Time `gorm:"column:pause_end_time;type:datetime" json:"pause_end_time"`                           //暂停结束日期
+	IsSet                  int       `gorm:"column:is_set;type:tinyint(4);default:0" json:"is_set"`
+	YbIconUrl              string    `gorm:"column:yb_icon_url;type:varchar(255) json:"yb_icon_url"`       //研报小程序3.0图标
+	YbBottomIcon           string    `gorm:"column:yb_bottom_icon;type:varchar(255) json:"yb_bottom_icon"` //研报小程序3.0底部菜单图标
 }
 
 func (r *ReportChapterType) TableName() string {
 	return "report_chapter_type"
-}
+}

+ 7 - 0
models/tables/yb_activity/query.go

@@ -104,4 +104,11 @@ func GetListCountByIds(activityIds []int) (total int64, err error)  {
 		Where("activity_id in (?) and is_delete = 0 and publish_status = 1", activityIds).
 		Count(&total).Error
 	return
+}
+
+
+// GetLatestActivity 获取最新的活动
+func GetLatestActivity() (activity *YbActivity, err error)  {
+	err = global.DEFAULT_MYSQL.Model(YbActivity{}).Where("is_delete = 0 and publish_status = 1").Order("create_time desc").First(&activity).Error
+	return
 }

+ 1 - 1
models/tables/yb_activity/yb_activity.go

@@ -6,7 +6,7 @@ import (
 
 // YbActivity 弘则研小程序 活动表
 type YbActivity struct {
-	ActivityID            int       `gorm:"primaryKey;column:activity_id;type:int(11);not null" json:"-"`                                                     // 活动ID
+	ActivityID            int       `gorm:"primaryKey;column:activity_id;type:int(11);not null" json:"activityID"`                                                     // 活动ID
 	FirstActivityTypeID   int       `gorm:"index:activity_type_id;column:first_activity_type_id;type:int(100);not null;default:0" json:"firstActivityTypeId"` // 第一级的活动类型ID
 	FirstActivityTypeName string    `gorm:"column:first_activity_type_name;type:varchar(30);not null;default:''" json:"firstActivityTypeName"`                // 第一级的活动类型名称
 	ActivityTypeID        int       `gorm:"column:activity_type_id;type:int(100);not null;default:0" json:"activityTypeId"`                                   // 活动类型ID

+ 8 - 0
models/tables/yb_pc_suncode/create.go

@@ -0,0 +1,8 @@
+package yb_pc_suncode
+
+import "hongze/hongze_yb/global"
+
+func (item *YbPcSuncode) Create() (err error) {
+	err = global.DEFAULT_MYSQL.Create(item).Error
+	return
+}

+ 11 - 0
models/tables/yb_pc_suncode/query.go

@@ -0,0 +1,11 @@
+package yb_pc_suncode
+
+import (
+	"hongze/hongze_yb/global"
+)
+
+// GetYbPcSunCode 获取太阳码
+func GetYbPcSunCode(scene, page string) (item *YbPcSuncode, err error) {
+	err = global.DEFAULT_MYSQL.Where("scene = ? AND code_page = ? ", scene, page).First(&item).Error
+	return
+}

+ 35 - 0
models/tables/yb_pc_suncode/yb_pc_suncode.go

@@ -0,0 +1,35 @@
+package yb_pc_suncode
+
+import "time"
+
+// YbPcSuncode 活动海报表
+type YbPcSuncode struct {
+	SuncodeID  uint32    `gorm:"primaryKey;index:idx_suncode_id;column:suncode_id;type:int(11) unsigned;not null" json:"-"`
+	Scene      string    `gorm:"column:scene;type:varchar(255);not null;default:0" json:"scene"` // 微信scene
+	SceneMd5   string    `gorm:"column:scene_md5;type:varchar(255);not null" json:"sceneMd5"`
+	CodePage   string    `gorm:"column:code_page;type:varchar(255);not null;default:''" json:"codePage"`     // 路径
+	SuncodeURL string    `gorm:"column:suncode_url;type:varchar(255);not null;default:''" json:"suncodeUrl"` // 太阳码储存地址
+	CreateTime time.Time `gorm:"column:create_time;type:timestamp;default:CURRENT_TIMESTAMP" json:"createTime"`
+}
+
+// TableName get sql table name.获取数据库表名
+func (m *YbPcSuncode) TableName() string {
+	return "yb_pc_suncode"
+}
+
+// YbPcSuncodeColumns get sql column name.获取数据库列名
+var YbPcSuncodeColumns = struct {
+	SuncodeID  string
+	Scene      string
+	SceneMd5   string
+	CodePage   string
+	SuncodeURL string
+	CreateTime string
+}{
+	SuncodeID:  "suncode_id",
+	Scene:      "scene",
+	SceneMd5:   "scene_md5",
+	CodePage:   "code_page",
+	SuncodeURL: "suncode_url",
+	CreateTime: "create_time",
+}

+ 22 - 0
routers/pc.go

@@ -0,0 +1,22 @@
+package routers
+
+import (
+	"github.com/gin-gonic/gin"
+	"hongze/hongze_yb/controller/pc"
+	"hongze/hongze_yb/middleware"
+)
+
+func InitPc(r *gin.Engine)  {
+	rGroup := r.Group("api/pc").Use(middleware.Token())
+	rGroup.GET("/latest_news", pc.LatestNews)
+	rGroup.GET("/banner", pc.Banner)
+	rGroup.GET("/latest_release", pc.LatestRelease)
+	rGroup.GET("/detail", pc.ClassifyDetail)
+	rGroup.GET("/detail_banner", pc.ClassifyDetailBanner)
+	rGroup.GET("/recommend", pc.Recommend)
+	rGroup.GET("/classify", pc.ClassifyFirstList)
+	rGroup.GET("/comment", pc.CustomerComment)
+	rGroup.POST("/getSunCode", pc.GetSunCode)
+	pcGroup := r.Group("api/pc")
+	pcGroup.GET("/login", pc.WechatLogin)
+}

+ 3 - 1
services/chart/edb_data.go

@@ -35,6 +35,8 @@ func RefreshEdbData(edbInfoId, source int, edbCode, startDate string) (resp *Ref
 		urlStr = "/wind/refresh"
 	case utils.DATA_SOURCE_PB:
 		urlStr = "/pb/refresh"
+	case utils.DATA_SOURCE_PB_FINANCE:
+		urlStr = "/pb_finance/refresh"
 	case utils.DATA_SOURCE_MANUAL:
 		urlStr = "/manual/refresh"
 	case utils.DATA_SOURCE_LZ:
@@ -121,4 +123,4 @@ func RefreshEdbCalculateData(edbInfoId int, edbCode, startDate string) (resp *Re
 	param["StartDate"] = startDate
 	resp, err = postRefreshEdbData(param, "/calculate/refresh")
 	return
-}
+}

+ 3 - 3
services/company/permission.go

@@ -664,7 +664,7 @@ func GetHomeFiccPermissions(user user.UserInfo) (ret response.PermissionFiccResp
 	permissionFirstMap["化工产业"] = &response.PermissionFirstItem{
 		Sort: 1002,
 	}
-	permissionFirstMap["黑色产业"] = &response.PermissionFirstItem{
+	permissionFirstMap["建材产业"] = &response.PermissionFirstItem{
 		Sort: 1003,
 	}
 	permissionFirstMap["有色产业"] = &response.PermissionFirstItem{
@@ -715,8 +715,8 @@ func GetHomeFiccPermissions(user user.UserInfo) (ret response.PermissionFiccResp
 			temp.ClassifyName = "化工"
 			temp.SelectIconUrl = utils.ALIYUN_YBIMG_HOST + "ficc_icon_idx_huagong_select.png"
 			temp.IconUrl = utils.ALIYUN_YBIMG_HOST + "ficc_icon_idx_huagong.png"
-		} else if temp.ClassifyName == "黑色产业" {
-			temp.ClassifyName = "黑色"
+		} else if temp.ClassifyName == "建材产业" {
+			temp.ClassifyName = "建材"
 			temp.SelectIconUrl = utils.ALIYUN_YBIMG_HOST + "ficc_icon_idx_black_select.png"
 			temp.IconUrl = utils.ALIYUN_YBIMG_HOST + "ficc_icon_idx_black.png"
 		} else if temp.ClassifyName == "有色产业" {

+ 131 - 0
services/pc/classify.go

@@ -0,0 +1,131 @@
+package pc
+
+import (
+	"errors"
+	"fmt"
+	"hongze/hongze_yb/global"
+	"hongze/hongze_yb/models/response/pc"
+	"hongze/hongze_yb/models/tables/rddp/classify"
+	"hongze/hongze_yb/services/user"
+	"hongze/hongze_yb/utils"
+	"sort"
+)
+
+// GetClassifyFirstList 获取一级分类列表
+func GetClassifyFirstList(user user.UserInfo) (list pc.ClassifyFirstList, err error) {
+	var errMsg string
+	defer func() {
+		if err != nil {
+			global.LOG.Critical(fmt.Sprintf("GetClassifyFirstList: userId=%d, err:%s, errMsg:%s", user.UserID, err.Error(), errMsg))
+		}
+	}()
+
+	classifyParents, err := classify.GetParentList()
+	if err != nil {
+		errMsg = err.Error()
+		err = errors.New("分类查询出错")
+		return
+	}
+	if len(classifyParents) == 0 {
+		err = errors.New("分类不存在")
+		return
+	}
+
+	// 当前版本一级分类固定
+	classifyIconMap := map[string]string{
+		"晨报": utils.ALIYUN_YBIMG_HOST + "ficc_classify_bg_blue.png",
+		"周报": utils.ALIYUN_YBIMG_HOST + "ficc_classify_bg_blue.png",
+		"双周报": utils.ALIYUN_YBIMG_HOST + "ficc_classify_bg_blue.png",
+		"月报": utils.ALIYUN_YBIMG_HOST + "ficc_classify_bg_blue.png",
+		"草根调研": utils.ALIYUN_YBIMG_HOST + "ficc_classify_bg_orange.png",
+		"需求报告": utils.ALIYUN_YBIMG_HOST + "ficc_classify_bg_green.png",
+		"宏观报告": utils.ALIYUN_YBIMG_HOST + "ficc_classify_bg_green.png",
+		"日度点评": utils.ALIYUN_YBIMG_HOST + "ficc_classify_bg_orange.png",
+		"数据点评": utils.ALIYUN_YBIMG_HOST + "ficc_classify_bg_green.png",
+		"碳市场价格周报": utils.ALIYUN_YBIMG_HOST + "ficc_classify_bg_blue.png",
+		"行业调研": utils.ALIYUN_YBIMG_HOST + "ficc_classify_bg_orange.png",
+		"海外视角": utils.ALIYUN_YBIMG_HOST + "ficc_classify_bg_orange.png",
+		"百家谈": utils.ALIYUN_YBIMG_HOST + "ficc_classify_bg_orange.png",
+		"会议纪要": utils.ALIYUN_YBIMG_HOST + "ficc_classify_bg_green.png",
+		"大事点评":  utils.ALIYUN_YBIMG_HOST + "ficc_classify_bg_orange.png",
+		"年报合集": utils.ALIYUN_YBIMG_HOST + "ficc_classify_bg_green.png",
+	}
+
+	classifySortMap := map[string]int{
+		"晨报": 1,
+		"周报": 2,
+		"双周报": 3,
+		"月报": 4,
+		"草根调研": 5,
+		"需求报告": 6,
+		"宏观报告": 7,
+		"日度点评": 8,
+		"数据点评": 9,
+		"碳市场价格周报": 10,
+		"行业调研": 11,
+		"海外视角": 12,
+		"百家谈": 13,
+		"会议纪要": 14,
+		"大事点评":  15,
+		"年报合集": 16,
+	}
+	names := []string{
+		"晨报",
+		"周报",
+		"双周报",
+		"月报",
+		"草根调研",
+		"需求报告",
+		"宏观报告",
+		"日度点评",
+		"数据点评",
+		"碳市场价格周报",
+		"行业调研",
+		"海外视角",
+		"百家谈",
+		"会议纪要",
+		"大事点评",
+		"年报合集",
+	}
+	reportList,err := pc.GetLatestStage(names)
+	if err != nil {
+		errMsg = err.Error()
+		err = errors.New("报告查询出错")
+		return
+	}
+	for _, item := range classifyParents {
+		temp := new(pc.ClassifyFirstListItem)
+		temp.ClassifyIdFirst = item.Id
+		temp.ClassifyNameFirst = item.ClassifyName
+		temp.BackImgUrl = classifyIconMap[item.ClassifyName]
+		temp.Sort = classifySortMap[item.ClassifyName]
+		if temp.Sort == 0 {
+			continue
+		}
+		// ShowType展示类型:1-列表 2-专栏; RedirectType跳转类型:1-专栏列表 2-报告列表 3-专栏详情
+		temp.RedirectType = 2
+		if item.ShowType == 2 {
+			temp.RedirectType = 1
+			classifyChild, _ := classify.GetChildByPid(item.Id)
+			if classifyChild != nil && len(classifyChild) == 1 {
+				// 存在二级分类且仅有一个时直接跳转专栏详情
+				temp.ClassifyIdSecond = classifyChild[0].Id
+				temp.ClassifyNameSecond = classifyChild[0].ClassifyName
+				temp.RedirectType = 3
+			}
+		}
+		list = append(list, temp)
+	}
+	for _, item := range list {
+		for _, report := range reportList {
+			if report.ClassifyNameFirst == item.ClassifyNameFirst {
+				item.Latest = report.Stage
+			}
+		}
+	}
+	if len(list) > 0 {
+		sort.Sort(list)
+	}
+
+	return
+}

+ 138 - 0
services/pc/report.go

@@ -0,0 +1,138 @@
+package pc
+
+import (
+	"errors"
+	"fmt"
+	"hongze/hongze_yb/global"
+	"hongze/hongze_yb/models/response/pc"
+	"hongze/hongze_yb/models/tables/chart_permission"
+	"hongze/hongze_yb/models/tables/chart_permission_search_key_word_mapping"
+	"hongze/hongze_yb/models/tables/rddp/classify"
+	"hongze/hongze_yb/models/tables/rddp/customer_comment"
+	"hongze/hongze_yb/models/tables/rddp/report"
+	"hongze/hongze_yb/services/company"
+	"hongze/hongze_yb/services/user"
+	"hongze/hongze_yb/utils"
+)
+
+func GetClassifyDetail(user user.UserInfo, classifyIdSecond int) (detail *pc.ClassifyDetail, err error)  {
+	var errMsg string
+	defer func() {
+		if err != nil {
+			global.LOG.Critical(fmt.Sprintf("GetClassifyDetail: userId=%d, err:%s, errMsg:%s", user.UserID, err.Error(), errMsg))
+		}
+	}()
+	classifyInfo, err := classify.GetByClassifyId(classifyIdSecond)
+	if err != nil {
+		errMsg = err.Error()
+		err = errors.New("分类查询出错")
+		return
+	}
+
+	if classifyInfo.Id == 0 {
+		err = errors.New("分类不存在")
+		return
+	}
+	if classifyInfo.ParentId == 0 {
+		err = errors.New("只允许查询二级分类")
+		return
+	}
+	//查询权限, 查询当前分类下的最新的报告,
+	permissionIds, err := chart_permission_search_key_word_mapping.GetChartPermissionIdsByKeyWord(classifyInfo.ClassifyName)
+	if err != nil {
+		errMsg = err.Error()
+		err = errors.New("分类权限查询出错")
+		return
+	}
+	authOk, permissionCheckInfo, _, err := company.GetCheckPermission(user.CompanyID, int(user.UserID), permissionIds)
+	if err != nil && err != utils.ErrNoRow {
+		errMsg = err.Error()
+		err = errors.New("权限查询出错")
+		return
+	}
+
+	comments,err := customer_comment.GetCustomerComment()
+	if err != nil {
+		errMsg = err.Error()
+		err = errors.New("客户评价查询出错")
+		return
+	}
+
+	detail = new(pc.ClassifyDetail)
+	detail.ClassifyIdSecond = classifyInfo.Id
+	detail.ParentId = classifyInfo.ParentId
+	detail.AuthorDescript = classifyInfo.AuthorDescript
+	detail.ReportAuthor = classifyInfo.ReportAuthor
+	detail.AvatarImgUrl = classifyInfo.AvatarImgUrl
+	detail.ClassifyNameSecond = classifyInfo.ClassifyName
+	detail.Abstract = classifyInfo.Abstract
+	detail.Descript = classifyInfo.Descript
+	detail.VipTitle = classifyInfo.VipTitle
+	detail.PermissionCheck = &permissionCheckInfo
+	detail.AuthOk = authOk
+	detail.Comments = comments
+
+	return
+}
+
+// GetLatestReportList 首页最新资讯
+func GetLatestReportList(user user.UserInfo, chartPermissionId int) (ret []*pc.LatestReport, err error) {
+	var errMsg string
+	defer func() {
+		if err != nil {
+			global.LOG.Critical(fmt.Sprintf("GetCollectReportList: userId=%d, err:%s, errMsg:%s", user.UserID, err.Error(), errMsg))
+		}
+	}()
+
+	// 查询权限的基本信息
+	permissionInfo, err := chart_permission.GetByChartPermissionId(chartPermissionId)
+	if err != nil {
+		errMsg = err.Error()
+		err = errors.New("查询权限出错")
+		return
+	}
+
+	if permissionInfo.ChartPermissionID == 0 {
+		err = errors.New("权限不存在")
+		return
+	}
+	// 除了晨报和周报以外的其他报告
+	classifyNames, err := chart_permission_search_key_word_mapping.GetKeyWordsByChartPermissionId(chartPermissionId, "rddp")
+	if err != nil {
+		errMsg = err.Error()
+		err = errors.New("查询权限对应的分类出错")
+		return
+	}
+
+	var classifySecondIds []int
+	if len(classifyNames) > 0 {
+		classifySecondIds, err = classify.GetSecondIdsByClassifyNames(classifyNames)
+		if err != nil {
+			errMsg = err.Error()
+			err = errors.New("查询分类出错")
+			return
+		}
+	}
+
+	var reportList []*pc.LatestReport
+	if len(classifySecondIds) > 0 {
+		reportList, err = report.GetLatestReportByPermission(classifySecondIds)
+		if err != nil {
+			errMsg = err.Error()
+			err = errors.New("查询报告信息出错")
+			return
+		}
+	}
+	//文章不足三篇时用下一品种补全
+	//if len(reportList) < 3 {
+	//
+	//	reportList, err = report.GetLatestReportByPermission(classifySecondIds)
+	//	if err != nil {
+	//		errMsg = err.Error()
+	//		err = errors.New("查询报告信息出错")
+	//		return
+	//	}
+	//}
+	ret = reportList
+	return
+}

+ 3 - 0
services/pc/wechat.go

@@ -0,0 +1,3 @@
+package pc
+
+

+ 1 - 0
services/report/report.go

@@ -424,6 +424,7 @@ func GetReportDetail(userinfo user.UserInfo, reportId int) (reportDetail respons
 	if reportInfo.VideoName == "" && reportInfo.VideoUrl != "" {
 		reportItem.VideoName = reportInfo.Title
 	}
+	reportItem.VideoSize = reportInfo.VideoSize
 	reportItem.VideoPlaySeconds = reportInfo.VideoPlaySeconds
 	reportItem.Author = reportInfo.Author
 	var reportTypeList []*response.ReportChapterListItem

+ 3 - 1
services/report/report_chapter.go

@@ -237,7 +237,7 @@ func GetChapterDetail(user user.UserInfo, reportChapterId int) (reportChapterDet
 	reportChapterItem := new(response.ReportChapterItem)
 	reportChapterItem.ReportChapterId = reportChapter.ReportChapterId
 	reportChapterItem.ReportId = reportChapter.ReportId
-
+	reportChapterItem.Abstract = reportChapter.Abstract
 	reportChapterItem.TypeId = reportChapter.TypeId
 	reportChapterItem.Title = reportChapter.Title
 	reportChapterItem.ReportId = reportChapter.ReportId
@@ -312,6 +312,8 @@ func GetMenuChapter(reportId int, typeIds []int, classifyNameFirst string, repor
 					temp.ReportChapterTypeName = typeItem.ReportChapterTypeName
 					temp.ReportChapterTypeThumb = typeItem.YbBottomIcon
 					temp.Sort = typeItem.Sort
+					temp.PcSelectedThumb = typeItem.PcSelectedImage
+					temp.PcUnselectedThumb = typeItem.PcUnselectedImage
 					reportTypeList = append(reportTypeList, temp)
 				}
 			}

+ 82 - 0
services/sun_code.go

@@ -0,0 +1,82 @@
+package services
+
+import (
+	"errors"
+	"fmt"
+	"hongze/hongze_yb/models/tables/yb_pc_suncode"
+	"hongze/hongze_yb/models/tables/yb_suncode_pars"
+	"hongze/hongze_yb/services/wx_app"
+	"hongze/hongze_yb/utils"
+	"os"
+	"time"
+)
+
+// SunCodeReq 获取太阳码请求体
+type SunCodeReq struct {
+	CodePage  string `json:"CodePage" description:"太阳码page"`
+	CodeScene string `json:"CodeScene" description:"太阳码scene"`
+}
+
+// PcCreateAndUploadSunCode 生成太阳码并上传OSS
+func PcCreateAndUploadSunCode(scene, page string) (imgUrl string, err error) {
+	if page == "" {
+		err = errors.New("page不能为空")
+		return
+	}
+
+	// scene超过32位会生成失败,md5处理至32位
+	sceneMD5 := "a=1"
+	if scene != "" {
+		sceneMD5 = utils.MD5(scene)
+	}
+	picByte, err := wx_app.GetSunCode(page, sceneMD5)
+	if err != nil {
+		return
+	}
+	// 生成图片
+	localPath := "./static/img"
+	fileName := utils.GetRandStringNoSpecialChar(28) + ".png"
+	fpath := fmt.Sprint(localPath, "/", fileName)
+	f, err := os.Create(fpath)
+	if err != nil {
+		return
+	}
+	if _, err = f.Write(picByte); err != nil {
+		return
+	}
+	defer func() {
+		f.Close()
+		os.Remove(fpath)
+	}()
+	// 上传OSS
+	fileDir := "yb/suncode/"
+	imgUrl, err = UploadAliyunToDir(fileName, fpath, fileDir)
+	if err != nil {
+		return
+	}
+
+	if err != nil {
+		return
+	}
+	// 记录参数
+	if scene != "" {
+		newPars := &yb_pc_suncode.YbPcSuncode{
+			Scene:      scene,
+			SceneMd5:   sceneMD5,
+			CodePage:   page,
+			SuncodeURL: imgUrl,
+			CreateTime: time.Now(),
+		}
+		err = newPars.Create()
+	}
+	// 记录参数md5
+	if scene != "" {
+		newPars := &yb_suncode_pars.YbSuncodePars{
+			Scene:      scene,
+			SceneKey:   sceneMD5,
+			CreateTime: time.Now(),
+		}
+		err = newPars.Create()
+	}
+	return
+}

+ 40 - 0
services/wechat/wechat.go

@@ -1,7 +1,10 @@
 package wechat
 
 import (
+	"encoding/json"
+	"errors"
 	"fmt"
+	"github.com/rdlucklib/rdluck_tools/http"
 	"github.com/silenceper/wechat/v2"
 	"github.com/silenceper/wechat/v2/cache"
 	"github.com/silenceper/wechat/v2/credential"
@@ -10,6 +13,7 @@ import (
 	"github.com/silenceper/wechat/v2/officialaccount/js"
 	"github.com/silenceper/wechat/v2/officialaccount/user"
 	"hongze/hongze_yb/global"
+	"hongze/hongze_yb/models/response/pc"
 	"hongze/hongze_yb/models/tables/wx_token"
 	"time"
 )
@@ -20,6 +24,8 @@ var (
 	WxAppSecret                     string
 	TemplateIdWithCommunityQuestion string // 问答社区回复模板消息ID
 	WxYbAppId                       string // 研报小程序AppID
+	PcWxAppId                       string //pc版AppId
+	PcWxAppSecret                   string //pc版AppSecret
 )
 
 func init() {
@@ -28,12 +34,20 @@ func init() {
 		WxAppId = "wx9b5d7291e581233a"
 		WxAppSecret = "f4d52e34021eee262dce9682b31f8861"
 		WxId = "gh_5dc508325c6f"
+
 		TemplateIdWithCommunityQuestion = "CB7bOl7f3viMG4s1uhRo7WM0Jbx3WvodKuIZ8A_z8fM"
+		PcWxAppId = "wxcba9a7ec590ee2d5"
+		PcWxAppSecret = "aa58d257e2521d768cbf1bf89989769d"
+
 	} else {
 		WxAppId = "wx4a844c734d8c8e56"
 		WxAppSecret = "26c586e7ccb3c575433f0f37797b3eeb"
 		WxId = "gh_b67e0049fb8c"
+
 		TemplateIdWithCommunityQuestion = "dYg6iHooRq74PyCXmw_Ns7qdJZmbtLoKS2p2FKeaXl0"
+		PcWxAppId = "wx4da95782cfc8c5eb"
+		PcWxAppSecret = "8f82ebf2ba3aa06ce44541726385df64"
+
 	}
 }
 
@@ -108,3 +122,29 @@ func getTokenFromServer(appid, wxSecret string) (accessToken string, expires int
 	accessToken = resAccessToken.AccessToken
 	return
 }
+
+func PcWxGetUserOpenIdByCode(code string) (item *pc.WxAccessToken, err error) {
+	if code == "" {
+		err = errors.New("code is empty")
+		return nil, err
+	}
+	requestUrl := `https://api.weixin.qq.com/sns/oauth2/access_token?appid=%s&secret=%s&code=%s&grant_type=authorization_code`
+	requestUrl = fmt.Sprintf(requestUrl, PcWxAppId, PcWxAppSecret, code)
+	result, err := http.Get(requestUrl)
+	if err != nil {
+		return nil, err
+	}
+	err = json.Unmarshal(result, &item)
+	return
+}
+
+func PcWxGetUserInfo(openId, accessToken string) (item *pc.WxUserInfo, err error) {
+	requestUrl := `https://api.weixin.qq.com/sns/userinfo?access_token=%s&openid=%s`
+	requestUrl = fmt.Sprintf(requestUrl, accessToken, openId)
+	result, err := http.Get(requestUrl)
+	if err != nil {
+		return
+	}
+	err = json.Unmarshal(result, &item)
+	return
+}

+ 1 - 0
utils/constants.go

@@ -69,6 +69,7 @@ const (
 	DATA_SOURCE_LT                              //路透->25
 	DATA_SOURCE_COAL                            //中国煤炭网->26
 	DATA_SOURCE_PYTHON                          //python代码->27
+	DATA_SOURCE_PB_FINANCE                      //彭博财务数据->28
 )
 
 const (