+CanSwitch2SelfDeliver,美团预定单是不能转自送的
减小转自送失败尝试时间间隙至3秒(以免出现不能取消三方运单的情况)
This commit is contained in:
@@ -35,6 +35,9 @@ const (
|
|||||||
second2AutoPickupGap = 60 //随机60秒
|
second2AutoPickupGap = 60 //随机60秒
|
||||||
time2AutoPickupAhead = 20 * time.Second // 有最后拣货时间的提前值
|
time2AutoPickupAhead = 20 * time.Second // 有最后拣货时间的提前值
|
||||||
|
|
||||||
|
switch2SelfDeliverRetryGap = 3 * time.Second // 转自送失败尝试的时间间隙
|
||||||
|
switch2SelfDeliverRetryCount = 2 // 转自送失败尝试次数
|
||||||
|
|
||||||
// (把pending order timerout 在-pendingOrderTimerMinMinSecond至pendingOrderTimerMaxSecond映射到pendingOrderTimerMinSecond至pendingOrderTimerMaxSecond)
|
// (把pending order timerout 在-pendingOrderTimerMinMinSecond至pendingOrderTimerMaxSecond映射到pendingOrderTimerMinSecond至pendingOrderTimerMaxSecond)
|
||||||
pendingOrderTimerMinMinSecond = 5 * 60 // 5分钟
|
pendingOrderTimerMinMinSecond = 5 * 60 // 5分钟
|
||||||
pendingOrderTimerMinSecond = 2
|
pendingOrderTimerMinSecond = 2
|
||||||
@@ -296,11 +299,13 @@ func init() {
|
|||||||
ShouldSetTimer: func(savedOrderInfo *WatchOrderInfo, bill *model.Waybill) bool {
|
ShouldSetTimer: func(savedOrderInfo *WatchOrderInfo, bill *model.Waybill) bool {
|
||||||
// 饿百转自送的时机不太清楚,暂时禁用超时转自送,在饿百运单取消时还是会自动创建
|
// 饿百转自送的时机不太清楚,暂时禁用超时转自送,在饿百运单取消时还是会自动创建
|
||||||
// 非自配送商家使用
|
// 非自配送商家使用
|
||||||
|
order := savedOrderInfo.order
|
||||||
return savedOrderInfo.isDeliveryCompetition &&
|
return savedOrderInfo.isDeliveryCompetition &&
|
||||||
model.IsOrderDeliveryByPlatform(savedOrderInfo.order) &&
|
model.IsOrderDeliveryByPlatform(order) &&
|
||||||
savedOrderInfo.order.VendorID == bill.WaybillVendorID &&
|
order.VendorID == bill.WaybillVendorID &&
|
||||||
savedOrderInfo.order.VendorID != model.VendorIDEBAI &&
|
order.VendorID != model.VendorIDEBAI &&
|
||||||
savedOrderInfo.order.DeliveryType != model.OrderDeliveryTypeSelfTake
|
order.DeliveryType != model.OrderDeliveryTypeSelfTake &&
|
||||||
|
isOrderCanSwitch2SelfDeliver(order)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
//*
|
//*
|
||||||
@@ -317,10 +322,11 @@ func init() {
|
|||||||
// 非自配送商家使用
|
// 非自配送商家使用
|
||||||
return (order.Status >= model.OrderStatusFinishedPickup && order.Status < model.OrderStatusEndBegin) &&
|
return (order.Status >= model.OrderStatusFinishedPickup && order.Status < model.OrderStatusEndBegin) &&
|
||||||
savedOrderInfo.isDeliveryCompetition &&
|
savedOrderInfo.isDeliveryCompetition &&
|
||||||
savedOrderInfo.order.VendorID == bill.WaybillVendorID &&
|
order.VendorID == bill.WaybillVendorID &&
|
||||||
model.IsOrderDeliveryByPlatform(savedOrderInfo.order) &&
|
model.IsOrderDeliveryByPlatform(order) &&
|
||||||
order.VendorID == model.VendorIDEBAI &&
|
order.VendorID == model.VendorIDEBAI &&
|
||||||
savedOrderInfo.order.DeliveryType != model.OrderDeliveryTypeSelfTake
|
order.DeliveryType != model.OrderDeliveryTypeSelfTake &&
|
||||||
|
isOrderCanSwitch2SelfDeliver(order)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
//*/
|
//*/
|
||||||
@@ -511,7 +517,7 @@ func (s *DefScheduler) OnWaybillStatusChanged(bill *model.Waybill, isPending boo
|
|||||||
}
|
}
|
||||||
s.notify3rdPartyWaybill(order, bill, isBillAlreadyCandidate)
|
s.notify3rdPartyWaybill(order, bill, isBillAlreadyCandidate)
|
||||||
} else {
|
} else {
|
||||||
s.swtich2SelfDeliverWithRetry(savedOrderInfo, bill, 2, 10*time.Second)
|
s.swtich2SelfDeliverWithRetry(savedOrderInfo, bill, switch2SelfDeliverRetryCount, switch2SelfDeliverRetryGap)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if !s.isBillCandidate(order, bill) && bill.WaybillVendorID != order.VendorID {
|
} else if !s.isBillCandidate(order, bill) && bill.WaybillVendorID != order.VendorID {
|
||||||
@@ -1276,3 +1282,11 @@ func (s *DefScheduler) notify3rdPartyWaybill(order *model.GoodsOrder, bill *mode
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isOrderCanSwitch2SelfDeliver(order *model.GoodsOrder) (isCan bool) {
|
||||||
|
isCan = true
|
||||||
|
if handler := partner.GetPurchaseOrderHandlerFromVendorID(order.VendorID); handler != nil {
|
||||||
|
isCan, _ = handler.CanSwitch2SelfDeliver(order)
|
||||||
|
}
|
||||||
|
return isCan
|
||||||
|
}
|
||||||
|
|||||||
@@ -192,16 +192,18 @@ func TestSyncAct(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestForceUpdateVendorPrice(t *testing.T) {
|
func TestForceUpdateVendorPrice(t *testing.T) {
|
||||||
_, err := ForceUpdateVendorPrice(jxcontext.AdminCtx, model.VendorIDJD, model.ActSkuDirectDown, []*ActStoreSkuParam{
|
hint, err := ForceUpdateVendorPrice(jxcontext.AdminCtx, model.VendorIDJD, model.ActSkuDirectDown, []*ActStoreSkuParam{
|
||||||
&ActStoreSkuParam{
|
&ActStoreSkuParam{
|
||||||
ActStoreSku: model.ActStoreSku{
|
ActStoreSku: model.ActStoreSku{
|
||||||
StoreID: 100118,
|
StoreID: 100118,
|
||||||
SkuID: 22509,
|
SkuID: 22509,
|
||||||
|
ActPrice: 9900,
|
||||||
},
|
},
|
||||||
ActualActPrice: 9900,
|
VendorPrice: 19900,
|
||||||
},
|
},
|
||||||
}, false)
|
}, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
t.Log(hint)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,8 +36,10 @@ type DeliveryHandler struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
curDeliveryHandler = new(DeliveryHandler)
|
if api.MtpsAPI != nil {
|
||||||
partner.RegisterDeliveryPlatform(curDeliveryHandler, true)
|
curDeliveryHandler = new(DeliveryHandler)
|
||||||
|
partner.RegisterDeliveryPlatform(curDeliveryHandler, true)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *DeliveryHandler) GetVendorID() int {
|
func (c *DeliveryHandler) GetVendorID() int {
|
||||||
|
|||||||
@@ -190,6 +190,10 @@ func (p *BasePurchasePlatform) GetStatusActionTimeout(order *model.GoodsOrder, s
|
|||||||
return params
|
return params
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *BasePurchasePlatform) CanSwitch2SelfDeliver(order *model.GoodsOrder) (isCan bool, err error) {
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
PurchasePlatformHandlers = make(map[int]IPurchasePlatformHandler)
|
PurchasePlatformHandlers = make(map[int]IPurchasePlatformHandler)
|
||||||
PurchaseOrderHandlers = make(map[int]IPurchasePlatformOrderHandler)
|
PurchaseOrderHandlers = make(map[int]IPurchasePlatformOrderHandler)
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ type IPurchasePlatformOrderHandler interface {
|
|||||||
CallCourier(ctx *jxcontext.Context, order *model.GoodsOrder) (err error) // 取货失败后再次招唤平台配送
|
CallCourier(ctx *jxcontext.Context, order *model.GoodsOrder) (err error) // 取货失败后再次招唤平台配送
|
||||||
ConfirmReceiveGoods(ctx *jxcontext.Context, order *model.GoodsOrder) (err error) // 投递失败后确认收到退货
|
ConfirmReceiveGoods(ctx *jxcontext.Context, order *model.GoodsOrder) (err error) // 投递失败后确认收到退货
|
||||||
|
|
||||||
|
// 是否可能转商家自送
|
||||||
|
CanSwitch2SelfDeliver(order *model.GoodsOrder) (isCan bool, err error)
|
||||||
// 将订单从购物平台配送转为自送
|
// 将订单从购物平台配送转为自送
|
||||||
Swtich2SelfDeliver(order *model.GoodsOrder, userName string) (err error)
|
Swtich2SelfDeliver(order *model.GoodsOrder, userName string) (err error)
|
||||||
|
|
||||||
|
|||||||
@@ -468,6 +468,11 @@ func (p *PurchaseHandler) ConfirmReceiveGoods(ctx *jxcontext.Context, order *mod
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 美团预定单不能转商家自送
|
||||||
|
func (c *PurchaseHandler) CanSwitch2SelfDeliver(order *model.GoodsOrder) (isCan bool, err error) {
|
||||||
|
return order.BusinessType != model.BusinessTypeDingshida, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (c *PurchaseHandler) Swtich2SelfDeliver(order *model.GoodsOrder, userName string) (err error) {
|
func (c *PurchaseHandler) Swtich2SelfDeliver(order *model.GoodsOrder, userName string) (err error) {
|
||||||
globals.SugarLogger.Debugf("mtwm Swtich2SelfDeliver orderID:%s", order.VendorOrderID)
|
globals.SugarLogger.Debugf("mtwm Swtich2SelfDeliver orderID:%s", order.VendorOrderID)
|
||||||
if globals.EnableMtwmStoreWrite {
|
if globals.EnableMtwmStoreWrite {
|
||||||
|
|||||||
Reference in New Issue
Block a user