| | |
| | | import com.dayu.baselibrary.utils.MornyUtil; |
| | | import com.dayu.qiheonlinelibrary.card.UserCard; |
| | | import com.dayu.qiheonlinelibrary.databinding.ActivityRechargeDetailQhlBinding; |
| | | import com.dayu.qiheonlinelibrary.dbBean.RechargeBean; |
| | | import com.dayu.qiheonlinelibrary.dbBean.UserCardBean; |
| | | |
| | | |
| | | import java.util.Calendar; |
| | |
| | | ActivityRechargeDetailQhlBinding binding; |
| | | UserCard userCard; |
| | | String statu; |
| | | String userName; |
| | | String morny; |
| | | String rechageWater; |
| | | String cardNumber; |
| | | UserCardBean userCardBean; |
| | | RechargeBean rechargeBean; |
| | | |
| | | @Override |
| | | protected void onCreate(Bundle savedInstanceState) { |
| | |
| | | try { |
| | | userCard = (UserCard) getIntent().getSerializableExtra("userCard"); |
| | | statu = getIntent().getStringExtra("statu"); |
| | | userName = getIntent().getStringExtra("userName"); |
| | | if (getIntent().hasExtra("morny")) { |
| | | morny = getIntent().getStringExtra("morny"); |
| | | rechageWater = getIntent().getStringExtra("rechageWater"); |
| | | rechargeBean = (RechargeBean) getIntent().getSerializableExtra("rechargeBean"); |
| | | } |
| | | if (getIntent().hasExtra("cardNumber")) { |
| | | cardNumber = getIntent().getStringExtra("cardNumber"); |
| | | if (getIntent().hasExtra("userCardBean")) { |
| | | userCardBean = (UserCardBean) getIntent().getSerializableExtra("userCardBean"); |
| | | } |
| | | setUserData(userName, statu); |
| | | setUserData(statu); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | |
| | | } |
| | | |
| | | private void setUserData(String userName, String statu) { |
| | | private void setUserData(String statu) { |
| | | int balance = userCard.getBalance(); |
| | | if (!TextUtils.isEmpty(morny)) { |
| | | binding.tip.setText("充值成功!"); |
| | | balance = userCard.getBalance(); |
| | | binding.redName.setText("姓名:" + rechargeBean.getUserName()); |
| | | binding.redRemainderMorny.setText("充值金额:" + morny + " 元"); |
| | | binding.redRechargeWater.setText("剩余金额:" + MornyUtil.changeF2Y(balance) + " 元"); |
| | | binding.redRechargeBalance.setText("剩余金额:" + MornyUtil.changeF2Y(balance) + " 元"); |
| | | binding.redRechargeElectric.setText("充值电量:" + rechargeBean.getRechargeElectric() + " 度"); |
| | | binding.redSurplusElectric.setText("剩余电量:" + rechargeBean.getSurplusElectic() + " 度"); |
| | | binding.redInitCode.setText("卡号:" + rechargeBean.getCardNumber()); |
| | | binding.redUserCode.setText("用户编号:" + rechargeBean.getUserCode()); |
| | | } else { |
| | | binding.redName.setText("姓名:" + userCardBean.getUserName()); |
| | | binding.tip.setText("开卡成功!"); |
| | | balance = userCard.getBalance(); |
| | | binding.redInitCode.setText("卡号:" + userCardBean.getCardNumber()); |
| | | binding.redUserCode.setText("用户编号:" + userCardBean.getUserCode()); |
| | | binding.redRemainderMorny.setVisibility(View.GONE); |
| | | binding.redRechargeWater.setVisibility(View.GONE); |
| | | binding.redRechargeBalance.setVisibility(View.GONE); |
| | | binding.redRechargeElectric.setVisibility(View.GONE); |
| | | binding.redSurplusElectric.setVisibility(View.GONE); |
| | | } |
| | | binding.redName.setText("用户姓名:" + userName); |
| | | // binding.redRemainderBlance.setText("剩余金额:" + MornyUtil.changeF2Y(balance) + " 元"); |
| | | // binding.redSurplusWater.setText("剩余水量:" + MornyUtil.changeF2Y(userCard.getSurplusWater()) + " 吨"); |
| | | binding.redStatu.setText("卡状态:" + statu); |
| | | if (userCard != null) { |
| | | binding.redInitCode.setText("当前卡号:" + cardNumber); |
| | | Calendar calendar = userCard.getRechargeDate(); |
| | | if (calendar != null) { |
| | | int year = calendar.get(Calendar.YEAR); |
| | | int month = calendar.get(Calendar.MONTH); // 月份从0开始,所以需要加1 |
| | | int day = calendar.get(Calendar.DAY_OF_MONTH); |
| | | |
| | | binding.redRechargeDate.setText("本卡最后购水日期:" + year + month + day); |
| | | } else { |
| | | binding.redRechargeDate.setText("本卡最后购水日期:无"); |
| | | } |
| | | |
| | | // binding.redRechargeNumber.setText("本卡充值次数:" + userCard.getRechargeTimes() + ""); |
| | | } |
| | | } |
| | | } |