- 对于饿百与美团外卖订单,设置其PickDeadline

This commit is contained in:
gazebo
2019-03-28 14:00:08 +08:00
parent 34edcda30c
commit cd99fc3e14
4 changed files with 23 additions and 14 deletions

View File

@@ -26,7 +26,7 @@ const (
time2Schedule3rdCarrier = 20 // 收到平台方自有配送的新运单消息后等待创建三方配送运单的时间分钟如果是定时达会再根据ExpectedDeliveredTime与dingShiDaAheadTime做调整
// time2Schedule3rdCarrierGap4OrderStatus = 3 * time.Minute // 京东要求是运单状态为待抢单且超时5分钟但为了防止没有运单事件所以就拣货完成事件开始算添加3分钟
time2AutoPickupMin = 15 * time.Minute // 自动拣货等待时间这个只有在没有PickDeadline信息才有用否则会根据PickDeadline设置
time2AutoPickupGap = 5 * 60 //随机5分钟
time2AutoPickupGap = 1 * 60 //随机1分钟
// 把pending order timerout 在-pendingOrderTimerMinMinSecond至pendingOrderTimerMaxSecond映射到pendingOrderTimerMinSecond至pendingOrderTimerMaxSecond
pendingOrderTimerMinMinSecond = 5 * 60 // 5分钟
@@ -734,7 +734,7 @@ func (s *DefScheduler) resetTimer(savedOrderInfo *WatchOrderInfo, bill *model.Wa
panic("TimerType is wrong!!!")
}
if config.TimeoutGap != 0 {
timeout += time.Duration(rand.Int31n(int32(config.TimeoutGap))) * time.Second
timeout += time.Duration(rand.Intn(int(config.TimeoutGap))) * time.Second
}
if isPending && timeout < pendingOrderTimerMaxSecond*time.Second { // 如果是PENDING的订单则将其分布到2--5秒内让后续事件有机会执行
timeout = time.Duration(jxutils.MapValue2Scope(int64(timeout), -pendingOrderTimerMinMinSecond*1000, pendingOrderTimerMaxSecond*1000, pendingOrderTimerMinSecond*1000, pendingOrderTimerMaxSecond*1000)) * time.Millisecond

View File

@@ -4,6 +4,7 @@ import (
"testing"
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/globals/refutil"
)
func TestObjFieldByName(t *testing.T) {
@@ -14,27 +15,27 @@ func TestObjFieldByName(t *testing.T) {
ID: 1,
Name: "hello",
}
if GetObjFieldByName(kk, "ID").(int8) != 1 {
if refutil.GetObjFieldByName(kk, "ID").(int8) != 1 {
t.Fatal("value is not ok")
}
if GetObjFieldByName(kk, "Name").(string) != "hello" {
if refutil.GetObjFieldByName(kk, "Name").(string) != "hello" {
t.Fatal("value is not ok")
}
pKK := &kk
if GetObjFieldByName(pKK, "ID").(int8) != 1 {
if refutil.GetObjFieldByName(pKK, "ID").(int8) != 1 {
t.Fatal("value is not ok")
}
if GetObjFieldByName(pKK, "Name").(string) != "hello" {
if refutil.GetObjFieldByName(pKK, "Name").(string) != "hello" {
t.Fatal("value is not ok")
}
SetObjFieldByName(pKK, "ID", int8(100))
SetObjFieldByName(pKK, "Name", "world")
if GetObjFieldByName(pKK, "ID").(int8) != 100 {
refutil.SetObjFieldByName(pKK, "ID", int8(100))
refutil.SetObjFieldByName(pKK, "Name", "world")
if refutil.GetObjFieldByName(pKK, "ID").(int8) != 100 {
t.Fatal("value is not ok")
}
if GetObjFieldByName(pKK, "Name").(string) != "world" {
if refutil.GetObjFieldByName(pKK, "Name").(string) != "world" {
t.Fatal("value is not ok")
}
t.Log(utils.Format4Output(pKK, false))

View File

@@ -21,8 +21,9 @@ import (
const (
// acceptOrderDelay = 180 * time.Second
pickupOrderDelay = 240 * time.Second
pickupOrderGap = 30
pickupOrderDelay = 240 * time.Second
pickupOrderGap = 20
callDeliveryDelay = 10 * time.Minute
callDeliveryDelayGap = 30
// fakePickedUp = "9527"
@@ -92,6 +93,9 @@ func (p *PurchaseHandler) Map2Order(orderData map[string]interface{}) (order *mo
ActualPayPrice: utils.MustInterface2Int64(orderMap["user_fee"]),
Skus: []*model.OrderSku{},
}
if jxutils.IsTimeEmpty(order.PickDeadline) && !jxutils.IsTimeEmpty(order.StatusTime) {
order.PickDeadline = order.StatusTime.Add(pickupOrderDelay /* + time.Duration(rand.Intn(pickupOrderGap))*time.Second*/)
}
if jxutils.IsMobileFake(order.ConsigneeMobile) {
if mobileInfo, err := api.EbaiAPI.OrderPrivateInfo(vendorOrderID); err == nil {
order.ConsigneeMobile = mobileInfo.ShortNumber

View File

@@ -22,8 +22,9 @@ const (
)
const (
pickupOrderDelay = 4 * time.Minute
pickupOrderGap = 20
pickupOrderDelay = 240 * time.Second
pickupOrderGap = 20
callDeliveryDelay = 10 * time.Minute
callDeliveryDelayGap = 30
)
@@ -91,6 +92,9 @@ func (p *PurchaseHandler) Map2Order(orderData map[string]interface{}) (order *mo
ActualPayPrice: jxutils.StandardPrice2Int(utils.MustInterface2Float64(result["total"])),
Skus: []*model.OrderSku{},
}
if jxutils.IsTimeEmpty(order.PickDeadline) && !jxutils.IsTimeEmpty(order.StatusTime) {
order.PickDeadline = order.StatusTime.Add(pickupOrderDelay /*+ time.Duration(rand.Intn(pickupOrderGap))*time.Second*/)
}
order.Status = p.GetStatusFromVendorStatus(order.VendorStatus)
if jxutils.IsTimeEmpty(order.ExpectedDeliveredTime) {
order.BusinessType = model.BusinessTypeImmediate