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