- autopickup config to store.
This commit is contained in:
@@ -34,7 +34,7 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type WatchOrderInfo struct {
|
type WatchOrderInfo struct {
|
||||||
isNeedAutoPickup bool
|
autoPickupTimeoutMinute int // 0表示禁用,1表示用缺省值time2AutoPickupMin,其它表示分钟数
|
||||||
storeDeliveryType int
|
storeDeliveryType int
|
||||||
isNeed3rdDelivery bool
|
isNeed3rdDelivery bool
|
||||||
supported3rdCarriers []int
|
supported3rdCarriers []int
|
||||||
@@ -65,7 +65,7 @@ type DefScheduler struct {
|
|||||||
|
|
||||||
func NewWatchOrderInfo(order *model.GoodsOrder) (retVal *WatchOrderInfo) {
|
func NewWatchOrderInfo(order *model.GoodsOrder) (retVal *WatchOrderInfo) {
|
||||||
retVal = &WatchOrderInfo{
|
retVal = &WatchOrderInfo{
|
||||||
isNeedAutoPickup: true,
|
autoPickupTimeoutMinute: 1,
|
||||||
isNeed3rdDelivery: false,
|
isNeed3rdDelivery: false,
|
||||||
storeDeliveryType: scheduler.StoreDeliveryTypeCrowdSourcing,
|
storeDeliveryType: scheduler.StoreDeliveryTypeCrowdSourcing,
|
||||||
waybills: map[int]*model.Waybill{},
|
waybills: map[int]*model.Waybill{},
|
||||||
@@ -95,7 +95,7 @@ func (s *WatchOrderInfo) updateOrderStoreFeature(order *model.GoodsOrder) (err e
|
|||||||
utils.CallFuncLogError(func() error {
|
utils.CallFuncLogError(func() error {
|
||||||
err = db.Read(storefeature, "Id")
|
err = db.Read(storefeature, "Id")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
s.isNeedAutoPickup = (storefeature.Autopickup != 0)
|
s.autoPickupTimeoutMinute = int(storefeature.Autopickup)
|
||||||
if order.VendorID == model.VendorIDELM {
|
if order.VendorID == model.VendorIDELM {
|
||||||
s.storeDeliveryType = int(storefeature.ElmDeliveryType)
|
s.storeDeliveryType = int(storefeature.ElmDeliveryType)
|
||||||
} else if order.VendorID == model.VendorIDJD {
|
} else if order.VendorID == model.VendorIDJD {
|
||||||
@@ -159,10 +159,10 @@ func init() {
|
|||||||
},
|
},
|
||||||
model.OrderStatusAccepted: &StatusActionConfig{ // 自动拣货
|
model.OrderStatusAccepted: &StatusActionConfig{ // 自动拣货
|
||||||
TimerType: scheduler.TimerTypeBaseExpectedDeliveredTime,
|
TimerType: scheduler.TimerTypeBaseExpectedDeliveredTime,
|
||||||
Timeout: time2AutoPickupMin,
|
Timeout: time2AutoPickupMin, // 此值会被门店设置覆盖
|
||||||
TimeoutGap: time2AutoPickupGap,
|
TimeoutGap: time2AutoPickupGap,
|
||||||
TimeoutAction: func(savedOrderInfo *WatchOrderInfo) (err error) {
|
TimeoutAction: func(savedOrderInfo *WatchOrderInfo) (err error) {
|
||||||
if savedOrderInfo.isNeedAutoPickup {
|
if savedOrderInfo.autoPickupTimeoutMinute > 0 {
|
||||||
return sch.autoPickupGood(savedOrderInfo.order)
|
return sch.autoPickupGood(savedOrderInfo.order)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@@ -561,6 +561,10 @@ func (s *DefScheduler) resetTimer(savedOrderInfo *WatchOrderInfo, bill *model.Wa
|
|||||||
default:
|
default:
|
||||||
panic("TimerType is wrong!!!")
|
panic("TimerType is wrong!!!")
|
||||||
}
|
}
|
||||||
|
// 对于自动拣货,以订单中的设置为准
|
||||||
|
if statusType == scheduler.TimerStatusTypeOrder && status == model.OrderStatusAccepted && savedOrderInfo.autoPickupTimeoutMinute > 1 {
|
||||||
|
timeout = time.Duration(savedOrderInfo.autoPickupTimeoutMinute) * time.Minute
|
||||||
|
}
|
||||||
if config.TimeoutGap != 0 {
|
if config.TimeoutGap != 0 {
|
||||||
timeout += time.Duration(rand.Int31n(int32(config.TimeoutGap))) * time.Second
|
timeout += time.Duration(rand.Int31n(int32(config.TimeoutGap))) * time.Second
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user