- 京东回调活动创建等5秒再执行,以免通过API创建时重复创建
- 饿百防重复创建
This commit is contained in:
@@ -307,15 +307,19 @@ func OnActMsg(msg *jdapi.CallbackOrderMsg) (retVal *jdapi.CallbackResponse) {
|
||||
func (c *PurchaseHandler) onActMsg(msg *jdapi.CallbackOrderMsg) (retVal *jdapi.CallbackResponse) {
|
||||
if msg.StatusID == jdapi.PromotionStatusSingleOK || msg.StatusID == jdapi.PromotionStatusLimitTimeOK {
|
||||
promotionID := msg.BillID
|
||||
if !partner.CurActManager.IsVendorActExist(jxcontext.AdminCtx, promotionID, model.VendorIDJD) {
|
||||
act, actStoreSkuList, err := getActFromJD(promotionID)
|
||||
if err == nil && len(actStoreSkuList) > 0 {
|
||||
_, err = partner.CurActManager.CreateActFromVendor(jxcontext.AdminCtx, act, actStoreSkuList)
|
||||
// 等几秒再执行的原因是防止通过后台自己创建时,本地还没有建好,消息就过来,导致重复记录
|
||||
// 可能的问题是在重启时丢失消息
|
||||
utils.AfterFuncWithRecover(5*time.Second, func() {
|
||||
if !partner.CurActManager.IsVendorActExist(jxcontext.AdminCtx, promotionID, model.VendorIDJD) {
|
||||
act, actStoreSkuList, err := getActFromJD(promotionID)
|
||||
if err == nil && len(actStoreSkuList) > 0 {
|
||||
_, err = partner.CurActManager.CreateActFromVendor(jxcontext.AdminCtx, act, actStoreSkuList)
|
||||
}
|
||||
if err != nil {
|
||||
retVal = jdapi.Err2CallbackResponse(err, promotionID)
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
retVal = jdapi.Err2CallbackResponse(err, promotionID)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
return retVal
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user