xingzai před 7 měsíci
rodič
revize
37a5d2b57c
3 změnil soubory, kde provedl 55 přidání a 1 odebrání
  1. 9 0
      controllers/yidong.go
  2. 42 0
      services/yidong/yidong.go
  3. 4 1
      utils/constants.go

+ 9 - 0
controllers/yidong.go

@@ -413,6 +413,15 @@ func (c *YiDongController) UserCheck() {
 	//校验是否是系统内权益的正式、试用、永续客户(不区分行业),若是,返回审核通过
 	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 (