Logo
RavenSaaS Docs

Points Management

RavenSaaS has a built-in points management system that helps developers implement user recharge to get points / use services to deduct points and other logic.

And provides users with a points management page to view point balance and point consumption records.

积分管理系统
积分管理系统界面

Configure Points Management System

1. Create Database Tables

Please ensure you have configured the database, copy the following SQL statement to create the points table.

data/install.sql
1CREATE TABLE credits (
2    id SERIAL PRIMARY KEY,
3    trans_no VARCHAR(255) UNIQUE NOT NULL,
4    created_at timestamptz,
5    user_uuid VARCHAR(255) NOT NULL,
6    trans_type VARCHAR(50) NOT NULL,
7    credits INT NOT NULL,
8    order_no VARCHAR(255),
9    expired_at timestamptz
10);

2. New User Reward Points

You can modify the following logic as needed to give reward points to new users:

新用户赠送积分
新用户注册赠送积分逻辑

3. Recharge Points

Modify the pricing table configuration and add fields to implement recharge to purchase points and set expiration dates for points.

积分充值配置
价格表配置积分充值

4. Consume Points

You can implement your own point deduction logic as needed. For example, deduct 2 points when a user generates an image, deduct 3 points when generating a video, etc.

Before deducting points, first check the user's point balance. If the balance is insufficient, prompt the user to recharge.

积分消费扣除
积分消费扣除逻辑