# CRW03409SFLogic

## Purpose

`CRW03409SFLogic` is the **core business logic controller** for the **Contract Cancellation-Inquiry Support** screen (CRW03409SF) in the K-Opticom customer backend system. It orchestrates the entire lifecycle of a dashboard-style inquiry management screen where operators view service contract status, handle customer inquiries, perform approvals/rejections, and navigate to numerous sub-screen workflows. This class acts as a central routing hub — receiving web events, initializing screen data from backend services, and dispatching operators to ~20 different child screens depending on user interaction.

## Design

`CRW03409SFLogic` follows the **screen logic controller** pattern, consistent with the X31 Web framework used across the codebase. It extends `JCCWebBusinessLogic` (the base class for all X31 B-side web business logic) and serves as the **facade between JSP presentation layers and backend services**. Every public method implements a specific user action — tab switching, button clicks, service invocations, or screen navigation — following a uniform six-phase structure:

1. **Acquire inherited info** (screen state from prior request)
2. **Configure service form bean** (prepare data structures)
3. **Call backend service** (invoke mappers and remote services)
4. **Set service results** (populate bean fields from output)
5. **Set navigation info** (prepare screen IDs and bean data for the next screen)
6. **Configure common form bean** (set destination screen metadata)

All methods return `boolean` (true for success, false for error) and throw `Exception` on failure.

## Key Methods

### init() → boolean

The most important method — performs the **initial display** of the inquiry support screen. This is the screen entry point.

- **Purpose**: Initializes the screen by acquiring screen info, resetting button/link states, invoking the `CRSV0084` service mapper (which pulls service contract data, device info, progress info, phone info, billing info, etc.), calculating transaction fees (`getJimFee`), replacing placeholder dates (`20991231` → "blank"), and mapping main inquiry data to a dedicated tab.
- **Parameters**: None (uses internal beans).
- **Returns**: `true` on success.
- **Side effects**: Populates the service form bean with service contract data, invokes 15+ mapper methods (`setCRSV008401SC` through `setCRSV008411SC` plus `setCRSV008413SC` through `setCRSV008419SC`), calculates fees, and sets navigation metadata.
- **Special behavior**: If the inherited info already contains a service contract number (`SVC_KEI_NO`) or SYSID, it skips the service call and returns `true` early, assuming the data is already loaded.

### display() → boolean

Called when the user clicks the **display button** on the inquiry support main screen.

- **Purpose**: Refreshes the MYBOX item count, QueryBOX item count, and mail item counts on the inquiry support main screen by calling `JCRWebCommon.getMyboxQueboxMailCnt()`.
- **Side effects**: Updates bean values for badge/notification counts displayed on the main screen.

### clickTab() → boolean

Handles **tab switching** within the inquiry support main screen.

- **Purpose**: When the user clicks a different tab, this method first refreshes the MYBOX/QueryBOX/mail counts, then determines which tab was clicked. If it's the main tab (`CRW03409`), it re-invokes `init()` to refresh the entire page. Otherwise, it prepares the selected sub-screen's navigation info and sets screen IDs for all possible child screens to carry the parent tab ID forward.
- **Side effects**: Updates 15+ screen ID references for child screens to maintain context.

### execute() → boolean

Displays other system screens (e.g., inquiry history view).

- **Purpose**: Delegates to `JCRWebCommon.execute(bean, commoninfoBean, this)` which handles the inquiry history screen workflow. Resets the next screen to the main CRW03409 tab.

### accept() → boolean / reject() → boolean / closeToiawase() → boolean / restart() → boolean / getKyosei() → boolean

These methods implement the **inquiry lifecycle management** actions:

| Method | Service | Purpose |
|--------|---------|---------|
| `accept()` | `execAccept` | Accept the inquiry, marking it approved |
| `reject()` | `execReject` | Reject the inquiry, sending it back |
| `closeToiawase()` | `execClose` | Close/finalize the inquiry |
| `restart()` | `execRestart` | Restart the inquiry for re-processing |
| `getKyosei()` | `execGetKyosei` | Force-reopen (compulsory acquisition) an inquiry |

All five follow the same pattern: call the corresponding `JCRWebCommon.exec*()` method with a mapper array, then call `refresh()` to update the screen.

