57 lines
2.0 KiB
Go
57 lines
2.0 KiB
Go
package scheduler
|
||
|
||
import (
|
||
"errors"
|
||
|
||
"git.rosy.net.cn/jx-callback/business/model"
|
||
)
|
||
|
||
const (
|
||
StoreDeliveryTypeCrowdSourcing = 0 //缺省,平台众包配送,可转自送
|
||
StoreDeliveryTypeByPlatform = 1 //平台专送
|
||
StoreDeliveryTypeByStore = 2 //完全门店自送
|
||
)
|
||
|
||
const (
|
||
TimerStatusTypeUnknown = -1
|
||
TimerStatusTypeOrder = 0
|
||
TimerStatusTypeWaybill = 1
|
||
)
|
||
|
||
const (
|
||
TimerTypeNoOverride = 0 // GetStatusActionConfig 返回表示不修改缺省配置
|
||
TimerTypeByPass = 1
|
||
TimerTypeBaseNow = 2
|
||
TimerTypeBaseStatusTime = 3
|
||
TimerTypeBaseExpectedDeliveredTime = 4 // 如果是定时达,以expected delivery time倒推的时间当成statusTime(之后与TimerTypeBaseStatusTime一样),否则与TimerTypeBaseStatusTime相同
|
||
)
|
||
|
||
var (
|
||
CurrentScheduler IScheduler
|
||
StoreDeliveryTypeName = map[int]string{
|
||
StoreDeliveryTypeCrowdSourcing: "平台众包",
|
||
StoreDeliveryTypeByPlatform: "平台专送",
|
||
StoreDeliveryTypeByStore: "商家自送",
|
||
}
|
||
)
|
||
|
||
var (
|
||
ErrOrderStatusIsNotSuitable4CurOperation = errors.New("订单状态不适合当前操作")
|
||
ErrOrderStatusAlreadySatisfyCurOperation = errors.New("订单当前状态已满足当前操作")
|
||
|
||
ErrCanNotCreateAtLeastOneWaybill = errors.New("一个运单都不能创建")
|
||
ErrCanNotFindOrder = errors.New("不能找到订单(一般是由于事件错序)")
|
||
ErrCanNotFindWaybill = errors.New("不能找到运单(一般是由于事件错序)")
|
||
ErrOrderIsNotSolid = errors.New("订单是临时订单,不完整,不能用于创建运单")
|
||
ErrDeliverProviderWrong = errors.New("快递商不存在或不能用于创建运单")
|
||
)
|
||
|
||
type IScheduler interface {
|
||
// 以下是订单
|
||
OnOrderNew(order *model.GoodsOrder, isPending bool) (err error)
|
||
OnOrderStatusChanged(status *model.OrderStatus, isPending bool) (err error)
|
||
|
||
// 以下是运单
|
||
OnWaybillStatusChanged(bill *model.Waybill, isPending bool) (err error)
|
||
}
|