diff --git a/business/jxstore/promotion/jd_promotion.go b/business/jxstore/promotion/jd_promotion.go index 8012d0f95..2fe7d4927 100644 --- a/business/jxstore/promotion/jd_promotion.go +++ b/business/jxstore/promotion/jd_promotion.go @@ -30,7 +30,7 @@ const ( ) const ( - PromotionLimitedTimeMinPercentage = 80 + PromotionLimitedTimeMinPercentage = 79 ) const ( @@ -49,7 +49,7 @@ const ( const ( defSearchDays = 7 - stockRefreshGap = 1 * time.Minute + stockRefreshGap = 5 * time.Minute userName = "jdpromotion" ) @@ -197,7 +197,7 @@ func Init() { scheduleRoutine() } -func CreateJdPromotion(ctx *jxcontext.Context, isIDJd bool, isAsync bool, params *PromotionParams, userName string) (hint string, err error) { +func CreateJdPromotion(ctx *jxcontext.Context, isIDJd bool, isAsync, isContinueWhenError bool, params *PromotionParams, userName string) (hint string, err error) { if len(params.SkuPrices) == 0 { return "", ErrEmptySkus } @@ -261,7 +261,7 @@ func CreateJdPromotion(ctx *jxcontext.Context, isIDJd bool, isAsync bool, params if skuBind.Price*PromotionLimitedTimeMinPercentage/100 < promotionSkuPrice.Price { modifyPricesList[skuBind.StoreID] = append(modifyPricesList[skuBind.StoreID], &jdapi.SkuPriceInfo{ OutSkuId: utils.Int2Str(skuBind.SkuID), - Price: promotionSkuPrice.Price*100/PromotionLimitedTimeMinPercentage + 1, + Price: promotionSkuPrice.Price*100/PromotionLimitedTimeMinPercentage + 5, }) } } @@ -368,7 +368,7 @@ func CreateJdPromotion(ctx *jxcontext.Context, isIDJd bool, isAsync bool, params } else if step == 1 { err = promotionHandler.CreatePromotionRules(infoId, "", 1, 1, 1, 1) } else if step == 2 { - task2 := tasksch.NewParallelTask("CreateJdPromotion CreatePromotionSku", tasksch.NewParallelConfig().SetBatchSize(MaxPromotionSkuCount), userName, func(task *tasksch.ParallelTask, batchItemList []interface{}, params2 ...interface{}) (retVal interface{}, err error) { + task2 := tasksch.NewParallelTask("CreateJdPromotion CreatePromotionSku", tasksch.NewParallelConfig().SetBatchSize(MaxPromotionSkuCount).SetIsContinueWhenError(isContinueWhenError), userName, func(task *tasksch.ParallelTask, batchItemList []interface{}, params2 ...interface{}) (retVal interface{}, err error) { skus := make([]map[string]interface{}, len(batchItemList)) for k, v := range batchItemList { skus[k] = v.(map[string]interface{}) @@ -378,6 +378,9 @@ func CreateJdPromotion(ctx *jxcontext.Context, isIDJd bool, isAsync bool, params }, promotionPrices) task.AddChild(task2).Run() _, err = task2.GetResult(0) + if isContinueWhenError && err != nil { // todo isContinueWhenError为true时,强制忽略此步的错误 + err = nil + } } else if step == 3 { err = promotionHandler.ConfirmPromotion(infoId, "") if err == nil { diff --git a/controllers/promotion.go b/controllers/promotion.go index 9e1dfe0c6..37d0ca000 100644 --- a/controllers/promotion.go +++ b/controllers/promotion.go @@ -25,6 +25,7 @@ type PromotionController struct { // @Param storeIDs formData string true "json数据,storeID列表[1,2,3]" // @Param skuPrices formData string true "json数据,价格信息列表" // @Param isAsync formData bool false "是否异步,缺省否(暂时只支持同步)" +// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false" // @Param advertising formData string false "广告语" // @Success 200 {object} controllers.CallResult // @Failure 200 {object} controllers.CallResult @@ -51,7 +52,7 @@ func (c *PromotionController) CreatePromotion() { } if err = utils.UnmarshalUseNumber([]byte(params.StoreIDs), &promotionParams.StoreIDs); err == nil { if err = utils.UnmarshalUseNumber([]byte(params.SkuPrices), &promotionParams.SkuPrices); err == nil { - retVal, err = promotion.CreateJdPromotion(params.Ctx, false, params.IsAsync, promotionParams, params.Ctx.GetUserName()) + retVal, err = promotion.CreateJdPromotion(params.Ctx, false, params.IsAsync, params.IsContinueWhenError, promotionParams, params.Ctx.GetUserName()) } } return retVal, "", err