#!/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 py_filegen_batch py_result_batch py_merchsum_batch py_ledger_batch \
         py_daily_batch py_settle_batch py_stat_batch py_reject_report_batch \
         py_file_confirm_batch py_close_batch; do
    echo "--- $b $BIZDATE ---"
    "/app/bin/$b" "$BIZDATE" || exit 1
done
