Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
164 views
in Technique[技术] by (71.8m points)

java - i want to show value arraylist in arraylist javaspring, how to fix it?

My code

public List<PaymentDetailInfo> PaymentDetailsInfo(List<Transaction> transactionInfo) {
    List<PaymentDetailInfo> result = new ArrayList<>();
    PaymentDetailInfo pay = new PaymentDetailInfo();
    List<PaymentDetailProduct> detProd = new ArrayList<>();
    PaymentDetailProduct det = new PaymentDetailProduct();

    for (int i = 0; i < transactionInfo.size(); i++) {
        pay.setTransactionId(transactionInfo.get(i).getTransactionId());
        pay.setYourPayment(transactionInfo.get(i).getYourPayment() == null ? 0 : transactionInfo.get(i).getYourPayment());
        pay.setSisaPembayaran(transactionInfo.get(i).getSisaPembayaran() == null ? 0 : transactionInfo.get(i).getSisaPembayaran());
        pay.setDendaKeterlambatan(transactionInfo.get(i).getDendaKeterlambatan() == null ? 0 : transactionInfo.get(i).getDendaKeterlambatan());
        pay.setJatuhTempo(transactionInfo.get(i).getJatuhTempo() == null ? "" : transactionInfo.get(i).getJatuhTempo());
        pay.setTotalPembayaran(transactionInfo.get(i).getTotalPembayaran() == null ? 0 : transactionInfo.get(i).getTotalPembayaran());
        for(int j = 0; j<transactionInfo.get(i).getMerchantProduct().size(); j++){
            det.setProductId(transactionInfo.get(i).getMerchantProduct().iterator().next().getMerchantProductId());
            det.setProductName(transactionInfo.get(i).getMerchantProduct().iterator().next().getProductName());
            det.setProductPrice(transactionInfo.get(i).getMerchantProduct().iterator().next().getProductPrice());
            det.setRegisteredDate(transactionInfo.get(i).getMerchantProduct().iterator().next().getCreatedDate());
            det.setLastModified(transactionInfo.get(i).getMerchantProduct().iterator().next().getUpdatedDate());
            detProd.add(det);
            pay.setPaymentProduct(detProd);
        }
        
        pay.setRegisteredDate(DateUtils.formatDateTimeOrEmptyString(transactionInfo.get(i).getCreatedDate()));
        pay.setLastModified(DateUtils.formatDateTimeOrEmptyString(transactionInfo.get(i).getUpdatedDate()));
        
        
        result.add(pay);
    }
    return result;
}

{ "meta": { "code": "2000", "message": "Sukses" }, "data": { "detailPayment": { "fin_payment": { "financialName": "BCAFINANCE", "loanLimit": 10000000, "sisaLimit": 7900000, "loanId": "61929149-59f4-4f2e-9ffd-7bbc6370fdaf", "registeredDate": "06/01/2021 22:20", "lastModified": "07/Jan/2021 03:03" }, "det_payment": [ { "transactionId": "09699913-e006-4684-b1e3-a346991609bd", "yourPayment": 0, "sisaPembayaran": 0, "dendaKeterlambatan": 0, "jatuhTempo": "", "paymentProduct": [ { "productId": "39c3cfdb-5e76-45c3-b0a1-d96d0181a73c", "productName": "BAJU", "productPrice": 350000, "registeredDate": "2021-01-06T22:50:41.270955" }, { "productId": "39c3cfdb-5e76-45c3-b0a1-d96d0181a73c", "productName": "BAJU", "productPrice": 350000, "registeredDate": "2021-01-06T22:50:41.270955" }, { "productId": "39c3cfdb-5e76-45c3-b0a1-d96d0181a73c", "productName": "BAJU", "productPrice": 350000, "registeredDate": "2021-01-06T22:50:41.270955" }, { "productId": "39c3cfdb-5e76-45c3-b0a1-d96d0181a73c", "productName": "BAJU", "productPrice": 350000, "registeredDate": "2021-01-06T22:50:41.270955" }, { "productId": "39c3cfdb-5e76-45c3-b0a1-d96d0181a73c", "productName": "BAJU", "productPrice": 350000, "registeredDate": "2021-01-06T22:50:41.270955" } ], "totalPembayaran": 0, "registeredDate": "", "lastModified": "" }, { "transactionId": "09699913-e006-4684-b1e3-a346991609bd", "yourPayment": 0, "sisaPembayaran": 0, "dendaKeterlambatan": 0, "j


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...