package orderrpc import ( "encoding/json" "strconv" "time" "git.tetele.net/tgo/crypter" "github.com/golang/protobuf/proto" ) type OrderVerifyRes struct { Result bool OrderRow map[string]string } /* * 按核销码/用户ID核销订单 * data map[string]string{"verify_code":"","user_id":""}, 二选一 */ func VerifyByBooking(dbname, site_id string, data map[string]string, url ...string) (OrderVerifyRes, error) { var order_rpc_url string = "127.0.0.1:7973" if len(url) > 0 && url[0] != "" { order_rpc_url = url[0] } conn, _, err := DialOrderService("tcp", order_rpc_url) if err != nil { return nil, err } defer conn.Close() data["dbname"] = dbname data["site_id"] = site_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 := &Request{ proto.String(encryData), proto.String(now), proto.String(sign), nil} res := &Response{} err = conn.VerifyByBooking(req, res) if err != nil { return nil, err } res_data_de, err := GetOrgData(res) if err != nil { return nil, err } var res_arr OrderVerifyRes err = json.Unmarshal([]byte(res_data_de), &res_arr) if err != nil { return nil, err } return res_arr, nil }