浏览代码

no message

xingzai 1 年之前
父节点
当前提交
b6e64015ca
共有 3 个文件被更改,包括 24 次插入4 次删除
  1. 8 3
      controllers/home.go
  2. 12 0
      models/company_product.go
  3. 4 1
      services/activity_special.go

+ 8 - 3
controllers/home.go

@@ -672,13 +672,18 @@ func (this *HomeController) NewList() {
 	var condition string
 	var conditionInit string
 	var pars []interface{}
-	var total int
+	//var total int
 	resp := new(models.HomeResourceDataListResp)
-
+	totalRai, err := models.GetCountCompanyProductCompanyId(user.CompanyId, utils.COMPANY_PRODUCT_RAI_ID)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		br.Msg = "获取失败"
+		br.ErrMsg = "GetCountCompanyProductCompanyId,Err:" + err.Error()
+		return
+	}
 	//condition += " AND source = 'article' "
 	//查询近一个月的数据
 	conditionInit = " AND publish_date  >   '" + time.Now().AddDate(0, 0, -30).Format(utils.FormatDateTime) + "'"
-	if user.CompanyId <= 1 {
+	if user.CompanyId <= 1 || totalRai == 0 {
 		condition += " AND source IN ('roadshow','article','activityvideo','activityvoice') " + conditionInit
 		if user.Mobile == "" && user.Email == "" {
 			startSize = 0

+ 12 - 0
models/company_product.go

@@ -0,0 +1,12 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+)
+
+// 获取是否属于权益客户
+func GetCountCompanyProductCompanyId(companyId, productId int) (count int, err error) {
+	sql := `SELECT  COUNT(1) AS count FROM company_product WHERE company_id = ?  AND product_id = ?  `
+	err = orm.NewOrm().Raw(sql, companyId, productId).QueryRow(&count)
+	return
+}

+ 4 - 1
services/activity_special.go

@@ -634,7 +634,7 @@ func GetActivitySpecialList(user *models.WxUserItem, currentIndex, pageSize int,
 		pageSizePrepare = pageSize - len(listConfirm)
 	}
 	listPrepare, totalPrepare, e := GetActivitySpecialPrepareList(user, startSizePrepare, pageSizePrepare, keywords)
-	if e != nil {
+	if e != nil && e.Error() != utils.ErrNoRow() {
 		err = errors.New("GetActivityLabelSpecialConfirmList, Err: " + e.Error())
 		return
 	}
@@ -645,6 +645,9 @@ func GetActivitySpecialList(user *models.WxUserItem, currentIndex, pageSize int,
 		if startSizePrepare == 0 {
 			listPrepare[0].Explain = utils.ACtIVITY_SPECIAL_EXPLAIN
 		}
+	} else {
+		err = nil
+		return
 	}
 	total = totalConfirm + totalPrepare
 	//处理封面图片