/** 小程序展示号:去掉 ORD_渠道_ 前缀。MP 长号仍缩成 录单日_后四位。 */ function formatMpOrderCode(code) { const raw = String(code || '').trim(); if (!raw) return ''; const mp = raw.match(/MP_(\d{8})_/i); if (mp) { const tail = raw.length >= 4 ? raw.slice(-4) : raw; return `${mp[1]}_${tail}`; } const prefixed = raw.match(/^ORD_[A-Z0-9]+_(.+)$/i); if (prefixed) return prefixed[1]; return raw; } function formatMpOrderCodeList(codes) { const raw = String(codes || '').trim(); if (!raw) return ''; return raw .split(/[,,\s]+/) .map((part) => formatMpOrderCode(part)) .filter(Boolean) .join('、'); } module.exports = { formatMpOrderCode, formatMpOrderCodeList, formatDeliveryOrderCode: formatMpOrderCode, };