- 템플릿 클론(정규화 후 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>
120 lines
4.2 KiB
Text
120 lines
4.2 KiB
Text
/* @tier easy @module rc @transform reconciliation-online */
|
|
/*
|
|
* rc_ol_0030.pgc - 대사 취소 온라인 서비스 (RC_OL_0030)
|
|
*
|
|
* 요청 KEY 의 원장 1건에 대해 대사(매입/불일치) 결과를 취소하여 접수('R')
|
|
* 상태로 되돌린다. 오취소를 막기 위해 확인 플래그(CFMFLAG="Y") 를 요구한다.
|
|
*
|
|
* 업무규칙:
|
|
* - CFMFLAG != "Y" → RESULT=NOCONFIRM, 상태 변경 없음 (TX_OK)
|
|
* - status == 정산완료('S') → RESULT=REJECT, 취소 불가 (상태 유지)
|
|
* - status in {'M','U'} → 접수('R') 로 전이, RESULT=CANCELLED
|
|
* - 그 외(이미 'R' 등) → RESULT=REJECT (취소 대상 아님)
|
|
*
|
|
* 응답: KEY, OLDSTATUS, NEWSTATUS, RESULT (조건부 갱신)
|
|
*/
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
#include "txcore.h"
|
|
#include "acq_util.h"
|
|
#include "rc_core.h"
|
|
|
|
EXEC SQL INCLUDE sqlca;
|
|
|
|
TX_SERVICE(RC_OL_0030, ctx)
|
|
{
|
|
rc_rec_t rec;
|
|
char key[16];
|
|
char cfmflag[4];
|
|
char oldstatus[2];
|
|
const char *newstatus;
|
|
const char *result;
|
|
int rc;
|
|
|
|
tx_log(TX_LOG_INFO, "[RC_OL_0030] 대사 취소 서비스 진입");
|
|
|
|
if (tx_buf_get(ctx->in, "KEY", key, sizeof(key)) != TX_OK) {
|
|
tx_log(TX_LOG_ERROR, "[RC_OL_0030] KEY 누락");
|
|
tx_return(ctx, TX_EINVAL, ctx->out);
|
|
return;
|
|
}
|
|
if (tx_buf_get(ctx->in, "CFMFLAG", cfmflag, sizeof(cfmflag)) != TX_OK) {
|
|
tx_log(TX_LOG_ERROR, "[RC_OL_0030] CFMFLAG(확인 플래그) 누락");
|
|
tx_return(ctx, TX_EINVAL, ctx->out);
|
|
return;
|
|
}
|
|
|
|
memset(&rec, 0, sizeof(rec));
|
|
rc = rc_rec_select(key, &rec);
|
|
if (rc != TX_OK) {
|
|
tx_log(TX_LOG_WARN, "[RC_OL_0030] 원장 조회 실패 key=%s rc=%d(%s)",
|
|
key, rc, tx_strerror(rc));
|
|
tx_return(ctx, rc, ctx->out);
|
|
return;
|
|
}
|
|
|
|
memset(oldstatus, 0, sizeof(oldstatus));
|
|
strncpy(oldstatus, rec.status, sizeof(oldstatus) - 1);
|
|
newstatus = oldstatus; /* 기본: 변경 없음 */
|
|
|
|
/* --- 확인 플래그 미승인 → 변경 없이 종료 --- */
|
|
if (strcmp(cfmflag, "Y") != 0) {
|
|
result = "NOCONFIRM";
|
|
tx_log(TX_LOG_WARN,
|
|
"[RC_OL_0030] 확인 플래그 미승인 key=%s flag=%s → 취소 보류",
|
|
key, cfmflag);
|
|
tx_buf_reset(ctx->out);
|
|
tx_buf_sets(ctx->out, "KEY", rec.key);
|
|
tx_buf_sets(ctx->out, "OLDSTATUS", oldstatus);
|
|
tx_buf_sets(ctx->out, "NEWSTATUS", newstatus);
|
|
tx_buf_sets(ctx->out, "RESULT", result);
|
|
tx_return(ctx, TX_OK, ctx->out);
|
|
return;
|
|
}
|
|
|
|
/* --- 정산완료 건은 취소 불가 --- */
|
|
if (strcmp(rec.status, RC_ST_SETTLED) == 0) {
|
|
result = "REJECT";
|
|
tx_log(TX_LOG_WARN,
|
|
"[RC_OL_0030] 정산완료 취소불가 key=%s status=S", key);
|
|
tx_buf_reset(ctx->out);
|
|
tx_buf_sets(ctx->out, "KEY", rec.key);
|
|
tx_buf_sets(ctx->out, "OLDSTATUS", oldstatus);
|
|
tx_buf_sets(ctx->out, "NEWSTATUS", newstatus);
|
|
tx_buf_sets(ctx->out, "RESULT", result);
|
|
tx_return(ctx, TX_OK, ctx->out);
|
|
return;
|
|
}
|
|
|
|
/* --- 매입확정/불일치 건만 접수('R') 로 되돌림 --- */
|
|
if (strcmp(rec.status, RC_ST_DONE) == 0 ||
|
|
strcmp(rec.status, RC_ST_FAIL) == 0) {
|
|
rc = rc_rec_update_status(key, RC_ST_RECV);
|
|
if (rc != TX_OK) {
|
|
tx_log(TX_LOG_ERROR, "[RC_OL_0030] 취소 전이 실패 key=%s rc=%d",
|
|
key, rc);
|
|
tx_return(ctx, rc, ctx->out);
|
|
return;
|
|
}
|
|
newstatus = RC_ST_RECV;
|
|
result = "CANCELLED";
|
|
tx_log(TX_LOG_INFO,
|
|
"[RC_OL_0030] 대사 취소 완료 key=%s %s→R", key, oldstatus);
|
|
} else {
|
|
result = "REJECT";
|
|
tx_log(TX_LOG_WARN,
|
|
"[RC_OL_0030] 취소 대상 아님 key=%s status=%s",
|
|
key, oldstatus);
|
|
}
|
|
|
|
tx_buf_reset(ctx->out);
|
|
tx_buf_sets(ctx->out, "KEY", rec.key);
|
|
tx_buf_sets(ctx->out, "OLDSTATUS", oldstatus);
|
|
tx_buf_sets(ctx->out, "NEWSTATUS", newstatus);
|
|
tx_buf_sets(ctx->out, "RESULT", result);
|
|
tx_log(TX_LOG_INFO,
|
|
"[RC_OL_0030] 대사 취소 서비스 종료 key=%s %s→%s 결과=%s",
|
|
key, oldstatus, newstatus, result);
|
|
tx_return(ctx, TX_OK, ctx->out);
|
|
}
|