package order import ( "crypto/md5" "encoding/hex" "encoding/json" "errors" "log" "strconv" "strings" "time" "git.tetele.net/tgo/crypter" "github.com/golang/protobuf/proto" ) type OrderCancelRes struct { Success bool } func Cancel(dbname, site_id string, order_id string, url ...string) (*OrderCancelRes, error) { conn, err := rpc_server_conn(url...) if err != nil { return nil, err } defer conn.Close() data := map[string]string{ "dbname": dbname, "site_id": site_id, "order_id": order_id, } data_json, err := json.Marshal(data) if err != nil { return nil, err } encryData := crypter.DesEn(string(data_json), DES_KEY) now_int64 := time.Now().Unix() now := strconv.FormatInt(now_int64, 10) sign := Sign(encryData, now) req := &CreateRequest{ proto.String(encryData), proto.String(now), proto.String(sign), nil} res := &CreateResponse{} err = conn.Cancel(req, res) if err != nil { return nil, err } res_data, err := HandleResponse(res) var res_arr OrderCancelRes err = json.Unmarshal([]byte(res_data_de), &res_arr) if err != nil { return nil, err } return &res_arr, nil }