|
@@ -55,6 +55,10 @@ type CrmApiUserResponse struct {
|
|
|
Data *CrmApiUserData `json:"data"`
|
|
|
}
|
|
|
|
|
|
+type CrmApiCodeResponse struct {
|
|
|
+ Code int `json:"code" comment:"返回码"`
|
|
|
+}
|
|
|
+
|
|
|
// Data 结构体表示数据部分
|
|
|
type CrmApiUserData struct {
|
|
|
ContactInfo *CrmApiUserContactInfo `json:"contactInfo"`
|
|
@@ -74,16 +78,28 @@ func GetClptCrmWorkerRule(mobile string) (statusResp int, err error) {
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
|
- item := new(CrmApiUserResponse)
|
|
|
- err = json.Unmarshal(body, &item)
|
|
|
+
|
|
|
+ // 尝试解析成功的响应
|
|
|
+ var responseCode CrmApiCodeResponse
|
|
|
+ err = json.Unmarshal(body, &responseCode)
|
|
|
if err != nil {
|
|
|
+ fmt.Println("JSON解析失败:", err)
|
|
|
return
|
|
|
}
|
|
|
//如果状态码不等于1 ,就把直接返回
|
|
|
- codeResp := item.Code
|
|
|
- if codeResp != 1 {
|
|
|
+ if responseCode.Code != 1 {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ item := new(CrmApiUserResponse)
|
|
|
+ err = json.Unmarshal(body, &item)
|
|
|
+ if err != nil {
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
+ //codeResp := item.Code
|
|
|
+ //if codeResp != 1 {
|
|
|
+ // return
|
|
|
+ //}
|
|
|
statusResp = item.Data.ContactInfo.Status
|
|
|
return
|
|
|
}
|