diff --git a/platformapi/jdapi/order.go b/platformapi/jdapi/order.go index 12fe9fef..f1b82e83 100644 --- a/platformapi/jdapi/order.go +++ b/platformapi/jdapi/order.go @@ -310,6 +310,19 @@ type OrderInfo struct { Yn bool `json:"yn"` } +type OrderQueryParam struct { + PageNo int64 `json:"pageNo,omitempty"` // 当前页数,默认:1 + PageSize int `json:"pageSize,omitempty"` // 每页条数,默认:20,最大值100 + OrderID int64 `json:"orderId,omitempty"` + + OrderPurchaseTimeBegin string `json:"orderPurchaseTime_begin,omitempty"` // 购买成交时间-支付(开始) + OrderPurchaseTimeEnd string `json:"orderPurchaseTime_end,omitempty"` // 购买成交时间-支付(结束) + OrderStatus int `json:"orderStatus,omitempty"` + + DeliveryStationNo string `json:"deliveryStationNo,omitempty"` // 到家门店编码 + DeliveryStationNoIsv string `json:"deliveryStationNoIsv,omitempty"` // 商家门店编码 +} + var ( ErrCanNotFindOrder = errors.New("can not find order") ) @@ -336,14 +349,6 @@ func (a *API) OrderQuery(jdParams map[string]interface{}) (retVal []interface{}, return retVal, totalCount, err } -func (a *API) OrderQuery2(jdParams map[string]interface{}) (retVal []*OrderInfo, totalCount int, err error) { - orderList, totalCount, err := a.OrderQuery(jdParams) - if err == nil { - err = utils.Map2StructByJson(orderList, &retVal, true) - } - return retVal, totalCount, err -} - // orderFreightMoney 基础运费 // tips 商家承担小费 // merchantPaymentDistanceFreightMoney 取件服务费(开票)(正向单展示远距离运费;售后单则展示达达售后运费) @@ -361,6 +366,28 @@ func (a *API) QuerySingleOrder(orderId string) (map[string]interface{}, error) { return result[0].(map[string]interface{}), nil } +func (a *API) OrderQuery2(queryParam *OrderQueryParam) (retVal []*OrderInfo, totalCount int, err error) { + orderList, totalCount, err := a.OrderQuery(utils.Struct2MapByJson(queryParam)) + if err == nil { + err = utils.Map2StructByJson(orderList, &retVal, true) + } + return retVal, totalCount, err +} + +func (a *API) QuerySingleOrder2(orderID string) (orderInfo *OrderInfo, err error) { + orderList, _, err := a.OrderQuery2(&OrderQueryParam{ + OrderID: utils.Str2Int64(orderID), + }) + if err == nil { + if len(orderList) > 0 { + orderInfo = orderList[0] + } else { + err = ErrCanNotFindOrder + } + } + return orderInfo, err +} + // 商家确认接单接口 // https://opendj.jd.com/staticnew/widgets/resources.html?groupid=169&apiid=c1a15129d1374e9da7fa35487f878604 func (a *API) OrderAcceptOperate(orderId string, isAgreed bool, userName string) error { diff --git a/platformapi/jdapi/order_test.go b/platformapi/jdapi/order_test.go index b64008ab..89d94372 100644 --- a/platformapi/jdapi/order_test.go +++ b/platformapi/jdapi/order_test.go @@ -226,3 +226,13 @@ func TestOrderAddTips(t *testing.T) { t.Fatal(err.Error()) } } + +func TestOrderQuery2(t *testing.T) { + orderList, _, err := api.OrderQuery2(&OrderQueryParam{ + OrderID: 918092290000042, + }) + t.Log(utils.Format4Output(orderList, false)) + if err != nil { + t.Fatal(err.Error()) + } +}