Skip to content

Commit

Permalink
feat(server): add signup bonus (#1531)
Browse files Browse the repository at this point in the history
  • Loading branch information
HUAHUAI23 authored Sep 12, 2023
1 parent 18be379 commit b5858c7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
13 changes: 11 additions & 2 deletions server/src/account/account.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
InviteRelation,
} from 'src/authentication/entities/invite-code'
import { AccountChargeOrderQuery } from './interface/account-query.interface'
import { Setting, SettingKey } from 'src/setting/entities/setting'

@Injectable()
export class AccountService {
Expand All @@ -34,10 +35,18 @@ export class AccountService {
) {}

async create(userid: ObjectId): Promise<Account> {
// get signup Profit Amount
let amount = 0
const signupBonus = await this.db.collection<Setting>('Setting').findOne({
key: SettingKey.SignupBonus,
})
if (signupBonus) {
amount = parseFloat(signupBonus.value)
}
await this.db.collection<Account>('Account').insertOne({
balance: 0,
balance: amount,
state: BaseState.Active,
createdBy: new ObjectId(userid),
createdBy: userid,
createdAt: new Date(),
updatedAt: new Date(),
})
Expand Down
7 changes: 7 additions & 0 deletions server/src/initializer/initializer.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,13 @@ export class InitializerService {
return
}

await this.db.collection<Setting>('Setting').insertOne({
public: false,
key: SettingKey.SignupBonus,
value: '0',
desc: 'Set up signup bonus',
})

await this.db.collection<Setting>('Setting').insertOne({
public: true,
key: SettingKey.InvitationProfit,
Expand Down
1 change: 1 addition & 0 deletions server/src/setting/entities/setting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export enum SettingKey {
InvitationProfit = 'invitation_profit',
IdVerify = 'id_verify',
DefaultUserQuota = 'default_user_quota',
SignupBonus = 'signup_bonus',

AiPilotUrl = 'ai_pilot_url',
LafForumUrl = 'laf_forum_url',
Expand Down

0 comments on commit b5858c7

Please sign in to comment.