# Business Logic — JKKTicktUseSisakListUkCC.sisakReturnJudge() [72 LOC]

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

## 1. Role

### JKKTicktUseSisakListUkCC.sisakReturnJudge()

This method implements the **promotion return judgment logic** (施策返却判定処理) for the K-Opticom premium rule-based customer promotion system. Its business purpose is to determine whether a given promotion (施策) should be **returned** (i.e., declined or rolled back) based on the customer's current discount service contract status. Specifically, it evaluates two data sources: first, it queries the EO premium rule-based promotion application conditions list to establish which promotional discount service codes are applicable; then it queries the discount service contract list for the given service contract number and checks whether any overlapping contracts are in an active state (Accepted or In-Service-Progress). If a matching contract exists in an active state, the method returns `false`, indicating the promotion should **not** be returned (i.e., it is already in use). If no promotional conditions exist at all, it short-circuits and returns `false` immediately. If no conflicting active contracts are found after iterating through all discount service contracts, it returns `true`, permitting the promotion return. This method acts as a **shared utility** called during the "application object promotion list inquiry" screen flow to gate whether a selected promotion can be applied to or returned for the current customer contract.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["sisakReturnJudge start"])
    S1["SET result = true"]
    S2["SET wribSvcCd = BLANK"]
    S3["Build ekk3061b501In map"]
    S4["CALL callSC - EKK3061B501CBS"]
    S5["Extract ekk3061b501Msg1List"]
    C1{"No promotion
conditions?"}
    S6["SET result = false"]
    S7["RETURN false"]
    S8["Create wribSvcCdSet"]
    S9["for each promotion:
extract wrib_svc_cd"]
    S10["Build ekk0451b002In map"]
    S11["CALL callSC - EKK0451B002CBS"]
    S12["Extract ekk0451b002Msg1List"]
    S13["for each discount contract"]
    S14["GET wrib_svc_cd from contract"]
    C2{"Contract code in
promotion set?"}
    S15["GET wrib_svc_kei_stat"]
    C3{"Status is ACCEPTED=010
or PROGRESS=100?"}
    S16["SET result = false"]
    S17["break loop"]
    S18["RETURN result"]

    START --> S1 --> S2 --> S3 --> S4 --> S5 --> C1
    C1 -- Yes --> S6 --> S7
    C1 -- No --> S8 --> S9 --> S10 --> S11 --> S12 --> S13 --> S14 --> C2
    C2 -- Yes --> S15 --> C3
    C3 -- Yes --> S16 --> S17 --> S18
    C2 -- No --> S18
    C3 -- No --> S13
    S17 --> S18
```

**CRITICAL — Constant Resolution:**

| Constant | Actual Value | Business Meaning |
|----------|-------------|-----------------|
| `EKK3061B501CBSMsg.FUNC_CODE` | `"1"` | Function code for inquiry mode (List Up / 上) |
| `EKK3061B501CBSMsg.KEY_EOPRMCL_SSKSSJK_SBT_CD` | `"00"` | EO Premium Rule Promotion Application Condition Type Code — filter by code "00" |
| `EKK3061B501CBSMsg.KEY_SSKSSJK_KSITEI_CD` | (variable) | Promotion Application Condition Individual Specification Code — passed via `sskssjkKsiteiCd` |
| `TEMPLATE_ID_EKK3061B501` | `"EKK3061B501"` | Template ID for EO Premium Rule Promotion Condition List Inquiry CBS |
| `EKK0451B002CBSMsg.FUNC_CODE` | `"1"` | Function code for inquiry mode (List Up / 上) |
| `EKK0451B002CBSMsg.KEY_SVC_KEI_NO` | (variable) | Service Contract Number — passed via `svcKeiNo` |
| `TEMPLATE_ID_EKK0451B002` | `"EKK0451B002"` | Template ID for Discount Service Contract List Inquiry CBS |
| `BLANK` | `""` | Empty string constant |
| `JKKSvcConst.WRIB_SVC_KEI_STAT_ACCEPTED` | `"010"` | Discount service contract status: Accepted (受注済) |
| `JKKSvcConst.WRIB_SVC_KEI_STAT_PROGRESS` | `"100"` | Discount service contract status: In Service Progress (サービス提供中) |

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `handle` | `SessionHandle` | Session handle carrying the database session context and user authentication state for the CBS call. |
| 2 | `param` | `IRequestParameterReadWrite` | Request parameter object used to pass and receive request/response data during the CBS invocation. |
| 3 | `fixedText` | `String` | User-defined string (ユーザ定義文字列) — passed through to the CBS layer, typically for logging or customization context. |
| 4 | `scCall` | `ServiceComponentRequestInvoker` | Service Component Request Invoker used to delegate CBS calls via the `callSC` wrapper method. |
| 5 | `sskssjkKsiteiCd` | `String` | Promotion Application Condition Individual Specification Code (施策申請条件個別指定コード) — identifies the specific promotion condition profile to query from the EO premium rule system. |
| 6 | `svcKeiNo` | `String` | Service Contract Number (サービス契約番号) — identifies the customer's service contract whose discount service contract list is evaluated for active status. |

**Instance Fields Read:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `TEMPLATE_ID_EKK3061B501` | `String` | Template ID used for the EKK3061B501 CBS call ("EKK3061B501"). |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `callSC` | EKK3061B501CBS | EO Premium Rule Promotion Condition List (EKK3061) | Calls the EO premium rule-based promotion application condition list inquiry CBS to retrieve applicable promotional discount service codes for the given condition spec. |
| R | `callSC` | EKK0451B002CBS | Discount Service Contract List (EKK0451) | Calls the discount service contract list inquiry CBS to retrieve all discount service contracts associated with the given service contract number. |
| R | `CAANMsg.getString` | - | - | Reads `wrib_svc_cd` (割引サービスコード) from EKK3061B501CBSMsg1List rows. |
| R | `CAANMsg.getString` | - | - | Reads `wrib_svc_cd` (割引サービスコード) from EKK0451B002CBSMsg1List rows. |
| R | `CAANMsg.getString` | - | - | Reads `wrib_svc_kei_stat` (割引サービス種別ステータス) from EKK0451B002CBSMsg1List rows. |
| R | `EKK3061B501CBSMsg.getContents` | - | - | Schema retrieval for EKK3061B501CBS input/output field definitions. |
| R | `EKK0451B002CBSMsg.getContents` | - | - | Schema retrieval for EKK0451B002CBS input/output field definitions. |

## 5. Dependency Trace

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

No screen/batch entry points found within 8 hops. Direct callers found: 1 methods.

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Controller:JKKTicktUseSisakListUkCC | `JKKTicktUseSisakListUkCC.searchTicktUseSisakList` -> `sisakReturnJudge` | `callSC [R] EKK3061B501CBS EO Premium Rule Promotion Conditions` |
| 1 | Controller:JKKTicktUseSisakListUkCC | `JKKTicktUseSisakListUkCC.searchTicktUseSisakList` -> `sisakReturnJudge` | `callSC [R] EKK0451B002CBS Discount Service Contracts` |

## 6. Per-Branch Detail Blocks

**Block 1** — Initialization (L637)

> Initializes local variables and result flag before processing.

| # | Type | Code |
|---|------|------|
| 1 | SET | `result = true` // Default result is true (promotion CAN be returned) |
| 2 | SET | `wribSvcCd = BLANK` // Initialize discount service code variable [-> BLANK=""] |

**Block 2** — Build Input Map for Promotion Condition List Inquiry (L641–648)

> Constructs the input map for the EO premium rule-based promotion application condition list inquiry CBS (EKK3061B501CBS), preparing the template ID, function code, promotion type code, and individual specification code.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ekk3061b501In` = new Object[][] containing {TEMPLATEID, TEMPLATE_ID_EKK3061B501} [-> "EKK3061B501"] |
| 2 | SET | `ekk3061b501In` = {FUNC_CODE, "1"} // Function code = "1" (List Up) |
| 3 | SET | `ekk3061b501In` = {KEY_EOPRMCL_SSKSSJK_SBT_CD, "00"} // Promotion condition type code = "00" |
| 4 | SET | `ekk3061b501In` = {KEY_SSKSSJK_KSITEI_CD, sskssjkKsiteiCd} // Individual spec code from parameter |

**Block 3** — Execute Promotion Condition List Inquiry CBS (L651–653)

> Calls the EO premium rule promotion application condition list CBS and extracts the result list.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `callSC(handle, scCall, param, fixedText, ekk3061b501In, new EKK3061B501CBSMsg().getContents())` // EO Premium Rule Promotion Condition List Inquiry |
| 2 | SET | `ekk3061b501Msg1List` = result.getCAANMsgList(EKK3061B501CBSMsg.EKK3061B501CBSMSG1LIST) // Extract the promotion conditions list |

**Block 4** — [IF] No Promotion Conditions (L656–660)

> If the promotion conditions list is null or empty, there are no applicable promotions to evaluate, so return false immediately.

| # | Type | Code |
|---|------|------|
| 1 | SET | `result = false` // No conditions available, cannot make a determination |
| 2 | RETURN | `result` // Return false — no promotion conditions exist |

**Block 5** — [ELSE] Extract Discount Service Codes from Promotion Conditions (L663–670)

> Iterates through the promotion conditions list to build a Set of discount service codes (`wrib_svc_cd`) that are eligible for this promotion. This set will be used to cross-reference against the customer's actual discount service contracts.

| # | Type | Code |
|---|------|------|
| 1 | SET | `wribSvcCdSet` = new HashSet<String>() // Create set to hold eligible discount service codes |
| 2 | SET | `for (CAANMsg ekk3061b501 : ekk3061b501Msg1List)` // Loop through each promotion condition |
| 3 | SET | `wribSvcCd` = `ekk3061b501.getString("wrib_svc_cd")` // Get discount service code from promotion condition |
| 4 | EXEC | `wribSvcCdSet.add(wribSvcCd)` // Add to the eligible set |

**Block 6** — Build Input Map for Discount Service Contract List Inquiry (L673–678)

> Constructs the input map for the discount service contract list inquiry CBS (EKK0451B002), preparing the template ID, function code, and service contract number.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ekk0451b002In` = new Object[][] containing {TEMPLATEID, TEMPLATE_ID_EKK0451B002} |
| 2 | SET | `ekk0451b002In` = {FUNC_CODE, "1"} // Function code = "1" (List Up) |
| 3 | SET | `ekk0451b002In` = {KEY_SVC_KEI_NO, svcKeiNo} // Service contract number from parameter |

**Block 7** — Execute Discount Service Contract List Inquiry CBS (L681–682)

> Calls the discount service contract list CBS and iterates over the results.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `callSC(handle, scCall, param, fixedText, ekk0451b002In, new EKK0451B002CBSMsg().getContents())` // Discount Service Contract List Inquiry |
| 2 | SET | `ekk0451b002Msg1List` = result.getCAANMsgList(EKK0451B002CBSMsg.EKK0451B002CBSMSG1LIST) // Extract discount contracts list |
| 3 | SET | `for (CAANMsg ekk0451b002Msg : ekk0451b002Msg1List)` // Loop through each discount service contract |

**Block 8** — [IF-NESTED] Contract Code Exists in Promotion Set (L685–686)

> Checks if the discount service code from the customer's contract matches any code in the promotion's eligible set.

| # | Type | Code |
|---|------|------|
| 1 | SET | `wribSvcCd` = `ekk0451b002Msg.getString("wrib_svc_cd")` // Get discount service code from contract |
| 2 | IF | `wribSvcCdSet.contains(wribSvcCd)` // Contract's discount service code is in the promotion set |

**Block 9** — [IF-NESTED-2] Contract Status is Active (L689–697)

> If the overlapping contract exists, check whether it is in an active state (Accepted or In-Service-Progress). If so, the promotion should NOT be returned.

| # | Type | Code |
|---|------|------|
| 1 | SET | `wribSvcKeiStat` = `ekk0451b002Msg.getString("wrib_svc_kei_stat")` // Get contract status |
| 2 | IF | `JKKSvcConst.WRIB_SVC_KEI_STAT_ACCEPTED.equals(wribSvcKeiStat)` [-> "010" 受注済] **OR** `JKKSvcConst.WRIB_SVC_KEI_STAT_PROGRESS.equals(wribSvcKeiStat)` [-> "100" サービス提供中] |
| 3 | SET | `result = false` // Contract is active, do NOT return the promotion |
| 4 | EXEC | `break` // Exit the for loop early — no need to check further |

**Block 10** — [FINAL] Return Result (L699)

> Returns the judgment result. `true` means the promotion can be returned (no active conflicts found); `false` means the promotion should not be returned (either no conditions existed, or an active contract was found).

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `result` // false if no conditions or active contract found; true otherwise |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `sisakReturnJudge` | Method | Promotion return judgment — determines whether a promotion should be returned (declined) based on contract status |
| `sskssjkKsiteiCd` | Field | Promotion Application Condition Individual Specification Code (施策申請条件個別指定コード) — uniquely identifies a specific promotion condition profile |
| `svcKeiNo` | Field | Service Contract Number (サービス契約番号) — the customer's service contract identifier used to look up discount contracts |
| `wrib_svc_cd` | Field | Discount Service Code (割引サービスコード) — identifies a specific discounted service type |
| `wrib_svc_kei_stat` | Field | Discount Service Contract Status (割引サービス種別ステータス) — current state of a discount service contract |
| `WRIB_SVC_KEI_STAT_ACCEPTED` | Constant | Discount service status: "010" — Accepted (受注済), meaning the order has been received and confirmed |
| `WRIB_SVC_KEI_STAT_PROGRESS` | Constant | Discount service status: "100" — In Service Progress (サービス提供中), meaning the service is actively being provided |
| `WRIB_SVC_KEI_STAT_APPLIED` | Constant | Discount service status: "300" — Applied (適用済), meaning the discount has been fully applied |
| `EKK3061B501CBS` | CBS | EO Premium Rule Promotion Application Condition List Inquiry — retrieves applicable promotion conditions from the EO premium rule engine |
| `EKK0451B002CBS` | CBS | Discount Service Contract List Inquiry — retrieves discount service contracts for a given service contract number |
| EO | Business term | Enterprise Operations — Fujitsu's telecom operations support system platform |
| Premium Rule | Business term | Rule-based premium/discount engine that determines applicable promotions for customers |
| 施策 (Shisaku) | Japanese term | Promotion/Promotional measure — a marketing or pricing promotion offered to customers |
| 返却 (Henkyaku) | Japanese term | Return — in this context, the action of returning/declining a promotion for a customer |
| 割引 (Waribiki) | Japanese term | Discount — a reduced-price service offering |
| サービス契約 (Saabisu Keiyaku) | Japanese term | Service Contract — the agreement between the customer and the telecom provider |
| 受注済 (Juchu-zumi) | Japanese term | Accepted — order has been received and confirmed |
| サービス提供中 (Saabisu Teikyou-chuu) | Japanese term | In Service Progress — the service is currently being actively delivered to the customer |
| callSC | Method | Central service component call wrapper that delegates CBS invocations with template and parameter handling |
| CAANMsg | Class | Common Application Abstract Network Message — the message object returned by CBS calls containing typed fields |
| FUNC_CODE | Field | Function code parameter — "1" indicates inquiry/list-up mode |
| TEMPLATEID | Field | Template ID for CBS schema identification — links the input/output to the correct CBS definition |
| SET_ID | — | — |
