| | |
| | | |
| | | // 支付方式相关属性 |
| | | private var paymentMethod: String = "现金" |
| | | private var paymentId: Long = 0 |
| | | private var paymentId: String = "" |
| | | private var paymentMethodList: List<PaymentMethod> = listOf() |
| | | |
| | | companion object { |
| | |
| | | private fun getPaymentMethods() { |
| | | ApiManager.getInstance().requestGetLoading( |
| | | this, |
| | | "sell/paymentmethod/get", |
| | | PaymentMethodResponse::class.java, |
| | | "terminal/paymentmethod/get", |
| | | Array<PaymentMethod>::class.java, |
| | | null, |
| | | object : SubscriberListener<BaseResponse<PaymentMethodResponse>>() { |
| | | override fun onNext(response: BaseResponse<PaymentMethodResponse>) { |
| | | object : SubscriberListener<BaseResponse<Array<PaymentMethod>>>() { |
| | | override fun onNext(response: BaseResponse<Array<PaymentMethod>>) { |
| | | if (response.success) { |
| | | // 获取支付方式列表 |
| | | val paymentMethods = response.content?.obj ?: listOf() |
| | | // 获取支付方式列表,现在content直接是PaymentMethod数组 |
| | | val paymentMethods = response.content?.toList() ?: listOf() |
| | | if (paymentMethods.isNotEmpty()) { |
| | | paymentMethodList = paymentMethods |
| | | // 更新支付方式显示 |
| | |
| | | 0.0 |
| | | } |
| | | |
| | | // 获取当前余额(转换为元) |
| | | val currentBalance = userCard?.let { |
| | | // 将分转换为元 |
| | | it.balance / 100.0 |
| | | } ?: run { |
| | | // 如果用户卡为空,则使用服务器返回的余额 |
| | | cardInfo?.balance ?: 0.0 |
| | | } |
| | | |
| | | // 计算充值后的总余额 |
| | | val totalAmountAfterRecharge = currentBalance + rechargeAmount + bonusAmount |
| | | |
| | | // 检查是否超过最大余额限制9999.99元 |
| | | if (totalAmountAfterRecharge > 9999.99) { |
| | | val maxRechargeAmount = 9999.99 - currentBalance |
| | | ToastUtil.show("充值失败:充值后余额不能超过9999.99元\n当前余额:${String.format("%.2f", currentBalance)}元\n最多可充值:${String.format("%.2f", maxRechargeAmount)}元") |
| | | return |
| | | } |
| | | |
| | | // 调用充值接口 |
| | | callRechargeApi(rechargeAmount, bonusAmount) |
| | | } |
| | |
| | | money = String.format("%.0f", rechargeAmount), |
| | | amount = String.format("%.0f", bonusAmount), |
| | | gift = String.format("%.0f", bonusAmount), |
| | | paymentId = paymentId.toString(), |
| | | paymentId = paymentId, |
| | | price = String.format("%.2f", currentWaterPrice), // 使用统一获取的水价 |
| | | remarks = "充值", |
| | | operator = BaseApplication.userId // 默认操作员ID,可以根据实际情况调整 |