瀏覽代碼

Merge branch 'cygx_need_986' of http://8.136.199.33:3000/hongze/hongze_open_api into debug

xingzai 6 月之前
父節點
當前提交
35600534bc
共有 3 個文件被更改,包括 75 次插入17 次删除
  1. 29 16
      controllers/yidong.go
  2. 42 0
      services/yidong/yidong.go
  3. 4 1
      utils/constants.go

+ 29 - 16
controllers/yidong.go

@@ -379,11 +379,11 @@ func (c *YiDongController) UserCheck() {
 		c.FailWithMessage("签名错误!")
 		return
 	}
-	activityDetail, err := cygxActivity.GetAddActivityInfoById(activityIdYiDong)
-	if err != nil {
-		c.FailWithMessage("会议id异常:" + activityIdYiDong)
-		return
-	}
+	//activityDetail, err := cygxActivity.GetAddActivityInfoById(activityIdYiDong)
+	//if err != nil {
+	//	c.FailWithMessage("会议id异常:" + activityIdYiDong)
+	//	return
+	//}
 	var dateTxt = []byte(mobile)
 	resultDe := utils.DesBase64Decrypt(dateTxt)
 	deMobile := string(resultDe)
@@ -393,22 +393,35 @@ func (c *YiDongController) UserCheck() {
 		return
 	}
 	resp := new(yidong.CheckHaspermissionResp)
-	//total, err := company_product.CheckUserAaiPerssionByMobile(deMobile)
-	//if err != nil {
-	//	c.FailWithMessage("校验失败!" + err.Error())
-	//	return
-	//}
-	//获取所有的权限名称
-	companyPermissionName, err := company_product.GetCompanyPermissionByMobile(deMobile)
+	total, err := company_product.CheckUserAaiPerssionByMobile(deMobile)
 	if err != nil {
 		c.FailWithMessage("校验失败!" + err.Error())
 		return
 	}
-	if companyPermissionName != "" {
-		companyPermissionName += ",宏观" // 有任意一个权限,就可以参加宏观权限的活动
-	}
-	if strings.Contains(companyPermissionName, activityDetail.ChartPermissionName) {
+	////获取所有的权限名称
+	//companyPermissionName, err := company_product.GetCompanyPermissionByMobile(deMobile)
+	//if err != nil {
+	//	c.FailWithMessage("校验失败!" + err.Error())
+	//	return
+	//}
+	//if companyPermissionName != "" {
+	//	companyPermissionName += ",宏观" // 有任意一个权限,就可以参加宏观权限的活动
+	//}
+	//if strings.Contains(companyPermissionName, activityDetail.ChartPermissionName) {
+	//	resp.Haspermission = true
+	//}
+	//校验是否是系统内权益的正式、试用、永续客户(不区分行业),若是,返回审核通过
+	if total > 0 {
 		resp.Haspermission = true
+	} else {
+		statusResp, err := servicesYidong.GetClptCrmWorkerRule(deMobile)
+		if err != nil {
+			c.FailWithMessage("校验失败!" + err.Error())
+			return
+		}
+		if statusResp == 1 {
+			resp.Haspermission = true
+		}
 	}
 	//添加请求日志记录
 	itemApiLog := new(cygx_three_api_log.CygxThreeApiLog)

+ 42 - 0
services/yidong/yidong.go

@@ -1,8 +1,10 @@
 package yidong
 
 import (
+	"encoding/json"
 	"errors"
 	"fmt"
+	"github.com/rdlucklib/rdluck_tools/http"
 	"hongze/hongze_open_api/models/tables/open_api_user"
 	"hongze/hongze_open_api/utils"
 	"strconv"
@@ -45,3 +47,43 @@ func CheckAppidAndIp(appid, ip string) (err error) {
 	//}
 	return
 }
+
+// Response 结构体表示整个响应
+type CrmApiUserResponse struct {
+	Code int             `json:"code"`
+	Msg  string          `json:"msg"`
+	Data *CrmApiUserData `json:"data"`
+}
+
+// Data 结构体表示数据部分
+type CrmApiUserData struct {
+	ContactInfo *CrmApiUserContactInfo `json:"contactInfo"`
+}
+
+// ContactInfo 结构体表示联系人信息
+type CrmApiUserContactInfo struct {
+	Status int `json:"status"`
+}
+
+// GetClptCrmWorkerRule 根据手机号,获取策略平台用户对应的权限
+func GetClptCrmWorkerRule(mobile string) (statusResp int, err error) {
+	crmUrl := utils.CLPT_CRM_URL + `worker/api/getWorkerRule?phone=%s&token=a2db0ab2ca6367741cab37f34d602987`
+	crmUrl = fmt.Sprintf(crmUrl, mobile)
+	body, err := http.Get(crmUrl)
+	//utils.FileLog.Info("lt result:%s", string(body))
+	if err != nil {
+		return
+	}
+	item := new(CrmApiUserResponse)
+	err = json.Unmarshal(body, &item)
+	if err != nil {
+		return
+	}
+	//如果状态码不等于1 ,就把直接返回
+	codeResp := item.Code
+	if codeResp != 1 {
+		return
+	}
+	statusResp = item.Data.ContactInfo.Status
+	return
+}

+ 4 - 1
utils/constants.go

@@ -114,7 +114,10 @@ const HZ_DEFAULT_AVATAR = "https://hzstatic.hzinsights.com/static/yb_wx/hz_defau
 
 const HZPHONE = "057187186319" //弘则电话
 
-const CLPT_APPID = "XVuGlcyEEVNYVWx5" //策略平台APPID
+const (
+	CLPT_APPID   = "XVuGlcyEEVNYVWx5"            //策略平台APPID
+	CLPT_CRM_URL = "https://crm.hzinsights.com/" //策略平台老的CRM接口访问地址
+)
 
 // EDB_LIB
 var (