다양화 Wave2: dbio 289 + common 120 고유화 + 프로그램 206개 EXEC SQL 심화
- dbio io(289): fetch/touch/total 시그니처 유지, SQL 바디를 JOIN/집계/커서/ upsert/DELETE 등 구조로 고유화 → 289/289 고유 - common cu(120): 유틸 시그니처 유지, Luhn/CRC/Zeller/BIN레인지/amortization/ netting 등 실 알고리즘으로 고유화 → 120/120 고유 - 심화: 실제 EXEC SQL 없던 프로그램에 SELECT/INSERT/UPDATE/커서+tx 추가 → online+batch 530/530 전부 실제 SQL 보유 - 전 코퍼스 프로그램 939/939 고유, 전체 docker make -j4 = EXIT 0, 958 오브젝트 - 임시 생성기 제거, inventory.json loc 실측 갱신 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
c3a0259e95
commit
93c3cb74af
1111 changed files with 31539 additions and 17258 deletions
|
|
@ -11,12 +11,14 @@
|
|||
* st_ol_0028.pgc - 프로모션 할인 정산 (ST_OL_0028) [tier=easy]
|
||||
*
|
||||
* 프로모션 할인요율(만분율)을 매출에 적용하여 할인액을 산출하되,
|
||||
* 프로모션 예산 한도(cap)를 상한으로 실 청구금액을 계산한다.
|
||||
* 프로모션 예산 한도(cap)를 상한으로 실 청구금액을 계산한다. 프로모션
|
||||
* 예산 마스터(st_promo)에서 요율/잔여예산을 조회하고 소진분을 차감한다.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "txcore.h"
|
||||
#include "txcore_dbio.h"
|
||||
#include "acq_util.h"
|
||||
#include "st_core.h"
|
||||
|
||||
|
|
@ -89,7 +91,7 @@ struct sqlca_t *ECPGget_sqlca(void);
|
|||
|
||||
#endif
|
||||
|
||||
#line 15 "app/online/st_ol_0028.pgc"
|
||||
#line 17 "app/online/st_ol_0028.pgc"
|
||||
|
||||
|
||||
|
||||
|
|
@ -103,8 +105,34 @@ static long st_fee_round(long amount, long rate_bp)
|
|||
|
||||
TX_SERVICE(ST_OL_0028, ctx)
|
||||
{
|
||||
/* exec sql begin declare section */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#line 31 "app/online/st_ol_0028.pgc"
|
||||
char h_promo [ 12 ] ;
|
||||
|
||||
#line 32 "app/online/st_ol_0028.pgc"
|
||||
long h_promo_bp ;
|
||||
|
||||
#line 33 "app/online/st_ol_0028.pgc"
|
||||
long h_remain_budget ;
|
||||
|
||||
#line 34 "app/online/st_ol_0028.pgc"
|
||||
long h_discount ;
|
||||
|
||||
#line 35 "app/online/st_ol_0028.pgc"
|
||||
long h_affected ;
|
||||
/* exec sql end declare section */
|
||||
#line 36 "app/online/st_ol_0028.pgc"
|
||||
|
||||
|
||||
char merch[16], promo[12];
|
||||
long amount = 0, promo_bp = 0, cap = 0, discount, charged;
|
||||
int budget_applied = 0;
|
||||
|
||||
tx_log(TX_LOG_INFO, "[ST_OL_0028] 프로모션 할인 정산 진입");
|
||||
|
||||
|
|
@ -117,6 +145,28 @@ TX_SERVICE(ST_OL_0028, ctx)
|
|||
tx_buf_getlong(ctx->in, "AMOUNT", &amount);
|
||||
tx_buf_getlong(ctx->in, "PROMOBP", &promo_bp);
|
||||
tx_buf_getlong(ctx->in, "CAP", &cap);
|
||||
|
||||
/* 프로모션 예산 조회 (요율/잔여예산) */
|
||||
strncpy(h_promo, promo, sizeof(h_promo) - 1);
|
||||
h_promo[sizeof(h_promo) - 1] = '\0';
|
||||
h_promo_bp = 0;
|
||||
h_remain_budget = 0;
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "select promo_bp , remain_budget from st_promo where promo_code = $1 ",
|
||||
ECPGt_char,(h_promo),(long)12,(long)1,(12)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
|
||||
ECPGt_long,&(h_promo_bp),(long)1,(long)1,sizeof(long),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_long,&(h_remain_budget),(long)1,(long)1,sizeof(long),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
|
||||
#line 62 "app/online/st_ol_0028.pgc"
|
||||
|
||||
if (sqlca.sqlcode == TX_SQL_OK) {
|
||||
if (promo_bp <= 0) promo_bp = h_promo_bp;
|
||||
if (cap <= 0) cap = h_remain_budget;
|
||||
budget_applied = 1;
|
||||
} else if (sqlca.sqlcode != TX_SQL_NOTFOUND) {
|
||||
TX_DBIO_LOG_ERR("SELECT st_promo");
|
||||
}
|
||||
if (promo_bp <= 0) promo_bp = 500; /* 5% 할인 */
|
||||
if (cap <= 0) cap = 10000; /* 프로모션 상한 1만원 */
|
||||
|
||||
|
|
@ -131,6 +181,31 @@ TX_SERVICE(ST_OL_0028, ctx)
|
|||
if (discount > cap) discount = cap;
|
||||
charged = amount - discount;
|
||||
|
||||
/* 예산 소진 반영 */
|
||||
if (budget_applied && discount > 0) {
|
||||
h_discount = discount;
|
||||
if (tx_begin() != TX_OK)
|
||||
tx_log(TX_LOG_WARN, "[ST_OL_0028] tx_begin 경고");
|
||||
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "update st_promo set remain_budget = remain_budget - $1 , upd_ts = now ( ) where promo_code = $2 and remain_budget >= $3 ",
|
||||
ECPGt_long,&(h_discount),(long)1,(long)1,sizeof(long),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_char,(h_promo),(long)12,(long)1,(12)*sizeof(char),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
|
||||
ECPGt_long,&(h_discount),(long)1,(long)1,sizeof(long),
|
||||
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
|
||||
#line 92 "app/online/st_ol_0028.pgc"
|
||||
|
||||
if (sqlca.sqlcode != TX_SQL_OK) {
|
||||
TX_DBIO_LOG_ERR("UPDATE st_promo 예산소진");
|
||||
tx_abort();
|
||||
} else {
|
||||
h_affected = sqlca.sqlerrd[2];
|
||||
tx_commit();
|
||||
if (h_affected == 0)
|
||||
tx_log(TX_LOG_WARN, "[ST_OL_0028] 예산부족 promo=%s", promo);
|
||||
}
|
||||
}
|
||||
|
||||
tx_buf_reset(ctx->out);
|
||||
tx_buf_sets(ctx->out, "RESPCODE", RESP_OK);
|
||||
tx_buf_sets(ctx->out, "MERCHID", merch);
|
||||
|
|
|
|||
Reference in a new issue