Browse Source

Merge branch 'master' of http://8.136.199.33:3000/hongze/hz_crm_api into cygx_11.0

xingzai 1 year ago
parent
commit
cecc695e07

+ 52 - 1
controllers/company.go

@@ -114,7 +114,17 @@ func (this *CompanyController) SearchList() {
 	}
 	// 查询当前销售是否有领取客户的权限
 	receiveEnabled, _ := services.CheckCompanyReceiveButton(sysUser.AdminId)
-
+	// 白嫖客户标记
+	scroungeList, err := company.GetScroungeCompany()
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取白嫖客户信息失败,Err:" + err.Error()
+		return
+	}
+	scroungeMap := make(map[int]int)
+	for _, v := range scroungeList {
+		scroungeMap[v.CompanyId] = 1
+	}
 	/*
 		时长根据客户状态定义,
 		若为冻结客户或者流失客户,则展示冻结时长或流失时长;
@@ -125,6 +135,10 @@ func (this *CompanyController) SearchList() {
 		duration := ""
 		item := list[i]
 		itemStatus := item.Status
+		//白嫖客户标记
+		if _, ok := scroungeMap[item.CompanyId]; ok{
+			item.IsScrounge = 1
+		}
 		if !strings.Contains(item.Status, "/") {
 			if item.Status == utils.COMPANY_STATUS_FREEZE {
 				if item.FreezeEndDate != "" {
@@ -359,6 +373,10 @@ func (this *CompanyController) SearchList() {
 			//根据销售"领取客户"的权限对部分按钮做限制
 			btnItem = services.GetCompanyPermissionButtonByReceiveEnabled(btnItem, receiveEnabled)
 		}
+		//如果是权益客户,操作者又是权益管理员,那么就对他进行展示研选详情按钮
+		if strings.Contains(item.CompanyType, utils.COMPANY_CLASSIFY_RAI) && sysUser.RoleName == utils.ROLE_TYPE_RAI_PRODUCT {
+			btnItem.IsResearchShow = true
+		}
 		list[i].BtnItem = btnItem
 	}
 	if list == nil {
@@ -1708,6 +1726,24 @@ func (this *CompanyController) List() {
 	if companyLists == nil {
 		companyLists = make([]*company.CompanyListItem, 0)
 	}
+
+	// 白嫖客户标记
+	scroungeList, err := company.GetScroungeCompany()
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取白嫖客户信息失败,Err:" + err.Error()
+		return
+	}
+	scroungeMap := make(map[int]int)
+	for _, v := range scroungeList {
+		scroungeMap[v.CompanyId] = 1
+	}
+	for i, v := range companyLists {
+		if _, ok := scroungeMap[v.CompanyId]; ok{
+			companyLists[i].IsScrounge = 1
+		}
+	}
+
 	page = paging.GetPaging(currentIndex, pageSize, total)
 	resp.List = companyLists
 	resp.StatusCount = statusItems
@@ -3346,6 +3382,21 @@ func (this *CompanyController) Detail() {
 		}
 	}
 
+	// 白嫖客户标记
+	scroungeList, err := company.GetScroungeCompany()
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取白嫖客户信息失败,Err:" + err.Error()
+		return
+	}
+	scroungeMap := make(map[int]int)
+	for _, v := range scroungeList {
+		scroungeMap[v.CompanyId] = 1
+	}
+	if _, ok := scroungeMap[item.CompanyId]; ok{
+		item.IsScrounge = 1
+	}
+
 	resp.Item = item
 	resp.BtnItem = btnDetailItem
 	br.Ret = 200

+ 1 - 0
controllers/company_service_record.go

@@ -61,6 +61,7 @@ func (this *CompanyServiceRecordController) ServiceRecordList() {
 			SysAdminId:             r.SysAdminId,
 			SysAdminName:           r.SysAdminName,
 			CreateTime:             r.CreateTime.Format(utils.FormatDateTime),
+			Mark:                   r.Mark,
 		})
 	}
 

+ 270 - 0
controllers/company_share.go

@@ -739,3 +739,273 @@ func (this *CompanyController) CompanyShareAddRemark() {
 	br.Success = true
 	br.Msg = "编辑成功"
 }
+
+// CompanyShareMark
+// @Title 新增客户标记
+// @Description 新增客户标记
+// @Param	request	body company.CompanyMarkReq true "type json string"
+// @Success 200 编辑成功
+// @router /share/mark [post]
+func (this *CompanyController) CompanyShareMark() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+	var req company.CompanyMarkReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	if req.CompanyServiceRecordId <= 0 {
+		br.Msg = "参数缺失"
+		br.ErrMsg = "参数缺失,备注ID未传!"
+		return
+	}
+
+	err = company.UpdateCompanyServiceRecordMark(req.CompanyServiceRecordId, req.Status)
+	if err != nil {
+		br.Msg = "操作失败"
+		br.ErrMsg = "新增共享客户备注失败, Err: " + err.Error()
+		return
+	}
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "编辑成功"
+}
+
+// @Title 共享客户列表-同城
+// @Description 共享客户列表接口
+// @Param   Keyword   query   string  true       "搜索关键词"
+// @Param   ListParam   query   int  false       "筛选字段参数,用来筛选的字段, 枚举值:0:全部 、 1:已分配 、 2:未分配  "
+// @Param   SortParam   query   string  false       "排序字段参数,用来排序的字段, 枚举值:'viewTotal':总阅读次数 、 'viewTime':阅读时间 、 'roadShowTotal':累计路演次数 、`expireDay:到期时间` 、 `createTime:创建时间` 、 'formalTime': 转正时间 、 'freezeTime':冻结时间 、'lossTime':流失时间  、'tryOutDay':试用天数"
+// @Param   SortType   query   string  true       "如何排序,是正序还是倒序,枚举值:`asc 正序`,`desc 倒叙`"
+// @Param   PageSize   query   int  true       "每页数据条数"
+// @Param   CurrentIndex   query   int  true       "当前页页码,从1开始"
+// @Success Ret=200 设置成功
+// @router /share/list/city [get]
+func (this *CompanyController) CompanyShareListByCity() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+
+	pageSize, _ := this.GetInt("PageSize")
+	currentIndex, _ := this.GetInt("CurrentIndex")
+	keyword := this.GetString("Keyword")
+	province := this.GetString("Province")
+	city := this.GetString("City")
+	//排序参数
+	//sortParam := this.GetString("SortParam")
+	//listParam, _ := this.GetInt("ListParam")
+	//sortType := this.GetString("SortType")
+
+	var total int
+	page := paging.GetPaging(currentIndex, pageSize, total)
+
+	var startSize int
+	if pageSize <= 0 {
+		pageSize = utils.PageSize20
+	}
+	if currentIndex <= 0 {
+		currentIndex = 1
+	}
+	startSize = paging.StartIndex(currentIndex, pageSize)
+	var condition string
+	var pars []interface{}
+
+	if keyword != "" {
+		companyIdStr, err := company.GetCompanyIdByKeyWord(keyword)
+		if err != nil {
+			br.Msg = "获取客户信息失败"
+			br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
+			return
+		}
+		if companyIdStr != "" {
+			condition += ` AND (a.company_name LIKE '%` + keyword + `%' OR a.credit_code LIKE '%` + keyword + `%' OR a.company_id IN(` + companyIdStr + `)) `
+		} else {
+			condition += ` AND (a.company_name LIKE '%` + keyword + `%' OR a.credit_code LIKE '%` + keyword + `%' ) `
+		}
+	}
+
+	condition += ` AND a.is_share=1 `
+	if province != "" {
+		var provinceSql string
+		slice := strings.Split(province, ",")
+		for _, v := range slice {
+			provinceSql += "'" + v + "'" + ","
+		}
+		provinceSql = strings.TrimRight(provinceSql, ",")
+		condition += ` AND a.province IN (` + provinceSql + `) `
+	}
+
+	if city != "" {
+		var citySql string
+		slice := strings.Split(city, ",")
+		for _, v := range slice {
+			citySql += "'" + v + "'" + ","
+		}
+		citySql = strings.TrimRight(citySql, ",")
+		condition += ` AND a.city IN (` + citySql + `) `
+	}
+
+	total, err := company.GetShareCompanyListCount(condition, pars)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取数据总数失败,Err:" + err.Error()
+		return
+	}
+
+	sortStr := ` `
+	//if sysUser.RoleTypeCode == utils.ROLE_TYPE_CODE_ADMIN {
+	//	sortStr = " ORDER BY sort_status asc, all_view_total desc, a.created_time "
+	//} else {
+	//	sortStr = " ORDER BY sort_status asc, b.view_total desc, a.created_time  "
+	//}
+
+	list, err := company.GetShareCompanyList(condition, sortStr, pars, startSize, pageSize)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取数据失败,Err:" + err.Error()
+		return
+	}
+	//企业用户数组切片
+	companyIds := make([]int, 0)
+	companyIdSlice := make([]string, 0)
+	for _, v := range list {
+		companyIds = append(companyIds, v.CompanyId)
+		companyIdSlice = append(companyIdSlice, strconv.Itoa(v.CompanyId))
+	}
+
+	//企业用户产品开通数
+	companyIdStr := strings.Join(companyIdSlice, ",")
+	companyProductTotalList, _ := company.GetCountProductByCompanyIds(companyIdStr)
+	companyProductTotalMap := make(map[int]*company.CompanyProductTotalSlice)
+	for _, companyProductTotal := range companyProductTotalList {
+		companyProductTotalMap[companyProductTotal.CompanyId] = companyProductTotal
+	}
+
+	// 客户产品详细信息
+	companyProductMap := make(map[string]*company.CompanyProduct)
+	var companyProductCondition string
+	var companyProductPars []interface{}
+
+	companyProductList, err := company.GetCompanyProductsByCompanyIds(companyIdStr, companyProductCondition, companyProductPars)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取客户产品数据失败,Err:" + err.Error()
+		return
+	}
+	for _, companyProduct := range companyProductList {
+		key := fmt.Sprint(companyProduct.CompanyId, "_", companyProduct.ProductId)
+		companyProductMap[key] = companyProduct
+	}
+
+	companyLists := make([]*company.CompanyListItem, 0)
+	//查询阅读次数
+	if list == nil {
+		companyLists = make([]*company.CompanyListItem, 0)
+	} else {
+		for _, v := range list {
+			//viewTotal:=GetviewTotal(v.CompanyId)
+
+			//活跃(客户状态)
+			tmpStatus := v.Status
+			if v.IsShare == 1 {
+				tmpStatus = v.Status + "(共享)"
+			}
+
+			companyList := &company.CompanyListItem{
+				CompanyId:        v.CompanyId,
+				CompanyName:      v.CompanyName,
+				CreditCode:       v.CreditCode,
+				CompanyCode:      v.CompanyCode,
+				StartDate:        v.StartDate,
+				EndDate:          v.EndDate,
+				LoseReason:       v.LoseReason,
+				RenewalReason:    v.RenewalReason,
+				FreezeReason:     v.FreezeReason,
+				LossTime:         v.LossTime,
+				Status:           tmpStatus,
+				CompanyType:      v.CompanyType,
+				ApproveStatus:    v.ApproveStatus,
+				SellerName:       v.SellerName,
+				SellerId:         v.SellerId,
+				SellerIds:        v.SellerIds,
+				ExpireDay:        v.ExpireDay,
+				FreezeTime:       v.FreezeTime,
+				GroupId:          v.GroupId,
+				GroupIds:         v.GroupIds,
+				DepartmentId:     v.DepartmentId,
+				IndustryName:     v.IndustryName,
+				IsSuspend:        v.IsSuspend,
+				CreatedTime:      v.CreatedTime,
+				Source:           v.Source,
+				Province:         v.Province,
+				City:             v.City,
+				Address:          v.Address,
+				Reasons:          v.Reasons,
+				FreezeStartDate:  v.FreezeStartDate,
+				FreezeEndDate:    v.FreezeEndDate,
+				FreezeExpireDays: v.FreezeExpireDays,
+				BtnItem:          v.BtnItem,
+				ProductId:        v.ProductId,
+				FormalTime:       v.FormalTime,
+				IsShared:         v.IsShared,
+				RegionType:       v.RegionType,
+				FiccPackageType:  v.FiccPackageType,
+				FiccLastViewTime: v.FiccLastViewTime,
+				RaiLastViewTime:  v.RaiLastViewTime,
+				//FiccView:         viewTotal[0],
+				//RaiView:          viewTotal[1],
+				//FiccView: ficcViewTotal,
+				//RaiView:  raiViewTotal,
+				FiccView:        v.FiccView,
+				RaiView:         v.RaiView,
+				FiccTryOutDay:   v.FiccTryOutDay,
+				RaiTryOutDay:    v.RaiTryOutDay,
+				AllViewTotal:    v.AllViewTotal,
+				RoadShowTotal:   v.RoadShowTotal,
+				TryStageSlice:   v.TryStageSlice,
+				Deadline:        v.Deadline,
+				WeekViewActive:  v.WeekViewActive,
+				IsShare:         v.IsShare,
+				ShareSeller:     v.ShareSeller,
+				ShareSellerId:   v.ShareSellerId,
+				LastServiceTime: v.LastServiceTime,
+				ServiceTimes:    v.ServiceTimes,
+			}
+			companyLists = append(companyLists, companyList)
+		}
+	}
+	if companyLists == nil {
+		companyLists = make([]*company.CompanyListItem, 0)
+	}
+	page = paging.GetPaging(currentIndex, pageSize, total)
+	resp := new(company.CompanyListResp)
+	resp.List = companyLists
+	resp.Paging = page
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+
+}

+ 42 - 1
controllers/cygx/activity.go

@@ -95,6 +95,9 @@ func (this *ActivityCoAntroller) PreserveAndPublish() {
 		req.Scale = ""
 		req.CustomerTypeIds = ""
 	}
+	if req.IsResearchPoints == 0 {
+		req.SiginupDeadline = ""
+	}
 	activityId := req.ActivityId
 	labelType := req.LabelType
 	labelList := req.List
@@ -435,6 +438,7 @@ func (this *ActivityCoAntroller) PreserveAndPublish() {
 			item.LastUpdatedTime = time.Now()
 			item.Scale = scale
 			item.IsExternalLabel = isExternalLabel
+			item.IsAllCustomerType = req.IsAllCustomerType
 			item.IsShowHz = isShowHz
 			item.ChartPermissionIdDeputy = charInfo.ChartPermissionId
 			item.ChartPermissionNameDeputy = charInfo.PermissionName
@@ -1122,6 +1126,9 @@ func (this *ActivityCoAntroller) Detail() {
 		return
 	}
 	if PointsSetDetail != nil {
+		if PointsSetDetail.CancelDeadlineType == "0" {
+			PointsSetDetail.CancelDeadlineType = ""
+		}
 		activityInfo.PointsSet = PointsSetDetail
 	} else {
 		activityInfo.PointsSet = new(cygx.CygxActivityPointsSetRsq)
@@ -1130,7 +1137,7 @@ func (this *ActivityCoAntroller) Detail() {
 	if activityInfo.VisibleRange == 0 {
 		activityInfo.VisibleRange = 2
 	}
-
+	//activityInfo.CancelDeadlineType = cygxService.ActivityCancelDeadlineType(activityInfo) //处理活动取消报名截止时间类型展示
 	activityInfo.VoiceList = VoiceReqList
 	activityInfo.VideoDetail = VideoDetail
 	activityInfo.ShowType = detail.ShowType
@@ -1419,3 +1426,37 @@ func (this *ActivityCoAntroller) CompanySearch() {
 	br.Msg = "获取成功"
 	br.Data = resp
 }
+
+// @Title 报名截止时间设置
+// @Description 报名截止时间设置接口
+// @Success Ret=200
+// @router /activity/deadlineSet [get]
+func (this *ActivityCoAntroller) DeadlineSet() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	AdminUser := this.SysUser
+	if AdminUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		return
+	}
+	list := make([]cygx.SendGroupStr, 0)
+	list = append(list, cygx.SendGroupStr{
+		Id:   "1",
+		Name: "同报名截止时间",
+	})
+	list = append(list, cygx.SendGroupStr{
+		Id:   "2",
+		Name: "活动开始前24小时",
+	})
+	list = append(list, cygx.SendGroupStr{
+		Id:   "3",
+		Name: "活动开始前48小时",
+	})
+	br.Ret = 200
+	br.Success = true
+	br.Data = list
+}

+ 46 - 32
controllers/cygx/activity_signup.go

@@ -302,13 +302,13 @@ func (this *ActivitySignupCoAntroller) AppointmentList() {
 	}
 	for k, v := range list {
 		//公司调研电话会的活动,研选扣点的展示自主拨入,非扣点的展示预约外呼
-		if activityInfo.ActivityTypeId == 3 {
-			if activityInfo.IsResearchPoints == 1 {
-				v.SignupType = 2
-			} else {
-				v.SignupType = 1
-			}
-		}
+		//if activityInfo.ActivityTypeId == 3 {
+		//	if activityInfo.IsResearchPoints == 1 {
+		//		v.SignupType = 2
+		//	} else {
+		//		v.SignupType = 1
+		//	}
+		//}
 		list[k].SellerName = v.PsellerName
 	}
 	respList := new(cygx.GetAppointmentListRep)
@@ -1368,28 +1368,28 @@ func (this *ActivitySignupCoAntroller) SignupFailExport() {
 	sqlStrOther := sqlStr
 	var listReminder []*cygx.CygxAppointmentList
 	var summaryList []*cygx.CygxAppointmentList
-	if activityInfo.ActivityTypeId == 1 || activityInfo.ActivityTypeId == 2 {
-		var err error
-		//消息提醒
-		listReminder, err = cygx.GetCygxActivityMeetingReminderList(activityId, sqlStrOther)
-		if err != nil {
-			br.Msg = "获取失败"
-			br.ErrMsg = "获取失败,Err:" + err.Error()
-			return
-		}
-		//预约纪要
-		summaryList, err = cygx.GetCygxAppointmentSummaryList(activityId, sqlStrOther)
-		if err != nil {
-			br.Msg = "获取失败"
-			br.ErrMsg = "获取失败,Err:" + err.Error()
-			return
-		}
-		if excelType == 1 {
-			sqlStr += ` AND  s.signup_type = 1 `
-		} else if excelType == 2 {
-			sqlStr += ` AND  s.signup_type != 1 `
-		}
+
+	var err error
+	//消息提醒
+	listReminder, err = cygx.GetCygxActivityMeetingReminderList(activityId, sqlStrOther)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	//预约纪要
+	summaryList, err = cygx.GetCygxAppointmentSummaryList(activityId, sqlStrOther)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
 	}
+	if excelType == 1 {
+		sqlStr += ` AND  s.signup_type = 1 `
+	} else if excelType == 2 {
+		sqlStr += ` AND  s.signup_type IN (2,4) `
+	}
+	//}
 	list, err := cygx.GetCygxAppointmentList(activityId, sqlStr)
 	if err != nil {
 		br.Msg = "获取失败"
@@ -1451,9 +1451,11 @@ func (this *ActivitySignupCoAntroller) SignupFailExport() {
 				cellC := rowTitle.AddCell()
 				cellC.Value = "国际代码"
 				cellD := rowTitle.AddCell()
-				cellD.Value = "公司名称"
+				cellD.Value = "邮箱"
 				cellE := rowTitle.AddCell()
-				cellE.Value = "所属销售"
+				cellE.Value = "公司名称"
+				cellF := rowTitle.AddCell()
+				cellF.Value = "所属销售"
 
 				for _, item := range listDate {
 					row := sheet.AddRow()
@@ -1464,9 +1466,11 @@ func (this *ActivitySignupCoAntroller) SignupFailExport() {
 					cellC := row.AddCell()
 					cellC.Value = item.CountryCode
 					cellD := row.AddCell()
-					cellD.Value = item.CompanyName
+					cellD.Value = item.Email
 					cellE := row.AddCell()
-					cellE.Value = item.SellerName
+					cellE.Value = item.CompanyName
+					cellF := row.AddCell()
+					cellF.Value = item.SellerName
 				}
 			} else {
 				rowTitle := sheet.AddRow()
@@ -2286,9 +2290,19 @@ func (this *ActivitySignupCoAntroller) SignupCancel() {
 			resultTime := utils.StrTimeToTime(activityInfo.ActivityTime) //时间字符串格式转时间格式
 			if time.Now().After(resultTime.Add(-time.Minute * 60)) {
 				br.Msg = "报名名单已发送至办会平台,请联系相关人员处理。"
+				br.ErrMsg = fmt.Sprint("UserId:", detail.UserId, "ActivityId:", detail.ActivityId)
 				return
 			}
 		}
+		//取消报名截止时间校验
+		//if activityInfo.CancelDeadline != utils.EmptyDateTimeStr {
+		//	cancelDeadline := utils.StrTimeToTime(activityInfo.CancelDeadline) //时间字符串格式转时间格式
+		//	if time.Now().After(cancelDeadline) {
+		//		br.Msg = "当前时间晚于取消报名截止时间,已无法取消报名。"
+		//		br.ErrMsg = fmt.Sprint("UserId:", detail.UserId, "ActivityId:", detail.ActivityId)
+		//		return
+		//	}
+		//}
 	}
 	_, err = cygx.CancelActivitySignup(detail)
 	if err != nil {

+ 0 - 100
controllers/cygx/activity_special.go

@@ -1184,103 +1184,3 @@ func (this *ActivitySpecialCoAntroller) Offline() {
 	br.Msg = "操作成功"
 	br.IsAddLog = true
 }
-
-// @Title 发送模版消息
-// @Description 发送模版消息接口
-// @Param	request	body cygx.AddOutboundPersonnelItm true "type json string"
-// @Success 200 操作成功
-// @router /special/trip/tempMsg [post]
-func (this *ActivitySpecialTripCoAntroller) TempMsg() {
-	br := new(models.BaseResponse).Init()
-	defer func() {
-		this.Data["json"] = br
-		this.ServeJSON()
-	}()
-	AdminUser := this.SysUser
-	if AdminUser == nil {
-		br.Msg = "请登录"
-		br.ErrMsg = "请登录,SysUser Is Empty"
-		return
-	}
-	var req cygx.ActivitySpecialSignupTempMsgReq
-	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
-	if err != nil {
-		br.Msg = "参数解析异常!"
-		br.ErrMsg = "参数解析失败,Err:" + err.Error()
-		return
-	}
-	idSlice := strings.Split(req.ActivityIds, ",")
-	for _, sId := range idSlice {
-		id, e := strconv.Atoi(sId)
-		if e != nil {
-			br.Msg = "活动Id参数异常"
-			br.ErrMsg = "参数解析异常, Err:" + e.Error()
-			return
-		}
-		var openIdList []*models.OpenIdList
-		idMap := make(map[string]string, 0)
-		//1已报名
-		if strings.Contains(req.SendGroup, "1") {
-			listSignup, err := cygx.GetCygxActivitySpecialTripListByActivityId(id)
-			if err != nil {
-				br.Msg = "查询报名信息失败失败"
-				br.ErrMsg = "GetCygxActivitySpecialTripListByActivityId,Err:" + err.Error()
-				return
-			}
-			if len(listSignup) == 0 {
-				continue
-			}
-			var mobileArr []string
-			for _, v := range listSignup {
-				if v.Mobile != "" {
-					mobileArr = append(mobileArr, v.Mobile)
-				}
-			}
-			mobileLen := len(mobileArr)
-			var condition string
-			var pars []interface{}
-			if mobileLen > 0 {
-				condition += ` AND u.mobile IN (` + utils.GetOrmInReplace(mobileLen) + `)`
-				pars = append(pars, mobileArr)
-			}
-			list, err := models.GetActivitySpecialOpenIdListMobile(condition, pars)
-			if err != nil {
-				br.Msg = "查询openId失败"
-				br.ErrMsg = "查询openId失败,Err:" + err.Error()
-				return
-			}
-			for _, idList := range list {
-				openIdList = append(openIdList, idList)
-				idMap[idList.OpenId] = idList.OpenId
-			}
-		}
-
-		if len(openIdList) > 0 {
-			openIdArr := make([]string, len(openIdList))
-			for i, v := range openIdList {
-				openIdArr[i] = v.OpenId
-			}
-			sendInfo := new(services.SendWxTemplate)
-			sendInfo.Keyword1 = req.ResearchTheme
-			sendInfo.Keyword2 = req.Content
-			sendInfo.TemplateId = utils.WxMsgTemplateIdActivityChangeApplyXzs
-			sendInfo.RedirectUrl = utils.WX_MSG_PATH_ACTIVITY_SPECIAL_DETAIL + strconv.Itoa(id)
-			if utils.RunMode == "debug" {
-				sendInfo.RedirectUrl = utils.WX_MSG_PATH_ACTIVITY_SPECIAL_DETAIL + strconv.Itoa(110) //测试环境调正式的ID
-			}
-			sendInfo.RedirectTarget = 3
-			sendInfo.Resource = strconv.Itoa(id)
-			sendInfo.SendType = utils.TEMPLATE_MSG_CYGX_ACTIVITY_CUSTOMIZE
-			sendInfo.OpenIdArr = openIdArr
-			e = services.SendTemplateMsg(sendInfo)
-			if e != nil {
-				br.Msg = "推送模板消息失败!"
-				br.ErrMsg = "参数解析失败,Err:" + e.Error()
-				return
-			}
-		}
-	}
-	br.Ret = 200
-	br.Success = true
-	br.Msg = "发送成功"
-}

+ 127 - 0
controllers/cygx/activity_special_trip.go

@@ -8,6 +8,7 @@ import (
 	"hongze/hz_crm_api/models"
 	"hongze/hz_crm_api/models/cygx"
 	"hongze/hz_crm_api/models/system"
+	"hongze/hz_crm_api/services"
 	cygxService "hongze/hz_crm_api/services/cygx"
 	"hongze/hz_crm_api/utils"
 	"os"
@@ -830,3 +831,129 @@ func (this *ActivitySpecialTripCoAntroller) OutboundMobileEdit() {
 	br.Msg = "操作成功"
 	br.IsAddLog = true
 }
+
+// @Title 模版消息发送客户类型列表
+// @Description 模版消息发送客户类型列表接口
+// @Success Ret=200
+// @router /special/trip/tempMsg/sendGroupList [get]
+func (this *ActivitySpecialTripCoAntroller) SendGroupList() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	AdminUser := this.SysUser
+	if AdminUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		return
+	}
+	list := make([]cygx.SendGroup, 0)
+	list = append(list, cygx.SendGroup{
+		Id:   1,
+		Name: "已报名客户",
+	})
+	br.Ret = 200
+	br.Success = true
+	br.Data = list
+}
+
+// @Title 发送模版消息
+// @Description 发送模版消息接口
+// @Param	request	body cygx.AddOutboundPersonnelItm true "type json string"
+// @Success 200 操作成功
+// @router /special/trip/tempMsg [post]
+func (this *ActivitySpecialTripCoAntroller) TempMsg() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	AdminUser := this.SysUser
+	if AdminUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		return
+	}
+	var req cygx.ActivitySpecialSignupTempMsgReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常!"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	idSlice := strings.Split(req.ActivityIds, ",")
+	for _, sId := range idSlice {
+		id, e := strconv.Atoi(sId)
+		if e != nil {
+			br.Msg = "活动Id参数异常"
+			br.ErrMsg = "参数解析异常, Err:" + e.Error()
+			return
+		}
+		var openIdList []*models.OpenIdList
+		idMap := make(map[string]string, 0)
+		//1已报名
+		if strings.Contains(req.SendGroup, "1") {
+			listSignup, err := cygx.GetCygxActivitySpecialTripListByActivityId(id)
+			if err != nil {
+				br.Msg = "查询报名信息失败失败"
+				br.ErrMsg = "GetCygxActivitySpecialTripListByActivityId,Err:" + err.Error()
+				return
+			}
+			if len(listSignup) == 0 {
+				continue
+			}
+			var mobileArr []string
+			for _, v := range listSignup {
+				if v.Mobile != "" {
+					mobileArr = append(mobileArr, v.Mobile)
+				}
+			}
+			mobileLen := len(mobileArr)
+			var condition string
+			var pars []interface{}
+			if mobileLen > 0 {
+				condition += ` AND u.mobile IN (` + utils.GetOrmInReplace(mobileLen) + `)`
+				pars = append(pars, mobileArr)
+			}
+			list, err := models.GetActivitySpecialOpenIdListMobile(condition, pars)
+			if err != nil {
+				br.Msg = "查询openId失败"
+				br.ErrMsg = "查询openId失败,Err:" + err.Error()
+				return
+			}
+			for _, idList := range list {
+				openIdList = append(openIdList, idList)
+				idMap[idList.OpenId] = idList.OpenId
+			}
+		}
+
+		if len(openIdList) > 0 {
+			openIdArr := make([]string, len(openIdList))
+			for i, v := range openIdList {
+				openIdArr[i] = v.OpenId
+			}
+			sendInfo := new(services.SendWxTemplate)
+			sendInfo.Keyword1 = req.ResearchTheme
+			sendInfo.Keyword2 = req.Content
+			sendInfo.TemplateId = utils.WxMsgTemplateIdActivityChangeApplyXzs
+			sendInfo.RedirectUrl = utils.WX_MSG_PATH_ACTIVITY_SPECIAL_DETAIL + strconv.Itoa(id)
+			if utils.RunMode == "debug" {
+				sendInfo.RedirectUrl = utils.WX_MSG_PATH_ACTIVITY_SPECIAL_DETAIL + strconv.Itoa(110) //测试环境调正式的ID
+			}
+			sendInfo.RedirectTarget = 3
+			sendInfo.Resource = strconv.Itoa(id)
+			sendInfo.SendType = utils.TEMPLATE_MSG_CYGX_ACTIVITY_CUSTOMIZE
+			sendInfo.OpenIdArr = openIdArr
+			e = services.SendTemplateMsg(sendInfo)
+			if e != nil {
+				br.Msg = "推送模板消息失败!"
+				br.ErrMsg = "参数解析失败,Err:" + e.Error()
+				return
+			}
+		}
+	}
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "发送成功"
+}

+ 13 - 13
controllers/cygx/report_selection.go

@@ -317,7 +317,19 @@ func (this *ReportSelectionController) Detail() {
 	listMore, err := cygx.GetChartPermissionDetail(condition)
 	var list []*cygx.CygxReportSelectionChart
 	//排序方式修改
-	permissionNameList := []cygx.CygxChartPermissionName{{ChartPermissionName: "消费"}, {ChartPermissionName: "医药"}, {ChartPermissionName: "科技"}, {ChartPermissionName: "智造"}}
+	permissionNameList := []cygx.CygxChartPermissionName{}
+	//获取行业核心逻辑汇总
+	listChartLog, err := cygx.GetCygxReportSelectionChartLogRepList(articleId)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+	mapChartLog := make(map[string]string)
+	for _, v := range listChartLog {
+		mapChartLog[v.ChartPermissionName] = v.BodyChartSummary
+		permissionNameList = append(permissionNameList, cygx.CygxChartPermissionName{v.ChartPermissionName})
+	}
 	for _, v := range permissionNameList {
 		for _, v2 := range listMore {
 			if v.ChartPermissionName == v2.ChartPermissionName {
@@ -335,18 +347,6 @@ func (this *ReportSelectionController) Detail() {
 		return
 	}
 
-	//获取行业核心逻辑汇总
-	listChartLog, err := cygx.GetCygxReportSelectionChartLogRepList(articleId)
-	if err != nil {
-		br.Msg = "获取失败"
-		br.ErrMsg = "获取失败,Err:" + err.Error()
-		return
-	}
-	mapChartLog := make(map[string]string)
-	for _, v := range listChartLog {
-		mapChartLog[v.ChartPermissionName] = v.BodyChartSummary
-	}
-
 	//获取关联的文章信息
 	mapArticle := make(map[int]string)
 	listSelectionLog, err := cygx.GetReportSelectionlogListAll(articleId)

+ 154 - 20
controllers/cygx/user.go

@@ -619,8 +619,10 @@ func (this *UserController) TableList() {
 		{PermissionName: "关注的产业", Source: 5, TotalNum: countDetail.IndustryFllowNum},
 		{PermissionName: "关注的作者", Source: 6, TotalNum: countDetail.DepartmentFollowNum},
 		{PermissionName: "搜索", Source: 7, TotalNum: countDetail.KeyWordNum},
-		{PermissionName: "音视频播放", Source: 9, TotalNum: countDetail.RoadshowVideoNum + countDetail.ActivityVideoNum + countDetail.ActivityVoiceNum}}
-	resp := new(cygx.CygxUserTableListRep)
+		{PermissionName: "音视频播放", Source: 9, TotalNum: countDetail.RoadshowVideoNum + countDetail.ActivityVideoNum + countDetail.ActivityVoiceNum},
+		{PermissionName: "首页标签点击", Source: 10, TotalNum: countDetail.TagNum}}
+
+resp := new(cygx.CygxUserTableListRep)
 	resp.List = List
 	resp.UserName = wxUser.RealName
 	resp.Mobile = wxUser.Mobile
@@ -696,7 +698,16 @@ func (this *UserController) TableDetail() {
 	var NoMeetingNum int
 	var list []*cygx.UserInteraction
 
-	listTable := []*cygx.CygxUserTableRep{{PermissionName: "报告阅读列表", Source: 1, TotalNum: 10}, {PermissionName: "活动互动记录", Source: 2, TotalNum: 10}, {PermissionName: "收藏的报告", Source: 3, TotalNum: 10}, {PermissionName: "收藏图表", Source: 4, TotalNum: 10}, {PermissionName: "关注的产业", Source: 5, TotalNum: 10}, {PermissionName: "关注的作者", Source: 6, TotalNum: 10}, {PermissionName: "搜索", Source: 7, TotalNum: 10}, {PermissionName: "专项调研", Source: 8, TotalNum: 10}, {PermissionName: "音视频播放", Source: 9, TotalNum: 10}}
+	listTable := []*cygx.CygxUserTableRep{{PermissionName: "报告阅读列表", Source: 1, TotalNum: 10},
+		{PermissionName: "活动互动记录", Source: 2, TotalNum: 10},
+		{PermissionName: "收藏的报告", Source: 3, TotalNum: 10},
+		{PermissionName: "收藏图表", Source: 4, TotalNum: 10},
+		{PermissionName: "关注的产业", Source: 5, TotalNum: 10},
+		{PermissionName: "关注的作者", Source: 6, TotalNum: 10},
+		{PermissionName: "搜索", Source: 7, TotalNum: 10},
+		{PermissionName: "专项调研", Source: 8, TotalNum: 10},
+		{PermissionName: "音视频播放", Source: 9, TotalNum: 10},
+		{PermissionName: "首页标签点击", Source: 10, TotalNum: 10}}
 	for _, v := range listTable {
 		if v.Source == source {
 			checkSource = true
@@ -973,6 +984,19 @@ func (this *UserController) TableDetail() {
 			br.Msg = "获取搜索记录列表失败"
 			return
 		}
+	} else if source == 10 { //标签点击记录
+		total, err = cygx.GetCygxTagHistoryCountByUserId(userId)
+		if err != nil {
+			br.ErrMsg = "获取信息失败,Err:" + err.Error()
+			br.Msg = "获取搜索记录失败"
+			return
+		}
+		list, err = cygx.GetCygxTagHistoryByUserId(userId, startSize, pageSize)
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			br.ErrMsg = "获取信息失败,Err:" + err.Error()
+			br.Msg = "获取搜索记录列表失败"
+			return
+		}
 	}
 	page := paging.GetPaging(currentIndex, pageSize, total)
 	resp := new(cygx.UserInteractionListResp)
@@ -1895,6 +1919,12 @@ func (this *UserController) CompanyTableList() {
 		br.ErrMsg = "获取搜索记录失败,Err:" + err.Error()
 		return
 	}
+	tagNum, err := cygx.GetCygxTagHistoryCountByCompanyId(companyId,"")
+	if err != nil {
+		br.ErrMsg = "获取信息失败,Err:" + err.Error()
+		br.Msg = "获取搜索记录失败"
+		return
+	}
 	List := []*cygx.CygxUserTableRep{{PermissionName: "报告阅读列表", Source: 1, TotalNum: historyNum},
 		{PermissionName: "活动互动记录", Source: 2, TotalNum: activityNum},
 		{PermissionName: "专项调研", Source: 8, TotalNum: triptotal},
@@ -1903,7 +1933,8 @@ func (this *UserController) CompanyTableList() {
 		{PermissionName: "关注的产业", Source: 5, TotalNum: industryFllowNum},
 		{PermissionName: "关注的作者", Source: 6, TotalNum: departmentFollowNum},
 		{PermissionName: "搜索", Source: 7, TotalNum: keyWordNum},
-		{PermissionName: "音视频播放", Source: 9, TotalNum: roadshowTotal}}
+		{PermissionName: "音视频播放", Source: 9, TotalNum: roadshowTotal},
+		{PermissionName: "首页标签点击", Source: 10, TotalNum: tagNum}}
 	resp := new(cygx.CygxUserTableListRep)
 	resp.List = List
 	resp.ComapnyName = comanyDetail.CompanyName
@@ -2296,6 +2327,23 @@ func (this *UserController) CompanyTableDetail() {
 			br.ErrMsg = "获取搜索记录列表失败,Err:" + err.Error()
 			return
 		}
+	} else if source == 10 { //标签点击记录
+		condition = ``
+		if keyWord != "" {
+			condition += ` AND  (a.mobile LIKE '%` + keyWord + `%' OR a.email LIKE '%` + keyWord + `%' OR a.real_name LIKE '%` + keyWord + `%'` + ` OR a.company_name LIKE '%` + keyWord + `%') `
+		}
+		total, err = cygx.GetCygxTagHistoryCountByCompanyId(companyId, condition)
+		if err != nil {
+			br.ErrMsg = "获取信息失败,Err:" + err.Error()
+			br.Msg = "获取搜索记录失败"
+			return
+		}
+		list, err = cygx.GetCygxTagHistoryByCompanyId(companyId, startSize, pageSize, condition)
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			br.ErrMsg = "获取信息失败,Err:" + err.Error()
+			br.Msg = "获取搜索记录列表失败"
+			return
+		}
 	}
 
 	page := paging.GetPaging(currentIndex, pageSize, total)
@@ -3238,6 +3286,26 @@ func (this *UserController) CompanyList() {
 			br.ErrMsg = "获取搜索记录列表失败,Err:" + err.Error()
 			return
 		}
+	} else if source == 10 { //标签点击记录
+		condition = ``
+		if adminId != "" {
+			condition += ` AND p.seller_id IN (` + adminId + `) `
+		}
+		if keyWord != "" {
+			condition += ` AND  (a.mobile LIKE '%` + keyWord + `%' OR a.email LIKE '%` + keyWord + `%' OR a.real_name LIKE '%` + keyWord + `%'` + ` OR a.company_name LIKE '%` + keyWord + `%') `
+		}
+		total, err = cygx.GetCygxTagHistoryCountByCompanyIds(companyIds, condition)
+		if err != nil {
+			br.ErrMsg = "获取信息失败,Err:" + err.Error()
+			br.Msg = "获取搜索记录失败"
+			return
+		}
+		list, err = cygx.GetCygxTagHistoryByCompanyIds(companyIds, condition, startSize, pageSize)
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			br.ErrMsg = "获取信息失败,Err:" + err.Error()
+			br.Msg = "获取搜索记录列表失败"
+			return
+		}
 	}
 	page := paging.GetPaging(currentIndex, pageSize, total)
 
@@ -4095,7 +4163,12 @@ func (this *UserController) TableCompanyList() {
 		br.ErrMsg = "获取搜索记录失败,Err:" + err.Error()
 		return
 	}
-
+	tagNum, err := cygx.GetCygxTagHistoryCountByCompanyIds(companyCondition,"")
+	if err != nil {
+		br.ErrMsg = "获取信息失败,Err:" + err.Error()
+		br.Msg = "获取搜索记录失败"
+		return
+	}
 	List := []*cygx.CygxUserTableRep{{PermissionName: "报告阅读列表", Source: 1, TotalNum: historyNum},
 		{PermissionName: "活动互动记录", Source: 2, TotalNum: activityNum},
 		{PermissionName: "专项调研", Source: 8, TotalNum: triptotal},
@@ -4104,7 +4177,8 @@ func (this *UserController) TableCompanyList() {
 		{PermissionName: "关注的产业", Source: 5, TotalNum: industryFllowNum},
 		{PermissionName: "关注的作者", Source: 6, TotalNum: departmentFollowNum},
 		{PermissionName: "搜索", Source: 7, TotalNum: keyWordNum},
-		{PermissionName: "音视频播放", Source: 9, TotalNum: roadshowTotal}}
+		{PermissionName: "音视频播放", Source: 9, TotalNum: roadshowTotal},
+		{PermissionName: "首页标签点击", Source: 10, TotalNum: tagNum}}
 	resp := new(cygx.CygxUserTableListRep)
 	resp.List = List
 	br.Ret = 200
@@ -4139,10 +4213,22 @@ func (this *UserController) UserRemind() {
 		return
 	}
 	userId := req.UserId
+	sourceType := req.SourceType
+	doType := req.DoType
 	wxUser, err := cygx.GetUserAndCompanyNameList(userId)
 	if err != nil {
+		br.Msg = "设置互动提醒失败"
 		br.ErrMsg = "获取信息失败,Err:" + err.Error()
-		br.Msg = "获取信息失败"
+		return
+	}
+	if sourceType != 1 && sourceType != 2 {
+		br.Msg = "设置互动提醒失败"
+		br.ErrMsg = "设置互动提醒失败,sourceType:" + strconv.Itoa(sourceType)
+		return
+	}
+	if doType != 1 && doType != 2 {
+		br.Msg = "设置互动提醒失败"
+		br.ErrMsg = "设置互动提醒失败,doType:" + strconv.Itoa(doType)
 		return
 	}
 	count, err := cygx.GetCygxUserRemindCount(userId)
@@ -4153,18 +4239,60 @@ func (this *UserController) UserRemind() {
 	}
 	resp := new(cygx.CygxUserRemindResp)
 	if count <= 0 {
-		item := new(cygx.CygxUserRemind)
-		item.AdminId = sysUser.AdminId
-		item.AdminName = sysUser.RealName
-		item.UserId = userId
-		item.Mobile = wxUser.Mobile
-		item.Email = wxUser.Email
-		item.CompanyId = wxUser.CompanyId
-		item.CompanyName = wxUser.CompanyName
-		item.RealName = wxUser.RealName
-		item.CreateTime = time.Now()
-		item.ModifyTime = time.Now()
-		_, err = cygx.AddCygxUserRemind(item)
+		var items []*cygx.CygxUserRemind
+		if sourceType == 1 {
+			item := new(cygx.CygxUserRemind)
+			item.AdminId = sysUser.AdminId
+			item.AdminName = sysUser.RealName
+			item.UserId = userId
+			item.Mobile = wxUser.Mobile
+			item.Email = wxUser.Email
+			item.CompanyId = wxUser.CompanyId
+			item.CompanyName = wxUser.CompanyName
+			item.RealName = wxUser.RealName
+			item.CreateTime = time.Now()
+			item.ModifyTime = time.Now()
+			items = append(items, item)
+		} else {
+			//获取机构下所有的用户
+			listUser, err := models.GetWxUserListCompanyId(wxUser.CompanyId)
+			if err != nil {
+				br.Msg = "获取数据失败!"
+				br.ErrMsg = "获取数据失败,GetWxUserListCompanyId Err:" + err.Error()
+				return
+			}
+			//获取已经添加消息提醒的
+			listUserRemind, err := cygx.GetCygxUserRemindListByCompanyId(wxUser.CompanyId)
+			if err != nil {
+				br.Msg = "获取数据失败!"
+				br.ErrMsg = "获取数据失败,GetCygxUserRemindListByCompanyId Err:" + err.Error()
+				return
+			}
+			mapUserRemind := make(map[int]bool)
+			for _, v := range listUserRemind {
+				mapUserRemind[v.UserId] = true
+			}
+			for _, v := range listUser {
+				//如果已经添加了提醒的用户就不做添加处理
+				if mapUserRemind[v.UserId] {
+					continue
+				}
+				item := new(cygx.CygxUserRemind)
+				item.AdminId = sysUser.AdminId
+				item.AdminName = sysUser.RealName
+				item.UserId = v.UserId
+				item.Mobile = v.Mobile
+				item.Email = v.Email
+				item.CompanyId = v.CompanyId
+				item.CompanyName = v.CompanyName
+				item.RealName = v.RealName
+				item.CreateTime = time.Now()
+				item.ModifyTime = time.Now()
+				items = append(items, item)
+			}
+		}
+		//批量加入
+		err = cygx.AddCygxUserRemindMulti(items)
 		if err != nil {
 			br.Msg = "添加失败"
 			br.ErrMsg = "添加失败,Err:" + err.Error()
@@ -4173,7 +4301,12 @@ func (this *UserController) UserRemind() {
 		br.Msg = "收藏成功"
 		resp.Status = 1
 	} else {
-		err = cygx.RemoveCygxUserRemind(userId)
+		if sourceType == 1 {
+			err = cygx.RemoveCygxUserRemind(userId) //取消个人提醒
+		} else {
+			err = cygx.RemoveCygxUserRemindByCompanyId(wxUser.CompanyId) //取消整个机构提醒
+		}
+
 		if err != nil {
 			br.Msg = "取消失败"
 			br.ErrMsg = "取消失败,Err:" + err.Error()
@@ -4186,3 +4319,4 @@ func (this *UserController) UserRemind() {
 	br.Success = true
 	br.Data = resp
 }
+

+ 62 - 0
controllers/official_user.go

@@ -41,6 +41,9 @@ func (this *OfficialUserController) OfficialUserList() {
 	currentIndex, _ := this.GetInt("CurrentIndex")
 	keyWord := this.GetString("KeyWord")
 	sourceType := this.GetString("SourceType")
+	markGroup := this.GetString("MarkGroup")
+	startDate := this.GetString("StartDate")
+	endDate := this.GetString("EndDate")
 	if sourceType == "" {
 		br.Msg = "获取失败"
 		br.ErrMsg = "请选择类型"
@@ -67,6 +70,17 @@ func (this *OfficialUserController) OfficialUserList() {
 	if keyWord != "" {
 		condition += ` and (company_name LIKE '%` + keyWord + `%' OR phone LIKE '%` + keyWord + `%' OR email LIKE '%` + keyWord + `%' OR real_name LIKE '%` + keyWord + `%') `
 	}
+	if markGroup != "" {
+		condition += `AND mark_group = `+"'"+markGroup+"'"
+	}
+	if startDate != "" {
+		startDate += " 00:00:00"
+		condition += ` AND create_time >= '` + startDate + `' `
+	}
+	if endDate != "" {
+		endDate += " 23:59:59"
+		condition += ` AND create_time <= '` + endDate + `' `
+	}
 
 	//获取总数据数
 	total, err := models.GetOfficialApplyUserListListCount(condition, pars)
@@ -281,3 +295,51 @@ func (this *OfficialUserController) OfficialUserListExport() {
 	br.Success = true
 	br.Msg = "导出成功"
 }
+
+// @Title 官网试用用户确认
+// @Description 官网试用用户确认接口
+// @Param   Id   query   int  true       "申请记录id"
+// @Success Ret=200 确认成功
+// @router /official/user/mark_group [post]
+func (this *OfficialUserController) OfficialUserMarkGroup() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
+
+	//参数拼接
+	var req models.UserTrialApplyMarkGroupReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	id := req.Id
+
+	//查询记录信息,并做初步判断
+	info, err := models.GetOfficialApplyUserById(id)
+	if err != nil && err.Error() == utils.ErrNoRow() {
+		br.Msg = "确认失败"
+		br.ErrMsg = "确认失败,记录异常"
+		return
+	}
+	if info.Status != "待处理" {
+		br.Msg = "确认失败"
+		br.ErrMsg = "确认失败,当前记录状态信息异常,请刷新页面"
+		return
+	}
+	err = models.OfficialApplyUserMarkGroup(id, sysUser.AdminId, sysUser.RealName, req.GroupName)
+	if err != nil {
+		br.Msg = "确认失败"
+		br.ErrMsg = "确认失败,Err:" + err.Error()
+		return
+	}
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "标记成功"
+	//br.Data = resp
+}

+ 61 - 0
controllers/yb/apply_record.go

@@ -271,6 +271,9 @@ func (this *ApplyRecordController) UserApplyList() {
 
 	pageSize, _ := this.GetInt("PageSize")
 	currentIndex, _ := this.GetInt("CurrentIndex")
+	markGroup := this.GetString("MarkGroup")
+	startDate := this.GetString("StartDate")
+	endDate := this.GetString("EndDate")
 	var startSize int
 	if pageSize <= 0 {
 		pageSize = utils.PageSize20
@@ -314,6 +317,17 @@ func (this *ApplyRecordController) UserApplyList() {
 		condition += " AND (a.real_name LIKE ? OR a.mobile LIKE ? OR a.email LIKE ? OR (a.company_id > 1 AND b.company_name LIKE ?) OR (a.company_id = 1 AND a.note LIKE ?))"
 		pars = append(pars, reqKeyword, reqKeyword, reqKeyword, reqKeyword, reqKeyword)
 	}
+	if markGroup != "" {
+		condition += `AND y.mark_group = `+"'"+markGroup+"'"
+	}
+	if startDate != "" {
+		startDate += " 00:00:00"
+		condition += ` AND IF(y.apply_record_id > 0,y.create_time, a.created_time) >= '` + startDate + `' `
+	}
+	if endDate != "" {
+		endDate += " 23:59:59"
+		condition += ` AND IF(y.apply_record_id > 0,y.create_time, a.created_time) <= '` + endDate + `' `
+	}
 
 	reqApplyStatus := this.GetString("ApplyStatus")
 	if reqApplyStatus != "" {
@@ -912,3 +926,50 @@ func (this *ApplyRecordController) DelPotentialUser() {
 	br.IsAddLog = true
 	return
 }
+
+// MarkGroup
+// @Title 标记分组
+// @Description 标记分组
+// @Param	request	body request.ApplyMarkReq true "type json string"
+// @Success 200 {object} 标记处理成功
+// @router /apply_record/mark_group [post]
+func (this *ApplyRecordController) MarkGroup() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser is Empty"
+		br.Ret = 408
+		return
+	}
+
+	var req request.ApplyMarkGroupReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	if req.ApplyRecordId <= 0 && req.GroupName != "" && req.UserId != 0 {
+		br.Msg = "申请记录ID或者分组名异常"
+		br.ErrMsg = "申请记录ID或者分组名异常"
+		return
+	}
+
+
+	// 标记处理
+	err = ybService.MarkGroupApplyRecord(req.ApplyRecordId, this.SysUser.AdminId, req.UserId, req.GroupName)
+	if err != nil {
+		br.Msg = "标记处理失败! "
+		br.ErrMsg = "标记处理失败,Err:" + err.Error()
+		return
+	}
+
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "标记处理成功"
+}

+ 10 - 0
models/company/company.go

@@ -90,6 +90,7 @@ type CompanySearchItem struct {
 	ShareSeller     string `description:"共享销售员"`
 	ShareSellerId   int    `description:"共享销售员id"`
 	IsShare         int    `description:"0:非共享用户,1:共享客户"`
+	IsScrounge      int    `description:"是否白嫖 0不是 1是"`
 }
 
 type CompanySearchListResp struct {
@@ -269,6 +270,7 @@ type CompanyListItem struct {
 	ServiceTimes     int                  `description:"服务次数"`
 	CloseReason      string               `description:"关闭客户原因"`
 	CloseTime        string               `description:"关闭客户时间"`
+	IsScrounge       int                  `description:"是否白嫖 0不是 1是"`
 }
 
 type TryStageSliceItem struct {
@@ -575,6 +577,7 @@ type CompanyDetail struct {
 	IsShare         int    `description:"0:非共享用户,1:共享客户"`
 	ShareSeller     string `description:"共享销售员"`
 	ShareSellerId   int    `description:"共享销售员id"`
+	IsScrounge      int    `description:"是否白嫖 0不是 1是"`
 }
 
 type CompanyDetailResp struct {
@@ -1202,6 +1205,7 @@ type ButtonPermission struct {
 	BtnServiceRecord bool `description:"查看服务记录按钮:true显示,false不显示"`
 	BtnClose         bool `description:"关闭客户按钮:true显示,false不显示"`
 	BtnLoss          bool `description:"转流失按钮:true显示,false不显示"`
+	IsResearchShow   bool `description:"研选详情展示控制:true显示,false不显示"`
 }
 
 type ButtonSearchPermission struct {
@@ -1887,6 +1891,12 @@ func Close2Loss(companyId, productId int) (err error) {
 	return
 }
 
+// CompanyMarkReq 标记请求
+type CompanyMarkReq struct {
+	CompanyServiceRecordId int `description:"服务记录ID"`
+	Status                 int `description:"0取消标记 1标记"`
+}
+
 // GetCompanyListByCondition 获取客户列表
 func GetCompanyListByCondition(condition string, pars []interface{}, fieldArr []string, orderRule string) (items []*Company, err error) {
 	o := orm.NewOrm()

+ 0 - 1
models/company/company_product.go

@@ -376,7 +376,6 @@ func GetRemarkListByCompanyId(CompanyId string) (items []*CompanyProductRemark,
 	_, err = o.Raw(sql, CompanyId).QueryRows(&items)
 	return
 }
-
 // 冻结客户
 //func FreezeCompany(productId, companyId, adminId int, remark, realName string) (msg, errMsg string){
 //	time.Sleep(time.Second)

+ 10 - 0
models/company/company_service_record.go

@@ -17,6 +17,7 @@ type CompanyServiceRecord struct {
 	SysAdminName           string    `description:"创建人姓名"`
 	CreateTime             time.Time `description:"创建时间"`
 	ModifyTime             time.Time `description:"修改时间"`
+	Mark                   int       `description:"是否标记 0不是 1是"`
 }
 
 var CompanyServiceRecordColumns = struct {
@@ -142,4 +143,13 @@ type CompanyServiceRecordItem struct {
 	SysAdminId             int    `description:"创建人ID"`
 	SysAdminName           string `description:"创建人姓名"`
 	CreateTime             string `description:"创建时间"`
+	Mark                   int    `description:"是否标记 0不是 1是"`
+}
+
+// 更新备注标记
+func UpdateCompanyServiceRecordMark(remarkId, mark int) (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE company_service_record SET mark=? WHERE company_service_record_id=? `
+	_, err = o.Raw(sql, mark, remarkId).Exec()
+	return
 }

+ 23 - 0
models/company/scrounge_company.go

@@ -0,0 +1,23 @@
+package company
+
+import (
+"github.com/beego/beego/v2/client/orm"
+"time"
+)
+
+type ScroungeCompany struct {
+	Id          int `orm:"column(id);pk"`
+	CompanyId   int
+	CompanyName string // 公司名
+	ProductId   int
+	CreateTime  time.Time // 申请时间
+	ModifyTime  time.Time // 修改时间
+	Remark      string    // 备注
+}
+
+func GetScroungeCompany() (list []*ScroungeCompany, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM scrounge_company   `
+	_, err = o.Raw(sql).QueryRows(&list)
+	return
+}

+ 6 - 0
models/cygx/activity.go

@@ -80,6 +80,7 @@ type ActivityRep struct {
 	IsResearch              bool                      `description:"是否为研选"`
 	IsShowHz                int                       `description:"是否同时在弘则展示  1是,0否"`
 	PointsSet               *CygxActivityPointsSetRsq `description:"研选扣点明细"`
+	IsAllCustomerType       int                       `description:"是否全选活动可见类型 0无 1全选"`
 	List                    []*ActivityGroupIndustrialRep
 	VoiceList               []*CygxActivityVoiceReq
 	VideoDetail             *CygxActivityVideoReq
@@ -229,9 +230,11 @@ type CygxActivity struct {
 	IsNeedEmail               int       `description:"是否需要提供邮箱 1是,0否"`
 	SiginupDeadline           string    `description:"报名截止时间"`
 	IsResearchPoints          int       `description:"是否为研选扣点  1是,0否"`
+	IsAllCustomerType         int       `description:"是否全选活动可见类型 0无 1全选"`
 	IsShowHz                  int       `description:"是否同时在弘则展示  1是,0否"`
 	ChartPermissionIdDeputy   int       `description:"行业id"`
 	ChartPermissionNameDeputy string    `description:"行业名称"`
+	CancelDeadline            string    `description:"取消报名截止时间"`
 }
 
 type CygxActivityEditDetail struct {
@@ -396,11 +399,13 @@ func EditActivity(item *CygxActivity, oldPublishStatus int, industrialActivityIt
 	updateParams["IsNeedEmail"] = item.IsNeedEmail
 	updateParams["SiginupDeadline"] = item.SiginupDeadline
 	updateParams["IsResearchPoints"] = item.IsResearchPoints
+	updateParams["IsAllCustomerType"] = item.IsAllCustomerType
 	if item.ChartPermissionId == utils.CHART_PERMISSION_ID_YANXUAN {
 		updateParams["IsShowHz"] = item.IsShowHz //研选的才做修改
 	}
 	updateParams["ChartPermissionNameDeputy"] = item.ChartPermissionNameDeputy
 	updateParams["ChartPermissionIdDeputy"] = item.ChartPermissionIdDeputy
+	updateParams["CancelDeadline"] = item.CancelDeadline
 	//修改活动信息
 	ptrStructOrTableName := "cygx_activity"
 	whereParam := map[string]interface{}{"activity_id": item.ActivityId}
@@ -513,6 +518,7 @@ func EditActivity(item *CygxActivity, oldPublishStatus int, industrialActivityIt
 				updateParams["PointsType"] = itemPointsSet.PointsType
 				updateParams["CompanyPointsNum"] = itemPointsSet.CompanyPointsNum
 				updateParams["ModifyTime"] = itemPointsSet.ModifyTime
+				updateParams["CancelDeadlineType"] = itemPointsSet.CancelDeadlineType
 				//修改活动信息
 				ptrStructOrTableName = "cygx_activity_points_set"
 				whereParam := map[string]interface{}{"activity_id": itemPointsSet.ActivityId}

+ 19 - 17
models/cygx/activity_points_set.go

@@ -18,26 +18,28 @@ type YanXuanActivityPointsRedis struct {
 }
 
 type CygxActivityPointsSet struct {
-	Id               int       `gorm:"column:id;primary_key;AUTO_INCREMENT" json:"id"`
-	ActivityId       int       `gorm:"column:activity_id;NOT NULL" json:"activity_id"`                         // 活动ID
-	PointsObject     string    `gorm:"column:points_object;default:1;NOT NULL" json:"points_object"`           // 扣点对象,1:参会人、2:办会人、3:办会人和参会人
-	CompanyId        int       `gorm:"column:company_id;default:0;NOT NULL" json:"company_id"`                 // 公司ID
-	CompanyName      string    `gorm:"column:company_name;NOT NULL" json:"company_name"`                       // 公司名称
-	UserPointsNum    string    `gorm:"column:user_points_num;default:0;NOT NULL" json:"user_points_num"`       // 参会人扣点数量
-	PointsType       string    `gorm:"column:points_type;default:0;NOT NULL" json:"points_type"`               // 扣点形式,1:报名即扣点,2:到会即扣点
-	CompanyPointsNum string    `gorm:"column:company_points_num;default:0;NOT NULL" json:"company_points_num"` // 办会人扣点数量
-	CreateTime       time.Time `gorm:"column:create_time;NOT NULL" json:"create_time"`                         // 创建时间
-	ModifyTime       time.Time `gorm:"column:modify_time;NOT NULL" json:"modify_time"`                         // 更新时间
+	Id                 int       `gorm:"column:id;primary_key;AUTO_INCREMENT" json:"id"`
+	ActivityId         int       `gorm:"column:activity_id;NOT NULL" json:"activity_id"`                             // 活动ID
+	PointsObject       string    `gorm:"column:points_object;default:1;NOT NULL" json:"points_object"`               // 扣点对象,1:参会人、2:办会人、3:办会人和参会人
+	CompanyId          int       `gorm:"column:company_id;default:0;NOT NULL" json:"company_id"`                     // 公司ID
+	CompanyName        string    `gorm:"column:company_name;NOT NULL" json:"company_name"`                           // 公司名称
+	UserPointsNum      string    `gorm:"column:user_points_num;default:0;NOT NULL" json:"user_points_num"`           // 参会人扣点数量
+	PointsType         string    `gorm:"column:points_type;default:0;NOT NULL" json:"points_type"`                   // 扣点形式,1:报名即扣点,2:到会即扣点
+	CompanyPointsNum   string    `gorm:"column:company_points_num;default:0;NOT NULL" json:"company_points_num"`     // 办会人扣点数量
+	CancelDeadlineType string    `gorm:"column:cancel_deadline_type;default:0;NOT NULL" json:"cancel_deadline_type"` // 取消报名截止时间类型,0:不设置,1:同报名截止时间, 2:24小时之前、3:48小时之前
+	CreateTime         time.Time `gorm:"column:create_time;NOT NULL" json:"create_time"`                             // 创建时间
+	ModifyTime         time.Time `gorm:"column:modify_time;NOT NULL" json:"modify_time"`                             // 更新时间
 }
 
 type CygxActivityPointsSetRsq struct {
-	ActivityId       int    `gorm:"column:activity_id;NOT NULL" json:"ActivityId"`                        // 活动ID
-	PointsObject     string `gorm:"column:points_object;NOT NULL" json:"PointsObject"`                    // 扣点对象,1:参会人、2:办会人、3:办会人和参会人
-	CompanyId        int    `gorm:"column:company_id;default:0;NOT NULL" json:"CompanyId"`                // 公司ID
-	CompanyName      string `gorm:"column:company_name;NOT NULL" json:"CompanyName"`                      // 公司名称
-	UserPointsNum    string `gorm:"column:user_points_num;default:0;NOT NULL" json:"UserPointsNum"`       // 参会人扣点数量
-	PointsType       string `gorm:"column:points_type;default:0;NOT NULL" json:"PointsType"`              // 扣点形式,1:报名即扣点,2:到会即扣点
-	CompanyPointsNum string `gorm:"column:company_points_num;default:0;NOT NULL" json:"CompanyPointsNum"` // 办会人扣点数量
+	ActivityId         int    `gorm:"column:activity_id;NOT NULL" json:"ActivityId"`                        // 活动ID
+	PointsObject       string `gorm:"column:points_object;NOT NULL" json:"PointsObject"`                    // 扣点对象,1:参会人、2:办会人、3:办会人和参会人
+	CompanyId          int    `gorm:"column:company_id;default:0;NOT NULL" json:"CompanyId"`                // 公司ID
+	CompanyName        string `gorm:"column:company_name;NOT NULL" json:"CompanyName"`                      // 公司名称
+	UserPointsNum      string `gorm:"column:user_points_num;default:0;NOT NULL" json:"UserPointsNum"`       // 参会人扣点数量
+	PointsType         string `gorm:"column:points_type;default:0;NOT NULL" json:"PointsType"`              // 扣点形式,1:报名即扣点,2:到会即扣点
+	CompanyPointsNum   string `gorm:"column:company_points_num;default:0;NOT NULL" json:"CompanyPointsNum"` // 办会人扣点数量
+	CancelDeadlineType string `description:"取消报名截止时间类型,0:不设置,1:同报名截止时间, 2:24小时之前、3:48小时之前"`
 }
 
 type CygxActivityPointsSetConfigListResp struct {

+ 7 - 1
models/cygx/activity_signup.go

@@ -5,7 +5,7 @@ import (
 	"hongze/hz_crm_api/models/company"
 	"hongze/hz_crm_api/utils"
 
-	//"hongze/hz_crm_api/models"
+	//"hongze/hongze_admin/models"
 	"github.com/beego/beego/v2/client/orm"
 	"github.com/rdlucklib/rdluck_tools/paging"
 	"time"
@@ -37,6 +37,7 @@ type CygxSignupList struct {
 	IsCanAppointmentMinutes int    `description:"是否可预约纪要 1是 ,0 否 默认0 "`
 	IsCancel                int    `description:"是否取消,1是,0否"`
 	IsYidongConduct         int    `description:"是否属于易董办会 1:是 、0:否"`
+	IsResearchPoints        int    `description:"是否为研选扣点  1是,0否"`
 }
 
 type GetCygxSignupListRep struct {
@@ -1101,6 +1102,11 @@ type SendGroup struct {
 	Name string
 }
 
+type SendGroupStr struct {
+	Id   string
+	Name string
+}
+
 type PermissionList struct {
 	CompanyId  int
 	Permission string

+ 15 - 4
models/cygx/cygx_user.go

@@ -197,8 +197,10 @@ type UserRemarksResp struct {
 }
 
 type UserRemarAddReq struct {
-	UserId  int    `description:"用户ID"`
-	Content string `description:"备注信息"`
+	UserId     int    `description:"用户ID"`
+	Content    string `description:"备注信息"`
+	SourceType int    `description:"操作类型,1:对联系人单独设置,2:对机构批量设置"`
+	DoType     int    `description:"操作方式,1:添加,2:取消"`
 }
 
 // 添加UserRemarks
@@ -322,8 +324,15 @@ type UserInteraction struct {
 	CurrentIndex          int    `description:"当前页页码,配合前端分页添加的参数"`
 	RegisterPlatform      int    `description:"来源 1小程序,2:网页 ,3:策略平台"`
 	SourcePlatform        string `description:"来源 'MOBILE:移动端小程序','PC:PC端小程序','CELUE:上海策略平台','WEB:查研观向网页版'"`
+	TagId                 int
+	TagName               string `orm:"column(tag_name);NOT NULL"`       // 标签名
+	ArticleTypes          string `orm:"column(article_types);NOT NULL"`  // 报告系列
+	ActivityTypes         string `orm:"column(activity_types);NOT NULL"` // 活动类型
+	Industries            string `orm:"column(industries);NOT NULL"`     // 产业
+	SubjectNames          string `orm:"column(subject_names);NOT NULL"`  // 标的
 }
 
+
 // 查研观向图表
 type CygxChartResp struct {
 	Title       string `description:"标题"`
@@ -833,6 +842,7 @@ type GetUserInteractionTableCountResp struct {
 	RoadshowVideoNum    int `description:"产业视频播放量"`
 	ActivityVideoNum    int `description:"活动视频播放量"`
 	ActivityVoiceNum    int `description:"活动音频播放量"`
+	TagNum              int `description:"首页标签点击量"`
 }
 
 // 用户互动总数统计
@@ -852,8 +862,9 @@ func GetUserInteractionTableCount(uid int) (item *GetUserInteractionTableCountRe
 			( SELECT COUNT( 1 ) FROM cygx_activity_special_meeting_detail AS h INNER JOIN cygx_activity_special AS a ON a.activity_id = h.activity_id WHERE h.mobile = u.mobile  AND a.publish_status = 1 AND a.activity_time_end < NOW()) AS trip_num,
 			( SELECT COUNT( 1 ) FROM cygx_micro_roadshow_video_history AS h  INNER JOIN cygx_micro_roadshow_video as v ON v.video_id = h.video_id WHERE  h.mobile = u.mobile  ) AS roadshow_video_num,
 			( SELECT COUNT( 1 ) FROM cygx_activity_video_history AS h  INNER JOIN cygx_activity_video as v ON v.video_id = h.video_id WHERE  h.mobile = u.mobile  ) AS activity_video_num,
-			( SELECT COUNT( 1 ) FROM cygx_activity_voice_history AS h  INNER JOIN cygx_activity_voice as v ON v.activity_id = h.activity_id WHERE  h.mobile = u.mobile  ) AS activity_voice_num
-		FROM
+			( SELECT COUNT( 1 ) FROM cygx_activity_voice_history AS h  INNER JOIN cygx_activity_voice as v ON v.activity_id = h.activity_id WHERE  h.mobile = u.mobile  ) AS activity_voice_num,
+			( SELECT COUNT(1) FROM cygx_tag_history as a INNER JOIN cygx_tag AS b ON a.tag_id = b.tag_id WHERE a.user_id=u.user_id  ) AS tag_num
+			FROM
 			wx_user  as u
 		WHERE
 			u.user_id = ?`

+ 1 - 0
models/cygx/report_selection_log.go

@@ -56,6 +56,7 @@ type CygxReportSelectionLogResp struct {
 	OverviewArticleId        int      `description:"综述报告Id"`
 	OverviewArticleTitle     string   `description:"综述报告标题"`
 	IsNew                    int      `description:"是否为New标签"`
+	ChartPermissionSort      int      `description:"品种排序"`
 }
 
 type CygxReportSelectionChart struct {

+ 106 - 1
models/cygx/tag_history.go

@@ -7,7 +7,7 @@ import (
 
 type CygxTagHistory struct {
 	Id               int `orm:"column(id);pk"`
-	TimeLineId       int
+	TagId            int
 	UserId           int
 	CreateTime       time.Time
 	Mobile           string    `description:"手机号"`
@@ -61,3 +61,108 @@ func GetCygxTagHistoryCountPv(tagId int) (count int, err error) {
 	err = o.Raw(sqlCount, tagId).QueryRow(&count)
 	return
 }
+
+// 获取数量
+func GetCygxTagHistoryCountByUserId(userId int) (count int, err error) {
+	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_tag_history as a 
+	INNER JOIN cygx_tag AS b ON a.tag_id = b.tag_id 
+	WHERE a.user_id=? ORDER BY a.create_time  `
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, userId).QueryRow(&count)
+	return
+}
+
+// 获取数量
+func GetCygxTagHistoryByUserId(userId, startSize, pageSize int) (list []*UserInteraction, err error) {
+	sqlCount := ` SELECT b.*,a.create_time FROM cygx_tag_history as a INNER JOIN cygx_tag AS b ON a.tag_id = b.tag_id 
+WHERE a.user_id=? ORDER BY a.create_time DESC LIMIT ?,? `
+	o := orm.NewOrm()
+	_, err = o.Raw(sqlCount, userId, startSize, pageSize).QueryRows(&list)
+	return
+}
+
+// 获取数量
+func GetCygxTagHistoryCountByCompanyId(companyId int, condition string) (count int, err error) {
+	sqlCount := ` SELECT COUNT(1) AS count  FROM (SELECT b.* FROM cygx_tag_history as a 
+	INNER JOIN cygx_tag AS b ON a.tag_id = b.tag_id 
+	LEFT JOIN cygx_user_interaction_num AS ui ON ui.user_id = a.user_id `
+	if condition != "" {
+		sqlCount += condition
+	}
+	sqlCount += ` WHERE a.company_id=? ) AS t `
+	o := orm.NewOrm()
+	err = o.Raw(sqlCount, companyId).QueryRow(&count)
+	return
+}
+
+// 获取数量
+func GetCygxTagHistoryByCompanyId(companyId, startSize, pageSize int, condition string) (list []*UserInteraction, err error) {
+	sqlCount := ` SELECT a.real_name,a.mobile,ui.tag_num, a.create_time AS create_time,
+b.tag_id,b.tag_name,b.article_types,b.activity_types,b.industries,b.subject_names   
+FROM cygx_tag_history as a 
+	INNER JOIN cygx_tag AS b ON a.tag_id = b.tag_id  
+	LEFT JOIN cygx_user_interaction_num AS ui ON ui.user_id = a.user_id `
+	if condition != "" {
+		sqlCount += condition
+	}
+	sqlCount += ` 
+	WHERE a.company_id=? ORDER BY tag_num DESC ,create_time DESC LIMIT ?,? `
+	o := orm.NewOrm()
+	_, err = o.Raw(sqlCount, companyId, startSize, pageSize).QueryRows(&list)
+	return
+}
+
+// 获取数量
+func GetCygxTagHistoryCountByCompanyIds(companyIds, condition string) (count int, err error) {
+	sqlCount := ` SELECT a.real_name,a.mobile,b.*,ci.tag_num,ui.tag_num AS ui_tag_num,a.company_name  FROM cygx_tag_history as a  
+	INNER JOIN cygx_tag AS b ON a.tag_id = b.tag_id 
+	LEFT JOIN company_product AS p ON a.company_id=p.company_id 
+	LEFT JOIN cygx_company_interaction_num AS ci ON ci.company_id = a.company_id 
+	LEFT JOIN cygx_user_interaction_num AS ui ON ui.user_id = a.user_id WHERE p.product_id=2 `
+	if companyIds != "" {
+		sqlCount += `AND a.company_id IN ( ` + companyIds + `) `
+	}
+	if condition != "" {
+		sqlCount += condition
+	}
+	sql := `SELECT COUNT(1) AS count  FROM (` + sqlCount + `)  AS t`
+	o := orm.NewOrm()
+	err = o.Raw(sql).QueryRow(&count)
+	return
+}
+
+// 获取数量
+func GetCygxTagHistoryByCompanyIds(companyIds, condition string, startSize, pageSize int) (list []*UserInteraction, err error) {
+	sqlCount := ` SELECT a.real_name,a.mobile,ci.tag_num,ui.tag_num AS ui_tag_num,a.company_name, a.create_time AS create_time,
+b.tag_id,b.tag_name,b.article_types,b.activity_types,b.industries,b.subject_names
+FROM cygx_tag_history as a 
+INNER JOIN cygx_tag AS b ON a.tag_id = b.tag_id 
+LEFT JOIN company_product AS p ON a.company_id=p.company_id 
+LEFT JOIN cygx_company_interaction_num AS ci ON ci.company_id = a.company_id 
+LEFT JOIN cygx_user_interaction_num AS ui ON ui.user_id = a.user_id WHERE p.product_id=2 `
+	if companyIds != "" {
+		sqlCount += `AND a.company_id IN ( ` + companyIds + `) `
+	}
+	if condition != "" {
+		sqlCount += condition
+	}
+	sqlCount += ` ORDER BY tag_num DESC ,ui_tag_num DESC , create_time DESC LIMIT ?,? `
+	o := orm.NewOrm()
+	_, err = o.Raw(sqlCount, startSize, pageSize).QueryRows(&list)
+	return
+}
+
+// 获取数量
+func GetCygxTagHistoryCountByCompanyIdCondition(condition string) (count int, err error) {
+	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_tag_history as a  
+	INNER JOIN cygx_tag AS b ON a.tag_id = b.tag_id 
+	INNER JOIN company_product AS p ON a.company_id=p.company_id WHERE p.product_id=2`
+	if condition != "" {
+		sqlCount += condition
+	}
+	sqlCount += `GROUP BY a.user_id,a.tag_id   `
+	sql := `SELECT COUNT(1) AS count  FROM (` + sqlCount + `)  AS t`
+	o := orm.NewOrm()
+	err = o.Raw(sql).QueryRow(&count)
+	return
+}

+ 52 - 1
models/cygx/user_remind.go

@@ -19,13 +19,33 @@ type CygxUserRemind struct {
 	AdminName   string `description:"管理员销售姓名"`
 }
 
-//添加
+// 添加
 func AddCygxUserRemind(item *CygxUserRemind) (lastId int64, err error) {
 	o := orm.NewOrm()
 	lastId, err = o.Insert(item)
 	return
 }
 
+// AddCygxUserRemindMulti 批量添加
+func AddCygxUserRemindMulti(items []*CygxUserRemind) (err error) {
+	o, err := orm.NewOrm().Begin()
+	if err != nil {
+		return
+	}
+	defer func() {
+		if err == nil {
+			o.Commit()
+		} else {
+			o.Rollback()
+		}
+	}()
+	if len(items) > 0 {
+		//批量添加流水信息
+		_, err = o.InsertMulti(len(items), items)
+	}
+	return
+}
+
 type CygxUserRemindResp struct {
 	Status int `description:"1:添加,2:取消"`
 }
@@ -37,8 +57,39 @@ func RemoveCygxUserRemind(userId int) (err error) {
 	return
 }
 
+func RemoveCygxUserRemindByCompanyId(companyId int) (err error) {
+	o := orm.NewOrm()
+	sql := `DELETE FROM cygx_user_remind WHERE company_id = ? `
+	_, err = o.Raw(sql, companyId).Exec()
+	return
+}
+
 func GetCygxUserRemindCount(userId int) (count int, err error) {
 	sql := `SELECT COUNT(1) AS count FROM cygx_user_remind WHERE user_id=? `
 	err = orm.NewOrm().Raw(sql, userId).QueryRow(&count)
 	return
 }
+
+// 列表
+func GetCygxUserRemindList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxUserRemind, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_user_remind as art WHERE 1= 1 `
+	if condition != "" {
+		sql += condition
+	}
+	if startSize+startSize > 0 {
+		sql += ` LIMIT ?,?  `
+		_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	} else {
+		_, err = o.Raw(sql, pars).QueryRows(&items)
+	}
+	return
+}
+
+// 根据公司ID获取列表
+func GetCygxUserRemindListByCompanyId(companyId int) (items []*CygxUserRemind, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_user_remind  WHERE 1= 1  AND company_id = ? `
+	_, err = o.Raw(sql, companyId).QueryRows(&items)
+	return
+}

+ 1 - 1
models/eta_trial/eta_trial.go

@@ -110,7 +110,7 @@ func AddETATrial(item *EtaTrial) (lastId int64, err error) {
 }
 
 func GetETATrialByAccount(account string) (items []*EtaTrial, err error) {
-	sql := `SELECT * FROM eta_trial WHERE user_name = ? `
+	sql := `SELECT * FROM eta_trial WHERE account = ? `
 	o := orm.NewOrm()
 
 	_, err = o.Raw(sql, account).QueryRows(&items)

+ 27 - 6
models/user_trial_apply.go

@@ -23,6 +23,7 @@ type UserTrialApply struct {
 	OpUserName  string    `orm:"size(64)";description:"操作用户名称"`
 	CreateTime  time.Time `description:"申请时间"`
 	ModifyTime  time.Time `description:"修改时间"`
+	MarkGroup   string    `description:"标记分组"`
 }
 
 type UserTrialApplyItem struct {
@@ -43,20 +44,21 @@ type UserTrialApplyItem struct {
 	CreateTimeStr string    `description:"申请时间字符串"`
 	ModifyTime    time.Time `description:"修改时间"`
 	ModifyTimeStr string    `description:"申请时间字符串"`
+	MarkGroup     string    `description:"标记分组"`
 }
 
-//列表数据
+// 列表数据
 type UserTrialApplyListResp struct {
 	List   []*UserTrialApplyItem
 	Paging *paging.PagingItem `description:"分页数据"`
 }
 
-//确认申请
+// 确认申请
 type UserTrialApplyConfirmReq struct {
 	Id int `description:"Id"`
 }
 
-//获取获取官网申请列表页数据的数据数
+// 获取获取官网申请列表页数据的数据数
 func GetOfficialApplyUserListListCount(condition string, pars []interface{}) (count int, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT 
@@ -70,7 +72,7 @@ func GetOfficialApplyUserListListCount(condition string, pars []interface{}) (co
 	return
 }
 
-//获取官网申请列表页数据
+// 获取官网申请列表页数据
 func GetOfficialApplyUserListList(condition string, pars []interface{}, startSize, pageSize int) (items []*UserTrialApplyItem, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT * from user_trial_apply `
@@ -94,14 +96,14 @@ func GetOfficialApplyUserListListExport(condition string, pars []interface{}) (i
 	return
 }
 
-//获取申请记录信息
+// 获取申请记录信息
 func GetOfficialApplyUserById(id int) (item *UserTrialApply, err error) {
 	o := orm.NewOrm()
 	err = o.Raw(`SELECT * from user_trial_apply where id = ?`, id).QueryRow(&item)
 	return
 }
 
-//确认申请记录
+// 确认申请记录
 func ConfirmOfficialApplyUser(id int, opUserId int, opUserName string) (err error) {
 	sql := ` UPDATE user_trial_apply
 			SET
@@ -113,3 +115,22 @@ func ConfirmOfficialApplyUser(id int, opUserId int, opUserName string) (err erro
 	_, err = orm.NewOrm().Raw(sql, "已处理", opUserId, opUserName, time.Now(), id).Exec()
 	return
 }
+
+type UserTrialApplyMarkGroupReq struct {
+	Id        int    `description:"申请记录ID"`
+	GroupName string `description:"分组名"`
+}
+
+// 标记分组
+func OfficialApplyUserMarkGroup(id int, opUserId int, opUserName,groupName string) (err error) {
+	sql := ` UPDATE user_trial_apply
+			SET
+			  status = ?,
+			  op_user_id = ?,
+			  op_user_name = ?,
+			  mark_group = ?,
+			  modify_time = ?
+			WHERE id = ? `
+	_, err = orm.NewOrm().Raw(sql, "已处理", opUserId, opUserName, groupName, time.Now(), id).Exec()
+	return
+}

+ 8 - 0
models/wx_user.go

@@ -514,3 +514,11 @@ func GetWxUserListByUserMobileHaveCompany(mobiles []string) (list []*WxUserItem,
 	_, err = o.Raw(sql, mobiles).QueryRows(&list)
 	return
 }
+
+// GetWxUserListCompanyId 根据公司ID获取所有用户信息
+func GetWxUserListCompanyId(companyId int) (list []*WxUserItem, err error) {
+	o := orm.NewOrm()
+	sql := ` SELECT* FROM wx_user  WHERE company_id = ?   `
+	_, err = o.Raw(sql, companyId).QueryRows(&list)
+	return
+}

+ 4 - 1
models/yb/apply_record.go

@@ -25,6 +25,7 @@ type ApplyRecord struct {
 	CreateTime      time.Time `description:"创建时间"`
 	IsMove          int       `description:"是否已移动"`
 	Source          int       `description:"申请来源:1-我的 2-活动 3-图库"`
+	MarkGroup       string    `description:"标记分组"`
 }
 
 func (applyRecord *ApplyRecord) TableName() string {
@@ -81,6 +82,7 @@ type ApplyListV2 struct {
 	RegisterSource   int       `description:"注册来源"`
 	SourceStr        string    `description:"来源"`
 	DelBtn           bool      `description:"是否展示删除按钮,true展示,false隐藏"`
+	MarkGroup        string    `description:"标记分组"`
 }
 
 // GetApplyRecordList 获取申请记录列表
@@ -156,6 +158,7 @@ SELECT
 	y.is_move,
 	y.source,
 	y.from_page,
+	y.mark_group,
     y.company_name as user_company_name
     #bp.seller_id,
 	#bp.seller_name
@@ -280,7 +283,7 @@ func GetTotalByUserIds(userIdsStr string) (list []*UserApplyTotal, err error) {
 	return
 }
 
-//DelApplyRecordByUserId 根据用户id删除该用户的所有申请
+// DelApplyRecordByUserId 根据用户id删除该用户的所有申请
 func DelApplyRecordByUserId(userId int64) (err error) {
 	o := orm.NewOrm()
 	sql := ` DELETE FROM yb_apply_record WHERE user_id=? `

+ 9 - 3
models/yb/request/apply_record.go

@@ -1,6 +1,12 @@
 package request
 
 type ApplyMarkReq struct {
-	ApplyRecordId	int		`description:"申请记录ID"`
-	UserId          int     `description:"用户ID"`
-}
+	ApplyRecordId int `description:"申请记录ID"`
+	UserId        int `description:"用户ID"`
+}
+
+type ApplyMarkGroupReq struct {
+	ApplyRecordId int    `description:"申请记录ID"`
+	GroupName     string `description:"分组名"`
+	UserId        int `description:"用户ID"`
+}

+ 54 - 0
routers/commentsRouter.go

@@ -511,6 +511,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:ActivityCoAntroller"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:ActivityCoAntroller"],
+        beego.ControllerComments{
+            Method: "DeadlineSet",
+            Router: `/activity/deadlineSet`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:ActivityCoAntroller"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:ActivityCoAntroller"],
         beego.ControllerComments{
             Method: "Delete",
@@ -1123,6 +1132,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:ActivitySpecialTripCoAntroller"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:ActivitySpecialTripCoAntroller"],
+        beego.ControllerComments{
+            Method: "SendGroupList",
+            Router: `/special/trip/tempMsg/sendGroupList`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:ActivitySpecialTripCoAntroller"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:ActivitySpecialTripCoAntroller"],
         beego.ControllerComments{
             Method: "TripList",
@@ -7117,6 +7135,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/yb:ApplyRecordController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/yb:ApplyRecordController"],
+        beego.ControllerComments{
+            Method: "MarkGroup",
+            Router: `/apply_record/mark_group`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/yb:ApplyRecordController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/yb:ApplyRecordController"],
         beego.ControllerComments{
             Method: "MarkHandle",
@@ -8530,6 +8557,24 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hz_crm_api/controllers:CompanyController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers:CompanyController"],
+        beego.ControllerComments{
+            Method: "CompanyShareListByCity",
+            Router: `/share/list/city`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
+    beego.GlobalControllerRouter["hongze/hz_crm_api/controllers:CompanyController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers:CompanyController"],
+        beego.ControllerComments{
+            Method: "CompanyShareMark",
+            Router: `/share/mark`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hz_crm_api/controllers:CompanyController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers:CompanyController"],
         beego.ControllerComments{
             Method: "MoveShareSeller",
@@ -9340,6 +9385,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hz_crm_api/controllers:OfficialUserController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers:OfficialUserController"],
+        beego.ControllerComments{
+            Method: "OfficialUserMarkGroup",
+            Router: `/official/user/mark_group`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hz_crm_api/controllers:PdfToImgCommonController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers:PdfToImgCommonController"],
         beego.ControllerComments{
             Method: "PdfToImgConvert",

+ 35 - 2
services/cygx/acitvity.go

@@ -499,6 +499,26 @@ func CheckActivityAddAppointment(activityInfo *cygx.ActivityDetail) (isProhibit
 	return
 }
 
+//// 处理活动取消报名截止时间类型展示
+//func ActivityCancelDeadlineType(activityInfo *cygx.ActivityDetail) (cancelDeadlineType int) {
+//	//CancelDeadlineType      int                       `description:"取消报名截止时间类型,0:不设置,1:24小时之前、2:48小时之前"`
+//	//如果时间是初始值或者为空,就是默认为0 状态
+//	if activityInfo.CancelDeadline == "" || activityInfo.CancelDeadline == utils.EmptyDateTimeStr {
+//		cancelDeadlineType = 0
+//		return
+//	}
+//	activityTime := utils.StrTimeToTime(activityInfo.ActivityTime)     //时间字符串格式转时间格式
+//	cancelDeadline := utils.StrTimeToTime(activityInfo.CancelDeadline) //时间字符串格式转时间格式
+//	hourNum := activityTime.Sub(cancelDeadline).Hours()
+//	if hourNum == 24 {
+//		cancelDeadlineType = 1
+//	}
+//	if hourNum == 48 {
+//		cancelDeadlineType = 2
+//	}
+//	return
+//}
+
 // 解析查研观向的模板内容
 func ActivityBodyAnalysis(body string, activeState int, req cygx.ActivityRep) (itemr *cygx.CygxActivity, errstr string) {
 	item := new(cygx.CygxActivity)
@@ -569,14 +589,27 @@ func ActivityBodyAnalysis(body string, activeState int, req cygx.ActivityRep) (i
 					errstr = "时间格式错误,请按照模板时间格式填写!"
 					return
 				}
-				//如果报名时间不为空,那么就做校验、
-				if req.SiginupDeadline != "" {
+				//如果报名时间不为空,而且是买方研选活动那么就做校验、
+				if req.SiginupDeadline != "" && strings.Contains(req.PermissionName, utils.CHART_PERMISSION_NAME_MF_YANXUAN) {
 					siginupDeadline := utils.StrTimeToTime(req.SiginupDeadline)
 					if siginupDeadline.After(resultTime) && activeState == 0 {
 						errstr = "截止时间需早于活动开始时间!"
 						return
 					}
 				}
+				//设置取消报名截止时间为会前一小时
+				item.CancelDeadline = resultTime.Add(-time.Hour * 1).Format(utils.FormatDateTime)
+				if req.IsResearchPoints == 1 {
+					if req.PointsSet.CancelDeadlineType == "1" && req.SiginupDeadline != "" {
+						item.CancelDeadline = req.SiginupDeadline
+					}
+					if req.PointsSet.CancelDeadlineType == "2" {
+						item.CancelDeadline = resultTime.Add(-time.Hour * 24).Format(utils.FormatDateTime)
+					}
+					if req.PointsSet.CancelDeadlineType == "3" {
+						item.CancelDeadline = resultTime.Add(-time.Hour * 48).Format(utils.FormatDateTime)
+					}
+				}
 			}
 		}
 		if strings.Contains(contentTxt, "主讲人:") {

+ 1 - 0
services/cygx/activity_points_set.go

@@ -131,6 +131,7 @@ func CheckActivityPointsSet(pointsSet *cygx.CygxActivityPointsSetRsq, activityId
 	item.UserPointsNum = pointsSet.UserPointsNum
 	item.PointsType = pointsSet.PointsType
 	item.CompanyPointsNum = pointsSet.CompanyPointsNum
+	item.CancelDeadlineType = pointsSet.CancelDeadlineType
 	item.CreateTime = time.Now()
 	item.ModifyTime = time.Now()
 	itemResp = item

+ 0 - 24
services/cygx/special_wx_msg.go

@@ -157,30 +157,6 @@ func DetermineTripCancel(activityId int) (err error) {
 	if len(openIdList) == 0 {
 		return
 	}
-	//sendMap := make(map[string]interface{})
-	//sendData := make(map[string]interface{})
-	//var first string
-	//var keyword1 string
-	//var keyword2 string
-	//first = "【" + activityInfo.ResearchTheme + "】专项调研因专家安排变动,本次调研活动延期举办,具体时间另行通知"
-	//keyword1 = activityInfo.ResearchTheme
-	//keyword2 = "已取消"
-	//
-	//redirectUrl := ""
-	//sendData["first"] = map[string]interface{}{"value": first, "color": "#173177"}
-	//sendData["keyword1"] = map[string]interface{}{"value": keyword1, "color": "#173177"}
-	//sendData["keyword2"] = map[string]interface{}{"value": keyword2, "color": "#173177"}
-	//sendUrl := "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=" + accessToken
-	//if utils.RunMode == "release" {
-	//	sendMap["template_id"] = utils.WxMsgTemplateIdActivityChangeApplyXzs
-	//} else {
-	//	sendMap["template_id"] = utils.WxMsgTemplateIdActivityChangeApply
-	//}
-	//sendMap["url"] = redirectUrl
-	//sendMap["data"] = sendData
-	//sendMap["miniprogram"] = map[string]interface{}{"appid": utils.WxCygxAppId, "pagepath": "activityPages/specialDetail/specialDetail?id=" + strconv.Itoa(activityId)}
-	//services.PublicsendTemplateMsg(sendUrl, sendMap, openIdList, strconv.Itoa(activityId), utils.TEMPLATE_MSG_CYGX_ACTIVITY_UPDATE)
-
 	openIdArr := make([]string, len(openIdList))
 	for i, v := range openIdList {
 		openIdArr[i] = v.OpenId

+ 73 - 0
services/yb/apply_record.go

@@ -258,3 +258,76 @@ func DeleteApplyUser(userId int64) (err error) {
 	}
 	return
 }
+
+// MarkGroupApplyRecord 标记申请记录和分组
+func MarkGroupApplyRecord(applyRecordId, adminId, userId int, groupName string) (err error) {
+	o := orm.NewOrm()
+	to, err := o.Begin()
+	if err != nil {
+		return
+	}
+	defer func() {
+		if err != nil {
+			_ = to.Rollback()
+		} else {
+			_ = to.Commit()
+		}
+	}()
+
+	if applyRecordId > 0 {
+		applyRecord, tErr := yb.GetApplyRecordById(applyRecordId)
+		if tErr != nil {
+			if tErr.Error() == utils.ErrNoRow() {
+				err = errors.New(fmt.Sprint("申请记录不存在:", err))
+			} else {
+				err = tErr
+			}
+			return
+		}
+		if applyRecord.OpStatus != 0 {
+			err = errors.New(fmt.Sprint("申请记录处理状态有误:", err))
+			return
+		}
+		if userId > 0 && userId != applyRecord.UserId {
+			err = errors.New(fmt.Sprint("申请记录ID与用户ID不匹配:", err))
+			return
+		}
+		userId = applyRecord.UserId
+		// 1.标记申请记录
+		applyRecord.OpStatus = 1
+		applyRecord.DealTime = time.Now()
+		applyRecord.SysUserId = adminId
+		applyRecord.MarkGroup = groupName
+		updateCols := make([]string, 0)
+		updateCols = append(updateCols, "OpStatus", "DealTime", "SysUserId","MarkGroup")
+		err = applyRecord.Update(updateCols)
+		if err != nil {
+			err = errors.New(fmt.Sprint("申请记录标记失败", err))
+			return
+		}
+	}
+
+	// 2.标记wx用户表
+	wxUser, err := models.GetWxUserByUserId(userId)
+	if err != nil {
+		if err.Error() == utils.ErrNoRow() {
+			err = nil // 用户可能在潜在用户列表直接被删除,那么直接不标记
+			return
+		}
+		return
+	}
+	// 未处理过则进行标记
+	if wxUser.IsDeal == 0 {
+		wxUser.IsDeal = 1
+		wxUser.LastUpdatedTime = time.Now()
+		userUpdateCols := make([]string, 0)
+		userUpdateCols = append(userUpdateCols, "IsDeal", "LastUpdatedTime")
+		err = wxUser.Update(userUpdateCols)
+		if err != nil {
+			err = errors.New(fmt.Sprint("对应用户信息标记失败", err))
+			return
+		}
+	}
+
+	return
+}

+ 1 - 0
utils/constants.go

@@ -113,6 +113,7 @@ const (
 	ROLE_TYPE_FICC_SELLER = "ficc销售"
 	ROLE_TYPE_RAI_ADMIN   = "权益管理员"
 	ROLE_TYPE_RAI_SELLER  = "权益销售"
+	ROLE_TYPE_RAI_PRODUCT = "权益产品"
 
 	ROLE_TYPE_FICC_GROUP      = "ficc销售组长"
 	ROLE_TYPE_FICC_MANAGER    = "ficc销售主管"