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