# Business Logic — JKKCallWrisvcAutoAplyUtil.callWrisvcAutoAply() [12 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `com.fujitsu.futurity.bp.custom.common.JKKCallWrisvcAutoAplyUtil` |
| Layer | Utility / Common Component (Package: `com.fujitsu.futurity.bp.custom.common`) |
| Module | `common` (Package: `com.fujitsu.futurity.bp.custom.common`) |

## 1. Role

### JKKCallWrisvcAutoAplyUtil.callWrisvcAutoAply()

This method performs **discount service automatic application processing** (割引サービス自動適用処理) for the Fujitsu Futurity billing/telecom platform. It acts as a thin utility wrapper that delegates all substantive logic to the Common Component `JKKWrisvcAutoAplyCC.execute()`, following a simple **delegation design pattern**. Its business purpose is to determine which discount services (e.g., Wi-Fi rental fee discount, plan change discount, early termination fee relief) apply to the current service line item based on the incoming request parameter map and apply them accordingly.

The method serves as a **shared utility** called by screen entry points (such as `JKKWrisvcAutoAplyGetSvcInfoCC.getSvcInfo()`) when the business process requires automatic discount service application. It uses a **routing/delegation** pattern — the actual branching logic (which discount type to apply) is handled inside `JKKWrisvcAutoAplyCC.execute()`, which internally evaluates flags like `wribDchsSkbtFlagList` and dispatches to handlers such as `executeWrisvcDchskmAutoSet`, `executeWrisvcDchskmAutoPlnChg`, `executeWrisvcDchskmAutoRls`, and others depending on which discount scenarios are active.

The `fixedText` parameter allows external callers to pass a fixed text string used for debug logging context within the CC execution. The method returns the same `param` object passed in, now potentially enriched with updated discount service information after the auto-application processing completes.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["callWrisvcAutoAply params"])
    STEP1["obj = new JKKWrisvcAutoAplyCC"]
    STEP2["JKKBpCommon.printBpDebugLog Start"]
    STEP3["obj.execute handle, param, fixedText"]
    STEP4["JKKBpCommon.printBpDebugLog End"]
    STEP5["return param"]

    START --> STEP1
    STEP1 --> STEP2
    STEP2 --> STEP3
    STEP3 --> STEP4
    STEP4 --> STEP5
