# Business Logic — JKKSeikySakiHeigoCC.seikySakiHeigo() [517 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `com.fujitsu.futurity.bp.custom.common.JKKSeikySakiHeigoCC` |
| Layer | Common Component (CC) — shared business logic component |
| Module | `common` (Package: `com.fujitsu.futurity.bp.custom.common`) |

## 1. Role

### JKKSeikySakiHeigoCC.seikySakiHeigo()

This method is the core orchestration component for **consolidated billing address processing** (請求先情報統合処理) within the K-Opticom customer base system (eo customer main system). It processes a batch of service contracts to merge them under a single billing address, performing all necessary service contract registrations, cancellations, fee code agreements, and instructional document management that a billing consolidation entails.

The method handles multiple service categories based on the service contract status (stateCd) and service code (svc_cd): FTTH fiber services, electricity services (handled via the JKKStrConst.CD00130_05 constant), TV services (K-CAT, KCN), network mansion services, and NHK group-bundled services. It branches based on the order content code (func_code): "1" means the main processing path (contract execution), "2" means confirmation mode (reservation date verification), and any other value triggers CIC (Credit Information Center) reference checks and non-routine integration processing.

The method implements a **dispatch/routing design pattern**: it iterates over a list of service contract detail items (KKSV0546CCList) and, for each item, routes processing to specialized Service Component (SC) methods — content approval registration (EKK0011D020), billing advance contract change (EKK0321C020), ops contract agreement/cancel/terminate (EKK0441A010/C210/C230/C240), fee code agreement (EKK0791A010), instruction document registration (ECK0151D010), work project changes (EKU0021C010/EKU0031C010/EKU0041C010/EKU0061C010), advance registration (EKK1091D010), contract agreement/change (EKK0491A010/EKK0491C060), and post-inspection (EKK0021C060).

