huangjiajun vor 1 Jahr
Ursprung
Commit
a0c4db14c4
2 geänderte Dateien mit 56 neuen und 0 gelöschten Zeilen
  1. +24
    -0
      express/api.go
  2. +32
    -0
      express/express.go

+ 24
- 0
express/api.go Datei anzeigen

@@ -0,0 +1,24 @@
package express

import (
zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils"
"github.com/syyongx/php2go"
"strings"
"time"
)

func Send(url, key, clientId, apiCode string, data map[string]interface{}) (string, error) {
timestamp := zhios_third_party_utils.Int64ToStr(time.Now().UnixNano() / 1e6)
param := map[string]interface{}{
"clientId": clientId,
"timestamp": timestamp,
"sign": getSign(key, clientId, timestamp),
"apiCode": apiCode,
"dataParams": data,
}
post, err := zhios_third_party_utils.CurlPost(url, zhios_third_party_utils.SerializeStr(param), nil)
return string(post), err
}
func getSign(key, clientId, timestamp string) string {
return strings.ToUpper(php2go.Md5("{\"clientId\":\"" + clientId + "\",\"privateKey\":\"" + key + "\",\"timestamp\":\"" + timestamp + "\"}"))
}

+ 32
- 0
express/express.go Datei anzeigen

@@ -0,0 +1,32 @@
package express

//余额
func Balance(url, key, clientId string) (string, error) {
data := make(map[string]interface{})
send, err := Send(url, key, clientId, "3004", data)
return send, err
}

//轨迹查询接口
func Trajectory(url, key, clientId string, data map[string]interface{}) (string, error) {
send, err := Send(url, key, clientId, "3002", data)
return send, err
}

//价格查询接口
func PriceTotal(url, key, clientId string, data map[string]interface{}) (string, error) {
send, err := Send(url, key, clientId, "3003", data)
return send, err
}

//订单取消接口
func CloseOrder(url, key, clientId string, data map[string]interface{}) (string, error) {
send, err := Send(url, key, clientId, "2001", data)
return send, err
}

//订单创建接口
func CreateOrder(url, key, clientId string, data map[string]interface{}) (string, error) {
send, err := Send(url, key, clientId, "1001", data)
return send, err
}

Laden…
Abbrechen
Speichern