```

**Processing Description:**

1. **Instantiate CC Object**: A new instance of `JKKWrisvcAutoAplyCC` is created. This Common Component encapsulates all the business logic for discount service automatic application, including mapping context creation, input validation, and dispatching to sub-handlers for each discount type.

2. **Log Start**: A debug log entry is emitted via `JKKBpCommon.printBpDebugLog()` recording that the `JKKWrisvcAutoAplyCC.execute()` method is starting.

3. **Delegate to CC**: The method delegates to `obj.execute(handle, param, fixedText)`. Inside this CC method, the following sub-steps occur:
   - A mapping context is instantiated (`JKKWrisvcAutoAplyCCMapper`) with the session handle, request parameter, operation date, system date, and fixed text.
   - Input data validation is performed (`chkCcMapInputData`) to ensure required fields are present in the CC mapping map.
   - If validation passes, multiple discount service sub-applications are executed in sequence:
     - `executeWrisvcDchskmAutoSet` — Wi-Fi rental discount auto-set
     - `executeWrisvcDchskmAutoPlnChg` — Wi-Fi rental discount auto-plan change
     - `executeWrisvcDchskmAutoRls` — Wi-Fi rental discount auto-release (two calls)
     - `executeWrisvcDchskmAutoRecover` — Wi-Fi rental discount auto-recovery
     - `executeWrisvcDchskmAutoCrsChg` — Wi-Fi rental discount auto-cross change
     - `executeWrisvcDchskmAutoCustPls` — Wi-Fi rental discount auto-customer plus
     - `executeWrisvcDchskmAutoCustSlt` — Wi-Fi rental discount auto-customer select
     - `executeWrisvcDchskmAutoBillPls` — Wi-Fi rental discount auto-bill plus
   - Each sub-handler checks the `wribDchsSkbtFlagList` to determine whether that specific discount operation should be applied.

4. **Log End**: A debug log entry records that `JKKWrisvcAutoAplyCC.execute()` has completed.

5. **Return Param**: The (potentially modified) request parameter map is returned to the caller.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `handle` | `SessionHandle` | Session handle carrying the database connection and transaction context. Used to access the persistent storage layer for reading/writing service contract and discount service entity data. |
| 2 | `param` | `IRequestParameterReadWrite` | Request parameter object containing the request parameter map with service information, discount service flags, and order details. This object is mutated during CC execution to include updated discount service application results. It carries fields such as service contract details, discount service type codes, and flag lists indicating which discounts are applicable. |
| 3 | `fixedText` | `String` | User-fixed text string used as a logging/context marker passed through to the CC's `execute` method. Used in debug logging to identify the caller or operation context. |

**External State Read:**

| Field | Source | Business Description |
|-------|--------|---------------------|
| `JKKBpCommon` | Static utility class | Provides debug logging via `printBpDebugLog()` |

## 4. CRUD Operations / Called Services

### Pre-computed evidence from code analysis graph:

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| CALL | `JKKBpCommon.printBpDebugLog` | - | - | Calls `printBpDebugLog` in `JKKBpCommon` (start log) |
| CALL | `JKKWrisvcAutoAplyCC.execute` | - | - | Delegates to CC execute — handles all discount service auto-application logic internally |
| CALL | `JKKBpCommon.printBpDebugLog` | - | - | Calls `printBpDebugLog` in `JKKBpCommon` (end log) |

### Detailed call analysis through CC.execute():

The `callWrisvcAutoAply` method itself does not directly access any SC Codes or DB tables — it delegates entirely to `JKKWrisvcAutoAplyCC.execute()`. However, the CC's `execute` method internally orchestrates the following operations:

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JKKWrisvcAutoAplyCCMapper` constructor | - | N/A (in-memory mapping context) | Creates a CC-SC mapping context with session handle, request parameters, operation date, and system date for subsequent SC calls |
| R | `chkCcMapInputData` | - | N/A (in-memory validation) | Validates that required fields exist in the CC mapping map before proceeding with discount service application |
| C/R/U | `executeWrisvcDchskmAutoSet` | - | Wi-Fi rental discount service entities | Applies automatic Wi-Fi rental fee discount set processing based on flag conditions |
| C/R/U | `executeWrisvcDchskmAutoPlnChg` | - | Wi-Fi rental discount service entities | Applies automatic Wi-Fi rental fee discount plan change processing |
| C/R/U | `executeWrisvcDchskmAutoRls` | - | Wi-Fi rental discount service entities | Applies automatic Wi-Fi rental fee discount release processing (called twice for different scenarios) |
| C/R/U | `executeWrisvcDchskmAutoRecover` | - | Wi-Fi rental discount service entities | Applies automatic Wi-Fi rental fee discount recovery processing |
| C/R/U | `executeWrisvcDchskmAutoCrsChg` | - | Wi-Fi rental discount service entities | Applies automatic Wi-Fi rental fee discount cross-change processing |
| C/R/U | `executeWrisvcDchskmAutoCustPls` | - | Wi-Fi rental discount service entities | Applies automatic Wi-Fi rental fee discount customer plus processing |
| C/R/U | `executeWrisvcDchskmAutoCustSlt` | - | Wi-Fi rental discount service entities | Applies automatic Wi-Fi rental fee discount customer select processing |
| C/R/U | `executeWrisvcDchskmAutoBillPls` | - | Wi-Fi rental discount service entities | Applies automatic Wi-Fi rental fee discount bill plus processing |

**Note:** The exact SC codes and entity/table names are embedded within each sub-handler method inside `JKKWrisvcAutoAplyCC`. These handlers operate on Wi-Fi rental discount service (Wi-Fi レンタル料割引サービス) related entity data. The specific database tables would include discount service contract tables and service line item tables, though the exact table names require deep inspection of the individual handler implementations.

## 5. Dependency Trace

### Pre-computed evidence from code analysis graph:

No screen/batch entry points found within 8 hops. Direct callers found: 1 methods.
Terminal operations from this method: `printBpDebugLog` [-], `execute` [-], `printBpDebugLog` [-]

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | CC:JKKWrisvcAutoAplyGetSvcInfoCC | `JKKWrisvcAutoAplyGetSvcInfoCC.getSvcInfo()` -> `JKKCallWrisvcAutoAplyUtil.callWrisvcAutoAply` | `execute [C/R/U/D] Wi-Fi rental discount service entities` |

**Caller Description:**

- **JKKWrisvcAutoAplyGetSvcInfoCC.getSvcInfo()** — This Common Component method retrieves service information for the Wi-Fi rental discount auto-application screen. It calls `callWrisvcAutoAply` to determine which discount services should be automatically applied to the current service line item, then returns the resulting service information including updated discount applicability flags.

## 6. Per-Branch Detail Blocks

**Block 1** — [NEW/ASSIGN] `obj = new JKKWrisvcAutoAplyCC()` (L43)

> Instantiates the Common Component that encapsulates all discount service automatic application logic.

| # | Type | Code |
|---|------|------|
| 1 | SET | `obj = new JKKWrisvcAutoAplyCC()` |

**Block 2** — [ASSIGN] `JKKBpCommon.printBpDebugLog(this.getClass(), "Start JKKWrisvcAutoAplyCC execute")` (L45)

> Emits a debug log entry indicating the start of the CC execute method. The log uses `this.getClass()` to identify the calling class and a fixed message string.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `JKKBpCommon.printBpDebugLog(this.getClass(), "Start JKKWrisvcAutoAplyCC execute")` |

