feat(payment): 添加会员折扣功能并重构支付逻辑
- 新增 getMemberDiscount 接口用于查询会员折扣 - 在人脸识别支付中集成会员折扣计算逻辑 - 将支付金额计算从 vipPrice 切换到 specPrice 并应用会员折扣 - 在初始化活动中添加设备配置获取功能 - 使用 ConstraintLayout 重构主餐品列表布局 - 添加 Timber 日志框架替换原有 Log 工具 - 重构 MainScreenPresentation 中的食物价格计算逻辑 - 移除重复的设备配置获取代码,统一在 InitActivity 中处理
This commit is contained in:
@@ -166,6 +166,8 @@ class PayActivity : BaseActivity<ActivityPayBinding>() {
|
||||
super.onDestroy()
|
||||
}
|
||||
|
||||
var memberDiscount = 1.0
|
||||
|
||||
var memberInfo: MemberInfo? = null
|
||||
fun showPayInfo(type: Int = 1, isVip: Boolean = false, memberInfo: MemberInfo? = null) {
|
||||
this.memberInfo = memberInfo
|
||||
@@ -191,9 +193,19 @@ class PayActivity : BaseActivity<ActivityPayBinding>() {
|
||||
it.type = type
|
||||
it.foodName = foodInfo?.foodName
|
||||
//确认使用vipPrice 还是 specPrice
|
||||
val onePrice = if (isVip) foodInfo?.vipPrice else foodInfo?.specPrice
|
||||
it.totalPrice = (onePrice ?: 0.0) * eatNum
|
||||
presentation.initView()
|
||||
//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
|
||||
var onePrice = foodInfo?.specPrice ?: 0.0
|
||||
onePrice = if (isVip) onePrice * memberDiscount else onePrice
|
||||
it.totalPrice = onePrice * eatNum
|
||||
presentation.initView()
|
||||
}
|
||||
} else {
|
||||
it.totalPrice = (foodInfo?.specPrice ?: 0.0) * eatNum
|
||||
presentation.initView()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user