左晓为主开发手持机充值管理机
zuoxiao
2024-04-25 8d53327d1b3df1aea5f9eb9fa22c644ccfeeabf1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package com.dayu.qihealonelibrary.activity;
 
import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
 
import com.dayu.baselibrary.utils.MornyUtil;
import com.dayu.qihealonelibrary.card.UserCard;
import com.dayu.qihealonelibrary.databinding.ActivityRechargeDetailBinding;
 
 
import java.util.Calendar;
 
/**
 * Created by Android Studio.
 * author: zuo
 * Date: 2023-11-21
 * Time: 15:01
 * 备注:写卡后的详情页
 */
public class RechargeDetail extends QHAloneBaseActivity {
 
    ActivityRechargeDetailBinding binding;
    UserCard userCard;
    String statu;
    String userName;
    String morny;
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
 
        binding = ActivityRechargeDetailBinding.inflate(LayoutInflater.from(this));
        setContentView(binding.getRoot());
 
        try {
            userCard = (UserCard) getIntent().getSerializableExtra("userCard");
            statu = getIntent().getStringExtra("statu");
            userName = getIntent().getStringExtra("userName");
            if (getIntent().hasExtra("morny")) {
                morny = getIntent().getStringExtra("morny");
            }
            setUserData(userName, statu);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
 
    }
 
    private void setUserData(String userName, String statu) {
        int balance = userCard.getBalance();
        if (!TextUtils.isEmpty(morny)) {
            binding.tip.setText("充值成功!");
            balance = userCard.getBalance() + MornyUtil.changeY2F(morny);
            binding.redRemainderMorny.setText("充值金额:" + morny + " 元");
        } else {
            binding.tip.setText("开卡成功!");
            balance = userCard.getBalance();
            binding.redRemainderMorny.setVisibility(View.GONE);
        }
        binding.redName.setText("用户姓名:" + userName);
        binding.redRemainderBlance.setText("剩余金额:" + MornyUtil.changeF2Y(balance) + " 元");
        binding.redStatu.setText("卡状态:" + statu);
        if (userCard != null) {
//            binding.redInitCode.setText("用户注册编号:" + userCard.getInitPeasantCode());
            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() + "");
        }
    }
}