diff --git a/business/jxstore/promotion/jd_promotion.go b/business/jxstore/promotion/jd_promotion.go index 4f445b176..ec3a72f12 100644 --- a/business/jxstore/promotion/jd_promotion.go +++ b/business/jxstore/promotion/jd_promotion.go @@ -131,7 +131,7 @@ var ( type JdPromotionHandler interface { CreatePromotionInfos(name string, beginDate, endDate time.Time, outInfoId, advertising string) (infoId int64, err error) CreatePromotionRules(infoId int64, outInfoId string, limitDevice, limitPin, limitCount, limitDaily int) (err error) - CreatePromotionSku(infoId int64, outInfoId string, skus []map[string]interface{}) (skusResult []map[string]interface{}, err error) + CreatePromotionSku(infoId int64, outInfoId string, skus []*jdapi.PromotionSku) (skusResult []*jdapi.PromotionSku, err error) ConfirmPromotion(infoId int64, outInfoId string) (err error) CancelPromotion(infoId int64, outInfoId string) (err error) } @@ -145,7 +145,7 @@ func (p *JdDirectDownHandler) CreatePromotionInfos(name string, beginDate, endDa func (p *JdDirectDownHandler) CreatePromotionRules(infoId int64, outInfoId string, limitDevice, limitPin, limitCount, limitDaily int) (err error) { return api.JdAPI.CreatePromotionRules(infoId, outInfoId, limitDevice, limitPin, limitCount, limitDaily) } -func (p *JdDirectDownHandler) CreatePromotionSku(infoId int64, outInfoId string, skus []map[string]interface{}) (skusResult []map[string]interface{}, err error) { +func (p *JdDirectDownHandler) CreatePromotionSku(infoId int64, outInfoId string, skus []*jdapi.PromotionSku) (skusResult []*jdapi.PromotionSku, err error) { return api.JdAPI.CreatePromotionSkuSingle(infoId, outInfoId, skus) } func (p *JdDirectDownHandler) ConfirmPromotion(infoId int64, outInfoId string) (err error) { @@ -164,7 +164,7 @@ func (p *JdLimitedTimeHandler) CreatePromotionInfos(name string, beginDate, endD func (p *JdLimitedTimeHandler) CreatePromotionRules(infoId int64, outInfoId string, limitDevice, limitPin, limitCount, limitDaily int) (err error) { return api.JdAPI.CreatePromotionRules(infoId, outInfoId, limitDevice, limitPin, limitCount, limitDaily) } -func (p *JdLimitedTimeHandler) CreatePromotionSku(infoId int64, outInfoId string, skus []map[string]interface{}) (skusResult []map[string]interface{}, err error) { +func (p *JdLimitedTimeHandler) CreatePromotionSku(infoId int64, outInfoId string, skus []*jdapi.PromotionSku) (skusResult []*jdapi.PromotionSku, err error) { return api.JdAPI.CreatePromotionSkuLimitTime(infoId, outInfoId, skus) } func (p *JdLimitedTimeHandler) ConfirmPromotion(infoId int64, outInfoId string) (err error) { @@ -183,7 +183,7 @@ func (p *JdNullHandler) CreatePromotionInfos(name string, beginDate, endDate tim func (p *JdNullHandler) CreatePromotionRules(infoId int64, outInfoId string, limitDevice, limitPin, limitCount, limitDaily int) (err error) { return nil } -func (p *JdNullHandler) CreatePromotionSku(infoId int64, outInfoId string, skus []map[string]interface{}) (skusResult []map[string]interface{}, err error) { +func (p *JdNullHandler) CreatePromotionSku(infoId int64, outInfoId string, skus []*jdapi.PromotionSku) (skusResult []*jdapi.PromotionSku, err error) { return nil, nil } func (p *JdNullHandler) ConfirmPromotion(infoId int64, outInfoId string) (err error) { @@ -260,7 +260,7 @@ func CreateJdPromotion(ctx *jxcontext.Context, isIDJd bool, isAsync, isContinueW userName := ctx.GetUserName() db := dao.GetDB() modifyPricesList := make(map[int][]*jdapi.SkuPriceInfo) - promotionPrices := make([]map[string]interface{}, len(params.StoreIDs)*len(params.SkuPrices)) + promotionPrices := make([]*jdapi.PromotionSku, len(params.StoreIDs)*len(params.SkuPrices)) var jxStoreIDs []int promotion := &model.Promotion{ Name: params.Name, @@ -338,13 +338,11 @@ func CreateJdPromotion(ctx *jxcontext.Context, isIDJd bool, isAsync, isContinueW }) } } - promotionPrices[index] = map[string]interface{}{ - jdapi.KeyStationNo: utils.Str2Int64(skuBind.VendorStoreID), - jdapi.KeySkuId: skuBind.JdSkuID, - // jdapi.KeyOutStationNo: utils.Int2Str(skuBind.StoreID), - // jdapi.KeyOutSkuId: utils.Int2Str(skuBind.SkuID), - jdapi.KeyPromotionPrice: promotionSkuPrice.Price, - jdapi.KeyLimitSkuCount: promotionSkuPrice.LimitSkuCount, + promotionPrices[index] = &jdapi.PromotionSku{ + StationNo: utils.Str2Int64(skuBind.VendorStoreID), + SkuID: skuBind.JdSkuID, + PromotionPrice: int64(promotionSkuPrice.Price), + LimitSkuCount: promotionSkuPrice.LimitSkuCount, } index++ } @@ -451,9 +449,9 @@ func CreateJdPromotion(ctx *jxcontext.Context, isIDJd bool, isAsync, isContinueW } else if step == 2 { task2 := tasksch.NewParallelTask("CreateJdPromotion CreatePromotionSku", tasksch.NewParallelConfig().SetBatchSize(MaxPromotionSkuCount).SetIsContinueWhenError(isContinueWhenError), ctx, func(task *tasksch.ParallelTask, batchItemList []interface{}, params2 ...interface{}) (retVal interface{}, err error) { - skus := make([]map[string]interface{}, len(batchItemList)) + skus := make([]*jdapi.PromotionSku, len(batchItemList)) for k, v := range batchItemList { - skus[k] = v.(map[string]interface{}) + skus[k] = v.(*jdapi.PromotionSku) } _, err = promotionHandler.CreatePromotionSku(infoId, "", skus) return nil, err @@ -930,12 +928,12 @@ func createLocalPromotionFromRemote(promotionInfoId int64) (retVal *jdapi.Callba if err = dao.GetEntity(db, promotion, "VendorPromotionID"); dao.IsNoRowsError(err) { storeIDMap := make(map[int64]int) skuIDMap := make(map[int64]int) - skuMap := make(map[int64]*jdapi.PromotionSkuResult) + skuMap := make(map[int64]*jdapi.PromotionLspQuerySkuResult) // 注意,这样处理可能是有问题,我们假定的是门店信息与SKU信息的叉乘 for _, v := range result.SkuResultList { storeIDMap[v.StationNo] = 1 - skuIDMap[v.SkuId] = 1 - skuMap[v.SkuId] = v + skuIDMap[v.SkuID] = 1 + skuMap[v.SkuID] = v } jdStoreIDs := make([]string, len(storeIDMap)) index := 0 @@ -970,7 +968,7 @@ func createLocalPromotionFromRemote(promotionInfoId int64) (retVal *jdapi.Callba jxStoreIDs[k] = v.StoreID } priceList := make([]*SkuPrice, len(skuList)) - var skuResult *jdapi.PromotionSkuResult + var skuResult *jdapi.PromotionLspQuerySkuResult for k, v := range skuList { skuResult = skuMap[v.JdID] priceList[k] = &SkuPrice{ @@ -985,11 +983,11 @@ func createLocalPromotionFromRemote(promotionInfoId int64) (retVal *jdapi.Callba // globals.SugarLogger.Debugf("priceList:%s", utils.Format4Output(priceList, false)) source := strings.Trim(result.Source, "来源") promotionParams := &PromotionParams{ - Name: source + "-" + utils.Int64ToStr(result.PromotionInfoId), + Name: source + "-" + utils.Int64ToStr(result.PromotionInfoID), Advertising: "", Type: result.PromotionType, - BeginAt: result.BeginTime, - EndAt: result.EndTime, + BeginAt: result.BeginTime.GoTime(), + EndAt: result.EndTime.GoTime(), StoreIDs: jxStoreIDs, SkuPrices: priceList, }