左晓为主开发手持机充值管理机
generallibrary/src/main/java/com/dayu/general/activity/NewCard2Activity.kt
@@ -172,17 +172,48 @@
        ApiManager.getInstance().requestGetLoading(
            this,
            "terminal/paymentmethod/get",
            Array<PaymentMethod>::class.java,
            Any::class.java,
            null,
            object : SubscriberListener<BaseResponse<Array<PaymentMethod>>>() {
                override fun onNext(response: BaseResponse<Array<PaymentMethod>>) {
            object : SubscriberListener<BaseResponse<Any>>() {
                override fun onNext(response: BaseResponse<Any>) {
                    if (response.success) {
                        // 获取支付方式列表,现在content直接是PaymentMethod数组
                        val paymentMethods = response.content?.toList() ?: listOf()
                        try {
                            // 安全地处理返回的content,服务器返回的是ArrayList<LinkedHashMap>
                            val paymentMethods = mutableListOf<PaymentMethod>()
                            val content = response.content
                            if (content is List<*>) {
                                content.forEach { item ->
                                    if (item is Map<*, *>) {
                                        val id = item["id"]?.toString() ?: ""
                                        val name = item["name"]?.toString() ?: ""
                                        if (id.isNotEmpty() && name.isNotEmpty()) {
                                            paymentMethods.add(PaymentMethod(id, name))
                                        }
                                    }
                                }
                            }
                        if (paymentMethods.isNotEmpty()) {
                            paymentMethodList = paymentMethods
                            // 更新支付方式显示
                            updatePaymentMethodRadioGroup()
                            } else {
                                Toast.makeText(
                                    this@NewCard2Activity,
                                    "获取支付方式失败:返回数据为空",
                                    Toast.LENGTH_SHORT
                                ).show()
                            }
                        } catch (e: Exception) {
                            android.util.Log.e("NewCard2Activity", "解析支付方式数据失败", e)
                            android.util.Log.e("NewCard2Activity", "原始数据类型: ${response.content?.javaClass?.name}")
                            android.util.Log.e("NewCard2Activity", "原始数据内容: ${response.content}")
                            Toast.makeText(
                                this@NewCard2Activity,
                                "解析支付方式数据失败: ${e.message}",
                                Toast.LENGTH_SHORT
                            ).show()
                        }
                    } else {
                        Toast.makeText(
@@ -195,6 +226,7 @@
                override fun onError(e: Throwable?) {
                    super.onError(e)
                    android.util.Log.e("NewCard2Activity", "网络请求失败", e)
                    Toast.makeText(
                        this@NewCard2Activity,
                        "获取支付方式失败: ${e?.message ?: "网络异常"}",