パッケージモジュール

説明

パッケージモジュールは、Trend Viewer API システム内でサブスクリプションパッケージ定義と機能アクセス制御を管理します。クライアントが利用可能なパッケージや具体的なパッケージプランを発見できる読み取り用 API を提供し、Checkout/Subscription フローで使用するプロバイダ連携(例: Stripe の Product/Price ID)をサポートします。

主な機能

  1. パッケージカタログ

    • パッケージと機能(制限、可視性、API 利用可否)の集中管理
    • クライアントアプリおよび管理ツール向けに読み取りエンドポイントを提供
  2. パッケージプランと価格

    • パッケージごとに複数プランを定義(通貨、金額、請求サイクル)
    • 決済プロバイダとの連携(Price ID)
  3. プロバイダマッピング

    • 決済プロバイダ(例: Stripe の Product/Price ID)との対応付け
    • Checkout/Subscription 時の一貫した連携を保証
  4. 機能アクセス制御

    • メンバー、商品グループ、商品、カテゴリ、検索クエリ、ビューポイントなどの各種上限を制御
    • パッケージごとの段階的な機能可視性を実現

概要フローダイアグラム

---
config:
  theme: base
  layout: dagre
  flowchart:
    curve: linear
    htmlLabels: true
  themeVariables:
    edgeLabelBackground: "transparent"
---
flowchart TD
    %% Actors
    Client[Consumer]

    %% API Controller Layer
    subgraph ApiControllerLayer["API Controller Layer"]
        PackageController[PackageController]
        PackagePlanController[PackagePlanController]
    end

    %% Repository Layer
    subgraph RepositoryLayer["Repository Layer"]
        PackageRepository(PackageRepository)
        PackagePlanToProviderRepository(PackagePlanToProviderRepository)
    end

    %% Database Layer
    subgraph DatabaseLayer["Database Layer"]
        PackagesDB[(packages)]
        PackagePlansDB[(package_plans)]
        PlanToProvidersDB[(package_plan_to_providers)]
        ProvidersDB[(payment_providers)]
        PackageToProvidersDB[(package_to_providers)]
    end

    %% Packages listing flow
    Client --- P1[
        <div style='text-align: center'>
            <span style='display: inline-block; background-color: #6699cc !important; color:white; width: 28px; height: 28px; line-height: 28px; border-radius: 50%; font-weight: bold'>1</span>
            <p style='margin-top: 8px'>パッケージ一覧をリクエスト</p>
        </div>
    ]
    P1 --> PackageController
    PackageController --- P2[
        <div style='text-align: center'>
            <span style='display: inline-block; background-color: #6699cc !important; color:white; width: 28px; height: 28px; line-height: 28px; border-radius: 50%; font-weight: bold'>2</span>
            <p style='margin-top: 8px'>リポジトリから取得</p>
        </div>
    ]
    P2 --> PackageRepository
    PackageRepository --> PackagesDB
    PackageRepository --> PackagePlansDB
    PackageRepository --> PackageToProvidersDB
    PackageRepository --> ProvidersDB

    %% Package plan listing flow
    Client --- PP1[
        <div style='text-align: center'>
            <span style='display: inline-block; background-color: #99cc66 !important; color:white; width: 28px; height: 28px; line-height: 28px; border-radius: 50%; font-weight: bold'>1'</span>
            <p style='margin-top: 8px'>パッケージプランをリクエスト</p>
        </div>
    ]
    PP1 --> PackagePlanController
    PackagePlanController --- PP2[
        <div style='text-align: center'>
            <span style='display: inline-block; background-color: #99cc66 !important; color:white; width: 28px; height: 28px; border-radius: 50%; font-weight: bold'>2'</span>
            <p style='margin-top: 8px'>リポジトリから取得</p>
        </div>
    ]
    PP2 --> PackagePlanToProviderRepository
    PackagePlanToProviderRepository --> PackagePlansDB
    PackagePlanToProviderRepository --> PlanToProvidersDB
    PackagePlanToProviderRepository --> PackagesDB
    PackagePlanToProviderRepository --> ProvidersDB

    %% Styling
    style Client fill:#e6f3ff,stroke:#0066cc,stroke-width:2px
    style ApiControllerLayer fill:#e6f3ff,stroke:#0066cc,stroke-width:2px
    style RepositoryLayer fill:#f0f8e6,stroke:#339933,stroke-width:2px
    style DatabaseLayer fill:#ffe6cc,stroke:#ff9900,stroke-width:2px
    style P1 fill:transparent,stroke:transparent,stroke-width:1px
    style P2 fill:transparent,stroke:transparent,stroke-width:1px
    style PP1 fill:transparent,stroke:transparent,stroke-width:1px
    style PP2 fill:transparent,stroke:transparent,stroke-width:1px

