# Business Logic — JBSbatKKSmtvlMskmInfoTrkm.chkAddValcd() [195 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.business.service.JBSbatKKSmtvlMskmInfoTrkm` |
| Layer | Service (Batch processing service for smart-batch submission information reflection) |
| Module | `service` (Package: `eo.business.service`) |

## 1. Role

### JBSbatKKSmtvlMskmInfoTrkm.chkAddValcd()

This method performs **value check processing for discount price group number** (割引料金グループ番号) during the smart-batch submission information reflection batch job. It validates a customer's discount price group code (`wribprc_grp_cd`) against their active service contracts, ensuring the customer has the proper combination of eo optical network (FTTH) and/or telephone (voice) service contracts to qualify for KDDI discount pricing. The method implements a **routing/dispatch pattern** by querying service contracts via discount group code, then applying eligibility rules (`executeRULE0086001`) per contract to determine which services match the smart-batch conditions. It handles three distinct service domains: network contracts (eo光ネット / eo Hikari Net), telephone contracts (eo光電話 / eo Hikari Phone), and third-party discount agreements (他事業者割引契約). The method enforces a **gated validation flow**: if no valid service contracts are found, the net-only case is rejected; if both net and phone exist simultaneously, the net-only rejection triggers an error; if only phone exists without net, a phone-only error is raised. Finally, it verifies that no third-party discount agreement is already concluded (which would conflict per KDDI double-registration rules), and on success, enriches the `workMap` with all derived service metadata (contract numbers, course name codes, charge start dates, etc.) for downstream processing by the batch job.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["chkAddValcd"])
    
    START --> INIT["Initialize local variables and maps"]
    
    INIT --> CHECK_DISCOUNT_TYPE{WRIBPRC_HKTGI_SBT equals WRIBPRC_HKTGI_SBT_VAL_CD=3}
    
    CHECK_DISCOUNT_TYPE --> |True| QUERY_SVC["Call selectSvcKeiByKddiValCd wribprc_grp_cd"]
    CHECK_DISCOUNT_TYPE --> |False| LOOP_SVC["Start loop: for each svcKeiMap in svcKeiList"]
    
    QUERY_SVC --> SVC_NULL_CHECK{svcKeiList is null or empty?}
    SVC_NULL_CHECK --> |Yes| SET_E03["Set ERR_CD=E03, KDDI_ERR_CD=205"]
    SET_E03 --> RET_FALSE1(["Return false"])
    SVC_NULL_CHECK --> |No| LOOP_SVC
    
    LOOP_SVC --> EXEC_RULE["Call executeRULE0086001 svcKeiMap"]
    EXEC_RULE --> EXTRACT_RULE["Extract APLY_KH, APLY_SVC_KEI, ERR_CD, KDDI_ERR_CD from ruleResult"]
    
    EXTRACT_RULE --> RULE_APPLY_OK{APLY_KH equals APLY_KH_OK=0}
    
    RULE_APPLY_OK --> |True| CHECK_EOHNT{APLY_SVC_KEI equals APLY_SVC_KEI_EOHNT=01}
    RULE_APPLY_OK --> |False| CHECK_ERR_EOHNT{APLY_SVC_KEI equals APLY_SVC_KEI_EOHNT=01}
    
    CHECK_EOHNT --> |True| SET_NET_SVC["Set SVC_KEI_NO_NET, copy to aplySvcKeiNetMap"]
    CHECK_EOHNT --> |False| CHECK_EOHTL{APLY_SVC_KEI equals APLY_SVC_KEI_EOHTL=02}
    
    CHECK_EOHTL --> |True| COPY_TEL_MAP["Copy svcKeiMap to aplySvcKeiTelMap"]
    CHECK_EOHTL --> |False| NEXT_LOOP["Next iteration"]
    
    SET_NET_SVC --> NEXT_LOOP
    COPY_TEL_MAP --> NEXT_LOOP
    
    CHECK_ERR_EOHNT --> |True| SET_NET_SVC_ERR["Set SVC_KEI_NO_NET from svcKeiMap"]
    CHECK_ERR_EOHNT --> |False| NEXT_LOOP2["Next iteration"]
    
    SET_NET_SVC_ERR --> ERR_E04_CHECK{ERR_CD equals ERR_CD_E04=E04}
    
    ERR_E04_CHECK --> |No| SET_ERR["Set ERR_CD, KDDI_ERR_CD from ruleResult"]
    SET_ERR --> RET_FALSE2(["Return false"])
    ERR_E04_CHECK --> |Yes| NEXT_LOOP2
    
    NEXT_LOOP2 --> NEXT_LOOP
    NEXT_LOOP --> MORE_SVC{More svcKeiMap?}
    MORE_SVC --> |Yes| EXEC_RULE
    MORE_SVC --> |No| CHECK_NET_MAP{aplySvcKeiNetMap not empty?}
    
    CHECK_NET_MAP --> |True| CHECK_TEL_EMPTY{aplySvcKeiTelMap empty?}
    CHECK_NET_MAP --> |False| CHECK_TEL_MAP{aplySvcKeiTelMap not empty?}
    
    CHECK_TEL_EMPTY --> |Yes| SET_E06["Set ERR_CD=E06, KDDI_ERR_CD=207"]
    SET_E06 --> RET_FALSE3(["Return false"])
    CHECK_TEL_EMPTY --> |No| NEXT_LOOP
    
    CHECK_TEL_MAP --> |True| TEL_ONLY_ERR["Set SVC_KEI_NO_NET, ERR_CD=E05, KDDI_ERR_CD=207"]
    TEL_ONLY_ERR --> RET_FALSE4(["Return false"])
    
    CHECK_TEL_MAP --> |False| NO_SERVICE["Set ERR_CD=E04, KDDI_ERR_CD=207"]
    NO_SERVICE --> RET_FALSE5(["Return false"])
    
    RET_FALSE1 --> END_BLOCK
    RET_FALSE2 --> END_BLOCK
    RET_FALSE3 --> END_BLOCK
    RET_FALSE4 --> END_BLOCK
    RET_FALSE5 --> END_BLOCK
    NEXT_LOOP --> END_BLOCK
    
    END_BLOCK["End svcKeiList loop"] --> QUERY_THIRD_PARTY["Call selectTajgsWribKeiByValCd wribprc_grp_cd"]
    
    QUERY_THIRD_PARTY --> THIRDPARTY_CHECK{tajgsWribKeiList not null and size greater than 0?}
    
    THIRDPARTY_CHECK --> |Yes| GET_FIRST["Get first map from tajgsWribKeiList"]
    GET_FIRST --> VALID_CONC_YMD{isValidYmd TAJGS_WRIB_KEI_CNC_YMD?}
    
    VALID_CONC_YMD --> |True| SET_E10["Set ERR_CD=E10, KDDI_ERR_CD=209"]
    SET_E10 --> RET_FALSE6(["Return false"])
    VALID_CONC_YMD --> |False| COPY_TAJGS["Copy tajgsWribKeiMap to aplyTajgsWribKeiMap"]
    
    COPY_TAJGS --> SET_RESULTS["Populate workMap with retrieved service data"]
    RET_FALSE6 --> SET_RESULTS
    
    THIRDPARTY_CHECK --> |No| SET_RESULTS
    
    SET_RESULTS --> RET_TRUE(["Return true"])
    RET_TRUE --> END(["End"])
    
    classDef startend fill:#e1f5e1
    classDef process fill:#e8eaf6
    classDef condition fill:#fff3e0
    classDef error fill:#ffebee
    
    class START,END startend
    class INIT,QUERY_SVC,EXEC_RULE,EXTRACT_RULE,SET_NET_SVC,COPY_TEL_MAP,SET_NET_SVC_ERR,SET_ERR,SET_E03,SET_E06,SET_E05,SET_E04,QUERY_THIRD_PARTY,GET_FIRST,COPY_TAJGS,SET_RESULTS process
    class CHECK_DISCOUNT_TYPE,SVC_NULL_CHECK,RULE_APPLY_OK,CHECK_EOHNT,CHECK_EOHTL,CHECK_ERR_EOHNT,ERR_E04_CHECK,CHECK_NET_MAP,CHECK_TEL_EMPTY,CHECK_TEL_MAP,THIRDPARTY_CHECK,VALID_CONC_YMD condition
    class RET_FALSE1,RET_FALSE2,RET_FALSE3,RET_FALSE4,RET_FALSE5,RET_FALSE6 error