### refresh() → boolean

Full **screen refresh** — used after state-changing operations (accept, reject, close, restart, getKyosei).

- **Purpose**: Re-loads screen info, calls `JCRWebCommon.refreshPage()` to re-fetch inquiry main screen data, and finally calls `init()` to reinitialize the full screen state.
- **Special behavior**: If the previous screen was CRW04101 (document sending registration), it displays a specific informational message and redirects to the main screen.

### insertEasyMemo() → boolean

Updates the **quick memo** field for the current inquiry.

- **Purpose**: Calls `JCRWebCommon.execInsertEasyMemo()`, then invokes `refresh()` to update the screen.

### openCrw00101Ins() → boolean / openCrw00101Upd() → boolean

Open the **inquiry input** and **inquiry edit** sub-screens respectively.

- **Purpose**: Sets up screen IDs and copies the current bean data using `JCRWebCommon.copyBeanToToiawaseIns()` or `JCRWebCommon.copyBeanToToiawaseUpd()` into the target screen's parameter map, then sets the destination screen info.

### openCrw04001() → boolean

Opens the **escalation execution screen**.

- **Purpose**: Copies bean data via `JCRWebCommon.copyBeanToEscalation()` and navigates to screen `CRW04001`.

### openCrw03901() → boolean

Opens the **inquiry cancellation registration screen**.

- **Purpose**: Copies bean data via `JCRWebCommon.copyBeanToCancel()` and navigates to screen `CRW03901`.

### openCrw02603() → boolean

Opens the **inquiry customer editing screen**. This method has a branching flow based on whether an inquiry customer number or service contract number is set.

- **If neither is set**: Navigates to `CRW02602` as parent and `CRW02601` as target.
- **If either is set**: Navigates to `CRW02604` as parent and `CRW02603` as target.
- **Purpose**: Copies bean data via `JCRWebCommon.copyBeanToProscstUpd()`.

### openCrw00401() → boolean

Opens the **Hotvoice registration screen**. Copies bean data via `JCRWebCommon.copyBeanToHotvoice()`.

### openCrw04101() → boolean

Opens the **document sending registration screen**. Copies bean data via `JCRWebCommon.copyBeanToSendSiryo()`.

### openCrw02401() → boolean

Opens the **inquiry customer info search screen**. Copies bean data via `JCRWebCommon.copyBeanToProscstSearch()`.

### openCrw00601() → boolean

Opens the **memo registration screen**. Copies bean data via `JCRWebCommon.copyBeanToMemo()`.

### openCrw00701() → boolean

Opens the **mail reply screen**. Copies bean data via `JCRWebCommon.copyBeanToMailHensin()`.

### openCrw00801() → boolean

Opens the **mail forward screen**. Copies bean data via `JCRWebCommon.copyBeanToMailTenso()`.

### clickLinkSeikyYm() → boolean

Displays the **billing detail screen** when the user clicks a billing period link.

- **Purpose**: Extracts the selected row's billing type number (`SEIKY_KEI_NO`), billing period (`L6_SEIKY_TRGT_DATE_07`), and billing number (`L6_SEIKY_NO_07`) from the service form bean, then navigates to screen `CHW00105` with this data in the parameter map.

### clickLinkMyboxCnt() → boolean

Displays the **MYBOX list screen** (`CRW01301`) when the user clicks the MYBOX count link.

- **Purpose**: Copies bean data via `JCRWebCommon.copyBeanToMyBOX()`.

### clickLinkQueboxCnt() → boolean

Displays the **QueryBOX list screen** (`CRW01401`) when the user clicks the QueryBOX count link.

- **Purpose**: Copies bean data via `JCRWebCommon.copyBeanToQueBOX()`.

### clickLinkMailCnt() → boolean

Displays the **quick send mail screen** (`CRW10301`) when the user clicks the mail count link.

- **Purpose**: Copies bean data via `JCRWebCommon.copyBeanToSendMail()`.

### clickLinkMskmshoNoUk() → boolean

Handles the **application number (receipt) link click**.

