rdluck 4 lat temu
rodzic
commit
4b97295943

+ 60 - 36
controllers/report.go

@@ -57,8 +57,16 @@ func (this *ReportController) Detail() {
 	}
 	report.ContentSub = html.UnescapeString(report.ContentSub)
 	report.Content = html.UnescapeString(report.Content)
-	company, err := models.GetCompanyById(user.CompanyId)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+
+	productId := 0
+	if report.ClassifyNameSecond == "近期路演精华" {
+		productId = 2
+	} else {
+		productId = 1
+	}
+
+	company, err := models.GetCompanyProductById(user.CompanyId, productId)
+	if err != nil {
 		if err.Error() != utils.ErrNoRow() {
 			br.Msg = "获取报告详情失败"
 			br.ErrMsg = "获取用户管理企业信息失败,Err:" + err.Error()
@@ -81,47 +89,55 @@ func (this *ReportController) Detail() {
 			report.Content = report.ContentSub
 		}
 	}
-	reportType := "rddp"
-	reportPermissionList, err := models.GetReportVarietyListByUserIdExt(user.UserId, reportType)
-	if err != nil {
-		if err.Error() != utils.ErrNoRow() {
-			br.Msg = "获取报告详情失败"
-			br.ErrMsg = "获取用户管理企业信息失败,Err:" + err.Error()
-			return
-		} else {
+	if productId==1 {
+		reportType := "rddp"
+		reportPermissionList, err := models.GetReportVarietyListByUserIdExt(user.UserId, reportType)
+		if err != nil {
+			if err.Error() != utils.ErrNoRow() {
+				br.Msg = "获取报告详情失败"
+				br.ErrMsg = "获取用户管理企业信息失败,Err:" + err.Error()
+				return
+			} else {
+				status = 2
+				msg = "您还未开通权限,如有需要请联系对口销售"
+				report.Content = report.ContentSub
+			}
+		}
+		if len(reportPermissionList) == 0 {
 			status = 2
 			msg = "您还未开通权限,如有需要请联系对口销售"
 			report.Content = report.ContentSub
 		}
-	}
-	permissionMap := make(map[int]int)
-	for _, v := range reportPermissionList {
-		if _, ok := permissionMap[v.ReportChapterTypeId]; !ok {
-			permissionMap[v.ReportChapterTypeId] = v.ReportChapterTypeId
+		permissionMap := make(map[int]int)
+		for _, v := range reportPermissionList {
+			if _, ok := permissionMap[v.ReportChapterTypeId]; !ok {
+				permissionMap[v.ReportChapterTypeId] = v.ReportChapterTypeId
+			}
 		}
-	}
-	if _, ok := permissionMap[reportId]; !ok {
-		tips := ""
-		status = 2
-		report.Content = report.ContentSub
-		classifyNameSecond := report.ClassifyNameSecond
-		if strings.Contains(classifyNameSecond, "宏观商品复盘") ||
-			strings.Contains(classifyNameSecond, "股债日评") ||
-			strings.Contains(classifyNameSecond, "每日经济数据备忘录") {
-			tips = "宏观"
-		} else if strings.Contains(classifyNameSecond, "知白守黑日评") ||
-			strings.Contains(classifyNameSecond, "动力煤数据点评") {
-			tips = "黑色"
-		} else if strings.Contains(classifyNameSecond, "化里化外日评") ||
-			strings.Contains(classifyNameSecond, "EIA原油库存点评") ||
-			strings.Contains(classifyNameSecond, "苯乙烯数据点评") ||
-			strings.Contains(classifyNameSecond, "聚酯数据点评") {
-			tips = "化工"
-		} else if strings.Contains(classifyNameSecond, "有声有色日度闲篇") {
-			tips = "有色"
+		if _, ok := permissionMap[reportId]; !ok {
+			tips := ""
+			status = 2
+			report.Content = report.ContentSub
+			classifyNameSecond := report.ClassifyNameSecond
+			if strings.Contains(classifyNameSecond, "宏观商品复盘") ||
+				strings.Contains(classifyNameSecond, "股债日评") ||
+				strings.Contains(classifyNameSecond, "每日经济数据备忘录") {
+				tips = "宏观"
+			} else if strings.Contains(classifyNameSecond, "知白守黑日评") ||
+				strings.Contains(classifyNameSecond, "动力煤数据点评") {
+				tips = "黑色"
+			} else if strings.Contains(classifyNameSecond, "化里化外日评") ||
+				strings.Contains(classifyNameSecond, "EIA原油库存点评") ||
+				strings.Contains(classifyNameSecond, "苯乙烯数据点评") ||
+				strings.Contains(classifyNameSecond, "聚酯数据点评") {
+				tips = "化工"
+			} else if strings.Contains(classifyNameSecond, "有声有色日度闲篇") {
+				tips = "有色"
+			}
+			msg = "您还未开通" + tips + "权限,如有需要请联系对口销售"
 		}
-		msg = "您还未开通" + tips + "权限,如有需要请联系对口销售"
 	}
+
 	resp := new(models.ReportDetailResp)
 	resp.Status = status
 	resp.Msg = msg
@@ -380,3 +396,11 @@ func (this *ReportController) AddAudioRecord() {
 	br.Success = true
 	br.Msg = "新增成功"
 }
+
+//func init() {
+//	fmt.Println("start")
+//	content:=`<p><strong><u>需要开始观察和警惕全球库存周期回摆对资产价格的压力</u></strong></p><p>从经济惊喜指数上看,8月以来欧美和新兴市场的走势出现了显著的背离,美国和欧洲的经济惊喜指数都在8月见顶,9月开始回落,而新兴市场的经济惊喜指数却在一路上行。新兴市场的走强不是中国带动的,因为中国的经济惊喜指数从8月开始就基本保持稳定。新兴市场的强势更多是由于自身的原因。</p><p><iframe src="https://vmp.hzinsights.com/element/750/citibank_economic_surprise_index/%7C%7C%7C%7C%7C/" width="100%" height="350" border="none" style="border-width:0px; min-height:350px;"></iframe></p><p>新兴市场经济强势的根本原因是什么?是因为疫情之后自身的经济比欧美恢复得更好么?显然不是。我们以巴西为例,看巴西的制造业PMI,已经到达突破历史的“逆天水平”。</p><p><iframe src="https://vmp.hzinsights.com/element/762/brazil_pmi_stock_market/%7C%7C%7C%7C%7C/" width="100%" height="350" border="none" style="border-width:0px; min-height:350px;"></iframe></p>`
+//	newContent:=html.UnescapeString(content)
+//	utils.FileLog.Info("%s",newContent)
+//	fmt.Println("end")
+//}

+ 8 - 6
controllers/video.go

@@ -68,7 +68,7 @@ func (this *VideoController) List() {
 	}
 
 	status := 0
-	company, err := models.GetCompanyById(user.CompanyId)
+	companyProduct, err := models.GetCompanyById(user.CompanyId)
 	if err != nil {
 		if err.Error() != utils.ErrNoRow() {
 			br.Msg = "获取报告详情失败"
@@ -78,13 +78,15 @@ func (this *VideoController) List() {
 			status = 1
 		}
 	}
-	if company == nil {
+	if len(companyProduct) == 0 {
 		status = 1
 	} else {
-		if company.Status == utils.COMPANY_STATUS_FREEZE ||
-			company.Status == utils.COMPANY_STATUS_LOSE ||
-			company.Status == utils.COMPANY_STATUS_POTENTIAL {
-			status = 1
+		for _,v:=range companyProduct{
+			if v.Status == utils.COMPANY_STATUS_FREEZE ||
+				v.Status == utils.COMPANY_STATUS_LOSE ||
+				v.Status == utils.COMPANY_STATUS_POTENTIAL {
+				status = 1
+			}
 		}
 	}
 

+ 12 - 3
models/company.go

@@ -35,11 +35,20 @@ type Company struct {
 	Status          string    `description:"'试用','永续','冻结','流失','正式','潜在'"`
 }
 
-func GetCompanyById(companyId int) (item *Company, err error) {
+func GetCompanyById(companyId int) (item []*CompanyProduct, err error) {
 	o := orm.NewOrm()
 	sql := ` SELECT a.*,b.status FROM company AS a
 			INNER JOIN company_product AS b ON a.company_id=b.company_id
-			WHERE a.company_id=? AND b.product_id=1 `
-	err = o.Raw(sql, companyId).QueryRow(&item)
+			WHERE a.company_id=? `
+	_,err = o.Raw(sql, companyId).QueryRows(&item)
+	return
+}
+
+func GetCompanyProductById(companyId,productId int) (item *CompanyProduct, err error) {
+	o := orm.NewOrm()
+	sql := ` SELECT a.*,b.status FROM company AS a
+			INNER JOIN company_product AS b ON a.company_id=b.company_id
+			WHERE a.company_id=? AND b.product_id=? `
+	err = o.Raw(sql, companyId,productId).QueryRow(&item)
 	return
 }

+ 32 - 0
models/company_product.go

@@ -0,0 +1,32 @@
+package models
+
+import "time"
+
+type CompanyProduct struct {
+	CompanyProductId int       `orm:"column(company_product_id);pk" description:"客户产品id"`
+	CompanyId        int       `description:"客户id"`
+	ProductId        int       `description:"产品id"`
+	ProductName      string    `description:"产品名称"`
+	CompanyName      string    `description:"客户名称"`
+	Source           string    `description:"来源"`
+	Reasons          string    `description:"新增理由"`
+	Status           string    `description:"客户状态"`
+	IndustryId       int       `description:"行业id"`
+	IndustryName     string    `description:"行业名称"`
+	SellerId         int       `description:"销售id"`
+	SellerName       string    `description:"销售名称"`
+	GroupId          int       `description:"销售分组id"`
+	DepartmentId     int       `description:"销售部门id"`
+	IsSuspend        int       `description:"1:暂停,0:启用"`
+	SuspendTime      time.Time `description:"暂停启用时间"`
+	ApproveStatus    string    `description:"审批状态:'审批中','通过','驳回'"`
+	FreezeTime       time.Time `description:"冻结时间"`
+	Remark           string    `description:"备注信息"`
+	CreateTime       time.Time `description:"创建时间"`
+	ModifyTime       time.Time `description:"修改时间"`
+	StartDate        string    `description:"开始日期"`
+	EndDate          string    `description:"结束日期"`
+	LoseReason       string    `description:"流失原因"`
+	LossTime         time.Time `description:"流失时间"`
+	CompanyType      string    `description:"客户类型"`
+}

+ 14 - 10
services/user_permission.go

@@ -27,26 +27,30 @@ func CheckUserPermission(userId int) (status int, err error) {
 			return status, err
 		}
 		companyId := wxUser.CompanyId
-		fmt.Println(companyId)
-		company, err := models.GetCompanyById(companyId)
+		fmt.Println("companyId",companyId)
+		companyProduct, err := models.GetCompanyById(companyId)
 		if err != nil {
 			status = 40001
 			err = errors.New("获取客户信息失败:userId:" + strconv.Itoa(userId) + ";Err:" + err.Error())
 			return status, err
 		}
-		if company == nil {
+		if len(companyProduct) == 0 {
 			status = 40001
 			err = errors.New("客户信息不存在:userId:" + strconv.Itoa(userId))
 			return status, err
 		}
-		if company.Status == utils.COMPANY_STATUS_FORMAL || //正式
-			company.Status == utils.COMPANY_STATUS_TRY_OUT || //试用
-			company.Status == utils.COMPANY_STATUS_FOREVER { //永续
-			status = 0
-		} else {
-			status = 40002
-			err = errors.New("非付费用户" + strconv.Itoa(userId))
+		for _,v:=range companyProduct{
+			if v.Status == utils.COMPANY_STATUS_FORMAL || //正式
+				v.Status == utils.COMPANY_STATUS_TRY_OUT || //试用
+				v.Status == utils.COMPANY_STATUS_FOREVER { //永续
+				status = 0
+				break
+			} else {
+				status = 40002
+				err = errors.New("非付费用户" + strconv.Itoa(userId))
+			}
 		}
+
 	} else {
 		status = 40001
 		err = errors.New("用户id错误")