| | |
| | | import com.dayu.baselibrary.utils.ToastUtil |
| | | import com.dayu.general.bean.card.ClearCard |
| | | import com.dayu.general.bean.card.UserCard |
| | | import com.dayu.general.tool.CardCommon |
| | | import com.dayu.general.tool.CardOperationType |
| | | import com.dayu.general.dao.BaseDaoSingleton |
| | | import com.dayu.general.databinding.ActivityNfcWriteGeBinding |
| | | import com.dayu.general.net.ApiManager |
| | | import com.dayu.general.net.BaseResponse |
| | | import com.dayu.general.tool.CardOperationType |
| | | import com.dayu.general.tool.NfcReadHelper |
| | | import com.dayu.general.tool.NfcWreatHelper |
| | | import com.dayu.general.dao.BaseDaoSingleton |
| | | import com.tencent.bugly.crashreport.CrashReport |
| | | import kotlinx.coroutines.launch |
| | | import java.lang.StringBuilder |
| | | |
| | | /** |
| | | * @author: zuo |
| | |
| | | // 销卡相关信息 |
| | | private var refundAmount = 0.0 |
| | | private var cardBalance = 0.0 |
| | | |
| | | // 返还相关信息 |
| | | private var returnAmount = 0.0 |
| | | |
| | | //订单编号 |
| | | var orderNumber = "" |
| | |
| | | // 获取销卡相关信息 |
| | | refundAmount = intent?.getDoubleExtra("refundAmount", 0.0) ?: 0.0 |
| | | cardBalance = intent?.getDoubleExtra("cardBalance", 0.0) ?: 0.0 |
| | | |
| | | // 获取返还相关信息 |
| | | returnAmount = intent?.getDoubleExtra("returnAmount", 0.0) ?: 0.0 |
| | | |
| | | if (intent?.hasExtra("cardFee") == true) { |
| | | cardFee = intent?.getIntExtra("cardFee", 0) ?: 0 |
| | |
| | | binding?.cardData?.text = textData.toString() |
| | | } |
| | | |
| | | CardOperationType.ReturnCard -> { |
| | | var textData = StringBuilder() |
| | | textData.append("返还\n") |
| | | textData.append("卡内余额:" + MornyUtil.changeF2Y(userCard.balance) + "元\n") |
| | | textData.append("返还金额:" + returnAmount + "元") |
| | | binding?.cardData?.text = textData.toString() |
| | | } |
| | | |
| | | CardOperationType.CheckCard -> TODO() |
| | | CardOperationType.DeductCard -> TODO() |
| | | CardOperationType.ReplaceCard -> TODO() |
| | |
| | | }) |
| | | } |
| | | |
| | | CardOperationType.ReturnCard -> { |
| | | nfcWreatHelper.writeUserDataAsync(userCard, object : NFCCallBack { |
| | | override fun isSusses(flag: Boolean, msg: String?) { |
| | | // 确保Toast在主线程中调用 |
| | | runOnUiThread { |
| | | if (flag) { |
| | | postCardData(cardAddr) |
| | | } else { |
| | | ToastUtil.show("返还写卡失败: ${msg ?: "未知错误"}") |
| | | } |
| | | } |
| | | } |
| | | }) |
| | | } |
| | | |
| | | CardOperationType.CheckCard -> TODO() |
| | | CardOperationType.DeductCard -> TODO() |
| | | CardOperationType.ReplaceCard -> TODO() |
| | |
| | | finish() |
| | | Intent(this@NfcWreatActivity, CardWriteSuccessActivity::class.java).apply { |
| | | putExtra("cardNumber", cardNumber) |
| | | putExtra("operationTypeCode", operationTypeCode) |
| | | startActivity(this) |
| | | } |
| | | } |