diff --git a/express/api.go b/express/api.go new file mode 100644 index 0000000..84464e1 --- /dev/null +++ b/express/api.go @@ -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 + "\"}")) +} diff --git a/express/express.go b/express/express.go new file mode 100644 index 0000000..2666ef2 --- /dev/null +++ b/express/express.go @@ -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 +}