From d834422b4e101a72b076f523a780a34093bef095 Mon Sep 17 00:00:00 2001 From: gazebo Date: Fri, 26 Oct 2018 13:55:58 +0800 Subject: [PATCH] - add limitSkuCount parameter when create jd promotion. --- business/jxstore/promotion/jd_promotion.go | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/business/jxstore/promotion/jd_promotion.go b/business/jxstore/promotion/jd_promotion.go index 4e4336205..287919b9b 100644 --- a/business/jxstore/promotion/jd_promotion.go +++ b/business/jxstore/promotion/jd_promotion.go @@ -48,10 +48,15 @@ const ( colEndAtIndex = 10 ) +const ( + DefaultLimitSkuCount = 100 +) + type SkuPrice struct { - SkuID int `json:"skuID"` - PriceType int `json:"priceType"` - Price int `json:"price"` // 分,这个不是单价 + SkuID int `json:"skuID"` + PriceType int `json:"priceType"` + Price int `json:"price"` // 分,这个不是单价 + LimitSkuCount int `json:"limitSkuCount"` } type PromotionParams struct { @@ -70,7 +75,7 @@ type tStoreSkuBindExt struct { } var ( - ErrEmptySkus = errors.New("空sku") + ErrEmptySkus = errors.New("空sku或指定的SKU没有被门店认领,请检查") ) type JdPromotionHandler interface { @@ -189,6 +194,9 @@ func CreateJdPromotion(ctx *jxcontext.Context, isIDJd bool, isAsync bool, params if promotionSkuPrice.Price >= skuBind.Price { errMsg += fmt.Sprintf("促销价大于等于原价,storeID:%d, skuID:%d\n", skuBind.StoreID, skuBind.SkuID) } + if promotionSkuPrice.LimitSkuCount <= 0 { + promotionSkuPrice.LimitSkuCount = DefaultLimitSkuCount + } if errMsg == "" { if params.Type == PromotionTypeLimitedTime { if skuBind.Price*PromotionLimitedTimeMinPercentage/100 < promotionSkuPrice.Price { @@ -202,6 +210,7 @@ func CreateJdPromotion(ctx *jxcontext.Context, isIDJd bool, isAsync bool, params jdapi.KeyOutStationNo: utils.Int2Str(skuBind.StoreID), jdapi.KeyOutSkuId: utils.Int2Str(skuBind.SkuID), jdapi.KeyPromotionPrice: promotionSkuPrice.Price, + jdapi.KeyLimitSkuCount: promotionSkuPrice.LimitSkuCount, } index++ }