# Business Logic — JBSbatKKintrjhAdd.premiumClubPointRegist() [50 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.business.service.JBSbatKKintrjhAdd` |
| Layer | Batch Service |
| Module | `service` (Package: `eo.business.service`) |

## 1. Role

### JBSbatKKintrjhAdd.premiumClubPointRegist()

This method performs **Premium Club Point Registration** for the TRANK (external/tracking) system. It is a batch-service method responsible for registering premium club loyalty points associated with a customer identified by `sysid` (system ID). The method follows a **builder-and-delegate pattern**: it constructs a request parameter map (`kksv102101map`) containing the system ID, effective start date, presentation division, and the earned present point amount fetched from the work parameter table, then delegates execution to the `KKSV102101SC` service component via `JCCBatchEsbInterface.invokeService()`. It serves as a **supporting batch utility** called by the referral information processing pipeline (`createSvcStaTgInf`) specifically when the data extraction item type code is `"60"` (Damicampaign — a promotional campaign type). The method handles a single critical early-exit path: if the present point amount cannot be resolved from the work parameter table, it returns an error response with a descriptive message ("Premium Club Point Acquisition Error") and logs a business error before returning early. The method ultimately forwards the prepared request to the point registration service component (`KKSV102101SC`) which performs the actual point crediting operation.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["premiumClubPointRegist(sysid)"])

    START --> REQ_MAP["Create reqMap HashMap"]
    REQ_MAP --> KKS_MAP["Create kksv102101map HashMap"]
    KKS_MAP --> PUT_REQ["reqMap.put(SC_TITLE_KKSV102101SC, kksv102101map)"]
    PUT_REQ --> RES_MAP["Create resMap HashMap"]
    RES_MAP --> FUNC_CODE["kksv102101map.put('func_code', '1')"]
    FUNC_CODE --> FUNC_CODE_TRANK["kksv102101map.put('func_code_trank', '1')"]
    FUNC_CODE_TRANK --> SYSID_PUT["kksv102101map.put('sysid', sysid)"]
    SYSID_PUT --> TEKIYO["kksv102101map.put('tekiyo_st_ymd', opeDate)"]
    TEKIYO --> PRESENT_KBN["kksv102101map.put('present_kbn', '30')"]
    PRESENT_KBN --> GM_PARAM["gmParamId = KK_INTR_PRPOINT ('KK_INTR_PRPOINT')"]
    GM_PARAM --> SELECT_PARAM["selectZmWorkParamKnri016(gmParamId)"]

    SELECT_PARAM --> CHECK_NULL{"workParamKnriMap1 == null<br/>|| BLANK"}

    CHECK_NULL -->|true| ERROR_MAP["resMap.put('error', ERR_RSN_PRMCL_POINT_ERR)"]
    ERROR_MAP --> ERROR_LOG["printBusinessErrorLog(EKKB2250CW)"]
    ERROR_LOG --> ERROR_RETURN["return resMap"]

    CHECK_NULL -->|false| GET_PT["workParamKnriMap1.getString(WORK_PARAM_SETTE_VALUE)"]
    GET_PT --> PRESENT_PT["kksv102101map.put('present_pt_su', presentPtSu)"]
    PRESENT_PT --> SNS_PUT["kksv102101map.put('sns_sbt_cd', null)"]
    SNS_PUT --> SISIK_PUT["kksv102101map.put('sisk_sins_eda_no', null)"]

    SISIK_PUT --> REQ_CREATE["Create req HashMap"]
    REQ_CREATE --> USECASE_PUT["req.put(TELEGRAM_INFO_USECASE_ID, 'KKSV1021')"]
    USECASE_PUT --> OPID_PUT["req.put(TELEGRAM_INFO_OPERATION_ID, 'KKSV1021OP')"]
    OPID_PUT --> INVOKE["JCCBatchEsbInterface.invokeService(commonItem, req, reqMap, resMap)"]
    INVOKE --> FINAL_RETURN["return resMap"]
    FINAL_RETURN --> END_NODE(["END"])

    ERROR_RETURN --> END_NODE
