package maycur import ( "context" "fmt" "hongze/hongze_task/services/alarm_msg" "hongze/hongze_task/utils" "io/ioutil" "net/http" "strings" ) const ( SyncMaycurCompanyProfileUrl = "http://127.0.0.1:8702/adminapi/maycur/company_profile/daily_sync" ) // DailyUpdateCompanyProfile 每日更新客户档案-请求hongze_admin同步接口 func DailyUpdateCompanyProfile(cont context.Context) (err error) { defer func() { if err != nil { utils.FileLog.Info("DailyUpdateCompanyProfile ErrMsg: %s", err.Error()) // 出错的话hongze_admin那边有报错, 这边只要定时请求了就行... go alarm_msg.SendAlarmMsg(fmt.Sprintf("每日更新客户档案失败, ErrMsg: %s", err.Error()), 2) } }() body := ioutil.NopCloser(strings.NewReader("")) client := &http.Client{} req, e := http.NewRequest("POST", SyncMaycurCompanyProfileUrl, body) if e != nil { err = fmt.Errorf("http create request err: %s", e.Error()) return } contentType := "application/json;charset=utf-8" req.Header.Set("Content-Type", contentType) //req.Header.Set("Authorization", utils.SendTemplateMsgAuthorization) resp, e := client.Do(req) if e != nil { err = fmt.Errorf("http client do err: %s", e.Error()) return err } defer func() { _ = resp.Body.Close() }() //b, e := ioutil.ReadAll(resp.Body) //if e != nil { // err = fmt.Errorf("resp body read err: %s", e.Error()) // return //} //if len(b) == 0 { // err = fmt.Errorf("resp body is empty") // return //} //// 解密 //bo := utils.DesBase64Decrypt(b) //result := new(models.BaseResponse) //if e = json.Unmarshal(bo, &result); e != nil { // err = fmt.Errorf("result unmarshal err: %s\nresult: %s", e.Error(), string(b)) // return //} //if result.Ret != 200 { // err = fmt.Errorf("result: %s", string(b)) // return err //} return }