使用人脸接口中的member字段判断是否会员;逻辑优化;
This commit is contained in:
@@ -956,7 +956,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
|
||||
model.userId, null, Base64.decode(model.faceFeatureStr)
|
||||
).also {
|
||||
//1-会员、2-临时用户
|
||||
it.userType = if (model.isMember) "1" else "2"
|
||||
it.userType = if (model.member) "1" else "2"
|
||||
it.cardNo = model.cardNo
|
||||
}
|
||||
faceList.add(faceEntity)
|
||||
|
||||
@@ -169,6 +169,7 @@ class PayActivity : BaseActivity<ActivityPayBinding>() {
|
||||
// scanQrCodePayPresentation?.show()
|
||||
// }
|
||||
presentation.let {
|
||||
it.pageType = PayPresentation.QR_CODE_PAY
|
||||
it.type = type
|
||||
it.foodName = foodInfo?.foodName
|
||||
//确认使用vipPrice 还是 specPrice
|
||||
|
||||
@@ -27,17 +27,17 @@ class FacePayFragment : BaseFragment<FragmentFacePayBinding>() {
|
||||
}
|
||||
showSubScreen()
|
||||
}
|
||||
|
||||
override fun onHiddenChanged(hidden: Boolean) {
|
||||
super.onHiddenChanged(hidden)
|
||||
if (hidden) {
|
||||
// dismissSubScreen()
|
||||
payActivity.presentation.pauseCamera()
|
||||
return
|
||||
}
|
||||
payActivity.presentation.resumeCamera()
|
||||
//showSubScreen()
|
||||
}
|
||||
//
|
||||
// override fun onHiddenChanged(hidden: Boolean) {
|
||||
// super.onHiddenChanged(hidden)
|
||||
// if (hidden) {
|
||||
//// dismissSubScreen()
|
||||
// payActivity.presentation.pauseCamera()
|
||||
// return
|
||||
// }
|
||||
// payActivity.presentation.resumeCamera()
|
||||
// //showSubScreen()
|
||||
// }
|
||||
|
||||
// override fun onDestroy() {
|
||||
// dismissSubScreen()
|
||||
@@ -78,8 +78,24 @@ class FacePayFragment : BaseFragment<FragmentFacePayBinding>() {
|
||||
it.pageType = PayPresentation.FACE_PAY
|
||||
it.foodName = foodName
|
||||
it.payAmount = payAmount.format2String(2)
|
||||
isResumeCamera = true
|
||||
it.initView()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
payActivity.presentation.pauseCamera()
|
||||
}
|
||||
|
||||
private var isResumeCamera = false
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
if (isResumeCamera) {
|
||||
payActivity.presentation.resumeCamera()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -74,7 +74,7 @@ class PayResultFragment : BaseFragment<FragmentPayResultBinding>() {
|
||||
memberInfo = it.getParcelable(MEMBER_INFO)
|
||||
}
|
||||
|
||||
if (memberInfo != null) {
|
||||
if (memberInfo != null && memberInfo!!.member) {
|
||||
totalPrice = (payActivity.foodInfo?.vipPrice ?: 0.0) * payActivity.eatNum
|
||||
binding.layoutVip.visible()
|
||||
balance = (memberInfo!!.topUpBalance ?: 0.0) + (memberInfo!!.rewardBalance ?: 0.0)
|
||||
@@ -112,9 +112,15 @@ class PayResultFragment : BaseFragment<FragmentPayResultBinding>() {
|
||||
)
|
||||
)
|
||||
|
||||
binding.tvAccountInfo.text = SpannedUtils.getAmountText(
|
||||
getAmountList()
|
||||
)
|
||||
if (memberInfo != null && memberInfo!!.member) {
|
||||
binding.tvAccountInfo.text = SpannedUtils.getAmountText(
|
||||
getAmountList()
|
||||
)
|
||||
} else {
|
||||
binding.tvAccountInfo.text = SpannedUtils.getAmountText(
|
||||
getAmountListNotMember()
|
||||
)
|
||||
}
|
||||
if (balance >= totalPrice) {
|
||||
binding.ivPayQrCode.invisible()
|
||||
binding.btnConfirmPay.run {
|
||||
@@ -201,6 +207,21 @@ class PayResultFragment : BaseFragment<FragmentPayResultBinding>() {
|
||||
//扣除余额
|
||||
private var expensesBalance = 0.0
|
||||
|
||||
private fun getAmountListNotMember(): List<TextBean> {
|
||||
val list: MutableList<TextBean> = mutableListOf()
|
||||
|
||||
list.add(TextBean(text = "应付金额 ", textSize = 30, textColor = "#FF889AC2"))
|
||||
list.add(
|
||||
TextBean(
|
||||
text = "-${totalPrice.format2String(2)}",
|
||||
textSize = 30,
|
||||
textColor = "#FF0A1428",
|
||||
isBold = true
|
||||
)
|
||||
)
|
||||
list.add(TextBean(text = " 元", textSize = 30, textColor = "#FF889AC2"))
|
||||
return list
|
||||
}
|
||||
private fun getAmountList(): List<TextBean> {
|
||||
val list: MutableList<TextBean> = mutableListOf()
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ data class MemberInfo(
|
||||
val rewardBalance: Double?,
|
||||
//积分余额
|
||||
val integralBalance: Int?,
|
||||
val member: Boolean
|
||||
var member: Boolean = false
|
||||
) : Parcelable
|
||||
|
||||
data class TextBean(
|
||||
|
||||
@@ -32,7 +32,7 @@ data class UserFaceModel(
|
||||
/**
|
||||
* 是否会员
|
||||
*/
|
||||
val isMember: Boolean
|
||||
val member: Boolean
|
||||
) : Parcelable
|
||||
|
||||
@Parcelize
|
||||
|
||||
@@ -302,10 +302,11 @@ class PayPresentation(
|
||||
lastFaceTrackId = compareResult.trackId
|
||||
val faceEntity = compareResult.faceEntity
|
||||
val userId = faceEntity.userName
|
||||
val isMember = faceEntity.userType == "1"
|
||||
if (userId == null) return@Observer
|
||||
// TODO: 测试支付用户id
|
||||
// userId = "1987710988425662466"
|
||||
faceRecSuccess(userId)
|
||||
faceRecSuccess(userId, isMember)
|
||||
})
|
||||
|
||||
recognizeViewModel.drawRectInfoText.observe(activity, Observer { info ->
|
||||
@@ -313,6 +314,7 @@ class PayPresentation(
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
private fun initArcView() {
|
||||
//在布局结束后才做初始化操作
|
||||
binding.dualCameraTexturePreviewRgb.getViewTreeObserver().addOnGlobalLayoutListener(this)
|
||||
@@ -586,7 +588,7 @@ class PayPresentation(
|
||||
}
|
||||
|
||||
|
||||
private fun faceRecSuccess(userId: String) {
|
||||
private fun faceRecSuccess(userId: String, isMember: Boolean) {
|
||||
activity.runOnUiThread {
|
||||
activity.showWaitingDialog("加载中,请稍后……")
|
||||
}
|
||||
@@ -596,6 +598,7 @@ class PayPresentation(
|
||||
//ToastUtils.showToast("查询会员信息失败,请稍后重试")
|
||||
return@getMemberInfoById
|
||||
}
|
||||
memberInfo.member = isMember
|
||||
activity.bindOrder(memberInfo.faceUserId ?: "") { bindResult ->
|
||||
if (bindResult.not()) {
|
||||
activity.hideWaitingDialog()
|
||||
@@ -607,9 +610,9 @@ class PayPresentation(
|
||||
// TODO: 测试 memberInfo.member是否返回正常数据---------------
|
||||
activity.showPayInfo(type = 1, isVip = memberInfo.member, memberInfo = memberInfo)
|
||||
activity.hidePayTab()
|
||||
binding.root.postDelayed({
|
||||
dismiss()
|
||||
}, 500)
|
||||
// binding.root.postDelayed({
|
||||
// dismiss()
|
||||
// }, 500)
|
||||
}, 1000)
|
||||
}
|
||||
}
|
||||
@@ -680,7 +683,7 @@ class PayPresentation(
|
||||
1 -> {
|
||||
val memberInfo = activity.memberInfo
|
||||
binding.layoutVip.run {
|
||||
if (memberInfo != null) visible() else gone()
|
||||
if (memberInfo != null && memberInfo.member) visible() else gone()
|
||||
}
|
||||
binding.layoutPaySuccess.gone()
|
||||
binding.layoutScanQrCode.visible()
|
||||
@@ -709,18 +712,22 @@ class PayPresentation(
|
||||
if (balance >= totalPrice) invisible() else visible()
|
||||
}
|
||||
|
||||
binding.tvPayTip.text = SpannedUtils.getAmountText(getAmountList())
|
||||
if (memberInfo !=null && memberInfo!!.member) {
|
||||
binding.tvPayTip.text = SpannedUtils.getAmountText(getAmountList())
|
||||
} else {
|
||||
binding.tvPayTip.text = SpannedUtils.getAmountText(getAmountListNotMember())
|
||||
}
|
||||
}
|
||||
|
||||
2 -> {
|
||||
val memberInfo = activity.memberInfo
|
||||
binding.layoutVip.run {
|
||||
if (memberInfo != null) visible() else gone()
|
||||
if (memberInfo != null && memberInfo.member) visible() else gone()
|
||||
}
|
||||
binding.layoutPaySuccess.visible()
|
||||
binding.layoutScanQrCode.gone()
|
||||
|
||||
balance = if (memberInfo != null) (memberInfo.topUpBalance
|
||||
balance = if (memberInfo != null && memberInfo.member) (memberInfo.topUpBalance
|
||||
?: 0.0) + (memberInfo.rewardBalance ?: 0.0) else 0.0
|
||||
realPayPrice = if (balance >= totalPrice) 0.0 else totalPrice - balance
|
||||
expensesBalance = if (balance >= totalPrice) totalPrice else balance
|
||||
@@ -758,6 +765,22 @@ class PayPresentation(
|
||||
else phone
|
||||
}
|
||||
|
||||
private fun getAmountListNotMember(): List<TextBean> {
|
||||
val list: MutableList<TextBean> = mutableListOf()
|
||||
|
||||
list.add(TextBean(text = "应付金额 ", textSize = 30, textColor = "#FF889AC2"))
|
||||
list.add(
|
||||
TextBean(
|
||||
text = "-${totalPrice.format2String(2)}",
|
||||
textSize = 30,
|
||||
textColor = "#FF0A1428",
|
||||
isBold = true
|
||||
)
|
||||
)
|
||||
list.add(TextBean(text = " 元", textSize = 30, textColor = "#FF889AC2"))
|
||||
return list
|
||||
}
|
||||
|
||||
private fun getAmountList(): List<TextBean> {
|
||||
val list: MutableList<TextBean> = mutableListOf()
|
||||
|
||||
|
||||
@@ -65,7 +65,9 @@ abstract class BaseViewModel() : ViewModel() {
|
||||
}
|
||||
val message = response.msg
|
||||
Timber.d("msg = ${message}, code = $code")
|
||||
ToastUtils.showToast("${message}(${code})")
|
||||
if (message!=null && !message.startsWith("未知错误")) {
|
||||
ToastUtils.showToast("${message}(${code})")
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
@@ -106,10 +106,13 @@ class UserViewModel : BaseViewModel() {
|
||||
ToastUtils.showToast("查询人脸数据为空")
|
||||
return@withContext
|
||||
}
|
||||
// val item = list.firstOrNull { it.userId == "1951105919342936066" }
|
||||
// Timber.tag(TAG).d("getUserFaceCache userId = ${item?.userId}")
|
||||
val item = list.map { it.member }
|
||||
Timber.tag(TAG).d("getUserFaceCache item = ${item}")
|
||||
val faceEntity = list.map {
|
||||
FaceEntity(it.userId, null, Base64.decode(it.faceFeatureStr))
|
||||
FaceEntity(it.userId, null, Base64.decode(it.faceFeatureStr)).also { item->
|
||||
item.userType = if (it.member) "1" else "2"
|
||||
item.cardNo = it.cardNo
|
||||
}
|
||||
}
|
||||
faceApi.updateFaceData(currentPageNo, faceEntity)
|
||||
if (list.size >= pageSize) {
|
||||
|
||||
Reference in New Issue
Block a user