5.6 KiB
5.6 KiB
Commission Share Guide
1. Purpose
This document describes the end-to-end flow channel commission → agent tree split → admin wallet credit, so operations, finance, and engineering share the same configuration and settlement rules.
2. Overall Structure (Two Layers + Tree)
Commission is calculated in two steps:
A. Layer 1: Channel settlement (platform → channel)
- Compute channel total commission from
channel.agent_mode:- turnover: base = sum of settled bet amounts; commission = total bet ×
turnover_share_rate - affiliate: base = platform profit after cost deduction; commission = base × ladder share rate
- turnover: base = sum of settled bet amounts; commission = total bet ×
- Data scope:
bet_order.status = 2(settled), period = last settlement end ~ current settlement time - Output:
agent_settlement_periodsnapshot
B. Layer 2: Agent tree split (channel total → each admin’s net amount)
- Do not configure flat channel-wide shares on the channel page (
channel_admin_shareis deprecated in UI; table may remain for history) - Maintain the agent tree in Administrator Management (
/admin/auth/admin):parent_admin_id: parent agent (empty for top-level)commission_share_rate: percentage taken from parent’s commission for this period (sub-agents only)
- At settlement,
AdminCommissionDistributionServicesplits recursively:- Channel total commission goes to top-level agent(s) (
parent_admin_idis null) - Each agent allocates to direct children by
commission_share_ratefrom their own received amount - Parent keeps = received amount − sum allocated to children
- Channel total commission goes to top-level agent(s) (
Example (parent receives 3000 this period):
| Sub-agent | Rate | Amount |
|---|---|---|
| Sub-agent A | 20% | 600 |
| Sub-agent B | 40% | 1200 |
| Parent | — | 1200 (3000 − 600 − 1200) |
If a sub-agent has further downline, the same rules apply on their received amount.
3. Configuration & Permissions
| Capability | Entry | Notes |
|---|---|---|
| Channel commission params | /admin/channel |
agent_mode, turnover/affiliate rates, settlement cycle, etc. |
| Agent tree & share rates | /admin/auth/admin |
Tree list; parent agent, share rate, channel |
| Channel filter | Admin list common search | Super admin can filter by channel |
| Visibility | Admin list | Non–super admin sees self + all downline only |
| Settlement | /admin/channel manual / cron |
Super admin only; credits admin_wallet on settle |
3.1 Sub-agent share validation
- Under the same
parent_admin_id, enabled sub-agents’commission_share_ratemust not exceed 100% in total - Form shows remaining allocatable rate when creating/editing sub-agents
- If total is 100%, parent keeps no commission at this level
- Top-level agents (no parent) do not set
commission_share_rate
3.2 Role groups
admin_groupis for menu/data permissions only- Not used in amount calculation
4. Settlement Flow
- Super admin triggers channel settlement (manual or
ChannelAutoSettleTicker) ChannelSettlementService::buildSettlePayloadaggregates bets and computes channel total commissionAdminCommissionDistributionService::distributeChannelCommissionsplits by agent tree- In one transaction:
- Insert
agent_settlement_period(status = 2completed) - Insert
agent_commission_recordper admin with amount > 0 (status = 1paid) AdminWalletService::creditCommission→admin_wallet+admin_wallet_record(biz_type = commission_income)
- Insert
- Reset
channel.carryover_balanceto 0 (settle-and-pay; no channel pending pool)
Prerequisite: at least one top-level agent for the channel (channel_id match, parent_admin_id empty); otherwise settlement fails.
5. Recommended wording (operations / stakeholders)
- Channel commission: computed from settled bets for the period (not from deposit volume).
- Distribution: total commission enters the channel top agent, then splits down by parent/child and share rates in Administrator Management; parent keeps the remainder after paying children.
- Role groups: permissions only, not money.
- Traceability: each
agent_commission_recordlinks toagent_settlement_period; walletcommission_incometraces back to commission records.
6. Core fields
| Table / field | Role |
|---|---|
channel.agent_mode / turnover_share_rate / affiliate_* |
Channel commission calculation |
admin.parent_admin_id |
Parent agent |
admin.channel_id |
Channel |
admin.commission_share_rate |
Share from parent (%); null for top-level |
agent_settlement_period |
Settlement period snapshot |
agent_commission_record |
Paid commission per admin |
admin_wallet / admin_wallet_record |
Admin wallet & ledger |
Legacy
channel_admin_share: flat 100% split (2026-04-18); tree split since 2026-05-29. Do not configure via this table.
7. Related code
| Module | Path |
|---|---|
| Channel settlement | app/common/service/ChannelSettlementService.php |
| Tree split | app/common/service/AdminCommissionDistributionService.php |
| Admin CRUD / validation | app/admin/controller/auth/Admin.php |
| Admin UI | web/src/views/backend/auth/admin/ |
| Auto settlement | app/process/ChannelAutoSettleTicker.php |
8. Changelog
| Date | Change |
|---|---|
| 2026-04-18 | channel_admin_share flat split; removed admin/admin_group.commission_rate |
| 2026-04-23 | Settle-and-pay to admin wallet; admin_wallet system |
| 2026-05-29 | Agent tree commission in Administrator Management; removed channel share UI; tree list & downline visibility |