```

**Constant Definitions Referenced in Flowchart:**

| Constant | Value | Source Location |
|----------|-------|-----------------|
| `WRIBPRC_HKTGI_SBT_VAL_CD` | `"3"` (Discount price group number / barcode code) | JBSbatKKSmtvlMskmInfoTrkm.java (line ~210) |
| `APLY_KH_OK` | `"0"` (Application eligible) | JBSbatKKSmtvlMskmInfoTrkm.java (line ~283) |
| `APLY_SVC_KEI_EOHNT` | `"01"` (eo optical net) | JBSbatKKSmtvlMskmInfoTrkm.java (line ~290) |
| `APLY_SVC_KEI_EOHTL` | `"02"` (eo optical telephone) | JBSbatKKSmtvlMskmInfoTrkm.java (line ~293) |
| `ERR_CD_E03` | `"E03"` (Customer not registered) | JBSbatKKSmtvlMskmInfoTrkm.java (line ~223) |
| `ERR_CD_E04` | `"E04"` (Non-target service) | JBSbatKKSmtvlMskmInfoTrkm.java (line ~226) |
| `ERR_CD_E05` | `"E05"` (Telephone only contract) | JBSbatKKSmtvlMskmInfoTrkm.java (line ~229) |
| `ERR_CD_E06` | `"E06"` (Net only contract) | JBSbatKKSmtvlMskmInfoTrkm.java (line ~232) |
| `ERR_CD_E10` | `"E10"` (Discount info already registered) | JBSbatKKSmtvlMskmInfoTrkm.java (line ~254) |
| `KDDI_ERR_CD_205` | `"205"` (Cross-settlement discount number not found) | JBSbatKKSmtvlMskmInfoTrkm.java (line ~324) |
| `KDDI_ERR_CD_207` | `"207"` (FTTH contract circuit service invalid error) | JBSbatKKSmtvlMskmInfoTrkm.java (line ~328) |
| `KDDI_ERR_CD_209` | `"209"` (Double registration error) | JBSbatKKSmtvlMskmInfoTrkm.java (line ~333) |

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `workMap` | `HashMap<String, Object>` | The work map carrying all smart-batch submission parameters and output fields. It contains the discount price group number (`wribprc_grp_cd`) and barcode code (`wribprc_hktgi_sbt` used as discount price carryover type) as inputs, and is populated with derived service contract data (service contract numbers, course name code, charge start dates, third-party discount info, etc.) on success. |

**Instance fields / external state read by the method:**

| Field | Source Location | Description |
|-------|-----------------|-------------|
| `commonItem` | JBSbatBusinessService parent class | Business service context providing access to `getLogPrint()` for debug logging |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JBSbatKKSmtvlMskmInfoTrkm.selectSvcKeiByKddiValCd` | KK_SELECT_2xx | `KK_T_SVC_KEI` | Reads service contract records (service contract numbers, pricing group codes, etc.) by discount group barcode code. SQL key depends on the calling context. |
| R | `JBSbatKKSmtvlMskmInfoTrkm.executeRULE0086001` | - | - | Applies business eligibility rules (rule 0086001) to a service contract map. Determines if the contract satisfies smart-batch conditions and which service type it belongs to (net=01, telephone=02). |
| R | `JBSbatKKSmtvlMskmInfoTrkm.selectTajgsWribKeiByValCd` | KK_SELECT_001/003 | `KK_T_TAJGS_WRIB_KEI`, `KK_T_TAJGSWKEI_TGKEI` | Reads third-party discount contract records (conclusion year/month/day, contract numbers) by discount group code. |
| R | `JBSbatKKSmtvlMskmInfoTrkm.getCourseNmCd` | - | `KK_M_PPLAN` | Looks up the course name code (コース名称コード) from net service contract data (svc_kei_no, prc_grp_cd, pcrs_cd, pplan_cd). |
| - | `JBSbatKKSmtvlMskmInfoTrkm.isValidYmd` | - | - | Validates that a year/month/day string (契約年月日) is a non-null, non-empty date value. |
| - | `JACBatCommon.printDebugLog` | - | - | Writes debug log messages for business logic traceability. |
| - | `JACbatDebugLogUtil.printDebugLog` | - | - | Writes debug log messages for business logic traceability. |
| - | `JCKLcsRenkeiUtil.printDebugLog` | - | - | Writes debug log messages for business logic traceability. |
| - | `JKKHttpCommunicator.printDebugLog` | - | - | Writes debug log messages for business logic traceability. |
| - | `JBSbatKKCashPostAddMail.printDebugLog` | - | - | Writes debug log messages for business logic traceability. |

