|
|
@@ -314,14 +314,18 @@ function handleCheckoutCouponLoadMore() {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 将接口/列表里的「折」统一为应付公式用的刻度:payRatio = rate/10,优惠 = 基数×(1−rate/10)。
|
|
|
- * 如 88(八八折整数)、8.8、0.88 均归一为 8.8。
|
|
|
+ * 统一为应付公式折数 zhe(1=一折,10=十折):优惠 = 基数×(1−zhe/10)
|
|
|
+ * - 与 couponNormalize 一致:接口 10 表示 1折(列表 discountRate/10 展示为 1折)
|
|
|
+ * - 88→8.8折;0.88/0.1→8.8/1折;1~9 为折数;≥100 为十折
|
|
|
*/
|
|
|
function normalizeZheRateForCheckoutFormula(r) {
|
|
|
if (!Number.isFinite(r) || r <= 0) return 0;
|
|
|
- if (r > 10 && r <= 100) return Math.round((r / 10) * 100) / 100;
|
|
|
+ if (r >= 100) return 10;
|
|
|
+ if (r > 10 && r < 100) return Math.round((r / 10) * 100) / 100;
|
|
|
+ if (r === 10) return 1;
|
|
|
if (r > 0 && r < 1) return Math.round(r * 10 * 100) / 100;
|
|
|
- return Math.round(r * 100) / 100;
|
|
|
+ if (r >= 1 && r < 10) return Math.round(r * 100) / 100;
|
|
|
+ return 0;
|
|
|
}
|
|
|
|
|
|
/** 折扣券:仅用接口/券上的 discountRate(及 _sourceDiscountRate 保留的原始值)计算折标,不用 amount 代替 */
|
|
|
@@ -620,8 +624,12 @@ function applyCheckoutCouponFromOrderRaw(raw) {
|
|
|
orderInfo.value.couponName = String(raw?.couponName ?? '').trim();
|
|
|
orderInfo.value.couponType = raw?.couponType ?? null;
|
|
|
const rawRate = raw?.discountRate;
|
|
|
- orderInfo.value.discountRate =
|
|
|
- rawRate != null && rawRate !== '' ? (Number(rawRate) || 0) / 10 : null;
|
|
|
+ if (rawRate != null && rawRate !== '') {
|
|
|
+ const zhe = normalizeZheRateForCheckoutFormula(Number(rawRate));
|
|
|
+ orderInfo.value.discountRate = zhe > 0 ? zhe : null;
|
|
|
+ } else {
|
|
|
+ orderInfo.value.discountRate = null;
|
|
|
+ }
|
|
|
orderInfo.value.nominalValue = raw?.nominalValue ?? null;
|
|
|
orderInfo.value.discountAmount = discountAmt;
|
|
|
recalcDiscountAfterServiceFeeChange();
|