1
This commit is contained in:
@@ -126,7 +126,6 @@ func BatchInitData(ctx *jxcontext.Context, fromSku []*mtwmapi.AppFood, toApi *mt
|
||||
foodDataList := make([]map[string]interface{}, len(fromSku))
|
||||
for i, storeSku := range fromSku {
|
||||
foodData := make(map[string]interface{})
|
||||
foodDataList[i] = foodData
|
||||
foodData[mtwmapi.KeyAppFoodCode] = storeSku.AppFoodCode
|
||||
foodData["skus"] = storeSku.Skus
|
||||
foodData["name"] = utils.LimitUTF8StringLen(storeSku.Name, mtwmapi.MaxSkuNameCharCount)
|
||||
@@ -149,17 +148,44 @@ func BatchInitData(ctx *jxcontext.Context, fromSku []*mtwmapi.AppFood, toApi *mt
|
||||
foodData["picture_contents"] = storeSku.PictureContents
|
||||
foodData["sequence"] = storeSku.Sequence
|
||||
foodData["tag_id"] = storeSku.TagID
|
||||
foodDataList[i] = foodData
|
||||
}
|
||||
|
||||
failedFoodList, err2 := toApi.RetailBatchInitData(ctx.GetTrackInfo(), vendorStoreID, foodDataList)
|
||||
if err := err2; err == nil {
|
||||
if err = putils.GenPartialFailedErr(failedFoodList, len(failedFoodList)); err != nil {
|
||||
return err
|
||||
}
|
||||
} else if err2 != nil && len(failedFoodList) == 0 {
|
||||
if errExt, ok := err2.(*utils.ErrorWithCode); ok {
|
||||
return utils.UnmarshalUseNumber([]byte(errExt.ErrMsg()), &failedFoodList)
|
||||
}
|
||||
count := len(foodDataList) / 5
|
||||
if len(foodDataList)%5 != 0 {
|
||||
count += 1
|
||||
}
|
||||
|
||||
for i := 0; i < count; i++ {
|
||||
if i == count-1 {
|
||||
failedFoodList, err2 := toApi.RetailBatchInitData(ctx.GetTrackInfo(), vendorStoreID, foodDataList[i*5:])
|
||||
if err := err2; err == nil {
|
||||
if err = putils.GenPartialFailedErr(failedFoodList, len(failedFoodList)); err != nil {
|
||||
globals.SugarLogger.Debugf("RetailBatchInitData err1 :%v", err)
|
||||
return err
|
||||
}
|
||||
} else if err2 != nil && len(failedFoodList) == 0 {
|
||||
if errExt, ok := err2.(*utils.ErrorWithCode); ok {
|
||||
globals.SugarLogger.Debugf("RetailBatchInitData err2 :%v", utils.UnmarshalUseNumber([]byte(errExt.ErrMsg()), &failedFoodList))
|
||||
return utils.UnmarshalUseNumber([]byte(errExt.ErrMsg()), &failedFoodList)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
failedFoodList, err2 := toApi.RetailBatchInitData(ctx.GetTrackInfo(), vendorStoreID, foodDataList[i*5:(i+1)*5])
|
||||
if err := err2; err == nil {
|
||||
if err = putils.GenPartialFailedErr(failedFoodList, len(failedFoodList)); err != nil {
|
||||
globals.SugarLogger.Debugf("RetailBatchInitData err3 :%v", err)
|
||||
return err
|
||||
}
|
||||
} else if err2 != nil && len(failedFoodList) == 0 {
|
||||
if errExt, ok := err2.(*utils.ErrorWithCode); ok {
|
||||
globals.SugarLogger.Debugf("RetailBatchInitData err4 :%v", utils.UnmarshalUseNumber([]byte(errExt.ErrMsg()), &failedFoodList))
|
||||
return utils.UnmarshalUseNumber([]byte(errExt.ErrMsg()), &failedFoodList)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user