```

**Constant Resolution:**

| Constant | Resolved Value | Business Meaning |
|----------|---------------|------------------|
| `SC_TITLE_KKSV102101SC` | `"KKSV102101SC"` | Key identifying the Premium Club Point Registration Service Component |
| `KK_INTR_PRPOINT` | `"KK_INTR_PRPOINT"` | Work parameter ID for fetching present point amount in intra-batch processing |
| `ERR_RSN_PRMCL_POINT_ERR` | `"プレミアムクラブポイント取得エラー"` (Premium Club Point Acquisition Error) | Error message when the present point amount cannot be obtained |
| `BLANK` | `""` (empty string) | Value used to check if a field is blank/null |
| `USECASE_ID` | `"KKSV1021"` | Usecase identifier for the premium club point registration telegram |
| `OPERATION_ID` | `"KKSV1021OP"` | Operation identifier for the premium club point registration telegram |

**Processing flow:**

1. **Request Map Construction**: Creates the outer `reqMap` and nested `kksv102101map`, registering the SC title as the key.
2. **Parameter Population**: Populates the inner map with functional codes (`func_code = "1"`, `func_code_trank = "1"` for TRANK targeting), the system ID, operation date (`opeDate`), and presentation division (`present_kbn = "30"`).
3. **Point Amount Resolution**: Fetches the present point amount (`present_pt_su`) from the work parameter table by calling `selectZmWorkParamKnri016()` with the parameter ID `"KK_INTR_PRPOINT"`.
4. **Early-Exit Validation**: If the point amount query returns null or a blank value, the method records an error message in `resMap`, logs a business error (`EKKB2250CW`), and returns immediately.
5. **SNS and Measure Fields**: Sets `sns_sbt_cd` and `sisk_sins_eda_no` to null (not applicable for this registration path).
6. **ESB Invocation**: Constructs an ESB request with `USECASE_ID` and `OPERATION_ID`, then calls `JCCBatchEsbInterface.invokeService()` to delegate to the point registration service component.
7. **Return**: Returns the response map containing the SC result and a return code.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `sysid` | `String` | System ID — the unique identifier for the customer account. This ID is passed directly to the Premium Club Point Registration SC (`KKSV102101SC`) to associate the point registration with the correct customer. The value originates from the calling batch processing pipeline and corresponds to the customer's system-level account identifier. |

**Instance fields read:**

| Field | Type | Business Description |
|-------|------|---------------------|
| `super.opeDate` | `Date` (inferred) | Operation date — the effective start date (`tekiyo_st_ymd`) for the point registration, representing when the premium club point eligibility begins. |
| `super.commonItem` | `JPCBatchCommonItem` (inferred) | Common batch item context — provides the logging subsystem and ESB invocation context used to call `JCCBatchEsbInterface.invokeService()`. |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `JBSbatKKintrjhAdd.selectZmWorkParamKnri016` | - | `ZM_M_WORK_PARAM_KNRI` (Work Parameter Management Table) | Reads the present point amount value from the work parameter table using the parameter ID `KK_INTR_PRPOINT`. The table stores configurable business parameter values accessible by parameter ID. |
| - | `JCCBatchEsbInterface.invokeService` | `KKSV102101SC` | - (ESB-mediated) | Invokes the Premium Club Point Registration Service Component via ESB bus. This is a delegate call that forwards the prepared request map containing `sysid`, `opeDate`, `present_kbn`, `present_pt_su`, and other fields to the `KKSV102101SC` SC for actual point registration. |
| - | `JPCBatchMessageConstant.printBusinessErrorLog` | - | - | Logs a business error with message code `EKKB2250CW` when the present point amount cannot be resolved from the work parameter table. |

### How SC Code was determined:

- The constant `SC_TITLE_KKSV102101SC` resolves to `"KKSV102101SC"`, which is used as the key in `reqMap` passed to `invokeService`. This directly identifies the target service component.
- The `USECASE_ID` (`"KKSV1021"`) and `OPERATION_ID` (`"KKSV1021OP"`) further confirm this is the Premium Club Point Registration ESB call.

## 5. Dependency Trace

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

No screen/batch entry points found within 8 hops. Direct callers found: 1 method.
Terminal operations from this method: `selectZmWorkParamKnri016` [R], `invokeService` [-], `printBusinessErrorLog` [-]

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Batch: `JBSbatKKintrjhAdd.createSvcStaTgInf()` | `createSvcStaTgInf` -> `premiumClubPointRegist(sysid)` | `selectZmWorkParamKnri016` [R] `ZM_M_WORK_PARAM_KNRI`, `invokeService` [-] `KKSV102101SC`, `printBusinessErrorLog` [-] `EKKB2250CW` |

**Call chain details:**

`createSvcStaTgInf` is the referral information processing method in the same class. It is called by the main batch processing entry point (`JBSbatKKintrjhAdd.add`) at line 335. Inside `createSvcStaTgInf`, at line 1222, `premiumClubPointRegist(sysid)` is called conditionally when:
1. The data extraction item type code (`DCHS_TYPE_CD`) equals `"60"` (Damicampaign)
2. The `premiumClubPointJudge` method returns `RESULT_OK` (customer is eligible for premium club point issuance)

The full path from the batch entry point:
`add` -> `createSvcStaTgInf` -> `premiumClubPointRegist` -> `selectZmWorkParamKnri016` -> `ZM_M_WORK_PARAM_KNRI` (Read)
`premiumClubPointRegist` -> `JCCBatchEsbInterface.invokeService` -> `KKSV102101SC` (ESB delegate to external service)

## 6. Per-Branch Detail Blocks

**Block 1** — [SET] (Request Map Construction) (L1867-L1872)

> Creates and initializes the request parameter maps for the SC invocation. The nested structure uses `SC_TITLE_KKSV102101SC` as the key for the inner map, which `invokeService` will use to route to the correct service component.

| # | Type | Code |
|---|------|------|
| 1 | SET | `HashMap<String, Object> reqMap = new HashMap<String, Object>();` // Service input parameter Map |
| 2 | SET | `HashMap<String, Object> kksv102101map = new HashMap<String, Object>();` // All-parameter Map for Premium Club Point Registration SC |
| 3 | SET | `reqMap.put(SC_TITLE_KKSV102101SC, kksv102101map);` // [-> `SC_TITLE_KKSV102101SC = "KKSV102101SC"`] Register nested map under SC title key |
| 4 | SET | `HashMap<Object, Object> resMap = new HashMap<Object, Object>();` // Service result Map |

**Block 2** — [SET] (Parameter Population) (L1875-L1885)

> Populates the inner parameter map with functional codes, system ID, operation date, and presentation division code. These parameters are required by the `KKSV102101SC` service component to identify the request context and customer.

| # | Type | Code |
|---|------|------|
| 1 | SET | `kksv102101map.put("func_code", "1");` // Functional code (service IF) |
| 2 | SET | `kksv102101map.put("func_code_trank", "1");` // Functional code for TRANK |
| 3 | SET | `kksv102101map.put("sysid", sysid);` // Customer system ID |
| 4 | SET | `kksv102101map.put("tekiyo_st_ymd", super.opeDate);` // Effective start date (from operation date) |
| 5 | SET | `kksv102101map.put("present_kbn", "30");` // Presentation division — fixed value "30" |
| 6 | SET | `String gmParamId = KK_INTR_PRPOINT;` // [-> `KK_INTR_PRPOINT = "KK_INTR_PRPOINT"`] Work parameter ID for point amount lookup |

**Block 3** — [SET + CALL] (Fetch Present Point Amount) (L1886-L1887)

> Retrieves the present point amount from the work parameter table. The `selectZmWorkParamKnri016` method queries the `ZM_M_WORK_PARAM_KNRI` table by `WORK_PARAM_ID` and returns a `JBSbatCommonDBInterface` containing the `WORK_PARAM_SETTE_VALUE` field.

| # | Type | Code |
|---|------|------|
| 1 | SET | `JBSbatCommonDBInterface workParamKnriMap1 = selectZmWorkParamKnri016(gmParamId);` // Query work parameter by `KK_INTR_PRPOINT` |

**Block 4** — [IF] (Null/Blank Validation) `(workParamKnriMap1 == null || BLANK.equals(workParamKnriMap1))` (L1888)

> Early-exit branch: if the work parameter query returned nothing or a blank value, record the error and return immediately. The constant `BLANK` resolves to `""` (empty string).

| # | Type | Code |
|---|------|------|
| 1 | SET | `resMap.put("error", ERR_RSN_PRMCL_POINT_ERR);` // [-> `ERR_RSN_PRMCL_POINT_ERR = "プレミアムクラブポイント取得エラー"` (Premium Club Point Acquisition Error)] |

**Block 4.1** — [CALL] (Error Logging — nested in Block 4 true branch) (L1890)

| # | Type | Code |
|---|------|------|
| 1 | CALL | `commonItem.getLogPrint().printBusinessErrorLog(JPCBatchMessageConstant.EKKB2250CW);` // Log business error with message code EKKB2250CW |

**Block 4.2** — [RETURN] (Error Return — nested in Block 4 true branch) (L1892)

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return resMap;` // Return error response with error message |

