- 템플릿 클론(정규화 후 0줄 상이) → 전 코퍼스 530/530 고유 바디 - 11개 모듈(mg/au/ac/rc/vl/st/py/lg/mm/cm/cl) 각 파일이 distinct한 매입·대사·정산·수수료·지급·원장·마감·마스터·정합성·전문게이트웨이·공통 업무 - TxCore(ATMI 유사) + ECPG(EXEC SQL) 관용구, 프레임워크/헤더/DBIO API/파일ID·경로 유지 - 전체 docker make -j4 = EXIT 0, 958 오브젝트, 데모 바이너리 링크 - inventory.json loc 실측 갱신 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
123 lines
4.2 KiB
Text
123 lines
4.2 KiB
Text
/* @tier easy @module ac @transform acquire-online */
|
|
/*
|
|
* ac_ol_0029.pgc - 매입 온라인 서비스 (AC_OL_0029) [tier=easy]
|
|
*
|
|
* 매입 청구조회(EDI): 청구번호(CLAIMNO)로 매입 청구내역(ac_claim)을
|
|
* 단건 조회한다. EDI 연계 파일로 실제 적재된 청구건의 가맹점/영업일/
|
|
* 금액/파일순번/상태를 확인하기 위한 조회 전용 서비스이다.
|
|
*
|
|
* 청구번호는 EDI 파일 헤더에서 채번되어 전달되므로, 조회 전 앞뒤
|
|
* 공백을 제거하여 정규화한 뒤 원장 키로 사용한다.
|
|
*/
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
#include "txcore.h"
|
|
#include "txcore_dbio.h"
|
|
#include "acq_util.h"
|
|
#include "ac_core.h"
|
|
|
|
EXEC SQL INCLUDE sqlca;
|
|
|
|
TX_SERVICE(AC_OL_0029, ctx)
|
|
{
|
|
/* ---- ECPG 호스트 변수 선언부 ---- */
|
|
EXEC SQL BEGIN DECLARE SECTION;
|
|
char h_claim_no[16];
|
|
char h_merch_id[16];
|
|
char h_biz_date[9];
|
|
long h_amount;
|
|
long h_file_seq;
|
|
char h_status[2];
|
|
EXEC SQL END DECLARE SECTION;
|
|
|
|
char claimno[16];
|
|
int len;
|
|
|
|
tx_log(TX_LOG_INFO, "[AC_OL_0029] 매입 청구조회(EDI) 서비스 진입");
|
|
|
|
/* ---- 1. 입력 검증 ---- */
|
|
if (tx_buf_get(ctx->in, "CLAIMNO", claimno, sizeof(claimno)) != TX_OK ||
|
|
claimno[0] == '\0') {
|
|
tx_log(TX_LOG_ERROR, "[AC_OL_0029] CLAIMNO 누락");
|
|
tx_buf_reset(ctx->out);
|
|
tx_buf_sets(ctx->out, "RESPCODE", RESP_INVALID);
|
|
tx_return(ctx, TX_EINVAL, ctx->out);
|
|
return;
|
|
}
|
|
|
|
/* ---- 2. 청구번호 정규화 (EDI 고정길이 전문의 트레일링 공백 제거) ---- */
|
|
len = (int)strlen(claimno);
|
|
while (len > 0 && claimno[len - 1] == ' ')
|
|
claimno[--len] = '\0';
|
|
|
|
if (len == 0) {
|
|
tx_log(TX_LOG_ERROR, "[AC_OL_0029] CLAIMNO 공백 전문");
|
|
tx_buf_reset(ctx->out);
|
|
tx_buf_sets(ctx->out, "RESPCODE", RESP_INVALID);
|
|
tx_return(ctx, TX_EINVAL, ctx->out);
|
|
return;
|
|
}
|
|
|
|
memset(h_claim_no, 0, sizeof(h_claim_no));
|
|
strncpy(h_claim_no, claimno, sizeof(h_claim_no) - 1);
|
|
|
|
/* ---- 3. 청구내역 단건 조회 ---- */
|
|
EXEC SQL
|
|
SELECT merch_id, biz_date, amount, file_seq, status
|
|
INTO :h_merch_id, :h_biz_date, :h_amount, :h_file_seq, :h_status
|
|
FROM ac_claim
|
|
WHERE claim_no = :h_claim_no;
|
|
|
|
if (sqlca.sqlcode == TX_SQL_NOTFOUND) {
|
|
tx_log(TX_LOG_WARN, "[AC_OL_0029] 청구건 없음 claim_no=%s", claimno);
|
|
tx_buf_reset(ctx->out);
|
|
tx_buf_sets(ctx->out, "RESPCODE", RESP_INVALID);
|
|
tx_return(ctx, TX_ENOENT, ctx->out);
|
|
return;
|
|
}
|
|
if (sqlca.sqlcode != TX_SQL_OK) {
|
|
TX_DBIO_LOG_ERR("SELECT ac_claim");
|
|
tx_buf_reset(ctx->out);
|
|
tx_buf_sets(ctx->out, "RESPCODE", RESP_SYSERR);
|
|
tx_return(ctx, TX_EDB, ctx->out);
|
|
return;
|
|
}
|
|
|
|
/* ---- 4. EDI 연계 정합성 참고 확인 (파일순번 미채번 시 경고만 남김) ---- */
|
|
if (h_file_seq <= 0) {
|
|
tx_log(TX_LOG_WARN,
|
|
"[AC_OL_0029] 파일순번 미채번 claim_no=%s file_seq=%ld",
|
|
claimno, h_file_seq);
|
|
}
|
|
|
|
/* ---- 5. 상태코드 설명 참고 로그 (응답필드는 원본 코드값 그대로 반환) ---- */
|
|
{
|
|
const char *statusdesc = "알수없음";
|
|
|
|
if (strcmp(h_status, "W") == 0)
|
|
statusdesc = "대기";
|
|
else if (strcmp(h_status, "S") == 0)
|
|
statusdesc = "전송완료";
|
|
else if (strcmp(h_status, "E") == 0)
|
|
statusdesc = "오류";
|
|
|
|
tx_log(TX_LOG_DEBUG, "[AC_OL_0029] 상태설명 claim_no=%s status=%s(%s)",
|
|
claimno, h_status, statusdesc);
|
|
}
|
|
|
|
/* ---- 6. 응답 구성 ---- */
|
|
tx_buf_reset(ctx->out);
|
|
tx_buf_sets(ctx->out, "RESPCODE", RESP_OK);
|
|
tx_buf_sets(ctx->out, "CLAIMNO", claimno);
|
|
tx_buf_sets(ctx->out, "MERCHID", h_merch_id);
|
|
tx_buf_sets(ctx->out, "BIZDATE", h_biz_date);
|
|
tx_buf_setlong(ctx->out, "AMOUNT", h_amount);
|
|
tx_buf_setlong(ctx->out, "FILESEQ", h_file_seq);
|
|
tx_buf_sets(ctx->out, "STATUS", h_status);
|
|
|
|
tx_log(TX_LOG_INFO,
|
|
"[AC_OL_0029] 청구조회완료 claim_no=%s merch=%s amount=%ld status=%s",
|
|
claimno, h_merch_id, h_amount, h_status);
|
|
tx_return(ctx, TX_OK, ctx->out);
|
|
}
|