- **Purpose**: Constructs a URL for the image system (URL receipt display) by combining the application change number and online password. Calls `JCRWebCommon.getOnetPwdImgSys()` to retrieve the password image system data, then sets the constructed URL and display flag on the bean.

### getMainData() → void

Private helper method that sets the status field.

- **Purpose**: Transfers the `SHINSA_STA_NM` (processing status name) value to the `STATUS` field on the service form bean. This maps inquiry status data to a dedicated tab.

### clickSaihakko() → boolean

Handles the **re-issue button click** for ID registration certificate reissue.

- **Purpose**: Calls the `CRSV0281` mapper service (`ADDWEBACCESSNSKEYCC`) to validate membership type. If the user is not a master member (individual or corporate), it displays an error message (`EKB1040_JW`). If validation passes, it sets the `CRW03410_OPN_FLG` to `true` to allow navigation to the reissue screen.
- **Service mapper**: `CRSV0281_CRSV0281OPDBMapper`

### openCrw03410() → boolean

Opens the **ID registration certificate reissue info output screen** (`CRW03410`).

- **Purpose**: Passes URL info, web access NS key, web access NS key password, and expiration datetime to the child screen via a parameter map. Sets `CRW03410_OPN_FLG` to `false` before navigation.

### executeCis() → boolean

Handles the **electric power CIS button click** (new electric power support).

- **Purpose**: Delegates to `JCRWebCommon.executeCis(bean, commoninfoBean, this)`, which handles the electric power CIS workflow. Returns to the main CRW03409 tab.

### clickLinkTrank() → boolean

Handles the **member link/rin-rin click** (premium support).

- **Purpose**: Navigates to screen `KKW00196` with data copied via `JCRWebCommon.clickLinkTrank()`.

### clickLinkVcms() → boolean

Handles the **lease contract screen link click**.

- **Purpose**: Navigates to screen `KKW00198` with data copied via `JCRWebCommon.clickLinkVcms()`.

### transferToMain() → boolean

Returns to the **inquiry support main screen** from a sub-screen.

- **Purpose**: Copies bean data via `JCRWebCommon.copyBeanToInitMain()` and sets the destination to `CRW01201` (the inquiry support main screen).

### openCrw10901() → boolean

Opens the **SMS send screen** (`CRW10901`).

- **Purpose**: Copies bean data via `JCRWebCommon.copyBeanToSmsSend()` and navigates to the SMS send sub-screen.

### receiveMessageWeb(X31CID arg0, Object arg1, EventObject arg2) → boolean

Override of the parent class method. Currently returns `false` and is unused — this appears to be a scaffolded method from the auto-generation tool that was never implemented.

## Relationships

```mermaid
flowchart TD
    A["WEBGAMEN_CRW034090PJP<br/>JSP Page"] -->|"calls"| B["CRW03409SFLogic"]
    C["x31business_logic_CRW03409SF.xml<br/>Business Logic Config"] -->|"references"| B
    B -->|"extends"| D["JCCWebBusinessLogic<br/>Base Framework Class"]

    B -->|"delegates to"| E["JCRWebCommon<br/>Utility Methods"]
    B -->|"delegates to"| F["JCCWebCommon<br/>Common Methods"]
    B -->|"calls"| G["CRSV0084_CRSV0084OPDBMapper<br/>Service Mapper"]
    B -->|"calls"| H["CRSV0281_CRSV0281OPDBMapper<br/>Reissue Mapper"]

    B -->|"navigates to"| I["CRW00101<br/>Inquiry Input/Edit"]
    B -->|"navigates to"| J["CRW00401<br/>Hotvoice Reg"]
    B -->|"navigates to"| K["CRW02401<br/>Cust Info Search"]
    B -->|"navigates to"| L["CRW03410<br/>ID Cert Reissue"]
    B -->|"navigates to"| M["CHW00105<br/>Billing Detail"]
    B -->|"navigates to"| N["CRW10301<br/>Quick Send"]
    B -->|"navigates to"| O["KKW00196<br/>Member Link"]
    B -->|"navigates to"| P["KKW00198<br/>Contract Link"]
```

