- 템플릿 클론(정규화 후 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>
75 lines
2.5 KiB
Text
75 lines
2.5 KiB
Text
/* @tier easy @module mg @transform msg-gateway-online */
|
|
/*
|
|
* mg_ol_0031.pgc - 전문게이트웨이 전문 스냅샷 조회 서비스 (MG_OL_0031) [tier=easy]
|
|
*
|
|
* 처리키(KEY)로 원장 레코드를 조회(mg_rec_select)한 뒤, 금액/상태/수수료를
|
|
* 포함한 전체 필드 스냅샷을 응답 TXBUF 로 구성한다. 상태코드는 사람이 읽을
|
|
* 수 있는 라벨로 함께 내려준다. (ATMI void SVC(TPSVCINFO*) 대응)
|
|
*/
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
#include "txcore.h"
|
|
#include "acq_util.h"
|
|
#include "mg_core.h"
|
|
|
|
EXEC SQL INCLUDE sqlca;
|
|
|
|
TX_SERVICE(MG_OL_0031, ctx)
|
|
{
|
|
mg_rec_t rec;
|
|
char key[16];
|
|
char won[40];
|
|
const char *st_label;
|
|
int rc;
|
|
|
|
tx_log(TX_LOG_INFO, "[MG_OL_0031] 전문 스냅샷 조회 서비스 진입");
|
|
|
|
/* 1) 처리키 수신 */
|
|
if (tx_buf_get(ctx->in, "KEY", key, sizeof(key)) != TX_OK) {
|
|
tx_log(TX_LOG_ERROR, "[MG_OL_0031] KEY 누락");
|
|
tx_return(ctx, TX_EINVAL, ctx->out);
|
|
return;
|
|
}
|
|
|
|
/* 2) 원장 단건 조회 */
|
|
memset(&rec, 0, sizeof(rec));
|
|
rc = mg_rec_select(key, &rec);
|
|
if (rc != TX_OK) {
|
|
tx_log(TX_LOG_WARN, "[MG_OL_0031] 스냅샷 대상 없음 key=%s rc=%d(%s)",
|
|
key, rc, tx_strerror(rc));
|
|
tx_return(ctx, rc, ctx->out);
|
|
return;
|
|
}
|
|
|
|
/* 3) 상태코드 -> 표시 라벨 매핑 */
|
|
if (strcmp(rec.status, MG_ST_RECV) == 0)
|
|
st_label = "접수";
|
|
else if (strcmp(rec.status, MG_ST_DONE) == 0)
|
|
st_label = "처리완료";
|
|
else if (strcmp(rec.status, MG_ST_FAIL) == 0)
|
|
st_label = "실패";
|
|
else if (strcmp(rec.status, MG_ST_SETTLED) == 0)
|
|
st_label = "정산완료";
|
|
else
|
|
st_label = "미상";
|
|
|
|
/* 4) 전체 필드 스냅샷 구성 */
|
|
amount_format_won(rec.amount, won, sizeof(won));
|
|
|
|
tx_buf_reset(ctx->out);
|
|
tx_buf_sets(ctx->out, "RESP", RESP_OK);
|
|
tx_buf_sets(ctx->out, "KEY", rec.key);
|
|
tx_buf_sets(ctx->out, "MERCHID", rec.merch_id);
|
|
tx_buf_sets(ctx->out, "CARDNO", rec.card_no);
|
|
tx_buf_sets(ctx->out, "BIZDATE", rec.biz_date);
|
|
tx_buf_setlong(ctx->out, "AMOUNT", rec.amount);
|
|
tx_buf_sets(ctx->out, "AMOUNTWON", won);
|
|
tx_buf_setlong(ctx->out, "FEE", rec.fee);
|
|
tx_buf_sets(ctx->out, "STATUS", rec.status);
|
|
tx_buf_sets(ctx->out, "STATUSLABEL", st_label);
|
|
|
|
tx_log(TX_LOG_INFO, "[MG_OL_0031] 스냅샷 조회완료 key=%s 상태=%s 금액=%ld 수수료=%ld",
|
|
key, st_label, rec.amount, rec.fee);
|
|
tx_return(ctx, TX_OK, ctx->out);
|
|
}
|