**Block 5** — [SET + CALL] (Normal Path — Point Amount Extraction) (L1893-L1894)

> Continues from Block 4 false branch: extracts the actual point amount value and registers it in the request map.

| # | Type | Code |
|---|------|------|
| 1 | SET | `String presentPtSu = workParamKnriMap1.getString(JBSbatZM_M_WORK_PARAM_KNRI.WORK_PARAM_SETTE_VALUE);` // Extract point amount from DB result |
| 2 | SET | `kksv102101map.put("present_pt_su", presentPtSu);` // Register present point amount (业务参数 — obtained from work parameter table) |

**Block 6** — [SET] (Null Field Initialization) (L1895-L1896)

> Sets SNS type code and measure application branch number to null — not applicable for the premium club point registration path.

| # | Type | Code |
|---|------|------|
| 1 | SET | `kksv102101map.put("sns_sbt_cd", null);` // SNS type code (null — not used) |
| 2 | SET | `kksv102101map.put("sisk_sins_eda_no", null);` // Measure application branch number (null — not used) |

**Block 7** — [SET] (ESB Request Map Construction) (L1899-L1902)

> Creates the ESB request map with usecase and operation identifiers for the telegram-based service invocation.

| # | Type | Code |
|---|------|------|
| 1 | SET | `HashMap<String, Object> req = new HashMap<String, Object>();` // Map containing usecase ID |
| 2 | SET | `req.put(JCCBatchEsbInterface.TELEGRAM_INFO_USECASE_ID, USECASE_ID);` // [-> `USECASE_ID = "KKSV1021"`] |
| 3 | SET | `req.put(JCCBatchEsbInterface.TELEGRAM_INFO_OPERATION_ID, OPERATION_ID);` // [-> `OPERATION_ID = "KKSV1021OP"`] |