## 5. Dependency Trace

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: JBSbatKKSmtvlMskmInfoTrkm.chkAdd | `JBSbatKKSmtvlMskmInfoTrkm.chkAdd` -> `JBSbatKKSmtvlMskmInfoTrkm.chkAddValcd` | `selectSvcKeiByKddiValCd [R] KK_T_SVC_KEI`, `selectTajgsWribKeiByValCd [R] KK_T_TAJGS_WRIB_KEI` |

**Caller Details:**
- `chkAdd()` is the sibling method within the same class that orchestrates the full smart-batch addition flow. It calls `chkAddValcd()` as part of the validation phase to check discount price group number eligibility before proceeding with contract registration.
- No external screen or CBS entry points were found within 8 hops — this method is a pure batch-processing utility called exclusively by its sibling `chkAdd()` method.

## 6. Per-Branch Detail Blocks

**Block 1** — [SET] Local variable initialization (L2462)

> Declares and initializes all local variables and working maps used throughout the method.

| # | Type | Code |
|---|------|------|
| 1 | SET | `ruleResult = new HashMap<String, Object>()` // Related rule OUT item map |
| 2 | SET | `aplyKh = ""` // Related rule OUT item application eligibility (適用可否) |
| 3 | SET | `aplySvcKei = ""` // Related rule OUT item application service contract (適用サービス契約) |
| 4 | SET | `errCd = ""` // Related rule OUT item error code (エラーコード) |
| 5 | SET | `kddiErrCd = ""` // Related rule OUT item KDDI error code (KDDIエラーコード) |
| 6 | SET | `aplySvcKeiNetMap = new HashMap<String, Object>()` // Net contract info matching smart-batch conditions (スマートバリュー適用条件を満たすネット契約の情報) |
| 7 | SET | `aplySvcKeiTelMap = new HashMap<String, Object>()` // Telephone contract info matching smart-batch conditions (スマートバリュー適用条件を満たす電話契約の情報) |
| 8 | SET | `aplyTajgsWribKeiMap = new HashMap<String, Object>()` // Third-party discount contract info already registered (他事業者割引契約の情報) |
| 9 | SET | `svcKeiList = new ArrayList<HashMap<String, Object>>()` // Service contract info list (サービス契約情報リスト) |

