Browse Source

增加查询订单内容调用方法

master v0.3.2
guzeng 3 years ago
parent
commit
aaffebd0b0
3 changed files with 71 additions and 7 deletions
  1. +58
    -0
      client.getinfo.go
  2. +13
    -0
      client.getinfo_test.go
  3. +0
    -7
      variable.go

+ 58
- 0
client.getinfo.go View File

@ -0,0 +1,58 @@
package orderrpcv2
import (
"encoding/json"
"errors"
"log"
)
func GetInfo(site_id, dbname string, order_id string, field string, url ...string) (map[string]string, error) {
if dbname == "" || order_id == "" {
return nil, errors.New("参数错误")
}
conn, err := rpc_server_conn(url...)
if err != nil {
return nil, err
}
defer conn.Close()
var data map[string]string = make(map[string]string)
data["dbname"] = dbname
data["site_id"] = site_id
data["order_id"] = order_id
data["field"] = field
req, err := SetReqData(data)
if err != nil {
return nil, err
}
res := &Response{}
err = conn.Get(req, res)
if err != nil {
return nil, err
}
res_data_de, err := GetResData(res)
if err != nil {
return nil, err
}
if res_data_de == "" {
return nil, nil
}
var res_arr map[string]string
err = json.Unmarshal([]byte(res_data_de), &res_arr)
if err != nil {
return nil, err
}
return res_arr, nil
}

+ 13
- 0
client.getinfo_test.go View File

@ -0,0 +1,13 @@
package orderrpcv2
import (
"testing"
)
func Test_GetInfo(t *testing.T) {
ret, err := GetInfo("100064", "shop_v2", "1", "id,order_sn")
t.Log(ret)
t.Log(err)
}

+ 0
- 7
variable.go View File

@ -9,10 +9,3 @@ type OrderCreateRes struct {
type OrderCancelRes struct {
Success bool
}
type GetParam struct {
SiteId string
Dbname string
OrderId string
Field string
}

Loading…
Cancel
Save