**Block 8** — [CALL] (Service Invocation) (L1905)

> Delegates to the ESB interface to invoke the `KKSV102101SC` service component with the prepared request map. The ESB transport handles routing the request to the target SC.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `JCCBatchEsbInterface.invokeService(super.commonItem, req, reqMap, resMap);` // Service invocation — forwards prepared request to KKSV102101SC |

**Block 9** — [RETURN] (Response Return) (L1908)

> Returns the response map containing the SC result (under key `KKSV102101SC`) and a return code. The caller (`createSvcStaTgInf`) will check `resMap.get("KKSV102101SC")` for error flags and `resMap.get("RETURN_CODE")` for the processing result.

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return resMap;` // Return response containing SC result and return code |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `sysid` | Field | System ID — unique customer account identifier used to associate the point registration with the correct customer |
| `opeDate` | Field | Operation date — the business date used as the effective start date for point registration |
| `SC_TITLE_KKSV102101SC` | Constant | Service Component title — `"KKSV102101SC"` identifies the Premium Club Point Registration service component |
| `KK_INTR_PRPOINT` | Constant | Work parameter ID — `"KK_INTR_PRPOINT"` is the key used to fetch the present point amount from the work parameter table |
| `ERR_RSN_PRMCL_POINT_ERR` | Constant | Error reason code — `"プレミアムクラブポイント取得エラー"` (Premium Club Point Acquisition Error) |
| `USECASE_ID` | Constant | `"KKSV1021"` — Usecase identifier for the premium club point registration telegram in the ESB |
| `OPERATION_ID` | Constant | `"KKSV1021OP"` — Operation identifier for the premium club point registration telegram |
| `func_code` | Parameter | Functional code — value `"1"` identifies this as a service IF request |
| `func_code_trank` | Parameter | Functional code for TRANK — value `"1"` indicates this is a TRANK (external/tracking) system request. TRANK likely refers to an external partner or tracking system. |
| `present_kbn` | Parameter | Presentation division code — value `"30"` classifies how the points are presented/processed |
| `present_pt_su` | Parameter | Present point amount — the numeric point value obtained from the work parameter table, representing the points to be registered |
| `sns_sbt_cd` | Parameter | SNS type code — not used in this path (set to null) |
| `sisk_sins_eda_no` | Parameter | Measure application branch number — not used in this path (set to null) |
| `tekiyo_st_ymd` | Parameter | Effective start date — when the premium club point eligibility begins (set to `opeDate`) |
| `BLANK` | Constant | `""` (empty string) — used as a sentinel to detect blank values |
| `ZM_M_WORK_PARAM_KNRI` | Entity | Work Parameter Management Table — stores configurable business parameter values accessible by parameter ID (`WORK_PARAM_ID`) and value (`WORK_PARAM_SETTE_VALUE`) |
| `KKSV102101SC` | SC Code | Premium Club Point Registration Service Component — the target service that performs the actual point crediting |
| `KKSV1021` | Use Case | Premium Club Point Registration usecase identifier for ESB routing |
| `KKSV1021OP` | Operation ID | Premium Club Point Registration operation identifier for ESB routing |
| `EKKB2250CW` | Message Code | Business error log message code logged when point amount acquisition fails |
| DAMICAMPAIGN | Business term | A promotional campaign type — referenced by `DCHS_TYPE_CD = "60"` in the calling method, which determines this point registration path is triggered |
| TRANK | Business term | External/tracking system — indicated by `func_code_trank = "1"`, the target system for this point registration |