**Block 2** — [IF] Contract data existence check: discount price carryover type = discount price group number (L2477) [WRIBPRC_HKTGI_SBT_VAL_CD="3"]

> Checks whether the discount price carryover type (`wribprc_hktgi_sbt`) equals `"3"` (discount price group number / barcode code). If so, queries service contracts by the discount group code. This is the only branch — all invocations use this value.

| # | Type | Code |
|---|------|------|
| 1 | IF | `WRIBPRC_HKTGI_SBT_VAL_CD.equals(workMap.get(WRIBPRC_HKTGI_SBT))` [-> WRIBPRC_HKTGI_SBT_VAL_CD="3"] // Discount price carryover type == Discount price group number (割引料金グループ番号) |

**Block 2.1** — [CALL] Query service contracts by discount group barcode code (L2480)

> Calls `selectSvcKeiByKddiValCd` to retrieve service contract records matching the discount group code from the workMap.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `svcKeiList = selectSvcKeiByKddiValCd((String)workMap.get(WRIBPRC_GRP_CD))` // Acquire service contract info using KDDI barcode code (割引料金グループコード) |

**Block 2.2** — [IF] Acquisition failure check: svcKeiList is null or empty (L2482)

> If no service contract records were returned, this is a business check error: the discount price group number does not match any existing service contract.

| # | Type | Code |
|---|------|------|
| 1 | IF | `svcKeiList == null || svcKeiList.size() == 0` // Could not acquire (取得できなかった場合) |

**Block 2.2.1** — [EXEC] Debug log: business check error — no service contract found (L2484)

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `commonItem.getLogPrint().printDebugLog("(バリュー)照合チェックエラー（登録）「割引料金グループ番号でサービス契約情報が取得できませんでした」")` // (Value) collation check error (registration) "Could not acquire service contract information by discount price group number" |

**Block 2.2.2** — [SET] Set error codes (L2486–2487)

| # | Type | Code |
|---|------|------|
| 1 | SET | `workMap.put(ERR_CD, ERR_CD_E03)` [-> ERR_CD="err_cd"] |
| 2 | SET | `workMap.put(KDDI_ERR_CD, KDDI_ERR_CD_205)` [-> KDDI_ERR_CD="kddi_err_cd", KDDI_ERR_CD_205="205"] |
| 3 | RETURN | `return false` // Check error — discount price group number has no matching service contract (割引料金グループ番号に該当するサービス契約なし) |

**Block 2.2.3** — [ELSE] Acquisition succeeded — proceed to loop (implicit, L2489)

**Block 3** — [FOR] eo net contract check: iterate through service contracts (L2494)

> Iterates over all service contracts retrieved for the discount group code. For each contract, applies eligibility rule 0086001 and categorizes the contract as either a matching net contract or telephone contract.

| # | Type | Code |
|---|------|------|
| 1 | FOR | `for (HashMap<String, Object> svcKeiMap : svcKeiList)` // For each service contract |

**Block 3.1** — [CALL] Execute eligibility rule 0086001 (L2497)

> Applies business rule to determine whether this service contract satisfies the smart-batch conditions.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `ruleResult = executeRULE0086001(svcKeiMap)` // Execute rule 0086001 (RULE0086001処理) |

**Block 3.2** — [SET] Extract rule result fields (L2499–2502)

