| | |
| | | String userName; |
| | | String cardNumber = null; |
| | | UserCardBean userCardBean; |
| | | int waterPrice; |
| | | String rechageWater;//充值的水量 |
| | | |
| | | @Override |
| | | protected void onCreate(Bundle savedInstanceState) { |
| | |
| | | setContentView(binding.getRoot()); |
| | | setPricePoint(binding.rechargeWater); |
| | | rechargeActivity = this; |
| | | waterPrice = baseDao.adminDao().findFirst().getWaterPrice(); |
| | | initView(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | |
| | | String state = ""; |
| | | if (cardType.equalsIgnoreCase(CardCommon.USER_CARD_TYPE_1)) { |
| | | state = "终端写卡"; |
| | | binding.rechargeTextLL.setVisibility(View.VISIBLE); |
| | | binding.rechargeRegistBtn.setVisibility(View.VISIBLE); |
| | | } else if (cardType.equalsIgnoreCase(CardCommon.USER_CARD_TYPE_2)) { |
| | | state = "刷卡开泵后,当前状态不能充值"; |
| | | binding.rechargeLL.setVisibility(View.GONE); |
| | | binding.rechargeRegistBtn.setVisibility(View.GONE); |
| | | } else if (cardType.equalsIgnoreCase(CardCommon.USER_CARD_TYPE_3)) { |
| | | state = "叠加充值"; |
| | | binding.rechargeLL.setVisibility(View.GONE); |
| | | binding.rechargeRegistBtn.setVisibility(View.GONE); |
| | | } else { |
| | | TipUtil.show(this, "非用户卡,不能充值"); |
| | | return; |
| | |
| | | AdminDataBean adminDataBean = baseDao.adminDao().findFirst(); |
| | | |
| | | |
| | | if (adminDataBean.addressCode.equalsIgnoreCase(String.valueOf(userCard.getArerNumber()))) { |
| | | if (Integer.valueOf(adminDataBean.getAddressCode()) == userCard.getArerNumber()) { |
| | | if (!userCardBeans.isEmpty()) { |
| | | userCardBean = userCardBeans.get(0); |
| | | this.userName = userCardBean.getUserName(); |
| | |
| | | } |
| | | |
| | | binding.rechargeReadLL.setVisibility(View.GONE); |
| | | binding.rechargeTextLL.setVisibility(View.VISIBLE); |
| | | binding.rechargeRegistBtn.setVisibility(View.VISIBLE); |
| | | binding.userName.setText(userName); |
| | | binding.redStatu.setText(state); |
| | | if (userCard != null) { |
| | |
| | | binding.redRechargeDate.setText("本卡最后购水日期:无"); |
| | | } |
| | | binding.redInitCode.setText(cardNumber); |
| | | binding.redRechargeNumber.setText("本卡充值次数:" + userCard.getRechargeTimes() + ""); |
| | | binding.redTotalWater.setText("总用水量:" + userCard.getTotalWater()); |
| | | binding.redTotalPower.setText("总用电量:" + userCard.getTotalElectric()); |
| | | binding.redRemainderBlance.setText(MornyUtil.changeF2Y(userCard.getBalance()) + "元"); |
| | | binding.redRemainderWater.setText("剩余水量:" + userCard.getSurplusWater()); |
| | | binding.redRechargeNumber.setText("本卡充值次数:" + userCard.getRechargeTimes() + " 次"); |
| | | binding.redTotalWater.setText("总用水量:" + MornyUtil.changeF2Y(userCard.getTotalWater()) + " 吨"); |
| | | binding.redTotalPower.setText("总用电量:" + MornyUtil.changeF2Y(userCard.getTotalElectric()) + " 度"); |
| | | binding.redRemainderBlance.setText(MornyUtil.changeF2Y(userCard.getBalance()) + " 元"); |
| | | binding.redRemainderWater.setText("剩余水量:" + MornyUtil.changeF2Y(userCard.getSurplusWater()) + " 吨"); |
| | | binding.redWaterPrice.setText("每立方米水价格:" + MornyUtil.changeF2Y(adminData.getWaterPrice()) + " 元"); |
| | | } |
| | | |
| | | } else { |
| | |
| | | intent.putExtra("cardNumber", cardNumber); |
| | | intent.putExtra("userCard", userCard); |
| | | intent.putExtra("userCardBean", userCardBean); |
| | | intent.putExtra("rechageWater", rechageWater); |
| | | startActivity(intent); |
| | | } else { |
| | | TipUtil.show(RechargeActivity.this, "请输入充值金额(元)"); |
| | |
| | | |
| | | |
| | | //校验金额 |
| | | public static void setPricePoint(final EditText editText) { |
| | | public void setPricePoint(final EditText editText) { |
| | | editText.addTextChangedListener(new TextWatcher() { |
| | | @Override |
| | | public void onTextChanged(CharSequence s, int start, int before, |
| | |
| | | editText.setSelection(1); |
| | | } |
| | | } |
| | | String morny = editText.getText().toString(); |
| | | if (!TextUtils.isEmpty(morny)) { |
| | | rechageWater = MornyUtil.intDiv(MornyUtil.changeY2F(editText.getText().toString()), waterPrice); |
| | | binding.redRechargeWater.setText("充值水量:" + rechageWater + " 立方米(吨)"); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | @Override |