- 设置美团外卖的自动拣货时间为4分钟
This commit is contained in:
@@ -792,7 +792,6 @@ func (s *DefScheduler) handleAutoAcceptOrder(orderID string, vendorID int, userM
|
||||
}
|
||||
|
||||
func (s *DefScheduler) mergeOrderStatusConfig(statusType, status int, purchaseVendorID int) (retVal *StatusActionConfig) {
|
||||
vendorTimeout := partner.GetPurchasePlatformFromVendorID(purchaseVendorID).GetStatusActionTimeout(statusType, status)
|
||||
s.locker.RLock()
|
||||
defer func() {
|
||||
s.locker.RUnlock()
|
||||
@@ -802,11 +801,12 @@ func (s *DefScheduler) mergeOrderStatusConfig(statusType, status int, purchaseVe
|
||||
return nil
|
||||
}
|
||||
retVal = &StatusActionConfig{}
|
||||
if defConfig != nil {
|
||||
*retVal = *defConfig
|
||||
}
|
||||
if vendorTimeout != 0 {
|
||||
retVal.Timeout = vendorTimeout
|
||||
*retVal = *defConfig
|
||||
if vendorActionParams := partner.GetPurchasePlatformFromVendorID(purchaseVendorID).GetStatusActionTimeout(statusType, status); vendorActionParams != nil {
|
||||
retVal.Timeout = vendorActionParams.Timeout
|
||||
if vendorActionParams.TimeoutGap >= 0 {
|
||||
retVal.TimeoutGap = vendorActionParams.TimeoutGap
|
||||
}
|
||||
}
|
||||
return retVal
|
||||
}
|
||||
|
||||
@@ -22,6 +22,11 @@ const (
|
||||
CancelWaybillReasonOther = 10
|
||||
)
|
||||
|
||||
type StatusActionParams struct {
|
||||
Timeout time.Duration // 超时时间,0在GetStatusActionConfig返回时表示不修改缺省
|
||||
TimeoutGap int // 以秒为单位的随机时间,0在GetStatusActionConfig返回时表示不修改缺省
|
||||
}
|
||||
|
||||
var (
|
||||
CancelWaybillReasonStrNotAcceptIntime = "没有及时抢单"
|
||||
CancelWaybillReasonStrSwitch2SelfFailed = "转自送失败"
|
||||
@@ -69,7 +74,7 @@ type IPurchasePlatformHandler interface {
|
||||
GetStatusFromVendorStatus(vendorStatus string) int
|
||||
Map2Order(orderData map[string]interface{}) (order *model.GoodsOrder)
|
||||
GetOrder(vendorOrderID string) (order *model.GoodsOrder, err error)
|
||||
GetStatusActionTimeout(statusType, status int) time.Duration
|
||||
GetStatusActionTimeout(statusType, status int) (params *StatusActionParams)
|
||||
|
||||
AcceptOrRefuseOrder(order *model.GoodsOrder, isAcceptIt bool, userName string) (err error)
|
||||
PickupGoods(order *model.GoodsOrder, isSelfDeilivery bool, userName string) (err error)
|
||||
@@ -147,8 +152,8 @@ type DeliveryPlatformHandlerInfo struct {
|
||||
type BasePurchasePlatform struct {
|
||||
}
|
||||
|
||||
func (p *BasePurchasePlatform) GetStatusActionTimeout(statusType, status int) time.Duration {
|
||||
return 0
|
||||
func (p *BasePurchasePlatform) GetStatusActionTimeout(statusType, status int) (params *StatusActionParams) {
|
||||
return params
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
||||
@@ -277,11 +277,13 @@ func (c *PurchaseHandler) callbackMsg2Status(msg *ebaiapi.CallbackMsg) (orderSta
|
||||
return orderStatus
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) GetStatusActionTimeout(statusType, status int) time.Duration {
|
||||
func (c *PurchaseHandler) GetStatusActionTimeout(statusType, status int) (params *partner.StatusActionParams) {
|
||||
if statusType == scheduler.TimerStatusTypeOrder && status == model.OrderStatusNew {
|
||||
return acceptOrderDelay // 饿百开了专送店的订单没有拣货状态,接单后就为拣货完成,所以要延迟接单,否则门店来不及备货
|
||||
params = &partner.StatusActionParams{ // 饿百开了专送店的订单没有拣货状态,接单后就为拣货完成,所以要延迟接单,否则门店来不及备货
|
||||
Timeout: acceptOrderDelay,
|
||||
}
|
||||
}
|
||||
return 0
|
||||
return params
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) getOrderStoreDeliveryType(order *model.GoodsOrder) (deliveryType int) {
|
||||
|
||||
@@ -317,11 +317,13 @@ func (c *PurchaseHandler) SelfDeliverDelievered(order *model.GoodsOrder, userNam
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) GetStatusActionTimeout(statusType, status int) time.Duration {
|
||||
func (c *PurchaseHandler) GetStatusActionTimeout(statusType, status int) (params *partner.StatusActionParams) {
|
||||
if statusType == scheduler.TimerStatusTypeOrder && status == model.OrderStatusNew {
|
||||
return acceptOrderDelay // 饿了么开了专送店的订单没有拣货状态,接单后就为拣货完成,所以要延迟接单,否则门店来不及备货
|
||||
params = &partner.StatusActionParams{ // 饿了么开了专送店的订单没有拣货状态,接单后就为拣货完成,所以要延迟接单,否则门店来不及备货
|
||||
Timeout: acceptOrderDelay,
|
||||
}
|
||||
}
|
||||
return 0
|
||||
return params
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) RefreshRealMobile(ctx *jxcontext.Context, fromTime, toTime time.Time, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/mtwmapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxcallback/scheduler"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
@@ -20,6 +21,11 @@ const (
|
||||
FakeMsgTypeOrderDelivering = "orderDelivering"
|
||||
)
|
||||
|
||||
const (
|
||||
pickupOrderDelay = 4 * time.Minute
|
||||
pickupOrderGap = 20
|
||||
)
|
||||
|
||||
var (
|
||||
VendorStatus2StatusMap = map[string]int{
|
||||
mtwmapi.OrderStatusUserCommitted: model.OrderStatusUnknown,
|
||||
@@ -259,3 +265,13 @@ func getTimeFromTimestamp(timeStamp int64) time.Time {
|
||||
func (c *PurchaseHandler) RefreshRealMobile(ctx *jxcontext.Context, fromTime, toTime time.Time, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
return hint, err
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) GetStatusActionTimeout(statusType, status int) (params *partner.StatusActionParams) {
|
||||
if statusType == scheduler.TimerStatusTypeOrder && status == model.OrderStatusAccepted {
|
||||
params = &partner.StatusActionParams{ // 美团外卖要求在5分钟内拣货,不然订单会被取消
|
||||
Timeout: pickupOrderDelay,
|
||||
TimeoutGap: pickupOrderGap,
|
||||
}
|
||||
}
|
||||
return params
|
||||
}
|
||||
|
||||
@@ -168,10 +168,6 @@ func (p *PurchaseHandler) Map2Order(orderData map[string]interface{}) (order *mo
|
||||
return order
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) GetStatusActionTimeout(statusType, status int) time.Duration {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) AcceptOrRefuseOrder(order *model.GoodsOrder, isAcceptIt bool, userName string) (err error) {
|
||||
if !isAcceptIt {
|
||||
if globals.EnableStoreWrite && globals.EnableWscStoreWrite {
|
||||
|
||||
Reference in New Issue
Block a user