**Block 3** — [CALL] `obj.execute(handle, param, fixedText)` (L47)

> Delegates to the Common Component's execute method. This is the core business logic call that:
> - Creates a CC-SC mapping context (`JKKWrisvcAutoAplyCCMapper`)
> - Validates input data (`chkCcMapInputData`)
> - Iterates through and applies all applicable discount service sub-applications based on flag conditions
>
> The param object is mutated in-place by the CC to include updated discount service information.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `obj.execute(handle, param, fixedText)` |

**Block 4** — [ASSIGN] `JKKBpCommon.printBpDebugLog(this.getClass(), "End JKKWrisvcAutoAplyCC execute")` (L49)

> Emits a debug log entry indicating the CC execute method has completed.

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `JKKBpCommon.printBpDebugLog(this.getClass(), "End JKKWrisvcAutoAplyCC execute")` |

**Block 5** — [RETURN] `return param` (L51)

> Returns the request parameter object (potentially modified by CC execution) to the caller. The param now contains updated discount service application results.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return param` |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `callWrisvcAutoAply` | Method | Discount Service Automatic Application — the core method name meaning "call Wi-Fi rental service auto-application" |
| `fixedText` | Parameter | Fixed text string — caller-provided string used for logging context and identification |
| `wribDchsSkbtFlagList` | Field | Wi-Fi rental discount benefit flag list — a list of boolean flags indicating which discount service operations are applicable |
| `executeWrisvcDchskmAutoSet` | Method | Wi-Fi rental discount auto-set — applies Wi-Fi rental fee discount setup processing |
| `executeWrisvcDchskmAutoPlnChg` | Method | Wi-Fi rental discount auto-plan change — applies plan change processing for Wi-Fi rental discount |
| `executeWrisvcDchskmAutoRls` | Method | Wi-Fi rental discount auto-release — releases (cancels) Wi-Fi rental discount |
| `executeWrisvcDchskmAutoRecover` | Method | Wi-Fi rental discount auto-recovery — restores previously released Wi-Fi rental discount |
| `executeWrisvcDchskmAutoCrsChg` | Method | Wi-Fi rental discount auto-cross change — applies cross-service change processing for Wi-Fi rental discount |
| `executeWrisvcDchskmAutoCustPls` | Method | Wi-Fi rental discount auto-customer plus — applies customer addition processing for Wi-Fi rental discount |
| `executeWrisvcDchskmAutoCustSlt` | Method | Wi-Fi rental discount auto-customer select — applies customer selection processing for Wi-Fi rental discount |
| `executeWrisvcDchskmAutoBillPls` | Method | Wi-Fi rental discount auto-bill plus — applies billing addition processing for Wi-Fi rental discount |
| JKKWrisvcAutoAplyCC | Class | Wi-Fi Rental Service Auto-Apply Common Component — the Common Component class containing the full discount service automatic application logic |
| JKKCallWrisvcAutoAplyUtil | Class | Wi-Fi Rental Service Auto-Apply Call Utility — the utility wrapper class for delegating to the CC |
| SessionHandle | Type | Session handle — carries database connection, transaction context, and session state across the application layer |
| IRequestParameterReadWrite | Type | Request parameter interface — read-write interface for passing request data between components via a parameter map |
| CC | Acronym | Common Component — a tier in the Fujitsu Futurity platform architecture that coordinates between screens and SC (Service Component) layers |
| SC | Acronym | Service Component — the business logic layer that handles specific domain operations and data access |
| CWIC | Abbreviation | (from class name prefix) Customer/Contract Wi-Fi Rental Service — domain prefix for Wi-Fi rental service related components |
| CSWK | Abbreviation | Contract Service Detail Work — related to service line item management |
| DCHSKM | Abbreviation | Discount Service/Kingaku (amount) — discount service monetary benefit processing |
| WRIB | Abbreviation | Wi-Fi Rental Information Base — data domain for Wi-Fi rental service information |
| DCHS | Abbreviation | Discount Service — discount-related service processing |
| BT | Abbreviation | Benefit/Telemeter — discount benefit processing |
| PLNCHG | Abbreviation | Plan Change — service plan modification processing |
| RLS | Abbreviation | Release — cancellation/reversal of a discount service |
| CRSCHG | Abbreviation | Cross Change — cross-service modification processing |
| CUSTPLS | Abbreviation | Customer Plus — customer addition processing |
| CUSTSLT | Abbreviation | Customer Select — customer selection/changing processing |
| BILLPLS | Abbreviation | Bill Plus — billing addition processing |
| opeDate | Field | Operation date — the business date for the current operation, retrieved via `getOpeDateCc` |
| sysDtm | Field | System date/time — current system date, retrieved via `JCCBPCommon.getSysDate()` |
| SKBT | Abbreviation | Service Benefit/Ticket — discount benefit/ticket processing |
