|
|
- package orderrpcv2
-
- import (
- "encoding/json"
- "errors"
- )
-
- 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
- data["condition"] = "order_id"
-
- 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
-
- }
-
- func GetInfoByOrderSn(site_id, dbname string, order_sn string, field string, url ...string) (map[string]string, error) {
-
- if dbname == "" || order_sn == "" {
- 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_sn"] = order_sn
- data["field"] = field
- data["condition"] = "order_sn"
-
- 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
-
- }
|