平安银行信用卡电子账单读取

public class PingAnBankBill  {
    // public static BillModal readBill(Document document) {
   public static List readBill(String mailContent) {
       List billModalList = new ArrayList();
        TempBillModal billModal = new TempBillModal();
        Document document = Jsoup.parse(mailContent);
        billModal.setBankname("平安银行");
        //解析获得持卡人
        String cardUserStr = document.select("strong:containsOwn(尊敬的)").text();
        String cardUser = cardUserStr.replace("尊敬的", "").replace(" :", "").trim();
        billModal.setCarduser(cardUser);
        System.out.println("户主:" + cardUser);
        //解析获得账单月份
        String monthStr = document.select("td:containsOwn(月的信用卡对账单)").first().child(0).html();
       // monthStr = monthStr.substring(1,monthStr.length()-1);
        monthStr = monthStr.replaceAll(" ","");
        System.out.println(monthStr);
        if(monthStr.trim().indexOf("0")==0){
            monthStr = monthStr.substring(1,monthStr.length());
        }
        int month = Integer.parseInt(monthStr);
         billModal.setBillmonth(month);
        System.out.println("账单月"+ month);
        //解析获得本期账单日
        String billDateStr = document.select("td:containsOwn(本期账单日)").first().nextElementSibling().text();
        billModal.setBilldate(billDateStr);
        System.out.println("本期账单日:"+billDateStr);
        //解析本期还款日
        String repayDateStr = document.select("strong:containsOwn(本期还款日)").parents().first().nextElementSibling().text();
        billModal.setRepaydate(repayDateStr);
        System.out.println("本期还款日:"+repayDateStr);
        //解析信用额度
        String creditlimitStr = document.select("td:containsOwn(信用额度)").first().nextElementSibling().text();
        creditlimitStr = creditlimitStr.replaceAll("¥ ", "").replace(",","");
        BigDecimal creditlimit = new BigDecimal(creditlimitStr);
        billModal.setCreditlimit(creditlimit);
        System.out.println("信用额度为¥:"+creditlimit.toString());
        //解析取现额度
        String crashlimitStr = document.select("td:containsOwn(取现额度)").first().nextElementSibling().text();
        crashlimitStr = crashlimitStr.replaceAll("¥ ", "").replace(",","");
        BigDecimal crashlimit = new BigDecimal(crashlimitStr);
        billModal.setCrashlimit(crashlimit);
        System.out.println("取额限度为¥:"+creditlimit.toString());
        //解析本期还款
        String needpayStr = document.select("strong:containsOwn(本期应还金额)").parents()
                .get(4)
                .nextElementSibling()
                .child(0)
                .child(0)
                .child(0)
                .child(0)
                .child(0).text();
        needpayStr = needpayStr.replaceAll("¥ ", "").replace(",","");
        BigDecimal needpay = new BigDecimal(needpayStr);
        billModal.setNeddrepay(needpay);
        System.out.println("本期还款为¥"+needpay.toString());
        //解析最低还款
        String lowpayStr = document.select("strong:containsOwn(本期应还金额)").parents()
                .get(4)
                .nextElementSibling()
                .child(0)//table
                .child(0)//tbody
                .child(2)//tr
                .child(0)//td
                .text();
        lowpayStr = lowpayStr.replaceAll("¥ ", "").replace(",","");
        BigDecimal lowpay = new BigDecimal(lowpayStr);
        billModal.setLowrepay(lowpay);
        System.out.println("最低还款为¥"+lowpay);
        //解析交易明细
        Elements tradeElements = document.select("td:containsOwn(人民币账户交易明细)").first().parents()
                .get(4)
                .nextElementSibling()
                .child(0)
                .child(0)//table
                .child(0)//tbody
                .children().select("tr[height=38]");
        List billDetailList = new ArrayList();
        for(int i=0; i 

 

转载于:https://my.oschina.net/riaway/blog/687130

你可能感兴趣的:(平安银行信用卡电子账单读取)