Update micFieldMapping.js via upload script - 2026-09-21 02:21:28

This commit is contained in:
mike 2026-09-21 02:21:37 +08:00
parent 513316a3b6
commit aa132ee3fd
1 changed files with 18 additions and 0 deletions

View File

@ -272,9 +272,27 @@ function buildAttributeList(product) {
};
}
// ---------------------------- 包裹尺寸(mm→cm) ----------------------------
// CRM里"尺寸(mm)"是自由文本,约定俗成按"长x宽x高"顺序输入(没有强制校验),
// 这里按这个假设拆分成三个数字、从mm换算成cm(MIC那边包裹尺寸的输入框单位是cm)。
// 顺序是CRM里人工填写时的约定,不保证100%准确——生成后建议人工核对一遍。
function parsePackageDimensionsCm(dimensionsMmStr) {
if (!dimensionsMmStr) return { depthCm: '', widthCm: '', heightCm: '' };
const nums = String(dimensionsMmStr).match(/[\d.]+/g);
if (!nums || nums.length < 3) return { depthCm: '', widthCm: '', heightCm: '' };
const toCm = (mm) => {
const n = parseFloat(mm);
if (Number.isNaN(n)) return '';
const cm = n / 10;
return Number.isInteger(cm) ? String(cm) : cm.toFixed(1);
};
return { depthCm: toCm(nums[0]), widthCm: toCm(nums[1]), heightCm: toCm(nums[2]) };
}
module.exports = {
buildAttributeList,
sanitizeValue,
sanitizeLabel,
parsePackageDimensionsCm,
CATEGORY_FIELD_MAP,
};