66 lines
2.1 KiB
Go
66 lines
2.1 KiB
Go
package scheduler
|
||
|
||
import (
|
||
"errors"
|
||
"time"
|
||
|
||
"git.rosy.net.cn/jx-callback/business/model"
|
||
"git.rosy.net.cn/jx-callback/business/partner"
|
||
)
|
||
|
||
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
|
||
)
|
||
|
||
var (
|
||
ErrStatusIsNotOKForOperation = errors.New("当前状态操作无效")
|
||
ErrCanNotCreateAtLeastOneWaybill = errors.New("一个运单都不能创建")
|
||
ErrCanNotFindOrder = errors.New("不能找到订单(一般是由于事件错序)")
|
||
ErrCanNotFindWaybill = errors.New("不能找到运单(一般是由于事件错序)")
|
||
ErrOrderIsNotSolid = errors.New("订单是临时订单,不完整,不能用于创建运单")
|
||
)
|
||
|
||
type DeliveryPlatformHandlerInfo struct {
|
||
Handler partner.IDeliveryPlatformHandler
|
||
Use4CreateWaybill bool
|
||
}
|
||
|
||
type IScheduler interface {
|
||
RegisterPurchasePlatform(vendorID int, handler partner.IPurchasePlatformHandler)
|
||
RegisterDeliveryPlatform(vendorID int, handler partner.IDeliveryPlatformHandler, isUse4CreateWaybill bool)
|
||
|
||
// 以下是订单
|
||
OnOrderNew(order *model.GoodsOrder, isPending bool) (err error)
|
||
OnOrderStatusChanged(status *model.OrderStatus, isPending bool) (err error)
|
||
|
||
// 以下是运单
|
||
OnWaybillStatusChanged(bill *model.Waybill, isPending bool) (err error)
|
||
}
|
||
|
||
type BasePurchasePlatform struct {
|
||
}
|
||
|
||
func (p *BasePurchasePlatform) GetStatusActionTimeout(statusType, status int) time.Duration {
|
||
return 0
|
||
}
|