60 lines
1.9 KiB
Go
60 lines
1.9 KiB
Go
package weimobapi
|
|
|
|
import (
|
|
"github.com/fatih/structs"
|
|
)
|
|
|
|
const (
|
|
OrderStatusWait4Pay = 0 // 待支付
|
|
OrderStatusPayed = 1 // 已付款,待发货
|
|
OrderStatusDelivering = 2 // 已发货
|
|
OrderStatusFinished = 3 // 已完成
|
|
OrderStatusCanceled = 4 // 已取消
|
|
)
|
|
|
|
type DeliveryOrderItem struct {
|
|
ItemId int64 `json:"itemId"`
|
|
SkuId int64 `json:"skuId"`
|
|
SkuNum int `json:"skuNum"`
|
|
}
|
|
|
|
type DeliveryOrder struct {
|
|
OrderNo int64 `json:"orderNo"`
|
|
DeliveryNo string `json:"deliveryNo"`
|
|
DeliveryCompanyCode string `json:"deliveryCompanyCode"`
|
|
DeliveryCompanyName string `json:"deliveryCompanyName"`
|
|
IsNeedLogistics bool `json:"isNeedLogistics"`
|
|
IsSplitPackage bool `json:"isSplitPackage"`
|
|
DeliveryRemark string `json:"deliveryRemark"`
|
|
DeliveryOrderItemList []*DeliveryOrderItem `json:"deliveryOrderItemList"`
|
|
}
|
|
|
|
func (a *API) QueryOrderDetail(orderNo int64, needInvoiceInfo bool) (retVal map[string]interface{}, err error) {
|
|
result, err := a.AccessAPI("order/queryOrderDetail", map[string]interface{}{
|
|
"orderNo": orderNo,
|
|
"needInvoiceInfo": needInvoiceInfo,
|
|
})
|
|
if err == nil {
|
|
return result.(map[string]interface{}), nil
|
|
}
|
|
return nil, err
|
|
}
|
|
|
|
func (a *API) CancelOrder(orderNo int64, specificCancelReason string) (err error) {
|
|
apiParams := map[string]interface{}{
|
|
"orderNo": orderNo,
|
|
}
|
|
if specificCancelReason != "" {
|
|
apiParams["specificCancelReason"] = specificCancelReason
|
|
}
|
|
_, err = a.AccessAPI("order/cancelOrder", apiParams)
|
|
return err
|
|
}
|
|
|
|
func (a *API) DeliveryOrder(orderDeliveryInfo *DeliveryOrder) (err error) {
|
|
apiParams := structs.Map(orderDeliveryInfo)
|
|
// baseapi.SugarLogger.Debug(utils.Format4Output(apiParams, false))
|
|
_, err = a.AccessAPI("order/deliveryOrder", apiParams)
|
|
return err
|
|
}
|