---
title: "setPayFlg"
category: "FUW02501SFLogic"
created_at: "2026-06-29"
updated_at: "2026-06-29"
tags:
  - FUW02501SF
---

# Business Logic — FUW02501SFLogic.setPayFlg() [31 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `eo.web.webview.FUW02501SF.FUW02501SFLogic` |
| Layer | Service (Web) |
| Module | `FUW02501SF` (Package: `eo.web.webview.FUW02501SF`) |

## 1. Role

### FUW02501SFLogic.setPayFlg()

This method determines whether the home page analysis service order incurs charges (有料フラグ設定). It operates within the context of the K-Opticom customer core system's "Home Page Analysis Service Order" (ホームページアクセス分析サービス申込) business domain — a telecom value-added analytics service that allows broadband subscribers to monitor their internet usage and access statistics.

The method implements a conditional billing determination algorithm that first calculates the remaining free usage allowance (残数) by subtracting the current contract count (keiCnt) from the service-provided free allowance (Svctk But Mryo Value). It then performs a paid pricing check (kotei tanka yu-mu check) by delegating to `chkPayKoteiTanka()`, which inspects whether any fixed-unit-price (fixed monthly fee) items exist in the pricing plan.

The method follows a delegation design pattern: it handles the free-count arithmetic and top-level conditional routing, while outsourcing the fixed-price detection logic to the separate `chkPayKoteiTanka()` method. Its return value is a boolean flag set into the data bean as `PAY_FLG`, which feeds directly into the UI to indicate whether the customer will be billed (true = charged /有料) or not (false = free /無料).

Within the larger system, this method is invoked during the screen initialization flow (called from `FUW02501SFLogic.init()`) to compute the billing flag before the home page analysis service order form is rendered to the customer. It acts as a gatekeeper for display logic — the UI uses this flag to conditionally present pricing information, payment fields, or billing notices.

The method branches into three logical outcomes: (1) Fixed price exists AND free count is exhausted (mryoCnt <= 0) → charge (true); (2) Fixed price exists AND free count remains → no charge (false); (3) No fixed price at all → no charge (false).

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["setPayFlg begin"])
    
    START --> INIT_RES["res = false"]
    
    INIT_RES --> GET_FREE["hpAcsMryoCnt = bean.sendMessageLong(SVCTK_BUT_MRYO_VALUE, DATABEAN_GET_VALUE)"]
    
    GET_FREE --> CALC_MRYO["mryoCnt = hpAcsMryoCnt - keiCnt"]
    
    CALC_MRYO --> CHK_KOTEI{"chkPayKoteiTanka(outputMap)?"}
    
    CHK_KOTEI -->|true| CHK_MRYO{"mryoCnt <= 0?"}
    CHK_KOTEI -->|false| ELSE_KOTEI["res = false"]
    
    CHK_MRYO -->|true| SET_TRUE["res = true"]
    CHK_MRYO -->|false| SET_FALSE["res = false"]
    
    SET_TRUE --> RETURN_END["return res"]
    SET_FALSE --> RETURN_END
    ELSE_KOTEI --> RETURN_END
