瀏覽代碼

Merge branch 'cygx_8.7' into debug

# Conflicts:
#	controllers/activity.go
#	utils/common.go
ziwen 2 年之前
父節點
當前提交
6d9cd625ce
共有 4 個文件被更改,包括 277 次插入1 次删除
  1. 197 0
      controllers/activity.go
  2. 1 1
      models/page_history_record.go
  3. 9 0
      routers/commentsRouter.go
  4. 70 0
      utils/common.go

+ 197 - 0
controllers/activity.go

@@ -4644,3 +4644,200 @@ func (this *ActivityCoAntroller) ActivityListSearch() {
 	br.Msg = "获取成功"
 	br.Data = resp
 }
+
+// @Title 已结束的活动
+// @Description 获取已结束的活动接口
+// @Param   ChartPermissionIds   query   string  false     "行业id 多个用 , 隔开"
+// @Param   WhichDay   query   string  false       "哪一天 1本周、2上周,3本月,4上月"
+// @Param   IsPower   query   int  false       "是否选择有权限行业 ,1是 0 否 默认0"
+// @Param   TypeName   query   string  false       "电话会类型 ,专家电话会 分析师电话会"
+// @Success 200 {object} models.GetCygxActivityLabelListRep
+// @router /overActivityList [get]
+func (this *ActivityCoAntroller) OverActivityList() {
+	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"
+		return
+	}
+
+	isPower, _ := this.GetInt("IsPower")
+	chartPermissionIds := this.GetString("ChartPermissionIds")
+	whichDay := this.GetString("WhichDay")
+	typeName := this.GetString("TypeName")
+
+	//入参为 undefined 时的处理
+	if chartPermissionIds == "undefined" {
+		chartPermissionIds = ""
+	}
+	if whichDay == "undefined" {
+		whichDay = ""
+	}
+
+
+	userType, permissionStr, err := services.GetUserType(user.CompanyId)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	var startSize, pageSize int
+	pageSize = 24
+	var condition string
+	var sortTime string
+	//var conditionStatus string
+	var pars []interface{}
+	//活动可见限制
+	var sqlExport string
+	resp := new(models.GetCygxActivityLabelListRep)
+	slicePer := strings.Split(permissionStr, ",")
+	var permissionSqlStr string
+	for _, v := range slicePer {
+		if userType == 1 {
+			//if v != "研选" {
+			if !strings.Contains(v, "研选") {
+				permissionSqlStr += "'" + v + "',"
+			}
+		} else {
+			permissionSqlStr += "'" + v + "',"
+		}
+	}
+	permissionSqlStr = strings.TrimRight(permissionSqlStr, ",")
+	permissionSqlStr = strings.Replace(permissionSqlStr, "(主观)", "", -1)
+	permissionSqlStr = strings.Replace(permissionSqlStr, "(客观)", "", -1)
+	permissionSqlStr = ` AND art.chart_permission_name  IN (` + permissionSqlStr + `)`
+	sqlExport = ` AND (art.customer_type_ids LIKE '%` + strconv.Itoa(userType) + `%' `
+	if userType == 2 {
+		sqlExport += ` OR  art.customer_type_ids LIKE '%3%' `
+	}
+	if (userType == 2 || userType == 3) && strings.Contains(permissionStr, "专家") {
+		sqlExport += ` OR  art.customer_type_ids LIKE '%4%' `
+	}
+	sqlExport += `) `
+
+	////进行中的活动
+	//condition = ` AND art.publish_status = 1  AND art.label != ''  AND art.active_state = 2 `
+	//var conditionOr string
+	//if (userType == 2 || userType == 3 || userType == 4) && strings.Contains(permissionStr, "专家") {
+	//	conditionOr += ` OR (  art.is_limit_people = 1 AND art.customer_type_ids LIKE '%4%'	 ` + condition + `) `
+	//}
+	//if (userType == 5) && strings.Contains(permissionStr, "专家") {
+	//	conditionOr += ` OR (  art.is_limit_people = 1 AND art.customer_type_ids LIKE '%5%'	 ` + condition + `) `
+	//}
+	//if userType == 1 {
+	//	conditionOr += ` OR ( art.is_limit_people = 0 ` + condition + permissionSqlStr + `) `
+	//} else {
+	//	conditionOr += ` OR ( art.is_limit_people = 0 ` + condition + `) `
+	//}
+	////判断客户规模是否属于可见范围的活动
+	//companyProduct, err := models.GetCompanyProductDetail(user.CompanyId, 2)
+	//if err != nil && err.Error() != utils.ErrNoRow() {
+	//	br.Msg = "获取信息失败"
+	//	br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
+	//	return
+	//}
+	//
+	//if companyProduct != nil {
+	//	if companyProduct.Scale != "" {
+	//		conditionOr += ` OR (  art.scale LIKE '%` + companyProduct.Scale + `%'	 ` + condition + `) `
+	//	}
+	//}
+	//condition += `AND art.is_limit_people = 1 ` + permissionSqlStr + sqlExport + conditionOr
+	//
+	////进行中的活动
+	//sortTime = ` mintimesort ASC `
+	//list, errList := models.GetActivityLabelListAll(condition, sortTime, pars, startSize, pageSize)
+	//if errList != nil {
+	//	br.Msg = "获取失败"
+	//	br.ErrMsg = "获取失败,Err:" + errList.Error()
+	//	return
+	//}
+
+	//已结束的活动
+	var conditionOr string
+	conditionOr = ""
+	condition = ` AND art.publish_status = 1  AND art.label != ''  AND art.active_state = 3 `
+	//if (userType == 2 || userType == 3 || userType == 4) && strings.Contains(permissionStr, "专家") {
+	//	conditionOr += ` OR (  art.is_limit_people = 1 AND art.customer_type_ids LIKE '%4%'	 ` + condition + `) `
+	//}
+	//if (userType == 5) && strings.Contains(permissionStr, "专家") {
+	//	conditionOr += ` OR (  art.is_limit_people = 1 AND art.customer_type_ids LIKE '%5%'	 ` + condition + `) `
+	//}
+	//if userType == 1 {
+	//	conditionOr += ` OR ( art.is_limit_people = 0 ` + condition + permissionSqlStr + `) `
+	//} else {
+	//	conditionOr += ` OR ( art.is_limit_people = 0 ` + condition + `) `
+	//}
+	condition += `AND art.is_limit_people = 1 ` + permissionSqlStr + sqlExport + conditionOr
+	startSize = 0
+
+	if isPower == 1 {
+		condition += permissionSqlStr
+	}
+	if whichDay != "" {
+		var startDate string
+		var endDate string
+		if whichDay == "1" {
+			startDate = utils.GetNowWeekMonday().Format(utils.FormatDate)
+			endDate = utils.GetNowWeekSunday().Format(utils.FormatDate)
+		} else if whichDay == "2" {
+			startDate = utils.GetLastWeekMonday().Format(utils.FormatDate)
+			endDate = utils.GetLastWeekSunday().Format(utils.FormatDate)
+		}  else if whichDay == "3" {
+			startDate = utils.GetNowMonthFirstDay().Format(utils.FormatDate)
+			endDate = utils.GetNowMonthLastDay().Format(utils.FormatDate)
+		} else if whichDay == "4" {
+			startDate = utils.GetLastMonthFirstDay().Format(utils.FormatDate)
+			endDate = utils.GetLastMonthLastDay().Format(utils.FormatDate)
+		}else {
+			startDate = utils.GetNowWeekMonday().Format(utils.FormatDate)
+			endDate = utils.GetNowWeekSunday().Format(utils.FormatDate)
+		}
+		condition += ` AND art.activity_time >= ` + "'" + startDate + " 00:00:00'"
+		condition += ` AND art.activity_time <= ` + "'" + endDate + " 23:59:59'"
+	}
+	if len(chartPermissionIds) > 0 {
+		condition += ` AND art.chart_permission_id  IN (` + chartPermissionIds + `)`
+	}
+	if typeName != ""{
+		condition += ` AND art.activity_type_name = ` + "'" + typeName + " '"
+	}
+
+	//pageSize = 24 - len(list)
+
+	//已结束的活动
+	sortTime = ` timesort DESC `
+	list, err := models.GetActivityLabelListAll(condition, sortTime, pars, startSize, pageSize)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	//for _, v := range listEnd {
+	//	list = append(list, v)
+	//}
+	//标签字段关联的产业与标签处理
+	for k, v := range list {
+		list[k].KeyWord = services.LabelStr(v.KeyWord)
+	}
+	//添加更多主题访问记录
+	item := new(models.CygxPageHistoryRecord)
+	item.UserId = user.UserId
+	item.CreateTime = time.Now()
+	item.Mobile = user.Mobile
+	item.Email = user.Email
+	item.CompanyId = user.CompanyId
+	item.CompanyName = user.CompanyName
+	item.PageType = "OverActivity"
+	go models.AddCygxPageHistoryRecord(item)
+	resp.List = list
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}