It serves as a **shared utility component** called exclusively by the KKSV0546 screen operation (KKSV0546OPOperation), which is the "Billing Address Information Consolidation Update" screen. The method is the single entry point that coordinates all downstream service contract lifecycle changes required to consolidate multiple billing addresses into one.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["seikySakiHeigo Start"])

    START --> INIT["Extract ccMsg / Init scCall"]
    INIT --> LSET["Load variables: futureFlg, ido_div, etc."]
    LSET --> JUDGE["Init JUDGE_UPDATE_MAP / svcKeiList"]
    JUDGE --> FORSTART["FOR each childMap in svc_list"]

    FORSTART --> UKSTATE{ukState check}
    UKSTATE --> |true| EKKA020["execEKK0011D020<br/>Content Approval"]
    UKSTATE --> |false| BR1DONE["Set mskmNo from childMap"]
    EKKA020 --> BR1DONE
    BR1DONE --> FUNC1A["Check func_code = 1"]
    FUNC1A --> |true| EKKB010["execEKK0321C020<br/>Billing Contract Change"]
    FUNC1A --> |false| LASTCHK["Last iteration check"]
    EKKB010 --> LASTCHK

    LASTCHK --> |no| FORNEXT["Next svc_list iteration"]
    LASTCHK --> |yes| SEIOPCHECK{"seiOpKeiNo exists<br/>and count = 1?"}

    SEIOPCHECK --> |no| NOOPFLOW["No ops processing"]
    SEIOPCHECK --> |yes| EKKA100["execEKK0441A010<br/>Ops Contract Agreement"]

    EKKA100 --> SEIOPSTATE{"seiOpKeiState = 010<br/>or 020?"}
    SEIOPSTATE --> |true| NHKCHK{"seiOpSvcCd != E002?"}
    NHKCHK --> |yes| EKKC110["execEKK0441C210<br/>Ops Contract Cancel"]
    NHKCHK --> |no| NOCANCEL
    EKKC110 --> NOCANCEL
    SEIOPSTATE --> |false| MTFLGCHK{"futureFlg = 1?"}
    MTFLGCHK --> |yes| NETCHK["hasNetSvcKeiFromSeikyKei"]
    NETCHK --> MTEXIST{"mtNetKeiExistFlg?"}
    MTFLGCHK --> |no| MTEXIST
    MTEXIST --> |no| SVCEND["Set svc_chrg_endymd"]
    MTEXIST --> |yes| NOOPFLOW
    SVCEND --> NHKCHK2{"seiOpSvcCd != E002?"}
    NHKCHK2 --> |yes| EKKC130["execEKK0441C230<br/>Ops Contract Termination"]
    NHKCHK2 --> |no| NOOPFLOW
    EKKC130 --> FUNC1B["Check func_code = 1"]
    FUNC1B --> |true| EKKC140["execEKK0441C240<br/>Cancel Confirm"]
    FUNC1B --> |false| NOOPFLOW
    EKKC140 --> NOOPFLOW
    NOCANCEL --> NOOPFLOW

    NOOPFLOW --> NON99{"prcgrpcd != 99?"}
    NON99 --> |yes| FUTURECHK{"futureFlg != 1<br/>and stateCd != 010?"}
    FUTURECHK --> |true| EKKA310["execEKK0791A010<br/>Fee Code Agreement"]
    FUTURECHK --> |false| KOJICHECK{"kojiakno != null?"}
    EKKA310 --> IDCHK{"id_tchisho<br/>h_hak_skbt_cd != 0?"}
    IDCHK --> |true| EKCD010["execECK0151D010<br/>Instruction Registration"]
    IDCHK --> |false| KOJICHECK
    EKCD010 --> KOJICHECK

    KOJICHECK --> |yes| PRCBRANCH{"prcgrp code check"}
    PRCBRANCH --> |02 or 10+no_mansion| EKU0021["execEKU0021C010<br/>Net changes"]
    PRCBRANCH --> |11 or 13| EKU0031["execEKU0031C010<br/>TV changes"]
    PRCBRANCH --> |12| EKU0041["execEKU0041C010<br/>TV wire changes"]
    PRCBRANCH --> |03 or 04 or 10+mansion| EKU0061["execEKU0061C010<br/>Mansion net changes"]
    PRCBRANCH --> |default| FWDCHK
    EKU0021 --> FWDCHK
    EKU0031 --> FWDCHK
    EKU0041 --> FWDCHK
    EKU0061 --> FWDCHK
    KOJICHECK --> |no| FWDCHK

    FWDCHK{"forward integration<br/>and mtSvcCD != 0?"}
    FWDCHK --> |no| POSTREG{"ukState?"}
    FWDCHK --> |yes| NETCHK2{"hasNetSvcKeiFromSeikyKei?"}
    NETCHK2 --> |no| EKKA091["execEKK0491A010<br/>Contract Agreement"]
    NETCHK2 --> |yes| POSTREG
    EKKA091 --> FUNC1C["Check func_code = 1"]
    FUNC1C --> |true| EKKC060["execEKK0491C060<br/>Contract Change"]
    FUNC1C --> |false| POSTREG
    EKKC060 --> POSTREG

    POSTREG --> |yes| EKKG010["execEKK1091D010 x2<br/>Advance Registration"]
    POSTREG --> |no| POSTCHK{"mskmFlg &&<br/>!sintyokuFlg?"}
    EKKG010 --> POSTCHK

    POSTCHK --> |true| POSTUK{"ukState &&<br/>func_code = 1?"}
    POSTUK --> |true| EKKA110["execEKK0021C060<br/>Post Inspection"]
    POSTUK --> |false| POSTCHKDONE
    POSTCHK --> |false| POSTCHKDONE
    EKKA110 --> POSTCHKDONE

    POSTCHKDONE --> UPDATECHK{"func_code = 1?"}
    UPDATECHK --> |true| AUTOCHK{"!autoAplyFlg?"}
    AUTOCHK --> |true| EXECUPDATE["execSeikyuUpdCall<br/>Billing Update"]
    AUTOCHK --> |false| NEWCONTRACT
    EXECUPDATE --> NEWCONTRACT

    NEWCONTRACT{"ido_div = 00001<br/>or 00002?"}
    NEWCONTRACT --> |yes| UPDMKMSUP["updMkmScinsprtWkCall<br/>Inspection Support"]
    NEWCONTRACT --> |no| FORNEXT
    UPDMKMSUP --> FORNEXT

    FORNEXT --> FOREND{"More items?"}
    FOREND --> |yes| FORSTART
    FOREND --> |no| FORCLOSE["End FOR loop"]

    FORCLOSE --> DISCOUNTCHK{"func_code = 1<br/>and !futureFlg?"}
    DISCOUNTCHK --> |yes| EXECWRISVC["execWrisvcAutoAplyHeigo<br/>Discount Processing"]
    DISCOUNTCHK --> |no| JUDGECHK
    EXECWRISVC --> JUDGECHK

    JUDGECHK{"func_code = 1<br/>and new contract?"}
    JUDGECHK --> |yes| EXECUPDATEJ["execUpdateJudge<br/>Judge Update"]
    JUDGECHK --> |no| CANCELCHECK
    EXECUPDATEJ --> CANCELCHECK

    CANCELCHECK{"func_code != 1<br/>count = 1<br/>state 010/020?"}
    CANCELCHECK --> |yes| EXECWRISVCCANC["execWrisvcAutoAply...05<br/>Cancel IF discount"]
    CANCELCHECK --> |no| CANCELCHECK2
    CANCELCHECK2{"else state?"}
    CANCELCHECK2 --> |yes| EXECWRISVCCANC2["execWrisvcAutoAply...03<br/>Termination IF discount"]
    CANCELCHECK2 --> |no| CICCHK
    EXECWRISVCCANC --> CICCHK
    EXECWRISVCCANC2 --> CICCHK

    CICCHK{"func_code != 1?"}
    CICCHK --> |yes| CICCHK1["exec EKK2951A010<br/>Moto CIC check"]
    CICCHK1 --> CICCHK2["exec EKK2951A010<br/>Saki CIC check"]
    CICCHK2 --> CICFLG["Set cic_chk_flg"]
    CICCHK --> |no| FUNC2CHK

    CICFLG --> FUNC2CHK{"func_code = 2?"}
    FUNC2CHK --> |yes| YOMCHK["Set yoyaku_chk_flg"]
    YOMCHK --> YOMCALL["execEKK0491A010 Confirm<br>Get yoyaku_ymd"]
    YOMCALL --> HEIGOMT["Process heigomtMap<br>Get heigomt_yoyaku_ymd"]
    HEIGOMT --> RETURN["Return param"]
    FUNC2CHK --> |no| RETURN