| # | Type | Code |
|---|------|------|
| 1 | SET | `aplyKh = (String)ruleResult.get("APLY_KH")` [-> APLY_KH="適用可否"] |
| 2 | SET | `aplySvcKei = (String)ruleResult.get("APLY_SVC_KEI")` [-> APLY_SVC_KEI="適用サービス契約"] |
| 3 | SET | `errCd = (String)ruleResult.get("ERR_CD")` [-> ERR_CD="エラーコード"] |
| 4 | SET | `kddiErrCd = (String)ruleResult.get("KDDI_ERR_CD")` [-> KDDI_ERR_CD="KDDIエラーコード"] |

**Block 3.3** — [IF] Application eligibility check: APLY_KH equals APLY_KH_OK=0 (L2504) [APLY_KH_OK="0"]

> Checks whether the service contract is eligible for smart-batch conditions.

| # | Type | Code |
|---|------|------|
| 1 | IF | `APLY_KH_OK.equals(aplyKh)` [-> APLY_KH_OK="0" (適用可: application eligible)] |

**Block 3.3.1** — [IF] Service type check: net contract APLY_SVC_KEI equals APLY_SVC_KEI_EOHNT=01 (L2506) [APLY_SVC_KEI_EOHNT="01"]

> Determines if the eligible contract is an eo optical net (FTTH) contract.

| # | Type | Code |
|---|------|------|
| 1 | IF | `APLY_SVC_KEI_EOHNT.equals(aplySvcKei)` [-> APLY_SVC_KEI_EOHNT="01" (eo光ネット)] |

**Block 3.3.1.1** — [SET] Store net contract info (L2512–2515)

> Sets the service contract number for net into workMap and copies the full svcKeiMap to aplySvcKeiNetMap for later use.

| # | Type | Code |
|---|------|------|
| 1 | SET | `workMap.put(SVC_KEI_NO_NET, (String)svcKeiMap.get(JBSbatKK_T_SVC_KEI.SVC_KEI_NO))` // Service contract number (net) — set here because it will be needed even if later checks fail (サービス契約番号（ネット）は、以下のチェックでNGとなった場合でもサービス呼出に必要になるため、この時点で設定) |
| 2 | SET | `aplySvcKeiNetMap.putAll(svcKeiMap)` // Copy DB-acquired items to net contract map (DBから取得した項目を退避) |

**Block 3.3.1.2** — [ELSE] Service type check: telephone contract APLY_SVC_KEI equals APLY_SVC_KEI_EOHTL=02 (L2518) [APLY_SVC_KEI_EOHTL="02"]

> Determines if the eligible contract is an eo optical telephone (voice) contract.

| # | Type | Code |
|---|------|------|
| 1 | IF | `APLY_SVC_KEI_EOHTL.equals(aplySvcKei)` [-> APLY_SVC_KEI_EOHTL="02" (eo光電話)] |

**Block 3.3.1.2.1** — [SET] Store telephone contract info (L2523)

| # | Type | Code |
|---|------|------|
| 1 | SET | `aplySvcKeiTelMap.putAll(svcKeiMap)` // Copy DB-acquired items to telephone contract map (DBから取得した項目を退避) |

**Block 3.3.1.2.2** — [ELSE] Non-target service (other service types besides net=01 and telephone=02) — skip, continue to next iteration.

**Block 3.3.2** — [ELSE] Application eligibility NG with net contract error (L2527–2538)

> The contract did NOT meet smart-batch conditions (APLY_KH != OK), but the service type is still net (EOHNT=01). Per the comment: "If the net has an error outside the target service at that point, use it as the error at that time." However, there is a guard: if the error code is `E04` (non-target service), it is silently ignored and the loop continues.

| # | Type | Code |
|---|------|------|
| 1 | IF | `APLY_SVC_KEI_EOHNT.equals(aplySvcKei)` [-> APLY_SVC_KEI_EOHNT="01"] // Net contract exists despite eligibility failure |

**Block 3.3.2.1** — [SET] Set net service contract number even on error (L2531)

| # | Type | Code |
|---|------|------|
| 1 | SET | `workMap.put(SVC_KEI_NO_NET, (String)svcKeiMap.get(JBSbatKK_T_SVC_KEI.SVC_KEI_NO))` // Service contract number (net) (サービス契約番号（ネット）) |

**Block 3.3.2.2** — [IF] Error code E04 check (L2533) [ERR_CD_E04="E04"]

| # | Type | Code |
|---|------|------|
| 1 | IF | `!ERR_CD_E04.equals(errCd)` [-> ERR_CD_E04="E04" (対象外サービス: non-target service)] |

**Block 3.3.2.3** — [EXEC] Debug log and error propagation (L2535–2538)

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `commonItem.getLogPrint().printDebugLog("(バリュー)照合チェックエラー（登録）「関連ルールによるネットの照合チェックエラー」")` // (Value) collation check error (registration) "Collation check error for net by related rule" |
| 2 | SET | `workMap.put(ERR_CD, errCd)` // Set error code from rule (エラーコード設定) |
| 3 | SET | `workMap.put(KDDI_ERR_CD, kddiErrCd)` // Set KDDI error code from rule |
| 4 | RETURN | `return false` |

**Block 3.3.2.4** — [ELSE] Error is E04 — skip silently, continue to next service contract iteration.

**Block 3.4** — [END] End of svcKeiList for-loop

**Block 4** — [IF] eo telephone contract check: net contract exists check (L2544)

> Checks whether any net contract matching the smart-batch conditions was found.

| # | Type | Code |
|---|------|------|
| 1 | IF | `!aplySvcKeiNetMap.isEmpty()` // Smart-batch conditions met: net contract exists (スマートバリュー適用条件を満たすネット契約が存在する場合) |

**Block 4.1** — [IF] Telephone contract does NOT exist (net-only scenario) (L2548) [APLY_SVC_KEI_EOHTL not found]

> If net exists but telephone does not, this is an error: smart-batch requires both or neither (net-only is rejected).

| # | Type | Code |
|---|------|------|
| 1 | IF | `aplySvcKeiTelMap.isEmpty()` // Smart-batch conditions met: no telephone contract exists (適用条件を満たす電話契約が存在しない場合) |

**Block 4.1.1** — [EXEC] Debug log: net only (L2550)

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `commonItem.getLogPrint().printDebugLog("(バリュー)照合チェックエラー（登録）「.NETのみ契約」")` // (Value) collation check error (registration) "Net-only contract" |

**Block 4.1.2** — [SET] Set net-only error (L2552–2553)

| # | Type | Code |
|---|------|------|
| 1 | SET | `workMap.put(ERR_CD, ERR_CD_E06)` [-> ERR_CD_E06="E06" (ネットのみ契約: net-only contract)] |
| 2 | SET | `workMap.put(KDDI_ERR_CD, KDDI_ERR_CD_207)` [-> KDDI_ERR_CD_207="207" (FTTH contract circuit service invalid error)] |
| 3 | RETURN | `return false` |

**Block 4.2** — [ELSE] Net contract exists and telephone contract also exists — validation passes this gate, proceed.

**Block 5** — [ELSE] No net contract matching smart-batch conditions (L2557)

> No net contract was found. Check whether a telephone contract exists instead.

| # | Type | Code |
|---|------|------|
| 1 | IF | `!aplySvcKeiTelMap.isEmpty()` // Smart-batch conditions met: eo optical telephone exists (スマートバリュー適用条件を満たすeo光ネット契約が存在しない場合 — 存在する場合) |

**Block 5.1** — [EXEC] Debug log: telephone only (L2561)

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `commonItem.getLogPrint().printDebugLog("(バリュー)照合チェックエラー（登録）「電話のみ」")` // (Value) collation check error (registration) "Telephone only" |

**Block 5.2** — [SET] Set phone-only error (L2564–2566)

> The service contract number (telephone) is stored into the `svc_kei_no_net` field — it is a telephone service number, but set as the net item for the purpose of KDDI discount contract error notification.

| # | Type | Code |
|---|------|------|
| 1 | SET | `workMap.put(SVC_KEI_NO_NET, (String)aplySvcKeiTelMap.get(JBSbatKK_T_SVC_KEI.SVC_KEI_NO))` // Service contract number (net) — this is actually the telephone service contract number, but set in the net field for KDDI discount contract error notification (KDDI割引契約誤通達に出力するため、ネットの項目に設定) |
| 2 | SET | `workMap.put(ERR_CD, ERR_CD_E05)` [-> ERR_CD_E05="E05" (電話のみ契約: telephone-only contract)] |
| 3 | SET | `workMap.put(KDDI_ERR_CD, KDDI_ERR_CD_207)` [-> KDDI_ERR_CD_207="207"] |
| 4 | RETURN | `return false` |

**Block 5.3** — [ELSE] Neither net nor telephone contract found (non-target service) (L2571)

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `commonItem.getLogPrint().printDebugLog("(バリュー)照合チェックエラー（登録）「対象外サービス」")` // (Value) collation check error (registration) "Non-target service" |
| 2 | SET | `workMap.put(ERR_CD, ERR_CD_E04)` [-> ERR_CD_E04="E04" (対象外サービス)] |
| 3 | SET | `workMap.put(KDDI_ERR_CD, KDDI_ERR_CD_207)` [-> KDDI_ERR_CD_207="207"] |
| 4 | RETURN | `return false` |

**Block 6** — [IF] Smart-batch conclusion check: third-party discount contract (L2579)

> Retrieves third-party discount contracts by the discount group code and verifies the conclusion date is NOT set. If a third-party discount is already concluded, this conflicts with the smart-batch processing.

