This commit is contained in:
邹宗楠
2025-08-20 18:15:40 +08:00
parent fb5300ef36
commit 32b50de6b9

View File

@@ -302,6 +302,7 @@ func CopyMtToMT(ctx *jxcontext.Context, fromStore, toStore *dao.StoreDetail, isA
func BatchInitSkuMT2MT(ctx *jxcontext.Context, fromSku []*mtwmapi.AppFood, toApi *mtwmapi.API, vendorStoreID string, offset int) ([]*mtwmapi.AppFoodResult, error) {
errList := make([]*mtwmapi.AppFoodResult, 0, 0)
foodDataList := make([]map[string]interface{}, len(fromSku))
nameList := make(map[string]string, len(fromSku))
//apiObj := apimanager.CurAPIManager.GetAPI(model.VendorIDJD, "320406").(*jdapi.API)
for k, storeSku := range fromSku {
@@ -309,7 +310,7 @@ func BatchInitSkuMT2MT(ctx *jxcontext.Context, fromSku []*mtwmapi.AppFood, toApi
if storeSku.AppFoodCode != "" {
foodData[mtwmapi.KeyAppFoodCode] = storeSku.AppFoodCode
} else {
foodData[mtwmapi.KeyAppFoodCode] = time.Now().UnixNano() + int64(k*3)
foodData[mtwmapi.KeyAppFoodCode] = utils.Int64ToStr(time.Now().UnixNano() + int64(k*3))
}
skus := make([]interface{}, 0)
@@ -404,6 +405,7 @@ func BatchInitSkuMT2MT(ctx *jxcontext.Context, fromSku []*mtwmapi.AppFood, toApi
}
foodDataList[k] = foodData
nameList[foodData[mtwmapi.KeyAppFoodCode].(string)] = foodData["name"].(string)
}
count := len(foodDataList) / 10
@@ -414,14 +416,22 @@ func BatchInitSkuMT2MT(ctx *jxcontext.Context, fromSku []*mtwmapi.AppFood, toApi
if i == count-1 {
failedFoodList, _ := toApi.RetailBatchInitData(ctx.GetTrackInfo(), vendorStoreID, foodDataList[i*10:])
if len(failedFoodList) != 0 {
globals.SugarLogger.Debugf("failedFoodList := %s", utils.Format4Output(failedFoodList, false))
errList = append(errList, failedFoodList...)
for _, ffl := range failedFoodList {
if nameList[ffl.AppFoodCode] != "" {
globals.SugarLogger.Debugf("name := %s", nameList[ffl.AppFoodCode])
}
}
}
} else {
failedFoodList, _ := toApi.RetailBatchInitData(ctx.GetTrackInfo(), vendorStoreID, foodDataList[i*10:(i+1)*10])
if len(failedFoodList) != 0 {
globals.SugarLogger.Debugf("failedFoodList := %s", utils.Format4Output(failedFoodList, false))
errList = append(errList, failedFoodList...)
for _, ffl := range failedFoodList {
if nameList[ffl.AppFoodCode] != "" {
globals.SugarLogger.Debugf("name := %s", nameList[ffl.AppFoodCode])
}
}
}
}
}