**Inbound connections** (classes that depend on CRW03409SFLogic):
- **WEBGAMEN_CRW034090PJP.xml** — The JSP page presentation layer. This XML references CRW03409SFLogic as the action delegate for the inquiry support screen.
- **x31business_logic_CRW03409SF.xml** — The X31 business logic configuration file. This XML declares the mapping between screen events and the logic class methods.

**Outbound dependencies**:
- **JCCWebBusinessLogic** — The base class providing common web business logic patterns, including `getServiceFormBean()`, `getCommonInfoBean()`, `invokeService()`, and other framework methods.

## Usage Example

The typical lifecycle of `CRW03409SFLogic` in a web request:

```
1. User navigates to the inquiry support screen
   → WEBGAMEN_CRW034090PJP.xml forwards the event to CRW03409SFLogic.init()
   → init() loads service contract data, device info, progress, phone, billing
   → init() calculates fees, replaces default dates, maps status to tab
   → init() sets navigation metadata (NEXT_SCREEN_ID = CRW03409)
   → Screen renders with all data populated

2. User clicks a tab (e.g., "Inquiry")
   → clickTab() refreshes MYBOX/QueryBOX/mail counts
   → clickTab() checks if it's the main tab (calls init()) or a sub-tab (sets screen ID)

3. User clicks "Accept" on an inquiry
   → accept() calls JCRWebCommon.execAccept() (backend service)
   → accept() calls refresh() which reinitializes the full screen

4. User clicks a billing period link
   → clickLinkSeikyYm() extracts row data from bean array
   → clickLinkSeikyYm() sets up screen info for CHW00105 (billing detail)
   → User is redirected to the billing detail sub-screen

5. User clicks "Inquiry Input" button
   → openCrw00101Ins() copies bean data via copyBeanToToiawaseIns()
   → openCrw00101Ins() sets screen info for CRW00101 (inquiry input)
   → User is redirected to the inquiry input sub-screen
```

## Notes for Developers

- **Auto-generated scaffold**: The `receiveMessageWeb()` method is an unimplemented override from an auto-generation tool. It currently just returns `false`. The actual entry point is `init()`, called by the JSP framework.
- **Six-phase pattern**: Every public method follows the same six-section structure (inherited info → bean setup → service call → result setting → navigation setup → common bean setup). This is a deliberate convention — new methods should follow this pattern.
- **Bean access**: All methods obtain the service form bean via `getServiceFormBean()` and the common info bean via `getCommonInfoBean()`. Never store bean references as instance fields — always fetch fresh on each method call.
- **Screen navigation**: Child screens are navigated via `JCRWebCommon.setScreenId()` (sets parent→child screen ID relationship) and `JCRWebCommon.setScreenInfo()` (passes bean data to the next screen). The parent tab ID is always preserved in the `SENYO_TAB_ID` constant.
- **Error handling**: Most methods always return `true` — errors are communicated via `JCCWebCommon.setMessageInfo()` which sets error messages on the logic object rather than throwing. The `invokeService()` method returns `X31CMessageResult` which is checked for non-null (indicating an error).
- **Service mappers**: The `CRSV0084` mapper handles the main data load. It has 15+ `set*SC()` and `get*SC()` methods that map to different backend service endpoints (service info, device info, progress, phone, billing, etc.). The additional `CRSV008413SC` through `CRSV008419SC` methods were added in v10.00.00 for dedicated tab support.
- **Re-issue workflow**: `clickSaihakko()` and `openCrw03410()` form a two-step re-issue flow. First validate membership type, then open the reissue screen if validation passes. The `CRW03410_OPN_FLG` flag gates whether the reissue screen can be opened.
- **Date replacement**: The `20991231` placeholder is replaced with blank throughout `init()` using `JZMWebCommon.replaceTendymd()`. This is a business convention where "no end date" is represented as 2099/12/31.
- **Thread safety**: As a web screen logic class instantiated per request, there is no shared mutable state across requests. Instance fields are only the two `static final` constants (`SENYO_TAB_ID` and `SENYO_TAB_NAME`). Safe for servlet container's per-request instantiation model.
- **Japanese comments**: The source is heavily commented in Japanese. The comments describe the six-phase processing structure in detail (sections labeled `(1)` through `(6)`). Many methods have sections marked `なし` (none) indicating that particular phase requires no action.