Browse Source

Merge branch 'crm/crm_14.7' of http://8.136.199.33:3000/hongze/hz_crm_api

xingzai 1 year ago
parent
commit
752e6fcb9e

+ 10 - 0
controllers/company.go

@@ -3321,6 +3321,16 @@ func (this *CompanyController) Detail() {
 		if resp.IsContractButtonShow == false {
 			resp.IsContractButtonShow = services.CheckCompanyUserButton(sysUser.RoleTypeCode, item.SellerId, sysUser.AdminId, item.ProductId, shareSellerId, item.Status)
 		}
+
+		//校验当前操作员是否具给联系人开通个人研选的权限
+		if resp.IsUserYanXuanButtonShow == false {
+			resp.IsUserYanXuanButtonShow, err = services.CheckCompanyUserYanXuanButton(sysUser.RoleTypeCode, sysUser.Mobile)
+			if err != nil {
+				br.Msg = "获取失败"
+				br.ErrMsg = "获取专项调研信息失败,Err:" + err.Error()
+				return
+			}
+		}
 	}
 
 	if roleTypeCode == utils.ROLE_TYPE_CODE_ADMIN ||

+ 377 - 112
controllers/company_user.go

@@ -16,6 +16,7 @@ import (
 	"hongze/hz_crm_api/models/system"
 	"hongze/hz_crm_api/models/yb"
 	"hongze/hz_crm_api/services"
+	cygxService "hongze/hz_crm_api/services/cygx"
 	"hongze/hz_crm_api/services/elastic"
 	"hongze/hz_crm_api/utils"
 	"os"
@@ -484,7 +485,9 @@ func (this *CompanyUserController) AddUser() {
 			}
 		}
 	}
