|
- package zero_buy
-
- import (
- "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/comm"
- "github.com/syyongx/php2go"
- "strings"
- )
-
- func ZeroBuyUrl(appSecret string, param map[string]string) string {
- url := "https://h5.hlpay178.cn/#/"
- param["deviceID"] = strings.ReplaceAll(param["deviceID"], " ", "")
- deviceID, _ := php2go.URLDecode(param["deviceID"])
- if deviceID != "" {
- param["deviceID"] = deviceID
- }
- for k, v := range param {
- if strings.Contains(url, "?") == false {
- url += "?" + k + "=" + php2go.URLEncode(v)
- } else {
- url += "&" + k + "=" + php2go.URLEncode(v)
- }
- }
- sign := GetSign(appSecret, param)
- url += "&sign=" + sign
- return url
- }
- func GetSign(appSecret string, param map[string]string) string {
- keys := comm.KsortToStr(param)
- str := ""
- for _, k := range keys {
- if str == "" {
- str += k + "=" + param[k]
- } else {
- str += "|" + k + "=" + param[k]
- }
- }
- str += "|" + appSecret
- return php2go.Md5(str)
- }
|