Commit 0b9a118e authored by shiyl's avatar shiyl

修复已优惠金额大于合计的问题

parent 81176aa2
......@@ -115,11 +115,15 @@ class ConfirmOrderViewModel : BaseViewModel() {
/**
* 计算商品合计 = 原价 - 优惠
* 已优惠金额 = 优惠券金额(但不能大于合计)
*/
private fun calculateTotalAmount() {
var total = originalAmount - couponAmount
if (total < 0) {
total = 0.00
couponAmountValue.value = originalAmount
} else {
couponAmountValue.value = couponAmount
}
totalAmount.value = total
}
......@@ -166,8 +170,6 @@ class ConfirmOrderViewModel : BaseViewModel() {
}
}
selectedCouponList.value = list
// 更新优惠券总金额
couponAmountValue.value = couponAmount
// 更新选择优惠券名称
couponNameValue.value = couponsAvailableList.value?.get(0)?.name
// 重新计算相关金额
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment