# Business Logic — JKKCustMemberSbtChgCC.updateWifiSpotLoginSysid() [89 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `com.fujitsu.futurity.bp.custom.common.JKKCustMemberSbtChgCC` |
| Layer | CC/Common Component (Service Component — custom business logic for customer subscription changes) |
| Module | `common` (Package: `com.fujitsu.futurity.bp.custom.common`) |

## 1. Role

### JKKCustMemberSbtChgCC.updateWifiSpotLoginSysid()

This method handles **Wi-Fi spot login SYSID migration** during a family membership tier upgrade. In the Fujitsu customer subscription domain, a "family membership" consists of a leader (parent/master member) and subordinate family members. When a subordinate family member ("target") is promoted to a master member and needs to assume the leader's ("parent") identity for Wi-Fi spot access, this method reassigns the Wi-Fi spot login SYSID from the target's identifier to the parent's identifier.

The method follows a **gather-then-update processing pattern**: it first queries all service contract details belonging to the parent member and all spot login records belonging to the target member, identifies the intersection (service contract line items used by the target for eo Mobile / Wi-Fi spot services), and then updates those line items to use the parent's SYSID. This ensures seamless continuity of Wi-Fi spot access rights after the membership promotion.

The method is called from `JKKCustMemberSbtChgCC.execute()` as part of a larger customer subscription change workflow. It implements **delegation** through `callScCmn()` (a shared Service Integration Framework dispatcher), using SIF mappers (`JKKSIFEKK0161Mapper`, `JKKSIFEKK0201Mapper`) to construct and execute database queries against the service contract entities. The method also writes results into the instance field `targetUcwkList`, which is consumed by subsequent processing steps in the same class.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["updateWifiSpotLoginSysid"])
    START --> CHECK_NULL["Check: targetSysid or parentSysid is null?"]
    CHECK_NULL -->|Yes| RET_NULL["Return early (null check)"]
    CHECK_NULL -->|No| CHECK_SAME["Check: targetSysid equals parentSysid?"]
    CHECK_SAME -->|Yes| RET_SAME["Return early (same sysid)"]
    CHECK_SAME -->|No| FETCH_ALL["Fetch all service contract details for parentSysid"]
    FETCH_ALL --> CALL_ALL["callScCmn with getMappedTemplateEKK0161B003"]
    CALL_ALL --> FETCH_SPOT["Fetch service contract detail: eo Mobile (spot login SYSID) for targetSysid"]
    FETCH_SPOT --> CALL_SPOT["callScCmn with getMappedTemplateEKK0201B001"]
    CALL_SPOT --> BUILD_SET["Build targetUcwkNoSet from spot results"]
    BUILD_SET --> EXTRACT_SPOT["Extract svc_kei_ucwk_no from EKK0201B001CBSMSG1LIST"]
    EXTRACT_SPOT --> ADD_SET["Add svc_kei_ucwk_no to targetUcwkNoSet"]
    ADD_SET --> CHECK_ALL["Check: resultMsgsUcwkAll has results?"]
    CHECK_ALL -->|Yes| EXTRACT_ALL["Extract svc_kei_ucwk_no from EKK0161B003CBSMSG1LIST"]
    CHECK_ALL -->|No| CHECK_SET["Check: targetUcwkNoSet has items?"]
    EXTRACT_ALL --> FILTER_ALL{"targetUcwkNoSet contains svc_kei_ucwk_no?"}
    FILTER_ALL -->|Yes| CREATE_MAP["Create HashMap with svc_kei_ucwk_no, add to targetUcwkList"]
    FILTER_ALL -->|No| CHECK_SET
    CREATE_MAP --> CHECK_SET
    CHECK_SET -->|Not empty| LOOP_LIST["Iterate targetUcwkList"]
    CHECK_SET -->|Empty| END_PROC["End processing"]
    LOOP_LIST --> GET_ITEM["Get Map from targetUcwkList.get(i)"]
    GET_ITEM --> GET_SVC["Extract svc_kei_ucwk_no from Map"]
    GET_SVC --> FETCH_SINGLE["Fetch single service contract agreement for svc_kei_ucwk_no"]
    FETCH_SINGLE --> CALL_SINGLE["callScCmn with getMappedTemplateEKK0161A010"]
    CALL_SINGLE --> CHECK_SINGLE["Check: resultMsgsSingle has results and list not empty?"]
    CHECK_SINGLE -->|Yes| READ_FIELDS["Read LAST_UPD_DTM, SVC_KEI_NO, GENE_ADD_DTM from result"]
    CHECK_SINGLE -->|No| NEXT_ITER["Next iteration"]
    READ_FIELDS --> SAVE_SVC["Save svc_kei_no to targetUcwk"]
    SAVE_SVC --> SAVE_DTM["Save gene_add_dtm to targetUcwk"]
    SAVE_DTM --> BUILD_UPDATE["Build template for spot login sysid update with parentSysid"]
    BUILD_UPDATE --> CALL_UPDATE["callScCmn with getMappedTemplateEKK0201C080"]
    CALL_UPDATE --> NEXT_ITER
    NEXT_ITER --> LOOP_END{"Loop complete?"}
    LOOP_END -->|No| GET_ITEM
    LOOP_END -->|Yes| END_PROC
    END_PROC --> FINISH(["Return void"])
```

**Processing Summary:**

1. **Guard checks** — Return early if either `targetSysid` or `parentSysid` is null, or if they are the same value.
2. **Fetch all service contracts for parent** — Query all service contract details belonging to the parent member using mapper `JKKSIFEKK0161Mapper` (template EKK0161B003), dispatched via `callScCmn`.
3. **Fetch spot login records for target** — Query the target member's eo Mobile service contract details using mapper `JKKSIFEKK0201Mapper` (template EKK0201B001), dispatched via `callScCmn`.
4. **Build target set** — Extract `svc_kei_ucwk_no` (service contract detail work numbers) from the target's spot results into a `HashSet` for efficient intersection lookups.
5. **Filter parent contracts** — From the parent's full contract list, extract only those line items whose `svc_kei_ucwk_no` exists in the target's set. Store each match as a `HashMap` into `targetUcwkList` (instance field).
6. **Update loop** — For each matched contract detail: fetch the single contract agreement (template EKK0161A010), read `svc_kei_no` and `gene_add_dtm` (generation timestamp) for SOD document generation, then call the update SIF (template EKK0201C080) to replace the spot login SYSID with the parent's SYSID.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `handle` | `SessionHandle` | Database/session handle providing the transaction context and database connection for SIF (Service Integration Framework) invocations. Used by `callScCmn()` to execute queries against service contract entities. |
| 2 | `param` | `IRequestParameterReadWrite` | Request parameter object carrying request-scoped data shared across SIF calls. Used by `callScCmn()` for request context during service contract queries and updates. |
| 3 | `targetSysid` | `String` | The SYSID of the family member being promoted from subordinate to master member. This is the customer whose Wi-Fi spot login records are being examined and whose old spot login SYSID references will be replaced. |
| 4 | `parentSysid` | `String` | The SYSID of the family member leader (parent) that the target member will inherit. The spot login SYSID is replaced with this value. |

**Instance Fields Referenced:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `targetUcwkList` | `List<Map<String, Object>>` | Instance field that accumulates matched service contract detail records for Wi-Fi spot SYSID update. Each entry is a HashMap containing `svc_kei_ucwk_no` and, after processing, `svc_kei_no` and `gene_add_dtm`. Consumed by subsequent methods in `JKKCustMemberSbtChgCC.execute()`. |

## 4. CRUD Operations / Called Services

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

The method delegates all data operations through `callScCmn()`, which acts as a Service Integration Framework (SIF) dispatcher. The actual SC Codes and entity tables are resolved from the SIF mapper templates used.

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JKKSIFEKK0161Mapper.getMappedTemplateEKK0161B003` | EKK0161B003SC | KK_T_SVC_KEI_UCWK_NO, KK_T_CUST_MEMBER | Query all service contract details for the parent member — reads the full list of service contract line items associated with the parent's SYSID. |
| R | `JKKSIFEKK0201Mapper.getMappedTemplateEKK0201B001` | EKK0201B001SC | KK_T_SVC_KEI_UCWK_NO, KK_T_SPOT_LOGIN | Query eo Mobile service contract details for the target member — reads spot login SYSID records to identify which contract line items use Wi-Fi spot services. |
| U | `JKKSIFEKK0201Mapper.getMappedTemplateEKK0201C080` | EKK0201C080SC | KK_T_SVC_KEI_UCWK_NO, KK_T_SPOT_LOGIN | Update spot login SYSID to parent SYSID — replaces the target's spot login identifier with the parent's SYSID for matched contract line items. |
| R | `JKKSIFEKK0161Mapper.getMappedTemplateEKK0161A010` | EKK0161A010SC | KK_T_SVC_KEI_UCWK_NO, KK_T_CUST_MEMBER | Query single service contract agreement — reads contract detail metadata (svc_kei_no, gene_add_dtm, last_updt_dtm) required for SOD document generation and update stamp. |
| R | `JBSbatFUCaseFileRnkData.getString` | - | - | Calls `getString` in `JBSbatFUCaseFileRnkData` (data access layer). |
| R | `JBSbatFUMoveNaviData.getString` | - | - | Calls `getString` in `JBSbatFUMoveNaviData` (data access layer). |
| R | `JBSbatZMAdDataSet.getString` | - | - | Calls `getString` in `JBSbatZMAdDataSet` (data access layer). |
| R | `JESC0101B010TPMA.getString` | - | - | Calls `getString` in `JESC0101B010TPMA` (data access layer). |
| R | `JESC0101B020TPMA.getString` | - | - | Calls `getString` in `JESC0101B020TPMA` (data access layer). |
| C | `callScCmn` (EKK0161B003CBS) | EKK0161B003CBS | Parent's service contract details | Dispatches SIF call to fetch all service contract details for the parent member. |
| C | `callScCmn` (EKK0201B001CBS) | EKK0201B001CBS | Target's eo Mobile spot login records | Dispatches SIF call to fetch target's Wi-Fi spot service contract details. |
| C | `callScCmn` (EKK0201C080CBS) | EKK0201C080CBS | Spot login SYSID record | Dispatches SIF call to update the spot login SYSID to the parent SYSID. |
| C | `callScCmn` (EKK0161A010CBS) | EKK0161A010CBS | Single service contract agreement | Dispatches SIF call to fetch single contract agreement metadata per matched line item. |

