Update micFieldMapping.js via upload script - 2026-09-21 02:21:28
This commit is contained in:
parent
513316a3b6
commit
aa132ee3fd
|
|
@ -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 = {
|
module.exports = {
|
||||||
buildAttributeList,
|
buildAttributeList,
|
||||||
sanitizeValue,
|
sanitizeValue,
|
||||||
sanitizeLabel,
|
sanitizeLabel,
|
||||||
|
parsePackageDimensionsCm,
|
||||||
CATEGORY_FIELD_MAP,
|
CATEGORY_FIELD_MAP,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue