民生银行信用卡电子账单读取

/**
 * 民生银行账单解读
 * Created by LYH on 2015/8/28.
 */
public class MinShengBankBill {
    public static String temp_hello = "尊敬的";
    public static String temp_cardbill = "您好!感谢您使用本行信用卡,特别呈上您";
    public static List<TempBillModal> readBillModal(String mailContent){
        //public static TempBillModal readBill(Document document) {
        List<TempBillModal> tempBillModalList = new ArrayList<TempBillModal>();
        TempBillModal billModal = new TempBillModal();
        Document document = Jsoup.parse(mailContent);
        tempBillModalList.add(billModal);
        //持卡人
        String cardUserStr = document.select("font:containsOwn(尊敬的)").first().text();
        cardUserStr = cardUserStr.substring(cardUserStr.indexOf(temp_hello) +temp_hello.length(),cardUserStr.indexOf(":"));
        billModal.setCarduser(cardUserStr);
        System.out.println("持卡人:"+cardUserStr);
        //账单月份
        String billStr = document.select("font:containsOwn(您好!感谢您使用本行信用卡,特别呈上您)").first()
                .parent()
                .parent()
                .nextElementSibling()
                .text();
        String year= billStr.substring(0,billStr.indexOf("年"));
        billStr = billStr.substring(billStr.indexOf("年")+1,billStr.indexOf("月"));
        if(billStr.trim().indexOf("0")==0){
            billStr = billStr.substring(1,billStr.length());
        }
        int month = Integer.parseInt(billStr);
        billModal.setBillmonth(month);
        System.out.println("账单月份:"+billStr);
        //账单日
        Elements billDateElements = document.select("font:containsOwn(Statement Date)").first().parents();
        String billDateStr = billDateElements.get(10).nextElementSibling().text().replaceAll("/", "-");
        billModal.setBilldate(billDateStr);
        System.out.println("账单日:"+billDateStr);
        //还款日
        Elements repayElements = document.select("font:containsOwn(Payment Due Date)").first().parents();
        String repayDateStr = repayElements.get(10).nextElementSibling().text().replaceAll("/", "-");
        billModal.setRepaydate(repayDateStr);
        System.out.println("还款日:"+repayDateStr);

        Element repayElement = document.select("font:containsOwn(RMB/USD Account)").first().parents().get(10);
        //本期应还金额
        String needPayStr = repayElement.nextElementSibling().text().replace("RMB ", "").replaceAll(",", "").replaceAll("   ","");
        billModal.setNeddrepay(new BigDecimal(needPayStr));
        System.out.println("应还金额:"+needPayStr);
        //最低应还金额
        String lowPayStr = repayElement.nextElementSibling()
                .nextElementSibling().text().replace("RMB ", "").replaceAll(",", "").replaceAll("   ","");
        billModal.setLowrepay(new BigDecimal(lowPayStr));
        System.out.println("最低还款金额:" + lowPayStr);
        billModal.setBillDetailList(new ArrayList<BillDetail>());
        billModal.setBankname("民生银行");
        //交易明细
        Elements detailElements = document.select("span#loopband3").first()
                .child(0)
                .child(0)
                .children();
        for(Element detailElement:detailElements){
            BillDetail billDetail = new BillDetail();
            billModal.getBillDetailList().add(billDetail);
            Element detail = detailElement.child(0)
                    .child(0)
                    .child(0)
                    .child(0)
                    .child(1)
                    .child(0)
                    .child(0)
                    .child(0)
                    .child(0)
                    .child(0)
                    .child(0)
                    .child(0)
                    .child(0);
            String detailDateStr = detail.child(1).text();
            detailDateStr = year+"-"+detailDateStr.replaceAll("/","-");
            billDetail.setTradedate(detailDateStr);
            System.out.println("交易日:"+detailDateStr);
            String detailStr = detail.child(3).text();
            billDetail.setDetail(detailStr);
            System.out.println("交易摘要:"+detailStr);
            String detailMoneyStr = detail.child(4).text().replace(",","");
            billDetail.setMoney(new BigDecimal(detailMoneyStr));
            System.out.println("交易金额:"+detailMoneyStr);
            String cardLastNum = detail.child(5).text();
            System.out.println("卡号后四位:"+cardLastNum);
        }
        return tempBillModalList;
    }

   /* public static void main(String[] args) {
        try {
            Document document = Jsoup.connect("http://127.0.0.1/card/minsheng.html").get();
            MinShengBankBill.readBill(document);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }*/
}

 

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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值