-	if req.BusinessCardUrl != "" && utils.RunMode == "release" {
+
+	//if req.BusinessCardUrl != "" && utils.RunMode == "release" {
+	if req.BusinessCardUrl != "" {
 		// 获取图片识别客户名称的配置
 		crmConfig, err := company.GetConfigDetailByCode("card_recognition_company_name")
 		if err != nil {
@@ -549,34 +552,39 @@ func (this *CompanyUserController) AddUser() {
 		//for _, v := range card.WordsResult {
 		//	mobileStr += v.Words + ","
 		//}
-		isFlag := true
+		isFlag := false
 		if len(card.WordsResult.MOBILE) > 0 {
 			mobileStr := strings.Join(card.WordsResult.MOBILE, ",")
-			if req.MobileOne != "" {
-				if strings.Contains(mobileStr, req.MobileOne) || mobileStr == "" {
-					isFlag = true
-				} else {
-					isFlag = false
-				}
+			//if req.MobileOne != "" {
+			//	if strings.Contains(mobileStr, req.MobileOne) || mobileStr == "" {
+			//		isFlag = true
+			//	} else {
+			//		isFlag = false
+			//	}
+			//}
+			//
+			//if isFlag == false && req.MobileTwo != "" {
+			//	if strings.Contains(mobileStr, req.MobileTwo) {
+			//		isFlag = true
+			//	} else {
+			//		isFlag = false
+			//	}
+			//}
+			if req.MobileOne != "" && strings.Contains(mobileStr, req.MobileOne) {
+				isFlag = true
 			}
-
-			if isFlag == false && req.MobileTwo != "" {
-				if strings.Contains(mobileStr, req.MobileTwo) {
-					isFlag = true
-				} else {
-					isFlag = false
-				}
+			if req.MobileTwo != "" && strings.Contains(mobileStr, req.MobileTwo) {
+				isFlag = true
 			}
 			//如果百度识别出来了客户名称,那么将识别出来的客户名称添加到待校验客户名称切片中
 			if len(card.WordsResult.COMPANY) > 0 && card.WordsResult.COMPANY[0] != "" {
 				companyNameSlice = card.WordsResult.COMPANY
 			}
 		}
-
 		//如果百度未识别出来手机号或者公司名称,那么进行阿里识别
 		if !isFlag || (len(companyNameSlice) == 0 && crmConfig.ConfigValue == "true") {
 			//阿里云识别
-			aliyunResult, err := services.AliyunBusinessCardOcr(req.BusinessCardUrl)
+			aliyunResult, errMsg, err := services.AliyunOcrBusinessCard(req.BusinessCardUrl)
 			if err != nil {
 				br.Msg = "识别失败"
 				br.ErrMsg = "识别失败,Err:" + err.Error()
@@ -587,6 +595,10 @@ func (this *CompanyUserController) AddUser() {
 				br.ErrMsg = "识别失败"
 				return
 			}
+			if errMsg != "" {
+				br.Msg = errMsg
+				return
+			}
 			//如果百度没有识别出来手机号,那么还需要阿里识别出来的手机号校验下
 			if !isFlag {
 				if len(aliyunResult.TelCell) > 0 {
@@ -609,7 +621,7 @@ func (this *CompanyUserController) AddUser() {
 		}
 
 		if !isFlag && crmConfig2.ConfigValue == "true" {
-			br.Msg = "名片手机号与所填手机号不匹配,请重新填写"
+			br.Msg = "名片信息与联系人手机号不符"
 			br.IsSendEmail = false
 			return
 		}
@@ -638,7 +650,7 @@ func (this *CompanyUserController) AddUser() {
 			}
 			//如果没有匹配到客户名称,那么就返回报错
 			if !isCompanyNameFlag {
-				br.Msg = "名片中客户名称不一致"
+				br.Msg = "名片信息与公司名称不符"
 				br.IsSendEmail = false
 				return
 			}
@@ -824,7 +836,6 @@ func (this *CompanyUserController) List() {
 		br.Ret = 408
 		return
 	}
-
 	pageSize, _ := this.GetInt("PageSize")
 	currentIndex, _ := this.GetInt("CurrentIndex")
 	companyId, _ := this.GetInt("CompanyId")
@@ -1210,7 +1221,7 @@ func (this *CompanyUserController) List() {
 				list[i].LastViewTimeStr = tmpLastViewTime.Format(utils.FormatDateTime)
 			}
 
-			if list[i].LastViewTime.Before(time.Now().AddDate(0,0,-7)) && list[i].IsFollow  == 1 {
+			if list[i].LastViewTime.Before(time.Now().AddDate(0, 0, -7)) && list[i].IsFollow == 1 {
 				list[i].NotRead = true
 			}
 
@@ -1236,9 +1247,47 @@ func (this *CompanyUserController) List() {
 					list[i].IsChartPermissionSetting = 1
 				}
 			}
+		}
+
+		isUserYanXuanButtonShow, err := services.CheckCompanyUserYanXuanButton(sysUser.RoleTypeCode, sysUser.Mobile)
+		if err != nil {
+			br.Msg = "获取失败"
+			br.ErrMsg = "获取专项调研信息失败,Err:" + err.Error()
+			return
+		}
+
+		if isUserYanXuanButtonShow {
+			userYanxuanPermissionMap := cygxService.GetCygxUserYanxuanPermissionMapItem(userIds) // 如果是权益部门下的人,则展示研选相关的信息
+			userInteractionNumMap := cygxService.GetUserInteractionNumMap(userIds)               // 如果是权益部门下的人,展示互动量相关的信息
 
-			// 分产品阅读统计
-			list[i].YbProductViewTotal = userYbViewsMap[int(list[i].UserId)]
+			mfyxuserRecordRegisterMap := make(map[int]string)
+			if len(userIdSlice) > 0 {
+				//用户绑定注册数据
+				mfyxuserRecordRegisterList, _ := models.GetUserRecordRegisterByUserIdsMyfx(userIdStr)
+				for _, userRecordRegister := range mfyxuserRecordRegisterList {
+					mfyxuserRecordRegisterMap[userRecordRegister.UserId] = userRecordRegister.CreateTime.Format(utils.FormatDateTime)
+				}
+			}
+			for i := 0; i < lenList; i++ {
+				item := list[i]
+				// 分产品阅读统计
+				list[i].YbProductViewTotal = userYbViewsMap[int(item.UserId)]
+				list[i].MfyxInteractionNum = userInteractionNumMap[int(item.UserId)]
+				//权益销售查看用户研选的信息
+				if userYanxuanPermissionMap[int(item.UserId)] != nil {
+					mfyxItem := userYanxuanPermissionMap[int(item.UserId)]
+					list[i].MfyxStatus = mfyxItem.Status
+					list[i].MfyxStartDate = mfyxItem.StartDate
+					list[i].MfyxEndDate = mfyxItem.EndDate
+				} else {
+					list[i].MfyxStatus = "未开通"
+				}
+				if mfyxuserRecordRegisterMap[int(item.UserId)] != "" {
+					list[i].MfyxIsBinding = true
+					list[i].MfyxBindingTime = mfyxuserRecordRegisterMap[int(item.UserId)]
+				}
+				list[i].LastViewTimeStr = list[i].RaiLastViewTime.Format(utils.FormatDateTime)
+			}
 		}
 	}
 
@@ -1895,7 +1944,17 @@ func (this *CompanyUserController) EditUser() {
 			}
 		}
 	}
-	if wxUser.BusinessCardUrl != req.BusinessCardUrl && utils.RunMode == "release" {
+	//if wxUser.BusinessCardUrl != req.BusinessCardUrl && utils.RunMode == "release" {
+
+	if wxUser.BusinessCardUrl != req.BusinessCardUrl {
+		// 获取图片识别客户名称的配置
+		crmConfig, err := company.GetConfigDetailByCode("card_recognition_company_name")
+		if err != nil {
+			br.Msg = "获取配置失败"
+			br.ErrMsg = "获取配置失败"
+			br.IsSendEmail = false
+			return
+		}
 		// 获取图片识别手机号的配置
 		crmConfig2, err := company.GetConfigDetailByCode("card_recognition_tel")
 		if err != nil {
@@ -1904,41 +1963,87 @@ func (this *CompanyUserController) EditUser() {
 			br.IsSendEmail = false
 			return
 		}
+
+		//companyName := wxUser.CompanyName
+		//if companyName == "" {
+		companyInfo, err := company.GetCompanyById(req.CompanyId)
+		if err != nil {
+			br.Msg = "查找客户失败"
+			br.ErrMsg = "查找客户失败,err:" + err.Error()
+			return
+		}
+		companyName := companyInfo.CompanyName
+		//}
+		companyName = utils.TrimStr(companyName)
+		tmpCompanyNameList, err := elastic.Analyze(companyName)
+		if err != nil {
+			br.Msg = "添加失败"
+			br.ErrMsg = "客户名称分词失败,Err:" + err.Error()
+			return
+		}
+		//公司名称切片
+		analyzeNameList := []string{companyName}
+		for _, v := range tmpCompanyNameList {
+			if v == "" {
+				continue
+			}
+			ignoreStrs := []string{"", "有限", "投资", "资本", "管理", "贸易", "资产", "公司", "股份", "集团", "有限公司"}
+			if !strings.Contains(strings.Join(ignoreStrs, ","), v) && utf8.RuneCount([]byte(v)) > 1 {
+				//不在上面的过滤字里面,且切出来的字符大于1位
+				analyzeNameList = append(analyzeNameList, v)
+			}
+		}
+
+		//名片识别出来的客户名称切片
+		companyNameSlice := make([]string, 0)
 		card, err := services.GetBusinessCard(req.BusinessCardUrl)
 		if err != nil {
 			br.Msg = "名片识别失败"
 			br.ErrMsg = "名片识别失败,Err:" + err.Error()
 			return
 		}
-		if card.Errno != 0 {
-			br.Msg = "您上传了非名片图片,请重新上传"
-			br.ErrMsg = "名片识别失败,ErrMsg:" + card.ErrorMsg + ";errCode:" + strconv.Itoa(card.Errno)
-			return
-		}
+		//if card.Errno != 0 {
+		//	br.Msg = "您上传了非名片图片,请重新上传"
+		//	br.ErrMsg = "名片识别失败,ErrMsg:" + card.ErrorMsg + ";errCode:" + strconv.Itoa(card.Errno)
+		//	return
+		//}
 		//var mobileStr string
 		//for _, v := range card.WordsResult {
 		//	mobileStr += v.Words + ","
 		//}
-		mobileStr := strings.Join(card.WordsResult.MOBILE, ",")
-		isFlag := true
-		if req.MobileOne != "" {
-			if strings.Contains(mobileStr, req.MobileOne) {
+		isFlag := false
+		if len(card.WordsResult.MOBILE) > 0 {
+			mobileStr := strings.Join(card.WordsResult.MOBILE, ",")
+			//if req.MobileOne != "" {
+			//	if strings.Contains(mobileStr, req.MobileOne) || mobileStr == "" {
+			//		isFlag = true
+			//	} else {
+			//		isFlag = false
+			//	}
+			//}
+			//
+			//if isFlag == false && req.MobileTwo != "" {
+			//	if strings.Contains(mobileStr, req.MobileTwo) {
+			//		isFlag = true
+			//	} else {
+			//		isFlag = false
+			//	}
+			//}
+			if req.MobileOne != "" && strings.Contains(mobileStr, req.MobileOne) {
 				isFlag = true
-			} else {
-				isFlag = false
 			}
-		}
-		if isFlag == false && req.MobileTwo != "" {
-			if strings.Contains(mobileStr, req.MobileTwo) {
+			if req.MobileTwo != "" && strings.Contains(mobileStr, req.MobileTwo) {
 				isFlag = true
-			} else {
-				isFlag = false
+			}
+			//如果百度识别出来了客户名称,那么将识别出来的客户名称添加到待校验客户名称切片中
+			if len(card.WordsResult.COMPANY) > 0 && card.WordsResult.COMPANY[0] != "" {
+				companyNameSlice = card.WordsResult.COMPANY
 			}
 		}
-
-		if !isFlag {
+		//如果百度未识别出来手机号或者公司名称,那么进行阿里识别
+		if !isFlag || (len(companyNameSlice) == 0 && crmConfig.ConfigValue == "true") {
 			//阿里云识别
-			aliyunResult, err := services.AliyunBusinessCardOcr(req.BusinessCardUrl)
+			aliyunResult, errMsg, err := services.AliyunOcrBusinessCard(req.BusinessCardUrl)
 			if err != nil {
 				br.Msg = "识别失败"
 				br.ErrMsg = "识别失败,Err:" + err.Error()
@@ -1949,21 +2054,66 @@ func (this *CompanyUserController) EditUser() {
 				br.ErrMsg = "识别失败"
 				return
 			}
-
-			mobileStr := strings.Join(aliyunResult.TelCell, ",")
-			if req.MobileOne != "" {
-				if strings.Contains(mobileStr, req.MobileOne) {
-					isFlag = true
+			if errMsg != "" {
+				br.Msg = errMsg
+				return
+			}
+			//如果百度没有识别出来手机号,那么还需要阿里识别出来的手机号校验下
+			if !isFlag {
+				if len(aliyunResult.TelCell) > 0 {
+					mobileStr := strings.Join(aliyunResult.TelCell, ",")
+					if req.MobileOne != "" {
+						if strings.Contains(mobileStr, req.MobileOne) {
+							isFlag = true
+						} else {
+							isFlag = false
+						}
+					}
 				} else {
-					isFlag = false
+					isFlag = true
 				}
 			}
+			//如果阿里云识别出来了客户名称,那么将识别出来的客户名称添加到待校验客户名称切片中
+			if len(aliyunResult.Company) > 0 {
+				companyNameSlice = append(companyNameSlice, aliyunResult.Company...)
+			}
 		}
 
 		if !isFlag && crmConfig2.ConfigValue == "true" {
-			br.Msg = "名片手机号与所填手机号不匹配,请重新填写"
+			br.Msg = "名片信息与联系人手机号不符"
+			br.IsSendEmail = false
 			return
 		}
+
+		//校验识别出来的名片名称与传入的客户名称是否一致
+		if len(companyNameSlice) > 0 && crmConfig.ConfigValue == "true" {
+			isCompanyNameFlag := false //是否成功匹配客户名称
+			//遍历识别出来的客户名称,然后与系统的客户名称做匹配(识别出来的名称包含系统名称的话,那么标记成功匹配)
+			for _, tmpCompanyName := range companyNameSlice {
+				//空串不处理
+				if companyName == "" {
+					continue
+				}
+				for _, analyzeName := range analyzeNameList {
+					//如果分词出来的公司名称正好在识别出来的公司名称里面,那么就认为校验通过了
+					if strings.Contains(tmpCompanyName, analyzeName) {
+						isCompanyNameFlag = true
+						break
+					}
+				}
+
+				if isCompanyNameFlag {
+					break
+				}
+
+			}
+			//如果没有匹配到客户名称,那么就返回报错
+			if !isCompanyNameFlag {
+				br.Msg = "名片信息与公司名称不符"
+				br.IsSendEmail = false
+				return
+			}
+		}
 	}
 
 	//UPDATE  wx_user
@@ -2449,48 +2599,55 @@ func (this *CompanyController) PotentialUserMove() {
 				br.ErrMsg = "名片识别失败,Err:" + err.Error()
 				return
 			}
-			isFlag := true
+			isFlag := false
 			if len(card.WordsResult.MOBILE) > 0 {
 				mobileStr := strings.Join(card.WordsResult.MOBILE, ",")
-				if req.Mobile != "" {
-					if strings.Contains(mobileStr, req.Mobile) || mobileStr == "" {
-						isFlag = true
-					} else {
-						isFlag = false
-					}
+				//if req.Mobile != "" {
+				//	if strings.Contains(mobileStr, req.Mobile) || mobileStr == "" {
+				//		isFlag = true
+				//	} else {
+				//		isFlag = false
+				//	}
+				//}
+				if req.Mobile != "" && strings.Contains(mobileStr, req.Mobile) {
+					isFlag = true
 				}
 			}
 			if !isFlag {
 				//阿里云识别
-				if utils.RunMode == "release" {
-					aliyunResult, err := services.AliyunBusinessCardOcr(req.BusinessCardUrl)
-					if err != nil {
-						br.Msg = "识别失败"
-						br.ErrMsg = "识别失败,Err:" + err.Error()
-						return
-					}
-					if !aliyunResult.Success {
-						br.Msg = "识别失败"
-						br.ErrMsg = "识别失败"
-						return
-					}
-					if len(aliyunResult.TelCell) > 0 {
-						mobileStr := strings.Join(aliyunResult.TelCell, ",")
-						if req.Mobile != "" {
-							if strings.Contains(mobileStr, req.Mobile) {
-								isFlag = true
-							} else {
-								isFlag = false
-							}
+				//if utils.RunMode == "release" {
+				aliyunResult, errMsg, err := services.AliyunOcrBusinessCard(req.BusinessCardUrl)
+				if err != nil {
+					br.Msg = "识别失败"
+					br.ErrMsg = "识别失败,Err:" + err.Error()
+					return
+				}
+				if !aliyunResult.Success {
+					br.Msg = "识别失败"
+					br.ErrMsg = "识别失败"
+					return
+				}
+				if errMsg != "" {
+					br.Msg = errMsg
+					return
+				}
+				if len(aliyunResult.TelCell) > 0 {
+					mobileStr := strings.Join(aliyunResult.TelCell, ",")
+					if req.Mobile != "" {
+						if strings.Contains(mobileStr, req.Mobile) {
+							isFlag = true
+						} else {
+							isFlag = false
 						}
-					} else {
-						isFlag = true
 					}
+				} else {
+					isFlag = true
 				}
+				//}
 			}
 
 			if !isFlag && crmConfig2.ConfigValue == "true" {
-				br.Msg = "名片手机号与所填手机号不匹配,请重新填写"
+				br.Msg = "名片信息与联系人手机号不符"
 				return
 			}
 		}
@@ -5034,48 +5191,57 @@ func (this *CompanyController) ApplyRecordPotentialUserMove() {
 				br.ErrMsg = "名片识别失败,Err:" + err.Error()
 				return
 			}
-			isFlag := true
+			isFlag := false
 			if len(card.WordsResult.MOBILE) > 0 {
 				mobileStr := strings.Join(card.WordsResult.MOBILE, ",")
-				if req.Mobile != "" {
-					if strings.Contains(mobileStr, req.Mobile) || mobileStr == "" {
-						isFlag = true
-					} else {
-						isFlag = false
-					}
+				//if req.Mobile != "" {
+				//	if strings.Contains(mobileStr, req.Mobile) || mobileStr == "" {
+				//		isFlag = true
+				//	} else {
+				//		isFlag = false
+				//	}
+				//}
+
+				if req.Mobile != "" && strings.Contains(mobileStr, req.Mobile) {
+					isFlag = true
 				}
 			}
+
 			if !isFlag {
 				//阿里云识别
-				if utils.RunMode == "release" {
-					aliyunResult, err := services.AliyunBusinessCardOcr(req.BusinessCardUrl)
-					if err != nil {
-						br.Msg = "识别失败"
-						br.ErrMsg = "识别失败,Err:" + err.Error()
-						return
-					}
-					if !aliyunResult.Success {
-						br.Msg = "识别失败"
-						br.ErrMsg = "识别失败"
-						return
-					}
-					if len(aliyunResult.TelCell) > 0 {
-						mobileStr := strings.Join(aliyunResult.TelCell, ",")
-						if req.Mobile != "" {
-							if strings.Contains(mobileStr, req.Mobile) {
-								isFlag = true
-							} else {
-								isFlag = false
-							}
+				//if utils.RunMode == "release" {
+				aliyunResult, errMsg, err := services.AliyunOcrBusinessCard(req.BusinessCardUrl)
+				if err != nil {
+					br.Msg = "识别失败"
+					br.ErrMsg = "识别失败,Err:" + err.Error()
+					return
+				}
+				if !aliyunResult.Success {
+					br.Msg = "识别失败"
+					br.ErrMsg = "识别失败"
+					return
+				}
+				if errMsg != "" {
+					br.Msg = errMsg
+					return
+				}
+				if len(aliyunResult.TelCell) > 0 {
+					mobileStr := strings.Join(aliyunResult.TelCell, ",")
+					if req.Mobile != "" {
+						if strings.Contains(mobileStr, req.Mobile) {
+							isFlag = true
+						} else {
+							isFlag = false
 						}
-					} else {
-						isFlag = true
 					}
+				} else {
+					isFlag = true
 				}
+				//}
 			}
 
 			if !isFlag && crmConfig2.ConfigValue == "true" {
-				br.Msg = "名片手机号与所填手机号不匹配,请重新填写"
+				br.Msg = "名片信息与联系人手机号不符"
 				return
 			}
 		}
@@ -5959,7 +6125,7 @@ func (this *CompanyUserController) Follow() {
 		br.ErrMsg = "参数解析失败,Err:" + err.Error()
 		return
 	}
-	if req.UserId <= 0  {
+	if req.UserId <= 0 {
 		br.Msg = "用户ID异常"
 		br.ErrMsg = "用户ID异常"
 		return
@@ -5989,4 +6155,103 @@ func (this *CompanyUserController) Follow() {
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "操作成功"
-}
+}
+
+// @Title 开通或者关闭用户研选权限
+// @Description 开通或者关闭用户研选权限
+// @Param	request	body request.ApplyMarkReq true "type json string"
+// @Success 200 {object} 操作成功
+// @router /update/user/yananxuan/permission [post]
+func (this *CompanyUserController) UpadteUserYanxuanPermission() {
+	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 cygx.UpdateUserYanxuanPermissionReq
+	err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
+	if err != nil {
+		br.Msg = "参数解析异常"
+		br.ErrMsg = "参数解析失败,Err:" + err.Error()
+		return
+	}
+	userId := req.UserId
+	if userId <= 0 {
+		br.Msg = "用户ID异常"
+		br.ErrMsg = "用户ID异常"
+		return
+	}
+
+	//获取联系人详情
+	userInfo, err := models.GetWxUserByUserId(req.UserId)
+	if err != nil {
+		br.Msg = "获取联系人异常!"
+		br.ErrMsg = "获取联系人异常,Err:" + err.Error()
+		return
+	}
+
+	if userInfo.BusinessCardUrl == "" {
+		br.Msg = "该联系人尚未添加名片,请点击编辑,上传名片后再开通试用"
+		return
+	}
+
+	companyInfo, err := company.GetCompanyById(userInfo.CompanyId)
+	if err != nil {
+		br.Msg = "查找客户失败"
+		br.ErrMsg = "查找客户失败,err:" + err.Error()
+		return
+	}
+
+	// 查询用户是否开通过
+	count, err := cygx.GetCygxUserYanxuanPermissionCountByUserId(userId)
+	if err != nil {
+		br.Msg = "操作失败! "
+		br.ErrMsg = "操作失败,Err:" + err.Error()
+		return
+	}
+
+	item := new(cygx.CygxUserYanxuanPermission)
+	if req.Type == 0 {
+		item.Status = "未开通"
+	} else {
+		item.Status = "试用"
+	}
+	item.UserId = userId
+	item.CompanyId = companyInfo.CompanyId
+	item.CompanyName = companyInfo.CompanyName
+	item.StartDate = time.Now().Format(utils.FormatDate)
+	item.EndDate = time.Now().AddDate(0, 2, 0).Format(utils.FormatDate) // 试用期两个月
+	item.Mobile = userInfo.Mobile
+	item.Email = userInfo.Email
+	item.RealName = userInfo.RealName
+	item.AdminId = sysUser.AdminId
+	item.AdminRealName = sysUser.RealName
+	item.CreatedTime = time.Now()
+	item.LastUpdatedTime = time.Now()
+	item.ModifyTime = time.Now()
+	if count == 0 {
+		_, err = cygx.AddCygxUserYanxuanPermission(item) // 添加
+	} else {
+		if req.Type == 0 {
+			err = cygx.UpdateCygxUserYanxuanPermissionClose(userId) // 关闭
+		} else {
+			err = cygx.UpdateCygxUserYanxuanPermissionOpen(item) // 开通
+		}
+	}
+	if err != nil {
+		br.Msg = "操作失败! "
+		br.ErrMsg = "操作失败,Err:" + err.Error()
+		return
+	}
+	go cygxService.AddCygxUserYanxuanPermissionLog(item)
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "操作成功"
+}

+ 9 - 8
models/company/company.go

@@ -585,14 +585,15 @@ type CompanyDetail struct {
 }
 
 type CompanyDetailResp struct {
-	Item                 *CompanyDetail        `description:"客户信息"`
-	FiccItem             *CompanyProductDetail `description:"Ficc客户产品详情"`
-	RaiItem              *CompanyProductDetail `description:"权益客户产品详情"`
-	CreateAuth           int                   `description:"创建人:1:ficc,2:权益"`
-	ProductName          string                `description:"部门名称:ficc/权益/admin"`
-	IsButtonShow         int                   `description:"1:显示编辑和删除按钮,0:不显示"`
-	IsContractButtonShow bool                  `description:"true:显示联系人操作按钮,新增、编辑、导入和删除按钮,false:不显示"`
-	BtnItem              *ButtonDetailPermission
+	Item                    *CompanyDetail        `description:"客户信息"`
+	FiccItem                *CompanyProductDetail `description:"Ficc客户产品详情"`
+	RaiItem                 *CompanyProductDetail `description:"权益客户产品详情"`
+	CreateAuth              int                   `description:"创建人:1:ficc,2:权益"`
+	ProductName             string                `description:"部门名称:ficc/权益/admin"`
+	IsButtonShow            int                   `description:"1:显示编辑和删除按钮,0:不显示"`
+	IsContractButtonShow    bool                  `description:"true:显示联系人操作按钮,新增、编辑、导入和删除按钮,false:不显示"`
+	IsUserYanXuanButtonShow bool                  `description:"true:显示联系人开通研选试用按钮,false:不显示"`
+	BtnItem                 *ButtonDetailPermission
 }
 
 // 客户权限列表

+ 6 - 0
models/company/company_user.go

@@ -69,6 +69,12 @@ type CompanyUser struct {
 	RaiViewTotal             int       `description:"权益报告的阅读次数" json:"-"`
 	RaiLastViewTime          time.Time `description:"权益报告的最近一次阅读时间" json:"-"`
 	NotRead                  bool      `description:"是否七天内未阅读"`
+	MfyxStartDate            string    `description:"买方研选权限开始日期"`
+	MfyxEndDate              string    `description:"买方研选权限结束日期"`
+	MfyxStatus               string    `description:"买方研选状态'试用','未开通'"`
+	MfyxInteractionNum       int       `description:"互动量"`
+	MfyxIsBinding            bool      `description:"买方研选是否绑定"`
+	MfyxBindingTime          string    `description:"买方研选绑定时间"`
 }
 
 type CompanyUserListResp struct {

+ 1 - 1
models/cygx/aliyun_ocr_log.go

@@ -12,7 +12,7 @@ type AliyunOcrImgUrlReq struct {
 type AliyunOcrLog struct {
 	Id         int       `orm:"column(id);pk"`
 	ImgUrl     string    `description:"图片地址"`
-	Result     string    `description:"手机号"`
+	Result     string    `description:"返回内容"`
 	CreateTime time.Time `description:"创建时间"`
 }
 

+ 117 - 0
models/cygx/user_yanxuan_permission.go

@@ -0,0 +1,117 @@
+package cygx
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type UpdateUserYanxuanPermissionReq struct {
+	UserId int `description:"用户ID"`
+	Type   int `description:"类型 0关闭 、1开通"`
+}
+
+type CygxUserYanxuanPermission struct {
+	UserYanxuanPermissionId int64     `orm:"column(user_yanxuan_permission_id);pk"`
+	UserId                  int       `description:"用户ID"`
+	CompanyId               int       `description:"权限开始日期"`
+	StartDate               string    `description:"权限开始日期"`
+	EndDate                 string    `description:"权限结束日期"`
+	Status                  string    `description:"'试用','未开通'"`
+	Mobile                  string    `description:"手机号"`
+	Email                   string    `description:"邮箱"`
+	RealName                string    `description:"用户实际名称"`
+	CompanyName             string    `description:"公司名称"`
+	AdminId                 int       `description:"后台添加人员ID"`
+	AdminRealName           string    `description:"后台添加人员姓名"`
+	CreatedTime             time.Time `description:"创建时间"`
+	LastUpdatedTime         time.Time `description:"修改时间根据时间戳自动更新"`
+	ModifyTime              time.Time `description:"修改时间"`
+}
+
+type CygxUserYanxuanPermissionLog struct {
+	UserYanxuanPermissionId int64     `orm:"column(user_yanxuan_permission_log_id);pk"`
+	UserId                  int       `description:"用户ID"`
+	CompanyId               int       `description:"权限开始日期"`
+	StartDate               string    `description:"权限开始日期"`
+	EndDate                 string    `description:"权限结束日期"`
+	Status                  string    `description:"'试用','未开通'"`
+	Mobile                  string    `description:"手机号"`
+	Email                   string    `description:"邮箱"`
+	RealName                string    `description:"用户实际名称"`
+	CompanyName             string    `description:"公司名称"`
+	AdminId                 int       `description:"后台添加人员ID"`
+	AdminRealName           string    `description:"后台添加人员姓名"`
+	CreatedTime             time.Time `description:"创建时间"`
+	LastUpdatedTime         time.Time `description:"修改时间根据时间戳自动更新"`
+	ModifyTime              time.Time `description:"修改时间"`
+}
+
+// 添加
+func AddCygxUserYanxuanPermission(item *CygxUserYanxuanPermission) (lastId int64, err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	lastId, err = o.Insert(item)
+	return
+}
+
+// 添加日志记录
+func AddCygxUserYanxuanPermissionLog(item *CygxUserYanxuanPermissionLog) (lastId int64, err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	lastId, err = o.Insert(item)
+	return
+}
+
+// 根据用户ID获取是否开通过研选权限
+func GetCygxUserYanxuanPermissionCountByUserId(userId int) (count int, err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	sql := ` SELECT COUNT(1) FROM cygx_user_yanxuan_permission WHERE user_id = ?  `
+	err = o.Raw(sql, userId).QueryRow(&count)
+	return
+}
+
+// 将研选权限状态改为未开通
+func UpdateCygxUserYanxuanPermissionClose(userId int) (err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	sql := ` UPDATE cygx_user_yanxuan_permission
+			SET
+			  status ='未开通',
+			  modify_time = ?
+			WHERE user_id = ? `
+	_, err = o.Raw(sql, time.Now(), userId).Exec()
+	return
+}
+
+// 将研选权限状态改为未开通
+func UpdateCygxUserYanxuanPermissionOpen(item *CygxUserYanxuanPermission) (err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	updateParams := make(map[string]interface{})
+	updateParams["CompanyId"] = item.CompanyId
+	updateParams["StartDate"] = item.StartDate
+	updateParams["EndDate"] = item.EndDate
+	updateParams["Status"] = item.Status
+	updateParams["Mobile"] = item.Mobile
+	updateParams["Email"] = item.Email
+	updateParams["RealName"] = item.RealName
+	updateParams["CompanyName"] = item.CompanyName
+	updateParams["AdminId"] = item.AdminId
+	updateParams["AdminRealName"] = item.AdminRealName
+	ptrStructOrTableName := "cygx_user_yanxuan_permission"
+	whereParam := map[string]interface{}{"user_id": item.UserId}
+	qs := o.QueryTable(ptrStructOrTableName)
+	for expr, exprV := range whereParam {
+		qs = qs.Filter(expr, exprV)
+	}
+	_, err = qs.Update(updateParams)
+	return
+}
+
+// 列表
+func GetCygxUserYanxuanPermissionList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxUserYanxuanPermission, err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	sql := `SELECT * FROM cygx_user_yanxuan_permission WHERE 1= 1 `
+	if condition != "" {
+		sql += condition
+	}
+	sql += ` LIMIT ?,?  `
+	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
+	return
+}

+ 2 - 0
models/db.go

@@ -466,6 +466,8 @@ func initCygx() {
 		new(cygx.CygxAskserieVideo),
 		new(cygx.CygxIndustrialAskserieVideoGroupManagement),
 		new(cygx.CygxActivitySpecialPermissionPoints),
+		new(cygx.CygxUserYanxuanPermission),
+		new(cygx.CygxUserYanxuanPermissionLog),
 	)
 }
 

+ 17 - 9
models/user_record.go

@@ -24,28 +24,28 @@ type UserRecord struct {
 	UserId         int       `description:"用户id"`
 }
 
-//根据openid获取用户关系
+// 根据openid获取用户关系
 func GetUserRecordByOpenId(openId string) (item *UserRecord, err error) {
 	sql := `SELECT * FROM user_record WHERE open_id=? `
 	err = orm.NewOrm().Raw(sql, openId).QueryRow(&item)
 	return
 }
 
-//根据用户id和平台id获取用户关系
+// 根据用户id和平台id获取用户关系
 func GetUserRecordByUserId(userId, platform int) (item *UserRecord, err error) {
 	sql := `SELECT * FROM user_record WHERE user_id=? AND create_platform = ?`
 	err = orm.NewOrm().Raw(sql, userId, platform).QueryRow(&item)
 	return
 }
 
-//添加用户关系
+// 添加用户关系
 func AddUserRecord(record *UserRecord) (recordId int64, err error) {
 	o := orm.NewOrm()
 	recordId, err = o.Insert(record)
 	return
 }
 
-//根据openid绑定用户关系
+// 根据openid绑定用户关系
 func BindUserRecordByOpenid(userId int, openId, bindAccount string) (err error) {
 	o := orm.NewOrm()
 	msql := " UPDATE user_record SET user_id = ?,bind_account=? WHERE open_id = ? "
@@ -53,7 +53,7 @@ func BindUserRecordByOpenid(userId int, openId, bindAccount string) (err error)
 	return
 }
 
-//修改用户微信信息
+// 修改用户微信信息
 func ModifyUserRecordInfo(openId, nickName, headimgUrl, city, province, country string, sex, userId int) (err error) {
 	o := orm.NewOrm()
 	sql := `UPDATE user_record SET nick_name=?,headimgurl=?,sex=?,city=?,province=?,country=? WHERE user_id=? and openid=? `
@@ -61,7 +61,7 @@ func ModifyUserRecordInfo(openId, nickName, headimgUrl, city, province, country
 	return
 }
 
-//根据用户id删除该用户的所有关联关系
+// 根据用户id删除该用户的所有关联关系
 func DelUserRecordByUserId(userId int) (err error) {
 	o := orm.NewOrm()
 	sql := ` DELETE FROM user_record WHERE user_id=? `
@@ -77,7 +77,7 @@ func GetUserRecordListByUserIds(userIds string) (items []*UserRecord, err error)
 	return
 }
 
-//根据用户id字符串批量删除该用户的所有关联关系
+// 根据用户id字符串批量删除该用户的所有关联关系
 func DelUserRecordByUserIds(userIds string) (err error) {
 	o := orm.NewOrm()
 	sql := ` DELETE FROM user_record WHERE user_id in (` + userIds + `) `
@@ -85,16 +85,24 @@ func DelUserRecordByUserIds(userIds string) (err error) {
 	return
 }
 
-//根据用户id字符串获取用户绑定时间结构体
+// 根据用户id字符串获取用户绑定时间结构体
 type UserRecordRegisterSlice struct {
 	UserId     int       `description:"用户id"`
 	CreateTime time.Time `description:"用户第三方信息绑定注册时间"`
 }
 
-//根据用户id字符串获取用户绑定时间
+// 根据用户id字符串获取用户绑定时间
 func GetUserRecordRegisterByUserIds(userIds string) (items []*UserRecordRegisterSlice, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT user_id,min(create_time) as create_time FROM user_record WHERE user_id in (` + userIds + `) group by user_id`
 	_, err = o.Raw(sql).QueryRows(&items)
 	return
 }
+
+// 根据用户id字符串获取用户绑定时间 (查研观向与买方研选小程序)
+func GetUserRecordRegisterByUserIdsMyfx(userIds string) (items []*UserRecordRegisterSlice, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT user_id,min(create_time) as create_time FROM user_record WHERE user_id in (` + userIds + `) AND  create_platform IN  (4,10)  group by user_id`
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}

+ 9 - 0
routers/commentsRouter.go

@@ -9790,6 +9790,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hz_crm_api/controllers:CompanyUserController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers:CompanyUserController"],
+        beego.ControllerComments{
+            Method: "UpadteUserYanxuanPermission",
+            Router: `/update/user/yananxuan/permission`,
+            AllowHTTPMethods: []string{"post"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hz_crm_api/controllers:CompanyUserController"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers:CompanyUserController"],
         beego.ControllerComments{
             Method: "AddUser",

+ 89 - 2
services/aliyun.go

@@ -9,12 +9,14 @@ import (
 	ocr20191230 "github.com/alibabacloud-go/ocr-20191230/v3/client"
 	util "github.com/alibabacloud-go/tea-utils/v2/service"
 	"github.com/alibabacloud-go/tea/tea"
+	rhttp "github.com/rdlucklib/rdluck_tools/http"
+	"hongze/hz_crm_api/models/cygx"
 	"hongze/hz_crm_api/utils"
+	"io"
 	"io/ioutil"
 	"net/http"
 	"strings"
-
-	rhttp "github.com/rdlucklib/rdluck_tools/http"
+	"time"
 )
 
 const (
@@ -23,6 +25,11 @@ const (
 	AlAppCode   = "22553c4ba74545568aba70ac6cfd441d"
 )
 
+var (
+	//文档 https://market.aliyun.com/apimarket/detail/cmapi013591?spm=5176.product-detail.detail.4.6d4f3dcaS0qPFI&endpoint=a3dd145f3865492ba6f02d0c09dd00a1
+	AliyunOcrBusinessCardCode = "22553c4ba74545568aba70ac6cfd441d" // 阿里云OCR名片识别的code
+)
+
 type OcrItem struct {
 	Image string `json:"image"`
 }
@@ -157,3 +164,83 @@ func AliyunBusinessCardOcr(imgUrl string) (result OcrResult, err error) {
 
 	return
 }
+
+// 阿里云名片识别返回类
+type OcrBusinessCardResult struct {
+	TelCell    []string `json:"tel_cell"`
+	Success    bool     `json:"success"`
+	Name       string   `json:"name"`
+	Company    []string `json:"company"`
+	Addr       []string `json:"addr"`
+	Department []string `json:"department"`
+	Title      []string `json:"title"`
+	RequestID  string   `json:"request_id"`
+	Email      []string `json:"email"`
+	TelWork    []string `json:"tel_work"`
+}
+
+// 阿里云名片识别更换2024-01-02
+func AliyunOcrBusinessCard(imageurl string) (result *OcrBusinessCardResult, errMsg string, err error) {
+	url := "https://bizcard.market.alicloudapi.com/rest/160601/ocr/ocr_business_card.json"
+	method := "POST"
+
+	payload := strings.NewReader(`{
+    "image":"` + imageurl + `"
+}`)
+	client := &http.Client{}
+	req, err := http.NewRequest(method, url, payload)
+
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+	req.Header.Add("Authorization", "APPCODE "+AliyunOcrBusinessCardCode)
+	req.Header.Add("Content-Type", "application/json")
+
+	res, err := client.Do(req)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+	defer res.Body.Close()
+
+	body, err := io.ReadAll(res.Body)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+	err = json.Unmarshal(body, &result)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+
+	//处理返回的手机号格式,并进行数据合并
+	var telCell []string
+	if len(result.TelCell) > 0 {
+		for _, v := range result.TelCell {
+			telCell = append(telCell, utils.GetArabicNumbers(v))
+		}
+	}
+	if len(result.TelWork) > 0 {
+		for _, v := range result.TelWork {
+			telCell = append(telCell, utils.GetArabicNumbers(v))
+		}
+	}
+	result.TelCell = telCell
+
+	if len(result.Company) == 0 && len(result.TelCell) == 0 {
+		errMsg = "OCR识别失败"
+	} else if len(result.Company) == 0 {
+		errMsg = "名片中未识别到公司名称"
+	} else if len(result.TelCell) == 0 {
+		errMsg = " 名片中未识别到手机号"
+	}
+
+	logItem := new(cygx.AliyunOcrLog)
+	logItem.ImgUrl = imageurl
+	logItem.Result = string(body)
+	logItem.CreateTime = time.Now()
+	err = cygx.AddAliyunOcrLog(logItem)
+	return
+}

+ 21 - 0
services/company.go

@@ -1651,6 +1651,27 @@ func CheckCompanyUserButton(roleTypeCode string, itemSellerId, sysUserId, produc
 	return
 }
 
+// 校验当前操作员是否具给联系人开通个人研选的权限
+func CheckCompanyUserYanXuanButton(roleTypeCode string, adminMobile string) (ok bool, err error) {
+	if roleTypeCode == utils.ROLE_TYPE_CODE_RAI_ADMIN || roleTypeCode == utils.ROLE_TYPE_CODE_RAI_SELLER || roleTypeCode == utils.ROLE_TYPE_CODE_RAI_GROUP {
+		ok = true
+		return
+	}
+	crmConfig, err := company.GetConfigDetailByCode("rai_wx_user_yanxuan_button")
+	if err != nil {
+		return
+	}
+
+	sliceMobile := strings.Split(crmConfig.ConfigValue, ",")
+	for _, v := range sliceMobile {
+		if v == adminMobile {
+			ok = true
+			return
+		}
+	}
+	return
+}
+
 // GenerateOpenCompanyCode 生成第三方code编号
 func GenerateOpenCompanyCode(companyId int) (openCode string) {
 	openCode = utils.MD5(fmt.Sprint(companyId, "hzyj20210902"))

+ 32 - 0
services/cygx/user_label.go

@@ -7,6 +7,8 @@ import (
 	"hongze/hz_crm_api/models/cygx"
 	"hongze/hz_crm_api/services/alarm_msg"
 	"hongze/hz_crm_api/utils"
+	"strconv"
+	"strings"
 	"time"
 )
 
@@ -238,3 +240,33 @@ func IndustryFllowUserLabelLogAdd(industrialManagementId, count, uid int) (err e
 	}
 	return
 }
+
+// GetUserInteractionNumMap 根据用户ID 获取对应的用户互动量
+func GetUserInteractionNumMap(userIds []int) (mapResp map[int]int) {
+	lenArr := len(userIds)
+	if lenArr == 0 {
+		return
+	}
+	var err error
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			go alarm_msg.SendAlarmMsg(fmt.Sprint("GetUserInteractionNumMap 根据用户ID 获取对应的用户互动量 失败 userIds", userIds, err.Error()), 2)
+		}
+	}()
+	var userIdsArr []string
+	for _, v := range userIds {
+		userIdsArr = append(userIdsArr, strconv.Itoa(v))
+	}
+	userIdstr := strings.Join(userIdsArr, ",")
+	list, e := cygx.GetCygxCompanyUserListSplit(userIdstr)
+	if e != nil {
+		err = errors.New("GetCygxCompanyUserListSplit, Err: " + e.Error())
+		return
+	}
+	mapResp = make(map[int]int, 0)
+	for k, v := range list {
+		mapResp[int(v.UserId)] = list[k].HistoryNum + list[k].CountNum + list[k].IndustryFllowNum + list[k].DepartmentFollowNum + list[k].KeyWordNum + list[k].OnLineNum + list[k].OfficeNum + list[k].ChartNum + list[k].TripNum + list[k].RoadshowVideoNum + list[k].ActivityVideoNum + list[k].ActivityVoiceNum + list[k].YanxuanspecialNum
+	}
+	return
+}

+ 72 - 0
services/cygx/user_yanxuan_permission.go

@@ -0,0 +1,72 @@
+package cygx
+
+import (
+	"errors"
+	"fmt"
+	"hongze/hz_crm_api/models/cygx"
+	"hongze/hz_crm_api/services/alarm_msg"
+	"hongze/hz_crm_api/utils"
+	"time"
+)
+
+// 添加更新日志记录
+func AddCygxUserYanxuanPermissionLog(item *cygx.CygxUserYanxuanPermission) {
+	var err error
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			go alarm_msg.SendAlarmMsg(fmt.Sprint(item, err.Error()), 2)
+		}
+	}()
+
+	itemLog := new(cygx.CygxUserYanxuanPermissionLog)
+	itemLog.Status = item.Status
+	itemLog.UserId = item.UserId
+	itemLog.CompanyId = item.CompanyId
+	itemLog.CompanyName = item.CompanyName
+	itemLog.StartDate = item.StartDate
+	itemLog.EndDate = item.EndDate
+	itemLog.Mobile = item.Mobile
+	itemLog.Email = item.Email
+	itemLog.RealName = item.RealName
+	itemLog.AdminId = item.AdminId
+	itemLog.AdminRealName = item.AdminRealName
+	itemLog.CreatedTime = time.Now()
+	itemLog.LastUpdatedTime = time.Now()
+	itemLog.ModifyTime = time.Now()
+	_, e := cygx.AddCygxUserYanxuanPermissionLog(itemLog)
+	if e != nil {
+		err = errors.New("AddCygxUserYanxuanPermissionLog, Err: " + e.Error())
+		return
+	}
+	return
+}
+
+// GetCygxUserYanxuanPermissionItem 根据用户ID 获取对应的研选权限信息
+func GetCygxUserYanxuanPermissionMapItem(userIds []int) (mapResp map[int]*cygx.CygxUserYanxuanPermission) {
+	lenArr := len(userIds)
+	if lenArr == 0 {
+		return
+	}
+	var err error
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			go alarm_msg.SendAlarmMsg(fmt.Sprint("userIds", userIds, err.Error()), 2)
+		}
+	}()
+	var condition string
+	var pars []interface{}
+	condition += "  AND	status = '试用' AND user_id IN(" + utils.GetOrmInReplace(lenArr) + ") "
+	pars = append(pars, userIds)
+	list, e := cygx.GetCygxUserYanxuanPermissionList(condition, pars, 0, lenArr)
+	if e != nil {
+		err = errors.New("GetCygxUserYanxuanPermissionList, Err: " + e.Error())
+		return
+	}
+	mapResp = make(map[int]*cygx.CygxUserYanxuanPermission, 0)
+	for _, v := range list {
+		mapResp[v.UserId] = v
+	}
+	return
+}

+ 12 - 0
utils/common.go

@@ -28,6 +28,7 @@ import (
 	"strconv"
 	"strings"
 	"time"
+	"unicode"
 )
 
 // 随机数种子
@@ -2169,3 +2170,14 @@ func GetHtmlContentText(content string) (contentSub string, err error) {
 	contentSub = body
 	return
 }
+
+// 获取字符串中的阿拉伯数字,并返回字符串
+func GetArabicNumbers(str string) string {
+	var numbers []rune
+	for _, char := range str {
+		if unicode.IsDigit(char) {
+			numbers = append(numbers, char)
+		}
+	}
+	return string(numbers)
+}

+ 1 - 0
utils/constants.go

@@ -157,6 +157,7 @@ const (
 	COMPANY_PRODUCT_FICC_NAME = "ficc"
 	COMPANY_PRODUCT_RAI_ID    = 2
 	COMPANY_PRODUCT_RAI_NAME  = "权益"
+	RAI_DEPARTMENT_ID         = 5 // 权益部门ID
 )
 
 var PermissionFiccClassifyArr = [...]string{"宏观经济", "化工产业", "建材产业", "有色产业", "新能源", "市场策略"}