機能一覧テーブル

名前 リンク 説明
パッケージ パッケージ サブスクリプションパッケージ管理と機能アクセス制御

関連データベース

erDiagram
    packages {
        bigint id PK "主キー"
        string name "パッケージ名"
        string slug "パッケージスラッグ(一意)"
        text description "説明(null 可)"
        text image "画像パス(null 可)"
        integer schedule_id "スケジュール ID"
        integer schedule_priority "スケジュール優先度"
        integer max_member "メンバー上限(null 可)"
        integer max_product_group "商品グループ上限(null 可)"
        integer max_product "商品上限(null 可)"
        integer max_category "カテゴリ上限(null 可)"
        integer max_search_query "検索クエリ上限(null 可)"
        integer max_viewpoint "ビューポイント上限(null 可)"
        string data_visible "データ可視性"
        tinyint api_available "API 利用可否"
        tinyint status "ステータス"
        timestamp created_at "作成日時"
        timestamp updated_at "更新日時"
    }

    package_plans {
        bigint id PK "主キー"
        string name "プラン名"
        string slug "プランスラッグ(一意)"
        bigint package_id FK "packages テーブルへの外部キー"
        double amount "金額"
        string currency "通貨"
        string type "プラン種別(recurring, one_time)"
        string billing_plan "請求サイクル"
        tinyint status "ステータス"
        timestamp created_at "作成日時"
        timestamp updated_at "更新日時"
    }

    package_plan_to_providers {
        bigint id PK "主キー"
        bigint package_plan_id FK "package_plans テーブルへの外部キー"
        bigint provider_id FK "payment_providers テーブルへの外部キー"
        string provider_price_id "プロバイダの価格 ID(Stripe)"
        tinyint status "ステータス"
        timestamp created_at "作成日時"
        timestamp updated_at "更新日時"
    }

    package_to_providers {
        bigint id PK "主キー"
        bigint package_id FK "packages テーブルへの外部キー"
        bigint provider_id FK "payment_providers テーブルへの外部キー"
        string provider_product_id "プロバイダのプロダクト ID(Stripe)"
        tinyint status "ステータス"
        timestamp created_at "作成日時"
        timestamp updated_at "更新日時"
    }

    payment_providers {
        bigint id PK "主キー"
        string name "プロバイダ名"
        string slug "プロバイダスラッグ(一意)"
        tinyint status "ステータス"
        timestamp created_at "作成日時"
        timestamp updated_at "更新日時"
    }

    packages ||--o{ package_plans : has
    package_plans ||--o{ package_plan_to_providers : has
    packages ||--o{ package_to_providers : has
    payment_providers ||--o{ package_plan_to_providers : linked
    payment_providers ||--o{ package_to_providers : linked

関連 API エンドポイント

メソッド エンドポイント コントローラ 説明
GET /api/admin/groups/packages PackageController@index 利用可能なサービスパッケージ一覧を取得
GET /api/general/package-plan PackagePlanController@index サービスパッケージプラン一覧を取得