支付调试优化

This commit is contained in:
2025-12-10 17:56:24 +08:00
parent 88d7530568
commit 6e318f8c82
13 changed files with 323 additions and 315 deletions
+2 -2
View File
@@ -4,10 +4,10 @@
<selectionStates> <selectionStates>
<SelectionState runConfigName="app"> <SelectionState runConfigName="app">
<option name="selectionMode" value="DROPDOWN" /> <option name="selectionMode" value="DROPDOWN" />
<DropdownSelection timestamp="2025-11-07T10:55:54.677927600Z"> <DropdownSelection timestamp="2025-12-10T08:38:49.440422600Z">
<Target type="DEFAULT_BOOT"> <Target type="DEFAULT_BOOT">
<handle> <handle>
<DeviceId pluginId="Default" identifier="serial=192.168.1.56:5555;connection=2687c52a" /> <DeviceId pluginId="Default" identifier="serial=192.168.1.177:5555;connection=45709318" />
</handle> </handle>
</Target> </Target>
</DropdownSelection> </DropdownSelection>
@@ -232,9 +232,9 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
val mealPickupMode = SPUtil.getInstance().get(GlobalKey.KEY_PICKUP_MODE, 0) ?: 0 val mealPickupMode = SPUtil.getInstance().get(GlobalKey.KEY_PICKUP_MODE, 0) ?: 0
val eatWeight = if (mealPickupMode == 0) { val eatWeight = if (mealPickupMode == 0) {
//即放即取 //即放即取
presentation?.recognitionWeight?:0.0 presentation!!.recognitionWeight
} else { } else {
presentation?.recognitionWeight?.minus(lastWeight)?:0.0 presentation!!.recognitionWeight - lastWeight
} }
createOrder( createOrder(
foodInfo = checkedItem!!, foodInfo = checkedItem!!,
@@ -684,6 +684,10 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
} }
fun createOrder(foodInfo: FoodInfo, foodWeight: Int, eatWeight: Int, block: () -> Unit) { fun createOrder(foodInfo: FoodInfo, foodWeight: Int, eatWeight: Int, block: () -> Unit) {
if (foodWeight <= 5 || eatWeight <= 5) {
ToastUtils.showToast("请取走餐品")
return
}
val mode = SPUtil.getInstance().get(GlobalKey.KEY_CHARGE_MODE, 0) val mode = SPUtil.getInstance().get(GlobalKey.KEY_CHARGE_MODE, 0)
val order = FoodOrder( val order = FoodOrder(
deviceId = GlobalData.deviceId, deviceId = GlobalData.deviceId,
@@ -217,6 +217,10 @@ class PayActivity : BaseActivity<ActivityPayBinding>() {
fun memberPay(param: HashMap<String, String>, block: () -> Unit) { fun memberPay(param: HashMap<String, String>, block: () -> Unit) {
userViewModel.memberPay(param) { userViewModel.memberPay(param) {
runOnUiThread { runOnUiThread {
if (it.not()) {
ToastUtils.showToast("支付失败,请稍后重试")
return@runOnUiThread
}
block() block()
} }
} }
@@ -53,15 +53,16 @@ class PayResultFragment : BaseFragment<FragmentPayResultBinding>() {
memberInfo = it.getParcelable(MEMBER_INFO) memberInfo = it.getParcelable(MEMBER_INFO)
} }
totalPrice = payActivity?.foodInfo?.vipPrice ?: 0.0
if (memberInfo != null) { if (memberInfo != null) {
binding.layoutMemberInfo.visible() totalPrice = payActivity?.foodInfo?.vipPrice ?: 0.0
binding.layoutVip.visible()
balance = (memberInfo!!.topUpBalance ?: 0.0) + (memberInfo!!.rewardBalance ?: 0.0) balance = (memberInfo!!.topUpBalance ?: 0.0) + (memberInfo!!.rewardBalance ?: 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
loadUserInfo(memberInfo!!) loadUserInfo(memberInfo!!)
} else { } else {
binding.layoutMemberInfo.gone() binding.layoutVip.gone()
totalPrice = payActivity?.foodInfo?.specPrice ?: 0.0
} }
when (pageType) { when (pageType) {
@@ -1,253 +1,253 @@
package com.sw.dualscreen.model.response //package com.sw.dualscreen.model.response
//
//
import android.os.Parcelable //import android.os.Parcelable
import android.text.TextUtils //import android.text.TextUtils
import com.google.gson.annotations.SerializedName //import com.google.gson.annotations.SerializedName
import kotlinx.parcelize.Parcelize //import kotlinx.parcelize.Parcelize
//
/** ///**
* 就餐数据 // * 就餐数据
*/ // */
@Parcelize //@Parcelize
data class UserNutritionData( //data class UserNutritionData(
/** // /**
* 总胆固醇 // * 总胆固醇
*/ // */
@SerializedName("cho") // @SerializedName("cho")
val cho: String? = "", // val cho: String? = "",
/** // /**
* 饮食纤维 // * 饮食纤维
*/ // */
@SerializedName("dietFiber") // @SerializedName("dietFiber")
val dietFiber: String? = "", // val dietFiber: String? = "",
/** // /**
* 能量 // * 能量
*/ // */
@SerializedName("energy") // @SerializedName("energy")
val energy: String? = "", // val energy: String? = "",
/** // /**
* 脂肪 // * 脂肪
*/ // */
@SerializedName("fat") // @SerializedName("fat")
val fat: String? = "", // val fat: String? = "",
/** // /**
* 食物类型和实际摄入量清单 // * 食物类型和实际摄入量清单
*/ // */
@SerializedName("foodTypeAndRealIntakeVoList") // @SerializedName("foodTypeAndRealIntakeVoList")
val foodTypeAndRealIntakeVoList: List<FoodTypeAndRealIntakeVo?>? = listOf(), // val foodTypeAndRealIntakeVoList: List<FoodTypeAndRealIntakeVo?>? = listOf(),
@SerializedName("foodWeight") // @SerializedName("foodWeight")
val foodWeight: String? = "", // val foodWeight: String? = "",
@SerializedName("message") // @SerializedName("message")
val message: String? = "", // val message: String? = "",
/** // /**
* 钠 // * 钠
*/ // */
@SerializedName("na") // @SerializedName("na")
val na: String? = "", // val na: String? = "",
/** // /**
* 蛋白质 // * 蛋白质
*/ // */
@SerializedName("protein") // @SerializedName("protein")
val protein: String? = "", // val protein: String? = "",
/** // /**
* 最大推荐热量 // * 最大推荐热量
*/ // */
@SerializedName("recommendMax") // @SerializedName("recommendMax")
val recommendMax: String? = "", // val recommendMax: String? = "",
/** // /**
* 最小推荐热量 // * 最小推荐热量
*/ // */
@SerializedName("recommendMin") // @SerializedName("recommendMin")
val recommendMin: String? = "", // val recommendMin: String? = "",
/** // /**
* 热量详情 // * 热量详情
*/ // */
@SerializedName("stFoodInfoPagoda") // @SerializedName("stFoodInfoPagoda")
val stFoodInfoPagoda: StFoodInfoPagoda? = StFoodInfoPagoda(), // val stFoodInfoPagoda: StFoodInfoPagoda? = StFoodInfoPagoda(),
@SerializedName("stUserFoodInfoList") // @SerializedName("stUserFoodInfoList")
val stUserFoodInfoList: List<StUserFoodInfo?>? = listOf(), // val stUserFoodInfoList: List<StUserFoodInfo?>? = listOf(),
/** // /**
* 每日总热量 // * 每日总热量
*/ // */
@SerializedName("totalEnergyCalculateScore") // @SerializedName("totalEnergyCalculateScore")
val totalEnergyCalculateScore: String? = "", // val totalEnergyCalculateScore: String? = "",
/** // /**
* 用户所在部门 // * 用户所在部门
*/ // */
@SerializedName("userDept") // @SerializedName("userDept")
val userDept: String? = "", // val userDept: String? = "",
/** // /**
* 用户id // * 用户id
*/ // */
@SerializedName("userId") // @SerializedName("userId")
val userId: String? = "", // val userId: String? = "",
/** // /**
* 姓名 // * 姓名
*/ // */
@SerializedName("userName") // @SerializedName("userName")
val userName: String? = "" // val userName: String? = ""
) : Parcelable { //) : Parcelable {
fun recommendMaxValue(): Double = // fun recommendMaxValue(): Double =
if (TextUtils.isEmpty(recommendMax)) 0.0 // if (TextUtils.isEmpty(recommendMax)) 0.0
else recommendMax!!.toDouble() // else recommendMax!!.toDouble()
//
fun recommendMinValue(): Double = // fun recommendMinValue(): Double =
if (TextUtils.isEmpty(recommendMin)) 0.0 // if (TextUtils.isEmpty(recommendMin)) 0.0
else recommendMin!!.toDouble() // else recommendMin!!.toDouble()
//
fun energyValue(): Double = // fun energyValue(): Double =
if (TextUtils.isEmpty(energy)) 0.0 // if (TextUtils.isEmpty(energy)) 0.0
else energy!!.toDouble() // else energy!!.toDouble()
//
fun totalEnergyCalculateScoreValue(): Double = // fun totalEnergyCalculateScoreValue(): Double =
if (TextUtils.isEmpty(totalEnergyCalculateScore)) 0.0 // if (TextUtils.isEmpty(totalEnergyCalculateScore)) 0.0
else totalEnergyCalculateScore!!.toDouble() // else totalEnergyCalculateScore!!.toDouble()
//
@Parcelize // @Parcelize
data class FoodTypeAndRealIntakeVo( // data class FoodTypeAndRealIntakeVo(
@SerializedName("childMaterClassName") // @SerializedName("childMaterClassName")
val childMaterClassName: String? = "", // val childMaterClassName: String? = "",
@SerializedName("foodId") // @SerializedName("foodId")
val foodId: String? = "", // val foodId: String? = "",
@SerializedName("goodsId") // @SerializedName("goodsId")
val goodsId: String? = "", // val goodsId: String? = "",
@SerializedName("goodsName") // @SerializedName("goodsName")
val goodsName: String? = "", // val goodsName: String? = "",
@SerializedName("materClassName") // @SerializedName("materClassName")
val materClassName: String? = "", // val materClassName: String? = "",
@SerializedName("materId") // @SerializedName("materId")
val materId: String? = "", // val materId: String? = "",
@SerializedName("materialType") // @SerializedName("materialType")
val materialType: String? = "", // val materialType: String? = "",
@SerializedName("realityIntake") // @SerializedName("realityIntake")
val realityIntake: String? = "" // val realityIntake: String? = ""
) : Parcelable // ) : Parcelable
//
@Parcelize // @Parcelize
data class StFoodInfoPagoda( // data class StFoodInfoPagoda(
/** // /**
* 水果 // * 水果
*/ // */
@SerializedName("fruits") // @SerializedName("fruits")
val fruits: String? = "", // val fruits: String? = "",
@SerializedName("fruitsRecommend") // @SerializedName("fruitsRecommend")
val fruitsRecommend: String? = "", // val fruitsRecommend: String? = "",
/** // /**
* 粮食 // * 粮食
*/ // */
@SerializedName("grain") // @SerializedName("grain")
val grain: String? = "", // val grain: String? = "",
@SerializedName("grainRecommend") // @SerializedName("grainRecommend")
val grainRecommend: String? = "", // val grainRecommend: String? = "",
/** // /**
* 肉 // * 肉
*/ // */
@SerializedName("meat") // @SerializedName("meat")
val meat: String? = "", // val meat: String? = "",
@SerializedName("meatRecommend") // @SerializedName("meatRecommend")
val meatRecommend: String? = "", // val meatRecommend: String? = "",
/** // /**
* 油 // * 油
*/ // */
@SerializedName("oil") // @SerializedName("oil")
val oil: String? = "", // val oil: String? = "",
/** // /**
* 盐 // * 盐
*/ // */
@SerializedName("salt") // @SerializedName("salt")
val salt: String? = "", // val salt: String? = "",
/** // /**
* 大豆 // * 大豆
*/ // */
@SerializedName("soya") // @SerializedName("soya")
val soya: String? = "", // val soya: String? = "",
@SerializedName("soyaRecommend") // @SerializedName("soyaRecommend")
val soyaRecommend: String? = "", // val soyaRecommend: String? = "",
/** // /**
* 糖 // * 糖
*/ // */
@SerializedName("sugar") // @SerializedName("sugar")
val sugar: String? = "", // val sugar: String? = "",
/** // /**
* 蔬菜 // * 蔬菜
*/ // */
@SerializedName("vegetable") // @SerializedName("vegetable")
val vegetable: String? = "", // val vegetable: String? = "",
@SerializedName("vegetableRecommend") // @SerializedName("vegetableRecommend")
val vegetableRecommend: String? = "" // val vegetableRecommend: String? = ""
) : Parcelable { // ) : Parcelable {
fun fruitsValue(): Double = // fun fruitsValue(): Double =
if (TextUtils.isEmpty(fruits)) // if (TextUtils.isEmpty(fruits))
0.0 // 0.0
else fruits!!.toDouble() // else fruits!!.toDouble()
//
fun grainValue(): Double = // fun grainValue(): Double =
if (TextUtils.isEmpty(grain)) // if (TextUtils.isEmpty(grain))
0.0 // 0.0
else grain!!.toDouble() // else grain!!.toDouble()
//
fun vegetableValue(): Double = // fun vegetableValue(): Double =
if (TextUtils.isEmpty(vegetable)) // if (TextUtils.isEmpty(vegetable))
0.0 // 0.0
else vegetable!!.toDouble() // else vegetable!!.toDouble()
//
fun meatValue(): Double = // fun meatValue(): Double =
if (TextUtils.isEmpty(meat)) // if (TextUtils.isEmpty(meat))
0.0 // 0.0
else meat!!.toDouble() // else meat!!.toDouble()
//
} // }
//
@Parcelize // @Parcelize
data class StUserFoodInfo( // data class StUserFoodInfo(
@SerializedName("canteenId") // @SerializedName("canteenId")
val canteenId: String? = "", // val canteenId: String? = "",
@SerializedName("createBy") // @SerializedName("createBy")
val createBy: String? = "", // val createBy: String? = "",
@SerializedName("createTime") // @SerializedName("createTime")
val createTime: String? = "", // val createTime: String? = "",
@SerializedName("dataSource") // @SerializedName("dataSource")
val dataSource: String? = "", // val dataSource: String? = "",
@SerializedName("dataType") // @SerializedName("dataType")
val dataType: String? = "", // val dataType: String? = "",
@SerializedName("delFlag") // @SerializedName("delFlag")
val delFlag: String? = "", // val delFlag: String? = "",
@SerializedName("deviceId") // @SerializedName("deviceId")
val deviceId: String? = "", // val deviceId: String? = "",
@SerializedName("dinnerType") // @SerializedName("dinnerType")
val dinnerType: String? = "", // val dinnerType: String? = "",
@SerializedName("eatDay") // @SerializedName("eatDay")
val eatDay: String? = "", // val eatDay: String? = "",
@SerializedName("eatNum") // @SerializedName("eatNum")
val eatNum: String? = "", // val eatNum: String? = "",
@SerializedName("eatWeight") // @SerializedName("eatWeight")
val eatWeight: Double? = 0.0, // val eatWeight: Double? = 0.0,
@SerializedName("foodId") // @SerializedName("foodId")
val foodId: String? = "", // val foodId: String? = "",
@SerializedName("foodImg") // @SerializedName("foodImg")
val foodImg: String? = "", // val foodImg: String? = "",
@SerializedName("foodMaterialId") // @SerializedName("foodMaterialId")
val foodMaterialId: String? = "", // val foodMaterialId: String? = "",
@SerializedName("foodName") // @SerializedName("foodName")
val foodName: String? = "", // val foodName: String? = "",
@SerializedName("foodWeight") // @SerializedName("foodWeight")
val foodWeight: String? = "", // val foodWeight: String? = "",
@SerializedName("id") // @SerializedName("id")
val id: String? = "", // val id: String? = "",
@SerializedName("isSync") // @SerializedName("isSync")
val isSync: String? = "", // val isSync: String? = "",
@SerializedName("isSyncCopy") // @SerializedName("isSyncCopy")
val isSyncCopy: String? = "", // val isSyncCopy: String? = "",
@SerializedName("specId") // @SerializedName("specId")
val specId: String? = "", // val specId: String? = "",
@SerializedName("stBasicDiningInformationUserESVo") // @SerializedName("stBasicDiningInformationUserESVo")
val stBasicDiningInformationUserESVo: String? = "", // val stBasicDiningInformationUserESVo: String? = "",
@SerializedName("stallType") // @SerializedName("stallType")
val stallType: String? = "", // val stallType: String? = "",
@SerializedName("type") // @SerializedName("type")
val type: String? = "", // val type: String? = "",
@SerializedName("userId") // @SerializedName("userId")
val userId: String? = "" // val userId: String? = ""
) : Parcelable // ) : Parcelable
} //}
@@ -9,10 +9,8 @@ import com.sw.dualscreen.model.response.FoodInfo
import com.sw.dualscreen.model.response.FoodSearchReq import com.sw.dualscreen.model.response.FoodSearchReq
import com.sw.dualscreen.model.response.FoodOrder import com.sw.dualscreen.model.response.FoodOrder
import com.sw.dualscreen.model.response.MemberInfo 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.UserFaceModel
import com.sw.dualscreen.model.response.UserNutrition import com.sw.dualscreen.model.response.UserNutrition
import com.sw.dualscreen.model.response.UserNutritionData
import com.sw.dualscreen.objbox.CollectedFoodInfo import com.sw.dualscreen.objbox.CollectedFoodInfo
import okhttp3.MultipartBody import okhttp3.MultipartBody
import okhttp3.RequestBody import okhttp3.RequestBody
@@ -166,11 +164,11 @@ interface ApiService {
/** /**
* 查询支付结果 * 查询支付结果
*/ */
@POST @GET
suspend fun queryOrderState( suspend fun queryOrderState(
@Url url: String = "${GlobalData.appBaseUrl}/terminal/neglect/pay/app/turnOrderInfo", @Url url: String = "${GlobalData.appBaseUrl}/terminal/neglect/pay/app/turnOrderInfo",
// @Query("orderNo") orderNo: String @Query("orderNo") orderNo: String
@Body param: HashMap<String, String> // @Body param: HashMap<String, String>
): ApiResponse<Any?> ): ApiResponse<Any?>
/** /**
@@ -31,12 +31,10 @@ import com.sw.dualscreen.ext.gone
import com.sw.dualscreen.ext.load import com.sw.dualscreen.ext.load
import com.sw.dualscreen.ext.maskName import com.sw.dualscreen.ext.maskName
import com.sw.dualscreen.ext.visible import com.sw.dualscreen.ext.visible
import com.sw.dualscreen.model.request.UserNutritionParam
import com.sw.dualscreen.model.response.DinnerType import com.sw.dualscreen.model.response.DinnerType
import com.sw.dualscreen.model.response.FoodInfo import com.sw.dualscreen.model.response.FoodInfo
import com.sw.dualscreen.model.response.UserEnergy import com.sw.dualscreen.model.response.UserEnergy
import com.sw.dualscreen.model.response.UserNutrition import com.sw.dualscreen.model.response.UserNutrition
import com.sw.dualscreen.model.response.UserNutritionData
import com.sw.dualscreen.utils.Debouncer import com.sw.dualscreen.utils.Debouncer
import com.sw.dualscreen.utils.SPUtil import com.sw.dualscreen.utils.SPUtil
import com.sw.dualscreen.viewmodel.UserViewModel import com.sw.dualscreen.viewmodel.UserViewModel
@@ -119,9 +117,16 @@ class MainScreenPresentation(
lastWeight = weight * 1000 // 将千克转成克 lastWeight = weight * 1000 // 将千克转成克
Timber.tag(TAG) Timber.tag(TAG)
.d("updateWeight lastWeight = $weight, currentStep = $currentStep, isGoStep1 = $isGoStep1") .d("updateWeight lastWeight = $weight, currentStep = $currentStep, isGoStep1 = $isGoStep1")
// if (lastWeight <= 5) { mealPickupMode = SPUtil.getInstance().get(GlobalKey.KEY_PICKUP_MODE, 0) ?: 0
// activity.isAnalyzing = false val chargeMode = SPUtil.getInstance().get(GlobalKey.KEY_CHARGE_MODE, 0)
// } if (mealPickupMode == 1 && chargeMode == 0) {
//余量计量+计费模式
recognitionWeight = lastWeight
if (weight > 5) {
//余量计量,有重量的情况下不回到重新识别状态
return
}
}
if (currentStep == 2 && lastWeight <= 5 && isGoStep1) { if (currentStep == 2 && lastWeight <= 5 && isGoStep1) {
//人脸识别过程中,秤上物品拿走 //人脸识别过程中,秤上物品拿走
isGoStep1 = false isGoStep1 = false
@@ -6,7 +6,6 @@ import com.sw.dualscreen.ext.toSafeDouble
import com.sw.dualscreen.model.response.FoodInfo import com.sw.dualscreen.model.response.FoodInfo
import com.sw.dualscreen.model.response.UserEnergy import com.sw.dualscreen.model.response.UserEnergy
import com.sw.dualscreen.model.response.UserNutrition import com.sw.dualscreen.model.response.UserNutrition
import com.sw.dualscreen.model.response.UserNutritionData
import timber.log.Timber import timber.log.Timber
import kotlin.math.max import kotlin.math.max
@@ -251,7 +251,7 @@ class FacePayPresentation(
var userId = faceEntity.userName var userId = faceEntity.userName
if (userId == null) return@Observer if (userId == null) return@Observer
// TODO: 测试支付用户id // TODO: 测试支付用户id
userId = "1987710988425662466" // userId = "1987710988425662466"
faceRecSuccess(userId) faceRecSuccess(userId)
}) })
@@ -1,5 +1,6 @@
package com.sw.dualscreen.presentation.pay package com.sw.dualscreen.presentation.pay
import android.annotation.SuppressLint
import android.app.Presentation import android.app.Presentation
import android.os.Bundle import android.os.Bundle
import android.view.Display import android.view.Display
@@ -47,9 +48,11 @@ class ScanQrCodePayPresentation(
//实际支付金额 //实际支付金额
private var realPayPrice = 0.0 private var realPayPrice = 0.0
//扣除余额 //扣除余额
private var expensesBalance = 0.0 private var expensesBalance = 0.0
@SuppressLint("SetTextI18n")
private fun initView() { private fun initView() {
when (type) { when (type) {
0 -> { 0 -> {
@@ -69,12 +72,14 @@ class ScanQrCodePayPresentation(
} }
1 -> { 1 -> {
binding.layoutVip.visible() val memberInfo = activity.memberInfo
binding.layoutVip.run {
if (memberInfo!=null) visible() else gone()
}
binding.layoutPaySuccess.gone() binding.layoutPaySuccess.gone()
binding.layoutScanQrCode.visible() binding.layoutScanQrCode.visible()
val memberInfo = activity.memberInfo //totalPrice = if (memberInfo != null) activity.foodInfo?.vipPrice else activity.foodInfo?.specPrice
totalPrice = activity.foodInfo?.vipPrice ?: 0.0
balance = (memberInfo?.topUpBalance ?: 0.0) + (memberInfo?.rewardBalance ?: 0.0) balance = (memberInfo?.topUpBalance ?: 0.0) + (memberInfo?.rewardBalance ?: 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
@@ -103,13 +108,15 @@ class ScanQrCodePayPresentation(
} }
2 -> { 2 -> {
binding.layoutVip.visible() val memberInfo = activity.memberInfo
binding.layoutVip.run {
if (memberInfo!=null) visible() else gone()
}
binding.layoutPaySuccess.visible() binding.layoutPaySuccess.visible()
binding.layoutScanQrCode.gone() binding.layoutScanQrCode.gone()
val memberInfo = activity.memberInfo //totalPrice = activity.foodInfo?.vipPrice ?: 0.0
totalPrice = activity.foodInfo?.vipPrice ?: 0.0 balance = if (memberInfo != null) (memberInfo.topUpBalance ?: 0.0)+(memberInfo.rewardBalance ?: 0.0) else 0.0
balance = (memberInfo?.topUpBalance ?: 0.0) + (memberInfo?.rewardBalance ?: 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
@@ -122,8 +129,9 @@ class ScanQrCodePayPresentation(
) )
) )
binding.tvPayInfo.text = val showBalance = expensesBalance.format2String(2)
"余额扣除 ${expensesBalance.format2String(2)} 元,在线支付 ${totalPrice.format2String(2)}" val showTotal = totalPrice.format2String(2)
binding.tvPayInfo.text = "余额扣除 $showBalance 元,在线支付 $showTotal"
} }
} }
} }
@@ -134,10 +142,8 @@ class ScanQrCodePayPresentation(
val phone = item.phone ?: "" val phone = item.phone ?: ""
binding.tvUserPhone.text = binding.tvUserPhone.text =
if (phone.length == 11) if (phone.length == 11) phone.replace(phone.substring(3, 7), "****")
phone.replace(phone.substring(3, 7), "****") else phone
else
phone
} }
private fun getAmountList(): List<TextBean> { private fun getAmountList(): List<TextBean> {
@@ -157,9 +163,7 @@ class ScanQrCodePayPresentation(
TextBean(text = " 元,扣除后可用余额 ", textSize = 30, textColor = "#FF5E7585") TextBean(text = " 元,扣除后可用余额 ", textSize = 30, textColor = "#FF5E7585")
val remainingBalance = balance - totalPrice val remainingBalance = balance - totalPrice
TextBean( TextBean(
text = remainingBalance.format2String(2), text = remainingBalance.format2String(2), textSize = 30, textColor = "#FF0A1428"
textSize = 30,
textColor = "#FF0A1428"
) )
} else { } else {
//余额小于总价格,使用余额+扫码支付 //余额小于总价格,使用余额+扫码支付
@@ -9,10 +9,8 @@ import com.sw.dualscreen.model.response.FoodInfo
import com.sw.dualscreen.model.response.FoodSearchReq import com.sw.dualscreen.model.response.FoodSearchReq
import com.sw.dualscreen.model.response.FoodOrder import com.sw.dualscreen.model.response.FoodOrder
import com.sw.dualscreen.model.response.MemberInfo 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.UserFaceModel
import com.sw.dualscreen.model.response.UserNutrition import com.sw.dualscreen.model.response.UserNutrition
import com.sw.dualscreen.model.response.UserNutritionData
import com.sw.dualscreen.network.api.ApiService import com.sw.dualscreen.network.api.ApiService
import com.sw.dualscreen.objbox.CollectedFoodInfo import com.sw.dualscreen.objbox.CollectedFoodInfo
import okhttp3.MediaType.Companion.toMediaTypeOrNull import okhttp3.MediaType.Companion.toMediaTypeOrNull
@@ -207,15 +205,11 @@ class RemoteRepository constructor(
/** /**
* 查询订单状态 * 查询订单状态
* @param orderNo 订单 * @param orderNo 订单
* @param queryType 查询类型 1支付2退款
*/ */
suspend fun queryOrderState(orderNo: String, queryType: Int = 1): ApiResponse<Any?> { suspend fun queryOrderState(orderNo: String): ApiResponse<Any?> {
return safeApiCall { return safeApiCall {
apiService.queryOrderState(param = hashMapOf( apiService.queryOrderState(orderNo = orderNo)
"payOrderNo" to orderNo,
"queryType" to "$queryType"
))
} }
} }
@@ -5,7 +5,6 @@ import com.arcsoft.face.ErrorInfo
import com.sw.dualscreen.GlobalData import com.sw.dualscreen.GlobalData
import com.sw.dualscreen.GlobalKey import com.sw.dualscreen.GlobalKey
import com.sw.dualscreen.model.request.UserNutritionParam import com.sw.dualscreen.model.request.UserNutritionParam
import com.sw.dualscreen.model.response.ApiResponse
import com.sw.dualscreen.model.response.DinnerType import com.sw.dualscreen.model.response.DinnerType
import com.sw.dualscreen.model.response.FoodInfo import com.sw.dualscreen.model.response.FoodInfo
import com.sw.dualscreen.model.response.FoodOrder import com.sw.dualscreen.model.response.FoodOrder
@@ -14,7 +13,6 @@ import com.sw.dualscreen.model.response.PayResult
import com.sw.dualscreen.model.response.UserFaceModel import com.sw.dualscreen.model.response.UserFaceModel
import com.sw.dualscreen.model.response.UserFaceModel2 import com.sw.dualscreen.model.response.UserFaceModel2
import com.sw.dualscreen.model.response.UserNutrition import com.sw.dualscreen.model.response.UserNutrition
import com.sw.dualscreen.model.response.UserNutritionData
import com.sw.dualscreen.objbox.CollectedFoodInfo import com.sw.dualscreen.objbox.CollectedFoodInfo
import com.sw.dualscreen.utils.GsonUtils import com.sw.dualscreen.utils.GsonUtils
import com.sw.dualscreen.utils.SPUtil import com.sw.dualscreen.utils.SPUtil
@@ -49,8 +47,8 @@ class UserViewModel : BaseViewModel() {
val searchFoodInfoList: StateFlow<List<FoodInfo>> = _searchFoodInfoList val searchFoodInfoList: StateFlow<List<FoodInfo>> = _searchFoodInfoList
// 就餐数据 // 就餐数据
private val _nutritionData = MutableStateFlow<UserNutritionData?>(null) // private val _nutritionData = MutableStateFlow<UserNutritionData?>(null)
val nutritionData: StateFlow<UserNutritionData?> = _nutritionData // val nutritionData: StateFlow<UserNutritionData?> = _nutritionData
/** /**
* 饭点类型 早餐/午餐/晚餐 * 饭点类型 早餐/午餐/晚餐
@@ -388,15 +386,16 @@ class UserViewModel : BaseViewModel() {
Timber.tag(TAG).d("queryOrderState") Timber.tag(TAG).d("queryOrderState")
val response = repository.queryOrderState(orderNo = orderId) val response = repository.queryOrderState(orderNo = orderId)
if (parseResponse(response)) { if (parseResponse(response)) {
val respData = response.data as? String //val respData = response.data as? String
?: if (response.data is Any) { // ?: if (response.data is Any) {
GsonUtils.toJson(response.data) // GsonUtils.toJson(response.data)
} else { // } else {
"" // ""
} // }
val payResult = GsonUtils.fromJson(respData, PayResult::class.java) //al payResult = GsonUtils.fromJson(respData, PayResult::class.java)
val orderState = payResult?.paySuc == "1" //val orderState = payResult?.paySuc == "1"
block(orderState) //data=1的话 是支付成功 0是待支付
block(response.data == "1")
} else { } else {
block(false) block(false)
} }
@@ -9,7 +9,7 @@
tools:background="#FFF4FAFF"> tools:background="#FFF4FAFF">
<androidx.cardview.widget.CardView <androidx.cardview.widget.CardView
android:id="@+id/layoutMemberInfo" android:id="@+id/layoutVip"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:cardBackgroundColor="@color/white" app:cardBackgroundColor="@color/white"