## 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 | Class: JKKCustMemberSbtChgCC | `execute()` -> `updateWifiSpotLoginSysid(handle, param, targetSysid, parentSysid)` | `callScCmn [R] service contracts (EKK0161B003CBS)`, `callScCmn [R] spot login (EKK0201B001CBS)`, `callScCmn [U] spot login SYSID (EKK0201C080CBS)`, `callScCmn [R] single contract (EKK0161A010CBS)`, `getString [R] data access layer` |

The `targetUcwkList` instance field is populated by this method and consumed by subsequent processing in `JKKCustMemberSbtChgCC.execute()`, forming an intra-method chain for the customer subscription change workflow.

Terminal operations from this method: `callScCmn` [R], `getMappedTemplateEKK0201C080` [R], `getString` [R], `getString` [R], `getString` [R], `getString` [R], `getString` [R], `getString` [R], `getString` [R], `getString` [R], `getString` [R], `getString` [R], `getString` [R], `getString` [R], `getString` [R], `getString` [R], `getString` [R], `callScCmn` [R], `getMappedTemplateEKK0161A010` [R], `getString` [R]

## 6. Per-Branch Detail Blocks

**Block 1** — IF `(targetSysid == null || parentSysid == null)` (L851)

> Guard: Return early if either SYSID parameter is null. This prevents NPE when comparing SYSIDs and avoids unnecessary SIF processing.

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

---

**Block 2** — IF `(targetSysid.equals(parentSysid))` (L856)

> Guard: 同じsysidが指定されている場合は処理対象外 — If the target SYSID equals the parent SYSID, the operation is a no-op (they are already the same member). No processing needed.

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

---

**Block 3** — Fetch all service contract details for parent (L861-L864)

> サービサ契約内訳一覧照会（SYSID）を実行 — Execute query for all service contract details belonging to the parent member's SYSID.

| # | Type | Code |
|---|------|------|
| 1 | SET | `mapperUcwkAll = new JKKSIFEKK0161Mapper()` |
| 2 | SET | `templateUcwkAll = mapperUcwkAll.getMappedTemplateEKK0161B003(parentSysid)` |
| 3 | CALL | `resultMsgsUcwkAll = callScCmn(param, handle, templateUcwkAll, mapperUcwkAll)` |

---

**Block 4** — Fetch spot login (eo Mobile) for target (L867-L870)

> サービサ契約内訳：eoモバイル一覧照会（スポットログインSYSID）を実行 — Execute query for eo Mobile service contract details (spot login SYSID) belonging to the target member's SYSID.

| # | Type | Code |
|---|------|------|
| 1 | SET | `mapperSpot = new JKKSIFEKK0201Mapper()` |
| 2 | SET | `templateSpot = mapperSpot.getMappedTemplateEKK0201B001(targetSysid)` |
| 3 | CALL | `resultMsgsSpot = callScCmn(param, handle, templateSpot, mapperSpot)` |

---

**Block 5** — Build targetUcwkNoSet from spot results (L873-L881)

> 判定用ハッシュの作成 — Build a HashSet for efficient intersection lookups. Extract `svc_kei_ucwk_no` values from the spot query results.

| # | Type | Code |
|---|------|------|
| 1 | SET | `targetUcwkNoSet = new HashSet<String>()` |
| 2 | IF | `resultMsgsSpot.length > 0` (L874) |

