| | |
| | | import com.dayu.recharge.tools.BcdUtil; |
| | | import com.dayu.recharge.tools.HexUtil; |
| | | import com.dayu.recharge.utils.MornyUtil; |
| | | import com.dayu.recharge.utils.MyCommon; |
| | | import com.tencent.bugly.crashreport.CrashReport; |
| | | |
| | | import java.io.Serializable; |
| | | import java.net.IDN; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.Calendar; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * Copyright (C), 2023, |
| | |
| | | public class DomainCard implements Serializable { |
| | | |
| | | |
| | | public String cardType = "C1";//卡类型 |
| | | public String cardType = MyCommon.DOMAIN_CARD_TYPE;//卡类型 |
| | | public String domainNumber;//域名序号 (BCD格式) |
| | | public int domainLength;//域名长度 |
| | | |
| | |
| | | this.domainName = domainName; |
| | | } |
| | | |
| | | public String getDomainNumber() { |
| | | return domainNumber; |
| | | } |
| | | |
| | | public void setDomainNumber(String domainNumber) { |
| | | this.domainNumber = domainNumber; |
| | | } |
| | | |
| | | public int getPort() { |
| | | return port; |
| | |
| | | } |
| | | |
| | | |
| | | public static DomainCard toBean(List<byte[]> data) { |
| | | try { |
| | | DomainCard domainCard = new DomainCard(); |
| | | String domainNumber = BcdUtil.bcdToStr(data.get(0)[1]); |
| | | domainCard.domainNumber = domainNumber; |
| | | int domainLength = HexUtil.get16to10(HexUtil.byteToHex(data.get(0)[2])); |
| | | byte[] domainData = new byte[domainLength + 7]; |
| | | int index = 0; |
| | | for (int i = 0; i < 3; i++) { |
| | | int jIndex; |
| | | if (i == 0) { |
| | | jIndex = 3; |
| | | } else { |
| | | jIndex = 0; |
| | | } |
| | | for (int j = jIndex; j < 15; j++) { |
| | | if (index < domainData.length) { |
| | | domainData[index] = data.get(i)[j]; |
| | | index++; |
| | | } |
| | | |
| | | } |
| | | } |
| | | String domainStr = new String(domainData, StandardCharsets.US_ASCII); |
| | | String domainName = domainStr.split(",")[0]; |
| | | String port = domainStr.split(",")[1].replace("#", ""); |
| | | domainCard.setDomainName(domainName); |
| | | domainCard.setPort(Integer.valueOf(port)); |
| | | |
| | | return domainCard; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | CrashReport.postCatchedException(e); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 用户卡0块 |
| | | */ |