```

**Key constant resolutions in the flowchart:**
- `func_code = "1"`: Main processing path (executing billing consolidation)
- `func_code = "2"`: Confirmation mode (checking reservation application dates)
- `func_code != "1"`: Non-routine integration path (CIC reference check)
- `ukState = true`: Service contract status is NOT "010" (received) OR is "010" with FTTH/electricity service — meaning it's not yet finalized
- `seiOpSvcCd != "E002"`: Not NHK group-bundled service — NHK is exempt from contract cancel/terminate processing
- `prcgrpcd`: Price group code determines which work project type (net, TV, mansion) drives which change SC is invoked
- `ido_div`: Movement division — "00001" or "00002" indicates a new contract or service addition

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `handle` | `SessionHandle` | Database session handle providing the transactional context and connection for all Service Component calls. Represents the current database session for the billing consolidation operation. |
| 2 | `param` | `IRequestParameterReadWrite` | Request parameter object carrying both input data (service contract list, func_code, future flags) and output data (results from SC calls, judge update map, reservation dates). Acts as the primary data carrier between the screen, this CC, and all called Service Components. |
| 3 | `fixedText` | `String` | Fixed text identifier/key used to retrieve a HashMap (ccMsg) from the param data store. This key (e.g., "KKSV0546CC") identifies the consolidated billing processing message payload within the parameter object. |

**Extracted internal state / fields read:**

| Source | Description |
|--------|-------------|
| `ccMsg.get("future_flg")` | Future day flag — "1" indicates this is a future-dated consolidation operation |
| `ccMsg.get("ido_div")` | Movement division code — "00001"/"00002" for new contract or service addition |
| `ccMsg.get("saki_seikyus_hakko_yh")` | Forward billing issuance flag — whether the forward party should issue billing |
| `ccMsg.get("count")` | Number of service contracts being processed |
| `ccMsg.get("mtSvcCd")` | Consolidation source network service code — "0" means no network service in the consolidation source |
| `ccMsg.get("KKSV0546CCList")` | List of service contract detail items (ArrayList of HashMaps) — each entry represents one service contract line item to process |
| `param.getMappingWorkArea()` | Work area map for BPM workflow data passing |
| `param.getControlMapData(SCControlMapKeys.OPERATOR_ID)` | Current operator ID for audit trail |
| `param.getControlMapData(SCControlMapKeys.OPE_DATE)` | Current operation date |
| `param.getControlMapData(SCControlMapKeys.OPE_TIME)` | Current operation time |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| C | `execEKK0011D020` | EKK0011D020CBS | Service contract agreement (content approval registration) | Registers new service contract content approval. Called for each non-received service item (ukState = true). |
| R | `execEKK0321C020` | EKK0321C020CBS | Billing advance contract information | Queries and updates billing advance contract when func_code = "1". |
| R | `execEKK0441A010` | EKK0441A010CBS | Operations contract agreement | Queries operations contract agreement when last item and seiOpKeiNo exists. |
| C | `execEKK0441C210` | EKK0441C210CBS | Operations contract cancel | Registers operations contract cancel for received/approved ops contracts (excluding NHK bundled). |
| C | `execEKK0441C230` | EKK0441C230CBS | Operations contract termination | Registers operations contract termination for non-future-dated contracts without network service. |
| C | `execEKK0441C240` | EKK0441C240CBS | Operations contract cancel confirm | Confirms operations contract cancel termination when func_code = "1". |
| R | `execEKK0791A010` | EKK0791A010CBS | Fee code agreement | Queries fee code agreement for non-future, non-received services with non-default price group. |
| C | `execECK0151D010` | ECK0151D010CBS | Instruction document registration | Registers instruction document (ID notification letter) when issuance flag is set. |
| R | `execEKU0021C010` | EKU0021C010CBS | Work project (eo net) changes | Updates work project details for eo net service. |
| R | `execEKU0031C010` | EKU0031C010CBS | Work project (eo TV) changes | Updates work project details for eo TV (K-CAT) service. |
| R | `execEKU0041C010` | EKU0041C010CBS | Work project (eo TV wire) changes | Updates work project details for eo TV (KCN) wire service. |
| R | `execEKU0061C010` | EKU0061C010CBS | Work project (eo mansion net) changes | Updates work project details for eo mansion net service. |
| R | `execEKK0491A010` | EKK0491A010CBS | Contract agreement | Queries contract agreement for forward integration processing and confirmation mode. |
| U | `execEKK0491C060` | EKK0491C060CBS | Contract content change | Updates contract content when func_code = "1" after contract agreement query. |
| C | `execEKK1091D010` | EKK1091D010CBS | Advance registration | Registers advance status (twice: once for "saki"/forward, once for "moto"/original). |
| R | `execEKK0021C060` | EKK0021C060CBS | Post-inspection task | Triggers post-inspection/compliance work when func_code = "1" and content approval was executed. |
| R | `hasNetSvcKeiFromSeikyKei` | (internal) | Network service contract check | Internal method to check if network service contract key exists from billing contract. |
| C | `execSeikyuUpdCall` | (internal CC) | Billing update | Triggers billing address update for forward party (called once per consolidation batch). |
| R | `updMkmScinsprtWkCall` | (internal CC) | Inspection support update | Updates screen entry support work information for new contracts. |
| C | `execWrisvcAutoAplyHeigo` | (internal CC) | Discount auto-application | Processes discount auto-application for the consolidation batch. |
| C | `execWrisvcAutoAply` | (internal CC) | Discount auto-application | Processes discount auto-application for cancel/terminate IF scenarios. |
| C | `execUpdateJudge` | JKKUpdateJudgeTranCC | Judge update | Executes judge (screening) result update for newly created service contracts. |
| R | `callSC (EKK2951A010)` | EKK2951A010CBS | CIC reference contract agreement | Queries CIC (Credit Information Center) reference contract for non-routine integration. |
| R | `JPCUtilCommon.getEndOfMonth` | Utility | Date calculation | Gets end-of-month date string for service charge end date calculation. |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Screen:KKSV0546 | `KKSV0546Flow.run` -> `KKSV0546OPOperation.run` -> `CCRequestBroker.invoke` -> `JKKSeikySakiHeigoCC.seikySakiHeigo` | `execEKK0011D020 [C] service_contract`, `execEKK0441C210 [C] ops_contract_cancel`, `execEKK1091D010 [C] advance_registration`, `execEKK0491A010 [R] contract_agreement`, `execEKK0791A010 [R] fee_code_agreement`, `execEKK0321C020 [R] billing_contract`, `execEKK0491C060 [U] contract_change` |

**Caller Details:**
- **KKSV0546OPOperation** — This is the sole caller of `seikySakiHeigo`. It is the operation class for screen KKSV0546, "Billing Address Information Consolidation Update" (請求先情報統合更新). The CCRequestBroker (`target3`) is configured to invoke this CC with the fixed text "KKSV0546CC". The BPM flow (KKSV0546Flow) calls this operation, which in turn invokes the CC via the request broker with database connection info "3".

## 6. Per-Branch Detail Blocks

**Block 1** — [SET] (Extract ccMsg and initialize) (L197)

> Extracts the ccMsg HashMap from the param data store using fixedText, creates a ServiceComponentRequestInvoker, and loads all working variables from the ccMsg.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ccMsg = (HashMap)param.getData(fixedText)` // Extracts processing message payload |
| 2 | SET | `scCall = new ServiceComponentRequestInvoker()` // SC call instance builder |
| 3 | SET | `workMap = (Map)param.getMappingWorkArea()` // Gets work area |
| 4 | SET | `mskmNo = ""` // Order number, initialized empty |
| 5 | SET | `seiOpKeiNo = ""` // Ops contract number, initialized empty |
| 6 | SET | `seiOpKeiState = ""` // Ops contract status, initialized empty |
| 7 | SET | `futureFlg = (String)ccMsg.get("future_flg")` // Future day flag |
| 8 | SET | `ido_div = (String)ccMsg.get("ido_div")` // Movement division code |
| 9 | SET | `saki_hakko_yh = (String)ccMsg.get("saki_seikyus_hakko_yh")` // Forward billing issuance flag |
| 10 | SET | `count = Integer.parseInt(ccMsg.get("count").toString())` // Service count |
| 11 | SET | `mtSvcCD = (String)ccMsg.get("mtSvcCd")` // Consolidation source network service code |

