- first version of order schedule.
This commit is contained in:
@@ -13,26 +13,25 @@ var (
|
||||
)
|
||||
|
||||
var (
|
||||
ErrStatusIsNotOKForOperation = errors.New("当前状态操作无效")
|
||||
ErrStatusIsNotOKForOperation = errors.New("当前状态操作无效")
|
||||
ErrCanNotCreateAtLeastOneWaybill = errors.New("一个运单都不能创建")
|
||||
)
|
||||
|
||||
type StatusTimeoutAction struct {
|
||||
Action func(order *model.GoodsOrder) (err error)
|
||||
Timeout time.Duration
|
||||
}
|
||||
|
||||
type StatusConfig struct {
|
||||
handler PurchasePlatformHandler
|
||||
AutoStatusChange map[int]*StatusTimeoutAction
|
||||
type StatusActionConfig struct {
|
||||
Timeout time.Duration // 超时时间,为0的话表示立即执行
|
||||
TimeoutAction func(order *model.GoodsOrder) (err error) // 超时后需要执行的动作,为nil表示此状态不需要执行监控
|
||||
}
|
||||
|
||||
type PurchasePlatformHandler interface {
|
||||
AcceptOrRefuseOrder(order *model.GoodsOrder, isAcceptIt bool) (err error)
|
||||
PickedUpGoods(order *model.GoodsOrder) (err error)
|
||||
Swtich2SelfDeliver(order *model.GoodsOrder) (err error)
|
||||
SelfDeliverPickedUpGoods(order *model.GoodsOrder) (err error)
|
||||
|
||||
Swtich2SelfDeliver(vendorOrderID string) (err error)
|
||||
|
||||
SelfDeliverDelievering(order *model.GoodsOrder) (err error)
|
||||
SelfDeliverDelievered(order *model.GoodsOrder) (err error)
|
||||
|
||||
GetStatusActionConfig(status int) *StatusActionConfig
|
||||
}
|
||||
|
||||
type DeliveryPlatformHandler interface {
|
||||
@@ -41,6 +40,7 @@ type DeliveryPlatformHandler interface {
|
||||
}
|
||||
|
||||
type OrderManager interface {
|
||||
LoadOrder(vendorOrderID string, vendorID int) (order *model.GoodsOrder, err error)
|
||||
OnOrderStatusChanged(status *model.OrderStatus) (err error) // 此消息是否使用还不确定
|
||||
UpdateWaybillVendorID(bill *model.Waybill) (err error)
|
||||
}
|
||||
@@ -92,3 +92,18 @@ func (c *BaseScheduler) RegisterDeliveryPlatform(vendorID int, handler DeliveryP
|
||||
}
|
||||
c.DeliveryPlatformHandlers[vendorID] = handler
|
||||
}
|
||||
|
||||
func (c *BaseScheduler) GetPurchasePlatformFromVendorID(vendorID int) PurchasePlatformHandler {
|
||||
return c.PurchasePlatformHandlers[vendorID]
|
||||
}
|
||||
|
||||
func (c *BaseScheduler) GetDeliveryPlatformFromVendorID(vendorID int) DeliveryPlatformHandler {
|
||||
return c.DeliveryPlatformHandlers[vendorID]
|
||||
}
|
||||
|
||||
type BasePurchasePlatform struct {
|
||||
}
|
||||
|
||||
func (p *BasePurchasePlatform) GetStatusActionConfig(status int) *StatusActionConfig {
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user