rencaika/pages/pending-payment/pending-payment.uvue
@@ -22,7 +22,7 @@ </view> <view class="discount-card"> <view class="discount-row"><text>人才折扣</text><text class="discount-highlight">6折</text></view> <view class="discount-row"><text>人才折扣</text><text class="discount-highlight">{{talentDiscountText}}</text></view> <view class="discount-row" :class="couponSelectable ? 'coupon-row' : ''" hover-class="discount-row-active" :hover-stop-propagation="true" @tap="chooseCoupon"> <text>商品优惠</text> <view v-if="couponSelectable" class="coupon-value"><text>{{couponText}}</text><text class="coupon-chevron">›</text></view> @@ -74,6 +74,7 @@ const productId = ref('') const priceVersion = ref(1) const discountText = ref('人才专享') const talentDiscountText = ref('无折扣') const expireAt = ref(0) const hasExpiry = ref(false) const remainingSeconds = ref(300) @@ -153,6 +154,7 @@ actualPayAmount.value = Number(data.payAmount) subsidyAmount.value = Number(data.subsidyAmount) discountText.value = data.productNameSnapshot != null ? data.productNameSnapshot as string : '人才专享' talentDiscountText.value = data.talentDiscountText != null ? data.talentDiscountText as string : '无折扣' hasExpiry.value = data.expiresAt != null expireAt.value = hasExpiry.value ? new Date((data.expiresAt as string).replace('T', ' ')).getTime() : 0 isExpired.value = data.expired === true || data.canPay !== true talent-card-server/src/main/java/com/talentcard/server/business/portal/PendingOrderPortalService.java
@@ -153,6 +153,7 @@ && orderStatus == 0 && !expired; result.put("couponSelectable", couponSelectable); result.put("couponLabel", order.get("couponName") == null ? "无" : "减" + yuan(order.get("couponAmount")).stripTrailingZeros().toPlainString() + "元"); result.put("talentDiscountText", talentDiscountText(order)); result.put("originalAmount", yuan(order.get("orderAmount"))); // “优惠金额”在待支付页仅表示优惠券抵扣,不应把人才折扣或补贴混入其中。 result.put("discountAmount", yuan(order.get("couponAmount"))); @@ -201,4 +202,13 @@ private long longNumber(Object value) { return value instanceof Number number ? number.longValue() : 0; } private Long longValue(Object value) { return value instanceof Number number ? number.longValue() : null; } private BigDecimal yuan(Object cent) { return BigDecimal.valueOf(longNumber(cent), 2); } private String talentDiscountText(Map<String, Object> order) { long originalAmount = longNumber(order.get("orderAmount")); long basePayAmount = longNumber(order.get("basePayAmount")); if (originalAmount <= 0 || basePayAmount >= originalAmount) return "无折扣"; if (basePayAmount <= 0) return "免费"; return BigDecimal.valueOf(basePayAmount).multiply(BigDecimal.TEN) .divide(BigDecimal.valueOf(originalAmount), 1, java.math.RoundingMode.HALF_UP) .stripTrailingZeros().toPlainString() + "折"; } }