Browse Source

Merge branch 'cygx/cygx_14.0' of http://8.136.199.33:3000/hongze/hz_crm_api into debug

zhangchuanxing 4 months ago
parent
commit
b1da4bed8c

+ 21 - 0
controllers/roadshow/calendar.go

@@ -612,6 +612,25 @@ func (this *CalendarController) Edit() {
 
 	calendarUpdateParams["modify_time"] = time.Now()
 	calendarUpdateParams["title"] = getTitle(req.ActivityType, req.RoadshowType, req.ActivityCategory, req.RoadshowPlatform, req.Province, req.City)
+
+	//如果是权益客户,添加销售跟共享销售的信息
+	roleTypeCode := sysUser.RoleTypeCode
+	//如果是权益销售、权益销售组长、权益管理员 添加的路演信息,做销售与共享销售信息关联查看
+	if req.CompanyId > 0 && req.ActivityType == "路演" && (roleTypeCode == utils.ROLE_TYPE_CODE_RAI_SELLER ||
+		roleTypeCode == utils.ROLE_TYPE_CODE_RAI_GROUP || roleTypeCode == utils.ROLE_TYPE_CODE_RAI_ADMIN) {
+		var productItemRai *company.CompanyProduct
+		productItemRai, err = company.GetCompanyProductByCompanyIdAndProductId(req.CompanyId, utils.COMPANY_PRODUCT_RAI_ID)
+		if err != nil && err.Error() != utils.ErrNoRow() {
+			br.Msg = "客户信息有误"
+			br.ErrMsg = "获取客户信息失败, Err: " + err.Error()
+			return
+		}
+		if productItemRai != nil {
+			calendarUpdateParams["seller_id"] = productItemRai.SellerId
+			calendarUpdateParams["share_seller_id"] = productItemRai.ShareSellerId
+		}
+	}
+
 	err = roadshow.UpdateRsCalendar(calendarWhereParams, calendarUpdateParams)
 	if err != nil {
 		br.Msg = "保存失败!"
@@ -708,6 +727,7 @@ func (this *CalendarController) Edit() {
 			calendar := roadshow.RsCalendar{
 				RsCalendarId: req.RsCalendarId,
 				SysUserId:    this.SysUser.AdminId,
+				CompanyName:  req.CompanyName,
 				Title:        getTitle(req.ActivityType, req.RoadshowType, req.ActivityCategory, req.RoadshowPlatform, req.Province, req.City),
 			}
 			researcher := *rsCalendarResearcherItem
@@ -717,6 +737,7 @@ func (this *CalendarController) Edit() {
 			researcher.EndTime = v.EndTime
 			researcher.StartWeek = v.StartWeek
 			researcher.EndWeek = v.EndWeek
+			roadshowService.DeleteSHCalendar(req.RsCalendarResearcherId) //删除老的
 			go roadshowService.CalendarToSH(calendar, researcher)
 
 			if req.EditType == 2 {

+ 2 - 1
models/cygx/cygx_user_record.go

@@ -113,7 +113,7 @@ func GetCygxUserFllowOpenid(articleId int) (items []*OpenIdList, err error) {
 			INNER JOIN cygx_user_record AS cr ON cr.cygx_user_id = s.user_id 
 			INNER JOIN cygx_industrial_article_group_management as mg  ON mg.industrial_management_id = f.industrial_management_id
 		WHERE 1=1 
-			AND mg.article_id  = ?`
+			AND mg.article_id  = ?   AND f.follow_type = 1 `
 	_, err = o.Raw(sql, articleId).QueryRows(&items)
 	return
 }
@@ -183,6 +183,7 @@ func GetCygxUserFllowCeLueOpenid(categoryId int) (items []*OpenIdList, err error
 			AND s.is_refuse = 0 
 			AND s.is_subjective = 1 
 			AND s.is_objective = 1 
+			AND f.follow_type = 1 
 			AND f.category_id = ?`
 	_, err = o.Raw(sql, categoryId).QueryRows(&items)
 	return

+ 1 - 1
models/cygx/report_mapping_cygx.go

@@ -36,7 +36,7 @@ type CygxReportMappingCygxAdd struct {
 // 列表
 func GetCygxReportMappingCygxList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxReportMappingCygx, err error) {
 	o := orm.NewOrmUsingDB("hz_cygx")
-	sql := `SELECT * FROM cygx_report_mapping_cygx as art WHERE 1= 1 `
+	sql := `SELECT * FROM   as art WHERE 1= 1 `
 	if condition != "" {
 		sql += condition
 	}

+ 25 - 0
services/cygx/acitvity.go

@@ -1183,6 +1183,31 @@ func DoActivityOnenIdWxTemplateMsg(activityId int) (err error) {
 		mapOpenidRefuset[v.UserId] = v.OpenId
 	}
 
+	if len(industrialList) > 0 {
+		var industrialIds []int
+		for _, v := range industrialList {
+			industrialIds = append(industrialIds, v.IndustrialManagementId)
+		}
+		var conditionFollow string
+		var parsFollow []interface{}
+		//根据产业关注ID,获取用户不感兴趣的产业信息
+		conditionFollow = " AND  industrial_management_id IN (" + utils.GetOrmInReplace(len(industrialIds)) + ")  AND follow_type = 3  "
+		parsFollow = append(parsFollow, industrialIds)
+		userFllowListUninterested, e := cygx.GetCygxIndustryFllowList(conditionFollow, parsFollow, 0, 0)
+		if e != nil {
+			err = errors.New("GetCygxIndustryFllowList, Err: " + e.Error())
+			return
+		}
+		var userFllowNum = make(map[int]int)
+		for _, v := range userFllowListUninterested {
+			userFllowNum[v.UserId]++
+			//如果活动对应的产业数量,跟用户不感兴趣的产业数量一致,就不做推送
+			if userFllowNum[v.UserId] == len(industrialList) {
+				mapOpenidRefuset[v.UserId] = "_"
+			}
+		}
+	}
+
 	var condition string
 
 	//如果活动选择了仅有决策人可见则做以下处理

+ 25 - 0
services/cygx/research_summary.go

@@ -317,6 +317,31 @@ func DoArticleOnenIdWxTemplateMsg(articleId int, source int) (err error) {
 		mapOpenidRefuset[v.UserId] = v.OpenId
 	}
 
+	if len(detailIndustryNameList) > 0 {
+		var industrialIds []int
+		for _, v := range detailIndustryNameList {
+			industrialIds = append(industrialIds, v.IndustrialManagementId)
+		}
+		var conditionFollow string
+		var parsFollow []interface{}
+		//根据产业关注ID,获取用户不感兴趣的产业信息
+		conditionFollow = " AND  industrial_management_id IN (" + utils.GetOrmInReplace(len(industrialIds)) + ")  AND follow_type = 3  "
+		parsFollow = append(parsFollow, industrialIds)
+		userFllowListUninterested, e := cygx.GetCygxIndustryFllowList(conditionFollow, parsFollow, 0, 0)
+		if e != nil {
+			err = errors.New("GetCygxIndustryFllowList, Err: " + e.Error())
+			return
+		}
+		var userFllowNum = make(map[int]int)
+		for _, v := range userFllowListUninterested {
+			userFllowNum[v.UserId]++
+			//如果活动对应的产业数量,跟用户不感兴趣的产业数量一致,就不做推送
+			if userFllowNum[v.UserId] == len(detailIndustryNameList) {
+				mapOpenidRefuset[v.UserId] = "_"
+			}
+		}
+	}
+
 	//获取提交过推送规则的用户的 openid
 	mapUserIdChooseSend := make(map[int]int)
 	chooseSendtList, err := cygx.GetCygxXzsChooseSend("")