Invitation Commission
RavenSaaS implements an invitation commission system. You can use this system in your product to incentivize users to invite new users.
How to Use
Usage Steps
User generates invitation link
Users can go to the /users/my-invites page to generate their own invitation links.

Share invitation link
The invitation link shared by users looks like:http://localhost:3000/i/LdO51N
New user registration
New users who enter the system through the sharer's invitation link will be automatically associated with the sharer.
View invitation records
Sharers can view invitation records and invitation rewards on the /users/my-invites page.
Admin backend management
Administrators can view invitation records and invitation rewards in the backend.

注意:Online automatic withdrawal is not currently supported. Administrators need to manually contact users to distribute rewards.
Database Structure
Invitation Commission Table
1CREATE TABLE affiliates (
2 id SERIAL PRIMARY KEY,
3 user_uuid VARCHAR(255) NOT NULL,
4 paid_order_no VARCHAR(255),
5 status VARCHAR(50) NOT NULL,
6 paid_amount INT,
7 reward_percent INT,
8 reward_amount INT,
9 invited_by VARCHAR(50),
10 created_at timestamptz
11);
Custom Reward Rules
Default Reward Rules
Current default rules:
- • New user registration through invitation link: Only record status, no reward issued
- • User payment: Give inviter 20% amount reward
When new users register, the /src/app/api/payment/orders/create interface will be requested. You can modify the logic of this interface to change the reward rules for new user registration scenarios.
1await insertAffiliate({
2 user_uuid: session.user.uuid,
3 invited_by: user.invited_by,
4 status: AffiliateStatus.Pending,
5 paid_order_no: orderNo || "",
6 paid_amount: 0,
7 reward_percent: AffiliateRewardPercent.Paied,
8 reward_amount: 0,
9 created_at: new Date().toISOString(),
10});