package thirdparty import ( "gd_management/common.in/config" "gd_management/common.in/httpClient" "gd_management/common.in/utils" "encoding/base64" "encoding/json" "fmt" "go.uber.org/zap" hurl "net/url" "strings" ) /*var CheCheMd5Key = "e10adc3949ba59abbe56e057f20f883e" var CheCheAID = "78900" var CheCheMid = "78900" */ func CheCheHttpPost(url string, action string, param map[string]string) (result []byte, err error) { defer func() { l.Info("thirdparty", zap.String("api", url), zap.String("request", utils.MarshalJsonString(param)), zap.String("response", utils.MarshalJsonString(result))) }() param["aId"] = config.Conf.ThirdPart.CheCheAid param["mId"] = config.Conf.ThirdPart.CheCheMid param["action"] = action urlValue := hurl.Values{} for k, v := range param { urlValue.Add(k, v) } signText := urlValue.Encode() signText = fmt.Sprintf("%s&%s", signText, config.Conf.ThirdPart.CheCheMd5Key) sign := utils.MD5(signText) sign = strings.ToUpper(sign) param["sign"] = sign for k, v := range param { param[k] = hurl.QueryEscape(v) } bytes, _ := json.Marshal(param) b64 := base64.StdEncoding.EncodeToString(bytes) var query = map[string]string{ "Base64": b64, } return httpClient.HttpPostWithHead(url, nil, query, nil) }