package hw import ( zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils" "github.com/syyongx/php2go" "github.com/tidwall/gjson" "strings" ) func HwSend(url string, param map[string]string, secret string) string { sign := getSign(param, secret) param["sign"] = sign for k, v := range param { if v == "" { continue } if strings.Contains(url, "?") == false { url += "?" + k + "=" + php2go.URLEncode(v) } else { url += "&" + k + "=" + php2go.URLEncode(v) } } return url } func HwSendOrder(url string, param map[string]string, secret string) string { sign := getSign(param, secret) param["sign"] = sign for k, v := range param { if v == "" { continue } if strings.Contains(url, "?") == false { url += "?" + k + "=" + php2go.URLEncode(v) } else { url += "&" + k + "=" + php2go.URLEncode(v) } } data, _ := zhios_third_party_utils.CurlGet(url, nil) list := gjson.Get(string(data), "data.list").String() if list == "" { list = gjson.Get(string(data), "data.order").String() } return list } func getSign(param map[string]string, secret string) string { strMap := zhios_third_party_utils.KsortToStr(param) str := "" for _, v := range strMap { if v == "sign" || param[v] == "" { continue } str += zhios_third_party_utils.UderscoreToUpperCamelCase(v) + "=" + param[v] + "&" } str += "secretKey=" + secret return strings.ToUpper(php2go.Md5(str)) }