Phase 2c: 전 11모듈 per-service 레거시 구조 분해·확장 (실동작 유지)
- 10개 모듈(au py rc st lg cl mm vl mg cm)을 ac 템플릿대로 분해: svc/ 30 서비스 .pgc + 카피북 .h, 얇은 <mod>_svr 디스패처 dbio/ ~25 .pgc(+.h), batch/ ~17 .pgc, run/ ~17 .sh (모듈마다) - 파일: svc 330 + dbio 276 + batch 187 + run 187, 총 소스 1602본 - 서비스별 고유 실로직(정규화 md5), build.sh 자동발견(inline/split 양립) - 통합 검증: build DONE modules=11 servers=11 batches=187, 12서버 runok, 333 서비스 AVAIL, 매입체인 XA 커밋(status=S), prepared_xacts=0 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
c3b99a8b75
commit
fd8b418c6e
1404 changed files with 30322 additions and 5994 deletions
14
app/src/au/dbio/au_auth_agg_dbio.h
Normal file
14
app/src/au/dbio/au_auth_agg_dbio.h
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
/*
|
||||
* au_auth_agg_dbio.h - au 모듈 DB 접근 계층 copybook (au_auth_agg_dbio, part of libaudbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef AU_AUTH_AGG_DBIO_H
|
||||
#define AU_AUTH_AGG_DBIO_H
|
||||
|
||||
typedef struct { char biz_date[16]; long gross; long cnt; } au_auth_agg_rec_t;
|
||||
|
||||
long audb_auth_gross_by_date(const char *bizdate);
|
||||
long audb_auth_count_by_date(const char *bizdate);
|
||||
|
||||
#endif /* AU_AUTH_AGG_DBIO_H */
|
||||
35
app/src/au/dbio/au_auth_agg_dbio.pgc
Normal file
35
app/src/au/dbio/au_auth_agg_dbio.pgc
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* au_auth_agg_dbio.pgc - au 모듈 DB 접근 함수 세트 (au_auth_agg_dbio), archived into libaudbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* Shape: aggregate sum/count (일자별 집계).
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "au_auth_agg_dbio.h"
|
||||
|
||||
/* 당일 승인 총액. */
|
||||
long audb_auth_gross_by_date(const char *bizdate)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
long h_v = 0;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
EXEC SQL SELECT coalesce(sum(amount),0) INTO :h_v FROM au_authorization
|
||||
WHERE biz_date = :h_bizdate AND status = 'A';
|
||||
if (sqlca.sqlcode < 0) { userlog("audb_auth_gross_by_date FAIL [%d] %s", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); return -1; }
|
||||
return h_v;
|
||||
}
|
||||
|
||||
/* 당일 승인 건수. */
|
||||
long audb_auth_count_by_date(const char *bizdate)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
long h_v = 0;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
EXEC SQL SELECT count(*) INTO :h_v FROM au_authorization WHERE biz_date = :h_bizdate;
|
||||
if (sqlca.sqlcode < 0) { userlog("audb_auth_count_by_date FAIL [%d] %s", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); return -1; }
|
||||
return h_v;
|
||||
}
|
||||
13
app/src/au/dbio/au_auth_bucket_dbio.h
Normal file
13
app/src/au/dbio/au_auth_bucket_dbio.h
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* au_auth_bucket_dbio.h - au 모듈 DB 접근 계층 copybook (au_auth_bucket_dbio, part of libaudbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef AU_AUTH_BUCKET_DBIO_H
|
||||
#define AU_AUTH_BUCKET_DBIO_H
|
||||
|
||||
typedef struct { char biz_date[16]; long small; long medium; long large; } au_auth_bucket_rec_t;
|
||||
|
||||
long audb_auth_large_bucket(const char *bizdate);
|
||||
|
||||
#endif /* AU_AUTH_BUCKET_DBIO_H */
|
||||
25
app/src/au/dbio/au_auth_bucket_dbio.pgc
Normal file
25
app/src/au/dbio/au_auth_bucket_dbio.pgc
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* au_auth_bucket_dbio.pgc - au 모듈 DB 접근 함수 세트 (au_auth_bucket_dbio), archived into libaudbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* Shape: CASE-based bucketing aggregate (금액대별 버킷팅, 고액 버킷 건수).
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "au_auth_bucket_dbio.h"
|
||||
|
||||
/* 당일 승인을 금액대(소/중/대)로 CASE 버킷팅하여 고액(>=1,000,000) 버킷 건수 반환. */
|
||||
long audb_auth_large_bucket(const char *bizdate)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
long h_v = 0;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
EXEC SQL SELECT coalesce(sum(
|
||||
CASE WHEN amount >= 1000000 THEN 1
|
||||
WHEN amount >= 100000 THEN 0
|
||||
ELSE 0 END), 0) INTO :h_v
|
||||
FROM au_authorization WHERE biz_date = :h_bizdate;
|
||||
if (sqlca.sqlcode < 0) return -1;
|
||||
return h_v;
|
||||
}
|
||||
13
app/src/au/dbio/au_auth_overavg_dbio.h
Normal file
13
app/src/au/dbio/au_auth_overavg_dbio.h
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* au_auth_overavg_dbio.h - au 모듈 DB 접근 계층 copybook (au_auth_overavg_dbio, part of libaudbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef AU_AUTH_OVERAVG_DBIO_H
|
||||
#define AU_AUTH_OVERAVG_DBIO_H
|
||||
|
||||
typedef struct { char biz_date[16]; long over_avg_cnt; } au_auth_overavg_rec_t;
|
||||
|
||||
long audb_auth_over_avg_count(const char *bizdate);
|
||||
|
||||
#endif /* AU_AUTH_OVERAVG_DBIO_H */
|
||||
23
app/src/au/dbio/au_auth_overavg_dbio.pgc
Normal file
23
app/src/au/dbio/au_auth_overavg_dbio.pgc
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* au_auth_overavg_dbio.pgc - au 모듈 DB 접근 함수 세트 (au_auth_overavg_dbio), archived into libaudbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* Shape: scalar-subquery comparison WHERE amount > (SELECT avg ...) (평균초과 승인 건수).
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "au_auth_overavg_dbio.h"
|
||||
|
||||
/* 당일 평균 승인금액을 초과하는 승인 건수 (스칼라 서브쿼리 비교). */
|
||||
long audb_auth_over_avg_count(const char *bizdate)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
long h_v = 0;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
EXEC SQL SELECT count(*) INTO :h_v FROM au_authorization
|
||||
WHERE biz_date = :h_bizdate
|
||||
AND amount > (SELECT coalesce(avg(amount),0) FROM au_authorization WHERE biz_date = :h_bizdate);
|
||||
if (sqlca.sqlcode < 0) return -1;
|
||||
return h_v;
|
||||
}
|
||||
14
app/src/au/dbio/au_auth_query_dbio.h
Normal file
14
app/src/au/dbio/au_auth_query_dbio.h
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
/*
|
||||
* au_auth_query_dbio.h - au 모듈 DB 접근 계층 copybook (au_auth_query_dbio, part of libaudbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef AU_AUTH_QUERY_DBIO_H
|
||||
#define AU_AUTH_QUERY_DBIO_H
|
||||
|
||||
typedef struct { long auth_id; long amount; char status[8]; } au_auth_q_rec_t;
|
||||
|
||||
long audb_auth_amount(long auth_id);
|
||||
long audb_auth_card_count(const char *card);
|
||||
|
||||
#endif /* AU_AUTH_QUERY_DBIO_H */
|
||||
33
app/src/au/dbio/au_auth_query_dbio.pgc
Normal file
33
app/src/au/dbio/au_auth_query_dbio.pgc
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* au_auth_query_dbio.pgc - au 모듈 DB 접근 함수 세트 (au_auth_query_dbio), archived into libaudbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* Shape: plain scalar SELECT (단건 스칼라 조회).
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "au_auth_query_dbio.h"
|
||||
|
||||
/* 단일 승인의 금액. */
|
||||
long audb_auth_amount(long auth_id)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long h_id, h_v = 0;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
h_id = auth_id;
|
||||
EXEC SQL SELECT coalesce(amount,0) INTO :h_v FROM au_authorization WHERE auth_id = :h_id;
|
||||
if (sqlca.sqlcode < 0) { userlog("audb_auth_amount FAIL [%d] %s", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); return -1; }
|
||||
return h_v;
|
||||
}
|
||||
|
||||
/* 카드의 전체 승인 건수. */
|
||||
long audb_auth_card_count(const char *card)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_card[24];
|
||||
long h_v = 0;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_card, card, sizeof(h_card)-1); h_card[sizeof(h_card)-1] = 0;
|
||||
EXEC SQL SELECT count(*) INTO :h_v FROM au_authorization WHERE card_no = :h_card;
|
||||
if (sqlca.sqlcode < 0) { userlog("audb_auth_card_count FAIL [%d] %s", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); return -1; }
|
||||
return h_v;
|
||||
}
|
||||
13
app/src/au/dbio/au_auth_status_dbio.h
Normal file
13
app/src/au/dbio/au_auth_status_dbio.h
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* au_auth_status_dbio.h - au 모듈 DB 접근 계층 copybook (au_auth_status_dbio, part of libaudbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef AU_AUTH_STATUS_DBIO_H
|
||||
#define AU_AUTH_STATUS_DBIO_H
|
||||
|
||||
typedef struct { char biz_date[16]; char status[8]; long cnt; } au_auth_status_rec_t;
|
||||
|
||||
long audb_status_declined_count(const char *bizdate);
|
||||
|
||||
#endif /* AU_AUTH_STATUS_DBIO_H */
|
||||
30
app/src/au/dbio/au_auth_status_dbio.pgc
Normal file
30
app/src/au/dbio/au_auth_status_dbio.pgc
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* au_auth_status_dbio.pgc - au 모듈 DB 접근 함수 세트 (au_auth_status_dbio), archived into libaudbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* Shape: cursor loop (DECLARE/OPEN/FETCH/CLOSE) over status groups.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "au_auth_status_dbio.h"
|
||||
|
||||
/* 상태별 건수를 커서로 순회하여 거절(D) 건수만 추출. */
|
||||
long audb_status_declined_count(const char *bizdate)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16], h_st[8];
|
||||
long h_cnt, declined = 0;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
EXEC SQL DECLARE ausc CURSOR FOR
|
||||
SELECT status, count(*) FROM au_authorization WHERE biz_date = :h_bizdate GROUP BY status;
|
||||
EXEC SQL OPEN ausc;
|
||||
if (sqlca.sqlcode < 0) return -1;
|
||||
for (;;) {
|
||||
EXEC SQL FETCH ausc INTO :h_st, :h_cnt;
|
||||
if (sqlca.sqlcode == 100) break;
|
||||
if (sqlca.sqlcode < 0) { EXEC SQL CLOSE ausc; return -1; }
|
||||
if (h_st[0] == 'D') declined = h_cnt;
|
||||
}
|
||||
EXEC SQL CLOSE ausc;
|
||||
return declined;
|
||||
}
|
||||
13
app/src/au/dbio/au_auth_type_dbio.h
Normal file
13
app/src/au/dbio/au_auth_type_dbio.h
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* au_auth_type_dbio.h - au 모듈 DB 접근 계층 copybook (au_auth_type_dbio, part of libaudbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef AU_AUTH_TYPE_DBIO_H
|
||||
#define AU_AUTH_TYPE_DBIO_H
|
||||
|
||||
typedef struct { char biz_date[16]; long variety; } au_auth_type_rec_t;
|
||||
|
||||
long audb_auth_type_variety(const char *bizdate);
|
||||
|
||||
#endif /* AU_AUTH_TYPE_DBIO_H */
|
||||
21
app/src/au/dbio/au_auth_type_dbio.pgc
Normal file
21
app/src/au/dbio/au_auth_type_dbio.pgc
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* au_auth_type_dbio.pgc - au 모듈 DB 접근 함수 세트 (au_auth_type_dbio), archived into libaudbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* Shape: count(DISTINCT ...) (당일 사용된 승인유형 가짓수).
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "au_auth_type_dbio.h"
|
||||
|
||||
/* 당일 사용된 승인유형(AUTH/STANDIN/INSTALL/PREAUTH ...) 가짓수. */
|
||||
long audb_auth_type_variety(const char *bizdate)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
long h_v = 0;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
EXEC SQL SELECT count(DISTINCT auth_type) INTO :h_v FROM au_authorization WHERE biz_date = :h_bizdate;
|
||||
if (sqlca.sqlcode < 0) return -1;
|
||||
return h_v;
|
||||
}
|
||||
13
app/src/au/dbio/au_blacklist_query_dbio.h
Normal file
13
app/src/au/dbio/au_blacklist_query_dbio.h
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* au_blacklist_query_dbio.h - au 모듈 DB 접근 계층 copybook (au_blacklist_query_dbio, part of libaudbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef AU_BLACKLIST_QUERY_DBIO_H
|
||||
#define AU_BLACKLIST_QUERY_DBIO_H
|
||||
|
||||
typedef struct { char card_no[24]; long listed; } au_blacklist_q_rec_t;
|
||||
|
||||
long audb_blacklist_exists(const char *card);
|
||||
|
||||
#endif /* AU_BLACKLIST_QUERY_DBIO_H */
|
||||
22
app/src/au/dbio/au_blacklist_query_dbio.pgc
Normal file
22
app/src/au/dbio/au_blacklist_query_dbio.pgc
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* au_blacklist_query_dbio.pgc - au 모듈 DB 접근 함수 세트 (au_blacklist_query_dbio), archived into libaudbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* Shape: EXISTS predicate SELECT (블랙리스트 존재여부 0/1).
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "au_blacklist_query_dbio.h"
|
||||
|
||||
/* 카드가 블랙리스트에 존재하면 1, 없으면 0. */
|
||||
long audb_blacklist_exists(const char *card)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_card[24];
|
||||
int h_v = 0;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_card, card, sizeof(h_card)-1); h_card[sizeof(h_card)-1] = 0;
|
||||
EXEC SQL SELECT CASE WHEN EXISTS (SELECT 1 FROM au_blacklist WHERE card_no = :h_card)
|
||||
THEN 1 ELSE 0 END INTO :h_v;
|
||||
if (sqlca.sqlcode < 0) { userlog("audb_blacklist_exists FAIL [%d] %s", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); return -1; }
|
||||
return (long)h_v;
|
||||
}
|
||||
13
app/src/au/dbio/au_cancel_agg_dbio.h
Normal file
13
app/src/au/dbio/au_cancel_agg_dbio.h
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* au_cancel_agg_dbio.h - au 모듈 DB 접근 계층 copybook (au_cancel_agg_dbio, part of libaudbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef AU_CANCEL_AGG_DBIO_H
|
||||
#define AU_CANCEL_AGG_DBIO_H
|
||||
|
||||
typedef struct { char biz_date[16]; long full_amt; long partial_amt; } au_cancel_agg_rec_t;
|
||||
|
||||
long audb_cancel_partial_sum(const char *bizdate);
|
||||
|
||||
#endif /* AU_CANCEL_AGG_DBIO_H */
|
||||
25
app/src/au/dbio/au_cancel_agg_dbio.pgc
Normal file
25
app/src/au/dbio/au_cancel_agg_dbio.pgc
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* au_cancel_agg_dbio.pgc - au 모듈 DB 접근 함수 세트 (au_cancel_agg_dbio), archived into libaudbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* Shape: FILTER (WHERE ...) aggregate (취소유형별 분리 집계).
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "au_cancel_agg_dbio.h"
|
||||
|
||||
/* FULL/PARTIAL 취소를 한 번에 분리 집계하고 PARTIAL 합 반환. */
|
||||
long audb_cancel_partial_sum(const char *bizdate)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
long h_full = 0, h_part = 0;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
EXEC SQL SELECT
|
||||
coalesce(sum(amount) FILTER (WHERE cancel_type = 'FULL'), 0),
|
||||
coalesce(sum(amount) FILTER (WHERE cancel_type = 'PARTIAL'), 0)
|
||||
INTO :h_full, :h_part FROM au_cancel WHERE biz_date = :h_bizdate;
|
||||
if (sqlca.sqlcode < 0) return -1;
|
||||
if (h_full < 0) return -1;
|
||||
return h_part;
|
||||
}
|
||||
13
app/src/au/dbio/au_cancel_query_dbio.h
Normal file
13
app/src/au/dbio/au_cancel_query_dbio.h
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* au_cancel_query_dbio.h - au 모듈 DB 접근 계층 copybook (au_cancel_query_dbio, part of libaudbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef AU_CANCEL_QUERY_DBIO_H
|
||||
#define AU_CANCEL_QUERY_DBIO_H
|
||||
|
||||
typedef struct { long auth_id; long cancel_amount; char cancel_type[8]; } au_cancel_q_rec_t;
|
||||
|
||||
long audb_cancel_amount_by_auth(long auth_id);
|
||||
|
||||
#endif /* AU_CANCEL_QUERY_DBIO_H */
|
||||
20
app/src/au/dbio/au_cancel_query_dbio.pgc
Normal file
20
app/src/au/dbio/au_cancel_query_dbio.pgc
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* au_cancel_query_dbio.pgc - au 모듈 DB 접근 함수 세트 (au_cancel_query_dbio), archived into libaudbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* Shape: aggregate sum keyed by FK (한 승인의 누적 취소액).
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "au_cancel_query_dbio.h"
|
||||
|
||||
/* 한 승인건에 대한 누적 취소 금액. */
|
||||
long audb_cancel_amount_by_auth(long auth_id)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long h_auth, h_v = 0;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
h_auth = auth_id;
|
||||
EXEC SQL SELECT coalesce(sum(amount),0) INTO :h_v FROM au_cancel WHERE auth_id = :h_auth;
|
||||
if (sqlca.sqlcode < 0) { userlog("audb_cancel_amount_by_auth FAIL [%d] %s", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); return -1; }
|
||||
return h_v;
|
||||
}
|
||||
13
app/src/au/dbio/au_capture_query_dbio.h
Normal file
13
app/src/au/dbio/au_capture_query_dbio.h
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* au_capture_query_dbio.h - au 모듈 DB 접근 계층 copybook (au_capture_query_dbio, part of libaudbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef AU_CAPTURE_QUERY_DBIO_H
|
||||
#define AU_CAPTURE_QUERY_DBIO_H
|
||||
|
||||
typedef struct { char biz_date[16]; long max_amt; long min_amt; } au_capture_q_rec_t;
|
||||
|
||||
long audb_capture_amount_range(const char *bizdate);
|
||||
|
||||
#endif /* AU_CAPTURE_QUERY_DBIO_H */
|
||||
23
app/src/au/dbio/au_capture_query_dbio.pgc
Normal file
23
app/src/au/dbio/au_capture_query_dbio.pgc
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* au_capture_query_dbio.pgc - au 모듈 DB 접근 함수 세트 (au_capture_query_dbio), archived into libaudbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* Shape: min AND max in one SELECT, computed range (매입확정 금액 범위).
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "au_capture_query_dbio.h"
|
||||
|
||||
/* 매입확정(M) 승인의 최대-최소 금액 폭. */
|
||||
long audb_capture_amount_range(const char *bizdate)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
long h_max = 0, h_min = 0;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
EXEC SQL SELECT coalesce(max(amount),0), coalesce(min(amount),0)
|
||||
INTO :h_max, :h_min FROM au_authorization
|
||||
WHERE biz_date = :h_bizdate AND status = 'M';
|
||||
if (sqlca.sqlcode < 0) return -1;
|
||||
return h_max - h_min;
|
||||
}
|
||||
13
app/src/au/dbio/au_card_velocity_dbio.h
Normal file
13
app/src/au/dbio/au_card_velocity_dbio.h
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* au_card_velocity_dbio.h - au 모듈 DB 접근 계층 copybook (au_card_velocity_dbio, part of libaudbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef AU_CARD_VELOCITY_DBIO_H
|
||||
#define AU_CARD_VELOCITY_DBIO_H
|
||||
|
||||
typedef struct { char biz_date[16]; long blacklisted_auths; } au_card_velocity_rec_t;
|
||||
|
||||
long audb_blacklisted_auth_count(const char *bizdate);
|
||||
|
||||
#endif /* AU_CARD_VELOCITY_DBIO_H */
|
||||
23
app/src/au/dbio/au_card_velocity_dbio.pgc
Normal file
23
app/src/au/dbio/au_card_velocity_dbio.pgc
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* au_card_velocity_dbio.pgc - au 모듈 DB 접근 함수 세트 (au_card_velocity_dbio), archived into libaudbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* Shape: subquery WHERE col IN (SELECT ...) (블랙리스트 카드의 당일 승인 건수).
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "au_card_velocity_dbio.h"
|
||||
|
||||
/* 블랙리스트에 등재된 카드가 당일 발생시킨 승인 건수. */
|
||||
long audb_blacklisted_auth_count(const char *bizdate)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
long h_v = 0;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
EXEC SQL SELECT count(*) INTO :h_v FROM au_authorization
|
||||
WHERE biz_date = :h_bizdate
|
||||
AND card_no IN (SELECT card_no FROM au_blacklist);
|
||||
if (sqlca.sqlcode < 0) return -1;
|
||||
return h_v;
|
||||
}
|
||||
13
app/src/au/dbio/au_decline_reason_dbio.h
Normal file
13
app/src/au/dbio/au_decline_reason_dbio.h
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* au_decline_reason_dbio.h - au 모듈 DB 접근 계층 copybook (au_decline_reason_dbio, part of libaudbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef AU_DECLINE_REASON_DBIO_H
|
||||
#define AU_DECLINE_REASON_DBIO_H
|
||||
|
||||
typedef struct { char biz_date[16]; char reason[128]; long cnt; } au_decline_reason_rec_t;
|
||||
|
||||
long audb_decline_total_by_reason(const char *bizdate);
|
||||
|
||||
#endif /* AU_DECLINE_REASON_DBIO_H */
|
||||
32
app/src/au/dbio/au_decline_reason_dbio.pgc
Normal file
32
app/src/au/dbio/au_decline_reason_dbio.pgc
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* au_decline_reason_dbio.pgc - au 모듈 DB 접근 함수 세트 (au_decline_reason_dbio), archived into libaudbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* Shape: cursor over GROUP BY decline_reason, accumulating counts (거절사유 누적).
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "au_decline_reason_dbio.h"
|
||||
|
||||
/* 거절(D) 건을 사유별로 커서 순회하며 총 거절 건수를 누적. */
|
||||
long audb_decline_total_by_reason(const char *bizdate)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16], h_reason[128];
|
||||
long h_cnt, total = 0;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
EXEC SQL DECLARE drc CURSOR FOR
|
||||
SELECT decline_reason, count(*) FROM au_authorization
|
||||
WHERE biz_date = :h_bizdate AND status = 'D'
|
||||
GROUP BY decline_reason;
|
||||
EXEC SQL OPEN drc;
|
||||
if (sqlca.sqlcode < 0) return -1;
|
||||
for (;;) {
|
||||
EXEC SQL FETCH drc INTO :h_reason, :h_cnt;
|
||||
if (sqlca.sqlcode == 100) break;
|
||||
if (sqlca.sqlcode < 0) { EXEC SQL CLOSE drc; return -1; }
|
||||
total = total + h_cnt;
|
||||
}
|
||||
EXEC SQL CLOSE drc;
|
||||
return total;
|
||||
}
|
||||
13
app/src/au/dbio/au_fraud_agg_dbio.h
Normal file
13
app/src/au/dbio/au_fraud_agg_dbio.h
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* au_fraud_agg_dbio.h - au 모듈 DB 접근 계층 copybook (au_fraud_agg_dbio, part of libaudbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef AU_FRAUD_AGG_DBIO_H
|
||||
#define AU_FRAUD_AGG_DBIO_H
|
||||
|
||||
typedef struct { char biz_date[16]; long score_sum; long fraud_cnt; } au_fraud_agg_rec_t;
|
||||
|
||||
long audb_fraud_avg_score(const char *bizdate);
|
||||
|
||||
#endif /* AU_FRAUD_AGG_DBIO_H */
|
||||
23
app/src/au/dbio/au_fraud_agg_dbio.pgc
Normal file
23
app/src/au/dbio/au_fraud_agg_dbio.pgc
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* au_fraud_agg_dbio.pgc - au 모듈 DB 접근 함수 세트 (au_fraud_agg_dbio), archived into libaudbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* Shape: computed avg = sum/count (건당 평균 스코어).
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "au_fraud_agg_dbio.h"
|
||||
|
||||
/* 당일 건당 평균 부정거래 스코어 = sum(score)/count(*). */
|
||||
long audb_fraud_avg_score(const char *bizdate)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
long h_sum = 0, h_cnt = 0;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
EXEC SQL SELECT coalesce(sum(score),0), count(*)
|
||||
INTO :h_sum, :h_cnt FROM au_fraud_log WHERE biz_date = :h_bizdate;
|
||||
if (sqlca.sqlcode < 0) return -1;
|
||||
if (h_cnt <= 0) return 0;
|
||||
return h_sum / h_cnt;
|
||||
}
|
||||
13
app/src/au/dbio/au_fraud_join_dbio.h
Normal file
13
app/src/au/dbio/au_fraud_join_dbio.h
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* au_fraud_join_dbio.h - au 모듈 DB 접근 계층 copybook (au_fraud_join_dbio, part of libaudbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef AU_FRAUD_JOIN_DBIO_H
|
||||
#define AU_FRAUD_JOIN_DBIO_H
|
||||
|
||||
typedef struct { char biz_date[16]; long high_risk_amount; } au_fraud_join_rec_t;
|
||||
|
||||
long audb_fraud_high_risk_amount(const char *bizdate);
|
||||
|
||||
#endif /* AU_FRAUD_JOIN_DBIO_H */
|
||||
24
app/src/au/dbio/au_fraud_join_dbio.pgc
Normal file
24
app/src/au/dbio/au_fraud_join_dbio.pgc
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* au_fraud_join_dbio.pgc - au 모듈 DB 접근 함수 세트 (au_fraud_join_dbio), archived into libaudbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* Shape: 2-table JOIN with predicate (고위험 부정거래 연계 승인금액).
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "au_fraud_join_dbio.h"
|
||||
|
||||
/* fraud_log(score>=50) 와 연결된 승인원장 금액 합계를 조인으로 산출. */
|
||||
long audb_fraud_high_risk_amount(const char *bizdate)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
long h_v = 0;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
EXEC SQL SELECT coalesce(sum(a.amount),0) INTO :h_v
|
||||
FROM au_fraud_log f
|
||||
JOIN au_authorization a ON f.auth_id = a.auth_id
|
||||
WHERE f.biz_date = :h_bizdate AND f.score >= 50;
|
||||
if (sqlca.sqlcode < 0) { userlog("audb_fraud_high_risk_amount FAIL [%d] %s", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); return -1; }
|
||||
return h_v;
|
||||
}
|
||||
14
app/src/au/dbio/au_fraud_query_dbio.h
Normal file
14
app/src/au/dbio/au_fraud_query_dbio.h
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
/*
|
||||
* au_fraud_query_dbio.h - au 모듈 DB 접근 계층 copybook (au_fraud_query_dbio, part of libaudbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef AU_FRAUD_QUERY_DBIO_H
|
||||
#define AU_FRAUD_QUERY_DBIO_H
|
||||
|
||||
typedef struct { char card_no[24]; long max_score; long min_score; } au_fraud_q_rec_t;
|
||||
|
||||
long audb_fraud_max_score(const char *card);
|
||||
long audb_fraud_min_score(const char *card);
|
||||
|
||||
#endif /* AU_FRAUD_QUERY_DBIO_H */
|
||||
34
app/src/au/dbio/au_fraud_query_dbio.pgc
Normal file
34
app/src/au/dbio/au_fraud_query_dbio.pgc
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* au_fraud_query_dbio.pgc - au 모듈 DB 접근 함수 세트 (au_fraud_query_dbio), archived into libaudbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* Shape: min/max aggregate (카드별 부정거래 스코어 극값).
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "au_fraud_query_dbio.h"
|
||||
|
||||
/* 카드의 최대 부정거래 스코어. */
|
||||
long audb_fraud_max_score(const char *card)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_card[24];
|
||||
long h_v = 0;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_card, card, sizeof(h_card)-1); h_card[sizeof(h_card)-1] = 0;
|
||||
EXEC SQL SELECT coalesce(max(score),0) INTO :h_v FROM au_fraud_log WHERE card_no = :h_card;
|
||||
if (sqlca.sqlcode < 0) return -1;
|
||||
return h_v;
|
||||
}
|
||||
|
||||
/* 카드의 최소 부정거래 스코어. */
|
||||
long audb_fraud_min_score(const char *card)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_card[24];
|
||||
long h_v = 0;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_card, card, sizeof(h_card)-1); h_card[sizeof(h_card)-1] = 0;
|
||||
EXEC SQL SELECT coalesce(min(score),0) INTO :h_v FROM au_fraud_log WHERE card_no = :h_card;
|
||||
if (sqlca.sqlcode < 0) return -1;
|
||||
return h_v;
|
||||
}
|
||||
14
app/src/au/dbio/au_limit_agg_dbio.h
Normal file
14
app/src/au/dbio/au_limit_agg_dbio.h
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
/*
|
||||
* au_limit_agg_dbio.h - au 모듈 DB 접근 계층 copybook (au_limit_agg_dbio, part of libaudbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef AU_LIMIT_AGG_DBIO_H
|
||||
#define AU_LIMIT_AGG_DBIO_H
|
||||
|
||||
typedef struct { long total_used; long over_cards; } au_limit_agg_rec_t;
|
||||
|
||||
long audb_limit_total_used(void);
|
||||
long audb_limit_over_cards(void);
|
||||
|
||||
#endif /* AU_LIMIT_AGG_DBIO_H */
|
||||
30
app/src/au/dbio/au_limit_agg_dbio.pgc
Normal file
30
app/src/au/dbio/au_limit_agg_dbio.pgc
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* au_limit_agg_dbio.pgc - au 모듈 DB 접근 함수 세트 (au_limit_agg_dbio), archived into libaudbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* Shape: table-wide aggregate + comparison-predicate count (인자 없음).
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "au_limit_agg_dbio.h"
|
||||
|
||||
/* 전체 카드의 사용금액 총합. */
|
||||
long audb_limit_total_used(void)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long h_v = 0;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
EXEC SQL SELECT coalesce(sum(used_amount),0) INTO :h_v FROM card_limit;
|
||||
if (sqlca.sqlcode < 0) return -1;
|
||||
return h_v;
|
||||
}
|
||||
|
||||
/* 한도를 초과 사용한(used_amount > daily_limit) 카드 수. */
|
||||
long audb_limit_over_cards(void)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long h_v = 0;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
EXEC SQL SELECT count(*) INTO :h_v FROM card_limit WHERE used_amount > daily_limit;
|
||||
if (sqlca.sqlcode < 0) return -1;
|
||||
return h_v;
|
||||
}
|
||||
14
app/src/au/dbio/au_limit_query_dbio.h
Normal file
14
app/src/au/dbio/au_limit_query_dbio.h
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
/*
|
||||
* au_limit_query_dbio.h - au 모듈 DB 접근 계층 copybook (au_limit_query_dbio, part of libaudbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef AU_LIMIT_QUERY_DBIO_H
|
||||
#define AU_LIMIT_QUERY_DBIO_H
|
||||
|
||||
typedef struct { char card_no[24]; long available; long utilization; } au_limit_q_rec_t;
|
||||
|
||||
long audb_limit_available(const char *card);
|
||||
long audb_limit_utilization(const char *card);
|
||||
|
||||
#endif /* AU_LIMIT_QUERY_DBIO_H */
|
||||
37
app/src/au/dbio/au_limit_query_dbio.pgc
Normal file
37
app/src/au/dbio/au_limit_query_dbio.pgc
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* au_limit_query_dbio.pgc - au 모듈 DB 접근 함수 세트 (au_limit_query_dbio), archived into libaudbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* Shape: computed column SELECT + guarded division.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "au_limit_query_dbio.h"
|
||||
|
||||
/* 가용한도 = daily_limit - used_amount (DB 계산). */
|
||||
long audb_limit_available(const char *card)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_card[24];
|
||||
long h_v = 0;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_card, card, sizeof(h_card)-1); h_card[sizeof(h_card)-1] = 0;
|
||||
EXEC SQL SELECT coalesce(daily_limit - used_amount, 0) INTO :h_v
|
||||
FROM card_limit WHERE card_no = :h_card;
|
||||
if (sqlca.sqlcode < 0 || sqlca.sqlcode == 100) return -1;
|
||||
return h_v;
|
||||
}
|
||||
|
||||
/* 한도 소진율(%) = used_amount*100/daily_limit (0 나눗셈 방지). */
|
||||
long audb_limit_utilization(const char *card)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_card[24];
|
||||
long h_lim = 0, h_used = 0;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_card, card, sizeof(h_card)-1); h_card[sizeof(h_card)-1] = 0;
|
||||
EXEC SQL SELECT coalesce(daily_limit,0), coalesce(used_amount,0)
|
||||
INTO :h_lim, :h_used FROM card_limit WHERE card_no = :h_card;
|
||||
if (sqlca.sqlcode < 0 || sqlca.sqlcode == 100) return -1;
|
||||
if (h_lim <= 0) return 0;
|
||||
return h_used * 100 / h_lim;
|
||||
}
|
||||
13
app/src/au/dbio/au_limit_upsert_dbio.h
Normal file
13
app/src/au/dbio/au_limit_upsert_dbio.h
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* au_limit_upsert_dbio.h - au 모듈 DB 접근 계층 copybook (au_limit_upsert_dbio, part of libaudbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: 0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef AU_LIMIT_UPSERT_DBIO_H
|
||||
#define AU_LIMIT_UPSERT_DBIO_H
|
||||
|
||||
typedef struct { char card_no[24]; long temp_limit; } au_limit_upsert_rec_t;
|
||||
|
||||
int audb_limit_temp_clear(const char *card);
|
||||
|
||||
#endif /* AU_LIMIT_UPSERT_DBIO_H */
|
||||
26
app/src/au/dbio/au_limit_upsert_dbio.pgc
Normal file
26
app/src/au/dbio/au_limit_upsert_dbio.pgc
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* au_limit_upsert_dbio.pgc - au 모듈 DB 접근 함수 세트 (au_limit_upsert_dbio), archived into libaudbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* Shape: ON CONFLICT upsert (임시한도 초기화 행 upsert).
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "au_limit_upsert_dbio.h"
|
||||
|
||||
/* 카드 한도행을 보장하고 임시한도(temp_limit)를 0 으로 초기화(upsert). */
|
||||
int audb_limit_temp_clear(const char *card)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_card[24];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_card, card, sizeof(h_card)-1); h_card[sizeof(h_card)-1] = 0;
|
||||
EXEC SQL INSERT INTO card_limit (card_no, daily_limit, used_amount, temp_limit)
|
||||
VALUES (:h_card, 0, 0, 0)
|
||||
ON CONFLICT (card_no) DO UPDATE
|
||||
SET temp_limit = 0, updated_at = now();
|
||||
if (sqlca.sqlcode < 0) {
|
||||
userlog("audb_limit_temp_clear FAIL [%d] %s", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
13
app/src/au/dbio/au_merchant_join_dbio.h
Normal file
13
app/src/au/dbio/au_merchant_join_dbio.h
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* au_merchant_join_dbio.h - au 모듈 DB 접근 계층 copybook (au_merchant_join_dbio, part of libaudbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef AU_MERCHANT_JOIN_DBIO_H
|
||||
#define AU_MERCHANT_JOIN_DBIO_H
|
||||
|
||||
typedef struct { char merchant_id[64]; char biz_date[16]; long joined_gross; } au_merchant_join_rec_t;
|
||||
|
||||
long audb_merchant_reconciled_gross(const char *bizdate);
|
||||
|
||||
#endif /* AU_MERCHANT_JOIN_DBIO_H */
|
||||
24
app/src/au/dbio/au_merchant_join_dbio.pgc
Normal file
24
app/src/au/dbio/au_merchant_join_dbio.pgc
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* au_merchant_join_dbio.pgc - au 모듈 DB 접근 함수 세트 (au_merchant_join_dbio), archived into libaudbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* Shape: 2-table JOIN aggregate (승인원장 x 승인집계 조인 총액).
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "au_merchant_join_dbio.h"
|
||||
|
||||
/* au_summary 에 집계행이 존재하는 가맹점의 당일 승인 총액을 조인으로 집계. */
|
||||
long audb_merchant_reconciled_gross(const char *bizdate)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
long h_v = 0;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
EXEC SQL SELECT coalesce(sum(a.amount),0) INTO :h_v
|
||||
FROM au_authorization a
|
||||
JOIN au_summary s ON a.merchant_id = s.merchant_id AND a.biz_date = s.biz_date
|
||||
WHERE a.biz_date = :h_bizdate AND a.status = 'A';
|
||||
if (sqlca.sqlcode < 0) { userlog("audb_merchant_reconciled_gross FAIL [%d] %s", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); return -1; }
|
||||
return h_v;
|
||||
}
|
||||
13
app/src/au/dbio/au_preauth_agg_dbio.h
Normal file
13
app/src/au/dbio/au_preauth_agg_dbio.h
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* au_preauth_agg_dbio.h - au 모듈 DB 접근 계층 copybook (au_preauth_agg_dbio, part of libaudbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef AU_PREAUTH_AGG_DBIO_H
|
||||
#define AU_PREAUTH_AGG_DBIO_H
|
||||
|
||||
typedef struct { char biz_date[16]; char merchant_id[64]; long open_cnt; } au_preauth_agg_rec_t;
|
||||
|
||||
long audb_preauth_open_merchants(const char *bizdate);
|
||||
|
||||
#endif /* AU_PREAUTH_AGG_DBIO_H */
|
||||
32
app/src/au/dbio/au_preauth_agg_dbio.pgc
Normal file
32
app/src/au/dbio/au_preauth_agg_dbio.pgc
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* au_preauth_agg_dbio.pgc - au 모듈 DB 접근 함수 세트 (au_preauth_agg_dbio), archived into libaudbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* Shape: GROUP BY ... HAVING via cursor (미확정 예비승인 보유 가맹점 수).
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "au_preauth_agg_dbio.h"
|
||||
|
||||
/* 미확정(P) 예비승인을 1건 이상 보유한 가맹점 수를 GROUP BY/HAVING 커서로 계수. */
|
||||
long audb_preauth_open_merchants(const char *bizdate)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16], h_merch[64];
|
||||
long h_cnt, merchants = 0;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
EXEC SQL DECLARE pamc CURSOR FOR
|
||||
SELECT merchant_id, count(*) FROM au_preauth
|
||||
WHERE biz_date = :h_bizdate AND status = 'P'
|
||||
GROUP BY merchant_id HAVING count(*) >= 1;
|
||||
EXEC SQL OPEN pamc;
|
||||
if (sqlca.sqlcode < 0) return -1;
|
||||
for (;;) {
|
||||
EXEC SQL FETCH pamc INTO :h_merch, :h_cnt;
|
||||
if (sqlca.sqlcode == 100) break;
|
||||
if (sqlca.sqlcode < 0) { EXEC SQL CLOSE pamc; return -1; }
|
||||
merchants++;
|
||||
}
|
||||
EXEC SQL CLOSE pamc;
|
||||
return merchants;
|
||||
}
|
||||
13
app/src/au/dbio/au_preauth_query_dbio.h
Normal file
13
app/src/au/dbio/au_preauth_query_dbio.h
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* au_preauth_query_dbio.h - au 모듈 DB 접근 계층 copybook (au_preauth_query_dbio, part of libaudbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef AU_PREAUTH_QUERY_DBIO_H
|
||||
#define AU_PREAUTH_QUERY_DBIO_H
|
||||
|
||||
typedef struct { long preauth_id; long amount; char status[8]; } au_preauth_q_rec_t;
|
||||
|
||||
int audb_preauth_detail(long preauth_id, long *amount_out, char *status_out /* >= 2 */);
|
||||
|
||||
#endif /* AU_PREAUTH_QUERY_DBIO_H */
|
||||
27
app/src/au/dbio/au_preauth_query_dbio.pgc
Normal file
27
app/src/au/dbio/au_preauth_query_dbio.pgc
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* au_preauth_query_dbio.pgc - au 모듈 DB 접근 함수 세트 (au_preauth_query_dbio), archived into libaudbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* Shape: multi-column SELECT INTO out-params (예비승인 상세).
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "au_preauth_query_dbio.h"
|
||||
|
||||
/* 예비승인의 금액/상태를 한 번에 조회하여 out 파라미터로 반환. */
|
||||
int audb_preauth_detail(long preauth_id, long *amount_out, char *status_out)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long h_pre = preauth_id, h_amt = 0;
|
||||
char h_status[8];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
EXEC SQL SELECT coalesce(amount,0), status INTO :h_amt, :h_status
|
||||
FROM au_preauth WHERE preauth_id = :h_pre;
|
||||
if (sqlca.sqlcode < 0 || sqlca.sqlcode == 100) {
|
||||
userlog("audb_preauth_detail FAIL [%d] %s", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc);
|
||||
return -1;
|
||||
}
|
||||
*amount_out = h_amt;
|
||||
status_out[0] = h_status[0];
|
||||
status_out[1] = 0;
|
||||
return 0;
|
||||
}
|
||||
13
app/src/au/dbio/au_summary_query_dbio.h
Normal file
13
app/src/au/dbio/au_summary_query_dbio.h
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* au_summary_query_dbio.h - au 모듈 DB 접근 계층 copybook (au_summary_query_dbio, part of libaudbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef AU_SUMMARY_QUERY_DBIO_H
|
||||
#define AU_SUMMARY_QUERY_DBIO_H
|
||||
|
||||
typedef struct { char merchant_id[64]; char biz_date[16]; long approve_count; } au_summary_q_rec_t;
|
||||
|
||||
long audb_summary_approve_count(const char *merch, const char *bizdate);
|
||||
|
||||
#endif /* AU_SUMMARY_QUERY_DBIO_H */
|
||||
23
app/src/au/dbio/au_summary_query_dbio.pgc
Normal file
23
app/src/au/dbio/au_summary_query_dbio.pgc
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* au_summary_query_dbio.pgc - au 모듈 DB 접근 함수 세트 (au_summary_query_dbio), archived into libaudbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* Shape: two-key scalar SELECT (가맹점/일자 승인집계 단건).
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "au_summary_query_dbio.h"
|
||||
|
||||
/* 가맹점 당일 승인건수(au_summary.approve_count). */
|
||||
long audb_summary_approve_count(const char *merch, const char *bizdate)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_merch[64], h_bizdate[16];
|
||||
long h_v = 0;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
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;
|
||||
EXEC SQL SELECT coalesce(approve_count,0) INTO :h_v FROM au_summary
|
||||
WHERE merchant_id = :h_merch AND biz_date = :h_bizdate;
|
||||
if (sqlca.sqlcode < 0) { userlog("audb_summary_approve_count FAIL [%d] %s", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); return -1; }
|
||||
return h_v;
|
||||
}
|
||||
13
app/src/au/dbio/au_summary_rate_dbio.h
Normal file
13
app/src/au/dbio/au_summary_rate_dbio.h
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* au_summary_rate_dbio.h - au 모듈 DB 접근 계층 copybook (au_summary_rate_dbio, part of libaudbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef AU_SUMMARY_RATE_DBIO_H
|
||||
#define AU_SUMMARY_RATE_DBIO_H
|
||||
|
||||
typedef struct { char biz_date[16]; long approve; long total; } au_summary_rate_rec_t;
|
||||
|
||||
long audb_summary_approval_rate(const char *bizdate);
|
||||
|
||||
#endif /* AU_SUMMARY_RATE_DBIO_H */
|
||||
23
app/src/au/dbio/au_summary_rate_dbio.pgc
Normal file
23
app/src/au/dbio/au_summary_rate_dbio.pgc
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* au_summary_rate_dbio.pgc - au 모듈 DB 접근 함수 세트 (au_summary_rate_dbio), archived into libaudbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* Shape: computed rate = approve*100/auth over an aggregated table (승인율).
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "au_summary_rate_dbio.h"
|
||||
|
||||
/* 당일 전체 승인율(%) = sum(approve_count)*100/sum(auth_count). */
|
||||
long audb_summary_approval_rate(const char *bizdate)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
long h_appr = 0, h_total = 0;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
EXEC SQL SELECT coalesce(sum(approve_count),0), coalesce(sum(auth_count),0)
|
||||
INTO :h_appr, :h_total FROM au_summary WHERE biz_date = :h_bizdate;
|
||||
if (sqlca.sqlcode < 0) return -1;
|
||||
if (h_total <= 0) return 0;
|
||||
return h_appr * 100 / h_total;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue