---
# Business Logic — JKKKeiNewCmnLogicUtil.intrCdYkKigenChk() [32 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.web.webview.commonOneStop.JKKKeiNewCmnLogicUtil` |
| Layer | Utility (Common/Shared) |
| Module | `commonOneStop` (Package: `eo.web.webview.commonOneStop`) |

---

## 1. Role

### JKKKeiNewCmnLogicUtil.intrCdYkKigenChk()

This method performs **referral coupon (introduction code) validity period checking** — determining whether a previously recorded introduction code's expiration date has passed relative to a given business operation date. It retrieves a list of introduction code records from a search result map (`scResult`), iterates through each record, and compares the recorded expiration date (`yk_kigen_ymd`) against the operation date (`opeDate`). If the operation date exceeds the expiration date, the method returns `false` (the coupon is expired and no longer valid). If the operation date is on or before the expiration date, the method returns `true` (the coupon is still valid). As a fallback, if no records are found in the list (the list is null or empty), the method conservatively returns `true`, treating the absence of an expiration date as "no expiration applied" and thus valid. This utility is a shared component called by screen logic classes (e.g., KKW00101SFLogic, KKW00121SFLogic) as part of their input validation error-checking pipelines, ensuring that referral coupons presented during customer-facing operations have not expired.

---

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["intrCdYkKigenChk scResult, opeDate"])
    RETRIEVE["Retrieve dataList from scResult<br/>get EKK0311A010CBSMsg1List"]
    LIST_CHECK{dataList is null?}
    LOOP_EMPTY_RETURN["Return true<br/>(No records found,<br/>treat as valid)"]
    LOOP_START["Loop: i = 0; i < dataList.size()"]
    LOOP_INDEX_CHECK{i < dataList.size()}
    GET_ITEM["childMap = dataList.get(i)"]
    ITEM_NULL_CHECK{childMap is null?}
    NESTED_SKIP["Skip to next iteration"]
    EXPIRY_GET["Get yk_kigen_ymd from childMap"]
    EXPIRY_CHECK{yk_kigen_ymd<br/>is null or blank?}
    DATE_COMPARE["Compare opeDate.compareTo(yk_kigen_ymd)"]
    EXPIRY_GREATER{opeDate > yk_kigen_ymd?<br/>(operation past expiration)}
    RETURN_EXPIRED["Return false<br/>(Coupon expired)"]
    RETURN_VALID["Return true<br/>(Coupon still valid)"]
    NEXT_ITER["Increment i<br/>continue loop"]
    END_NODE(["Return true<br/>End"])

    START --> RETRIEVE
    RETRIEVE --> LIST_CHECK
    LIST_CHECK -- Yes --> LOOP_EMPTY_RETURN
    LIST_CHECK -- No --> LOOP_START
    LOOP_START --> LOOP_INDEX_CHECK
    LOOP_INDEX_CHECK -- Yes --> GET_ITEM
    LOOP_INDEX_CHECK -- No --> END_NODE
    GET_ITEM --> ITEM_NULL_CHECK
    ITEM_NULL_CHECK -- No --> EXPIRY_GET
    ITEM_NULL_CHECK -- Yes --> NESTED_SKIP
    EXPIRY_GET --> EXPIRY_CHECK
    EXPIRY_CHECK -- Yes --> NEXT_ITER
    EXPIRY_CHECK -- No --> DATE_COMPARE
    DATE_COMPARE --> EXPIRY_GREATER
    EXPIRY_GREATER -- Yes --> RETURN_EXPIRED
    EXPIRY_GREATER -- No --> RETURN_VALID
    RETURN_EXPIRED --> END_NODE
    RETURN_VALID --> END_NODE
    NESTED_SKIP --> NEXT_ITER
    NEXT_ITER --> LOOP_START
```

**Processing Summary:**

This method implements a **linear iteration with early-return** pattern over a collection of introduction code records. The core business rule is a date comparison: an introduction code is valid only when the operation date (`opeDate`) has not exceeded its recorded expiration date (`yk_kigen_ymd`). The method iterates through all records in the list and returns on the **first** valid or expired finding — it does not aggregate or validate all records. If no records exist (null or empty list), it defaults to `true`, assuming no expiration constraint has been set.

---

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `scResult` | `HashMap` | Search result map containing query results from CBS (Common Business Service) calls. Specifically expected to contain a key `"EKK0311A010CBSMsg1List"` that maps to an `ArrayList` of introduction code records. Each record is a `Map` containing fields such as `yk_kigen_ymd` (expiration date). |
| 2 | `opeDate` | `String` | Business operation date in `yyyyMMdd` string format (e.g., `"20260728"`). Represents the date of the current business transaction. Used as the reference point for comparing against each introduction code's expiration date. |

**External state / called utilities:**

| Name | Type | Business Description |
|------|------|---------------------|
| `JKKCommonUtil.isNull()` | Static utility | Null-check utility — determines whether the retrieved dataList is null before attempting iteration |
| `JKKStringUtil.isNullBlank()` | Static utility | Null-or-blank check utility — determines whether the `yk_kigen_ymd` field has a meaningful date value before performing comparison |

---

## 4. CRUD Operations / Called Services

This method performs **no direct database or entity operations**. It only reads from the provided `scResult` HashMap (which was pre-populated by other CBS/SC calls) and performs string comparisons. All method calls are utility-level null checks.

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `JKKCommonUtil.isNull` | JKKCommonUtil | - | Utility null-check on the dataList retrieved from scResult |
| - | `JKKStringUtil.isNullBlank` | JKKStringUtil | - | Utility null-or-blank check on the yk_kigen_ymd field of each introduction code record |

**Notes:**

- The `scResult` map is expected to be pre-populated by the CBS `EKK0311A010CBSMsg1List`, which is a message-level response containing introduction code records. The actual data retrieval for this list is performed by a separate CBS/SC call **outside** this method.
- This method is a pure validation check — it reads business data from a pre-fetched in-memory structure and returns a boolean validity result.

---

## 5. Dependency Trace

### Callers

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Caller:KKW00101SFLogic | `KKW00101SFLogic.checkKKW00114Error()` → `JKKKeiNewCmnLogicUtil.intrCdYkKigenChk()` | `isNullBlank [R] -` |
| 2 | Caller:KKW00121SFLogic | `KKW00121SFLogic.checkKKW00184Error()` → `JKKKeiNewCmnLogicUtil.intrCdYkKigenChk()` | `isNullBlank [R] -` |

**Notes:**

- Both callers are screen logic classes (`KKW*SFLogic`) that invoke this method as part of their **input validation error-checking** routines.
- `checkKKW00114Error()` in KKW00101SFLogic — validates the introduction code expiration during a specific screen's error-checking flow.
- `checkKKW00184Error()` in KKW00121SFLogic — same validation, a different screen context.
- No terminal SC/CRUD operations originate from this method; its terminal calls are only utility-level null checks (`isNullBlank`, `isNull`).

---

## 6. Per-Branch Detail Blocks

**Block 1** — [SET] `(retrieve dataList from scResult)` (L17983)

Retrieve the introduction code record list from the search result map using the CBS-specific key `EKK0311A010CBSMsg1List`.

| # | Type | Code |
|---|------|------|
| 1 | SET | `dataList = (ArrayList) scResult.get("EKK0311A010CBSMsg1List")` // Extract dataList from scResult using CBS message key |

**Key constant resolution:**

| Constant | Value | Business Meaning |
|----------|-------|-----------------|
| `EKK0311A010CBSMsg1List` | `"EKK0311A010CBSMsg1List"` | Search result list key — contains introduction code records returned by CBS `EKK0311A010` |

**Block 2** — [IF] `(dataList is null)` (L17985)

Check whether the retrieved dataList is null before attempting to iterate.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `JKKCommonUtil.isNull(dataList)` // Null-check utility call |

**Block 2.1** — [ELSE] `(dataList is not null)` (L17985)

Proceed with iteration over the introduction code records.

**Block 2.1.1** — [FOR LOOP] `(i = 0; i < dataList.size())` (L17987)

Iterate through each introduction code record in the list.

| # | Type | Code |
|---|------|------|
| 1 | SET | `int i = 0` // Initialize loop counter |
| 2 | SET | `i < dataList.size()` // Loop bound check |
| 3 | EXEC | `i++` // Increment loop counter (after each iteration) |

**Block 2.1.2** — [SET] `(retrieve childMap from dataList)` (L17989)

Get the current iteration's child map (introduction code record) from the list.

| # | Type | Code |
|---|------|------|
| 1 | SET | `childMap = (Map) dataList.get(i)` // Retrieve record as Map |

**Block 3** — [IF] `(childMap is null)` (L17991)

Check whether the current iteration's childMap is null before accessing its fields.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `if (childMap != null)` // Null-check on current record |

**Block 3.1** — [IF - ELSE] `(childMap != null)` (L17991)

The current record is valid — proceed to check its expiration date field.

**Block 3.1.1** — [IF] `(yk_kigen_ymd is null or blank)` (L17993)

Check whether the `yk_kigen_ymd` field (expiration date) has a meaningful value.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `JKKStringUtil.isNullBlank((String) childMap.get("yk_kigen_ymd"))` // Null-or-blank check on expiration date field |

**Key constant resolution:**

| Constant | Value | Business Meaning |
|----------|-------|-----------------|
| `yk_kigen_ymd` | `"yk_kigen_ymd"` | Expiration date field — the date (yyyyMMdd) until which the introduction code is valid |

**Block 3.1.1.1** — [ELSE] `(yk_kigen_ymd is not null or blank)` (L17993)

The expiration date exists — proceed to compare it with the operation date.

**Block 3.1.1.1.1** — [IF] `(opeDate.compareTo(yk_kigen_ymd) > 0)` (L17995)

Compare the operation date with the expiration date. If `opeDate > yk_kigen_ymd`, the operation date is after the expiration, meaning the coupon has expired.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `opeDate.compareTo((String) childMap.get("yk_kigen_ymd"))` // String-based date comparison: if > 0, opeDate is later than expiration |
| 2 | RETURN | `return false` // Expiry comment: 紹介コードの有効期限が運用日より前の場合 → "If the introduction code's validity period is before the operation date" |

**Business rule:** If the operation date is AFTER the expiration date (`opeDate > yk_kigen_ymd`), the introduction code is **expired** → return `false`.

**Block 3.1.1.1.2** — [ELSE] `(opeDate.compareTo(yk_kigen_ymd) <= 0)` (L17998)

The operation date is on or before the expiration date.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return true` // Coupon is still valid |

**Business rule:** If the operation date is on or BEFORE the expiration date, the introduction code is **valid** → return `true`.

**Block 4** — [ELSE - outer dataList null/empty check] (L17985)

If `dataList` is null (or the list is empty, since the loop would not execute), the method falls through to the final return.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return true` // No introduction code records found; treat as valid (no expiration constraint) |

**Block 5** — [FOR LOOP - else if no records matched] (L17987, implicit)

If the loop completes without any `yk_kigen_ymd` being found (all were null/blank), the method falls through to the final return.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return true` // All records had no expiration date; treat as valid |

---

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `intrCdYkKigenChk` | Method | Introduction Code (Referral Coupon) Validity Period Check — checks whether a referral coupon's expiration date has passed |
| `scResult` | Field/Parameter | Search Result — HashMap containing data returned from CBS (Common Business Service) queries |
| `EKK0311A010CBSMsg1List` | Constant | CBS Message List Key — the HashMap key used to store the list of introduction code records returned by CBS EKK0311A010 |
| `opeDate` | Field/Parameter | Operation Date — the business date (yyyyMMdd) of the current transaction being processed |
| `dataList` | Field | Data List — ArrayList of introduction code records retrieved from scResult |
| `childMap` | Field | Child Map — individual introduction code record (as a Map) extracted from dataList during iteration |
| `yk_kigen_ymd` | Field | Expiration Date (有効期限年月日) — the YYYYMMDD-formatted date until which the introduction code is valid. `yk` = 有効期限 (validity period), `kigen` = 期限 (deadline), `ymd` = Year-Month-Day |
| `yk_kigen` | Business term | 有効期限 (Valid Period / Expiration Date) — the date until which the introduction code can be used |
| JKKCommonUtil | Class | Common utility class providing null-check and other generic helper methods |
| JKKStringUtil | Class | String utility class providing null/blank checking methods |
| `isNull` | Method | Null-check utility — returns true if the given object is null |
| `isNullBlank` | Method | Null-or-blank check utility — returns true if the given string is null, empty, or blank |
| SFLogic | Class Suffix | Screen Logic — class containing the business logic for a specific screen operation (e.g., `KKW00101SFLogic`) |
| CBS | Acronym | Common Business Service — shared service layer component that encapsulates business logic and data access |
| SC | Acronym | Service Component — finer-grained service component that implements specific business operations, often called by CBS |
| HashMap | Type | Java Map implementation storing key-value pairs; used here as the search result container |
| ArrayList | Type | Java resizable array; used here to store the list of introduction code records |
