增加消费码支付功能、支付逻辑优化、金额问题优化、订单绑定优化

This commit is contained in:
2025-12-12 17:50:51 +08:00
parent a0847d21b7
commit 1d0e1a62e2
24 changed files with 507 additions and 247 deletions
@@ -9,12 +9,10 @@ import com.sw.dualscreen.model.response.DinnerType
import com.sw.dualscreen.model.response.FoodInfo
import com.sw.dualscreen.model.response.FoodOrder
import com.sw.dualscreen.model.response.MemberInfo
import com.sw.dualscreen.model.response.PayResult
import com.sw.dualscreen.model.response.UserFaceModel
import com.sw.dualscreen.model.response.UserFaceModel2
import com.sw.dualscreen.model.response.UserNutrition
import com.sw.dualscreen.objbox.CollectedFoodInfo
import com.sw.dualscreen.utils.GsonUtils
import com.sw.dualscreen.utils.SPUtil
import com.sw.plate.App
import com.sw.plate.utils.Base64
@@ -277,10 +275,16 @@ class UserViewModel : BaseViewModel() {
/**
* 获取支付二维码
*/
fun getQrCodeImg(orderId: String, userId: String? = null, totalFee: String?=null, block: (String?) -> Unit) {
fun getQrCodeImg(
orderId: String,
userId: String? = null,
totalFee: String? = null,
block: (String?) -> Unit
) {
Timber.tag(TAG).d("getQrCodeImg orderId = $orderId, userId = $userId")
launch {
val response = repository.getQrCodeImg(orderNo = orderId, memberId = userId, totalFee = totalFee)
val response =
repository.getQrCodeImg(orderNo = orderId, memberId = userId, totalFee = totalFee)
if (parseResponse(response)) {
block(response.data)
} else {
@@ -419,10 +423,10 @@ class UserViewModel : BaseViewModel() {
/**
* 绑定订单
*/
fun bindOrder(userId: String, orderId: String, block: (Boolean) -> Unit) {
fun bindOrder(userId: String, orderId: String, mode: Int, block: (Boolean) -> Unit) {
Timber.tag(TAG).d("bindOrder")
launchWithLoading {
val response = repository.bindOrder(userId = userId, orderId = orderId)
val response = repository.bindOrder(userId = userId, orderId = orderId, mode =mode)
if (parseResponse(response)) {
block(true)
} else {
@@ -431,10 +435,22 @@ class UserViewModel : BaseViewModel() {
}
}
fun getMemberInfo(memberId: String, block: (MemberInfo?) -> Unit) {
fun getMemberInfoById(memberId: String, block: (MemberInfo?) -> Unit) {
Timber.tag(TAG).d("getMemberInfo")
launchWithLoading {
val response = repository.getMemberInfo(memberId)
val response = repository.getMemberInfoById(memberId)
if (parseResponse(response)) {
block(response.data)
} else {
block(null)
}
}
}
fun getMemberInfoByPhone(phone: String, key: String, block: (MemberInfo?) -> Unit) {
Timber.tag(TAG).d("getMemberInfo")
launchWithLoading {
val response = repository.getMemberInfoByPhone(phone, key)
if (parseResponse(response)) {
block(response.data)
} else {