Files
baseapi/platformapi/mtwmapi/order.go
2019-03-21 11:33:46 +08:00

150 lines
3.7 KiB
Go

package mtwmapi
import (
"git.rosy.net.cn/baseapi/utils"
)
const (
MaxBatchPullPhoneNumberLimit = 1000
)
const (
OrderStatusUserCommitted = "1"
OrderStatusNew = "2"
OrderStatusReceived = "3"
OrderStatusAccepted = "4"
OrderStatusDelivering = "6"
OrderStatusDelivered = "7"
OrderStatusFinished = "8"
OrderStatusCanceled = "9"
)
const (
WaybillStatusWait4Delivery = "0"
WaybillStatusAccepted = "10"
WaybillStatusCourierArrived = "15"
WaybillStatusPickedup = "20"
WaybillStatusDelivered = "40"
WaybillStatusCanceled = "100"
)
const (
NotifyTypeSuccess = "agree"
)
func (a *API) OrderReceived(orderID int64) (err error) {
_, err = a.AccessAPI("order/poi_received", true, map[string]interface{}{
KeyOrderID: orderID,
})
return err
}
func (a *API) OrderConfirm(orderID int64) (err error) {
_, err = a.AccessAPI("order/confirm", true, map[string]interface{}{
KeyOrderID: orderID,
})
return err
}
func (a *API) OrderCancel(orderID int64) (err error) {
_, err = a.AccessAPI("order/cancel", true, map[string]interface{}{
KeyOrderID: orderID,
})
return err
}
func (a *API) OrderDelivering(orderID int64) (err error) {
_, err = a.AccessAPI("order/delivering", true, map[string]interface{}{
KeyOrderID: orderID,
})
return err
}
func (a *API) OrderArrived(orderID int64) (err error) {
_, err = a.AccessAPI("order/arrived", true, map[string]interface{}{
KeyOrderID: orderID,
})
return err
}
func (a *API) OrderRefundAgree(orderID int64, reason string) (err error) {
_, err = a.AccessAPI("order/refund/agree", true, map[string]interface{}{
KeyOrderID: orderID,
"reason": reason,
})
return err
}
func (a *API) OrderRefundReject(orderID int64, reason string) (err error) {
_, err = a.AccessAPI("order/refund/reject", true, map[string]interface{}{
KeyOrderID: orderID,
"reason": reason,
})
return err
}
func (a *API) OrderViewStatus(orderID int64) (status int, err error) {
result, err := a.AccessAPI("order/viewstatus", true, map[string]interface{}{
KeyOrderID: orderID,
})
if err == nil {
// baseapi.SugarLogger.Debug(result)
return int(utils.MustInterface2Int64(result.(map[string]interface{})["status"])), nil
}
return 0, err
}
func (a *API) OrderGetOrderDetail(orderID int64, isMTLogistics bool) (orderInfo map[string]interface{}, err error) {
params := map[string]interface{}{
KeyOrderID: orderID,
}
if isMTLogistics {
params["is_mt_logistics"] = 1
}
result, err := a.AccessAPI("order/getOrderDetail", true, params)
if err == nil {
return result.(map[string]interface{}), nil
}
return nil, err
}
func (a *API) OrderLogisticsPush(orderID int64, reason string) (err error) {
_, err = a.AccessAPI("order/logistics/push", true, map[string]interface{}{
KeyOrderID: orderID,
})
return err
}
func (a *API) OrderLogisticsCancel(orderID int64, reason string) (err error) {
_, err = a.AccessAPI("order/logistics/cancel", true, map[string]interface{}{
KeyOrderID: orderID,
})
return err
}
func (a *API) OrderLogisticsStatus(orderID int64) (status map[string]interface{}, err error) {
result, err := a.AccessAPI("order/logistics/status", true, map[string]interface{}{
KeyOrderID: orderID,
})
if err == nil {
return result.(map[string]interface{}), nil
}
return nil, err
}
// limit最大为MaxBatchPullPhoneNumberLimit = 1000
func (a *API) OrderBatchPullPhoneNumber(poiCode string, offset, limit int) (realNumberList []map[string]interface{}, err error) {
params := map[string]interface{}{
"offset": offset,
"limit": limit,
}
if poiCode != "" {
params[KeyAppPoiCode] = poiCode
}
result, err := a.AccessAPI("order/batchPullPhoneNumber", false, params)
if err == nil {
return utils.Slice2MapSlice(result.([]interface{})), nil
}
return nil, err
}