Browse Source

Merge branch 'cygx_8.2' of http://8.136.199.33:3000/hongze/hongze_cygx into debug

xingzai 2 years ago
parent
commit
bbada6a921

+ 1 - 0
controllers/activity.go

@@ -1251,6 +1251,7 @@ func (this *ActivityCoAntroller) SignupAdd() {
 				resp.SignupType = signupType
 				resp.SignupStatus = signupStatus
 				resp.HasPermission = hasPermission
+				resp.PopupMsg = "活动开始前1小时内无法预约,请联系对口销售处理"
 				br.Ret = 200
 				br.Success = true
 				br.Msg = ""

+ 326 - 0
controllers/activity_special.go

@@ -0,0 +1,326 @@
+package controllers
+
+import (
+	"github.com/rdlucklib/rdluck_tools/paging"
+	"hongze/hongze_cygx/models"
+	"hongze/hongze_cygx/services"
+	"hongze/hongze_cygx/utils"
+	"strconv"
+	"strings"
+)
+
+//专项调研活动
+type ActivitySpecialCoAntroller struct {
+	BaseAuthController
+}
+
+// @Title 专项产业调研列表
+// @Description 获取专项产业调研列表接口
+// @Param   PageSize   query   int  true       "每页数据条数"
+// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
+// @Success 200 {object} models.GetCygxActivitySpecialDetailListResp
+// @router /list [get]
+func (this *ActivitySpecialCoAntroller) SpecialList() {
+	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
+	}
+	pageSize, _ := this.GetInt("PageSize")
+	currentIndex, _ := this.GetInt("CurrentIndex")
+	if pageSize <= 0 {
+		pageSize = utils.PageSize20
+	}
+	if currentIndex <= 0 {
+		currentIndex = 1
+	}
+	list, total, errList := services.GetActivitySpecialList(user, currentIndex, pageSize, "")
+	if errList != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + errList.Error()
+		return
+	}
+	page := paging.GetPaging(currentIndex, pageSize, total)
+	resp := new(models.GetCygxActivitySpecialDetailListResp)
+	count, err := models.GetCygxUserFollowSpecial(user.UserId)
+	if err != nil {
+		br.Msg = "获取数据失败!"
+		br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
+		return
+	}
+	if count == 1 && user.UserId > 0 {
+		resp.IsFollow = true
+	}
+	if user.Mobile != "" {
+		resp.IsBindingMobile = true
+	}
+	resp.List = list
+	resp.Paging = page
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+
+}
+
+// @Title  专项产业调研详情
+// @Description 获取专项产业调研详情接口
+// @Param   ActivityId   query   int  true       "活动ID"
+// @Success Ret=200 {object} models.CygxActivitySpecialResp
+// @router /detail [get]
+func (this *ActivitySpecialCoAntroller) SpecialDetail() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	user := this.User
+	if user == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,用户信息为空"
+		br.Ret = 408
+		return
+	}
+	uid := user.UserId
+	activityId, _ := this.GetInt("ActivityId")
+	if activityId < 1 {
+		br.Msg = "请输入活动ID"
+		return
+	}
+	resp := new(models.CygxActivitySpecialResp)
+	hasPermission := 0
+
+	activityInfo, err := models.GetCygxActivitySpecialDetailById(uid, activityId)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
+		return
+	}
+	if activityInfo == nil {
+		br.Msg = "活动不存在"
+		br.ErrMsg = "活动ID错误,Err:" + "activityId:" + strconv.Itoa(activityId)
+		return
+	}
+	applyCount, err := models.GetApplyRecordCount(uid)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
+		return
+	}
+	//获取FICC销售信息 如果是FICC的客户类型,则默认他申请过
+	sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 1)
+	if err != nil && err.Error() != utils.ErrNoRow() {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
+		return
+	}
+	if user.CompanyId <= 1 {
+		//companyDetailStatus = ""
+	} else {
+		companyPermission, err := models.GetCompanyPermission(user.CompanyId)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
+			return
+		}
+		if companyPermission == "" {
+			if applyCount > 0 {
+				hasPermission = 4
+			} else {
+				if sellerItem != nil {
+					hasPermission = 5
+				} else {
+					//获取权益销售信息 如果是FICC的客户类型,则默认他申请过
+					sellerItemQy, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
+					if err != nil && err.Error() != utils.ErrNoRow() {
+						br.Msg = "获取信息失败"
+						br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
+						return
+					}
+					if sellerItemQy != nil {
+						hasPermission = 2
+						resp.SellerMobile = sellerItemQy.Mobile
+						resp.SellerName = sellerItemQy.RealName
+					} else {
+						hasPermission = 3
+					}
+				}
+			}
+			resp.HasPermission = hasPermission
+			resp.OperationMode = "Apply"
+			resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
+			br.Ret = 200
+			br.Success = true
+			br.Msg = "获取成功"
+			br.Data = resp
+			return
+		}
+		companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
+		if err != nil {
+			br.Msg = "获取信息失败!"
+			br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
+			return
+		}
+		if companyDetail == nil {
+			br.Msg = "获取信息失败!"
+			br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId) + "CompanyId:" + strconv.Itoa(user.CompanyId)
+			return
+		}
+	}
+	userType, permissionStr, err := services.GetUserType(user.CompanyId)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
+		return
+	}
+	itemAct := new(models.ActivityDetail)
+	itemAct.CustomerTypeIds = activityInfo.CustomerTypeIds
+	noPower, err := services.GetShareNoPowe(itemAct, permissionStr, userType, user)
+	if err != nil {
+		br.Msg = "获取信息失败"
+		br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
+		return
+	}
+
+	//获取用户的产业规模,判断是否允许可见
+	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 != "" {
+			if strings.Count(activityInfo.Scale, companyProduct.Scale) > 0 {
+				noPower = false
+			}
+		}
+	}
+	if noPower {
+		br.Msg = "您暂无查看该活动权限"
+		br.ErrMsg = "被分享客户不可见,获取信息失败"
+		br.IsSendEmail = false
+		return
+	}
+
+	if userType == 1 && strings.Contains(activityInfo.ChartPermissionName, "研选") {
+		br.Msg = "您暂无查看该活动权限"
+		br.ErrMsg = "被分享客户不可见,永续客户无法查看研选行业"
+		return
+	}
+	//判断是否已经申请过
+	if user.CompanyId > 1 {
+		permissionStr, err := models.GetCompanyPermissionByUser(user.CompanyId)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取客户权限信息失败,Err:" + err.Error()
+			return
+		}
+		companyItem, err := models.GetCompanyDetailById(user.CompanyId)
+		//冻结客户
+		if err != nil {
+			if err.Error() == utils.ErrNoRow() {
+				if applyCount > 0 {
+					hasPermission = 4
+				} else {
+					if sellerItem != nil {
+						hasPermission = 5
+					} else {
+						//获取权益销售信息 如果是FICC的客户类型,则默认他申请过
+						sellerItemQy, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
+						if err != nil && err.Error() != utils.ErrNoRow() {
+							br.Msg = "获取信息失败"
+							br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
+							return
+						}
+						if sellerItemQy != nil {
+							hasPermission = 2
+							resp.SellerMobile = sellerItemQy.Mobile
+							resp.SellerName = sellerItemQy.RealName
+						} else {
+							hasPermission = 3
+						}
+					}
+				}
+				resp.HasPermission = hasPermission
+				resp.OperationMode = "Apply"
+				resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
+				br.Ret = 200
+				br.Success = true
+				br.Msg = "获取成功"
+				br.Data = resp
+				return
+			} else {
+				br.Msg = "获取信息失败"
+				br.ErrMsg = "获取客户公司信息失败,Err:" + err.Error()
+				return
+			}
+		}
+		var havePower bool
+		if strings.Contains(permissionStr, activityInfo.ActivityTypeName) {
+			havePower = true
+		}
+		if havePower {
+			hasPermission = 1
+			resp.HaqveJurisdiction = true
+		} else {
+			if permissionStr == "专家" {
+				resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
+				resp.MsgType = "Type"
+			} else {
+				resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
+				resp.MsgType = "Industry"
+			}
+			if companyItem.ProductId == 2 {
+				resp.SellerMobile = companyItem.Mobile
+				resp.SellerName = companyItem.SellerName
+				resp.OperationMode = "Call"
+				hasPermission = 2
+			} else {
+				hasPermission = 5
+			}
+		}
+	} else { //潜在客户
+		if applyCount > 0 {
+			hasPermission = 4
+		} else {
+			if sellerItem != nil {
+				hasPermission = 5
+			} else {
+				hasPermission = 3
+			}
+		}
+		resp.OperationMode = "Apply"
+		resp.PopupMsg = "您暂无权限参加此活动,若想参加可以申请开通对应的试用权限"
+	}
+	if hasPermission == 1 {
+		count, err := models.GetCygxUserFollowSpecial(user.UserId)
+		if err != nil {
+			br.Msg = "获取数据失败!"
+			br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
+			return
+		}
+		if count == 1 {
+			resp.IsFollow = true
+		}
+		activityInfo, err := services.HandleActivitySpecialShow(activityInfo, user)
+		if err != nil {
+			br.Msg = "获取数据失败!"
+			br.ErrMsg = "HandleActivitySpecialShow,Err:" + err.Error()
+			return
+		}
+		activityInfo.ActivityTypeName = "专项调研"
+		resp.Detail = activityInfo
+	}
+	resp.HasPermission = hasPermission
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}

