This repository has been archived on 2026-07-19. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
acquire-core-full/app/online/vl_ol_0002.pgc
forge-bot 93c3cb74af 다양화 Wave2: dbio 289 + common 120 고유화 + 프로그램 206개 EXEC SQL 심화
- dbio io(289): fetch/touch/total 시그니처 유지, SQL 바디를 JOIN/집계/커서/
  upsert/DELETE 등 구조로 고유화 → 289/289 고유
- common cu(120): 유틸 시그니처 유지, Luhn/CRC/Zeller/BIN레인지/amortization/
  netting 등 실 알고리즘으로 고유화 → 120/120 고유
- 심화: 실제 EXEC SQL 없던 프로그램에 SELECT/INSERT/UPDATE/커서+tx 추가
  → online+batch 530/530 전부 실제 SQL 보유
- 전 코퍼스 프로그램 939/939 고유, 전체 docker make -j4 = EXIT 0, 958 오브젝트
- 임시 생성기 제거, inventory.json loc 실측 갱신

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-19 04:54:59 +00:00

112 lines
3.9 KiB
Text

/* @tier medium @module vl @transform validation-online */
/*
* vl_ol_0002.pgc - 정합성 접수등록 서비스 (VL_OL_0002)
*
* 매입 정합성 대상 거래를 접수한다. 필수필드(처리키/가맹점/영업일/금액)를
* 검증한 뒤 표준 DBIO 로 원장에 접수(vl_rec_insert)하고, 접수이력 테이블
* (vl_recv_hist) 에 감사 로그를 남긴다. 마지막으로 당일 접수건수를 집계하여
* 응답에 실어 반환한다.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "txcore.h"
#include "txcore_dbio.h"
#include "acq_util.h"
#include "vl_core.h"
EXEC SQL INCLUDE sqlca;
TX_SERVICE(VL_OL_0002, ctx)
{
EXEC SQL BEGIN DECLARE SECTION;
char h_key[16];
char h_merch[16];
char h_bizdate[9];
char h_status[2];
long h_amount;
char h_recv_time[7];
EXEC SQL END DECLARE SECTION;
vl_rec_t rec;
char key[16], merch[16], bizdate[16];
long amount = 0, cnt;
int rc;
tx_log(TX_LOG_INFO, "[VL_OL_0002] 정합성 접수등록 서비스 진입");
/* 1) 필수필드 검증 */
if (tx_buf_get(ctx->in, "KEY", key, sizeof(key)) != TX_OK ||
tx_buf_get(ctx->in, "MERCHID", merch, sizeof(merch)) != TX_OK ||
tx_buf_get(ctx->in, "BIZDATE", bizdate, sizeof(bizdate)) != TX_OK) {
tx_log(TX_LOG_ERROR, "[VL_OL_0002] 필수 필드 누락");
tx_buf_sets(ctx->out, "ERRCODE", "VL0200");
tx_return(ctx, TX_EINVAL, ctx->out);
return;
}
tx_buf_getlong(ctx->in, "AMOUNT", &amount);
if (!amount_is_valid(amount) || !date_is_valid(bizdate)) {
tx_log(TX_LOG_WARN, "[VL_OL_0002] 입력값 검증 실패 amount=%ld date=%s",
amount, bizdate);
tx_buf_sets(ctx->out, "ERRCODE", "VL0201");
tx_return(ctx, TX_EINVAL, ctx->out);
return;
}
/* 2) 원장 접수 (표준 DBIO) */
memset(&rec, 0, sizeof(rec));
strncpy(rec.key, key, sizeof(rec.key) - 1);
strncpy(rec.merch_id, merch, sizeof(rec.merch_id) - 1);
strncpy(rec.biz_date, bizdate, sizeof(rec.biz_date) - 1);
strncpy(rec.status, VL_ST_RECV, sizeof(rec.status) - 1);
rec.amount = amount;
rec.fee = amount / 100;
rc = vl_rec_insert(&rec);
if (rc != TX_OK) {
tx_log(TX_LOG_ERROR, "[VL_OL_0002] 원장접수 실패 rc=%d(%s)",
rc, tx_strerror(rc));
tx_buf_sets(ctx->out, "ERRCODE", "VL0202");
tx_return(ctx, rc, ctx->out);
return;
}
/* 3) 접수이력 INSERT (감사 로그) */
strncpy(h_key, key, sizeof(h_key) - 1); h_key[sizeof(h_key) - 1] = '\0';
strncpy(h_merch, merch, sizeof(h_merch) - 1); h_merch[sizeof(h_merch) - 1] = '\0';
strncpy(h_bizdate, bizdate, sizeof(h_bizdate) - 1);
h_bizdate[sizeof(h_bizdate) - 1] = '\0';
strncpy(h_status, VL_ST_RECV, sizeof(h_status) - 1);
h_status[sizeof(h_status) - 1] = '\0';
h_amount = amount;
strncpy(h_recv_time, "000000", sizeof(h_recv_time) - 1);
h_recv_time[sizeof(h_recv_time) - 1] = '\0';
EXEC SQL INSERT INTO vl_recv_hist
(recv_key, merch_id, biz_date, recv_amount, recv_status, recv_time)
VALUES
(:h_key, :h_merch, :h_bizdate, :h_amount, :h_status, :h_recv_time);
if (sqlca.sqlcode != TX_SQL_OK) {
TX_DBIO_LOG_ERR("INSERT vl_recv_hist");
tx_buf_sets(ctx->out, "ERRCODE", "VL0209");
tx_return(ctx, TX_EDB, ctx->out);
return;
}
/* 4) 당일 접수건수 집계 */
cnt = vl_rec_count(bizdate, VL_ST_RECV);
if (cnt < 0)
cnt = 0;
tx_buf_reset(ctx->out);
tx_buf_sets(ctx->out, "RESPCODE", RESP_OK);
tx_buf_sets(ctx->out, "ERRCODE", RESP_OK);
tx_buf_sets(ctx->out, "KEY", key);
tx_buf_setlong(ctx->out, "RECVAMT", amount);
tx_buf_setlong(ctx->out, "DAYCNT", cnt);
tx_log(TX_LOG_INFO, "[VL_OL_0002] 접수완료 key=%s 당일건수=%ld", key, cnt);
tx_return(ctx, TX_OK, ctx->out);
}