#!/bin/bash
##
## run_eod.sh - 일마감(EOD): 승인/한도 집계·반영 배치 일괄 실행.
## 운영 스크립트: Enduro/X + ECPG/XA 런타임 환경을 설정하고 배치/서비스를 실행.
##   Usage: run_eod.sh [BIZDATE] [MERCH] [AMOUNT] [PID]
##
set -e
. /app/conf/setapp.sh

BIZDATE="${1:-2026-07-19}"
MERCH="${2:-M0001}"
AMOUNT="${3:-1000000}"
PID="${4:-1}"

echo "[run_eod.sh] BIZDATE=$BIZDATE MERCH=$MERCH AMOUNT=$AMOUNT"
for b in au_daily_auth_batch au_summary_build_batch au_capture_sweep_batch \
         au_eod_reflect_batch au_settle_reflect_batch au_fraud_scan_batch \
         au_cancel_daily_batch au_decline_bucket_batch au_limit_reset_batch; do
    echo "--- $b $BIZDATE ---"
    "/app/bin/$b" "$BIZDATE" || exit 1
done
