Files
baseapi/platformapi/jdapi/order.go
gazebo 8357982612 - refactor AccessAPINoPage.
- product related api added.
2018-08-26 09:57:43 +08:00

161 lines
5.4 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package jdapi
import (
"errors"
"git.rosy.net.cn/baseapi/utils"
)
const (
OrderStatusAddComment = "12001"
OrderStatusModifyComment = "12006"
OrderStatusTipChanged = "12008"
OrderStatusPurchased = "41000" // 也即待处理JD的消息很怪新订单消息发过来是32000但如果不是自动接单的去查却是41000接单后才变为32000
OrderStatusNew = "32000"
OrderStatusAdjust = "33080"
OrderStatusWaitOutStore = "32001"
OrderStatusFinishedPickup = "2"
OrderStatusDelivering = "33040"
OrderStatusDelivered = "33060"
OrderStatusFinished = "90000"
OrderStatusCanceled = "20020"
OrderStatusUserApplyCancel = "20030" // 这个其实不是一个状态,是一个动作
OrderStatusLocked = "20010"
OrderStatusUnlocked = "20050"
OrderStatusInfoChanged = "1"
)
const (
DeliveryStatusWait4Grap = "10"
DeliveryStatusAccepted = "20"
DeliveryStatusCourierCanceled = "21"
DeliveryStatusCourierArrived = "23"
DeliveryStatusFailedGetGoods = "25"
DeliveryStatusFailedGetGoodsRejected = "26"
DeliveryStatusFailedGetGoodsWaiting = "27"
DeliveryStatusGotGoods = "30"
DeliveryStatusFailedDelivery = "35"
DeliveryStatusFinished = "40"
)
const (
PromotionTypeNormal = 1
PromotionTypeSeckill = 2
PromotionTypeDirectDown = 3
PromotionTypeLimitedTime = 4
PromotionTypeAddMoneyBuy = 1202
PromotionTypeOverflowGiveGift = 1203
PromotionTypeBuyGiveGift = 6
)
var (
ErrCanNotFindOrder = errors.New("can not find order")
)
func (a *API) OrderQuery(jdParams map[string]interface{}) (retVal []interface{}, totalCount int, err error) {
return a.AccessAPIHavePage("order/es/query", jdParams, nil, nil, nil)
}
// orderFreightMoney 基础运费
// tips 商家承担小费
// merchantPaymentDistanceFreightMoney 取件服务费(开票)(正向单展示远距离运费;售后单则展示达达售后运费)
// orderBaseFreightMoney ?
func (a *API) QuerySingleOrder(orderId string) (map[string]interface{}, error) {
jdParams := make(map[string]interface{})
jdParams["orderId"] = orderId
result, _, err := a.AccessAPIHavePage("order/es/query", jdParams, nil, nil, nil)
if err != nil {
return nil, err
}
if len(result) == 0 {
return nil, ErrCanNotFindOrder
}
return result[0].(map[string]interface{}), nil
}
func (a *API) LegacyQuerySingleOrder(orderId string) (map[string]interface{}, error) {
jdParams := make(map[string]interface{})
jdParams["orderId"] = orderId
result, err := a.AccessAPI("order/es/query", jdParams)
if err != nil {
return nil, err
}
dataStr, _ := result["data"].(string)
var data map[string]interface{}
utils.UnmarshalUseNumber([]byte(dataStr), &data)
result["data"] = data
var dataResult map[string]interface{}
utils.UnmarshalUseNumber([]byte(data["result"].(string)), &dataResult)
data["result"] = dataResult
return result, nil
}
func (a *API) OrderAcceptOperate(orderId string, isAgreed bool, userName string) (interface{}, error) {
jdParams := map[string]interface{}{
"orderId": orderId,
"isAgreed": utils.Bool2String(isAgreed),
"operator": utils.GetAPIOperator(userName),
}
return a.AccessAPINoPage("ocs/orderAcceptOperate", jdParams, nil, nil, nil)
}
// 拣货完成且众包配送接口
// https://opendj.jd.com/staticnew/widgets/resources.html?groupid=169&apiid=ed93745b86c6487eaaea5f55a84785ac
func (a *API) OrderJDZBDelivery(orderId string, userName string) (interface{}, error) {
jdParams := map[string]interface{}{
"orderId": orderId,
"operator": utils.GetAPIOperator(userName),
}
return a.AccessAPINoPage("bm/open/api/order/OrderJDZBDelivery", jdParams, nil, nil, nil)
}
// 订单达达配送转商家自送接口
// https://opendj.jd.com/staticnew/widgets/resources.html?groupid=169&apiid=e7b4950164754eecac7ea87278c2b071
func (a *API) ModifySellerDelivery(orderId string, userName string) (interface{}, error) {
jdParams := map[string]interface{}{
"orderId": orderId,
"updatePin": utils.GetAPIOperator(userName),
}
return a.AccessAPINoPage("order/modifySellerDelivery", jdParams, nil, nil, nil)
}
// 拣货完成且商家自送接口(这个接口是商家本身配置为自送模式下才能调用的接口,如果启用了达达配送,是不能调用的)
// https://opendj.jd.com/staticnew/widgets/resources.html?groupid=169&apiid=0e08e71a45dc48b6a337e06a852ac33a
func (a *API) OrderSerllerDelivery(orderId string, userName string) (interface{}, error) {
jdParams := map[string]interface{}{
"orderId": orderId,
"operator": utils.GetAPIOperator(userName),
}
return a.AccessAPINoPage("bm/open/api/order/OrderSerllerDelivery", jdParams, nil, nil, nil)
}
// 商家自送,订单妥投接口
// https://opendj.jd.com/staticnew/widgets/resources.html?groupid=169&apiid=ecc80f06d35141979f4841f345001f74
func (a *API) DeliveryEndOrder(orderId string, userName string) (interface{}, error) {
jdParams := map[string]interface{}{
"orderId": orderId,
"operPin": utils.GetAPIOperator(userName),
"operTime": utils.GetCurTimeStr(),
}
return a.AccessAPINoPage("ocs/deliveryEndOrder", jdParams, nil, nil, nil)
}
//订单金额拆分接口
func (a *API) QueryOassBussMoney(orderId string) ([]interface{}, error) {
jdParams := map[string]interface{}{
"orderId": orderId,
}
result, err := a.AccessAPINoPage("oassBussService/queryOassBussMoney", jdParams, nil, nil, nil)
if err != nil {
return nil, err
}
return result.([]interface{}), nil
}