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
35
app/src/st/batch/st_adjust_batch.pgc
Normal file
35
app/src/st/batch/st_adjust_batch.pgc
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* st_adjust_batch.pgc - 정산 조정 집계 (XA 배치).
|
||||
* 당일 조정 delta 총합.
|
||||
* ATMI 클라이언트: tpinit/tpopen 으로 ECPG XA RM 를 열고 tpbegin 으로 ONE global tx
|
||||
* 를 시작, EXEC SQL 수행 후 tpcommit 이 XA 2PC 를 구동. 사용법: st_adjust_batch [YYYY-MM-DD]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <atmi.h>
|
||||
#include "st_dbio.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *bizdate = (argc > 1) ? argv[1] : "2026-07-19";
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
long h_delta;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
|
||||
if (tpinit(NULL) < 0) { fprintf(stderr, "tpinit FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
if (tpopen() < 0) { fprintf(stderr, "tpopen FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
if (tpbegin(60, 0) < 0) { fprintf(stderr, "tpbegin FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
|
||||
EXEC SQL SELECT coalesce(sum(delta),0) INTO :h_delta FROM st_adjust WHERE biz_date = :h_bizdate;
|
||||
if (sqlca.sqlcode < 0) { fprintf(stderr, "st_adjust_batch FAIL [%d] %s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); tpabort(0); return 1; }
|
||||
|
||||
if (tpcommit(0) < 0) { fprintf(stderr, "tpcommit FAIL: %s\n", tpstrerror(tperrno)); tpabort(0); return 1; }
|
||||
printf(">>> st_adjust_batch COMMIT: bizdate=%s delta=%ld\n", bizdate, h_delta);
|
||||
|
||||
tpclose(); tpterm();
|
||||
return 0;
|
||||
}
|
||||
34
app/src/st/batch/st_cancelpurge_batch.pgc
Normal file
34
app/src/st/batch/st_cancelpurge_batch.pgc
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* st_cancelpurge_batch.pgc - 취소 지급 정리 (XA 배치).
|
||||
* CANCELLED 지급 레코드를 삭제.
|
||||
* ATMI 클라이언트: tpinit/tpopen 으로 ECPG XA RM 를 열고 tpbegin 으로 ONE global tx
|
||||
* 를 시작, EXEC SQL 수행 후 tpcommit 이 XA 2PC 를 구동. 사용법: st_cancelpurge_batch [YYYY-MM-DD]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <atmi.h>
|
||||
#include "st_dbio.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *bizdate = (argc > 1) ? argv[1] : "2026-07-19";
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
|
||||
if (tpinit(NULL) < 0) { fprintf(stderr, "tpinit FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
if (tpopen() < 0) { fprintf(stderr, "tpopen FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
if (tpbegin(60, 0) < 0) { fprintf(stderr, "tpbegin FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
|
||||
EXEC SQL DELETE FROM st_payment WHERE status='CANCELLED' AND biz_date=:h_bizdate;
|
||||
if (sqlca.sqlcode < 0) { fprintf(stderr, "st_cancelpurge_batch FAIL [%d] %s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); tpabort(0); return 1; }
|
||||
|
||||
if (tpcommit(0) < 0) { fprintf(stderr, "tpcommit FAIL: %s\n", tpstrerror(tperrno)); tpabort(0); return 1; }
|
||||
printf(">>> st_cancelpurge_batch COMMIT: bizdate=%s purged rows=%d\n", bizdate, (int)sqlca.sqlerrd[2]);
|
||||
|
||||
tpclose(); tpterm();
|
||||
return 0;
|
||||
}
|
||||
34
app/src/st/batch/st_confirm_batch.pgc
Normal file
34
app/src/st/batch/st_confirm_batch.pgc
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* st_confirm_batch.pgc - 정산 일괄 확정 (XA 배치).
|
||||
* SETTLED 정산을 CONFIRMED 로 일괄 확정.
|
||||
* ATMI 클라이언트: tpinit/tpopen 으로 ECPG XA RM 를 열고 tpbegin 으로 ONE global tx
|
||||
* 를 시작, EXEC SQL 수행 후 tpcommit 이 XA 2PC 를 구동. 사용법: st_confirm_batch [YYYY-MM-DD]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <atmi.h>
|
||||
#include "st_dbio.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *bizdate = (argc > 1) ? argv[1] : "2026-07-19";
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
|
||||
if (tpinit(NULL) < 0) { fprintf(stderr, "tpinit FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
if (tpopen() < 0) { fprintf(stderr, "tpopen FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
if (tpbegin(60, 0) < 0) { fprintf(stderr, "tpbegin FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
|
||||
EXEC SQL UPDATE settlement SET status='CONFIRMED' WHERE status='SETTLED' AND biz_date=:h_bizdate;
|
||||
if (sqlca.sqlcode < 0) { fprintf(stderr, "st_confirm_batch FAIL [%d] %s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); tpabort(0); return 1; }
|
||||
|
||||
if (tpcommit(0) < 0) { fprintf(stderr, "tpcommit FAIL: %s\n", tpstrerror(tperrno)); tpabort(0); return 1; }
|
||||
printf(">>> st_confirm_batch COMMIT: bizdate=%s confirmed rows=%d\n", bizdate, (int)sqlca.sqlerrd[2]);
|
||||
|
||||
tpclose(); tpterm();
|
||||
return 0;
|
||||
}
|
||||
50
app/src/st/batch/st_delayint_batch.pgc
Normal file
50
app/src/st/batch/st_delayint_batch.pgc
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* st_delayint_batch.pgc - 지연이자 정산 배치 (XA 배치).
|
||||
* 미완결 지급을 커서로 순회하여 지연이자 정산 상세를 기록.
|
||||
* ATMI 클라이언트: tpinit/tpopen 으로 ECPG XA RM 를 열고 tpbegin 으로 ONE global tx
|
||||
* 를 시작, EXEC SQL 수행 후 tpcommit 이 XA 2PC 를 구동. 사용법: st_delayint_batch [YYYY-MM-DD]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <atmi.h>
|
||||
#include "st_dbio.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *bizdate = (argc > 1) ? argv[1] : "2026-07-19";
|
||||
long rows = 0;
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
long h_pid, h_net;
|
||||
char h_merch[64];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
|
||||
if (tpinit(NULL) < 0) { fprintf(stderr, "tpinit FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
if (tpopen() < 0) { fprintf(stderr, "tpopen FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
if (tpbegin(60, 0) < 0) { fprintf(stderr, "tpbegin FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
|
||||
EXEC SQL DECLARE st_delayint_batch_c CURSOR FOR
|
||||
SELECT purchase_id, merchant_id, net FROM settlement WHERE biz_date=:h_bizdate AND status='SETTLED';
|
||||
EXEC SQL OPEN st_delayint_batch_c;
|
||||
if (sqlca.sqlcode < 0) { fprintf(stderr, "OPEN FAIL [%d] %s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); tpabort(0); return 1; }
|
||||
for (;;) {
|
||||
EXEC SQL FETCH st_delayint_batch_c INTO :h_pid, :h_merch, :h_net;
|
||||
if (sqlca.sqlcode == 100) break;
|
||||
if (sqlca.sqlcode < 0) { fprintf(stderr, "FETCH FAIL [%d] %s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); EXEC SQL CLOSE st_delayint_batch_c; tpabort(0); return 1; }
|
||||
{
|
||||
long intr = h_net * 15 / 10000;
|
||||
if (stdb_insert_fee_dtl(0, h_pid, h_merch, "DELAYINT", intr, bizdate) < 0) { EXEC SQL CLOSE st_delayint_batch_c; tpabort(0); return 1; }
|
||||
rows++;
|
||||
}
|
||||
}
|
||||
EXEC SQL CLOSE st_delayint_batch_c;
|
||||
|
||||
if (tpcommit(0) < 0) { fprintf(stderr, "tpcommit FAIL: %s\n", tpstrerror(tperrno)); tpabort(0); return 1; }
|
||||
printf(">>> st_delayint_batch COMMIT: bizdate=%s delayint_rows=%ld\n", bizdate, rows);
|
||||
|
||||
tpclose(); tpterm();
|
||||
return 0;
|
||||
}
|
||||
35
app/src/st/batch/st_feepct_batch.pgc
Normal file
35
app/src/st/batch/st_feepct_batch.pgc
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* st_feepct_batch.pgc - 수수료율 집계 (XA 배치).
|
||||
* 매입 수수료/매입금액 비율(bps).
|
||||
* ATMI 클라이언트: tpinit/tpopen 으로 ECPG XA RM 를 열고 tpbegin 으로 ONE global tx
|
||||
* 를 시작, EXEC SQL 수행 후 tpcommit 이 XA 2PC 를 구동. 사용법: st_feepct_batch [YYYY-MM-DD]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <atmi.h>
|
||||
#include "st_dbio.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *bizdate = (argc > 1) ? argv[1] : "2026-07-19";
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
long h_fee, h_gross;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
|
||||
if (tpinit(NULL) < 0) { fprintf(stderr, "tpinit FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
if (tpopen() < 0) { fprintf(stderr, "tpopen FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
if (tpbegin(60, 0) < 0) { fprintf(stderr, "tpbegin FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
|
||||
EXEC SQL SELECT coalesce(sum(fee),0), coalesce(sum(amount),0) INTO :h_fee, :h_gross FROM purchase WHERE biz_date = :h_bizdate;
|
||||
if (sqlca.sqlcode < 0) { fprintf(stderr, "st_feepct_batch FAIL [%d] %s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); tpabort(0); return 1; }
|
||||
|
||||
if (tpcommit(0) < 0) { fprintf(stderr, "tpcommit FAIL: %s\n", tpstrerror(tperrno)); tpabort(0); return 1; }
|
||||
printf(">>> st_feepct_batch COMMIT: bizdate=%s fee=%ld gross=%ld\n", bizdate, h_fee, h_gross);
|
||||
|
||||
tpclose(); tpterm();
|
||||
return 0;
|
||||
}
|
||||
34
app/src/st/batch/st_hold_batch.pgc
Normal file
34
app/src/st/batch/st_hold_batch.pgc
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* st_hold_batch.pgc - 지급 일괄 보류 (XA 배치).
|
||||
* SCHEDULED 지급을 HELD 로 일괄 전환.
|
||||
* ATMI 클라이언트: tpinit/tpopen 으로 ECPG XA RM 를 열고 tpbegin 으로 ONE global tx
|
||||
* 를 시작, EXEC SQL 수행 후 tpcommit 이 XA 2PC 를 구동. 사용법: st_hold_batch [YYYY-MM-DD]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <atmi.h>
|
||||
#include "st_dbio.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *bizdate = (argc > 1) ? argv[1] : "2026-07-19";
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
|
||||
if (tpinit(NULL) < 0) { fprintf(stderr, "tpinit FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
if (tpopen() < 0) { fprintf(stderr, "tpopen FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
if (tpbegin(60, 0) < 0) { fprintf(stderr, "tpbegin FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
|
||||
EXEC SQL UPDATE st_payment SET status='HELD' WHERE status='SCHEDULED' AND biz_date=:h_bizdate;
|
||||
if (sqlca.sqlcode < 0) { fprintf(stderr, "st_hold_batch FAIL [%d] %s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); tpabort(0); return 1; }
|
||||
|
||||
if (tpcommit(0) < 0) { fprintf(stderr, "tpcommit FAIL: %s\n", tpstrerror(tperrno)); tpabort(0); return 1; }
|
||||
printf(">>> st_hold_batch COMMIT: bizdate=%s held rows=%d\n", bizdate, (int)sqlca.sqlerrd[2]);
|
||||
|
||||
tpclose(); tpterm();
|
||||
return 0;
|
||||
}
|
||||
35
app/src/st/batch/st_mdr_sum_batch.pgc
Normal file
35
app/src/st/batch/st_mdr_sum_batch.pgc
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* st_mdr_sum_batch.pgc - MDR 수수료 집계 (XA 배치).
|
||||
* MDR 수수료 상세 합계.
|
||||
* ATMI 클라이언트: tpinit/tpopen 으로 ECPG XA RM 를 열고 tpbegin 으로 ONE global tx
|
||||
* 를 시작, EXEC SQL 수행 후 tpcommit 이 XA 2PC 를 구동. 사용법: st_mdr_sum_batch [YYYY-MM-DD]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <atmi.h>
|
||||
#include "st_dbio.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *bizdate = (argc > 1) ? argv[1] : "2026-07-19";
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
long h_mdr;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
|
||||
if (tpinit(NULL) < 0) { fprintf(stderr, "tpinit FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
if (tpopen() < 0) { fprintf(stderr, "tpopen FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
if (tpbegin(60, 0) < 0) { fprintf(stderr, "tpbegin FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
|
||||
EXEC SQL SELECT coalesce(sum(amount) FILTER (WHERE fee_type='MDR'),0) INTO :h_mdr FROM st_settle_dtl WHERE biz_date = :h_bizdate;
|
||||
if (sqlca.sqlcode < 0) { fprintf(stderr, "st_mdr_sum_batch FAIL [%d] %s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); tpabort(0); return 1; }
|
||||
|
||||
if (tpcommit(0) < 0) { fprintf(stderr, "tpcommit FAIL: %s\n", tpstrerror(tperrno)); tpabort(0); return 1; }
|
||||
printf(">>> st_mdr_sum_batch COMMIT: bizdate=%s mdr=%ld\n", bizdate, h_mdr);
|
||||
|
||||
tpclose(); tpterm();
|
||||
return 0;
|
||||
}
|
||||
49
app/src/st/batch/st_merchroll_batch.pgc
Normal file
49
app/src/st/batch/st_merchroll_batch.pgc
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* st_merchroll_batch.pgc - 가맹점 정산 롤업 (XA 배치).
|
||||
* 가맹점별 매입/수수료/net 을 집계해 st_merch_settle 에 upsert.
|
||||
* ATMI 클라이언트: tpinit/tpopen 으로 ECPG XA RM 를 열고 tpbegin 으로 ONE global tx
|
||||
* 를 시작, EXEC SQL 수행 후 tpcommit 이 XA 2PC 를 구동. 사용법: st_merchroll_batch [YYYY-MM-DD]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <atmi.h>
|
||||
#include "st_dbio.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *bizdate = (argc > 1) ? argv[1] : "2026-07-19";
|
||||
long rows = 0;
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
long h_cnt, h_gross, h_fee, h_net;
|
||||
char h_merch[64];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
|
||||
if (tpinit(NULL) < 0) { fprintf(stderr, "tpinit FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
if (tpopen() < 0) { fprintf(stderr, "tpopen FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
if (tpbegin(60, 0) < 0) { fprintf(stderr, "tpbegin FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
|
||||
EXEC SQL DECLARE st_merchroll_batch_c CURSOR FOR
|
||||
SELECT s.merchant_id, count(*), coalesce(sum(p.amount),0), coalesce(sum(p.fee),0), coalesce(sum(s.net),0)
|
||||
FROM settlement s JOIN purchase p ON p.purchase_id=s.purchase_id
|
||||
WHERE s.biz_date=:h_bizdate GROUP BY s.merchant_id ORDER BY s.merchant_id;
|
||||
EXEC SQL OPEN st_merchroll_batch_c;
|
||||
if (sqlca.sqlcode < 0) { fprintf(stderr, "OPEN FAIL [%d] %s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); tpabort(0); return 1; }
|
||||
for (;;) {
|
||||
EXEC SQL FETCH st_merchroll_batch_c INTO :h_merch, :h_cnt, :h_gross, :h_fee, :h_net;
|
||||
if (sqlca.sqlcode == 100) break;
|
||||
if (sqlca.sqlcode < 0) { fprintf(stderr, "FETCH FAIL [%d] %s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); EXEC SQL CLOSE st_merchroll_batch_c; tpabort(0); return 1; }
|
||||
if (stdb_upsert_merch_settle(h_merch, bizdate, h_gross, h_fee, h_net, h_cnt) < 0) { EXEC SQL CLOSE st_merchroll_batch_c; tpabort(0); return 1; }
|
||||
rows++;
|
||||
}
|
||||
EXEC SQL CLOSE st_merchroll_batch_c;
|
||||
|
||||
if (tpcommit(0) < 0) { fprintf(stderr, "tpcommit FAIL: %s\n", tpstrerror(tperrno)); tpabort(0); return 1; }
|
||||
printf(">>> st_merchroll_batch COMMIT: bizdate=%s merchants=%ld\n", bizdate, rows);
|
||||
|
||||
tpclose(); tpterm();
|
||||
return 0;
|
||||
}
|
||||
36
app/src/st/batch/st_monthly_batch.pgc
Normal file
36
app/src/st/batch/st_monthly_batch.pgc
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* st_monthly_batch.pgc - 월별 정산 집계 (XA 배치).
|
||||
* 당월(YYYY-MM) 정산 net 합계.
|
||||
* ATMI 클라이언트: tpinit/tpopen 으로 ECPG XA RM 를 열고 tpbegin 으로 ONE global tx
|
||||
* 를 시작, EXEC SQL 수행 후 tpcommit 이 XA 2PC 를 구동. 사용법: st_monthly_batch [YYYY-MM-DD]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <atmi.h>
|
||||
#include "st_dbio.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *bizdate = (argc > 1) ? argv[1] : "2026-07-19";
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
long h_sum;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
|
||||
if (tpinit(NULL) < 0) { fprintf(stderr, "tpinit FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
if (tpopen() < 0) { fprintf(stderr, "tpopen FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
if (tpbegin(60, 0) < 0) { fprintf(stderr, "tpbegin FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
|
||||
EXEC SQL SELECT coalesce(sum(net),0) INTO :h_sum FROM settlement
|
||||
WHERE to_char(biz_date, 'YYYY-MM') = to_char(:h_bizdate::date, 'YYYY-MM');
|
||||
if (sqlca.sqlcode < 0) { fprintf(stderr, "st_monthly_batch FAIL [%d] %s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); tpabort(0); return 1; }
|
||||
|
||||
if (tpcommit(0) < 0) { fprintf(stderr, "tpcommit FAIL: %s\n", tpstrerror(tperrno)); tpabort(0); return 1; }
|
||||
printf(">>> st_monthly_batch COMMIT: bizdate=%s monthly_net=%ld\n", bizdate, h_sum);
|
||||
|
||||
tpclose(); tpterm();
|
||||
return 0;
|
||||
}
|
||||
35
app/src/st/batch/st_netting_batch.pgc
Normal file
35
app/src/st/batch/st_netting_batch.pgc
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* st_netting_batch.pgc - 정산 네팅 집계 (XA 배치).
|
||||
* 정산 건수/net/최대 정산 통계.
|
||||
* ATMI 클라이언트: tpinit/tpopen 으로 ECPG XA RM 를 열고 tpbegin 으로 ONE global tx
|
||||
* 를 시작, EXEC SQL 수행 후 tpcommit 이 XA 2PC 를 구동. 사용법: st_netting_batch [YYYY-MM-DD]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <atmi.h>
|
||||
#include "st_dbio.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *bizdate = (argc > 1) ? argv[1] : "2026-07-19";
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
long h_cnt, h_net, h_max;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
|
||||
if (tpinit(NULL) < 0) { fprintf(stderr, "tpinit FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
if (tpopen() < 0) { fprintf(stderr, "tpopen FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
if (tpbegin(60, 0) < 0) { fprintf(stderr, "tpbegin FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
|
||||
EXEC SQL SELECT count(*), coalesce(sum(net),0), coalesce(max(net),0) INTO :h_cnt, :h_net, :h_max FROM settlement WHERE biz_date = :h_bizdate;
|
||||
if (sqlca.sqlcode < 0) { fprintf(stderr, "st_netting_batch FAIL [%d] %s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); tpabort(0); return 1; }
|
||||
|
||||
if (tpcommit(0) < 0) { fprintf(stderr, "tpcommit FAIL: %s\n", tpstrerror(tperrno)); tpabort(0); return 1; }
|
||||
printf(">>> st_netting_batch COMMIT: bizdate=%s cnt=%ld net=%ld max=%ld\n", bizdate, h_cnt, h_net, h_max);
|
||||
|
||||
tpclose(); tpterm();
|
||||
return 0;
|
||||
}
|
||||
53
app/src/st/batch/st_offset_batch.pgc
Normal file
53
app/src/st/batch/st_offset_batch.pgc
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* st_offset_batch.pgc - 상계 정산 배치 (XA 배치).
|
||||
* 정산 net vs 매입 net 차이를 커서로 순회하여 상계 조정 기록.
|
||||
* ATMI 클라이언트: tpinit/tpopen 으로 ECPG XA RM 를 열고 tpbegin 으로 ONE global tx
|
||||
* 를 시작, EXEC SQL 수행 후 tpcommit 이 XA 2PC 를 구동. 사용법: st_offset_batch [YYYY-MM-DD]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <atmi.h>
|
||||
#include "st_dbio.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *bizdate = (argc > 1) ? argv[1] : "2026-07-19";
|
||||
long rows = 0;
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
long h_pid, h_snet, h_pnet;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
|
||||
if (tpinit(NULL) < 0) { fprintf(stderr, "tpinit FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
if (tpopen() < 0) { fprintf(stderr, "tpopen FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
if (tpbegin(60, 0) < 0) { fprintf(stderr, "tpbegin FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
|
||||
EXEC SQL DECLARE st_offset_batch_c CURSOR FOR
|
||||
SELECT s.purchase_id, coalesce(sum(s.net),0), coalesce(max(p.net),0)
|
||||
FROM settlement s JOIN purchase p ON p.purchase_id=s.purchase_id
|
||||
WHERE s.biz_date=:h_bizdate GROUP BY s.purchase_id;
|
||||
EXEC SQL OPEN st_offset_batch_c;
|
||||
if (sqlca.sqlcode < 0) { fprintf(stderr, "OPEN FAIL [%d] %s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); tpabort(0); return 1; }
|
||||
for (;;) {
|
||||
EXEC SQL FETCH st_offset_batch_c INTO :h_pid, :h_snet, :h_pnet;
|
||||
if (sqlca.sqlcode == 100) break;
|
||||
if (sqlca.sqlcode < 0) { fprintf(stderr, "FETCH FAIL [%d] %s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); EXEC SQL CLOSE st_offset_batch_c; tpabort(0); return 1; }
|
||||
{
|
||||
long d = h_pnet - h_snet;
|
||||
if (d != 0) {
|
||||
if (stdb_insert_adjust(0, h_pid, d, "OFFSET", bizdate) < 0) { EXEC SQL CLOSE st_offset_batch_c; tpabort(0); return 1; }
|
||||
rows++;
|
||||
}
|
||||
}
|
||||
}
|
||||
EXEC SQL CLOSE st_offset_batch_c;
|
||||
|
||||
if (tpcommit(0) < 0) { fprintf(stderr, "tpcommit FAIL: %s\n", tpstrerror(tperrno)); tpabort(0); return 1; }
|
||||
printf(">>> st_offset_batch COMMIT: bizdate=%s offsets=%ld\n", bizdate, rows);
|
||||
|
||||
tpclose(); tpterm();
|
||||
return 0;
|
||||
}
|
||||
47
app/src/st/batch/st_payment_batch.pgc
Normal file
47
app/src/st/batch/st_payment_batch.pgc
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* st_payment_batch.pgc - 가맹점 지급 생성 (XA 배치).
|
||||
* 가맹점별 정산 net 을 커서로 순회하여 지급(SCHEDULED) 레코드 생성.
|
||||
* ATMI 클라이언트: tpinit/tpopen 으로 ECPG XA RM 를 열고 tpbegin 으로 ONE global tx
|
||||
* 를 시작, EXEC SQL 수행 후 tpcommit 이 XA 2PC 를 구동. 사용법: st_payment_batch [YYYY-MM-DD]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <atmi.h>
|
||||
#include "st_dbio.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *bizdate = (argc > 1) ? argv[1] : "2026-07-19";
|
||||
long rows = 0;
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
long h_net;
|
||||
char h_merch[64];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
|
||||
if (tpinit(NULL) < 0) { fprintf(stderr, "tpinit FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
if (tpopen() < 0) { fprintf(stderr, "tpopen FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
if (tpbegin(60, 0) < 0) { fprintf(stderr, "tpbegin FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
|
||||
EXEC SQL DECLARE st_payment_batch_c CURSOR FOR
|
||||
SELECT merchant_id, coalesce(sum(net),0) FROM settlement WHERE biz_date=:h_bizdate GROUP BY merchant_id ORDER BY merchant_id;
|
||||
EXEC SQL OPEN st_payment_batch_c;
|
||||
if (sqlca.sqlcode < 0) { fprintf(stderr, "OPEN FAIL [%d] %s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); tpabort(0); return 1; }
|
||||
for (;;) {
|
||||
EXEC SQL FETCH st_payment_batch_c INTO :h_merch, :h_net;
|
||||
if (sqlca.sqlcode == 100) break;
|
||||
if (sqlca.sqlcode < 0) { fprintf(stderr, "FETCH FAIL [%d] %s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); EXEC SQL CLOSE st_payment_batch_c; tpabort(0); return 1; }
|
||||
if (stdb_insert_payment(h_merch, h_net, bizdate, "SCHEDULED", bizdate) < 0) { EXEC SQL CLOSE st_payment_batch_c; tpabort(0); return 1; }
|
||||
rows++;
|
||||
}
|
||||
EXEC SQL CLOSE st_payment_batch_c;
|
||||
|
||||
if (tpcommit(0) < 0) { fprintf(stderr, "tpcommit FAIL: %s\n", tpstrerror(tperrno)); tpabort(0); return 1; }
|
||||
printf(">>> st_payment_batch COMMIT: bizdate=%s payments=%ld\n", bizdate, rows);
|
||||
|
||||
tpclose(); tpterm();
|
||||
return 0;
|
||||
}
|
||||
34
app/src/st/batch/st_release_batch.pgc
Normal file
34
app/src/st/batch/st_release_batch.pgc
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* st_release_batch.pgc - 지급 보류 일괄 해제 (XA 배치).
|
||||
* HELD 지급을 SCHEDULED 로 일괄 복원.
|
||||
* ATMI 클라이언트: tpinit/tpopen 으로 ECPG XA RM 를 열고 tpbegin 으로 ONE global tx
|
||||
* 를 시작, EXEC SQL 수행 후 tpcommit 이 XA 2PC 를 구동. 사용법: st_release_batch [YYYY-MM-DD]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <atmi.h>
|
||||
#include "st_dbio.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *bizdate = (argc > 1) ? argv[1] : "2026-07-19";
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
|
||||
if (tpinit(NULL) < 0) { fprintf(stderr, "tpinit FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
if (tpopen() < 0) { fprintf(stderr, "tpopen FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
if (tpbegin(60, 0) < 0) { fprintf(stderr, "tpbegin FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
|
||||
EXEC SQL UPDATE st_payment SET status='SCHEDULED' WHERE status='HELD' AND biz_date=:h_bizdate;
|
||||
if (sqlca.sqlcode < 0) { fprintf(stderr, "st_release_batch FAIL [%d] %s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); tpabort(0); return 1; }
|
||||
|
||||
if (tpcommit(0) < 0) { fprintf(stderr, "tpcommit FAIL: %s\n", tpstrerror(tperrno)); tpabort(0); return 1; }
|
||||
printf(">>> st_release_batch COMMIT: bizdate=%s released rows=%d\n", bizdate, (int)sqlca.sqlerrd[2]);
|
||||
|
||||
tpclose(); tpterm();
|
||||
return 0;
|
||||
}
|
||||
35
app/src/st/batch/st_report_batch.pgc
Normal file
35
app/src/st/batch/st_report_batch.pgc
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* st_report_batch.pgc - 정산 리포트 집계 (XA 배치).
|
||||
* 당일 정산 건수/net 합계 리포트.
|
||||
* ATMI 클라이언트: tpinit/tpopen 으로 ECPG XA RM 를 열고 tpbegin 으로 ONE global tx
|
||||
* 를 시작, EXEC SQL 수행 후 tpcommit 이 XA 2PC 를 구동. 사용법: st_report_batch [YYYY-MM-DD]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <atmi.h>
|
||||
#include "st_dbio.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *bizdate = (argc > 1) ? argv[1] : "2026-07-19";
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
long h_cnt, h_net;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
|
||||
if (tpinit(NULL) < 0) { fprintf(stderr, "tpinit FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
if (tpopen() < 0) { fprintf(stderr, "tpopen FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
if (tpbegin(60, 0) < 0) { fprintf(stderr, "tpbegin FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
|
||||
EXEC SQL SELECT count(*), coalesce(sum(net),0) INTO :h_cnt, :h_net FROM settlement WHERE biz_date = :h_bizdate;
|
||||
if (sqlca.sqlcode < 0) { fprintf(stderr, "st_report_batch FAIL [%d] %s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); tpabort(0); return 1; }
|
||||
|
||||
if (tpcommit(0) < 0) { fprintf(stderr, "tpcommit FAIL: %s\n", tpstrerror(tperrno)); tpabort(0); return 1; }
|
||||
printf(">>> st_report_batch COMMIT: bizdate=%s settlements=%ld net=%ld\n", bizdate, h_cnt, h_net);
|
||||
|
||||
tpclose(); tpterm();
|
||||
return 0;
|
||||
}
|
||||
35
app/src/st/batch/st_vat_sum_batch.pgc
Normal file
35
app/src/st/batch/st_vat_sum_batch.pgc
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* st_vat_sum_batch.pgc - 부가세 집계 (XA 배치).
|
||||
* VAT 수수료 상세 합계.
|
||||
* ATMI 클라이언트: tpinit/tpopen 으로 ECPG XA RM 를 열고 tpbegin 으로 ONE global tx
|
||||
* 를 시작, EXEC SQL 수행 후 tpcommit 이 XA 2PC 를 구동. 사용법: st_vat_sum_batch [YYYY-MM-DD]
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <atmi.h>
|
||||
#include "st_dbio.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *bizdate = (argc > 1) ? argv[1] : "2026-07-19";
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
long h_vat;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
|
||||
if (tpinit(NULL) < 0) { fprintf(stderr, "tpinit FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
if (tpopen() < 0) { fprintf(stderr, "tpopen FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
if (tpbegin(60, 0) < 0) { fprintf(stderr, "tpbegin FAIL: %s\n", tpstrerror(tperrno)); return 1; }
|
||||
|
||||
EXEC SQL SELECT coalesce(sum(amount),0) INTO :h_vat FROM st_settle_dtl WHERE fee_type = 'VAT' AND biz_date = :h_bizdate;
|
||||
if (sqlca.sqlcode < 0) { fprintf(stderr, "st_vat_sum_batch FAIL [%d] %s\n", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); tpabort(0); return 1; }
|
||||
|
||||
if (tpcommit(0) < 0) { fprintf(stderr, "tpcommit FAIL: %s\n", tpstrerror(tperrno)); tpabort(0); return 1; }
|
||||
printf(">>> st_vat_sum_batch COMMIT: bizdate=%s vat=%ld\n", bizdate, h_vat);
|
||||
|
||||
tpclose(); tpterm();
|
||||
return 0;
|
||||
}
|
||||
13
app/src/st/dbio/st_adjdelta_dbio.h
Normal file
13
app/src/st/dbio/st_adjdelta_dbio.h
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* st_adjdelta_dbio.h - st 모듈 DB 접근 계층 copybook (st_adjdelta_dbio, part of libstdbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef ST_ADJDELTA_DBIO
|
||||
#define ST_ADJDELTA_DBIO
|
||||
|
||||
typedef struct { char biz_date[16]; long delta; } st_adjdelta_rec_t;
|
||||
|
||||
long stdb_adjust_delta_total(const char *bizdate);
|
||||
|
||||
#endif /* ST_ADJDELTA_DBIO */
|
||||
20
app/src/st/dbio/st_adjdelta_dbio.pgc
Normal file
20
app/src/st/dbio/st_adjdelta_dbio.pgc
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* st_adjdelta_dbio.pgc - st 모듈 DB 접근 함수 세트 (st_adjdelta_dbio), archived into libstdbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* 당일 조정 증감(delta) 총합 - 음수 포함.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "st_adjdelta_dbio.h"
|
||||
|
||||
long stdb_adjust_delta_total(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(delta),0) INTO :h_v FROM st_adjust WHERE biz_date = :h_bizdate;
|
||||
if (sqlca.sqlcode < 0) { userlog("stdb_adjust_delta_total FAIL [%d] %s", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); return -1; }
|
||||
return h_v;
|
||||
}
|
||||
13
app/src/st/dbio/st_confirmall_dbio.h
Normal file
13
app/src/st/dbio/st_confirmall_dbio.h
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* st_confirmall_dbio.h - st 모듈 DB 접근 계층 copybook (st_confirmall_dbio, part of libstdbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef ST_CONFIRMALL_DBIO
|
||||
#define ST_CONFIRMALL_DBIO
|
||||
|
||||
typedef struct { char biz_date[16]; long affected; } st_confirmall_rec_t;
|
||||
|
||||
long stdb_confirm_all(const char *bizdate);
|
||||
|
||||
#endif /* ST_CONFIRMALL_DBIO */
|
||||
20
app/src/st/dbio/st_confirmall_dbio.pgc
Normal file
20
app/src/st/dbio/st_confirmall_dbio.pgc
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* st_confirmall_dbio.pgc - st 모듈 DB 접근 함수 세트 (st_confirmall_dbio), archived into libstdbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* 당일 정산 일괄 확정 - UPDATE 후 영향 행수 반환.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "st_confirmall_dbio.h"
|
||||
|
||||
long stdb_confirm_all(const char *bizdate)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
EXEC SQL UPDATE settlement SET status = 'CONFIRMED'
|
||||
WHERE biz_date = :h_bizdate AND status = 'SETTLED';
|
||||
if (sqlca.sqlcode < 0) { userlog("stdb_confirm_all FAIL [%d] %s", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); return -1; }
|
||||
return (long)sqlca.sqlerrd[2];
|
||||
}
|
||||
13
app/src/st/dbio/st_confirmratio_dbio.h
Normal file
13
app/src/st/dbio/st_confirmratio_dbio.h
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* st_confirmratio_dbio.h - st 모듈 DB 접근 계층 copybook (st_confirmratio_dbio, part of libstdbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef ST_CONFIRMRATIO_DBIO
|
||||
#define ST_CONFIRMRATIO_DBIO
|
||||
|
||||
typedef struct { char biz_date[16]; long pct; } st_confirmratio_rec_t;
|
||||
|
||||
long stdb_confirm_pct(const char *bizdate);
|
||||
|
||||
#endif /* ST_CONFIRMRATIO_DBIO */
|
||||
22
app/src/st/dbio/st_confirmratio_dbio.pgc
Normal file
22
app/src/st/dbio/st_confirmratio_dbio.pgc
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* st_confirmratio_dbio.pgc - st 모듈 DB 접근 함수 세트 (st_confirmratio_dbio), archived into libstdbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* 확정율(%) - CASE 로 SETTLED+CONFIRMED 분모 방지.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "st_confirmratio_dbio.h"
|
||||
|
||||
long stdb_confirm_pct(const char *bizdate)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
long h_conf = 0, h_all = 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(*) FILTER (WHERE status = 'CONFIRMED'), count(*)
|
||||
INTO :h_conf, :h_all FROM settlement WHERE biz_date = :h_bizdate;
|
||||
if (sqlca.sqlcode < 0) { userlog("stdb_confirm_pct FAIL [%d] %s", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); return -1; }
|
||||
return h_all > 0 ? (h_conf * 100 / h_all) : 0;
|
||||
}
|
||||
13
app/src/st/dbio/st_derived_dbio.h
Normal file
13
app/src/st/dbio/st_derived_dbio.h
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* st_derived_dbio.h - st 모듈 DB 접근 계층 copybook (st_derived_dbio, part of libstdbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef ST_DERIVED_DBIO
|
||||
#define ST_DERIVED_DBIO
|
||||
|
||||
typedef struct { char biz_date[16]; long top_merch_net; } st_derived_rec_t;
|
||||
|
||||
long stdb_max_merchant_net(const char *bizdate);
|
||||
|
||||
#endif /* ST_DERIVED_DBIO */
|
||||
22
app/src/st/dbio/st_derived_dbio.pgc
Normal file
22
app/src/st/dbio/st_derived_dbio.pgc
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* st_derived_dbio.pgc - st 모듈 DB 접근 함수 세트 (st_derived_dbio), archived into libstdbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* 파생 테이블(FROM 서브쿼리) - 가맹점별 net 합의 최대값.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "st_derived_dbio.h"
|
||||
|
||||
long stdb_max_merchant_net(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(max(mnet),0) INTO :h_v FROM (
|
||||
SELECT merchant_id, coalesce(sum(net),0) AS mnet FROM settlement
|
||||
WHERE biz_date = :h_bizdate GROUP BY merchant_id) t;
|
||||
if (sqlca.sqlcode < 0) { userlog("stdb_max_merchant_net FAIL [%d] %s", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); return -1; }
|
||||
return h_v;
|
||||
}
|
||||
13
app/src/st/dbio/st_distinctmerch_dbio.h
Normal file
13
app/src/st/dbio/st_distinctmerch_dbio.h
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* st_distinctmerch_dbio.h - st 모듈 DB 접근 계층 copybook (st_distinctmerch_dbio, part of libstdbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef ST_DISTINCTMERCH_DBIO
|
||||
#define ST_DISTINCTMERCH_DBIO
|
||||
|
||||
typedef struct { char biz_date[16]; long uniq; } st_distinctmerch_rec_t;
|
||||
|
||||
long stdb_distinct_merchants(const char *bizdate);
|
||||
|
||||
#endif /* ST_DISTINCTMERCH_DBIO */
|
||||
20
app/src/st/dbio/st_distinctmerch_dbio.pgc
Normal file
20
app/src/st/dbio/st_distinctmerch_dbio.pgc
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* st_distinctmerch_dbio.pgc - st 모듈 DB 접근 함수 세트 (st_distinctmerch_dbio), archived into libstdbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* 정산 대상 고유 가맹점 수 - count(distinct).
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "st_distinctmerch_dbio.h"
|
||||
|
||||
long stdb_distinct_merchants(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 merchant_id) INTO :h_v FROM settlement WHERE biz_date = :h_bizdate;
|
||||
if (sqlca.sqlcode < 0) return -1;
|
||||
return h_v;
|
||||
}
|
||||
13
app/src/st/dbio/st_dtlfeesum_dbio.h
Normal file
13
app/src/st/dbio/st_dtlfeesum_dbio.h
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* st_dtlfeesum_dbio.h - st 모듈 DB 접근 계층 copybook (st_dtlfeesum_dbio, part of libstdbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef ST_DTLFEESUM_DBIO
|
||||
#define ST_DTLFEESUM_DBIO
|
||||
|
||||
typedef struct { char biz_date[16]; char fee_type[16]; long amount; } st_dtlfeesum_rec_t;
|
||||
|
||||
long stdb_dtl_fee_sum(const char *bizdate, const char *fee_type);
|
||||
|
||||
#endif /* ST_DTLFEESUM_DBIO */
|
||||
22
app/src/st/dbio/st_dtlfeesum_dbio.pgc
Normal file
22
app/src/st/dbio/st_dtlfeesum_dbio.pgc
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* st_dtlfeesum_dbio.pgc - st 모듈 DB 접근 함수 세트 (st_dtlfeesum_dbio), archived into libstdbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* 수수료 종류별 정산 상세 금액 합계.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "st_dtlfeesum_dbio.h"
|
||||
|
||||
long stdb_dtl_fee_sum(const char *bizdate, const char *fee_type)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16], h_type[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;
|
||||
strncpy(h_type, fee_type, sizeof(h_type)-1); h_type[sizeof(h_type)-1] = 0;
|
||||
EXEC SQL SELECT coalesce(sum(amount),0) INTO :h_v FROM st_settle_dtl
|
||||
WHERE biz_date = :h_bizdate AND fee_type = :h_type;
|
||||
if (sqlca.sqlcode < 0) { userlog("stdb_dtl_fee_sum FAIL [%d] %s", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); return -1; }
|
||||
return h_v;
|
||||
}
|
||||
13
app/src/st/dbio/st_dtlgroup_dbio.h
Normal file
13
app/src/st/dbio/st_dtlgroup_dbio.h
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* st_dtlgroup_dbio.h - st 모듈 DB 접근 계층 copybook (st_dtlgroup_dbio, part of libstdbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef ST_DTLGROUP_DBIO
|
||||
#define ST_DTLGROUP_DBIO
|
||||
|
||||
typedef struct { char fee_type[16]; long amount; } st_dtlgroup_rec_t;
|
||||
|
||||
long stdb_dtl_fee_kinds(const char *bizdate);
|
||||
|
||||
#endif /* ST_DTLGROUP_DBIO */
|
||||
30
app/src/st/dbio/st_dtlgroup_dbio.pgc
Normal file
30
app/src/st/dbio/st_dtlgroup_dbio.pgc
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* st_dtlgroup_dbio.pgc - st 모듈 DB 접근 함수 세트 (st_dtlgroup_dbio), archived into libstdbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* 수수료 종류별 GROUP BY 커서 - 종류 수 반환.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "st_dtlgroup_dbio.h"
|
||||
|
||||
long stdb_dtl_fee_kinds(const char *bizdate)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16], h_type[16];
|
||||
long h_sum, kinds = 0;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
EXEC SQL DECLARE dgc CURSOR FOR
|
||||
SELECT fee_type, coalesce(sum(amount),0) FROM st_settle_dtl
|
||||
WHERE biz_date = :h_bizdate GROUP BY fee_type ORDER BY fee_type;
|
||||
EXEC SQL OPEN dgc;
|
||||
if (sqlca.sqlcode < 0) return -1;
|
||||
for (;;) {
|
||||
EXEC SQL FETCH dgc INTO :h_type, :h_sum;
|
||||
if (sqlca.sqlcode == 100) break;
|
||||
if (sqlca.sqlcode < 0) { EXEC SQL CLOSE dgc; return -1; }
|
||||
kinds++;
|
||||
}
|
||||
EXEC SQL CLOSE dgc;
|
||||
return kinds;
|
||||
}
|
||||
13
app/src/st/dbio/st_existsadj_dbio.h
Normal file
13
app/src/st/dbio/st_existsadj_dbio.h
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* st_existsadj_dbio.h - st 모듈 DB 접근 계층 copybook (st_existsadj_dbio, part of libstdbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef ST_EXISTSADJ_DBIO
|
||||
#define ST_EXISTSADJ_DBIO
|
||||
|
||||
typedef struct { long purchase_id; int has_adj; } st_existsadj_rec_t;
|
||||
|
||||
int stdb_has_adjust(long pid);
|
||||
|
||||
#endif /* ST_EXISTSADJ_DBIO */
|
||||
20
app/src/st/dbio/st_existsadj_dbio.pgc
Normal file
20
app/src/st/dbio/st_existsadj_dbio.pgc
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* st_existsadj_dbio.pgc - st 모듈 DB 접근 함수 세트 (st_existsadj_dbio), archived into libstdbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* 매입에 정산 조정 존재 여부 - EXISTS boolean.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "st_existsadj_dbio.h"
|
||||
|
||||
int stdb_has_adjust(long pid)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long h_pid = pid;
|
||||
int h_v = 0;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
EXEC SQL SELECT CASE WHEN EXISTS
|
||||
(SELECT 1 FROM st_adjust WHERE purchase_id = :h_pid) THEN 1 ELSE 0 END INTO :h_v;
|
||||
if (sqlca.sqlcode < 0) return -1;
|
||||
return h_v;
|
||||
}
|
||||
13
app/src/st/dbio/st_feefilter_dbio.h
Normal file
13
app/src/st/dbio/st_feefilter_dbio.h
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* st_feefilter_dbio.h - st 모듈 DB 접근 계층 copybook (st_feefilter_dbio, part of libstdbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef ST_FEEFILTER_DBIO
|
||||
#define ST_FEEFILTER_DBIO
|
||||
|
||||
typedef struct { char biz_date[16]; long mdr; long van; } st_feefilter_rec_t;
|
||||
|
||||
long stdb_fee_mdr_filter(const char *bizdate);
|
||||
|
||||
#endif /* ST_FEEFILTER_DBIO */
|
||||
24
app/src/st/dbio/st_feefilter_dbio.pgc
Normal file
24
app/src/st/dbio/st_feefilter_dbio.pgc
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* st_feefilter_dbio.pgc - st 모듈 DB 접근 함수 세트 (st_feefilter_dbio), archived into libstdbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* MDR/VAN FILTER 분리 집계 - MDR 합 반환.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "st_feefilter_dbio.h"
|
||||
|
||||
long stdb_fee_mdr_filter(const char *bizdate)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
long h_mdr = 0, h_van = 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 fee_type = 'MDR'), 0),
|
||||
coalesce(sum(amount) FILTER (WHERE fee_type = 'VAN'), 0)
|
||||
INTO :h_mdr, :h_van FROM st_settle_dtl WHERE biz_date = :h_bizdate;
|
||||
if (sqlca.sqlcode < 0) return -1;
|
||||
userlog("stdb_fee_mdr_filter van=%ld", h_van);
|
||||
return h_mdr;
|
||||
}
|
||||
13
app/src/st/dbio/st_feepct_dbio.h
Normal file
13
app/src/st/dbio/st_feepct_dbio.h
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* st_feepct_dbio.h - st 모듈 DB 접근 계층 copybook (st_feepct_dbio, part of libstdbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef ST_FEEPCT_DBIO
|
||||
#define ST_FEEPCT_DBIO
|
||||
|
||||
typedef struct { char biz_date[16]; long pct; } st_feepct_rec_t;
|
||||
|
||||
long stdb_fee_pct_of_gross(const char *bizdate);
|
||||
|
||||
#endif /* ST_FEEPCT_DBIO */
|
||||
23
app/src/st/dbio/st_feepct_dbio.pgc
Normal file
23
app/src/st/dbio/st_feepct_dbio.pgc
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* st_feepct_dbio.pgc - st 모듈 DB 접근 함수 세트 (st_feepct_dbio), archived into libstdbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* 수수료율(%) = 수수료합/매입금액합 - 두 서브쿼리 비율.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "st_feepct_dbio.h"
|
||||
|
||||
long stdb_fee_pct_of_gross(const char *bizdate)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
long h_fee = 0, h_gross = 0;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
EXEC SQL SELECT
|
||||
(SELECT coalesce(sum(fee),0) FROM purchase WHERE biz_date = :h_bizdate),
|
||||
(SELECT coalesce(sum(amount),0) FROM purchase WHERE biz_date = :h_bizdate)
|
||||
INTO :h_fee, :h_gross;
|
||||
if (sqlca.sqlcode < 0) { userlog("stdb_fee_pct_of_gross FAIL [%d] %s", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); return -1; }
|
||||
return h_gross > 0 ? (h_fee * 10000 / h_gross) : 0;
|
||||
}
|
||||
13
app/src/st/dbio/st_heldcursor_dbio.h
Normal file
13
app/src/st/dbio/st_heldcursor_dbio.h
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* st_heldcursor_dbio.h - st 모듈 DB 접근 계층 copybook (st_heldcursor_dbio, part of libstdbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef ST_HELDCURSOR_DBIO
|
||||
#define ST_HELDCURSOR_DBIO
|
||||
|
||||
typedef struct { char biz_date[16]; long held; } st_heldcursor_rec_t;
|
||||
|
||||
long stdb_held_payment_accum(const char *bizdate);
|
||||
|
||||
#endif /* ST_HELDCURSOR_DBIO */
|
||||
29
app/src/st/dbio/st_heldcursor_dbio.pgc
Normal file
29
app/src/st/dbio/st_heldcursor_dbio.pgc
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* st_heldcursor_dbio.pgc - st 모듈 DB 접근 함수 세트 (st_heldcursor_dbio), archived into libstdbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* 보류(HELD) 지급액 커서 누적 합계.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "st_heldcursor_dbio.h"
|
||||
|
||||
long stdb_held_payment_accum(const char *bizdate)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
long h_amt, 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 hpc CURSOR FOR
|
||||
SELECT net_amount FROM st_payment WHERE biz_date = :h_bizdate AND status = 'HELD';
|
||||
EXEC SQL OPEN hpc;
|
||||
if (sqlca.sqlcode < 0) return -1;
|
||||
for (;;) {
|
||||
EXEC SQL FETCH hpc INTO :h_amt;
|
||||
if (sqlca.sqlcode == 100) break;
|
||||
if (sqlca.sqlcode < 0) { EXEC SQL CLOSE hpc; return -1; }
|
||||
total += h_amt;
|
||||
}
|
||||
EXEC SQL CLOSE hpc;
|
||||
return total;
|
||||
}
|
||||
13
app/src/st/dbio/st_joingross_dbio.h
Normal file
13
app/src/st/dbio/st_joingross_dbio.h
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* st_joingross_dbio.h - st 모듈 DB 접근 계층 copybook (st_joingross_dbio, part of libstdbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef ST_JOINGROSS_DBIO
|
||||
#define ST_JOINGROSS_DBIO
|
||||
|
||||
typedef struct { char biz_date[16]; long gross; } st_joingross_rec_t;
|
||||
|
||||
long stdb_settle_gross_join(const char *bizdate);
|
||||
|
||||
#endif /* ST_JOINGROSS_DBIO */
|
||||
22
app/src/st/dbio/st_joingross_dbio.pgc
Normal file
22
app/src/st/dbio/st_joingross_dbio.pgc
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* st_joingross_dbio.pgc - st 모듈 DB 접근 함수 세트 (st_joingross_dbio), archived into libstdbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* 정산-매입 JOIN 총 매입금액(gross) 합계.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "st_joingross_dbio.h"
|
||||
|
||||
long stdb_settle_gross_join(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(p.amount),0) INTO :h_v
|
||||
FROM settlement s JOIN purchase p ON p.purchase_id = s.purchase_id
|
||||
WHERE s.biz_date = :h_bizdate;
|
||||
if (sqlca.sqlcode < 0) { userlog("stdb_settle_gross_join FAIL [%d] %s", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); return -1; }
|
||||
return h_v;
|
||||
}
|
||||
13
app/src/st/dbio/st_laststatus_dbio.h
Normal file
13
app/src/st/dbio/st_laststatus_dbio.h
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* st_laststatus_dbio.h - st 모듈 DB 접근 계층 copybook (st_laststatus_dbio, part of libstdbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef ST_LASTSTATUS_DBIO
|
||||
#define ST_LASTSTATUS_DBIO
|
||||
|
||||
typedef struct { long purchase_id; char status[16]; } st_laststatus_rec_t;
|
||||
|
||||
int stdb_last_status(long pid, char *out);
|
||||
|
||||
#endif /* ST_LASTSTATUS_DBIO */
|
||||
22
app/src/st/dbio/st_laststatus_dbio.pgc
Normal file
22
app/src/st/dbio/st_laststatus_dbio.pgc
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* st_laststatus_dbio.pgc - st 모듈 DB 접근 함수 세트 (st_laststatus_dbio), archived into libstdbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* 최근 정산 상태 1건 - ORDER BY LIMIT single fetch (문자열 out).
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "st_laststatus_dbio.h"
|
||||
|
||||
int stdb_last_status(long pid, char *out)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long h_pid = pid;
|
||||
char h_status[16];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
EXEC SQL SELECT status INTO :h_status FROM settlement
|
||||
WHERE purchase_id = :h_pid ORDER BY settlement_id DESC LIMIT 1;
|
||||
if (sqlca.sqlcode == 100) { strcpy(out, "NONE"); return 0; }
|
||||
if (sqlca.sqlcode < 0) { userlog("stdb_last_status FAIL [%d] %s", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); return -1; }
|
||||
strncpy(out, h_status, 15); out[15] = 0;
|
||||
return 0;
|
||||
}
|
||||
13
app/src/st/dbio/st_merchhaving_dbio.h
Normal file
13
app/src/st/dbio/st_merchhaving_dbio.h
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* st_merchhaving_dbio.h - st 모듈 DB 접근 계층 copybook (st_merchhaving_dbio, part of libstdbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef ST_MERCHHAVING_DBIO
|
||||
#define ST_MERCHHAVING_DBIO
|
||||
|
||||
typedef struct { char merchant_id[64]; long net; } st_merchhaving_rec_t;
|
||||
|
||||
long stdb_big_merchants(const char *bizdate, long threshold);
|
||||
|
||||
#endif /* ST_MERCHHAVING_DBIO */
|
||||
30
app/src/st/dbio/st_merchhaving_dbio.pgc
Normal file
30
app/src/st/dbio/st_merchhaving_dbio.pgc
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* st_merchhaving_dbio.pgc - st 모듈 DB 접근 함수 세트 (st_merchhaving_dbio), archived into libstdbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* HAVING 커서 - 임계 net 이상 가맹점 수.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "st_merchhaving_dbio.h"
|
||||
|
||||
long stdb_big_merchants(const char *bizdate, long threshold)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16], h_merch[64];
|
||||
long h_thr = threshold, h_net, cnt = 0;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
EXEC SQL DECLARE mhc CURSOR FOR
|
||||
SELECT merchant_id, coalesce(sum(net),0) FROM settlement
|
||||
WHERE biz_date = :h_bizdate GROUP BY merchant_id HAVING coalesce(sum(net),0) >= :h_thr;
|
||||
EXEC SQL OPEN mhc;
|
||||
if (sqlca.sqlcode < 0) return -1;
|
||||
for (;;) {
|
||||
EXEC SQL FETCH mhc INTO :h_merch, :h_net;
|
||||
if (sqlca.sqlcode == 100) break;
|
||||
if (sqlca.sqlcode < 0) { EXEC SQL CLOSE mhc; return -1; }
|
||||
cnt++;
|
||||
}
|
||||
EXEC SQL CLOSE mhc;
|
||||
return cnt;
|
||||
}
|
||||
13
app/src/st/dbio/st_minband_dbio.h
Normal file
13
app/src/st/dbio/st_minband_dbio.h
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* st_minband_dbio.h - st 모듈 DB 접근 계층 copybook (st_minband_dbio, part of libstdbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef ST_MINBAND_DBIO
|
||||
#define ST_MINBAND_DBIO
|
||||
|
||||
typedef struct { char fee_type[16]; long min_bps; } st_minband_rec_t;
|
||||
|
||||
long stdb_min_band_rate(const char *fee_type);
|
||||
|
||||
#endif /* ST_MINBAND_DBIO */
|
||||
20
app/src/st/dbio/st_minband_dbio.pgc
Normal file
20
app/src/st/dbio/st_minband_dbio.pgc
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* st_minband_dbio.pgc - st 모듈 DB 접근 함수 세트 (st_minband_dbio), archived into libstdbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* 수수료 유형의 최저 구간 요율(bps) - min() 스칼라.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "st_minband_dbio.h"
|
||||
|
||||
long stdb_min_band_rate(const char *fee_type)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_type[16];
|
||||
long h_v = 0;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_type, fee_type, sizeof(h_type)-1); h_type[sizeof(h_type)-1] = 0;
|
||||
EXEC SQL SELECT coalesce(min(rate_bps),0) INTO :h_v FROM st_fee_rate WHERE fee_type = :h_type;
|
||||
if (sqlca.sqlcode < 0) { userlog("stdb_min_band_rate FAIL [%d] %s", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); return -1; }
|
||||
return h_v;
|
||||
}
|
||||
13
app/src/st/dbio/st_netavg_dbio.h
Normal file
13
app/src/st/dbio/st_netavg_dbio.h
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* st_netavg_dbio.h - st 모듈 DB 접근 계층 copybook (st_netavg_dbio, part of libstdbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef ST_NETAVG_DBIO
|
||||
#define ST_NETAVG_DBIO
|
||||
|
||||
typedef struct { char biz_date[16]; long avg_net; } st_netavg_rec_t;
|
||||
|
||||
long stdb_settle_avg_net(const char *bizdate);
|
||||
|
||||
#endif /* ST_NETAVG_DBIO */
|
||||
20
app/src/st/dbio/st_netavg_dbio.pgc
Normal file
20
app/src/st/dbio/st_netavg_dbio.pgc
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* st_netavg_dbio.pgc - st 모듈 DB 접근 함수 세트 (st_netavg_dbio), archived into libstdbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* 정산 net 평균 - avg() 반올림.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "st_netavg_dbio.h"
|
||||
|
||||
long stdb_settle_avg_net(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(round(avg(net)),0) INTO :h_v FROM settlement WHERE biz_date = :h_bizdate;
|
||||
if (sqlca.sqlcode < 0) return -1;
|
||||
return h_v;
|
||||
}
|
||||
13
app/src/st/dbio/st_netmax_dbio.h
Normal file
13
app/src/st/dbio/st_netmax_dbio.h
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* st_netmax_dbio.h - st 모듈 DB 접근 계층 copybook (st_netmax_dbio, part of libstdbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef ST_NETMAX_DBIO
|
||||
#define ST_NETMAX_DBIO
|
||||
|
||||
typedef struct { char biz_date[16]; long max_net; } st_netmax_rec_t;
|
||||
|
||||
long stdb_settle_max_net(const char *bizdate);
|
||||
|
||||
#endif /* ST_NETMAX_DBIO */
|
||||
20
app/src/st/dbio/st_netmax_dbio.pgc
Normal file
20
app/src/st/dbio/st_netmax_dbio.pgc
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* st_netmax_dbio.pgc - st 모듈 DB 접근 함수 세트 (st_netmax_dbio), archived into libstdbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* 당일 최대 정산 net - max() 스칼라.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "st_netmax_dbio.h"
|
||||
|
||||
long stdb_settle_max_net(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(max(net),0) INTO :h_v FROM settlement WHERE biz_date = :h_bizdate;
|
||||
if (sqlca.sqlcode < 0) return -1;
|
||||
return h_v;
|
||||
}
|
||||
13
app/src/st/dbio/st_netsum_dbio.h
Normal file
13
app/src/st/dbio/st_netsum_dbio.h
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* st_netsum_dbio.h - st 모듈 DB 접근 계층 copybook (st_netsum_dbio, part of libstdbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef ST_NETSUM_DBIO
|
||||
#define ST_NETSUM_DBIO
|
||||
|
||||
typedef struct { char biz_date[16]; long net; } st_netsum_rec_t;
|
||||
|
||||
long stdb_settle_net_sum(const char *bizdate);
|
||||
|
||||
#endif /* ST_NETSUM_DBIO */
|
||||
20
app/src/st/dbio/st_netsum_dbio.pgc
Normal file
20
app/src/st/dbio/st_netsum_dbio.pgc
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* st_netsum_dbio.pgc - st 모듈 DB 접근 함수 세트 (st_netsum_dbio), archived into libstdbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* 당일 정산 net 단순 합계.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "st_netsum_dbio.h"
|
||||
|
||||
long stdb_settle_net_sum(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(net),0) INTO :h_v FROM settlement WHERE biz_date = :h_bizdate;
|
||||
if (sqlca.sqlcode < 0) { userlog("stdb_settle_net_sum FAIL [%d] %s", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); return -1; }
|
||||
return h_v;
|
||||
}
|
||||
13
app/src/st/dbio/st_nopay_dbio.h
Normal file
13
app/src/st/dbio/st_nopay_dbio.h
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* st_nopay_dbio.h - st 모듈 DB 접근 계층 copybook (st_nopay_dbio, part of libstdbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef ST_NOPAY_DBIO
|
||||
#define ST_NOPAY_DBIO
|
||||
|
||||
typedef struct { char biz_date[16]; long cnt; } st_nopay_rec_t;
|
||||
|
||||
long stdb_settle_no_payment(const char *bizdate);
|
||||
|
||||
#endif /* ST_NOPAY_DBIO */
|
||||
22
app/src/st/dbio/st_nopay_dbio.pgc
Normal file
22
app/src/st/dbio/st_nopay_dbio.pgc
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* st_nopay_dbio.pgc - st 모듈 DB 접근 함수 세트 (st_nopay_dbio), archived into libstdbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* 지급 레코드가 없는 정산 건수 - NOT EXISTS 서브쿼리.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "st_nopay_dbio.h"
|
||||
|
||||
long stdb_settle_no_payment(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 settlement s
|
||||
WHERE s.biz_date = :h_bizdate
|
||||
AND NOT EXISTS (SELECT 1 FROM st_payment p WHERE p.merchant_id = s.merchant_id AND p.biz_date = s.biz_date);
|
||||
if (sqlca.sqlcode < 0) { userlog("stdb_settle_no_payment FAIL [%d] %s", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); return -1; }
|
||||
return h_v;
|
||||
}
|
||||
13
app/src/st/dbio/st_payinstatus_dbio.h
Normal file
13
app/src/st/dbio/st_payinstatus_dbio.h
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* st_payinstatus_dbio.h - st 모듈 DB 접근 계층 copybook (st_payinstatus_dbio, part of libstdbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef ST_PAYINSTATUS_DBIO
|
||||
#define ST_PAYINSTATUS_DBIO
|
||||
|
||||
typedef struct { char biz_date[16]; long pending; } st_payinstatus_rec_t;
|
||||
|
||||
long stdb_payment_pending_count(const char *bizdate);
|
||||
|
||||
#endif /* ST_PAYINSTATUS_DBIO */
|
||||
21
app/src/st/dbio/st_payinstatus_dbio.pgc
Normal file
21
app/src/st/dbio/st_payinstatus_dbio.pgc
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* st_payinstatus_dbio.pgc - st 모듈 DB 접근 함수 세트 (st_payinstatus_dbio), archived into libstdbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* 미완결 지급 상태 집합(SCHEDULED/HELD) IN 필터 건수.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "st_payinstatus_dbio.h"
|
||||
|
||||
long stdb_payment_pending_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 st_payment
|
||||
WHERE biz_date = :h_bizdate AND status IN ('SCHEDULED', 'HELD');
|
||||
if (sqlca.sqlcode < 0) return -1;
|
||||
return h_v;
|
||||
}
|
||||
13
app/src/st/dbio/st_payrank_dbio.h
Normal file
13
app/src/st/dbio/st_payrank_dbio.h
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* st_payrank_dbio.h - st 모듈 DB 접근 계층 copybook (st_payrank_dbio, part of libstdbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef ST_PAYRANK_DBIO
|
||||
#define ST_PAYRANK_DBIO
|
||||
|
||||
typedef struct { long pay_id; long rnk; long net; } st_payrank_rec_t;
|
||||
|
||||
long stdb_top_payment_sum(const char *bizdate, long topn);
|
||||
|
||||
#endif /* ST_PAYRANK_DBIO */
|
||||
30
app/src/st/dbio/st_payrank_dbio.pgc
Normal file
30
app/src/st/dbio/st_payrank_dbio.pgc
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* st_payrank_dbio.pgc - st 모듈 DB 접근 함수 세트 (st_payrank_dbio), archived into libstdbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* 윈도우(rank) 커서 - 상위 N 지급 net 합계.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "st_payrank_dbio.h"
|
||||
|
||||
long stdb_top_payment_sum(const char *bizdate, long topn)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
long h_top = topn, h_rnk, h_net, 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 prc CURSOR FOR
|
||||
SELECT net_amount, rank() OVER (ORDER BY net_amount DESC) AS rnk
|
||||
FROM st_payment WHERE biz_date = :h_bizdate;
|
||||
EXEC SQL OPEN prc;
|
||||
if (sqlca.sqlcode < 0) return -1;
|
||||
for (;;) {
|
||||
EXEC SQL FETCH prc INTO :h_net, :h_rnk;
|
||||
if (sqlca.sqlcode == 100) break;
|
||||
if (sqlca.sqlcode < 0) { EXEC SQL CLOSE prc; return -1; }
|
||||
if (h_rnk <= h_top) total += h_net;
|
||||
}
|
||||
EXEC SQL CLOSE prc;
|
||||
return total;
|
||||
}
|
||||
13
app/src/st/dbio/st_paystatuscnt_dbio.h
Normal file
13
app/src/st/dbio/st_paystatuscnt_dbio.h
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* st_paystatuscnt_dbio.h - st 모듈 DB 접근 계층 copybook (st_paystatuscnt_dbio, part of libstdbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef ST_PAYSTATUSCNT_DBIO
|
||||
#define ST_PAYSTATUSCNT_DBIO
|
||||
|
||||
typedef struct { char biz_date[16]; char status[16]; long cnt; } st_paystatuscnt_rec_t;
|
||||
|
||||
long stdb_payment_status_count(const char *bizdate, const char *status);
|
||||
|
||||
#endif /* ST_PAYSTATUSCNT_DBIO */
|
||||
22
app/src/st/dbio/st_paystatuscnt_dbio.pgc
Normal file
22
app/src/st/dbio/st_paystatuscnt_dbio.pgc
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* st_paystatuscnt_dbio.pgc - st 모듈 DB 접근 함수 세트 (st_paystatuscnt_dbio), archived into libstdbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* 지급 상태별 건수 조회.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "st_paystatuscnt_dbio.h"
|
||||
|
||||
long stdb_payment_status_count(const char *bizdate, const char *status)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16], h_status[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;
|
||||
strncpy(h_status, status, sizeof(h_status)-1); h_status[sizeof(h_status)-1] = 0;
|
||||
EXEC SQL SELECT count(*) INTO :h_v FROM st_payment
|
||||
WHERE biz_date = :h_bizdate AND status = :h_status;
|
||||
if (sqlca.sqlcode < 0) return -1;
|
||||
return h_v;
|
||||
}
|
||||
13
app/src/st/dbio/st_purgecancel_dbio.h
Normal file
13
app/src/st/dbio/st_purgecancel_dbio.h
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* st_purgecancel_dbio.h - st 모듈 DB 접근 계층 copybook (st_purgecancel_dbio, part of libstdbio.a).
|
||||
* ECPG functions; run on the caller's XA branch (no EXEC SQL CONNECT).
|
||||
* Return convention: >=0 ok, -1 = SQL error.
|
||||
*/
|
||||
#ifndef ST_PURGECANCEL_DBIO
|
||||
#define ST_PURGECANCEL_DBIO
|
||||
|
||||
typedef struct { char biz_date[16]; long deleted; } st_purgecancel_rec_t;
|
||||
|
||||
long stdb_purge_cancelled_pay(const char *bizdate);
|
||||
|
||||
#endif /* ST_PURGECANCEL_DBIO */
|
||||
19
app/src/st/dbio/st_purgecancel_dbio.pgc
Normal file
19
app/src/st/dbio/st_purgecancel_dbio.pgc
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
* st_purgecancel_dbio.pgc - st 모듈 DB 접근 함수 세트 (st_purgecancel_dbio), archived into libstdbio.a.
|
||||
* ECPG (EXEC SQL) functions; run on the caller's XA branch. No EXEC SQL CONNECT.
|
||||
* 취소 지급 레코드 정리 - DELETE 후 삭제 행수 반환.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <userlog.h>
|
||||
#include "st_purgecancel_dbio.h"
|
||||
|
||||
long stdb_purge_cancelled_pay(const char *bizdate)
|
||||
{
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_bizdate[16];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
EXEC SQL DELETE FROM st_payment WHERE biz_date = :h_bizdate AND status = 'CANCELLED';
|
||||
if (sqlca.sqlcode < 0) { userlog("stdb_purge_cancelled_pay FAIL [%d] %s", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); return -1; }
|
||||
return (long)sqlca.sqlerrd[2];
|
||||
}
|
||||
13
app/src/st/run/run_adjubatch.sh
Executable file
13
app/src/st/run/run_adjubatch.sh
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
##
|
||||
## run_adjubatch.sh - st_adjust_batch 실행.
|
||||
## 운영 스크립트: Enduro/X + ECPG/XA 런타임 환경을 설정하고 st 배치를 실행.
|
||||
## Usage: run_adjubatch.sh [BIZDATE]
|
||||
##
|
||||
set -e
|
||||
. /app/conf/setapp.sh
|
||||
|
||||
BIZDATE="${1:-2026-07-19}"
|
||||
|
||||
echo "[run_adjubatch.sh] mod=st BIZDATE=$BIZDATE -> st_adjust_batch"
|
||||
exec /app/bin/st_adjust_batch "$BIZDATE"
|
||||
13
app/src/st/run/run_cancelpurge.sh
Executable file
13
app/src/st/run/run_cancelpurge.sh
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
##
|
||||
## run_cancelpurge.sh - st_cancelpurge_batch 실행.
|
||||
## 운영 스크립트: Enduro/X + ECPG/XA 런타임 환경을 설정하고 st 배치를 실행.
|
||||
## Usage: run_cancelpurge.sh [BIZDATE]
|
||||
##
|
||||
set -e
|
||||
. /app/conf/setapp.sh
|
||||
|
||||
BIZDATE="${1:-2026-07-19}"
|
||||
|
||||
echo "[run_cancelpurge.sh] mod=st BIZDATE=$BIZDATE -> st_cancelpurge_batch"
|
||||
exec /app/bin/st_cancelpurge_batch "$BIZDATE"
|
||||
13
app/src/st/run/run_confirm.sh
Executable file
13
app/src/st/run/run_confirm.sh
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
##
|
||||
## run_confirm.sh - st_confirm_batch 실행.
|
||||
## 운영 스크립트: Enduro/X + ECPG/XA 런타임 환경을 설정하고 st 배치를 실행.
|
||||
## Usage: run_confirm.sh [BIZDATE]
|
||||
##
|
||||
set -e
|
||||
. /app/conf/setapp.sh
|
||||
|
||||
BIZDATE="${1:-2026-07-19}"
|
||||
|
||||
echo "[run_confirm.sh] mod=st BIZDATE=$BIZDATE -> st_confirm_batch"
|
||||
exec /app/bin/st_confirm_batch "$BIZDATE"
|
||||
13
app/src/st/run/run_delayint.sh
Executable file
13
app/src/st/run/run_delayint.sh
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
##
|
||||
## run_delayint.sh - st_delayint_batch 실행.
|
||||
## 운영 스크립트: Enduro/X + ECPG/XA 런타임 환경을 설정하고 st 배치를 실행.
|
||||
## Usage: run_delayint.sh [BIZDATE]
|
||||
##
|
||||
set -e
|
||||
. /app/conf/setapp.sh
|
||||
|
||||
BIZDATE="${1:-2026-07-19}"
|
||||
|
||||
echo "[run_delayint.sh] mod=st BIZDATE=$BIZDATE -> st_delayint_batch"
|
||||
exec /app/bin/st_delayint_batch "$BIZDATE"
|
||||
13
app/src/st/run/run_feecalc.sh
Executable file
13
app/src/st/run/run_feecalc.sh
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
##
|
||||
## run_feecalc.sh - st_feecalc_batch 실행.
|
||||
## 운영 스크립트: Enduro/X + ECPG/XA 런타임 환경을 설정하고 st 배치를 실행.
|
||||
## Usage: run_feecalc.sh [BIZDATE]
|
||||
##
|
||||
set -e
|
||||
. /app/conf/setapp.sh
|
||||
|
||||
BIZDATE="${1:-2026-07-19}"
|
||||
|
||||
echo "[run_feecalc.sh] mod=st BIZDATE=$BIZDATE -> st_feecalc_batch"
|
||||
exec /app/bin/st_feecalc_batch "$BIZDATE"
|
||||
13
app/src/st/run/run_feepct.sh
Executable file
13
app/src/st/run/run_feepct.sh
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
##
|
||||
## run_feepct.sh - st_feepct_batch 실행.
|
||||
## 운영 스크립트: Enduro/X + ECPG/XA 런타임 환경을 설정하고 st 배치를 실행.
|
||||
## Usage: run_feepct.sh [BIZDATE]
|
||||
##
|
||||
set -e
|
||||
. /app/conf/setapp.sh
|
||||
|
||||
BIZDATE="${1:-2026-07-19}"
|
||||
|
||||
echo "[run_feepct.sh] mod=st BIZDATE=$BIZDATE -> st_feepct_batch"
|
||||
exec /app/bin/st_feepct_batch "$BIZDATE"
|
||||
13
app/src/st/run/run_hold.sh
Executable file
13
app/src/st/run/run_hold.sh
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
##
|
||||
## run_hold.sh - st_hold_batch 실행.
|
||||
## 운영 스크립트: Enduro/X + ECPG/XA 런타임 환경을 설정하고 st 배치를 실행.
|
||||
## Usage: run_hold.sh [BIZDATE]
|
||||
##
|
||||
set -e
|
||||
. /app/conf/setapp.sh
|
||||
|
||||
BIZDATE="${1:-2026-07-19}"
|
||||
|
||||
echo "[run_hold.sh] mod=st BIZDATE=$BIZDATE -> st_hold_batch"
|
||||
exec /app/bin/st_hold_batch "$BIZDATE"
|
||||
13
app/src/st/run/run_mdr_sum.sh
Executable file
13
app/src/st/run/run_mdr_sum.sh
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
##
|
||||
## run_mdr_sum.sh - st_mdr_sum_batch 실행.
|
||||
## 운영 스크립트: Enduro/X + ECPG/XA 런타임 환경을 설정하고 st 배치를 실행.
|
||||
## Usage: run_mdr_sum.sh [BIZDATE]
|
||||
##
|
||||
set -e
|
||||
. /app/conf/setapp.sh
|
||||
|
||||
BIZDATE="${1:-2026-07-19}"
|
||||
|
||||
echo "[run_mdr_sum.sh] mod=st BIZDATE=$BIZDATE -> st_mdr_sum_batch"
|
||||
exec /app/bin/st_mdr_sum_batch "$BIZDATE"
|
||||
13
app/src/st/run/run_merchroll.sh
Executable file
13
app/src/st/run/run_merchroll.sh
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
##
|
||||
## run_merchroll.sh - st_merchroll_batch 실행.
|
||||
## 운영 스크립트: Enduro/X + ECPG/XA 런타임 환경을 설정하고 st 배치를 실행.
|
||||
## Usage: run_merchroll.sh [BIZDATE]
|
||||
##
|
||||
set -e
|
||||
. /app/conf/setapp.sh
|
||||
|
||||
BIZDATE="${1:-2026-07-19}"
|
||||
|
||||
echo "[run_merchroll.sh] mod=st BIZDATE=$BIZDATE -> st_merchroll_batch"
|
||||
exec /app/bin/st_merchroll_batch "$BIZDATE"
|
||||
13
app/src/st/run/run_monthly.sh
Executable file
13
app/src/st/run/run_monthly.sh
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
##
|
||||
## run_monthly.sh - st_monthly_batch 실행.
|
||||
## 운영 스크립트: Enduro/X + ECPG/XA 런타임 환경을 설정하고 st 배치를 실행.
|
||||
## Usage: run_monthly.sh [BIZDATE]
|
||||
##
|
||||
set -e
|
||||
. /app/conf/setapp.sh
|
||||
|
||||
BIZDATE="${1:-2026-07-19}"
|
||||
|
||||
echo "[run_monthly.sh] mod=st BIZDATE=$BIZDATE -> st_monthly_batch"
|
||||
exec /app/bin/st_monthly_batch "$BIZDATE"
|
||||
13
app/src/st/run/run_netting.sh
Executable file
13
app/src/st/run/run_netting.sh
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
##
|
||||
## run_netting.sh - st_netting_batch 실행.
|
||||
## 운영 스크립트: Enduro/X + ECPG/XA 런타임 환경을 설정하고 st 배치를 실행.
|
||||
## Usage: run_netting.sh [BIZDATE]
|
||||
##
|
||||
set -e
|
||||
. /app/conf/setapp.sh
|
||||
|
||||
BIZDATE="${1:-2026-07-19}"
|
||||
|
||||
echo "[run_netting.sh] mod=st BIZDATE=$BIZDATE -> st_netting_batch"
|
||||
exec /app/bin/st_netting_batch "$BIZDATE"
|
||||
13
app/src/st/run/run_offset.sh
Executable file
13
app/src/st/run/run_offset.sh
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
##
|
||||
## run_offset.sh - st_offset_batch 실행.
|
||||
## 운영 스크립트: Enduro/X + ECPG/XA 런타임 환경을 설정하고 st 배치를 실행.
|
||||
## Usage: run_offset.sh [BIZDATE]
|
||||
##
|
||||
set -e
|
||||
. /app/conf/setapp.sh
|
||||
|
||||
BIZDATE="${1:-2026-07-19}"
|
||||
|
||||
echo "[run_offset.sh] mod=st BIZDATE=$BIZDATE -> st_offset_batch"
|
||||
exec /app/bin/st_offset_batch "$BIZDATE"
|
||||
13
app/src/st/run/run_payment.sh
Executable file
13
app/src/st/run/run_payment.sh
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
##
|
||||
## run_payment.sh - st_payment_batch 실행.
|
||||
## 운영 스크립트: Enduro/X + ECPG/XA 런타임 환경을 설정하고 st 배치를 실행.
|
||||
## Usage: run_payment.sh [BIZDATE]
|
||||
##
|
||||
set -e
|
||||
. /app/conf/setapp.sh
|
||||
|
||||
BIZDATE="${1:-2026-07-19}"
|
||||
|
||||
echo "[run_payment.sh] mod=st BIZDATE=$BIZDATE -> st_payment_batch"
|
||||
exec /app/bin/st_payment_batch "$BIZDATE"
|
||||
13
app/src/st/run/run_release.sh
Executable file
13
app/src/st/run/run_release.sh
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
##
|
||||
## run_release.sh - st_release_batch 실행.
|
||||
## 운영 스크립트: Enduro/X + ECPG/XA 런타임 환경을 설정하고 st 배치를 실행.
|
||||
## Usage: run_release.sh [BIZDATE]
|
||||
##
|
||||
set -e
|
||||
. /app/conf/setapp.sh
|
||||
|
||||
BIZDATE="${1:-2026-07-19}"
|
||||
|
||||
echo "[run_release.sh] mod=st BIZDATE=$BIZDATE -> st_release_batch"
|
||||
exec /app/bin/st_release_batch "$BIZDATE"
|
||||
13
app/src/st/run/run_report.sh
Executable file
13
app/src/st/run/run_report.sh
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
##
|
||||
## run_report.sh - st_report_batch 실행.
|
||||
## 운영 스크립트: Enduro/X + ECPG/XA 런타임 환경을 설정하고 st 배치를 실행.
|
||||
## Usage: run_report.sh [BIZDATE]
|
||||
##
|
||||
set -e
|
||||
. /app/conf/setapp.sh
|
||||
|
||||
BIZDATE="${1:-2026-07-19}"
|
||||
|
||||
echo "[run_report.sh] mod=st BIZDATE=$BIZDATE -> st_report_batch"
|
||||
exec /app/bin/st_report_batch "$BIZDATE"
|
||||
13
app/src/st/run/run_settle.sh
Executable file
13
app/src/st/run/run_settle.sh
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
##
|
||||
## run_settle.sh - st_settle_batch 실행.
|
||||
## 운영 스크립트: Enduro/X + ECPG/XA 런타임 환경을 설정하고 st 배치를 실행.
|
||||
## Usage: run_settle.sh [BIZDATE]
|
||||
##
|
||||
set -e
|
||||
. /app/conf/setapp.sh
|
||||
|
||||
BIZDATE="${1:-2026-07-19}"
|
||||
|
||||
echo "[run_settle.sh] mod=st BIZDATE=$BIZDATE -> st_settle_batch"
|
||||
exec /app/bin/st_settle_batch "$BIZDATE"
|
||||
13
app/src/st/run/run_vat_sum.sh
Executable file
13
app/src/st/run/run_vat_sum.sh
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
##
|
||||
## run_vat_sum.sh - st_vat_sum_batch 실행.
|
||||
## 운영 스크립트: Enduro/X + ECPG/XA 런타임 환경을 설정하고 st 배치를 실행.
|
||||
## Usage: run_vat_sum.sh [BIZDATE]
|
||||
##
|
||||
set -e
|
||||
. /app/conf/setapp.sh
|
||||
|
||||
BIZDATE="${1:-2026-07-19}"
|
||||
|
||||
echo "[run_vat_sum.sh] mod=st BIZDATE=$BIZDATE -> st_vat_sum_batch"
|
||||
exec /app/bin/st_vat_sum_batch "$BIZDATE"
|
||||
|
|
@ -1,71 +1,71 @@
|
|||
/*
|
||||
* st_svr.pgc - st (정산/수수료) MODULE SERVER.
|
||||
* st_svr.pgc - st (정산/수수료) MODULE SERVER (thin dispatcher).
|
||||
*
|
||||
* ONE binary that tpadvertise()s ALL ~30 online st(정산/수수료) services — the
|
||||
* real Enduro-X "one module server, many services" pattern, modeled on ac_svr.
|
||||
* Every service is a distinct 정산/수수료 operation with genuine EXEC SQL (directly,
|
||||
* or via the linked libstdbio.a dbio layer) plus fee math from libacqcommon.a.
|
||||
* The legacy "one module server, many services" pattern: this binary owns NO
|
||||
* business logic. Each of st's 30 online services now lives in its own file
|
||||
* (app/src/st/svc/<SVCNAME>.pgc) with its own copybook header
|
||||
* (app/src/st/svc/<SVCNAME>.h); those objects are archived into libstsvc.a and
|
||||
* linked into this server. Here we only include every service copybook, tpopen()
|
||||
* the ECPG XA RM, tpadvertise() all services from a {name, fn} table, and
|
||||
* tpclose() at shutdown.
|
||||
*
|
||||
* XA: the connection is opened once by tpopen() (ECPG XA switch); there is NO
|
||||
* EXEC SQL CONNECT. SETTLE keeps the proven behavior: its own XA branch writes
|
||||
* the settlement + settle ledger rows (the purchase status transition is owned by
|
||||
* the ACQUIRE branch). Terminal service of the 매입 chain. Owner-writes: st
|
||||
* services never tpcall each other.
|
||||
* st_svr: ONE binary that tpadvertise()s ALL 30 online st(정산/수수료) services.
|
||||
* SETTLE keeps the proven behavior: its own XA branch writes the settlement +
|
||||
* settle ledger rows. Terminal service of the 매입 chain.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <atmi.h>
|
||||
#include <ubf.h>
|
||||
#include <userlog.h>
|
||||
#include <ndebug.h>
|
||||
#include "acq.fd.h"
|
||||
#include "acq_common.h"
|
||||
#include "st_dbio.h"
|
||||
|
||||
/* ----- small UBF helpers ------------------------------------------------- */
|
||||
static long getl(UBFH *b, BFLDID f) { long v = 0; Bget(b, f, 0, (char *)&v, 0L); return v; }
|
||||
static void gets_(UBFH *b, BFLDID f, char *out, int cap)
|
||||
{ BFLDLEN l = cap; out[0] = 0; Bget(b, f, 0, out, &l); }
|
||||
static void setl(UBFH *b, BFLDID f, long v) { Bchg(b, f, 0, (char *)&v, 0L); }
|
||||
/* every st service's copybook header (declares its record struct + prototype) */
|
||||
#include "SETTLE.h"
|
||||
#include "ST_MDR.h"
|
||||
#include "ST_NETTING.h"
|
||||
#include "ST_VAT.h"
|
||||
#include "ST_VANFEE.h"
|
||||
#include "ST_RELAYFEE.h"
|
||||
#include "ST_WHT.h"
|
||||
#include "ST_ADJUST.h"
|
||||
#include "ST_ADVANCE.h"
|
||||
#include "ST_DELAYINT.h"
|
||||
#include "ST_HOLD.h"
|
||||
#include "ST_RELEASE.h"
|
||||
#include "ST_SPLIT.h"
|
||||
#include "ST_PAYDATE.h"
|
||||
#include "ST_BYMERCH.h"
|
||||
#include "ST_MONTHLY.h"
|
||||
#include "ST_OFFSET.h"
|
||||
#include "ST_DIFFCHK.h"
|
||||
#include "ST_RECALC.h"
|
||||
#include "ST_RATEAPPLY.h"
|
||||
#include "ST_REPORT.h"
|
||||
#include "ST_XFERLINK.h"
|
||||
#include "ST_STATS.h"
|
||||
#include "ST_CANCEL.h"
|
||||
#include "ST_LEDGERLINK.h"
|
||||
#include "ST_BANDRATE.h"
|
||||
#include "ST_CAP.h"
|
||||
#include "ST_FXCONV.h"
|
||||
#include "ST_CONFIRM.h"
|
||||
#include "ST_STATUS.h"
|
||||
|
||||
#define FAIL(b) do { tpreturn(TPFAIL, 0, (char *)(b), 0L, 0L); return; } while (0)
|
||||
#define OK(b) do { tpreturn(TPSUCCESS, 0, (char *)(b), 0L, 0L); return; } while (0)
|
||||
|
||||
/* ----- service prototypes ------------------------------------------------ */
|
||||
void SETTLE(TPSVCINFO *p); void ST_MDR(TPSVCINFO *p);
|
||||
void ST_NETTING(TPSVCINFO *p); void ST_VAT(TPSVCINFO *p);
|
||||
void ST_VANFEE(TPSVCINFO *p); void ST_RELAYFEE(TPSVCINFO *p);
|
||||
void ST_WHT(TPSVCINFO *p); void ST_ADJUST(TPSVCINFO *p);
|
||||
void ST_ADVANCE(TPSVCINFO *p); void ST_DELAYINT(TPSVCINFO *p);
|
||||
void ST_HOLD(TPSVCINFO *p); void ST_RELEASE(TPSVCINFO *p);
|
||||
void ST_SPLIT(TPSVCINFO *p); void ST_PAYDATE(TPSVCINFO *p);
|
||||
void ST_BYMERCH(TPSVCINFO *p); void ST_MONTHLY(TPSVCINFO *p);
|
||||
void ST_OFFSET(TPSVCINFO *p); void ST_DIFFCHK(TPSVCINFO *p);
|
||||
void ST_RECALC(TPSVCINFO *p); void ST_RATEAPPLY(TPSVCINFO *p);
|
||||
void ST_REPORT(TPSVCINFO *p); void ST_XFERLINK(TPSVCINFO *p);
|
||||
void ST_STATS(TPSVCINFO *p); void ST_CANCEL(TPSVCINFO *p);
|
||||
void ST_LEDGERLINK(TPSVCINFO *p);void ST_BANDRATE(TPSVCINFO *p);
|
||||
void ST_CAP(TPSVCINFO *p); void ST_FXCONV(TPSVCINFO *p);
|
||||
void ST_CONFIRM(TPSVCINFO *p); void ST_STATUS(TPSVCINFO *p);
|
||||
|
||||
/* ----- advertise table --------------------------------------------------- */
|
||||
/* ----- advertise table: {service name, function} ---------------------- */
|
||||
static struct { const char *name; void (*fn)(TPSVCINFO *); } SVCS[] = {
|
||||
{"SETTLE", SETTLE}, {"ST_MDR", ST_MDR},
|
||||
{"ST_NETTING", ST_NETTING}, {"ST_VAT", ST_VAT},
|
||||
{"ST_VANFEE", ST_VANFEE}, {"ST_RELAYFEE", ST_RELAYFEE},
|
||||
{"ST_WHT", ST_WHT}, {"ST_ADJUST", ST_ADJUST},
|
||||
{"ST_ADVANCE", ST_ADVANCE}, {"ST_DELAYINT", ST_DELAYINT},
|
||||
{"ST_HOLD", ST_HOLD}, {"ST_RELEASE", ST_RELEASE},
|
||||
{"ST_SPLIT", ST_SPLIT}, {"ST_PAYDATE", ST_PAYDATE},
|
||||
{"ST_BYMERCH", ST_BYMERCH}, {"ST_MONTHLY", ST_MONTHLY},
|
||||
{"ST_OFFSET", ST_OFFSET}, {"ST_DIFFCHK", ST_DIFFCHK},
|
||||
{"ST_RECALC", ST_RECALC}, {"ST_RATEAPPLY", ST_RATEAPPLY},
|
||||
{"ST_REPORT", ST_REPORT}, {"ST_XFERLINK", ST_XFERLINK},
|
||||
{"ST_STATS", ST_STATS}, {"ST_CANCEL", ST_CANCEL},
|
||||
{"ST_LEDGERLINK", ST_LEDGERLINK},{"ST_BANDRATE", ST_BANDRATE},
|
||||
{"ST_CAP", ST_CAP}, {"ST_FXCONV", ST_FXCONV},
|
||||
{"ST_CONFIRM", ST_CONFIRM}, {"ST_STATUS", ST_STATUS},
|
||||
{"SETTLE", SETTLE}, {"ST_MDR", ST_MDR},
|
||||
{"ST_NETTING", ST_NETTING}, {"ST_VAT", ST_VAT},
|
||||
{"ST_VANFEE", ST_VANFEE}, {"ST_RELAYFEE", ST_RELAYFEE},
|
||||
{"ST_WHT", ST_WHT}, {"ST_ADJUST", ST_ADJUST},
|
||||
{"ST_ADVANCE", ST_ADVANCE}, {"ST_DELAYINT", ST_DELAYINT},
|
||||
{"ST_HOLD", ST_HOLD}, {"ST_RELEASE", ST_RELEASE},
|
||||
{"ST_SPLIT", ST_SPLIT}, {"ST_PAYDATE", ST_PAYDATE},
|
||||
{"ST_BYMERCH", ST_BYMERCH}, {"ST_MONTHLY", ST_MONTHLY},
|
||||
{"ST_OFFSET", ST_OFFSET}, {"ST_DIFFCHK", ST_DIFFCHK},
|
||||
{"ST_RECALC", ST_RECALC}, {"ST_RATEAPPLY", ST_RATEAPPLY},
|
||||
{"ST_REPORT", ST_REPORT}, {"ST_XFERLINK", ST_XFERLINK},
|
||||
{"ST_STATS", ST_STATS}, {"ST_CANCEL", ST_CANCEL},
|
||||
{"ST_LEDGERLINK", ST_LEDGERLINK}, {"ST_BANDRATE", ST_BANDRATE},
|
||||
{"ST_CAP", ST_CAP}, {"ST_FXCONV", ST_FXCONV},
|
||||
{"ST_CONFIRM", ST_CONFIRM}, {"ST_STATUS", ST_STATUS},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
|
|
@ -84,545 +84,4 @@ int tpsvrinit(int argc, char **argv)
|
|||
|
||||
void tpsvrdone(void) { tpclose(); userlog("st_svr: tpsvrdone"); }
|
||||
|
||||
/* ========================================================================= */
|
||||
/* 1. SETTLE - 정산 + settle 원장 (own branch). 매입 체인 종단. (KEEP) */
|
||||
/* ========================================================================= */
|
||||
void SETTLE(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
char merch[64], bizdate[16];
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long h_pid, h_sid, h_net;
|
||||
char h_merch[64], h_bizdate[16];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
h_pid = getl(b, T_PURCHASE_ID);
|
||||
h_net = getl(b, T_NET);
|
||||
gets_(b, T_MERCHANT, merch, sizeof(merch));
|
||||
gets_(b, T_BIZDATE, bizdate, sizeof(bizdate));
|
||||
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 nextval('settlement_seq') INTO :h_sid;
|
||||
if (sqlca.sqlcode < 0) FAIL(b);
|
||||
EXEC SQL INSERT INTO settlement (settlement_id, purchase_id, merchant_id, net, biz_date, status)
|
||||
VALUES (:h_sid, :h_pid, :h_merch, :h_net, :h_bizdate, 'SETTLED');
|
||||
if (sqlca.sqlcode < 0) { userlog("SETTLE INSERT settlement FAIL [%d] %s", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); FAIL(b); }
|
||||
EXEC SQL INSERT INTO ledger (ledger_id, purchase_id, entry_type, amount, biz_date)
|
||||
VALUES (nextval('ledger_seq'), :h_pid, 'SETTLE', :h_net, :h_bizdate);
|
||||
if (sqlca.sqlcode < 0) FAIL(b);
|
||||
|
||||
setl(b, T_SETTLE_ID, h_sid);
|
||||
Bchg(b, T_STATUS, 0, "S", 0L);
|
||||
userlog("SETTLE pid=%ld settlement_id=%ld net=%ld", h_pid, h_sid, h_net);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* 2. ST_MDR - MDR 수수료 원장 기록. (KEEP) */
|
||||
void ST_MDR(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
char bizdate[16];
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long h_pid, h_fee;
|
||||
char h_bizdate[16];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
h_pid = getl(b, T_PURCHASE_ID); h_fee = getl(b, T_FEE);
|
||||
gets_(b, T_BIZDATE, bizdate, sizeof(bizdate));
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
EXEC SQL INSERT INTO ledger (ledger_id, purchase_id, entry_type, amount, biz_date)
|
||||
VALUES (nextval('ledger_seq'), :h_pid, 'MDR', :h_fee, :h_bizdate);
|
||||
if (sqlca.sqlcode < 0) FAIL(b);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* 3. ST_NETTING - 당일 net 합계 조회. (KEEP) */
|
||||
void ST_NETTING(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
char merch[64], bizdate[16];
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long h_sum;
|
||||
char h_merch[64], h_bizdate[16];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
gets_(b, T_MERCHANT, merch, sizeof(merch));
|
||||
gets_(b, T_BIZDATE, bizdate, sizeof(bizdate));
|
||||
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(sum(net),0) INTO :h_sum FROM settlement
|
||||
WHERE merchant_id = :h_merch AND biz_date = :h_bizdate;
|
||||
if (sqlca.sqlcode < 0) FAIL(b);
|
||||
setl(b, T_GROSS, h_sum);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* 4. ST_VAT - 정산 부가세 원장 기록. (KEEP) */
|
||||
void ST_VAT(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
char bizdate[16];
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long h_pid, h_vat;
|
||||
char h_bizdate[16];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
h_pid = getl(b, T_PURCHASE_ID); h_vat = getl(b, T_FEE) / 10;
|
||||
gets_(b, T_BIZDATE, bizdate, sizeof(bizdate));
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
EXEC SQL INSERT INTO ledger (ledger_id, purchase_id, entry_type, amount, biz_date)
|
||||
VALUES (nextval('ledger_seq'), :h_pid, 'VAT', :h_vat, :h_bizdate);
|
||||
if (sqlca.sqlcode < 0) FAIL(b);
|
||||
setl(b, T_TAX, h_vat);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* 5. ST_VANFEE - VAN 수수료: 구간요율 조회 후 정산 상세 기록 (dbio). */
|
||||
void ST_VANFEE(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
char merch[64], bizdate[16];
|
||||
long sid = getl(b, T_SETTLE_ID), pid = getl(b, T_PURCHASE_ID);
|
||||
long amount = getl(b, T_AMOUNT), bps, fee, dtl;
|
||||
gets_(b, T_MERCHANT, merch, sizeof(merch));
|
||||
gets_(b, T_BIZDATE, bizdate, sizeof(bizdate));
|
||||
bps = stdb_lookup_rate("VAN", amount);
|
||||
if (bps < 0) FAIL(b);
|
||||
fee = acq_fee(amount, bps);
|
||||
dtl = stdb_insert_fee_dtl(sid, pid, merch, "VAN", fee, bizdate);
|
||||
if (dtl < 0) FAIL(b);
|
||||
setl(b, T_FEE, fee);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* 6. ST_RELAYFEE - 중계 수수료: 구간요율 조회 후 정산 상세 기록 (dbio). */
|
||||
void ST_RELAYFEE(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
char merch[64], bizdate[16];
|
||||
long sid = getl(b, T_SETTLE_ID), pid = getl(b, T_PURCHASE_ID);
|
||||
long amount = getl(b, T_AMOUNT), bps, fee, dtl;
|
||||
gets_(b, T_MERCHANT, merch, sizeof(merch));
|
||||
gets_(b, T_BIZDATE, bizdate, sizeof(bizdate));
|
||||
bps = stdb_lookup_rate("RELAY", amount);
|
||||
if (bps < 0) FAIL(b);
|
||||
fee = acq_fee(amount, bps);
|
||||
dtl = stdb_insert_fee_dtl(sid, pid, merch, "RELAY", fee, bizdate);
|
||||
if (dtl < 0) FAIL(b);
|
||||
setl(b, T_FEE, fee);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* 7. ST_WHT - 원천징수(수수료의 22%) 정산 상세 기록 (dbio). */
|
||||
void ST_WHT(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
char merch[64], bizdate[16];
|
||||
long sid = getl(b, T_SETTLE_ID), pid = getl(b, T_PURCHASE_ID);
|
||||
long fee = getl(b, T_FEE), tax, dtl;
|
||||
gets_(b, T_MERCHANT, merch, sizeof(merch));
|
||||
gets_(b, T_BIZDATE, bizdate, sizeof(bizdate));
|
||||
tax = acq_wht_amt(fee, 2200);
|
||||
dtl = stdb_insert_fee_dtl(sid, pid, merch, "WHT", tax, bizdate);
|
||||
if (dtl < 0) FAIL(b);
|
||||
setl(b, T_TAX, tax);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* 8. ST_ADJUST - 정산 조정 (가감) 기록 (dbio). */
|
||||
void ST_ADJUST(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
char bizdate[16], reason[128];
|
||||
long sid = getl(b, T_SETTLE_ID), pid = getl(b, T_PURCHASE_ID);
|
||||
long delta = getl(b, T_DELTA), adj;
|
||||
gets_(b, T_BIZDATE, bizdate, sizeof(bizdate));
|
||||
gets_(b, T_REASON, reason, sizeof(reason)); if (reason[0] == 0) strcpy(reason, "ADJ");
|
||||
adj = stdb_insert_adjust(sid, pid, delta, reason, bizdate);
|
||||
if (adj < 0) FAIL(b);
|
||||
setl(b, T_ADJ, adj);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* 9. ST_ADVANCE - 선지급 예약: 지급 레코드(SCHEDULED) 생성 (dbio). */
|
||||
void ST_ADVANCE(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
char merch[64], bizdate[16], paydate[16];
|
||||
long net = getl(b, T_NET), pay;
|
||||
gets_(b, T_MERCHANT, merch, sizeof(merch));
|
||||
gets_(b, T_BIZDATE, bizdate, sizeof(bizdate));
|
||||
gets_(b, T_KEY1, paydate, sizeof(paydate));
|
||||
if (paydate[0] == 0) { strncpy(paydate, bizdate, sizeof(paydate)-1); paydate[sizeof(paydate)-1] = 0; }
|
||||
pay = stdb_insert_payment(merch, net, paydate, "SCHEDULED", bizdate);
|
||||
if (pay < 0) FAIL(b);
|
||||
setl(b, T_ID1, pay);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* 10. ST_DELAYINT - 지연이자(net * bps/10000 * 일수) 정산 상세 기록 (dbio). */
|
||||
void ST_DELAYINT(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
char merch[64], bizdate[16];
|
||||
long sid = getl(b, T_SETTLE_ID), pid = getl(b, T_PURCHASE_ID);
|
||||
long net = getl(b, T_NET), days = getl(b, T_ARG1), bps = getl(b, T_ARG2), intr, dtl;
|
||||
gets_(b, T_MERCHANT, merch, sizeof(merch));
|
||||
gets_(b, T_BIZDATE, bizdate, sizeof(bizdate));
|
||||
if (days <= 0) days = 1;
|
||||
if (bps <= 0) bps = 15; /* 일 0.15% 기본 */
|
||||
intr = acq_fee(net, bps) * days;
|
||||
dtl = stdb_insert_fee_dtl(sid, pid, merch, "DELAYINT", intr, bizdate);
|
||||
if (dtl < 0) FAIL(b);
|
||||
setl(b, T_AMOUNT, intr);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* 11. ST_HOLD - 가맹점 지급 보류 (SCHEDULED -> HELD) (dbio). */
|
||||
void ST_HOLD(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
char merch[64], bizdate[16];
|
||||
gets_(b, T_MERCHANT, merch, sizeof(merch));
|
||||
gets_(b, T_BIZDATE, bizdate, sizeof(bizdate));
|
||||
if (stdb_update_payment_status(merch, "SCHEDULED", "HELD", bizdate) < 0) FAIL(b);
|
||||
Bchg(b, T_STATUS, 0, "H", 0L);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* 12. ST_RELEASE - 지급 보류 해제 (HELD -> SCHEDULED) (dbio). */
|
||||
void ST_RELEASE(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
char merch[64], bizdate[16];
|
||||
gets_(b, T_MERCHANT, merch, sizeof(merch));
|
||||
gets_(b, T_BIZDATE, bizdate, sizeof(bizdate));
|
||||
if (stdb_update_payment_status(merch, "HELD", "SCHEDULED", bizdate) < 0) FAIL(b);
|
||||
Bchg(b, T_STATUS, 0, "R", 0L);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* 13. ST_SPLIT - 분할 지급: net 을 n 회로 나눠 지급 레코드 생성 (dbio 루프). */
|
||||
void ST_SPLIT(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
char merch[64], bizdate[16];
|
||||
long net = getl(b, T_NET), n = getl(b, T_INSTALL_N), part, i, pay;
|
||||
gets_(b, T_MERCHANT, merch, sizeof(merch));
|
||||
gets_(b, T_BIZDATE, bizdate, sizeof(bizdate));
|
||||
if (n < 1) n = 2;
|
||||
part = net / n;
|
||||
for (i = 0; i < n; i++) {
|
||||
pay = stdb_insert_payment(merch, part, bizdate, "SCHEDULED", bizdate);
|
||||
if (pay < 0) FAIL(b);
|
||||
}
|
||||
setl(b, T_COUNT, n);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* 14. ST_PAYDATE - 지급일 산정(익영업일) 후 지급일 갱신. */
|
||||
void ST_PAYDATE(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
char merch[64], bizdate[16], paydate[16];
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
char h_merch[64], h_bizdate[16], h_paydate[16];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
gets_(b, T_MERCHANT, merch, sizeof(merch));
|
||||
gets_(b, T_BIZDATE, bizdate, sizeof(bizdate));
|
||||
if (acq_next_bizday(bizdate, paydate) < 0) FAIL(b);
|
||||
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_paydate, paydate, sizeof(h_paydate)-1); h_paydate[sizeof(h_paydate)-1] = 0;
|
||||
EXEC SQL UPDATE st_payment SET pay_date = :h_paydate
|
||||
WHERE merchant_id = :h_merch AND biz_date = :h_bizdate AND status = 'SCHEDULED';
|
||||
if (sqlca.sqlcode < 0) FAIL(b);
|
||||
Bchg(b, T_KEY1, 0, paydate, 0L);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* 15. ST_BYMERCH - 가맹점별 정산 집계 upsert (dbio). */
|
||||
void ST_BYMERCH(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
char merch[64], bizdate[16];
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long h_cnt, h_gross, h_fee, h_net;
|
||||
char h_merch[64], h_bizdate[16];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
gets_(b, T_MERCHANT, merch, sizeof(merch));
|
||||
gets_(b, T_BIZDATE, bizdate, sizeof(bizdate));
|
||||
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 count(*), coalesce(sum(p.amount),0), coalesce(sum(p.fee),0), coalesce(sum(s.net),0)
|
||||
INTO :h_cnt, :h_gross, :h_fee, :h_net
|
||||
FROM settlement s JOIN purchase p ON p.purchase_id = s.purchase_id
|
||||
WHERE s.merchant_id = :h_merch AND s.biz_date = :h_bizdate;
|
||||
if (sqlca.sqlcode < 0) FAIL(b);
|
||||
if (stdb_upsert_merch_settle(merch, bizdate, h_gross, h_fee, h_net, h_cnt) < 0) FAIL(b);
|
||||
setl(b, T_COUNT, h_cnt); setl(b, T_GROSS, h_gross);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* 16. ST_MONTHLY - 월별 정산 net 합계 (biz_date LIKE 'YYYY-MM%'). */
|
||||
void ST_MONTHLY(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
char merch[64], ym[16], like[16];
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long h_sum;
|
||||
char h_merch[64], h_like[16];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
gets_(b, T_MERCHANT, merch, sizeof(merch));
|
||||
gets_(b, T_KEY1, ym, sizeof(ym)); if (ym[0] == 0) strcpy(ym, "2026-07");
|
||||
snprintf(like, sizeof(like), "%s%%", ym);
|
||||
strncpy(h_merch, merch, sizeof(h_merch)-1); h_merch[sizeof(h_merch)-1] = 0;
|
||||
strncpy(h_like, like, sizeof(h_like)-1); h_like[sizeof(h_like)-1] = 0;
|
||||
EXEC SQL SELECT coalesce(sum(net),0) INTO :h_sum FROM settlement
|
||||
WHERE merchant_id = :h_merch AND to_char(biz_date, 'YYYY-MM-DD') LIKE :h_like;
|
||||
if (sqlca.sqlcode < 0) FAIL(b);
|
||||
setl(b, T_GROSS, h_sum);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* 17. ST_OFFSET - 상계: 음수 조정으로 채권 상계 기록 (dbio). */
|
||||
void ST_OFFSET(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
char bizdate[16];
|
||||
long sid = getl(b, T_SETTLE_ID), pid = getl(b, T_PURCHASE_ID);
|
||||
long amt = getl(b, T_AMOUNT), adj;
|
||||
gets_(b, T_BIZDATE, bizdate, sizeof(bizdate));
|
||||
adj = stdb_insert_adjust(sid, pid, -amt, "OFFSET", bizdate);
|
||||
if (adj < 0) FAIL(b);
|
||||
setl(b, T_ADJ, adj);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* 18. ST_DIFFCHK - 정산 net vs 매입 net 차이 점검. */
|
||||
void ST_DIFFCHK(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long h_pid, h_snet, h_pnet, h_diff;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
h_pid = getl(b, T_PURCHASE_ID);
|
||||
EXEC SQL SELECT coalesce(sum(net),0) INTO :h_snet FROM settlement WHERE purchase_id = :h_pid;
|
||||
if (sqlca.sqlcode < 0) FAIL(b);
|
||||
EXEC SQL SELECT net INTO :h_pnet FROM purchase WHERE purchase_id = :h_pid;
|
||||
if (sqlca.sqlcode < 0 || sqlca.sqlcode == 100) FAIL(b);
|
||||
h_diff = h_pnet - h_snet;
|
||||
setl(b, T_DELTA, h_diff);
|
||||
setl(b, T_RC, h_diff == 0 ? 0 : 1);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* 19. ST_RECALC - 매입 수수료 기준 정산 net 재계산 + 갱신. */
|
||||
void ST_RECALC(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long h_pid, h_amount, h_fee, h_net;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
h_pid = getl(b, T_PURCHASE_ID);
|
||||
EXEC SQL SELECT amount, fee INTO :h_amount, :h_fee FROM purchase WHERE purchase_id = :h_pid;
|
||||
if (sqlca.sqlcode < 0 || sqlca.sqlcode == 100) FAIL(b);
|
||||
h_net = h_amount - h_fee;
|
||||
EXEC SQL UPDATE settlement SET net = :h_net WHERE purchase_id = :h_pid;
|
||||
if (sqlca.sqlcode < 0) FAIL(b);
|
||||
setl(b, T_NET, h_net);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* 20. ST_RATEAPPLY - 구간요율 적용 수수료 계산 + 정산 상세 기록 (dbio). */
|
||||
void ST_RATEAPPLY(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
char merch[64], bizdate[16], ftype[16];
|
||||
long sid = getl(b, T_SETTLE_ID), pid = getl(b, T_PURCHASE_ID);
|
||||
long amount = getl(b, T_AMOUNT), bps, fee, dtl;
|
||||
gets_(b, T_MERCHANT, merch, sizeof(merch));
|
||||
gets_(b, T_BIZDATE, bizdate, sizeof(bizdate));
|
||||
gets_(b, T_STR1, ftype, sizeof(ftype)); if (ftype[0] == 0) strcpy(ftype, "MDR");
|
||||
bps = stdb_lookup_rate(ftype, amount);
|
||||
if (bps < 0) FAIL(b);
|
||||
fee = acq_fee(amount, bps);
|
||||
dtl = stdb_insert_fee_dtl(sid, pid, merch, ftype, fee, bizdate);
|
||||
if (dtl < 0) FAIL(b);
|
||||
setl(b, T_FEE, fee);
|
||||
setl(b, T_RC, bps);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* 21. ST_REPORT - 당일 정산 건수/합계 리포트. */
|
||||
void ST_REPORT(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
char bizdate[16];
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long h_cnt, h_sum;
|
||||
char h_bizdate[16];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
gets_(b, T_BIZDATE, bizdate, sizeof(bizdate));
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
EXEC SQL SELECT count(*), coalesce(sum(net),0) INTO :h_cnt, :h_sum
|
||||
FROM settlement WHERE biz_date = :h_bizdate;
|
||||
if (sqlca.sqlcode < 0) FAIL(b);
|
||||
setl(b, T_COUNT, h_cnt);
|
||||
setl(b, T_GROSS, h_sum);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* 22. ST_XFERLINK - 이체 연계 원장 기록. */
|
||||
void ST_XFERLINK(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
char bizdate[16];
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long h_pid, h_net;
|
||||
char h_bizdate[16];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
h_pid = getl(b, T_PURCHASE_ID); h_net = getl(b, T_NET);
|
||||
gets_(b, T_BIZDATE, bizdate, sizeof(bizdate));
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
EXEC SQL INSERT INTO ledger (ledger_id, purchase_id, entry_type, amount, biz_date)
|
||||
VALUES (nextval('ledger_seq'), :h_pid, 'ST_XFER', :h_net, :h_bizdate);
|
||||
if (sqlca.sqlcode < 0) FAIL(b);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* 23. ST_STATS - 정산 통계(건수/net 합계) 조회. */
|
||||
void ST_STATS(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
char bizdate[16];
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long h_cnt, h_sum, h_max;
|
||||
char h_bizdate[16];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
gets_(b, T_BIZDATE, bizdate, sizeof(bizdate));
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
EXEC SQL SELECT count(*), coalesce(sum(net),0), coalesce(max(net),0)
|
||||
INTO :h_cnt, :h_sum, :h_max FROM settlement WHERE biz_date = :h_bizdate;
|
||||
if (sqlca.sqlcode < 0) FAIL(b);
|
||||
setl(b, T_COUNT, h_cnt);
|
||||
setl(b, T_GROSS, h_sum);
|
||||
setl(b, T_AMT1, h_max);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* 24. ST_CANCEL - 정산 취소: 상태 CANCELLED + 취소 조정 (dbio). */
|
||||
void ST_CANCEL(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
char bizdate[16];
|
||||
long adj;
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long h_pid, h_net;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
h_pid = getl(b, T_PURCHASE_ID);
|
||||
gets_(b, T_BIZDATE, bizdate, sizeof(bizdate));
|
||||
EXEC SQL SELECT coalesce(sum(net),0) INTO :h_net FROM settlement WHERE purchase_id = :h_pid;
|
||||
if (sqlca.sqlcode < 0) FAIL(b);
|
||||
EXEC SQL UPDATE settlement SET status = 'CANCELLED' WHERE purchase_id = :h_pid;
|
||||
if (sqlca.sqlcode < 0) FAIL(b);
|
||||
adj = stdb_insert_adjust(0, h_pid, -h_net, "SETTLE_CANCEL", bizdate);
|
||||
if (adj < 0) FAIL(b);
|
||||
Bchg(b, T_STATUS, 0, "C", 0L);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* 25. ST_LEDGERLINK - 정산 연계 원장 기록. */
|
||||
void ST_LEDGERLINK(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
char bizdate[16];
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long h_pid, h_net;
|
||||
char h_bizdate[16];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
h_pid = getl(b, T_PURCHASE_ID); h_net = getl(b, T_NET);
|
||||
gets_(b, T_BIZDATE, bizdate, sizeof(bizdate));
|
||||
strncpy(h_bizdate, bizdate, sizeof(h_bizdate)-1); h_bizdate[sizeof(h_bizdate)-1] = 0;
|
||||
EXEC SQL INSERT INTO ledger (ledger_id, purchase_id, entry_type, amount, biz_date)
|
||||
VALUES (nextval('ledger_seq'), :h_pid, 'SETTLELINK', :h_net, :h_bizdate);
|
||||
if (sqlca.sqlcode < 0) FAIL(b);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* 26. ST_BANDRATE - 금액 구간 요율(bps) 조회 (dbio). */
|
||||
void ST_BANDRATE(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
char ftype[16];
|
||||
long amount = getl(b, T_AMOUNT), bps;
|
||||
gets_(b, T_STR1, ftype, sizeof(ftype)); if (ftype[0] == 0) strcpy(ftype, "MDR");
|
||||
bps = stdb_lookup_rate(ftype, amount);
|
||||
if (bps < 0) FAIL(b);
|
||||
setl(b, T_RC, bps);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* 27. ST_CAP - 수수료 상한 적용: 상한 초과분을 감액 조정 (dbio). */
|
||||
void ST_CAP(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
char bizdate[16];
|
||||
long sid = getl(b, T_SETTLE_ID), pid = getl(b, T_PURCHASE_ID);
|
||||
long fee = getl(b, T_FEE), cap = getl(b, T_ARG1), over, adj;
|
||||
gets_(b, T_BIZDATE, bizdate, sizeof(bizdate));
|
||||
if (cap <= 0) cap = 100000; /* 기본 상한 */
|
||||
if (fee > cap) {
|
||||
over = fee - cap;
|
||||
adj = stdb_insert_adjust(sid, pid, -over, "FEE_CAP", bizdate);
|
||||
if (adj < 0) FAIL(b);
|
||||
setl(b, T_FEE, cap);
|
||||
setl(b, T_DELTA, -over);
|
||||
} else {
|
||||
setl(b, T_DELTA, 0);
|
||||
}
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* 28. ST_FXCONV - 외화 환산: fx * rate/100 = KRW. */
|
||||
void ST_FXCONV(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
long fx = getl(b, T_FX_AMT), rate = getl(b, T_ARG1), krw;
|
||||
if (rate <= 0) rate = 1350; /* 13.50 KRW/unit (bps of 100) */
|
||||
krw = fx * rate / 100;
|
||||
setl(b, T_AMOUNT, krw);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* 29. ST_CONFIRM - 정산 확정 (SETTLED -> CONFIRMED). */
|
||||
void ST_CONFIRM(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long h_pid;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
h_pid = getl(b, T_PURCHASE_ID);
|
||||
EXEC SQL UPDATE settlement SET status = 'CONFIRMED'
|
||||
WHERE purchase_id = :h_pid AND status = 'SETTLED';
|
||||
if (sqlca.sqlcode < 0) FAIL(b);
|
||||
Bchg(b, T_STATUS, 0, "C", 0L);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* 30. ST_STATUS - 정산 상태 조회. */
|
||||
void ST_STATUS(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long h_pid;
|
||||
char h_status[16];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
h_pid = getl(b, T_PURCHASE_ID);
|
||||
EXEC SQL SELECT status INTO :h_status FROM settlement
|
||||
WHERE purchase_id = :h_pid ORDER BY settlement_id DESC LIMIT 1;
|
||||
if (sqlca.sqlcode < 0) FAIL(b);
|
||||
if (sqlca.sqlcode == 100) strcpy(h_status, "NONE");
|
||||
Bchg(b, T_STATUS, 0, h_status, 0L);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* vim: set ts=4 sw=4 et smartindent: */
|
||||
|
|
|
|||
21
app/src/st/svc/SETTLE.h
Normal file
21
app/src/st/svc/SETTLE.h
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* SETTLE.h - st 서비스 SETTLE 카피북 (copybook / record header).
|
||||
*
|
||||
*/
|
||||
#ifndef SETTLE_H
|
||||
#define SETTLE_H
|
||||
|
||||
#include "st_svc.h"
|
||||
|
||||
typedef struct {
|
||||
long purchase_id;
|
||||
char merchant_id[64];
|
||||
long amount;
|
||||
long net;
|
||||
char status[8];
|
||||
char biz_date[16];
|
||||
} st_settle_rec_t;
|
||||
|
||||
void SETTLE(TPSVCINFO *p);
|
||||
|
||||
#endif /* SETTLE_H */
|
||||
40
app/src/st/svc/SETTLE.pgc
Normal file
40
app/src/st/svc/SETTLE.pgc
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* SETTLE.pgc - st 모듈 서비스 SETTLE (one service = one file).
|
||||
* Moved verbatim from the former inline st_svr.pgc; runs on the caller's XA
|
||||
* branch (no EXEC SQL CONNECT). Advertised by st_svr at tpsvrinit.
|
||||
*/
|
||||
#include "SETTLE.h"
|
||||
|
||||
/* ========================================================================= */
|
||||
void SETTLE(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
char merch[64], bizdate[16];
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long h_pid, h_sid, h_net;
|
||||
char h_merch[64], h_bizdate[16];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
|
||||
h_pid = getl(b, T_PURCHASE_ID);
|
||||
h_net = getl(b, T_NET);
|
||||
gets_(b, T_MERCHANT, merch, sizeof(merch));
|
||||
gets_(b, T_BIZDATE, bizdate, sizeof(bizdate));
|
||||
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 nextval('settlement_seq') INTO :h_sid;
|
||||
if (sqlca.sqlcode < 0) FAIL(b);
|
||||
EXEC SQL INSERT INTO settlement (settlement_id, purchase_id, merchant_id, net, biz_date, status)
|
||||
VALUES (:h_sid, :h_pid, :h_merch, :h_net, :h_bizdate, 'SETTLED');
|
||||
if (sqlca.sqlcode < 0) { userlog("SETTLE INSERT settlement FAIL [%d] %s", sqlca.sqlcode, sqlca.sqlerrm.sqlerrmc); FAIL(b); }
|
||||
EXEC SQL INSERT INTO ledger (ledger_id, purchase_id, entry_type, amount, biz_date)
|
||||
VALUES (nextval('ledger_seq'), :h_pid, 'SETTLE', :h_net, :h_bizdate);
|
||||
if (sqlca.sqlcode < 0) FAIL(b);
|
||||
|
||||
setl(b, T_SETTLE_ID, h_sid);
|
||||
Bchg(b, T_STATUS, 0, "S", 0L);
|
||||
userlog("SETTLE pid=%ld settlement_id=%ld net=%ld", h_pid, h_sid, h_net);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* vim: set ts=4 sw=4 et smartindent: */
|
||||
21
app/src/st/svc/ST_ADJUST.h
Normal file
21
app/src/st/svc/ST_ADJUST.h
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* ST_ADJUST.h - st 서비스 ST_ADJUST 카피북 (copybook / record header).
|
||||
* 정산 조정 (가감) 기록 (dbio).
|
||||
*/
|
||||
#ifndef ST_ADJUST_H
|
||||
#define ST_ADJUST_H
|
||||
|
||||
#include "st_svc.h"
|
||||
|
||||
typedef struct {
|
||||
long purchase_id;
|
||||
char merchant_id[64];
|
||||
long amount;
|
||||
long net;
|
||||
char status[8];
|
||||
char biz_date[16];
|
||||
} st_st_adjust_rec_t;
|
||||
|
||||
void ST_ADJUST(TPSVCINFO *p);
|
||||
|
||||
#endif /* ST_ADJUST_H */
|
||||
23
app/src/st/svc/ST_ADJUST.pgc
Normal file
23
app/src/st/svc/ST_ADJUST.pgc
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* ST_ADJUST.pgc - st 모듈 서비스 ST_ADJUST (one service = one file).
|
||||
* Moved verbatim from the former inline st_svr.pgc; runs on the caller's XA
|
||||
* branch (no EXEC SQL CONNECT). Advertised by st_svr at tpsvrinit.
|
||||
*/
|
||||
#include "ST_ADJUST.h"
|
||||
|
||||
/* 8. ST_ADJUST - 정산 조정 (가감) 기록 (dbio). */
|
||||
void ST_ADJUST(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
char bizdate[16], reason[128];
|
||||
long sid = getl(b, T_SETTLE_ID), pid = getl(b, T_PURCHASE_ID);
|
||||
long delta = getl(b, T_DELTA), adj;
|
||||
gets_(b, T_BIZDATE, bizdate, sizeof(bizdate));
|
||||
gets_(b, T_REASON, reason, sizeof(reason)); if (reason[0] == 0) strcpy(reason, "ADJ");
|
||||
adj = stdb_insert_adjust(sid, pid, delta, reason, bizdate);
|
||||
if (adj < 0) FAIL(b);
|
||||
setl(b, T_ADJ, adj);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* vim: set ts=4 sw=4 et smartindent: */
|
||||
21
app/src/st/svc/ST_ADVANCE.h
Normal file
21
app/src/st/svc/ST_ADVANCE.h
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* ST_ADVANCE.h - st 서비스 ST_ADVANCE 카피북 (copybook / record header).
|
||||
* 선지급 예약: 지급 레코드(SCHEDULED) 생성 (dbio).
|
||||
*/
|
||||
#ifndef ST_ADVANCE_H
|
||||
#define ST_ADVANCE_H
|
||||
|
||||
#include "st_svc.h"
|
||||
|
||||
typedef struct {
|
||||
long purchase_id;
|
||||
char merchant_id[64];
|
||||
long amount;
|
||||
long net;
|
||||
char status[8];
|
||||
char biz_date[16];
|
||||
} st_st_advance_rec_t;
|
||||
|
||||
void ST_ADVANCE(TPSVCINFO *p);
|
||||
|
||||
#endif /* ST_ADVANCE_H */
|
||||
24
app/src/st/svc/ST_ADVANCE.pgc
Normal file
24
app/src/st/svc/ST_ADVANCE.pgc
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* ST_ADVANCE.pgc - st 모듈 서비스 ST_ADVANCE (one service = one file).
|
||||
* Moved verbatim from the former inline st_svr.pgc; runs on the caller's XA
|
||||
* branch (no EXEC SQL CONNECT). Advertised by st_svr at tpsvrinit.
|
||||
*/
|
||||
#include "ST_ADVANCE.h"
|
||||
|
||||
/* 9. ST_ADVANCE - 선지급 예약: 지급 레코드(SCHEDULED) 생성 (dbio). */
|
||||
void ST_ADVANCE(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
char merch[64], bizdate[16], paydate[16];
|
||||
long net = getl(b, T_NET), pay;
|
||||
gets_(b, T_MERCHANT, merch, sizeof(merch));
|
||||
gets_(b, T_BIZDATE, bizdate, sizeof(bizdate));
|
||||
gets_(b, T_KEY1, paydate, sizeof(paydate));
|
||||
if (paydate[0] == 0) { strncpy(paydate, bizdate, sizeof(paydate)-1); paydate[sizeof(paydate)-1] = 0; }
|
||||
pay = stdb_insert_payment(merch, net, paydate, "SCHEDULED", bizdate);
|
||||
if (pay < 0) FAIL(b);
|
||||
setl(b, T_ID1, pay);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* vim: set ts=4 sw=4 et smartindent: */
|
||||
21
app/src/st/svc/ST_BANDRATE.h
Normal file
21
app/src/st/svc/ST_BANDRATE.h
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* ST_BANDRATE.h - st 서비스 ST_BANDRATE 카피북 (copybook / record header).
|
||||
* 금액 구간 요율(bps) 조회 (dbio).
|
||||
*/
|
||||
#ifndef ST_BANDRATE_H
|
||||
#define ST_BANDRATE_H
|
||||
|
||||
#include "st_svc.h"
|
||||
|
||||
typedef struct {
|
||||
long purchase_id;
|
||||
char merchant_id[64];
|
||||
long amount;
|
||||
long net;
|
||||
char status[8];
|
||||
char biz_date[16];
|
||||
} st_st_bandrate_rec_t;
|
||||
|
||||
void ST_BANDRATE(TPSVCINFO *p);
|
||||
|
||||
#endif /* ST_BANDRATE_H */
|
||||
21
app/src/st/svc/ST_BANDRATE.pgc
Normal file
21
app/src/st/svc/ST_BANDRATE.pgc
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* ST_BANDRATE.pgc - st 모듈 서비스 ST_BANDRATE (one service = one file).
|
||||
* Moved verbatim from the former inline st_svr.pgc; runs on the caller's XA
|
||||
* branch (no EXEC SQL CONNECT). Advertised by st_svr at tpsvrinit.
|
||||
*/
|
||||
#include "ST_BANDRATE.h"
|
||||
|
||||
/* 26. ST_BANDRATE - 금액 구간 요율(bps) 조회 (dbio). */
|
||||
void ST_BANDRATE(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
char ftype[16];
|
||||
long amount = getl(b, T_AMOUNT), bps;
|
||||
gets_(b, T_STR1, ftype, sizeof(ftype)); if (ftype[0] == 0) strcpy(ftype, "MDR");
|
||||
bps = stdb_lookup_rate(ftype, amount);
|
||||
if (bps < 0) FAIL(b);
|
||||
setl(b, T_RC, bps);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* vim: set ts=4 sw=4 et smartindent: */
|
||||
21
app/src/st/svc/ST_BYMERCH.h
Normal file
21
app/src/st/svc/ST_BYMERCH.h
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* ST_BYMERCH.h - st 서비스 ST_BYMERCH 카피북 (copybook / record header).
|
||||
* 가맹점별 정산 집계 upsert (dbio).
|
||||
*/
|
||||
#ifndef ST_BYMERCH_H
|
||||
#define ST_BYMERCH_H
|
||||
|
||||
#include "st_svc.h"
|
||||
|
||||
typedef struct {
|
||||
long purchase_id;
|
||||
char merchant_id[64];
|
||||
long amount;
|
||||
long net;
|
||||
char status[8];
|
||||
char biz_date[16];
|
||||
} st_st_bymerch_rec_t;
|
||||
|
||||
void ST_BYMERCH(TPSVCINFO *p);
|
||||
|
||||
#endif /* ST_BYMERCH_H */
|
||||
31
app/src/st/svc/ST_BYMERCH.pgc
Normal file
31
app/src/st/svc/ST_BYMERCH.pgc
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* ST_BYMERCH.pgc - st 모듈 서비스 ST_BYMERCH (one service = one file).
|
||||
* Moved verbatim from the former inline st_svr.pgc; runs on the caller's XA
|
||||
* branch (no EXEC SQL CONNECT). Advertised by st_svr at tpsvrinit.
|
||||
*/
|
||||
#include "ST_BYMERCH.h"
|
||||
|
||||
/* 15. ST_BYMERCH - 가맹점별 정산 집계 upsert (dbio). */
|
||||
void ST_BYMERCH(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
char merch[64], bizdate[16];
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long h_cnt, h_gross, h_fee, h_net;
|
||||
char h_merch[64], h_bizdate[16];
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
gets_(b, T_MERCHANT, merch, sizeof(merch));
|
||||
gets_(b, T_BIZDATE, bizdate, sizeof(bizdate));
|
||||
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 count(*), coalesce(sum(p.amount),0), coalesce(sum(p.fee),0), coalesce(sum(s.net),0)
|
||||
INTO :h_cnt, :h_gross, :h_fee, :h_net
|
||||
FROM settlement s JOIN purchase p ON p.purchase_id = s.purchase_id
|
||||
WHERE s.merchant_id = :h_merch AND s.biz_date = :h_bizdate;
|
||||
if (sqlca.sqlcode < 0) FAIL(b);
|
||||
if (stdb_upsert_merch_settle(merch, bizdate, h_gross, h_fee, h_net, h_cnt) < 0) FAIL(b);
|
||||
setl(b, T_COUNT, h_cnt); setl(b, T_GROSS, h_gross);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* vim: set ts=4 sw=4 et smartindent: */
|
||||
21
app/src/st/svc/ST_CANCEL.h
Normal file
21
app/src/st/svc/ST_CANCEL.h
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* ST_CANCEL.h - st 서비스 ST_CANCEL 카피북 (copybook / record header).
|
||||
* 정산 취소: 상태 CANCELLED + 취소 조정 (dbio).
|
||||
*/
|
||||
#ifndef ST_CANCEL_H
|
||||
#define ST_CANCEL_H
|
||||
|
||||
#include "st_svc.h"
|
||||
|
||||
typedef struct {
|
||||
long purchase_id;
|
||||
char merchant_id[64];
|
||||
long amount;
|
||||
long net;
|
||||
char status[8];
|
||||
char biz_date[16];
|
||||
} st_st_cancel_rec_t;
|
||||
|
||||
void ST_CANCEL(TPSVCINFO *p);
|
||||
|
||||
#endif /* ST_CANCEL_H */
|
||||
29
app/src/st/svc/ST_CANCEL.pgc
Normal file
29
app/src/st/svc/ST_CANCEL.pgc
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* ST_CANCEL.pgc - st 모듈 서비스 ST_CANCEL (one service = one file).
|
||||
* Moved verbatim from the former inline st_svr.pgc; runs on the caller's XA
|
||||
* branch (no EXEC SQL CONNECT). Advertised by st_svr at tpsvrinit.
|
||||
*/
|
||||
#include "ST_CANCEL.h"
|
||||
|
||||
/* 24. ST_CANCEL - 정산 취소: 상태 CANCELLED + 취소 조정 (dbio). */
|
||||
void ST_CANCEL(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
char bizdate[16];
|
||||
long adj;
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long h_pid, h_net;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
h_pid = getl(b, T_PURCHASE_ID);
|
||||
gets_(b, T_BIZDATE, bizdate, sizeof(bizdate));
|
||||
EXEC SQL SELECT coalesce(sum(net),0) INTO :h_net FROM settlement WHERE purchase_id = :h_pid;
|
||||
if (sqlca.sqlcode < 0) FAIL(b);
|
||||
EXEC SQL UPDATE settlement SET status = 'CANCELLED' WHERE purchase_id = :h_pid;
|
||||
if (sqlca.sqlcode < 0) FAIL(b);
|
||||
adj = stdb_insert_adjust(0, h_pid, -h_net, "SETTLE_CANCEL", bizdate);
|
||||
if (adj < 0) FAIL(b);
|
||||
Bchg(b, T_STATUS, 0, "C", 0L);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* vim: set ts=4 sw=4 et smartindent: */
|
||||
21
app/src/st/svc/ST_CAP.h
Normal file
21
app/src/st/svc/ST_CAP.h
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* ST_CAP.h - st 서비스 ST_CAP 카피북 (copybook / record header).
|
||||
* 수수료 상한 적용: 상한 초과분을 감액 조정 (dbio).
|
||||
*/
|
||||
#ifndef ST_CAP_H
|
||||
#define ST_CAP_H
|
||||
|
||||
#include "st_svc.h"
|
||||
|
||||
typedef struct {
|
||||
long purchase_id;
|
||||
char merchant_id[64];
|
||||
long amount;
|
||||
long net;
|
||||
char status[8];
|
||||
char biz_date[16];
|
||||
} st_st_cap_rec_t;
|
||||
|
||||
void ST_CAP(TPSVCINFO *p);
|
||||
|
||||
#endif /* ST_CAP_H */
|
||||
29
app/src/st/svc/ST_CAP.pgc
Normal file
29
app/src/st/svc/ST_CAP.pgc
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* ST_CAP.pgc - st 모듈 서비스 ST_CAP (one service = one file).
|
||||
* Moved verbatim from the former inline st_svr.pgc; runs on the caller's XA
|
||||
* branch (no EXEC SQL CONNECT). Advertised by st_svr at tpsvrinit.
|
||||
*/
|
||||
#include "ST_CAP.h"
|
||||
|
||||
/* 27. ST_CAP - 수수료 상한 적용: 상한 초과분을 감액 조정 (dbio). */
|
||||
void ST_CAP(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
char bizdate[16];
|
||||
long sid = getl(b, T_SETTLE_ID), pid = getl(b, T_PURCHASE_ID);
|
||||
long fee = getl(b, T_FEE), cap = getl(b, T_ARG1), over, adj;
|
||||
gets_(b, T_BIZDATE, bizdate, sizeof(bizdate));
|
||||
if (cap <= 0) cap = 100000; /* 기본 상한 */
|
||||
if (fee > cap) {
|
||||
over = fee - cap;
|
||||
adj = stdb_insert_adjust(sid, pid, -over, "FEE_CAP", bizdate);
|
||||
if (adj < 0) FAIL(b);
|
||||
setl(b, T_FEE, cap);
|
||||
setl(b, T_DELTA, -over);
|
||||
} else {
|
||||
setl(b, T_DELTA, 0);
|
||||
}
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* vim: set ts=4 sw=4 et smartindent: */
|
||||
21
app/src/st/svc/ST_CONFIRM.h
Normal file
21
app/src/st/svc/ST_CONFIRM.h
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* ST_CONFIRM.h - st 서비스 ST_CONFIRM 카피북 (copybook / record header).
|
||||
* 정산 확정 (SETTLED -> CONFIRMED).
|
||||
*/
|
||||
#ifndef ST_CONFIRM_H
|
||||
#define ST_CONFIRM_H
|
||||
|
||||
#include "st_svc.h"
|
||||
|
||||
typedef struct {
|
||||
long purchase_id;
|
||||
char merchant_id[64];
|
||||
long amount;
|
||||
long net;
|
||||
char status[8];
|
||||
char biz_date[16];
|
||||
} st_st_confirm_rec_t;
|
||||
|
||||
void ST_CONFIRM(TPSVCINFO *p);
|
||||
|
||||
#endif /* ST_CONFIRM_H */
|
||||
23
app/src/st/svc/ST_CONFIRM.pgc
Normal file
23
app/src/st/svc/ST_CONFIRM.pgc
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* ST_CONFIRM.pgc - st 모듈 서비스 ST_CONFIRM (one service = one file).
|
||||
* Moved verbatim from the former inline st_svr.pgc; runs on the caller's XA
|
||||
* branch (no EXEC SQL CONNECT). Advertised by st_svr at tpsvrinit.
|
||||
*/
|
||||
#include "ST_CONFIRM.h"
|
||||
|
||||
/* 29. ST_CONFIRM - 정산 확정 (SETTLED -> CONFIRMED). */
|
||||
void ST_CONFIRM(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long h_pid;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
h_pid = getl(b, T_PURCHASE_ID);
|
||||
EXEC SQL UPDATE settlement SET status = 'CONFIRMED'
|
||||
WHERE purchase_id = :h_pid AND status = 'SETTLED';
|
||||
if (sqlca.sqlcode < 0) FAIL(b);
|
||||
Bchg(b, T_STATUS, 0, "C", 0L);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* vim: set ts=4 sw=4 et smartindent: */
|
||||
21
app/src/st/svc/ST_DELAYINT.h
Normal file
21
app/src/st/svc/ST_DELAYINT.h
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* ST_DELAYINT.h - st 서비스 ST_DELAYINT 카피북 (copybook / record header).
|
||||
* 지연이자(net * bps/10000 * 일수) 정산 상세 기록 (dbio).
|
||||
*/
|
||||
#ifndef ST_DELAYINT_H
|
||||
#define ST_DELAYINT_H
|
||||
|
||||
#include "st_svc.h"
|
||||
|
||||
typedef struct {
|
||||
long purchase_id;
|
||||
char merchant_id[64];
|
||||
long amount;
|
||||
long net;
|
||||
char status[8];
|
||||
char biz_date[16];
|
||||
} st_st_delayint_rec_t;
|
||||
|
||||
void ST_DELAYINT(TPSVCINFO *p);
|
||||
|
||||
#endif /* ST_DELAYINT_H */
|
||||
26
app/src/st/svc/ST_DELAYINT.pgc
Normal file
26
app/src/st/svc/ST_DELAYINT.pgc
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* ST_DELAYINT.pgc - st 모듈 서비스 ST_DELAYINT (one service = one file).
|
||||
* Moved verbatim from the former inline st_svr.pgc; runs on the caller's XA
|
||||
* branch (no EXEC SQL CONNECT). Advertised by st_svr at tpsvrinit.
|
||||
*/
|
||||
#include "ST_DELAYINT.h"
|
||||
|
||||
/* 10. ST_DELAYINT - 지연이자(net * bps/10000 * 일수) 정산 상세 기록 (dbio). */
|
||||
void ST_DELAYINT(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
char merch[64], bizdate[16];
|
||||
long sid = getl(b, T_SETTLE_ID), pid = getl(b, T_PURCHASE_ID);
|
||||
long net = getl(b, T_NET), days = getl(b, T_ARG1), bps = getl(b, T_ARG2), intr, dtl;
|
||||
gets_(b, T_MERCHANT, merch, sizeof(merch));
|
||||
gets_(b, T_BIZDATE, bizdate, sizeof(bizdate));
|
||||
if (days <= 0) days = 1;
|
||||
if (bps <= 0) bps = 15; /* 일 0.15% 기본 */
|
||||
intr = acq_fee(net, bps) * days;
|
||||
dtl = stdb_insert_fee_dtl(sid, pid, merch, "DELAYINT", intr, bizdate);
|
||||
if (dtl < 0) FAIL(b);
|
||||
setl(b, T_AMOUNT, intr);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* vim: set ts=4 sw=4 et smartindent: */
|
||||
21
app/src/st/svc/ST_DIFFCHK.h
Normal file
21
app/src/st/svc/ST_DIFFCHK.h
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* ST_DIFFCHK.h - st 서비스 ST_DIFFCHK 카피북 (copybook / record header).
|
||||
* 정산 net vs 매입 net 차이 점검.
|
||||
*/
|
||||
#ifndef ST_DIFFCHK_H
|
||||
#define ST_DIFFCHK_H
|
||||
|
||||
#include "st_svc.h"
|
||||
|
||||
typedef struct {
|
||||
long purchase_id;
|
||||
char merchant_id[64];
|
||||
long amount;
|
||||
long net;
|
||||
char status[8];
|
||||
char biz_date[16];
|
||||
} st_st_diffchk_rec_t;
|
||||
|
||||
void ST_DIFFCHK(TPSVCINFO *p);
|
||||
|
||||
#endif /* ST_DIFFCHK_H */
|
||||
26
app/src/st/svc/ST_DIFFCHK.pgc
Normal file
26
app/src/st/svc/ST_DIFFCHK.pgc
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* ST_DIFFCHK.pgc - st 모듈 서비스 ST_DIFFCHK (one service = one file).
|
||||
* Moved verbatim from the former inline st_svr.pgc; runs on the caller's XA
|
||||
* branch (no EXEC SQL CONNECT). Advertised by st_svr at tpsvrinit.
|
||||
*/
|
||||
#include "ST_DIFFCHK.h"
|
||||
|
||||
/* 18. ST_DIFFCHK - 정산 net vs 매입 net 차이 점검. */
|
||||
void ST_DIFFCHK(TPSVCINFO *p)
|
||||
{
|
||||
UBFH *b = (UBFH *)p->data;
|
||||
EXEC SQL BEGIN DECLARE SECTION;
|
||||
long h_pid, h_snet, h_pnet, h_diff;
|
||||
EXEC SQL END DECLARE SECTION;
|
||||
h_pid = getl(b, T_PURCHASE_ID);
|
||||
EXEC SQL SELECT coalesce(sum(net),0) INTO :h_snet FROM settlement WHERE purchase_id = :h_pid;
|
||||
if (sqlca.sqlcode < 0) FAIL(b);
|
||||
EXEC SQL SELECT net INTO :h_pnet FROM purchase WHERE purchase_id = :h_pid;
|
||||
if (sqlca.sqlcode < 0 || sqlca.sqlcode == 100) FAIL(b);
|
||||
h_diff = h_pnet - h_snet;
|
||||
setl(b, T_DELTA, h_diff);
|
||||
setl(b, T_RC, h_diff == 0 ? 0 : 1);
|
||||
OK(b);
|
||||
}
|
||||
|
||||
/* vim: set ts=4 sw=4 et smartindent: */
|
||||
21
app/src/st/svc/ST_FXCONV.h
Normal file
21
app/src/st/svc/ST_FXCONV.h
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* ST_FXCONV.h - st 서비스 ST_FXCONV 카피북 (copybook / record header).
|
||||
* 외화 환산: fx * rate/100 = KRW.
|
||||
*/
|
||||
#ifndef ST_FXCONV_H
|
||||
#define ST_FXCONV_H
|
||||
|
||||
#include "st_svc.h"
|
||||
|
||||
typedef struct {
|
||||
long purchase_id;
|
||||
char merchant_id[64];
|
||||
long amount;
|
||||
long net;
|
||||
char status[8];
|
||||
char biz_date[16];
|
||||
} st_st_fxconv_rec_t;
|
||||
|
||||
void ST_FXCONV(TPSVCINFO *p);
|
||||
|
||||
#endif /* ST_FXCONV_H */
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue