增加支付接口相关逻辑
This commit is contained in:
@@ -14,6 +14,7 @@ import com.sw.dualscreen.model.response.MemberInfo
|
||||
import com.sw.dualscreen.presentation.pay.ScanQrCodePayPresentation
|
||||
import com.sw.dualscreen.viewmodel.BaseViewModel
|
||||
import com.sw.dualscreen.viewmodel.UserViewModel
|
||||
import com.sw.plate.utils.ToastUtils
|
||||
import com.sw.plate.utils.arcface.viewmodel.RecognizeViewModel
|
||||
|
||||
class PayActivity : BaseActivity<ActivityPayBinding>() {
|
||||
@@ -52,13 +53,13 @@ class PayActivity : BaseActivity<ActivityPayBinding>() {
|
||||
var facePayFragment: FacePayFragment? = null
|
||||
private var payResultFragment: PayResultFragment? = null
|
||||
|
||||
var foodOrderId:String = ""
|
||||
var foodOrderId: String = ""
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
override fun initialize() {
|
||||
super.initialize()
|
||||
foodInfo = intent.getParcelableExtra(FOOD_INFO)
|
||||
foodOrderId = intent.getStringExtra(FOOD_ORDER_ID)?:""
|
||||
foodOrderId = intent.getStringExtra(FOOD_ORDER_ID) ?: ""
|
||||
// totalAmount = intent.getDoubleExtra(TOTAL_AMOUNT,0.0)
|
||||
// memberInfo = intent.getParcelableExtra(MEMBER_INFO)
|
||||
binding.tvFoodName.text = foodInfo?.foodName
|
||||
@@ -164,40 +165,63 @@ class PayActivity : BaseActivity<ActivityPayBinding>() {
|
||||
|
||||
private var scanQrCodePayPresentation: ScanQrCodePayPresentation? = null
|
||||
var memberInfo: MemberInfo? = null
|
||||
fun showPayInfo(memberInfo: MemberInfo) {
|
||||
fun showPayInfo(type: Int = 1, isVip: Boolean = false, memberInfo: MemberInfo? = null) {
|
||||
this.memberInfo = memberInfo
|
||||
payResultFragment = PayResultFragment.instance(1, memberInfo)
|
||||
payResultFragment = PayResultFragment.instance(type, memberInfo)
|
||||
showFragment(payResultFragment!!, TAG_PAY_RESULT)
|
||||
if (displays.size > 1) {
|
||||
scanQrCodePayPresentation = ScanQrCodePayPresentation(
|
||||
activity = this,
|
||||
display = displays[1],
|
||||
type = 1
|
||||
type = type
|
||||
) {
|
||||
scanQrCodePayPresentation?.dismiss()
|
||||
}.also {
|
||||
it.foodName = foodInfo?.foodName
|
||||
it.totalPrice = foodInfo?.vipPrice?:0.0
|
||||
//确认使用vipPrice 还是 specPrice
|
||||
val totalPrice = if (isVip) foodInfo?.vipPrice else foodInfo?.specPrice
|
||||
it.totalPrice = totalPrice ?: 0.0
|
||||
}
|
||||
scanQrCodePayPresentation?.show()
|
||||
}
|
||||
}
|
||||
|
||||
fun showPaySuccess() {
|
||||
payResultFragment = PayResultFragment.instance(2, memberInfo!!)
|
||||
showFragment(payResultFragment!!, TAG_PAY_RESULT)
|
||||
if (displays.size > 1) {
|
||||
scanQrCodePayPresentation = ScanQrCodePayPresentation(
|
||||
activity = this,
|
||||
display = displays[1],
|
||||
type = 2
|
||||
) {
|
||||
scanQrCodePayPresentation?.dismiss()
|
||||
}.also {
|
||||
it.foodName = foodInfo?.foodName
|
||||
it.totalPrice = foodInfo?.vipPrice?:0.0
|
||||
fun showPaySuccess(isVip: Boolean) {
|
||||
showPayInfo(type = 2, isVip = isVip, memberInfo = memberInfo)
|
||||
}
|
||||
|
||||
fun getQrCodeImg(orderId: String, userId: String? = null, block: (String?) -> Unit) {
|
||||
userViewModel.getQrCodeImg(orderId = orderId, userId = userId) { qrCodeImg ->
|
||||
runOnUiThread {
|
||||
if (qrCodeImg.isNullOrBlank()) {
|
||||
ToastUtils.showToast("获取二维码失败")
|
||||
return@runOnUiThread
|
||||
}
|
||||
block(qrCodeImg)
|
||||
}
|
||||
scanQrCodePayPresentation?.show()
|
||||
}
|
||||
}
|
||||
|
||||
fun cashPay(param: HashMap<String, String>, block: (Boolean) -> Unit) {
|
||||
userViewModel.cashPay(param) {
|
||||
runOnUiThread {
|
||||
block(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun memberPay(param: HashMap<String, String>, block: () -> Unit) {
|
||||
userViewModel.memberPay(param) {
|
||||
runOnUiThread {
|
||||
block()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun paySuccessCallback(isVip: Boolean, block: () -> Unit = {}) {
|
||||
userViewModel.paySuccessCallback(queryType = 1, orderId = foodOrderId) {
|
||||
showPaySuccess(isVip)
|
||||
block()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user