+ 1 - 1
models/page_history_record.go

@@ -16,7 +16,7 @@ type CygxPageHistoryRecord struct {
 	DetailId               string    `description:"详情ID"`
 	ChartPermissionId      int       `description:"行业ID"`
 	IndustrialManagementId string    `description:"产业ID"`
-	PageType               string    `description:"页面类型,纪要:Summary,纪要搜索:SummarySearch,报告:Report,报告搜索:ReportSearch,产业列表:IndustryList,活动:Activit,活动搜索:ActivitSearch,活动详情:ActivitParticulars,报告详情:ReportParticulars"`
+	PageType               string    `description:"页面类型,纪要:Summary,纪要搜索:SummarySearch,报告:Report,报告搜索:ReportSearch,产业列表:IndustryList,活动:Activit,活动搜索:ActivitSearch,活动详情:ActivitParticulars,报告详情:ReportParticulars,已结束活动:OverActivity"`
 }
 
 type CygxPageHistoryRecordRep struct {

+ 9 - 0
routers/commentsRouter.go

@@ -151,6 +151,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ActivityCoAntroller"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ActivityCoAntroller"],
+        beego.ControllerComments{
+            Method: "OverActivityList",
+            Router: `/overActivityList`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ActivityCoAntroller"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ActivityCoAntroller"],
         beego.ControllerComments{
             Method: "ScheduleList",

+ 70 - 0
utils/common.go

@@ -754,3 +754,73 @@ func InArrayByStr(idStrList []string, searchId string) (has bool) {
 	}
 	return
 }
