refactor(discount): 简化会员折扣空值处理逻辑

- 使用Elvis操作符替代条件表达式判断空值
- 统一两个位置的折扣计算逻辑实现方式
- 提高代码可读性和简洁性
This commit is contained in:
2026-06-30 09:51:35 +08:00
parent 061680b32b
commit 088aabc535
2 changed files with 2 additions and 2 deletions
@@ -196,7 +196,7 @@ class PayActivity : BaseActivity<ActivityPayBinding>() {
//val onePrice = if (isVip) foodInfo?.vipPrice else foodInfo?.specPrice
if (isVip) {
userViewModel.getMemberDiscount(memberInfo?.faceUserId?:"") { discount ->
memberDiscount = if (discount == null) 1.0 else discount / 10
memberDiscount = discount ?: 1.0
var onePrice = foodInfo?.specPrice ?: 0.0
onePrice = if (isVip) onePrice * memberDiscount else onePrice
it.totalPrice = onePrice * eatNum
@@ -1034,7 +1034,7 @@ class MainScreenPresentation(
// pauseCamera()
//先查询会员折扣
userViewModel.getMemberDiscount(userId) { discount ->
memberDiscount = if (discount == null) 1.0 else discount / 10
memberDiscount = discount ?: 1.0
step3ShowRecognizeResult(userId)
}
})