**Block 5.1** — IF `(resultMsgsSpot.length > 0)` (L874)

| # | Type | Code |
|---|------|------|
| 1 | SET | `resultMsgsSpotList = resultMsgsSpot[0].getCAANMsgList(EKK0201B001CBSMsg.EKK0201B001CBSMSG1LIST)` |
| 2 | FOR | `i = 0; i < resultMsgsSpotList.length` (L877) |

**Block 5.1.1** — FOR body: Extract svc_kei_ucwk_no (L878-L881)

| # | Type | Code |
|---|------|------|
| 1 | SET | `msgSpot = resultMsgsSpotList[i]` |
| 2 | SET | `svc_kei_ucwk_no = msgSpot.getString(EKK0201B001CBSMsg1List.SVC_KEI_UCWK_NO)` |
| 3 | SET | `targetUcwkNoSet.add(svc_kei_ucwk_no)` |

---

**Block 6** — Filter parent contracts by target set (L884-L896)

> parentSysid元に取り得たサービサ契約一覧から対象となるものを抽出 — From the parent's service contract list, extract only those matching target's spot login contract details.

| # | Type | Code |
|---|------|------|
| 1 | IF | `resultMsgsUcwkAll.length > 0` (L884) |

**Block 6.1** — IF `(resultMsgsUcwkAll.length > 0)` (L884)

| # | Type | Code |
|---|------|------|
| 1 | SET | `resultMsgsUcwkAllList = resultMsgsUcwkAll[0].getCAANMsgList(EKK0161B003CBSMsg.EKK0161B003CBSMSG1LIST)` |
| 2 | FOR | `i = 0; i < resultMsgsUcwkAllList.length` (L886) |

**Block 6.1.1** — FOR body: Filter and build targetUcwkList (L887-L896)

| # | Type | Code |
|---|------|------|
| 1 | SET | `msgUcwk = resultMsgsUcwkAllList[i]` |
| 2 | SET | `svc_kei_ucwk_no = msgUcwk.getString(EKK0161B003CBSMsg1List.SVC_KEI_UCWK_NO)` |
| 3 | IF | `targetUcwkNoSet.contains(svc_kei_ucwk_no)` (L889) |

**Block 6.1.1.1** — IF `(targetUcwkNoSet.contains(svc_kei_ucwk_no))` (L889)

> The contract detail from the parent's list also appears in the target's spot login list — this is a matched item requiring SYSID update.

| # | Type | Code |
|---|------|------|
| 1 | SET | `m = new HashMap()` |
| 2 | SET | `m.put("svc_kei_ucwk_no", svc_kei_ucwk_no)` |
| 3 | EXEC | `targetUcwkList.add(m)` |

---

**Block 7** — Update spot login SYSID loop (L899-L933)

> スポットログインSYSIDを更新（親sysidに置き換える）— Update spot login SYSID for each matched contract detail, replacing target's SYSID with parent's SYSID.

| # | Type | Code |
|---|------|------|
| 1 | FOR | `i = 0; i < targetUcwkList.size()` (L900) |

**Block 7.1** — FOR body: Per-contract update cycle (L901-L933)

| # | Type | Code |
|---|------|------|
| 1 | SET | `targetUcwk = targetUcwkList.get(i)` |
| 2 | SET | `svc_kei_ucwk_no = targetUcwk.get("svc_kei_ucwk_no")` |

**Block 7.1.1** — Fetch single service contract (L905-L909)

> サービサ契約一致照会を実行 — Execute single service contract agreement query for the matched contract detail.

| # | Type | Code |
|---|------|------|
| 1 | SET | `mapperSingle = new JKKSIFEKK0161Mapper()` |
| 2 | SET | `templateSingle = mapperSingle.getMappedTemplateEKK0161A010(svc_kei_ucwk_no, null)` |
| 3 | CALL | `resultMsgsSingle = callScCmn(param, handle, templateSingle, mapperSingle)` |

**Block 7.1.2** — IF `(resultMsgsSingle.length > 0)` (L909)

| # | Type | Code |
|---|------|------|
| 1 | IF | `svcKeiUcwk.length > 0` (L910) |

**Block 7.1.2.1** — IF `(svcKeiUcwk.length > 0)` (L910)

> Read contract metadata and perform the SYSID update.

