2.0订单rpc数据结构
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

110 lines
1.8 KiB

  1. package orderrpcv2
  2. import (
  3. "encoding/json"
  4. "errors"
  5. )
  6. func GetInfo(site_id, dbname string, order_id string, field string, url ...string) (map[string]string, error) {
  7. if dbname == "" || order_id == "" {
  8. return nil, errors.New("参数错误")
  9. }
  10. conn, err := rpc_server_conn(url...)
  11. if err != nil {
  12. return nil, err
  13. }
  14. defer conn.Close()
  15. var data map[string]string = make(map[string]string)
  16. data["dbname"] = dbname
  17. data["site_id"] = site_id
  18. data["order_id"] = order_id
  19. data["field"] = field
  20. data["condition"] = "order_id"
  21. req, err := SetReqData(data)
  22. if err != nil {
  23. return nil, err
  24. }
  25. res := &Response{}
  26. err = conn.Get(req, res)
  27. if err != nil {
  28. return nil, err
  29. }
  30. res_data_de, err := GetResData(res)
  31. if err != nil {
  32. return nil, err
  33. }
  34. if res_data_de == "" {
  35. return nil, nil
  36. }
  37. var res_arr map[string]string
  38. err = json.Unmarshal([]byte(res_data_de), &res_arr)
  39. if err != nil {
  40. return nil, err
  41. }
  42. return res_arr, nil
  43. }
  44. func GetInfoByOrderSn(site_id, dbname string, order_sn string, field string, url ...string) (map[string]string, error) {
  45. if dbname == "" || order_sn == "" {
  46. return nil, errors.New("参数错误")
  47. }
  48. conn, err := rpc_server_conn(url...)
  49. if err != nil {
  50. return nil, err
  51. }
  52. defer conn.Close()
  53. var data map[string]string = make(map[string]string)
  54. data["dbname"] = dbname
  55. data["site_id"] = site_id
  56. data["order_sn"] = order_sn
  57. data["field"] = field
  58. data["condition"] = "order_sn"
  59. req, err := SetReqData(data)
  60. if err != nil {
  61. return nil, err
  62. }
  63. res := &Response{}
  64. err = conn.Get(req, res)
  65. if err != nil {
  66. return nil, err
  67. }
  68. res_data_de, err := GetResData(res)
  69. if err != nil {
  70. return nil, err
  71. }
  72. if res_data_de == "" {
  73. return nil, nil
  74. }
  75. var res_arr map[string]string
  76. err = json.Unmarshal([]byte(res_data_de), &res_arr)
  77. if err != nil {
  78. return nil, err
  79. }
  80. return res_arr, nil
  81. }