xingzai пре 1 година
родитељ
комит
1afc2416b5
4 измењених фајлова са 50 додато и 0 уклоњено
  1. 1 0
      controllers/report.go
  2. 11 0
      models/questionnaire.go
  3. 1 0
      models/report.go
  4. 37 0
      services/questionnaire.go

+ 1 - 0
controllers/report.go

@@ -1406,6 +1406,7 @@ func (this *ReportController) IsShow() {
 	//resp.YanXuan_Explain = true
 	resp.IsShowFreeButton = IsShowFreeButton
 	resp.IsBelongRai = services.GetBelongingRai(user.Mobile)
+	resp.IsShowQuestionnaire = services.GetQuestionnaireButtonIsShow() // 获取研选问卷调查按钮是否展示
 	resp.IsShowResearchPoints = true
 	//mobile := user.Mobile
 	//if mobile == "" {

+ 11 - 0
models/questionnaire.go

@@ -40,6 +40,17 @@ func GetCygxQuestionnaireDetail(questionnaireId int) (item *CygxQuestionnaireRes
 	return
 }
 
+// 获取数量
+func GetCygxQuestionnaireCount(condition string, pars []interface{}) (count int, err error) {
+	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_questionnaire as art WHERE 1= 1  `
+	if condition != "" {
+		sqlCount += condition
+	}
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, pars).QueryRow(&count)
+	return
+}
+
 // 通过ID获取详情
 func GetCygxQuestionnaireDetailBestNew() (item *CygxQuestionnaireResp, err error) {
 	o := orm.NewOrm()

+ 1 - 0
models/report.go

@@ -382,6 +382,7 @@ type IsShow struct {
 	SearchTxtList          SearchTxt `description:"搜索栏回显内容说明"`
 	IsBelongRai            bool      `description:"是否属于权益内部人员"`
 	IsShowResearchPoints   bool      `description:"是否展示研选扣点搜索"`
+	IsShowQuestionnaire    bool      `description:"是否展示研选问卷调查"`
 }
 
 type SearchTxt struct {

+ 37 - 0
services/questionnaire.go

@@ -0,0 +1,37 @@
+package services
+
+import (
+	"errors"
+	"fmt"
+	"hongze/hongze_cygx/models"
+	"hongze/hongze_cygx/utils"
+	"time"
+)
+
+//func init() {
+//	fmt.Println(GetQuestionnaireButtonIsShow())
+//}
+
+// 获取研选问卷调查按钮是否展示
+func GetQuestionnaireButtonIsShow() (isShow bool) {
+	var err error
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			go utils.SendAlarmMsg("约访专家的请求失败"+err.Error(), 2)
+		}
+	}()
+	var condition string
+	var pars []interface{}
+	condition += ` AND end_time >= ? `
+	pars = append(pars, time.Now().Format(utils.FormatDate))
+	total, e := models.GetCygxQuestionnaireCount(condition, pars)
+	if e != nil {
+		err = errors.New("GetCygxQuestionnaireCount, Err: " + e.Error())
+		return
+	}
+	if total > 0 {
+		isShow = true
+	}
+	return
+}