Files
baseapi/platformapi/jdshopapi/order.go
2020-06-29 14:45:54 +08:00

49 lines
1.7 KiB
Go

package jdshopapi
import (
"encoding/json"
"fmt"
)
//订单出库
//https://open.jd.com/home/home#/doc/api?apiCateId=55&apiId=1948&apiName=jingdong.pop.order.shipment
func (a *API) OrderShipment(orderID int64, logiCoprId, logiNo string) (err error) {
result, err := a.AccessAPI("jingdong.pop.order.shipment", prodURL, map[string]interface{}{
"orderId": orderID,
"logiCoprId": logiCoprId,
"logiNo": logiNo,
})
if err == nil {
if !result["jingdong_pop_order_shipment_responce"].(map[string]interface{})["sopjosshipment_result"].(map[string]interface{})["success"].(bool) {
return fmt.Errorf("OrderShipment error: %v", result["jingdong_pop_order_shipment_responce"].(map[string]interface{})["sopjosshipment_result"].(map[string]interface{})["chineseErrCode"])
}
}
return err
}
//获取商家物流公司
//https://open.jd.com/home/home#/doc/api?apiCateId=75&apiId=582&apiName=360buy.get.vender.all.delivery.company
func (a *API) GetDeliveryCompany() (result interface{}, err error) {
var params = map[string]interface{}{
"fields": "id,name",
}
data, _ := json.Marshal(params)
result, err = a.AccessAPI("360buy.get.vender.all.delivery.company", prodURL, map[string]interface{}{
"360buy_param_json": string(data),
})
if err == nil {
}
return result, err
}
//查询单个订单
//https://open.jd.com/home/home#/doc/api?apiCateId=55&apiId=4247&apiName=jingdong.pop.order.get
func (a *API) GetOrder(orderID int64) (err error) {
_, err = a.AccessAPI("jingdong.pop.order.get", prodURL, map[string]interface{}{
"order_id": orderID,
"optional_fields": "orderType,payType,orderTotalPrice,orderSellerPrice,orderPayment,freightPrice",
})
return err
}