159 lines
4.3 KiB
Go
159 lines
4.3 KiB
Go
package mtwmapi
|
|
|
|
import (
|
|
"git.rosy.net.cn/baseapi/utils"
|
|
)
|
|
|
|
const (
|
|
MaxBatchPullPhoneNumberLimit = 1000
|
|
)
|
|
|
|
// http://developer.waimai.meituan.com/home/doc/food/99
|
|
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
|
|
}
|
|
|
|
// 专快混配送转为商家自配送
|
|
func (a *API) OrderLogisticsChange2Self(orderID int64) (err error) {
|
|
_, err = a.AccessAPI("order/logistics/change/poi_self", false, map[string]interface{}{
|
|
KeyOrderID: orderID,
|
|
})
|
|
return err
|
|
}
|