+ 1 - 0
controllers/report.go

@@ -1220,6 +1220,7 @@ func (this *ReportController) IsShow() {
 	resp.IsShowChart = true
 	resp.IsShowResearch = true
 	resp.LinkWxExplain = utils.LINK_WX_EXPLAIN
+	resp.ActivitySpecialExplain = utils.ACTIVITY_SPECIAL_EXPLAIN
 	resp.YanXuan_Explain = true
 	resp.IsShowFreeButton = IsShowFreeButton
 	mobile := user.Mobile

+ 14 - 2
models/activity.go

@@ -747,6 +747,18 @@ type CygxActivitySpecialDetail struct {
 	IndustrialSubjectName string `description:"标的名称(相关公司)"`
 	Scale                 string `description:"管理规模,空不填,1::50亿以下,2:50~100亿,3:100亿以上。多个用, 隔开"`
 	CustomerTypeIds       string `description:"活动可见的客户类型,多个ID用 , 隔开"`
+	IsTrip                int    `description:"是否报名 1是 ,0 否"`
+	Days                  int    `description:"调研天数"`
+	Host                  string `description:"主持人"`
+	PersonInCharge        string `description:"纪要负责人"`
+	LimitPeopleNum        int    `description:"限制人数数量"`
+	TripImgLinkFix        string `description:"确定行程之后的图片链接"`
+	ActivityTimeTextByDay string `description:"活动预期时间带周日"`
+	ActivityTime          string `description:"活动预期时间"`
+	ActivityTimeEnd       string `description:"活动预期结束时间"`
+	ActiveState           int    `description:"活动进行状态 未开始:1、进行中2、已结束3"`
+	TripStatus            int    `description:"行程进行状态 1:预报名,2:确定行程"`
+	Explain               string `description:"说明"`
 }
 
 type GetCygxActivitySpecialDetailListResp struct {
@@ -802,8 +814,8 @@ WHERE
 	if condition != "" {
 		sql += condition
 	}
-	sql += ` ORDER BY art.last_updated_time DESC  LIMIT ?,? `
-	_, err = o.Raw(sql, pars, uid, startSize, pageSize).QueryRows(&items)
+	sql += `  LIMIT ?,? `
+	_, err = o.Raw(sql, uid, pars, startSize, pageSize).QueryRows(&items)
 	return
 }
 

+ 31 - 0
models/activity_special_trip.go

@@ -0,0 +1,31 @@
+package models
+
+import (
+	//"hongze/hongze_admin/models"
+	"github.com/beego/beego/v2/client/orm"
+)
+
+type CygxActivitySpecialTripResp struct {
+	Id             int    `description:"ID"`
+	UserId         int    `description:"用户id"`
+	ActivityId     int    `description:"活动ID"`
+	CreateTime     string `description:"创建时间"`
+	Mobile         string `description:"手机号"`
+	Email          string `description:"邮箱号"`
+	CompanyId      int    `description:"公司ID"`
+	CompanyName    string `description:"公司名称"`
+	RealName       string `description:"用户实际名称"`
+	SellerName     string `description:"所属销售"`
+	OutboundMobile string `description:"外呼手机号"`
+	CountryCode    string `description:"手机国家区号"`
+}
+
+func GetCygxActivitySpecialTripList(condition string, pars []interface{}) (item []*CygxActivitySpecialTripResp, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT *
+			FROM
+			cygx_activity_special_trip  
+			WHERE 1 = 1 ` + condition
+	_, err = o.Raw(sql, pars).QueryRows(&item)
+	return
+}

+ 9 - 8
models/report.go

@@ -226,14 +226,15 @@ func GetWhichDepartmentCount(condition string) (count int, err error) {
 }
 
 type IsShow struct {
-	IsShow           bool      `description:"绝密内参按钮是否展示"`
-	IsShowFreeButton bool      `description:"免费送月卡按钮是否展示"`
-	IsShowResearch   bool      `description:"研选是否展示限免"`
-	IsShowChart      bool      `description:"图表是否展示限免"`
-	IsShowList       bool      `description:"榜单是否展示"`
-	LinkWxExplain    string    `description:"关注微信公众号链接说明地址"`
-	YanXuan_Explain  bool      `description:"研选说明"`
-	SearchTxtList    SearchTxt `description:"搜索栏回显内容说明"`
+	IsShow                 bool      `description:"绝密内参按钮是否展示"`
+	IsShowFreeButton       bool      `description:"免费送月卡按钮是否展示"`
+	IsShowResearch         bool      `description:"研选是否展示限免"`
+	IsShowChart            bool      `description:"图表是否展示限免"`
+	IsShowList             bool      `description:"榜单是否展示"`
+	LinkWxExplain          string    `description:"关注微信公众号链接说明地址"`
+	YanXuan_Explain        bool      `description:"研选说明"`
+	ActivitySpecialExplain string    `description:"专项调研活动"`
+	SearchTxtList          SearchTxt `description:"搜索栏回显内容说明"`
 }
 
 type SearchTxt struct {

+ 18 - 0
routers/commentsRouter.go

@@ -223,6 +223,24 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ActivitySpecialCoAntroller"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ActivitySpecialCoAntroller"],
+        beego.ControllerComments{
+            Method: "SpecialDetail",
+            Router: `/detail`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ActivitySpecialCoAntroller"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:ActivitySpecialCoAntroller"],
+        beego.ControllerComments{
+            Method: "SpecialList",
+            Router: `/list`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:AdviceController"] = append(beego.GlobalControllerRouter["hongze/hongze_cygx/controllers:AdviceController"],
         beego.ControllerComments{
             Method: "ApplyApprove",

+ 5 - 0
routers/router.go

@@ -129,6 +129,11 @@ func init() {
 				&controllers.MicroRoadShowController{},
 			),
 		),
+		web.NSNamespace("/activity_special",
+			web.NSInclude(
+				&controllers.ActivitySpecialCoAntroller{},
+			),
+		),
 	)
 	web.AddNamespace(ns)
 }

+ 273 - 0
services/activity_special.go

@@ -2,10 +2,12 @@ package services
 
 import (
 	"context"
+	"errors"
 	"fmt"
 	"hongze/hongze_cygx/models"
 	"hongze/hongze_cygx/utils"
 	"strconv"
+	"strings"
 	"time"
 )
 
@@ -106,3 +108,274 @@ func GetActivityLabelSpecialList(userType, isPower int, chartPermissionIds, scal
 	item = itemList
 	return
 }
+
+//HandleActivityLabelSpecialPermission 处理专项产业调研的查询权限sql
+func HandleActivityLabelSpecialPermission(user *models.WxUserItem) (condition string, err error) {
+	userType, permissionStr, err := GetUserType(user.CompanyId)
+	if err != nil {
+		return
+	}
+	slicePer := strings.Split(permissionStr, ",")
+	var permissionSqlStr string
+	for _, v := range slicePer {
+		if userType == 1 {
+			if !strings.Contains(v, "研选") {
+				permissionSqlStr += "'" + v + "',"
+			}
+		} else {
+			permissionSqlStr += "'" + v + "',"
+		}
+	}
+	permissionSqlStr = strings.TrimRight(permissionSqlStr, ",")
+	permissionSqlStr = strings.Replace(permissionSqlStr, "(主观)", "", -1)
+	permissionSqlStr = strings.Replace(permissionSqlStr, "(客观)", "", -1)
+	condition = ` AND art.publish_status = 1  AND art.label != ''  AND art.is_offline = 0  `
+	condition += ` AND art.chart_permission_name  IN (` + permissionSqlStr + `) `
+	condition += ` AND  art.customer_type_ids LIKE '%` + strconv.Itoa(userType) + `%' `
+	return
+}
+
+//获取预报名列表
+func GetActivitySpecialPrepareList(user *models.WxUserItem, startSize, pageSize int, keywords string) (list []*models.CygxActivitySpecialDetail, totalPrepare int, err error) {
+	condition, e := HandleActivityLabelSpecialPermission(user)
+	if e != nil {
+		err = errors.New("HandleActivityLabelSpecialPermission, Err: " + e.Error())
+		return
+	}
+	var pars []interface{}
+	condition += ` AND art.days = 0  AND art.publish_status = 1 AND art.is_offline = 0   `
+	if keywords != "" {
+		keywords = "%" + keywords + "%"
+		condition += ` AND art.research_theme LIKE ? `
+		pars = append(pars, keywords)
+	}
+	totalPrepare, e = models.GetActivitySpecialCount(condition, pars)
+	if e != nil {
+		err = errors.New("GetActivitySpecialCount, Err: " + e.Error())
+		return
+	}
+	condition += `  ORDER BY art.last_updated_time DESC `
+	list, e = models.GetCygxActivitySpecialDetailList(condition, pars, user.UserId, startSize, pageSize)
+	if e != nil {
+		err = errors.New("GetCygxActivitySpecialDetailList, Err: " + e.Error())
+		return
+	}
+	return
+}
+
+/*
+确定行程的查询  GetActivityLabelSpecialConfirmList
+state 进行状态 1:未开始,2:进行中,3:已结束 不传默认查询全部items []*CygxActivitySpecialDetail
+*/
+func GetActivityLabelSpecialConfirmList(user *models.WxUserItem, startSize, pageSize, state int, keywords string) (list []*models.CygxActivitySpecialDetail, totalConfirm int, err error) {
+	//var condition string
+	condition, e := HandleActivityLabelSpecialPermission(user)
+	if e != nil {
+		err = errors.New("HandleActivityLabelSpecialPermission, Err: " + e.Error())
+		return
+	}
+	var pars []interface{}
+	condition += ` AND art.days >0  `
+	if state == 1 {
+		condition += ` AND art.activity_time > ? `
+		pars = append(pars, time.Now())
+	}
+	if state == 2 {
+		condition += ` AND art.activity_time < ? `
+		pars = append(pars, time.Now())
+		condition += ` AND art.activity_time_end > ? `
+		pars = append(pars, time.Now())
+	}
+	if state == 3 {
+		condition += ` AND art.activity_time_end < ? `
+		pars = append(pars, time.Now())
+	}
+
+	if keywords != "" {
+		keywords = "%" + keywords + "%"
+		condition += ` AND art.research_theme LIKE ? `
+		pars = append(pars, keywords)
+	}
+	totalConfirm, e = models.GetActivitySpecialCount(condition, pars)
+	if e != nil {
+		err = errors.New("GetActivitySpecialCount, Err: " + e.Error())
+		return
+	}
+	condition += `  ORDER BY art.activity_time DESC `
+	list, e = models.GetCygxActivitySpecialDetailList(condition, pars, user.UserId, startSize, pageSize)
+	if e != nil {
+		err = errors.New("GetCygxActivitySpecialDetailList, Err: " + e.Error())
+		return
+	}
+
+	var activityIds []int
+	for k, v := range list {
+		resultTimeStart := utils.StrTimeToTime(v.ActivityTime)  //时间字符串格式转时间格式
+		resultTimeEnd := utils.StrTimeToTime(v.ActivityTimeEnd) //时间字符串格式转时间格式
+		if resultTimeStart.After(time.Now()) {
+			list[k].ActiveState = 1
+		} else if time.Now().After(resultTimeEnd) {
+			list[k].ActiveState = 3
+		} else {
+			list[k].ActiveState = 2
+		}
+		if list[k].Days == 0 {
+			list[k].TripStatus = 1
+		} else {
+			list[k].TripStatus = 2
+		}
+		activityIds = append(activityIds, v.ActivityId)
+	}
+
+	//处理用户已经报名了的行程
+	UserMap, e := GetSpecialTripUserMap(activityIds, user.UserId)
+	if e != nil {
+		err = errors.New("GetSpecialTripUserMap, Err: " + e.Error())
+		return
+	}
+	for k, v := range list {
+		if _, ok := UserMap[v.ActivityId]; ok {
+			list[k].IsTrip = 1
+		}
+	}
+	return
+}
+
+//获取用户已经报名的活动
+func GetSpecialTripUserMap(activityIds []int, userId int) (mapUserId map[int]int, err error) {
+	var condition string
+	var pars []interface{}
+	activityIdsLen := len(activityIds)
+	if activityIdsLen > 0 {
+		condition += ` AND activity_id IN (` + utils.GetOrmInReplace(activityIdsLen) + `)`
+		pars = append(pars, activityIds)
+	}
+	condition += ` AND user_id = ?  AND is_cancel = 0 `
+	pars = append(pars, userId)
+	list, e := models.GetCygxActivitySpecialTripList(condition, pars)
+	if e != nil {
+		err = errors.New("GetCygxActivitySpecialTripList, Err: " + e.Error())
+		return
+	}
+	mapUid := make(map[int]int)
+	for _, v := range list {
+		mapUid[v.UserId] = v.UserId
+	}
+	mapUserId = mapUid
+	return
+}
+
+//GetActivitySpecialList 获取专项调研列表
+func GetActivitySpecialList(user *models.WxUserItem, currentIndex, pageSize int, keywords string) (list []*models.CygxActivitySpecialDetail, total int, err error) {
+	listConfirm, totalConfirm, e := GetActivityLabelSpecialConfirmList(user, (currentIndex-1)*pageSize, pageSize, 1, keywords)
+	if e != nil {
+		err = errors.New("GetActivityLabelSpecialConfirmList, Err: " + e.Error())
+		return
+	}
+	if currentIndex == 1 && len(listConfirm) > 0 {
+		listConfirm[0].Explain = "此类调研时间安排已经确定,点击报名后按人次扣除对应机构的服务点数。由于每场活动人数有限,如果不能参加请提前48小时取消,未及时取消导致影响其他客户报名将会维持扣点。"
+	}
+	list = listConfirm
+	total = totalConfirm
+	var startSizePrepare, pageSizePrepare int
+	//全是确定行程的查询数据
+	if totalConfirm >= currentIndex*pageSize {
+		total = totalConfirm
+		startSizePrepare = 0
+		pageSizePrepare = 0
+		return
+	} else if totalConfirm > (currentIndex-1)*pageSize && totalConfirm < currentIndex*pageSize {
+		//一半确认行程一半预报名
+		startSizePrepare = 0
+		pageSizePrepare = pageSize - len(listConfirm)
+	} else {
+		//全是预报名
+		startSizePrepare = (currentIndex-1)*pageSize - totalConfirm
+		pageSizePrepare = pageSize - len(listConfirm)
+	}
+	listPrepare, totalPrepare, e := GetActivitySpecialPrepareList(user, startSizePrepare, pageSizePrepare, keywords)
+	if e != nil {
+		err = errors.New("GetActivityLabelSpecialConfirmList, Err: " + e.Error())
+		return
+	}
+	if len(listPrepare) > 0 {
+		for _, v := range listPrepare {
+			list = append(list, v)
+		}
+		if startSizePrepare == 0 {
+			listPrepare[0].Explain = "此类调研具体行程尚未确认,待预报名人数满10人后弘则会确定行程并推送给您活动日期,只有在确认行程中再次报名才完成占位。"
+		}
+	}
+	total = totalConfirm + totalPrepare
+
+	//处理封面图片
+	detail, e := models.GetConfigByCode("city_img_url")
+	if e != nil {
+		err = errors.New("GetConfigByCode, Err: " + e.Error())
+		return
+	}
+	detailChart, e := models.GetConfigByCode("chart_img_url")
+	if e != nil {
+		err = errors.New("GetConfigByCode, Err: " + e.Error())
+		return
+	}
+	addressList := strings.Split(detail.ConfigValue, "{|}")
+	mapAddress := make(map[string]string)
+	chartList := strings.Split(detailChart.ConfigValue, "{|}")
+	mapChart := make(map[string]string)
+	var cityName string
+	var chartName string
+	var imgUrl string
+	var imgUrlChart string
+	for _, v := range addressList {
+		vslice := strings.Split(v, "_")
+		cityName = vslice[0]
+		imgUrl = vslice[len(vslice)-1]
+		mapAddress[cityName] = imgUrl
+	}
+	for _, v := range chartList {
+		vslice := strings.Split(v, "_")
+		chartName = vslice[0]
+		imgUrlChart = vslice[len(vslice)-1]
+		mapChart[chartName] = imgUrlChart
+	}
+	for k, v := range list {
+		list[k].ImgUrlText = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202112/20211221/bIdfv8t86xrFRpDOeGGHXOmKEuKl.png"
+		if mapChart[v.ChartPermissionName] != "" {
+			list[k].ImgUrl = mapChart[v.ChartPermissionName]
+		}
+		list[k].ActivityTypeName = "专项调研"
+	}
+	return
+}
+
+//HandleActivitySpecialShow 处理活动的状态
+func HandleActivitySpecialShow(activityDetail *models.CygxActivitySpecialDetail, user *models.WxUserItem) (item *models.CygxActivitySpecialDetail, err error) {
+	var activityIds []int
+	resultTimeStart := utils.StrTimeToTime(activityDetail.ActivityTime)  //时间字符串格式转时间格式
+	resultTimeEnd := utils.StrTimeToTime(activityDetail.ActivityTimeEnd) //时间字符串格式转时间格式
+	if resultTimeStart.After(time.Now()) {
+		activityDetail.ActiveState = 1
+	} else if time.Now().After(resultTimeEnd) {
+		activityDetail.ActiveState = 3
+	} else {
+		activityDetail.ActiveState = 2
+	}
+	activityIds = append(activityIds, activityDetail.ActivityId)
+	//处理用户已经报名了的行程
+	UserMap, e := GetSpecialTripUserMap(activityIds, user.UserId)
+	if e != nil {
+		err = errors.New("GetSpecialTripUserMap, Err: " + e.Error())
+		return
+	}
+	if activityDetail.Days == 0 {
+		activityDetail.TripStatus = 1
+	} else {
+		activityDetail.TripStatus = 2
+	}
+	if _, ok := UserMap[activityDetail.ActivityId]; ok {
+		activityDetail.IsTrip = 1
+	}
+	item = activityDetail
+	return
+}

+ 1 - 0
utils/constants.go

@@ -89,6 +89,7 @@ const (
 	ZHI_ZAO_NAME                     string = "智造"
 	ZHI_ZAO_ID                       int    = 19
 	LINK_WX_EXPLAIN                         = "https://mp.weixin.qq.com/s?__biz=Mzg2OTYzODk0Nw==&mid=2247483662&idx=1&sn=3752df99025189b9d77fe658bfc0edbd&chksm=ce98b742f9ef3e54b49986e647dd951a3aad74f323174b252174e0938c264c0562c8ec455106#rd" //用户阅读数据
+	ACTIVITY_SPECIAL_EXPLAIN                = "预报名专项调研行程持续更新中,满10家即开团,欢迎点击感兴趣预报名"                                                                                                                                                                //用户阅读数据
 	HZ_COMPANY_ID                    int    = 16                                                                                                                                                                                                 // 弘则公司的ID
 	HONG_GUAN_NAME                   string = "宏观"
 	HONG_GUAN_ID                     int    = 1