+
+// GetNowWeekMonday 获取本周周一的时间
+func GetNowWeekMonday() time.Time {
+	offset := int(time.Monday - time.Now().Weekday())
+	if offset == 1 { //正好是周日,但是按照中国人的理解,周日是一周最后一天,而不是一周开始的第一天
+		offset = -6
+	}
+	mondayTime := time.Now().AddDate(0, 0, offset)
+	mondayTime = time.Date(mondayTime.Year(), mondayTime.Month(), mondayTime.Day(), 0, 0, 0, 0, mondayTime.Location())
+	return mondayTime
+}
+
+// GetLastWeekMonday 获取上周周一的时间
+func GetLastWeekMonday() time.Time {
+	offset := int(time.Monday - time.Now().Weekday())
+	if offset == 1 { //正好是周日,但是按照中国人的理解,周日是一周最后一天,而不是一周开始的第一天
+		offset = -6
+	}
+	mondayTime := time.Now().AddDate(0, 0, offset-7)
+	mondayTime = time.Date(mondayTime.Year(), mondayTime.Month(), mondayTime.Day(), 0, 0, 0, 0, mondayTime.Location())
+	return mondayTime
+}
+
+// GetNowWeekSunDay 获取本周周日的时间
+func GetNowWeekSunday() time.Time {
+	offset := int(time.Sunday - time.Now().Weekday())
+	if offset == 1 { //正好是周日,但是按照中国人的理解,周日是一周最后一天,而不是一周开始的第一天
+		offset = -6
+	}
+	mondayTime := time.Now().AddDate(0, 0, offset)
+	mondayTime = time.Date(mondayTime.Year(), mondayTime.Month(), mondayTime.Day(), 0, 0, 0, 0, mondayTime.Location())
+	return mondayTime
+}
+
+// GetLastWeekSunday 获取上周周日的时间
+func GetLastWeekSunday() time.Time {
+	offset := int(time.Sunday - time.Now().Weekday())
+	if offset == 1 { //正好是周日,但是按照中国人的理解,周日是一周最后一天,而不是一周开始的第一天
+		offset = -6
+	}
+	mondayTime := time.Now().AddDate(0, 0, offset-7)
+	mondayTime = time.Date(mondayTime.Year(), mondayTime.Month(), mondayTime.Day(), 0, 0, 0, 0, mondayTime.Location())
+	return mondayTime
+}
+
+// GetNowMonthFirstDay 获取本月第一天的时间
+func GetNowMonthFirstDay() time.Time {
+	nowMonthFirstDay := time.Date(time.Now().Year(), time.Now().Month(), 1, 0, 0, 0, 0, time.Now().Location())
+	return nowMonthFirstDay
+}
+
+// GetNowMonthLastDay 获取本月最后一天的时间
+func GetNowMonthLastDay() time.Time {
+	nowMonthLastDay := time.Date(time.Now().Year(), time.Now().Month(), 1, 0, 0, 0, 0, time.Now().Location()).AddDate(0, 1, -1)
+	nowMonthLastDay = time.Date(nowMonthLastDay.Year(), nowMonthLastDay.Month(), nowMonthLastDay.Day(), 23, 59, 59, 0, nowMonthLastDay.Location())
+	return nowMonthLastDay
+}
+
+// GetNowMonthFirstDay 获取上月第一天的时间
+func GetLastMonthFirstDay() time.Time {
+	nowMonthFirstDay := time.Date(time.Now().Year(), time.Now().AddDate(0,-1,0).Month(), 1, 0, 0, 0, 0, time.Now().Location())
+	return nowMonthFirstDay
+}
+
+// GetNowMonthLastDay 获取上月最后一天的时间
+func GetLastMonthLastDay() time.Time {
+	nowMonthLastDay := time.Date(time.Now().Year(), time.Now().AddDate(0,-1,0).Month(), 1, 0, 0, 0, 0, time.Now().Location()).AddDate(0, 1, -1)
+	nowMonthLastDay = time.Date(nowMonthLastDay.Year(), nowMonthLastDay.Month(), nowMonthLastDay.Day(), 23, 59, 59, 0, nowMonthLastDay.Location())
+	return nowMonthLastDay
+}