```mermaid
---
title: 0.套餐设计流程（包含佣金设计）
---
flowchart TD
    Start((开始))
    --> Login[使用平台管理员账号登录]

    Login --> HasPermission{是否有套餐与分配管理权限?}
    HasPermission -->|否| NoPermission[无权限，流程终止]
    HasPermission -->|是| EnterDesign[进入套餐系列与套餐管理]

    subgraph SeriesDesignFlow[系列与套餐设计]
        EnterDesign --> CreateSeries[新建套餐系列]
        CreateSeries --> EnableOneTime{是否启用一次性佣金?}

        EnableOneTime -->|否| SeriesReady[保存系列基础信息]
        EnableOneTime -->|是| SetTrigger[设置触发方式<br/>首充 或 累计充值]

        SetTrigger --> SetCommissionType{选择佣金模式}
        SetCommissionType -->|固定模式| SetFixedCommission[设置固定佣金金额]
        SetCommissionType -->|梯度模式| SetTierCommission[设置梯度档位与金额]

        SetFixedCommission --> SetValidity[设置规则生效时效]
        SetTierCommission --> SetValidity
        SetValidity --> SeriesReady

        SeriesReady --> CreatePackage[创建该系列下套餐]
        CreatePackage --> SetPackageInfo[填写套餐信息<br/>成本价、建议售价、周期、流量额度]
        SetPackageInfo --> PackageReview{套餐信息是否完整?}

        PackageReview -->|否| FixPackageInfo[返回补充套餐信息]
        FixPackageInfo --> SetPackageInfo
        PackageReview -->|是| PackageReady[系列与套餐设计完成]
    end

    subgraph ForceRechargeFlow[强充规则设计（单独分支）]
        SetTrigger --> TriggerTypeCheck{触发方式是首充吗?}
        TriggerTypeCheck -->|是| FirstRechargeRule[首充模式：设置首充门槛]
        TriggerTypeCheck -->|否| AccumulatedRule[累计模式：设置累计门槛]

        FirstRechargeRule --> ForceRuleReady[强充规则确定]
        AccumulatedRule --> NeedForceRecharge{累计模式是否启用强充?}
        NeedForceRecharge -->|是| SetForceAmount[设置强充金额]
        NeedForceRecharge -->|否| NoForceRecharge[不启用强充]

        SetForceAmount --> ForceRuleReady
        NoForceRecharge --> ForceRuleReady
    end

    PackageReady --> ToCommissionSystemFlow[进入 0.代理佣金体系设计流程]
    ToCommissionSystemFlow --> ToAllocationFlow[进入 5.套餐分配流程（本图不展开）]
    ForceRuleReady --> ToAllocationFlow

    ToAllocationFlow --> AllocationDone{是否已完成套餐分配?}
    AllocationDone -->|否| WaitAllocation[先完成套餐分配后再验收]
    WaitAllocation --> ToAllocationFlow
    AllocationDone -->|是| StartAcceptance[开始业务验收]

    subgraph AcceptanceFlow[业务验收与佣金核对]
        StartAcceptance --> AdminOrderVerify[后台创建测试订单并完成购买<br/>用于验证套餐可购与基础佣金链]
        AdminOrderVerify --> NeedCCheck{是否需要验收强充规则?}

        NeedCCheck -->|否| CheckCommissionEntry[进入后台「代理商资金管理」页面]
        NeedCCheck -->|是| ClientOrderVerify[使用C端发起购买并完成支付]

        ClientOrderVerify --> HitForceRule{C端购买是否命中强充规则?}
        HitForceRule -->|是| ForceRechargePath[按强充要求完成充值并继续购买]
        HitForceRule -->|否| DirectBuyPath[按正常流程购买]

        ForceRechargePath --> CheckCommissionEntry
        DirectBuyPath --> CheckCommissionEntry

        CheckCommissionEntry --> CheckAmount[在「佣金明细」核对佣金金额]
        CheckAmount --> CheckOwner[在「佣金明细」核对佣金归属权]
        CheckOwner --> CheckManualReview[在「佣金明细」筛选待审状态<br/>核对是否进入人工核查]
        CheckManualReview --> CommissionOK{验收是否通过?}

        CommissionOK -->|是| End([流程结束])
        CommissionOK -->|否| IssueType{问题属于哪类?}
        IssueType -->|规则设计问题| BackToDesign[回到系列与佣金规则调整]
        IssueType -->|分配问题| BackToAllocation[回到 5.套餐分配流程调整]

        BackToDesign --> EnterDesign
        BackToAllocation --> ToAllocationFlow
    end

    %% ==================== 样式美化 ====================
    style Start fill:#90EE90,stroke:#2E7D32,stroke-width:2px
    style End fill:#FF9999,stroke:#C62828,stroke-width:2px
    style NoPermission fill:#FFCDD2,stroke:#D32F2F
    style BackToDesign fill:#FFCCBC,stroke:#E64A19
    style BackToAllocation fill:#FFCCBC,stroke:#E64A19
    style FixPackageInfo fill:#FFCCBC,stroke:#E64A19

    classDef decision fill:#FFF3E0,stroke:#F57C00,stroke-width:2px
    class HasPermission,EnableOneTime,SetCommissionType,PackageReview,TriggerTypeCheck,NeedForceRecharge,AllocationDone,NeedCCheck,HitForceRule,CommissionOK,IssueType decision
```
