|
@@ -402,6 +402,96 @@ func GetUserType(companyId int) (userType int, permissionStrnew string, err erro
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+func GetUserTypeZhengShi(companyId int) (userType int, permissionStrnew, permissionStrZhengShinew string, err error) {
|
|
|
+ var permissionStr, permissionZhengShiStr string
|
|
|
+ if companyId <= 1 {
|
|
|
+ userType = 0
|
|
|
+ } else {
|
|
|
+ total, errs := models.GetCountCompanyDetailByIdGroup(companyId)
|
|
|
+ if errs != nil {
|
|
|
+ err = errs
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if total == 0 {
|
|
|
+ userType = 0
|
|
|
+ } else {
|
|
|
+ companyDetail, errs := models.GetCompanyDetailByIdGroup(companyId)
|
|
|
+ if errs != nil {
|
|
|
+ err = errs
|
|
|
+ return
|
|
|
+ }
|
|
|
+ permissionStr, errs = models.GetCompanyPermission(companyId)
|
|
|
+ if errs != nil {
|
|
|
+ err = errs
|
|
|
+ return
|
|
|
+ }
|
|
|
+ permissionStrnew = permissionStr
|
|
|
+ //大套餐客户,数据库添加标识,
|
|
|
+ companyUserTypeDetail, errs := models.GetCygxCompanyUserType(companyId)
|
|
|
+ if errs != nil && errs.Error() != utils.ErrNoRow() {
|
|
|
+ err = errs
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if companyUserTypeDetail != nil {
|
|
|
+ if companyUserTypeDetail.CustomerTypeId != 0 {
|
|
|
+ userType = companyUserTypeDetail.CustomerTypeId
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ permissionZhengShiStr, errs = models.GetCompanyPermissionByUserZhengShi(companyId)
|
|
|
+ if errs != nil {
|
|
|
+ err = errs
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //1、永续客户 //2、大套餐客户(4个行业全开通的正式客户) //3、分行业套餐客户(开通对应行业的正式客户) //4、仅开通专家套餐的正式客户 //5、开通对应行业套餐或专家套餐的试用客户、 10: 30W套餐客户
|
|
|
+ //大套餐客户定义:医药、消费、科技、智造、策略。5个行业中任意4个及以上是正式权限的,属于大套餐客户(医药、消费、科技、智造需要主客观都开)
|
|
|
+ if companyDetail.Status == "永续" {
|
|
|
+ userType = 1
|
|
|
+ } else if companyDetail.Status == "试用" {
|
|
|
+ userType = 5
|
|
|
+ } else if companyDetail.Status == "冻结" {
|
|
|
+ userType = 6
|
|
|
+ } else if companyDetail.Status == "流失" {
|
|
|
+ userType = 7
|
|
|
+ }
|
|
|
+ //大套餐客户定义:医药、消费、科技、智造、策略。5个行业中任意4个及以上是正式权限的,属于大套餐客户(医药、消费、科技、智造需要主客观都开)
|
|
|
+ if userType == 0 && companyDetail.Status == "正式" {
|
|
|
+ var permissionZhegnshiNum int
|
|
|
+ if strings.Count(permissionZhengShiStr, "医药") == 2 {
|
|
|
+ permissionZhegnshiNum++
|
|
|
+ }
|
|
|
+ if strings.Count(permissionZhengShiStr, "消费") == 2 {
|
|
|
+ permissionZhegnshiNum++
|
|
|
+ }
|
|
|
+ if strings.Count(permissionZhengShiStr, "科技") == 2 {
|
|
|
+ permissionZhegnshiNum++
|
|
|
+ }
|
|
|
+ if strings.Count(permissionZhengShiStr, "智造") == 2 {
|
|
|
+ permissionZhegnshiNum++
|
|
|
+ }
|
|
|
+ if strings.Count(permissionZhengShiStr, "策略") == 1 {
|
|
|
+ permissionZhegnshiNum++
|
|
|
+ }
|
|
|
+ if strings.Count(permissionZhengShiStr, "路演服务") == 1 {
|
|
|
+ permissionZhegnshiNum++
|
|
|
+ }
|
|
|
+ //if permissionZhegnshiNum == 6 {
|
|
|
+ // userType = 2
|
|
|
+ //} else
|
|
|
+ //大套餐客户,数据库添加标识,条件大于等于四的都是 30W套餐客户
|
|
|
+ if permissionZhegnshiNum >= 4 {
|
|
|
+ userType = 10
|
|
|
+ } else {
|
|
|
+ userType = 3
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ permissionStrnew = permissionStr
|
|
|
+ permissionStrZhengShinew = permissionZhengShiStr
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
// GetSpecialDetailUserPower 处理用户查看详情的权限
|
|
|
func GetActivityDetailUserPower(user *models.WxUserItem, activityInfo *models.ActivityDetail) (havePower bool, err error) {
|
|
|
var companyDetailStatus string
|
|
@@ -411,7 +501,7 @@ func GetActivityDetailUserPower(user *models.WxUserItem, activityInfo *models.Ac
|
|
|
havePower = true
|
|
|
return
|
|
|
}
|
|
|
- userType, permissionStr, e := GetUserType(user.CompanyId)
|
|
|
+ userType, permissionStr, permissionStrZhengShi, e := GetUserTypeZhengShi(user.CompanyId)
|
|
|
if e != nil {
|
|
|
err = errors.New("GetCompanyPermissionUpgrade, Err: " + e.Error())
|
|
|
return
|
|
@@ -419,6 +509,11 @@ func GetActivityDetailUserPower(user *models.WxUserItem, activityInfo *models.Ac
|
|
|
if permissionStr == "" {
|
|
|
return
|
|
|
}
|
|
|
+ //如果是易董的活动且属于研选类型,只要开通任何权限就可以查看详情
|
|
|
+ if activityInfo.YidongActivityId != "" && permissionStr != "" && strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
|
|
|
+ havePower = true
|
|
|
+ return
|
|
|
+ }
|
|
|
if activityInfo.LimitPeopleNum > 0 {
|
|
|
mapUserType, e := GetActivityCcustomerTypeList()
|
|
|
if e != nil {
|
|
@@ -433,6 +528,11 @@ func GetActivityDetailUserPower(user *models.WxUserItem, activityInfo *models.Ac
|
|
|
//return
|
|
|
}
|
|
|
}
|
|
|
+ } else {
|
|
|
+ if strings.Contains(permissionStr, activityInfo.ChartPermissionName) {
|
|
|
+ havePower = true
|
|
|
+ return
|
|
|
+ }
|
|
|
}
|
|
|
//判断管理规模是否满足
|
|
|
companyProduct, e := models.GetCompanyProductDetail(user.CompanyId, 2)
|
|
@@ -477,9 +577,25 @@ func GetActivityDetailUserPower(user *models.WxUserItem, activityInfo *models.Ac
|
|
|
} else if (activityInfo.ActivityTypeId == 1 || activityInfo.ActivityTypeId == 3 || activityInfo.ActivityTypeId == 4 || activityInfo.ActivityTypeId == 5) && strings.Contains(permissionStr, "专家") {
|
|
|
havePower = true
|
|
|
}
|
|
|
- if (strings.Contains(activityInfo.ChartPermissionName, "研选") || activityInfo.ChartPermissionName == "策略") && strings.Contains(permissionStr, activityInfo.ChartPermissionName) {
|
|
|
- havePower = true
|
|
|
- return
|
|
|
+
|
|
|
+ fmt.Println(permissionStrZhengShi)
|
|
|
+ //if (strings.Contains(activityInfo.ChartPermissionName, "研选") || activityInfo.ChartPermissionName == "策略") && strings.Contains(permissionStr, activityInfo.ChartPermissionName) {
|
|
|
+ // havePower = true
|
|
|
+ // return
|
|
|
+ //}
|
|
|
+ if strings.Contains(activityInfo.ChartPermissionName, "研选") || activityInfo.ChartPermissionName == "策略" {
|
|
|
+
|
|
|
+ if strings.Contains(activityInfo.CustomerTypeIds, "5") {
|
|
|
+ if strings.Contains(permissionStr, activityInfo.ChartPermissionName) {
|
|
|
+ havePower = true
|
|
|
+ return
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if strings.Contains(permissionStrZhengShi, activityInfo.ChartPermissionName) {
|
|
|
+ havePower = true
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
if activityInfo.ActivityTypeId == 2 || activityInfo.ActivityTypeId == 6 || activityInfo.ActivityTypeId == 7 {
|
|
|
if strings.Contains(permissionStr, activityInfo.ChartPermissionName+"(主观)") {
|
|
@@ -499,11 +615,6 @@ func GetActivityDetailUserPower(user *models.WxUserItem, activityInfo *models.Ac
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- //如果是易董的活动且属于研选类型,只要开通任何权限就可以查看详情
|
|
|
- if activityInfo.YidongActivityId != "" && permissionStr != "" && strings.Contains(activityInfo.ChartPermissionName, utils.CHART_PERMISSION_NAME_YANXUAN) {
|
|
|
- havePower = true
|
|
|
- }
|
|
|
-
|
|
|
permissionShengji, errs := models.GetCompanyPermissionByUserTrip(user.CompanyId)
|
|
|
if errs != nil {
|
|
|
err = errs
|
|
@@ -663,7 +774,7 @@ func GetActivityonditionList(user *models.WxUserItem, activityTypeId, chartPermi
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
|
- userType, permissionStr, err := GetUserType(user.CompanyId)
|
|
|
+ userType, permissionStr, permissionStrZhengShi, err := GetUserTypeZhengShi(user.CompanyId)
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
@@ -689,6 +800,23 @@ func GetActivityonditionList(user *models.WxUserItem, activityTypeId, chartPermi
|
|
|
permissionNameStr = strings.Replace(permissionNameStr, "(主观)", "", -1)
|
|
|
permissionNameStr = strings.Replace(permissionNameStr, "(客观)", "", -1)
|
|
|
permissionNameStr = strings.TrimRight(permissionNameStr, ",")
|
|
|
+
|
|
|
+ slicePerZhengShi := strings.Split(permissionStrZhengShi, ",")
|
|
|
+
|
|
|
+ var permissionNameStrZhengShi string
|
|
|
+ for _, v := range slicePerZhengShi {
|
|
|
+ if userType == 1 {
|
|
|
+ //研选权限处理
|
|
|
+ if !strings.Contains(v, utils.CHART_PERMISSION_NAME_YANXUAN) {
|
|
|
+ permissionNameStrZhengShi += "'" + v + "',"
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ permissionNameStrZhengShi += "'" + v + "',"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ permissionNameStrZhengShi = strings.Replace(permissionNameStrZhengShi, "(主观)", "", -1)
|
|
|
+ permissionNameStrZhengShi = strings.Replace(permissionNameStrZhengShi, "(客观)", "", -1)
|
|
|
+ permissionNameStrZhengShi = strings.TrimRight(permissionNameStrZhengShi, ",")
|
|
|
mapUserType, e := GetActivityCcustomerTypeList()
|
|
|
if e != nil {
|
|
|
err = e
|
|
@@ -883,8 +1011,9 @@ func GetActivityonditionList(user *models.WxUserItem, activityTypeId, chartPermi
|
|
|
}
|
|
|
|
|
|
if adminIds != "" {
|
|
|
+
|
|
|
if userType == 3 {
|
|
|
- conditionAdmin += ` AND art.chart_permission_name IN (` + permissionNameStr + `) `
|
|
|
+ conditionAdmin += ` AND art.chart_permission_name IN (` + permissionNameStrZhengShi + `) `
|
|
|
}
|
|
|
conditionOr += ` OR ( art.customer_type_ids LIKE '%` + userTypeStr + `%' ` + ` AND art.admin_id IN (` + adminIds + `) ` + conditionAdmin + `) `
|
|
|
if companyProduct != nil {
|
|
@@ -921,7 +1050,7 @@ func GetActivityonditionList(user *models.WxUserItem, activityTypeId, chartPermi
|
|
|
}
|
|
|
}
|
|
|
if userType == 3 {
|
|
|
- condition += ` AND art.chart_permission_name IN (` + permissionNameStr + `) `
|
|
|
+ condition += ` AND art.chart_permission_name IN (` + permissionNameStrZhengShi + `) `
|
|
|
}
|
|
|
conditionActivity = condition + permissionSqlStr + sqlExport + conditionOr
|
|
|
return
|
|
@@ -984,7 +1113,8 @@ func SendEmailFileForAskMsgResearch(cont context.Context) (err error) {
|
|
|
openIpItem, _ := models.GetUserRecordByMobile(4, utils.ActSendMsgMobile)
|
|
|
if openIpItem != nil && openIpItem.OpenId != "" {
|
|
|
//SendActivityAskApplyTemplateMsg(user.RealName+"——"+user.CompanyName+"(所属销售:"+sellerItem.RealName+")", v2.CreateTime, v2.Content, activityInfo.ActivityName, activityInfo.ActivityId, openIpItem)
|
|
|
- SendActivityAskApplyTemplateMsgV2(user.RealName+"——"+user.CompanyName, "所属销售:"+sellerItem.RealName, time.Now().Format(utils.FormatDateTime), v2.Content, activityInfo.ActivityName, openIpItem, activityInfo)
|
|
|
+ //SendActivityAskApplyTemplateMsgV2(user.RealName+"——"+user.CompanyName, "所属销售:"+sellerItem.RealName, time.Now().Format(utils.FormatDateTime), v2.Content, activityInfo.ActivityName, openIpItem, activityInfo)
|
|
|
+ SendActivityAskApplyTemplateMsgV2(user.RealName+"——"+user.CompanyName+"("+sellerItem.RealName+")", "留言:"+activityInfo.ActivityName, time.Now().Format(utils.FormatDateTime), v2.Content, activityInfo.ActivityName, openIpItem, activityInfo)
|
|
|
}
|
|
|
}
|
|
|
//给所属销售推送消息
|
|
@@ -992,7 +1122,8 @@ func SendEmailFileForAskMsgResearch(cont context.Context) (err error) {
|
|
|
openIpItem, _ := models.GetUserRecordByMobile(4, sellerItem.Mobile)
|
|
|
if openIpItem != nil && openIpItem.OpenId != "" {
|
|
|
//SendActivityAskApplyTemplateMsg(user.RealName+"——"+user.CompanyName+"(所属销售:"+sellerItem.RealName+")", v2.CreateTime, v2.Content, activityInfo.ActivityName, activityInfo.ActivityId, openIpItem)
|
|
|
- SendActivityAskApplyTemplateMsgV2(user.RealName+"——"+user.CompanyName, "所属销售:"+sellerItem.RealName, time.Now().Format(utils.FormatDateTime), v2.Content, activityInfo.ActivityName, openIpItem, activityInfo)
|
|
|
+ //SendActivityAskApplyTemplateMsgV2(user.RealName+"——"+user.CompanyName, "所属销售:"+sellerItem.RealName, time.Now().Format(utils.FormatDateTime), v2.Content, activityInfo.ActivityName, openIpItem, activityInfo)
|
|
|
+ SendActivityAskApplyTemplateMsgV2(user.RealName+"——"+user.CompanyName+"("+sellerItem.RealName+")", "留言:"+activityInfo.ActivityName, time.Now().Format(utils.FormatDateTime), v2.Content, activityInfo.ActivityName, openIpItem, activityInfo)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1074,7 +1205,8 @@ func SendEmailFileForAskMsg(cont context.Context) (err error) {
|
|
|
openIpItem, _ := models.GetUserRecordByMobile(4, sendMobile)
|
|
|
if openIpItem != nil && openIpItem.OpenId != "" {
|
|
|
//SendActivityAskApplyTemplateMsg(user.RealName+"——"+user.CompanyName+"(所属销售:"+sellerItem.RealName+")", v2.CreateTime, v2.Content, activityInfo.ActivityName, activityInfo.ActivityId, openIpItem)
|
|
|
- SendActivityAskApplyTemplateMsgV2(user.RealName+"——"+user.CompanyName, "所属销售:"+sellerItem.RealName, time.Now().Format(utils.FormatDateTime), v2.Content, activityInfo.ActivityName, openIpItem, activityInfo)
|
|
|
+ //SendActivityAskApplyTemplateMsgV2(user.RealName+"——"+user.CompanyName, "所属销售:"+sellerItem.RealName, time.Now().Format(utils.FormatDateTime), v2.Content, activityInfo.ActivityName, openIpItem, activityInfo)
|
|
|
+ SendActivityAskApplyTemplateMsgV2(user.RealName+"——"+user.CompanyName+"("+sellerItem.RealName+")", "留言:"+activityInfo.ActivityName, time.Now().Format(utils.FormatDateTime), v2.Content, activityInfo.ActivityName, openIpItem, activityInfo)
|
|
|
}
|
|
|
}
|
|
|
//给销售推送模板消息
|
|
@@ -1082,7 +1214,8 @@ func SendEmailFileForAskMsg(cont context.Context) (err error) {
|
|
|
openIpItem, _ := models.GetUserRecordByMobile(4, sellerItem.Mobile)
|
|
|
if openIpItem != nil && openIpItem.OpenId != "" {
|
|
|
//SendActivityAskApplyTemplateMsg(user.RealName+"——"+user.CompanyName+"(所属销售:"+sellerItem.RealName+")", v2.CreateTime, v2.Content, activityInfo.ActivityName, activityInfo.ActivityId, openIpItem)
|
|
|
- SendActivityAskApplyTemplateMsgV2(user.RealName+"——"+user.CompanyName, "所属销售:"+sellerItem.RealName, time.Now().Format(utils.FormatDateTime), v2.Content, activityInfo.ActivityName, openIpItem, activityInfo)
|
|
|
+ //SendActivityAskApplyTemplateMsgV2(user.RealName+"——"+user.CompanyName, "所属销售:"+sellerItem.RealName, time.Now().Format(utils.FormatDateTime), v2.Content, activityInfo.ActivityName, openIpItem, activityInfo)
|
|
|
+ SendActivityAskApplyTemplateMsgV2(user.RealName+"——"+user.CompanyName+"("+sellerItem.RealName+")", "留言:"+activityInfo.ActivityName, time.Now().Format(utils.FormatDateTime), v2.Content, activityInfo.ActivityName, openIpItem, activityInfo)
|
|
|
}
|
|
|
}
|
|
|
}
|