| | |
| | | import com.dayu.general.databinding.ActivityNewCardGeBinding |
| | | import com.dayu.general.net.ApiManager |
| | | import com.dayu.general.net.BaseResponse |
| | | import com.dayu.general.tool.BaseCommon.Companion.protocol |
| | | import com.dayu.general.tool.CardCommon.Companion.USER_CARD_TYPE_1 |
| | | import com.dayu.general.tool.CardOperationType |
| | | import com.dayu.general.tool.NfcReadHelper |
| | |
| | | private var paymentMethod: String = "现金" |
| | | |
| | | // 支付方式ID |
| | | private var paymentId: Long = 0 |
| | | private var paymentId: String = "" |
| | | |
| | | // 支付方式列表 |
| | | private var paymentMethodList: List<PaymentMethod> = listOf() |
| | |
| | | // 客户ID |
| | | private var clientId: String = "" |
| | | |
| | | private lateinit var clientInfo : ClientInfo |
| | | private lateinit var clientInfo: ClientInfo |
| | | |
| | | // 是否已读卡 |
| | | private var isReadCard: Boolean = false |
| | | |
| | | private var orderId:String="" |
| | | private var orderId: String = "" |
| | | |
| | | companion object { |
| | | private const val TAG = "NewCard2Activity" |
| | |
| | | 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 |
| | | // 更新支付方式显示 |
| | |
| | | params["amount"] = rechargeAmount // 充值金额(元) |
| | | params["paymentId"] = paymentId // 支付方式ID |
| | | params["remarks"] = remark // 备注 |
| | | params["protocol"] = "p206V1_0_1" // 协议 |
| | | params["protocol"] = protocol // 协议 |
| | | params["operator"] = BaseApplication.userId // 操作人ID |
| | | |
| | | // 执行卡片激活API请求 |
| | |
| | | object : SubscriberListener<BaseResponse<NewCardDataResult>>() { |
| | | override fun onNext(response: BaseResponse<NewCardDataResult>) { |
| | | if (response.success) { |
| | | orderId=response.content?.orderNo.toString() |
| | | orderId = response.content?.orderNo.toString() |
| | | // 保存开卡信息到数据库 |
| | | val cardRegistration = CardRegistrationBean( |
| | | cardNumber = cardPhysicalId, |
| | |
| | | clientId = clientId, |
| | | cardFee = cardFee, |
| | | remark = binding.newCardRemark.text.toString(), |
| | | paymentMethod = paymentId.toInt(), |
| | | paymentMethod = paymentId.toLongOrNull()?.toInt() ?: 0, |
| | | isReported = true, |
| | | isCardWritten = false, // 初始设置为false,写卡成功后再更新为true |
| | | operatorId = orderId, |
| | |
| | | putExtra("orderNumber", orderId) |
| | | putExtra("cardAddr", cardPhysicalId) |
| | | var userCard = UserCard() |
| | | userCard.areaNumber = response.content?.cardNum?.substring(0, 12).toString() |
| | | userCard.userCode =clientInfo.clientNum |
| | | userCard.phoneNumber =clientInfo.phone |
| | | userCard.userCodeNumber = response.content?.cardNum?.substring(12)?.toInt()!! |
| | | userCard.areaNumber = |
| | | response.content?.cardNum?.substring(0, 12).toString() |
| | | userCard.userCode = clientInfo.clientNum |
| | | userCard.phoneNumber = clientInfo.phone |
| | | userCard.userCodeNumber = |
| | | response.content?.cardNum?.substring(12)?.toInt()!! |
| | | userCard.projectCode = response.content?.projectNo!! |
| | | userCard.balance = MornyUtil.changeY2F(response.content?.balance) |
| | | userCard.balance = |
| | | MornyUtil.changeY2F(response.content?.balance) |
| | | // userCard.surplusWater = response.content?.surplusWater?.toInt()!! |
| | | userCard.waterPrice = response.content?.waterPrice?.toFloat()!! |
| | | // userCard.electricPrice = response.content?.electricPrice?.toFloat()!! |
| | | userCard.rechargeDate = DateUtils.parseStringToCalendar(response.content?.time) |
| | | userCard.waterPrice = |
| | | MornyUtil.changeY2F(response.content?.waterPrice) |
| | | userCard.electricPrice = |
| | | MornyUtil.changeY2F(response.content?.waterPrice) |
| | | userCard.rechargeDate = |
| | | DateUtils.parseStringToCalendar(response.content?.time) |
| | | |
| | | // 输出userCard的所有信息到日志 |
| | | android.util.Log.d( |
| | | "NewCard2Activity", |
| | | "=== 开卡UserCard信息 ===" |
| | | ) |
| | | android.util.Log.d( |
| | | "NewCard2Activity", |
| | | "卡片类型: ${userCard.cardType}" |
| | | ) |
| | | android.util.Log.d( |
| | | "NewCard2Activity", |
| | | "国家行政区域号: ${userCard.areaNumber}" |
| | | ) |
| | | android.util.Log.d( |
| | | "NewCard2Activity", |
| | | "用户编号: ${userCard.userCode}" |
| | | ) |
| | | android.util.Log.d( |
| | | "NewCard2Activity", |
| | | "用户卡编号: ${userCard.userCodeNumber}" |
| | | ) |
| | | android.util.Log.d( |
| | | "NewCard2Activity", |
| | | "完整用户编号: ${userCard.getMyUserCode()}" |
| | | ) |
| | | android.util.Log.d( |
| | | "NewCard2Activity", |
| | | "手机号: ${userCard.phoneNumber}" |
| | | ) |
| | | android.util.Log.d( |
| | | "NewCard2Activity", |
| | | "项目编码: ${userCard.projectCode}" |
| | | ) |
| | | android.util.Log.d( |
| | | "NewCard2Activity", |
| | | "卡内余额: ${userCard.balance}" |
| | | ) |
| | | android.util.Log.d( |
| | | "NewCard2Activity", |
| | | "剩余水量: ${userCard.surplusWater}" |
| | | ) |
| | | android.util.Log.d( |
| | | "NewCard2Activity", |
| | | "水量单价: ${userCard.waterPrice}" |
| | | ) |
| | | android.util.Log.d( |
| | | "NewCard2Activity", |
| | | "电量单价: ${userCard.electricPrice}" |
| | | ) |
| | | android.util.Log.d( |
| | | "NewCard2Activity", |
| | | "充值时间: ${userCard.rechargeDate}" |
| | | ) |
| | | android.util.Log.d("NewCard2Activity", "==================") |
| | | |
| | | putExtra("userCard", userCard) |
| | | putExtra("operationTypeCode", CardOperationType.OpenCard.code) |
| | | putExtra("cardFee", cardFee) |