| # | Type | Code |
|---|------|------|
| 1 | SET | `svcKeiUcwk = resultMsgsSingle[0].getCAANMsgList(EKK0161A010CBSMsg.EKK0161A010CBSMSG1LIST)` |
| 2 | SET | `upd_dtm_bf = svcKeiUcwk[0].getString(EKK0161A010CBSMsg1List.LAST_UPD_DTM)` |
| 3 | SET | `svc_kei_no = svcKeiUcwk[0].getString(EKK0161A010CBSMsg1List.SVC_KEI_NO)` // SOD発行用に保存 サークビサ契約番号 |
| 4 | SET | `targetUcwk.put("svc_kei_no", svc_kei_no)` |
| 5 | SET | `gene_add_dtm = svcKeiUcwk[0].getString(EKK0161A010CBSMsg1List.GENE_ADD_DTM)` // SOD発行用に保存 世代登録年月日時分秒 |
| 6 | SET | `targetUcwk.put("gene_add_dtm", gene_add_dtm)` |
| 7 | SET | `templateSpotUpd = mapperSpot.getMappedTemplateEKK0201C080(svc_kei_ucwk_no, null, parentSysid, upd_dtm_bf)` |
| 8 | CALL | `callScCmn(param, handle, templateSpotUpd, mapperSpot)` |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `sysid` | Field | System ID — unique internal identifier for a customer member account in the Fujitsu subscription management system. |
| `targetSysid` | Field | The SYSID of the family member being promoted from subordinate to master member. |
| `parentSysid` | Field | The SYSID of the family member leader (parent) that the target member inherits. |
| `svc_kei_ucwk_no` | Field | Service detail work number — internal tracking ID for a service contract line item. Used to correlate contracts across the parent and target member records. |
| `svc_kei_no` | Field | Service contract number — the high-level contract identifier, stored for SOD (Service Order Data) document generation. |
| `gene_add_dtm` | Field | Generation registration date-time — timestamp of when the contract detail record was created, stored for SOD document generation. |
| `upd_dtm_bf` | Field | Last update date-time before — the current last update timestamp, used as a pessimistic lock stamp in the update query (EKK0201C080) to prevent concurrent modification conflicts. |
| `targetUcwkList` | Field | Instance-level accumulator list holding matched contract detail records. Populated during this method and consumed by subsequent processing in `execute()`. |
| `targetUcwkNoSet` | Local | HashSet of `svc_kei_ucwk_no` values extracted from the target's spot login results. Used as the intersection key when filtering parent contracts. |
| SOD | Acronym | Service Order Data — output documents generated from service contract information, used for billing and order fulfillment. |
| SYSID | Acronym | System ID — unique identifier within the Fujitsu customer management system for members, contracts, and service lines. |
| SIF | Acronym | Service Integration Framework — the middleware layer for executing database queries against telecom subscription entities. Uses `callScCmn()` as the dispatcher. |
| EKK0161B003 | SC Code | Query template for all service contract details (一覧照会) — returns the full list of contract line items for a given member SYSID. |
| EKK0201B001 | SC Code | Query template for eo Mobile spot login SYSID details (eoモバイル一覧照会) — returns Wi-Fi spot service contract records for a given member SYSID. |
| EKK0161A010 | SC Code | Query template for single service contract agreement (契約一致照会) — returns metadata (svc_kei_no, gene_add_dtm, last_updt_dtm) for a specific contract detail work number. |
| EKK0201C080 | SC Code | Update template for spot login SYSID change (スポットログインSYSID変更) — updates the spot login SYSID to the parent SYSID, using the contract work number and update timestamp as filter. |
| `callScCmn` | Method | Shared SIF dispatch method — executes a Service Integration Framework call using the provided mapper template, handling the request/response lifecycle. |
| eo Mobile | Business term | NTT docomo's eo branded mobile service — the Wi-Fi spot login service domain handled by the EKK0201 mapper. |
| サークビサ契約内訳 | Japanese term | Service contract detail — individual line items within a customer's service contract, each representing a specific service type (e.g., FTTH, Mail, Wi-Fi spot). |
| スポットログインID | Japanese term | Spot login ID — the identifier used for Wi-Fi spot access authentication in the eo Mobile service. |
| 親マスター会員 | Japanese term | Parent/master member — the family membership leader whose identity other members inherit. |
| ファミリー会員 | Japanese term | Family member — a subordinate member account within a family membership group. |
| マスタ会員へ格上げ | Japanese term | Promotion to master member — the business operation of upgrading a subordinate family member to master member status. |
| CAANMsg | Type | Fujitsu's message envelope type used in SIF — container for request/response data with typed accessors (`getString`, `getCAANMsgList`). |
| JKKSIFEKK0161Mapper | Type | SIF mapper for service contract detail queries (EKK0161 family). |
| JKKSIFEKK0201Mapper | Type | SIF mapper for spot login / eo Mobile service queries (EKK0201 family). |
