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
)

var (
	CurrentScheduler IScheduler
)

var (
	ErrOrderStatusIsNotSuitable4CurOperation     = errors.New("订单锁定或状态不适合当前操作")
	ErrOrderStatusAlreadySatisfyCurOperation     = errors.New("订单当前状态已满足当前操作")
	ErrOrderStatusShippedCurOperation            = errors.New("订单已发货，不允许再次执行发货")
	ErrOrderStatusAlreadySatisfyCurOperationELM  = errors.New("无需切自配送")
	ErrOrderStatusAlreadySatisfyCurOperationMTWM = errors.New("非专送、快送、混合送订单不允许调用此接口 level:0, code:1047")

	ErrCanNotCreateAtLeastOneWaybill = errors.New("一个运单都不能创建")
	ErrCanNotFindOrder               = errors.New("不能找到订单（一般是由于事件错序）")
	ErrCanNotFindWaybill             = errors.New("不能找到运单（一般是由于事件错序）")
	ErrOrderIsNotSolid               = errors.New("订单是临时订单，不完整，不能用于创建运单")
	ErrDeliverProviderWrong          = errors.New("快递商不存在或不能用于创建运单")
)

type IScheduler interface {
	// 以下是订单
	OnOrderNew(order *model.GoodsOrder, isPending bool, isAuto bool) (err error)
	OnOrderStatusChanged(order *model.GoodsOrder, status *model.OrderStatus, isPending bool) (err error)

	// 以下是运单
	OnWaybillStatusChanged(bill *model.Waybill, isPending bool) (err error)

	// 以下是售后单
	OnAfsOrderNew(order *model.AfsOrder, isPending bool) (err error)
	OnAfsOrderStatusChanged(order *model.AfsOrder, status *model.OrderStatus, isPending bool) (err error)
}
