- replace all goroutine and AfterFunc with recover version
This commit is contained in:
@@ -291,9 +291,9 @@ func (c *PurchaseHandler) postFakeFinishedPickupMsg(vendorOrderID string) {
|
||||
"order_id": vendorOrderID,
|
||||
},
|
||||
}
|
||||
go func() {
|
||||
utils.CallFuncAsync(func() {
|
||||
OnCallbackMsg(msg)
|
||||
}()
|
||||
})
|
||||
}
|
||||
|
||||
func getTimeFromTimestampStr(sendTime string) time.Time {
|
||||
|
||||
@@ -21,14 +21,14 @@ const (
|
||||
)
|
||||
|
||||
func (c *PurchaseHandler) StartRefreshComment() {
|
||||
time.AfterFunc(5*time.Second, func() {
|
||||
utils.AfterFuncWithRecover(5*time.Second, func() {
|
||||
c.refreshCommentOnce()
|
||||
})
|
||||
}
|
||||
|
||||
func (c *PurchaseHandler) refreshCommentOnce() {
|
||||
c.RefreshComment(time.Now().Add(-RefreshCommentTime), time.Now())
|
||||
time.AfterFunc(RefreshCommentTimeInterval, func() {
|
||||
utils.AfterFuncWithRecover(RefreshCommentTimeInterval, func() {
|
||||
c.refreshCommentOnce()
|
||||
})
|
||||
}
|
||||
|
||||
@@ -250,7 +250,7 @@ func (p *PurchaseHandler) SyncStoreSkus(ctx *jxcontext.Context, parentTask tasks
|
||||
// 饿百支持创建sku时绑定商家分类了
|
||||
// isCreate = true
|
||||
// // 创建SKU后马上绑定分类,会失败,所以延迟绑定
|
||||
// time.AfterFunc(3*time.Second, func() {
|
||||
// utils.AfterFuncWithRecover(3*time.Second, func() {
|
||||
// if err := api.EbaiAPI.SkuShopCategoryMap(strStoreID, storeSku.EbaiID, utils.Int64ToStr(storeSku.CatEbaiID)); err == nil {
|
||||
// storeSku.EbaiSyncStatus = 0
|
||||
// dao.UpdateEntity(nil, &storeSku.StoreSkuBind, updateFields...)
|
||||
|
||||
@@ -16,7 +16,8 @@ const (
|
||||
)
|
||||
|
||||
func (c *PurchaseHandler) ClientUrgeOrder(orderID string) (err error) {
|
||||
go func() (err error) {
|
||||
utils.CallFuncAsync(func() {
|
||||
var err error
|
||||
globals.SugarLogger.Debugf("ClientUrgeOrder orderID:%s", orderID)
|
||||
order, err2 := partner.CurOrderManager.LoadOrder(orderID, model.VendorIDELM)
|
||||
if err = err2; err == nil {
|
||||
@@ -45,7 +46,6 @@ func (c *PurchaseHandler) ClientUrgeOrder(orderID string) (err error) {
|
||||
if err != nil {
|
||||
globals.SugarLogger.Warnf("ClientUrgeOrder orderID:%s failed with error:%v", orderID, err)
|
||||
}
|
||||
return err
|
||||
}()
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ func (c *PurchaseHandler) replyOrderComment(intOrderID int64, jdStoreNo string,
|
||||
delaySeconds := config.delayGapBegin + rand.Intn(config.delayGapEnd-config.delayGapBegin)
|
||||
content := config.comments[rand.Intn(len(config.comments))]
|
||||
globals.SugarLogger.Debugf("replyOrderComment orderID:%d, delaySeconds:%d, content:%s", intOrderID, delaySeconds, content)
|
||||
time.AfterFunc(time.Duration(delaySeconds)*time.Second, func() {
|
||||
utils.AfterFuncWithRecover(time.Duration(delaySeconds)*time.Second, func() {
|
||||
// err2 := utils.CallFuncLogError(func() error {
|
||||
// if globals.ReallyCallPlatformAPI {
|
||||
// return api.JdAPI.OrgReplyComment(intOrderID, jdStoreNo, content, utils.GetAPIOperator(""))
|
||||
|
||||
@@ -189,9 +189,9 @@ func (c *PurchaseHandler) AcceptOrRefuseOrder(order *model.GoodsOrder, isAcceptI
|
||||
msg.Data.Set("utime", msg.Data.Get("timestamp"))
|
||||
msg.Data.Set(mtwmapi.KeyOrderID, order.VendorOrderID)
|
||||
msg.Data.Set("status", mtwmapi.OrderStatusReceived)
|
||||
go func() {
|
||||
utils.CallFuncAsync(func() {
|
||||
OnOrderCallbackMsg(msg)
|
||||
}()
|
||||
})
|
||||
}
|
||||
} else {
|
||||
err = api.MtwmAPI.OrderCancel(utils.Str2Int64(order.VendorOrderID))
|
||||
|
||||
@@ -40,9 +40,9 @@ func (c *PurchaseHandler) onWaybillMsg(msg *mtwmapi.CallbackMsg) (response *mtwm
|
||||
msg.Data.Set("utime", msg.Data.Get("timestamp"))
|
||||
msg.Data.Set(mtwmapi.KeyOrderID, waybill.VendorOrderID)
|
||||
msg.Data.Set("status", mtwmapi.OrderStatusDelivering)
|
||||
go func() {
|
||||
utils.CallFuncAsync(func() {
|
||||
OnOrderCallbackMsg(msg)
|
||||
}()
|
||||
})
|
||||
}
|
||||
return mtwmapi.Err2CallbackResponse(err, "")
|
||||
}
|
||||
|
||||
@@ -243,9 +243,9 @@ func (p *PurchaseHandler) postFakeMsg(orderNo int64, fakeStatus string) {
|
||||
OrderNo: orderNo,
|
||||
StatusTime: time.Now(),
|
||||
}
|
||||
go func() {
|
||||
utils.CallFuncAsync(func() {
|
||||
OnCallbackMsg(msg)
|
||||
}()
|
||||
})
|
||||
}
|
||||
|
||||
func (p *PurchaseHandler) arrangeSaleStore(order *model.GoodsOrder, cityName, provinceName string) {
|
||||
|
||||
Reference in New Issue
Block a user