export function transform(leftData) {
  let rightData = {};
  // 分类
  let leftCategory = leftData.categories;
  rightData.cat1Id = leftCategory.cat1.catId;
  rightData.cat2Id = leftCategory.cat2.catId;
  rightData.cat3Id = leftCategory.cat3.catId;
  rightData.cat4Id = leftCategory.cat4.catId;
  rightData.cat5Id = leftCategory.cat5.catId;
  rightData.cat6Id = leftCategory.cat6.catId;
  rightData.cat7Id = leftCategory.cat7.catId;
  rightData.cat8Id = leftCategory.cat8.catId;
  rightData.cat9Id = leftCategory.cat9.catId;
  rightData.cat10Id = leftCategory.cat10.catId;

  // 普通属性
  rightData.productName = leftData.productName;
  rightData.materialMultiLanguages = leftData.productLocalExtAttr.materialMultiLanguages;
  rightData.productI18nReqs = leftData.productI18nList;
  rightData.productPropertyReqs = [];
  for (let i = 0; i < leftData.productPropertyList.length; i++) {
    rightData.productPropertyReqs.push({
      valueUnit: leftData.productPropertyList[i].valueUnit,
      propValue: leftData.productPropertyList[i].propValue,
      propName: leftData.productPropertyList[i].propName,
      refPid: leftData.productPropertyList[i].refPid,
      vid: leftData.productPropertyList[i].vid,
      controlType: 1,
      pid: leftData.productPropertyList[i].pid,
      templatePid: leftData.productPropertyList[i].templatePid,
      valueExtendInfo: leftData.productPropertyList[i].valueExtendInfo
    });
  }

  // SKC
  let rightSkc = [];
  let leftSkc = leftData.productSkcList;

  let productSpecPropertyReqs = [];
  for(let i = 0; i < leftSkc.length; i++) {
    let rightSkcItem = {};
    rightSkcItem.previewImgUrls = leftSkc[i].previewImgUrls;
    rightSkcItem.productSkcCarouselImageI18nReqs = leftSkc[i].productSkcCarouselImageI18nVOList;
    rightSkcItem.extCode = leftSkc[i].extCode;
    rightSkcItem.mainProductSkuSpecReqs =  [
      {
      "parentSpecId": 0,
      "parentSpecName": "",
      "specId": 0,
      "specName": ""
      }
    ];
    rightSkcItem.productSkuReqs = [];
    for(let j = 0; j < leftSkc[i].productSkuList.length; j++) {
      let leftSkuItem = leftSkc[i].productSkuList[j];
      let rightSkuItem = {};

      rightSkuItem.thumbUrl = leftSkuItem.thumbUrl;
      rightSkuItem.productSkuThumbUrlI18nReqs = leftSkuItem.productSkuThumbUrlI18nVOList;
      rightSkuItem.extCode = leftSkuItem.extCode;
      rightSkuItem.supplierPrice = leftSkuItem.supplierPrice;
      rightSkuItem.currencyType = leftSkuItem.currencyType;
      rightSkuItem.productSkuSpecReqs = leftSkuItem.productSkuSpecList;
      productSpecPropertyReqs.push({
        "parentSpecId": leftSkuItem.productSkuSpecList[0].parentSpecId,
        "parentSpecName": leftSkuItem.productSkuSpecList[0].parentSpecName,
        "specId": leftSkuItem.productSkuSpecList[0].specId,
        "specName": leftSkuItem.productSkuSpecList[0].specName,
        "refPid": 0,
        "pid": 0,
        "templatePid": 0,
        "propName": leftSkuItem.productSkuSpecList[0].specName,
        "vid": 0,
        "propValue": leftSkuItem.productSkuSpecList[0].specName,
        "valueUnit": "",
        "valueGroupId": 0,
        "valueGroupName": "",
        "valueExtendInfo": ""
      });
      rightSkuItem.productSkuId = 0;
      rightSkuItem.productSkuWhExtAttrReq = {
        "productSkuVolumeReq": leftSkuItem.productSkuWhExtAttr.productSkuVolume,
        "productSkuWeightReq": leftSkuItem.productSkuWhExtAttr.productSkuWeight,
        "productSkuBarCodeReqs": leftSkuItem.productSkuWhExtAttr.productSkuBarCodes,
        "productSkuSensitiveAttrReq": {
          "isSensitive": leftSkuItem.productSkuWhExtAttr.productSkuSensitiveAttr.isSensitive,
          "sensitiveList": leftSkuItem.productSkuWhExtAttr.productSkuSensitiveAttr.sensitiveList},
        "productSkuSensitiveLimitReq": leftSkuItem.productSkuWhExtAttr.productSkuSensitiveLimit,
      };
      rightSkuItem.currencyType = leftSkuItem.currencyType;

      rightSkcItem.productSkuReqs.push(rightSkuItem);
    }
    rightSkcItem.productSkcId = 0;

    rightSkc.push(rightSkcItem);
  }
  rightData.productSkcReqs = rightSkc;

  // Spec
  rightData.productSpecPropertyReqs = productSpecPropertyReqs;
  rightData.carouselImageUrls = leftData.carouselImageUrls;
  rightData.carouselImageI18nReqs = leftData.carouselImageI18nVOList;
  rightData.materialImgUrl = leftData.materialImgUrl;
  rightData.goodsLayerDecorationReqs = leftData.goodsLayerDecorationVOList;
  rightData.sizeTemplateIds = !leftData.sizeTemplateIds ? []: leftData.sizeTemplateIds;
  rightData.showSizeTemplateIds = !leftData.showSizeTemplateIds ? []: leftData.showSizeTemplateIds;
  rightData.goodsModelReqs = !leftData.goodsModelList ? []: leftData.goodsModelList;
  rightData.productWhExtAttrReq = {
    outerGoodsUrl: leftData.productWhExtAttr.outerGoodsUrl,
    productOrigin: {
      countryShortName: leftData.productWhExtAttr.productOrigin.countryShortName
    }
  };
  rightData.productCarouseVideoReqList = leftData.carouseVideoVOList;
  rightData.goodsAdvantageLabelTypes = leftData.goodsAdvantageLabelVOList;
  rightData.productDetailVideoReqList = leftData.detailVideoVOList;
  rightData.productOuterPackageImageReqs = [];
  for (let i = 0;i < leftData.outerPackageImages.length; i++) {
    rightData.productOuterPackageImageReqs.push({
      imageUrl: leftData.outerPackageImages[i].imageUrl
    })
  }
  rightData.productOuterPackageReq = leftData.productWhExtAttr.productOuterPackage;
  rightData.sensitiveTransNormalFileReqs = leftData.productWhExtAttr.sensitiveTransNormalFiles;
  rightData.productGuideFileI18nReqs = leftData.productGuideFileI18nList;
  rightData.productSaleExtAttrReq = {};
  rightData.productDraftId = "";

  return JSON.stringify(rightData);
}