**Block 2** — [SET] (Initialize flags and work structures) (L218)

> Sets initial boolean flags, creates a HashMap for service contract tracking, and initializes the judge update map for judge result reflection processing (v4.00.03).

| # | Type | Code |
|---|------|------|
| 1 | SET | `mskmFlg = false` // First content approval flag |
| 2 | SET | `sintyokuFlg = false` // Post-inspection execution flag |
| 3 | SET | `autoAplyFlg = false` // Auto-application flag |
| 4 | SET | `svckeiMap = new HashMap<String,Object>()` // Service contract key tracker |
| 5 | SET | `ccMsg.put("upd_dtm_work", "0")` // Update timestamp work key |
| 6 | SET | `param.setData(JUDGE_UPDATE_MAP, new HashMap<String, Object>())` // Init judge update map |
| 7 | SET | `outMap = (HashMap)param.getData(JUDGE_UPDATE_MAP)` // Get judge update map reference |
| 8 | SET | `svcKeiList = new ArrayList<String>()` // Service contract number list for judge update |
| 9 | SET | `outMap.put("key_svc_kei_no1" ~ "key_svc_kei_no4", "")` // Initialize 4 judge key slots |

**Block 3** — [FOR] (Iterate service contract list) (L226)

> Iterates over all service contract detail items in svc_list. Each iteration processes one childMap (service contract line item). This is the primary processing loop.

| # | Type | Code |
|---|------|------|
| 1 | SET | `svc_list = (ArrayList)ccMsg.get("KKSV0546CCList")` // Service contract detail list |
| 2 | SET | `childMap = svc_list.get(i)` // Current service contract item |
| 3 | SET | `svckeiMap.put((String)childMap.get("svc_kei_no"), "")` // Track service contract number |
| 4 | SET | `stateCd = (String)childMap.get("svc_kei_stat_cd")` // Service contract status code |
| 5 | SET | `svc_cd = (String)childMap.get("svc_cd")` // Service code |

**Block 3.1** — [IF] (ukState determination — non-received or FTTH/electricity received) (L230) [CONSTANT "010" = "received status"]

> Determines whether the service is in "received" (受付済) status. If received AND service is FTTH ("51") or electricity (CD00130_05 = "05"), mark as ukState = false (treat as received). Otherwise, ukState = true (not yet received).

| # | Type | Code |
|---|------|------|
| 1 | SET | `ukState = false` // Default: received state |
| 2 | IF | `"010".equals(stateCd)` // Check if status is "received" [010 = "received"] |
| 3 | IF | `svc_cd.equals("51") || svc_cd.equals(JKKStrConst.CD00130_05)` // FTTH or electricity [CD00130_05 = "05"] |
| 4 | SET | `ukState = true` // Non-received or FTTH/electricity received => process |

**Block 3.1.1** — [ELSE] (Non-received status)

| # | Type | Code |
|---|------|------|
| 1 | SET | `ukState = true` // Not received status |

**Block 3.2** — [IF] (First iteration: set update timestamp) (L242) [i == 0]