| # | Type | Code |
|---|------|------|
| 1 | SET | `tajgsWribKeiList = new ArrayList<HashMap<String, Object>>()` // Initialize third-party discount contract list (他事業者割引契約取得) |
| 2 | CALL | `tajgsWribKeiList = selectTajgsWribKeiByValCd((String)workMap.get(WRIBPRC_GRP_CD))` // Acquire third-party discount contract with barcode code (バリ/code code) |

**Block 6.1** — [IF] Third-party discount contract exists (L2581)

| # | Type | Code |
|---|------|------|
| 1 | IF | `tajgsWribKeiList != null && tajgsWribKeiList.size() > 0` // Third-party discount contract found (他事業者割引契約が取引) |

**Block 6.2** — [SET] Get first contract from list (L2583)

| # | Type | Code |
|---|------|------|
| 1 | SET | `tajgsWribKeiMap = tajgsWribKeiList.get(0)` // Get first third-party discount contract map (他事業者割引契約番号) |

**Block 6.3** — [IF] Conclusion date validation (L2584) [TAJGS_WRIB_KEI_CNC_YMD]

> Checks if the third-party discount contract conclusion year/month/day is set (non-empty). If so, the customer already has another provider's discount, which is a conflict.

| # | Type | Code |
|---|------|------|
| 1 | IF | `isValidYmd((String)tajgsWribKeiMap.get(JBSbatKK_T_TAJGS_WRIB_KEI.TAJGS_WRIB_KEI_CNC_YMD))` // Third-party discount contract conclusion year/month/day is set (他事業者割引契約締結年月日が設定されている場合) |

**Block 6.3.1** — [EXEC] Debug log: smart-batch conclusion check error (L2587)

| # | Type | Code |
|---|------|------|
| 1 | EXEC | `commonItem.getLogPrint().printDebugLog("(バリュー)照合チェックエラー（登録）「スマートバリュー締結チェック」")` // (Value) collation check error (registration) "Smart-batch conclusion check" |

**Block 6.3.2** — [SET] Set conflict error (L2589–2590)

| # | Type | Code |
|---|------|------|
| 1 | SET | `workMap.put(ERR_CD, ERR_CD_E10)` [-> ERR_CD_E10="E10" (割引情報登録済: discount info already registered)] |
| 2 | SET | `workMap.put(KDDI_ERR_CD, KDDI_ERR_CD_209)` [-> KDDI_ERR_CD_209="209" (二重登録エラー: double registration error)] |
| 3 | RETURN | `return false` |

**Block 6.4** — [ELSE] Conclusion date is empty — no conflict, store the third-party discount info (L2594)

| # | Type | Code |
|---|------|------|
| 1 | SET | `aplyTajgsWribKeiMap.putAll(tajgsWribKeiMap)` // Copy third-party discount contract info (他事業者割引契約情報を退避) |

**Block 7** — [SET] Validation OK: populate workMap with retrieved service data (L2604–2638)

> On successful validation, enrich the workMap with all derived service metadata for downstream processing.

