1Lúc sáu giờ, client gọi importFile(file) trên VnpayImporter qua kiểu SettlementImporter. importFile là final nên lớp con không đổi được thứ tự; nó đọc file một lần rồi ghi log chung.At six, the client calls importFile(file) on a VnpayImporter through the SettlementImporter type. importFile is final, so subclasses cannot reorder it; it reads the file once and writes the shared log.
2Khung gọi skip(headerLines()); VnpayImporter override hook này trả về 2 thay vì mặc định 1, nên dòng tiêu đề và dòng header đều bị bỏ.The skeleton calls skip(headerLines()); VnpayImporter overrides this hook to return 2 instead of the default 1, so both the title row and the header are skipped.
3Với từng dòng, map(this::parse) gọi parse() của VNPay: line.split(",") thành Settlement(txnRef, amount, payDate). Khung chỉ cần nhận lại Settlement.For each line, map(this::parse) calls VNPay's parse(): line.split(",") into Settlement(txnRef, amount, payDate). The skeleton only needs a Settlement back.
4filter(this::accept) dùng hook mặc định amount().signum() > 0, rồi khung gọi repo.saveAll(rows) và trả new ImportReport(provider(), lines.size(), rows.size()).filter(this::accept) uses the default hook amount().signum() > 0, then the skeleton calls repo.saveAll(rows) and returns new ImportReport(provider(), lines.size(), rows.size()).
5Spring cũng dùng mẫu này: SettlementQueries.byDate(day) gọi jdbc.query(sql, rowMapper, day). JdbcTemplate giữ khung lấy connection, chạy lệnh, duyệt kết quả, đóng tài nguyên; ta chỉ đưa bước thay đổi là lambda (rs, rowNum) -> new Settlement(...).Spring uses the same idea: SettlementQueries.byDate(day) calls jdbc.query(sql, rowMapper, day). JdbcTemplate owns the skeleton of getting a connection, executing, iterating and closing; we only pass the varying step, the lambda (rs, rowNum) -> new Settlement(...).
6Bản Go: client gọi Import(ctx, file, VNPay{}, store). Không có lớp trừu tượng; Import là hàm thường giữ các bước cố định và gọi qua interface Parser.In Go: the client calls Import(ctx, file, VNPay{}, store). There is no abstract class; Import is a plain function owning the fixed steps and calling through the Parser interface.
7VNPay nhúng Defaults nhưng tự khai báo HeaderLines() = 2, che hook mặc định; Parse dùng parseSep(line, ","). Import bỏ 2 dòng đầu và chỉ giữ dòng Amount > 0.VNPay embeds Defaults but declares its own HeaderLines() = 2, shadowing the default hook; Parse uses parseSep(line, ","). Import skips the first 2 lines and keeps only rows with Amount > 0.
8Lượt Momo dùng cùng Import với Momo{}: HeaderLines() = 1 được promote từ Defaults, Parse tách bằng "|". Định dạng mới không phải sao chép quy trình.The Momo run uses the same Import with Momo{}: HeaderLines() = 1 is promoted from Defaults and Parse splits on "|". A new format needs no copied workflow.
9Cuối cùng Import gọi store.SaveAll(ctx, rows) và trả Report{Provider: "MOMO", ...}. Nếu một dòng sai định dạng, Import dừng sớm với lỗi kèm tên cổng và số dòng.Finally Import calls store.SaveAll(ctx, rows) and returns Report{Provider: "MOMO", ...}. If a line is malformed, Import stops early with an error naming the provider and line number.