Skip to content

Feat/38: 가맹점 일일 정산(매출 전표 csv 파일 생성 및 SFTP 전송 Batch Job) 구현#54

Merged
yxhwxn merged 26 commits intodevelopfrom
feat/38
Jun 8, 2025
Merged

Feat/38: 가맹점 일일 정산(매출 전표 csv 파일 생성 및 SFTP 전송 Batch Job) 구현#54
yxhwxn merged 26 commits intodevelopfrom
feat/38

Conversation

@yxhwxn
Copy link
Member

@yxhwxn yxhwxn commented May 28, 2025

[PG서버 Batch Job] 매입 파일 생성 및 SFTP 전송 Job

  • Job 이름: GenerateAndSendPurchaseCsvJob
  • Trigger 시간: 가맹점마다 설정한 정산 시간 기준 (Quartz 사용)
  • Step 로직 구성:
    • 정산 시간이 지난 승인 상태 결제 데이터 조회
    • 가맹점별로 일자 기준으로 결제 데이터 그룹화
    • 각 가맹점별로 하나의 매입 CSV 파일 생성
    • SFTP 로 카드사 서버에 전송
  • 고려 사항:
    • JobParameter에 가맹점 ID나 정산 시간 기준을 전달
    • 실패 시 재전송 로직 필요
    • 전송 성공 여부를 Meta_DB에 저장

참고 사항

현재 secret.yml 공유가 안돼서 CI 빌드 에러 나는 부분은 아래를 참고하여 설정파일 수정해야 합니다!

  • Spring Quartz 기반 글로벌 락 적용(중복 배치 작업 방지)
    • secret.yml 설정 필수!!
    • Image

yxhwxn added 23 commits May 27, 2025 15:54
…) 오버로드만 사용하는 걸 권장함에 따라 파라미터 추가
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements a new daily settlement batch job that generates purchase CSV files and sends them via SFTP.

  • Adds new repository methods to query payment and merchant data.
  • Introduces separate database configurations along with Quartz scheduling, retry, and batch job components.
  • Implements CSV generation and SFTP file upload utilities to support the job workflow.

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/main/java/com/fisa/pg/repository/PaymentRepository.java Adds method to retrieve payments by merchant, payment status, and approval date range.
src/main/java/com/fisa/pg/repository/MerchantRepository.java Introduces query for active merchants.
src/main/java/com/fisa/pg/config/db/MetaDBConfig.java Configures primary datasource for the Meta DB.
src/main/java/com/fisa/pg/config/db/DataDBConfig.java Sets up the Data DB with JPA properties and entity management.
src/main/java/com/fisa/pg/batch/utils/SftpUploader.java Implements SFTP file upload with retry logic.
src/main/java/com/fisa/pg/batch/utils/CsvGenerator.java Creates CSV files from merchant summary data.
src/main/java/com/fisa/pg/batch/quartz/QuartzJobLauncher.java Launches Spring Batch Jobs via a Quartz trigger.
src/main/java/com/fisa/pg/batch/quartz/QuartzConfig.java Defines Quartz job and trigger configurations.
src/main/java/com/fisa/pg/batch/job_config/RetryTemplateConfig.java Configures a RetryTemplate with fixed backoff policy.
src/main/java/com/fisa/pg/batch/job_config/GenerateAndSendPurchaseCsvJob.java Implements the batch job that ties together data retrieval, CSV generation, and SFTP upload.
src/main/java/com/fisa/pg/batch/dto/MerchantSummary.java Defines an immutable DTO for merchant settlement summaries.
Comments suppressed due to low confidence (1)

src/main/java/com/fisa/pg/batch/job_config/GenerateAndSendPurchaseCsvJob.java:74

  • [nitpick] Consider capturing a consistent job start timestamp and reusing it for both the date calculations and settlementTime to avoid potential discrepancies if the job runs around midnight.
LocalDateTime settlementTime = LocalDateTime.now().withHour(2).withMinute(0).withSecond(0).withNano(0);

em.setJpaVendorAdapter(new HibernateJpaVendorAdapter());

HashMap<String, Object> properties = new HashMap<>();
properties.put("hibernate.hbm2ddl.auto", "update");
Copy link

Copilot AI May 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using a managed schema migration tool (e.g., Flyway or Liquibase) instead of relying on 'update' in hibernate.hbm2ddl.auto to prevent unintended schema changes in production.

Copilot uses AI. Check for mistakes.
Comment on lines +41 to +43
if (file == null || !file.exists()) {
throw new IllegalArgumentException(">>>>>>>>>>>>>[Error]: 전송할 파일이 존재하지 않습니다: " + file);
}
Copy link

Copilot AI May 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider separating the null check from the exists() check to provide a clearer error message when file is null.

Suggested change
if (file == null || !file.exists()) {
throw new IllegalArgumentException(">>>>>>>>>>>>>[Error]: 전송할 파일이 존재하지 않습니다: " + file);
}
if (file == null) {
throw new IllegalArgumentException(">>>>>>>>>>>>>[Error]: 전송할 파일이 null입니다.");
}
if (!file.exists()) {
throw new IllegalArgumentException(">>>>>>>>>>>>>[Error]: 전송할 파일이 존재하지 않습니다: " + file.getAbsolutePath());
}

Copilot uses AI. Check for mistakes.
@yxhwxn yxhwxn self-assigned this May 28, 2025
@yxhwxn yxhwxn added the enhancement New feature or request label May 28, 2025
@yxhwxn yxhwxn changed the title Feat/38: 가맹점 일일 정산(매입 파일 생성 및 SFTP 파일 전송 Batch Job) 구현 Feat/38: 가맹점 일일 정산(매출 전표 csv 파일 생성 및 SFTP 전송 Batch Job) 구현 May 31, 2025
@yxhwxn yxhwxn merged commit 7f8af21 into develop Jun 8, 2025
1 check failed
@yxhwxn yxhwxn deleted the feat/38 branch June 8, 2025 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🚀 [feature] 가맹점 일일 정산(매입 파일 생성 및 SFTP 전송 Batch Job 적용)

2 participants