> On the first iteration only, sets the update timestamp work field from the previous update timestamp of the first service item.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ccMsg.put("upd_dtm_work", (String)childMap.get("upd_dtm_bf"))` // Set update timestamp |

**Block 3.3** — [IF] (First content approval registration) (L246) [!mskmFlg]

> On the first iteration, if the service is not in received status (or is FTTH/electricity received), execute content approval registration (EKK0011D020). This is the first-time screen update path.

| # | Type | Code |
|---|------|------|
| 1 | IF | `ukState` // Not received or FTTH/electricity received |
| 2 | CALL | `execEKK0011D020(handle, param, scCall, ccMsg, childMap)` // Content approval registration |
| 3 | IF | `"1".equals((String)ccMsg.get("func_code"))` // func_code = "1": main processing |
| 4 | SET | `mskmNo = (String)ccMsg.get("mskm_no")` // Capture order number from result |
| 5 | SET | `mskmFlg = true` // Mark content approval executed |

**Block 3.3.1** — [ELSE] (Already received, take existing mskmNo)

| # | Type | Code |
|---|------|------|
| 1 | SET | `mskmNo = (String)childMap.get("mskm_no")` // Use existing order number |

**Block 3.4** — [IF] (Billing advance contract change) (L262) [func_code = "1"]

> Executes billing advance contract change (EKK0321C020) whenever func_code = "1", for every service item in the list.

| # | Type | Code |
|---|------|------|
| 1 | IF | `"1".equals((String)ccMsg.get("func_code"))` // Main processing path |
| 2 | CALL | `execEKK0321C020(handle, param, scCall, ccMsg, childMap)` // Billing advance contract change |

**Block 3.5** — [IF] (Last iteration: operations contract processing) (L269) [i == svc_list.size()-1]

> On the last iteration of the loop, determines whether ops contract processing is needed. This is because ops contract processing is batch-level, not per-item.

| # | Type | Code |
|---|------|------|
| 1 | SET | `prcgrpcd = (String)childMap.get("prc_grp_cd")` // Price group code |
| 2 | IF | `i == svc_list.size()-1` // Last iteration |
| 3 | SET | `seiOpKeiNo = (String)childMap.get("seiopsvc_kei_no")` // Ops contract number |

**Block 3.5.1** — [IF] (Ops contract number exists and count = 1) (L275)

> When there is an existing ops contract number and only one service item, execute ops contract agreement and potentially cancel/terminate.

| # | Type | Code |
|---|------|------|
| 1 | IF | `seiOpKeiNo != null && !"".equals(seiOpKeiNo) && count == 1` |
| 2 | CALL | `execEKK0441A010(handle, param, scCall, ccMsg, childMap)` // Ops contract agreement |
| 3 | SET | `optChildMap = childMap` // Save for later discount processing |
| 4 | SET | `seiOpKeiState = (String)childMap.get("seiopsvc_kei_stat")` // Ops contract status |
| 5 | SET | `seiOpSvcCd = (String)childMap.get("seiopsvc_cd")` // Ops service code |

**Block 3.5.1.1** — [IF] (Ops contract status is received or approved) (L287) [CONSTANT "010" = received, "020" = approved]

> If ops contract status is "010" (received) or "020" (approved), process cancel (not terminate). NHK group-bundled services are exempt.

| # | Type | Code |
|---|------|------|
| 1 | IF | `"010".equals(seiOpKeiState) || "020".equals(seiOpKeiState)` // Received or approved |
| 2 | IF | `!SEIOP_SVC_CD_NHK.equals(seiOpSvcCd)` // Not NHK [SEIOP_SVC_CD_NHK = "E002"] |
| 3 | CALL | `execEKK0441C210(handle, param, scCall, ccMsg, childMap)` // Ops contract cancel |

**Block 3.5.1.2** — [ELSE] (Future application: not received/approved)

> If ops contract is not yet received/approved, this is a future-dated cancellation. Check if network service exists and terminate if not.

| # | Type | Code |
|---|------|------|
| 1 | SET | `tekiyoYmd = (String)ccMsg.get("tekiyoYmd")` // Application date |
| 2 | SET | `mtNetKeiExistFlg = false` // Network service existence flag |
| 3 | IF | `"1".equals(futureFlg)` // Future-dated processing |
| 4 | CALL | `hasNetSvcKeiFromSeikyKei(handle, param, scCall, ccMsg, childMap, "1", null)` // Check network service |
| 5 | IF | `!mtNetKeiExistFlg` // No network service in future => terminate |

**Block 3.5.1.2.1** — [IF] (No network service: calculate service charge end date and terminate)

> Calculate the end of the month of the application date as the service charge end date, then register contract termination.

| # | Type | Code |
|---|------|------|
| 1 | SET | `svc_chrg_endymd = tekiyoYmd.substring(0, 6) + JPCUtilCommon.getEndOfMonth(tekiyoYmd.substring(0, 6))` // End of month of application date |
| 2 | IF | `!SEIOP_SVC_CD_NHK.equals(seiOpSvcCd)` // Not NHK [SEIOP_SVC_CD_NHK = "E002"] |
| 3 | CALL | `execEKK0441C230(handle, param, scCall, ccMsg, childMap, svc_chrg_endymd)` // Ops contract termination |
| 4 | IF | `"1".equals((String)ccMsg.get("func_code"))` // func_code = "1" |
| 5 | CALL | `execEKK0441C240(handle, param, scCall, ccMsg, childMap, svc_chrg_endymd)` // Cancel confirm |

**Block 3.6** — [IF] (Fee code agreement for non-default price group) (L319) [prcgrpcd != "99"] [CONSTANT "99" = default/other]

> For non-default price groups, when not future-dated and service is not yet received, execute fee code agreement and optionally register instruction document.

| # | Type | Code |
|---|------|------|
| 1 | IF | `!"99".equals(prcgrpcd)` // Not default price group [99 = default/other] |
| 2 | IF | `!"1".equals(futureFlg) && !"010".equals(stateCd)` // Not future, not received |
| 3 | CALL | `execEKK0791A010(handle, param, scCall, ccMsg, childMap)` // Fee code agreement |
| 4 | IF | `!"0".equals(childMap.get("id_tchisho_hak_skbt_cd"))` // Instruction document issuance flag != "0" |
| 5 | CALL | `execECK0151D010(handle, param, scCall, ccMsg, childMap)` // Instruction document registration |

**Block 3.7** — [IF] (Work project changes by service type) (L331) [kojiakno != null]

> If a work project number (kojiak_no) exists, execute the appropriate work project change SC based on the price group code and mansion bukken code.

| # | Type | Code |
|---|------|------|
| 1 | SET | `manbukcd = (String)childMap.get("mansion_bukken_cd")` // Mansion property code |
| 2 | SET | `kojiakno = (String)childMap.get("kojiak_no")` // Work project number |
| 3 | IF | `kojiakno != null && !"".equals(kojiakno)` |
| 4 | IF | `"02".equals(prcgrpcd) || ("10".equals(prcgrpcd) && "".equals(manbukcd))` // Net home type |
| 5 | CALL | `execEKU0021C010(handle, param, scCall, ccMsg, childMap)` // eo net changes |

**Block 3.7.1** — [ELSE-IF] (TV K-CAT service) [CONSTANT "11" = TV K-CAT]

| # | Type | Code |
|---|------|------|
| 1 | IF | `"11".equals(prcgrpcd) || "13".equals(prcgrpcd)` // TV K-CAT or TV resend [11 = TV(K-CAT), 13 = TV(resend)] |
| 2 | CALL | `execEKU0031C010(handle, param, scCall, ccMsg, childMap)` // eo TV changes |

**Block 3.7.2** — [ELSE-IF] (TV KCN service) [CONSTANT "12" = TV KCN]

| # | Type | Code |
|---|------|------|
| 1 | IF | `"12".equals(prcgrpcd)` // TV KCN [12 = TV(KCN)] |
| 2 | CALL | `execEKU0041C010(handle, param, scCall, ccMsg, childMap)` // eo TV wire changes |

**Block 3.7.3** — [ELSE-IF] (Mansion net / net mesh / light electric) [CONSTANT "03" = net mansion, "04" = net mesh, "10" = light electric]

| # | Type | Code |
|---|------|------|
| 1 | IF | `"03".equals(prcgrpcd) || "04".equals(prcgrpcd) || ("10".equals(prcgrpcd) && !"".equals(manbukcd))` // Mansion net, mesh, or light electric with mansion |
| 2 | CALL | `execEKU0061C010(handle, param, scCall, ccMsg, childMap)` // eo mansion net changes |

**Block 3.8** — [IF] (Forward integration: check and update forward billing contract) (L369)

> When forward billing issuance flag is "1" and the last item, and consolidation source has network service, check if network service exists from billing side. If not, execute contract agreement and contract change for forward party.

| # | Type | Code |
|---|------|------|
| 1 | IF | `"1".equals(saki_hakko_yh) && i == svc_list.size()-1 && !"0".equals(mtSvcCD)` |
| 2 | CALL | `hasNetSvcKeiFromSeikyKei(handle, param, scCall, ccMsg, childMap, "2", svckeiMap)` // Check network service from billing |
| 3 | IF | `!hasNetSvcKeiFromSeikyKei(...)` // No network service from billing |
| 4 | CALL | `execEKK0491A010(handle, param, scCall, ccMsg, childMap)` // Contract agreement |
| 5 | IF | `ekk0491a010outMsg != null && ekk0491a010outMsg.length != 0 && "1".equals((String)ccMsg.get("func_code"))` |
| 6 | CALL | `execEKK0491C060(handle, param, scCall, ccMsg, ekk0491a010outMsg)` // Contract content change |

**Block 3.9** — [IF] (Advance registration for non-received services) (L393)

> After processing each item (except those in received status), register advance status for both the forward and original service contracts.

| # | Type | Code |
|---|------|------|
| 1 | IF | `ukState` // Not received or FTTH/electricity received |
| 2 | CALL | `execEKK1091D010(handle, param, scCall, ccMsg, childMap, "saki")` // Advance registration (forward) |
| 3 | CALL | `execEKK1091D010(handle, param, scCall, ccMsg, childMap, "moto")` // Advance registration (original) |

**Block 3.10** — [IF] (Post-inspection processing) (L404)

> When content approval (EKK0011D020) was called and post-inspection has not been done yet, and the service is not received (or FTTH/electricity received) and func_code = "1", execute post-inspection.

| # | Type | Code |
|---|------|------|
| 1 | IF | `mskmFlg && !sintyokuFlg` // Content approval called, post-inspection not done |
| 2 | IF | `ukState && "1".equals((String)ccMsg.get("func_code"))` // Not received and main processing |
| 3 | CALL | `execEKK0021C060(handle, param, scCall, ccMsg, childMap)` // Post-inspection task |
| 4 | SET | `sintyokuFlg = true` // Mark post-inspection done |

**Block 3.11** — [IF] (Billing update and new contract support) (L416)

> When func_code = "1", execute billing update (once) and inspection support for new contracts or service additions.

| # | Type | Code |
|---|------|------|
| 1 | IF | `"1".equals((String)ccMsg.get("func_code"))` |
| 2 | SET | `svcKeiNo = (String)childMap.get("svc_kei_no")` // Service contract number |
| 3 | IF | `!autoAplyFlg` // First time billing update |
| 4 | CALL | `execSeikyuUpdCall(handle, param, fixedText)` // Billing address update |
| 5 | SET | `autoAplyFlg = true` // Mark billing update done |
| 6 | IF | `"00001".equals(ido_div) || "00002".equals(ido_div)` // New contract or service addition [00001 = new contract, 00002 = service addition] |
| 7 | CALL | `updMkmScinsprtWkCall(handle, param, svcKeiNo)` // Inspection support work update |
| 8 | SET | `svcKeiList.add(svcKeiNo)` // Collect service contract numbers for judge update |

**Block 4** — [IF] (Discount processing for non-future main processing) (L431)

> After the FOR loop ends, execute discount auto-application for the consolidation batch.

| # | Type | Code |
|---|------|------|
| 1 | IF | `"1".equals((String)ccMsg.get("func_code"))` |
| 2 | IF | `!"1".equals(futureFlg)` // Not future-dated |
| 3 | CALL | `execWrisvcAutoAplyHeigo(handle, param, fixedText, mskmNo)` // Discount auto-application |

**Block 5** — [IF] (Judge update for new contracts) (L440)

> For new contracts or service additions where func_code = "1", create judge update data and execute the judge update process.

| # | Type | Code |
|---|------|------|
| 1 | IF | `"1".equals((String)ccMsg.get("func_code"))` |
| 2 | IF | `"00001".equals(ido_div) || "00002".equals(ido_div)` // New contract or service addition |
| 3 | FOR | `j = 0 to svcKeiList.size()` // Iterate collected service contract numbers |
| 4 | SET | `outMap.put("key_svc_kei_no" + (j+1), svcKeiList.get(j))` // Store in judge update map |
| 5 | SET | `jkkupdatejudgetrancc = new JKKUpdateJudgeTranCC()` // Create judge update CC instance |
| 6 | CALL | `jkkupdatejudgetrancc.execUpdateJudge(handle, param, JUDGE_UPDATE_MAP)` // Execute judge update |

**Block 6** — [IF] (Discount processing for cancel/terminate) (L458)

> When the main processing (func_code = "1") is NOT executed (non-routine integration) and not future-dated, process discount for cancel or terminate IF.

| # | Type | Code |
|---|------|------|
| 1 | IF | `"1".equals((String)ccMsg.get("func_code")) && !"1".equals(futureFlg)` |
| 2 | IF | `seiOpKeiNo != null && !"".equals(seiOpKeiNo) && count == 1` |
| 3 | IF | `"010".equals(seiOpKeiState) || "020".equals(seiOpKeiState)` // Received or approved |
| 4 | CALL | `execWrisvcAutoAply(handle, param, fixedText, mskmNo, "", "05", optChildMap)` // Cancel IF discount |
| 5 | IF | [ELSE] // Not received/approved |
| 6 | CALL | `execWrisvcAutoAply(handle, param, fixedText, mskmNo, "", "03", optChildMap)` // Termination IF discount |

**Block 7** — [IF] (CIC reference check for non-routine integration) (L478) [ANK-2273-00-00]

> When func_code is NOT "1" (non-routine integration), execute CIC (Credit Information Center) reference check for both the original (moto) and forward (saki) billing contracts.

| # | Type | Code |
|---|------|------|
| 1 | SET | `cicChkFlg = false` // CIC check flag |
| 2 | IF | `!"1".equals((String)ccMsg.get("func_code"))` // Non-routine integration |
| 3 | SET | `ekk2951a010In = {{TEMPLATEID, "EKK2951A010"}, {FUNC_CODE, "1"}, {KEY_SEIKY_KEI_NO, childMap.get("old_seiky_kei_no")}}` // Moto CIC input |
| 4 | CALL | `callSC(handle, scCall, param, fixedText, ekk2951a010In)` // CIC reference (moto) |
| 5 | IF | `ekk2951a010Out != null && !"00".equals(ekk2951a010Out[0].getString(CIC_RNKI_NAIYO_CD))` // CIC result != "00" (normal) |
| 6 | SET | `cicChkFlg = true` // CIC issue found |
| 7 | IF | `!cicChkFlg` // No CIC issue in moto, check saki |
| 8 | SET | `ekk2951a010In2 = {{TEMPLATEID, "EKK2951A010"}, {FUNC_CODE, "1"}, {KEY_SEIKY_KEI_NO, ccMsg.get("seiky_kei_no_saki")}}` // Saki CIC input |
| 9 | CALL | `callSC(handle, scCall, param, fixedText, ekk2951a010In2)` // CIC reference (saki) |
| 10 | IF | `ekk2951a010Out2 != null && !"00".equals(ekk2951a010Out2[0].getString(CIC_RNKI_NAIYO_CD))` |
| 11 | SET | `cicChkFlg = true` // CIC issue found in saki |
| 12 | SET | `ccMsg.put("cic_chk_flg", cicChkFlg)` // Set CIC check result |

**Block 8** — [IF] (Confirmation mode: func_code = "2") (L510) [v19.00.00, ANK-2661-00-00]

> When func_code = "2" (confirmation mode), set reservation confirmation flag, execute contract agreement SC to get the reservation application date, and process consolidation source hash map to get its reservation application date.

| # | Type | Code |
|---|------|------|
| 1 | IF | `"2".equals((String)ccMsg.get("func_code"))` // Confirmation mode |
| 2 | SET | `childMap.put(YOYAKU_CHK_FLG, "1")` // Set reservation confirmation flag |
| 3 | CALL | `execEKK0491A010(handle, param, scCall, ccMsg, childMap)` // Contract agreement (confirm) |
| 4 | IF | `ekk0491a010outMsg != null && ekk0491a010outMsg.length != 0` |
| 5 | SET | `yoyakuYmd = ekk0491a010outMsg[0].getString(RSV_APLY_YMD)` // Reservation application date |
| 6 | SET | `ccMsg.put(YOYAKU_YMD, yoyakuYmd)` // Return reservation date |
| 7 | SET | `heigomtMap = new HashMap<String, Object>()` // Consolidation source hash map |
| 8 | SET | `heigomtMap.put("seiky_kei_no_saki", childMap.get("old_seiky_kei_no"))` // Original billing contract number |
| 9 | CALL | `execEKK0491A010(handle, param, scCall, heigomtMap, childMap)` // Contract agreement (heigomt) |
| 10 | IF | `heigomtEkk0491a010outMsg != null && heigomtEkk0491a010outMsg.length != 0` |
| 11 | SET | `heigomtYoyakuYmd = heigomtEkk0491a010outMsg[0].getString(RSV_APLY_YMD)` // Consolidation source reservation date |
| 12 | SET | `ccMsg.put(HEIGOMT_YOYAKU_YMD, heigomtYoyakuYmd)` // Return consolidation source reservation date |

**Block 9** — [RETURN] (L553)

> Returns the param object carrying all processed results.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return param` // Return processed parameter |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `seikySakiHeigo` | Method | Billing address consolidation — the process of merging multiple billing addresses into one |
| `請求先情報統合処理` | Field (Japanese) | Billing address information consolidation processing — business domain name for this operation |
| `func_code` | Field | Function code — "1" = main processing (executing), "2" = confirmation mode (checking), other = non-routine integration |
| `future_flg` | Field | Future day flag — "1" indicates this is a future-dated consolidation (applied later) |
| `ido_div` | Field | Movement division code — "00001" = new contract, "00002" = service addition, other = existing contract modification |
| `saki_seikyus_hakko_yh` | Field | Forward billing issuance flag — whether the forward party should issue billing |
| `mtSvcCd` | Field | Consolidation source network service code — "0" means no network service in consolidation source |
| `KKSV0546CCList` | Field | Service contract detail item list — ArrayList of HashMaps, each containing one service contract line item |
| `svc_kei_stat_cd` | Field | Service contract status code — "010" = received (受付済), "020" = approved (照会済), other = not finalized |
| `svc_cd` | Field | Service code — "51" = FTTH, "05" (CD00130_05) = electricity, other codes for other services |
| `seiOpKeiNo` | Field | Operations contract number — the contract number for billing operations services |
| `seiOpKeiState` | Field | Operations contract status — "010" = received, "020" = approved, other = not finalized |
| `seiOpSvcCd` | Field | Operations service code — "E002" = NHK group-bundled service |
| `prc_grp_cd` | Field | Price group code — "02" = net home type, "03" = net mansion, "04" = net mesh, "10" = light electric, "11" = TV(K-CAT), "12" = TV(KCN), "13" = TV(resend), "99" = default/other |
| `kojiak_no` | Field | Work project number — internal tracking ID for work project files |
| `mansion_bukken_cd` | Field | Mansion property code — identifies whether the service is at a mansion location |
| `mskm_no` | Field | Order number — the generated order number from content approval registration |
| `ukoState` | Field | Non-received state flag — true means the service is NOT in "received" status, or is FTTH/electricity received (requires processing) |
| `mskmFlg` | Field | First content approval flag — true means EKK0011D020 has been called for the first time |
| `sintyokuFlg` | Field | Post-inspection execution flag — true means EKK0021C060 (post-inspection) has been called |
| `autoAplyFlg` | Field | Auto-application flag — true means execSeikyuUpdCall has been called (billing update called once) |
| `cic_chk_flg` | Field | CIC check flag — true means CIC (Credit Information Center) reference returned a non-standard result |
| `yoyaku_ymd` | Field | Reservation application date — the date the reservation will be applied |
| `heigomt_yoyaku_ymd` | Field | Consolidation source reservation application date — the reservation date of the original billing contract |
| `judge_update_map` | Field | Judge update map key — map carrying service contract numbers for judge result reflection processing |
| `JUDGE_UPDATE_MAP` | Constant | String constant = "judge_update_map" — key for judge result reflection CC correlation |
| `SEIOP_SVC_CD_NHK` | Constant | String constant = "E002" — NHK group-bundled service code |
| `YOYAKU_YMD` | Constant | String constant = "yoyaku_ymd" — reservation application date key |
| `YOYAKU_CHK_FLG` | Constant | String constant = "yoyaku_chk_flg" — reservation confirmation flag key |
| `HEIGOMT_YOYAKU_YMD` | Constant | String constant = "heigomt_yoyaku_ymd" — consolidation source reservation date key |
| `CD00130_05` | Constant | String constant = "05" — electricity service category code |
| FTTH | Business term | Fiber To The Home — fiber-optic internet service (service code "51") |
| NHK | Business term | Nippon Hoso Kyokai (Japan Broadcasting Corporation) — public broadcaster; NHK group-bundled services are exempt from contract cancel/terminate processing |
| CIC | Acronym | Credit Information Center — credit reference agency in Japan; CIC reference checks are needed for non-routine integration |
| EKK | Prefix | Electronic K-Opticom — service component code prefix for billing/contract operations (EKK = 請求系, billing domain) |
| ECK | Prefix | Electronic Check — service component code prefix for check/document operations (ECK = 照会系, inquiry document domain) |
| EKU | Prefix | Electronic Update — service component code prefix for work project update operations (EKU = 工事系, construction domain) |
| SC | Acronym | Service Component — a reusable business logic component that performs specific database or business operations |
| CBS | Acronym | Common Business Service — a specific type of SC that encapsulates end-to-end business processes |
| CC | Acronym | Common Component — a shared business component that coordinates SC calls (this method's classification) |
| 受付済 | Field (Japanese) | "Received" status (stateCd = "010") — the service contract has been received/accepted |
| 照会済 | Field (Japanese) | "Approved/Inquired" status (stateCd = "020") — the service contract has been approved after inquiry |
| 審斯基間 | Field (Japanese) | Screening skip — refers to the judge/screening update processing |
| 割当CC | Field (Japanese) | Discount CC — the discount auto-application component (WrisvcAutoAply) |
| 請求契約 | Field (Japanese) | Billing contract — the formal contract for billing services |
| 請求オプションサービス | Field (Japanese) | Billing option service — optional add-on services billed through the billing system |
| 請求先 | Field (Japanese) | Billing address — the party responsible for billing payment |
| 統合 | Field (Japanese) | Consolidation — merging multiple items into one |
| 請求オプシヨンスサビヨス契約 | Field (Japanese) | Billing option service contract — the formal contract for billing option/add-on services |
| 料金コース | Field (Japanese) | Fee code — the pricing plan/code for a service |
| 指示書登録 | Field (Japanese) | Instruction document registration — registering official instruction documents (ID notification letters) |
| 工事案件 | Field (Japanese) | Work project — a construction/installation project file for services |
| 審査結果反映CC | Field (Japanese) | Judge result reflection CC — component that updates screening/judge results for service contracts |
| 新規契約 | Field (Japanese) | New contract — a newly created service contract (ido_div = "00001") |
| サービス追加 | Field (Japanese) | Service addition — adding a service to an existing contract (ido_div = "00002") |
| 進捗登録 | Field (Japanese) | Advance registration — registering the advance status of a contract in the workflow |
| 内容承認登録 | Field (Japanese) | Content approval registration — registering and approving the content of a service contract |