```

**Constant Resolutions:**

| Constant | Actual Value | Business Meaning |
|----------|-------------|------------------|
| `SVCTK_BUT_MRYO_VALUE` | "サービス提供無料値" | Service-provided free allowance — the number of free usage units provided by the service |
| `PAY_FLG` | "有料フラグ" | Paid flag — result stored in data bean to indicate billing status |
| `DATABEAN_GET_VALUE` | system constant | Data bean get-value operation |
| `DATABEAN_SET_VALUE` | system constant | Data bean set-value operation |

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| 1 | `bean` | `X31SDataBeanAccess` | The data bean access object used to retrieve and set cross-screen data. It carries the service-provided free allowance value (`SVCTK_BUT_MRYO_VALUE`) — the total number of free usage units allocated to the subscriber for the home page analysis service. |
| 2 | `outputMap` | `HashMap<String, Object>` | The output map populated during screen initialization. It contains pricing plan data under the key `SC_TITLE_FUSV006902` ("FUSV006902SC"), which holds a nested map with the `EKK0601B001_LIST` ("EKK0601B001CBSMsg1List") key containing an `ArrayList` of pricing plan child items, each with a `PPLAN_KOTEI_AMNT` ("pplan_kotei_amnt") field representing the fixed monthly fee amount. |
| 3 | `keiCnt` | `int` | The subscription service contract count — the number of active service contract lines associated with this order. This value is subtracted from the free allowance to compute the remaining free usage count (mryoCnt). |

**Instance/External State Read:**

| Source | Description |
|--------|-------------|
| `bean.sendMessageLong()` | Reads the service-provided free allowance from the data bean. This value is pre-populated during screen initialization from the service configuration. |

## 4. CRUD Operations / Called Services

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

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `FUW02501SFLogic.chkPayKoteiTanka` | FUW02501SFLogic | - | Calls `chkPayKoteiTanka()` in `FUW02501SFLogic` |

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| R | `bean.sendMessageLong()` | FUW02501SFLogic | - | Read — retrieves the service-provided free allowance value (SVCTK_BUT_MRYO_VALUE = "サービス提供無料値") from the data bean. This is a data bean getter call, not a DB operation. |
| R | `chkPayKoteiTanka()` | FUW02501SFLogic | FUSV006902SC / EKK0601B001CBSMsg1List | Read — delegates to `chkPayKoteiTanka()` which inspects the pricing plan data in the outputMap. It checks for fixed-unit-price items under the FUSV006902SC key, traverses the EKK0601B001CBSMsg1List child list, and evaluates PPLAN_KOTEI_AMNT (pplan_kotei_amnt) values. The data originates from the FUSV006902SC (FUSV0069_FUSV0069OPDBMapper) service component which maps to pricing plan table data. |

**Classification Rationale:**
- No Create, Update, or Delete operations are performed. This method is purely a read and compute operation.
- `chkPayKoteiTanka()` traverses the `outputMap` which was populated during `init()` by calls to `JFUWebCommon.setFreePrcInfoMap()` and `JFUWebCommon.setPrcInfoArea()`, which in turn use `FUSV0069_FUSV0069OPDBMapper` to fetch pricing plan data from the database.

## 5. Dependency Trace

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

No screen/batch entry points found within 8 hops. Direct callers found: 1 methods.
Terminal operations from this method: `chkPayKoteiTanka` [-]

Trace of who calls this method and what this method ultimately calls.

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | FUW02501SFLogic | `init()` -> `setPayFlg(bean, outputMap, sbopSvcKeiCnt)` -> `bean.sendMessageBoolean(PAY_FLG, DATABEAN_SET_VALUE, result)` | `chkPayKoteiTanka()` [R] FUSV006902SC / EKK0601B001CBSMsg1List |

**Caller Details:**
- **FUW02501SFLogic.init()** — The screen initialization method at line 162 calls `setPayFlg()` with the bean, outputMap, and `sbopSvcKeiCnt` (subscription service contract count, backed by the `SBOP_SVC_KEI_CNT` field). The result is immediately written back into the data bean under the `PAY_FLG` key ("有料フラグ").
- The `init()` method is the entry point for the FUW02501SF screen (Home Page Analysis Service Order). It performs common info bean retrieval, customer contract data fetching, and then calls `setPayFlg()` as part of its initialization sequence before rendering the order form.

## 6. Per-Branch Detail Blocks

**Block 1** — [IF] `(mryoCnt <= 0)` [Fixed price exists AND free count exhausted] (L661)

> When the fixed price check passes (chkPayKoteiTanka returns true) and the remaining free count is zero or negative (all free units consumed), the method sets the billing flag to true, indicating the customer should be charged.

| # | Type | Code |
|---|------|------|
| 1 | SET | `res = true` // Fixed price present & no free count remaining — mark as charged |

**Block 2** — [ELSE] `(mryoCnt > 0)` [Fixed price exists AND free count available] (L664)

> When the fixed price check passes but there are still remaining free usage units (mryoCnt > 0), the method sets the billing flag to false — the customer's free allowance has not been exhausted.

| # | Type | Code |
|---|------|------|
| 1 | SET | `res = false` // Fixed price present but free count available — not yet charged |

**Block 3** — [ELSE] `(chkPayKoteiTanka returns false)` [No fixed price] (L668)

> When no fixed-unit-price items exist in the pricing plan (chkPayKoteiTanka returns false), regardless of the free count, the method sets the billing flag to false. Without a fixed monthly fee, there is no charge mechanism.

| # | Type | Code |
|---|------|------|
| 1 | SET | `res = false` // No fixed price configured — always free |

**Block N** — [RETURN] `(end of method)` (L671)

| # | Type | Code |
|---|------|------|
| 1 | RETURN | `return res` // true = charged (有料), false = free (無料 — no payment required) |

**Control Flow Summary (Blocks preceding the if-else chain):**

**Pre-Block 0** — [INITIALIZATION] (L649–L659)

| # | Type | Code |
|---|------|------|
| 1 | SET | `boolean res = false` // Initialize result to false (free) by default |
| 2 | EXEC | `hpAcsMryoCnt = bean.sendMessageLong(SVCTK_BUT_MRYO_VALUE, X31CWebConst.DATABEAN_GET_VALUE).intValue()` // Read the service-provided free allowance from the data bean. SVCTK_BUT_MRYO_VALUE = "サービス提供無料値" (Service-provided free amount) |
| 3 | SET | `mryoCnt = hpAcsMryoCnt - keiCnt` // Calculate remaining free count = free allowance minus the number of active subscription service contracts |
| 4 | CALL | `chkPayKoteiTanka(outputMap)` // Delegate to fixed-price existence check. Returns true if any fixed-unit-price item in the pricing plan has an amount > 0. |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `setPayFlg` | Method | Paid flag setter — determines whether the current home page analysis service order incurs a charge |
| `chkPayKoteiTanka` | Method | Fixed-unit-price paid check — inspects pricing plan data to determine if any fixed monthly fee items exist with amount > 0 |
| `pay_flg` / `PAY_FLG` | Field | Paid flag — "有料フラグ". true means charged/billed, false means free (no payment required) |
| `mryoCnt` / `残数` | Field | Remaining count — the number of remaining free usage units after subtracting contract count from the total free allowance |
| `hpAcsMryoCnt` | Field | Home Page Access Free Count — the total free allowance value retrieved from the service-provided free amount value in the data bean |
| `keiCnt` | Parameter | Contract count — the number of subscription service contract lines for this order |
| `sbopSvcKeiCnt` | Field | Subscription Service Contract Count — backed by `SBOP_SVC_KEI_CNT` ("sbop_svc_kei_cnt"), passed to setPayFlg during init() |
| `SVCTK_BUT_MRYO_VALUE` | Constant | "サービス提供無料値" (Service-provided free amount) — the total number of free usage units allocated by the service for the home page analysis feature |
| `SC_TITLE_FUSV006902` | Constant | "FUSV006902SC" — key in outputMap for pricing plan fixed-unit-price (option charge) list service component data |
| `CC_TITLE_FUSV006901` | Constant | "FUSV006901CC" — key in outputMap for initial cost list check component data |
| `EKK0601B001_LIST` | Constant | "EKK0601B001CBSMsg1List" — key for the pricing plan child item list containing fixed-unit-price entries |
| `EKK0721A010_LIST` | Constant | "EKK0721A010CBSMsg1List" — key for the initial cost list |
| `PPLAN_KOTEI_AMNT` | Constant | "pplan_kotei_amnt" — fixed unit price amount field in a pricing plan child item. Amount > 0 indicates a paid (有料) pricing tier exists |
| FUSV0069 | Service ID | Home Page Analysis Service Order (initial display) — service identifier for the analytics service screen |
| FUSV0070 | Service ID | Home Page Analysis Service Order (order submission) — service identifier for the order submission flow |
| FUSV006902SC | SC Code | Pricing plan fixed-unit-price (option charge) list Service Component — maps pricing plan data for the order screen |
| FUSV006901CC | CC Code | Initial cost list Check Component — maps initial cost data for display |
| X31SDataBeanAccess | Technical | X31S framework data bean access class — provides cross-screen data passing via key-value pairs |
| X31CWebConst | Technical | X31C framework web constants — provides system constants like DATABEAN_GET_VALUE and DATABEAN_SET_VALUE |
| `chkPayInitialCost` | Method | Initial cost existence check — determines whether initial/one-time fees are present for the order |
| `JFUWebCommon` | Technical | Web common utility class providing shared screen initialization helpers (setFreePrcInfoMap, setPrcInfoArea) |
| FUSV0069_FUSV0069OPDBMapper | Technical | Database mapper for FUSV0069 — maps pricing plan screen data to/from database entities |
