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/mm_ol_0006.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

126 lines
4.1 KiB
Text

/* @tier easy @module mm @transform master-online */
/*
* mm_ol_0006.pgc - 수수료율 등록/변경 서비스 (MM_OL_0006) [tier=easy]
*
* 가맹점+상품구분의 수수료율을 신규 적용한다. 기존 유효 rate 를 전일자로
* 종료처리(UPDATE end_date) 하고, 신규 rate 를 INSERT 한 뒤 변경이력
* (mm_fee_hist) 에 남긴다. (CRUD + 이력)
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "txcore.h"
#include "txcore_dbio.h"
#include "acq_util.h"
#include "mm_core.h"
EXEC SQL INCLUDE sqlca;
TX_SERVICE(MM_OL_0006, ctx)
{
EXEC SQL BEGIN DECLARE SECTION;
char h_merch_id[16];
char h_prod_gb[4];
char h_today[9];
char h_far[9];
long h_new_bp;
long h_chg_by;
EXEC SQL END DECLARE SECTION;
char merch_id[16];
char prod_gb[4];
char rate_str[16];
long rate_bp = 0;
long chg_by = 0;
tx_log(TX_LOG_INFO, "[MM_OL_0006] 수수료율 등록/변경 서비스 진입");
if (tx_buf_get(ctx->in, "MERCHID", merch_id, sizeof(merch_id)) != TX_OK ||
tx_buf_get(ctx->in, "PRODGB", prod_gb, sizeof(prod_gb)) != TX_OK) {
tx_log(TX_LOG_ERROR, "[MM_OL_0006] 필수 필드 누락");
tx_buf_sets(ctx->out, "ERRCODE", "MM0600");
tx_return(ctx, TX_EINVAL, ctx->out);
return;
}
tx_buf_getlong(ctx->in, "RATEBP", &rate_bp);
tx_buf_getlong(ctx->in, "CHGBY", &chg_by);
/* 수수료율 범위검증: 0 ~ 1000bp (0~10%) */
if (rate_bp <= 0 || rate_bp > 1000) {
tx_log(TX_LOG_WARN, "[MM_OL_0006] 수수료율 범위오류 bp=%ld", rate_bp);
tx_buf_sets(ctx->out, "ERRCODE", "MM0601");
tx_return(ctx, TX_EINVAL, ctx->out);
return;
}
strncpy(h_merch_id, merch_id, sizeof(h_merch_id) - 1);
h_merch_id[sizeof(h_merch_id) - 1] = '\0';
strncpy(h_prod_gb, prod_gb, sizeof(h_prod_gb) - 1);
h_prod_gb[sizeof(h_prod_gb) - 1] = '\0';
h_new_bp = rate_bp;
h_chg_by = chg_by;
date_today(h_today);
strncpy(h_far, "99991231", sizeof(h_far) - 1);
h_far[sizeof(h_far) - 1] = '\0';
if (tx_begin() != TX_OK)
tx_log(TX_LOG_WARN, "[MM_OL_0006] tx_begin 경고");
/* 기존 유효 rate 종료처리 (없어도 정상) */
EXEC SQL UPDATE mm_fee_rate
SET end_date = :h_today
WHERE merch_id = :h_merch_id
AND prod_gb = :h_prod_gb
AND end_date = '99991231';
if (sqlca.sqlcode != TX_SQL_OK && sqlca.sqlcode != TX_SQL_NOTFOUND) {
TX_DBIO_LOG_ERR("UPDATE end_date mm_fee_rate");
tx_abort();
tx_buf_sets(ctx->out, "ERRCODE", "MM0602");
tx_return(ctx, TX_EDB, ctx->out);
return;
}
/* 신규 rate INSERT */
EXEC SQL INSERT INTO mm_fee_rate
(merch_id, prod_gb, rate_bp, start_date, end_date)
VALUES (:h_merch_id, :h_prod_gb, :h_new_bp, :h_today, :h_far);
if (sqlca.sqlcode != TX_SQL_OK) {
TX_DBIO_LOG_ERR("INSERT mm_fee_rate");
tx_abort();
tx_buf_sets(ctx->out, "ERRCODE", "MM0603");
tx_return(ctx, TX_EDB, ctx->out);
return;
}
/* 변경이력 INSERT */
EXEC SQL INSERT INTO mm_fee_hist
(merch_id, prod_gb, rate_bp, apply_date, chg_by)
VALUES (:h_merch_id, :h_prod_gb, :h_new_bp, :h_today, :h_chg_by);
if (sqlca.sqlcode != TX_SQL_OK) {
TX_DBIO_LOG_ERR("INSERT mm_fee_hist");
tx_abort();
tx_buf_sets(ctx->out, "ERRCODE", "MM0604");
tx_return(ctx, TX_EDB, ctx->out);
return;
}
tx_commit();
snprintf(rate_str, sizeof(rate_str), "%ld.%02ld",
h_new_bp / 100, h_new_bp % 100);
tx_buf_reset(ctx->out);
tx_buf_sets(ctx->out, "MERCHID", merch_id);
tx_buf_sets(ctx->out, "PRODGB", prod_gb);
tx_buf_setlong(ctx->out, "RATEBP", h_new_bp);
tx_buf_sets(ctx->out, "RATEPCT", rate_str);
tx_buf_sets(ctx->out, "STARTDATE", h_today);
tx_buf_sets(ctx->out, "ERRCODE", RESP_OK);
tx_log(TX_LOG_INFO, "[MM_OL_0006] 수수료율 변경완료 merch=%s prod=%s rate=%s%%",
merch_id, prod_gb, rate_str);
tx_return(ctx, TX_OK, ctx->out);
}