| # | Type | Code |
|---|------|------|
| 1 | SET | `workMap.put(SVC_KEI_NO_TEL, (String)aplySvcKeiTelMap.get(JBSbatKK_T_SVC_KEI.SVC_KEI_NO))` // Service contract number (telephone) (サービス契約番号（電話）) |
| 2 | SET | `workMap.put(TAJGS_WRIB_KEI_NO, (String)aplyTajgsWribKeiMap.get(JBSbatKK_T_TAJGS_WRIB_KEI.TAJGS_WRIB_KEI_NO))` // Third-party discount contract number (他事業者割引契約番号) |
| 3 | SET | `workMap.put(TAJGS_WRIB_KEI_UPD_DTM, (String)aplyTajgsWribKeiMap.get(JBSbatKK_T_TAJGS_WRIB_KEI.UPD_DTM))` // Third-party discount contract update timestamp (他事業者割引契約更新年月日時分秒) |
| 4 | SET | `workMap.put(KDDI_JGS_KEI_KANRI_NO, (String)aplyTajgsWribKeiMap.get(JBSbatKK_T_TAJGS_WRIB_KEI.KDDI_JGS_KEI_KANRI_NO))` // KDDI business contract management number (KDDI事業者契約管理番号) |
| 5 | SET | `workMap.put(TAJGS_WRIB_KEI_GENE_ADD_DTM, (String)aplyTajgsWribKeiMap.get(JBSbatKK_T_TAJGS_WRIB_KEI.GENE_ADD_DTM))` // Generation add timestamp (third-party discount) (世代登録年月日時分秒（他事業者割引契約）) |
| 6 | CALL | `workMap.put(COURSE_NM_CD, getCourseNmCd(...))` // Course name code — resolved from net contract svc_kei_no, prc_grp_cd, pcrs_cd, pplan_cd (コース名称コード) |
| 7 | SET | `workMap.put(NET_SVC_MSKM_YMD, (String)aplySvcKeiNetMap.get(JBSbatKK_T_SVC_KEI.SHOSA_YMD))` // Net service submission date (ネットサービス申請年月日) |
| 8 | SET | `workMap.put(NET_SVC_CHRG_STAYMD, (String)aplySvcKeiNetMap.get(JBSbatKK_T_SVC_KEI.SVC_CHRG_STAYMD))` // Net service charge start date (ネットサービス課金開始年月日) |
| 9 | SET | `workMap.put(TEL1_SVC_MSKM_YMD, (String)aplySvcKeiTelMap.get(JBSbatKK_T_SVC_KEI.SHOSA_YMD))` // Telephone service 1 submission date (電話サービス1申請年月日) |
| 10 | SET | `workMap.put(TEL1_SVC_CHRG_STAYMD, (String)aplySvcKeiTelMap.get(JBSbatKK_T_SVC_KEI.SVC_CHRG_STAYMD))` // Telephone service 1 charge start date (電話サービス1課金開始年月日) |
| 11 | RETURN | `return true` // Validation passed (チェックOK) |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `wribprc_grp_cd` | Field | Discount price group code — the group code used to identify a discount pricing arrangement linked to a KDDI barcode code |
| `wribprc_hktgi_sbt` | Field | Discount price carryover type — classifies how the discount is applied: `"1"` = submission number, `"3"` = discount price group number (barcode code) |
| `wribprc_hktgi_sbt` value `"3"` | Constant | Discount price group number / barcode code (割引料金グループ番号（バリューコード）) — identifies discount pricing by a barcode code rather than a submission number |
| `svc_kei_no` | Field | Service contract number — the unique identifier for a customer's service contract (FTTH or telephone) |
| `APLY_KH` | Field | Application eligibility (適用可否) — indicates whether a service contract satisfies smart-batch conditions; `"0"` = eligible, `"1"` = not eligible |
| `APLY_SVC_KEI` | Field | Application service contract (適用サービス契約) — indicates the service type of a matching contract; `"01"` = eo optical net (FTTH), `"02"` = eo optical telephone (voice) |
| `err_cd` | Field | Error code — internal application error code (E01–E15, EA1–EA5, E99) |
| `kddi_err_cd` | Field | KDDI error code — KDDI-facing error code for external notification (205, 206, 207, 208, 209, 999) |
| `ERR_CD_E03` | Constant | `"E03"` — Customer not registered (お客様未登録) |
| `ERR_CD_E04` | Constant | `"E04"` — Non-target service (対象外サービス) |
| `ERR_CD_E05` | Constant | `"E05"` — Telephone-only contract (電話のみ契約) |
| `ERR_CD_E06` | Constant | `"E06"` — Net-only contract (.NETのみ契約) |
| `ERR_CD_E10` | Constant | `"E10"` — Discount info already registered (割引情報登録済) |
| `KDDI_ERR_CD_205` | Constant | `"205"` — Cross-settlement discount number not found (クロセッタル料金引継番号存在エラー) |
| `KDDI_ERR_CD_207` | Constant | `"207"` — FTTH contract circuit service invalid error (FTTH契約回線サービス不正エラー) |
| `KDDI_ERR_CD_209` | Constant | `"209"` — Double registration error (二重登録エラー) |
| Smart-batch (スマートバリュー) | Business term | KDDI's smart-value discount program offering price reductions for bundled FTTH and telephone services |
| eo光ネット (eo HNT) | Business term | eo optical fiber-to-the-home (FTTH) broadband service |
| eo光電話 (eo HTL) | Business term | eo optical telephone (voice) service |
| 他事業者割引 (tajgs_wrib) | Business term | Third-party carrier discount — a discount arrangement with a non-KDDI carrier that may conflict with KDDI discount eligibility |
| `KK_T_SVC_KEI` | DB Table | Service contract table — stores service contract records including contract numbers, pricing group codes, and service dates |
| `KK_T_TAJGS_WRIB_KEI` | DB Table | Third-party discount contract table — stores third-party carrier discount contract information |
| `KK_T_TAJGSWKEI_TGKEI` | DB Table | Third-party discount contract target contract table — links third-party discount arrangements to target contracts |
| `RULE0086001` | Business rule | Eligibility rule 0086001 — determines whether a service contract qualifies for smart-batch discount conditions |
| `course_nm_cd` | Field | Course name code — the service course classification derived from service contract parameters |
| `shosa_ymd` | Field | Inspection/read date (年月日) — typically the service submission/application date |
| `svc_chrg_staymd` | Field | Service charge start date (課金開始年月日) — when billing for the service begins |
