- refactor LegacyQuerySingleOrder.
This commit is contained in:
@@ -1,21 +1,9 @@
|
|||||||
package jdapi
|
package jdapi
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
type LegacyJDOrderInfo struct {
|
|
||||||
Code string `json:"code"`
|
|
||||||
Msg string `json:"msg"`
|
|
||||||
Result map[string]interface{} `json:"result"`
|
|
||||||
Detail string `json:"detail"`
|
|
||||||
Success bool `json:"success"`
|
|
||||||
OrderStatus int `json:"-"`
|
|
||||||
OrderStatusTime string `json:"-"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (j JDAPI) OrderQuery(jdParams map[string]string) (retVal []interface{}, err error) {
|
func (j JDAPI) OrderQuery(jdParams map[string]string) (retVal []interface{}, err error) {
|
||||||
retVal, err = j.AccessJDQueryHavePage("order/es/query", jdParams, nil, nil, nil)
|
retVal, err = j.AccessJDQueryHavePage("order/es/query", jdParams, nil, nil, nil)
|
||||||
return
|
return
|
||||||
@@ -27,7 +15,7 @@ func (j JDAPI) QuerySingleOrder(orderId string) ([]interface{}, error) {
|
|||||||
return j.AccessJDQueryHavePage("order/es/query", jdParams, nil, nil, nil)
|
return j.AccessJDQueryHavePage("order/es/query", jdParams, nil, nil, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (j JDAPI) LegacyQuerySingleOrder(orderId string) (*LegacyJDOrderInfo, error) {
|
func (j JDAPI) LegacyQuerySingleOrder(orderId string) (map[string]interface{}, error) {
|
||||||
jdParams := make(map[string]string)
|
jdParams := make(map[string]string)
|
||||||
jdParams["orderId"] = orderId
|
jdParams["orderId"] = orderId
|
||||||
|
|
||||||
@@ -39,25 +27,13 @@ func (j JDAPI) LegacyQuerySingleOrder(orderId string) (*LegacyJDOrderInfo, error
|
|||||||
dataStr, _ := result["data"].(string)
|
dataStr, _ := result["data"].(string)
|
||||||
var data map[string]interface{}
|
var data map[string]interface{}
|
||||||
utils.UnmarshalUseNumber([]byte(dataStr), &data)
|
utils.UnmarshalUseNumber([]byte(dataStr), &data)
|
||||||
|
result["data"] = data
|
||||||
resultList, _ := NormalJDQueryHavePageResultParser(data, 0)
|
|
||||||
orderInfo, _ := resultList[0].(map[string]interface{})
|
|
||||||
orderStatus64, _ := orderInfo["orderStatus"].(json.Number).Int64()
|
|
||||||
|
|
||||||
var dataResult map[string]interface{}
|
var dataResult map[string]interface{}
|
||||||
utils.UnmarshalUseNumber([]byte(data["result"].(string)), &dataResult)
|
utils.UnmarshalUseNumber([]byte(data["result"].(string)), &dataResult)
|
||||||
dataResult["resultList"] = resultList
|
data["result"] = dataResult
|
||||||
|
|
||||||
retVal := &LegacyJDOrderInfo{}
|
return result, nil
|
||||||
retVal.OrderStatus = int(orderStatus64)
|
|
||||||
retVal.OrderStatusTime = orderInfo["orderStatusTime"].(string)
|
|
||||||
retVal.Code = result["code"].(string)
|
|
||||||
retVal.Msg = result["msg"].(string)
|
|
||||||
|
|
||||||
retVal.Result = dataResult
|
|
||||||
retVal.Success = true
|
|
||||||
|
|
||||||
return retVal, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (j JDAPI) OrderAcceptOperate(orderId string, isAgreed bool) (interface{}, error) {
|
func (j JDAPI) OrderAcceptOperate(orderId string, isAgreed bool) (interface{}, error) {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetConcretValue(value reflect.Value) reflect.Value {
|
func GetConcretValue(value reflect.Value) reflect.Value {
|
||||||
@@ -91,3 +92,13 @@ func Bool2String(value bool) string {
|
|||||||
}
|
}
|
||||||
return "false"
|
return "false"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Str2Int(str string) int {
|
||||||
|
retVal, _ := strconv.Atoi(str)
|
||||||
|
return retVal
|
||||||
|
}
|
||||||
|
|
||||||
|
func Str2Int64(str string) int64 {
|
||||||
|
retVal, _ := strconv.ParseInt(str, 10, 64)
|
||||||
|
return retVal
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user