mirror of
https://github.com/certd/certd.git
synced 2026-07-09 14:17:37 +08:00
feat: 新增推广等级激励功能
This commit is contained in:
@@ -23,6 +23,7 @@ CREATE TABLE `cd_invite_user_plan`
|
||||
`enabled` boolean NOT NULL DEFAULT false,
|
||||
`level_id` bigint NOT NULL DEFAULT 0,
|
||||
`level_locked` boolean NOT NULL DEFAULT false,
|
||||
`promotion_amount` bigint NOT NULL DEFAULT 0,
|
||||
`agreement_time` bigint NOT NULL DEFAULT 0,
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
@@ -31,6 +32,6 @@ CREATE UNIQUE INDEX `index_invite_user_plan_user_id` ON `cd_invite_user_plan` (`
|
||||
|
||||
INSERT INTO `cd_invite_level` (`name`, `icon`, `sort`, `min_amount`, `commission_rate`, `level_type`, `disabled`)
|
||||
VALUES ('青铜', 'fluent-emoji-flat:2nd-place-medal', 10, 0, 10, 'normal', false),
|
||||
('白银', 'fluent-emoji-flat:1st-place-medal', 20, 100000, 15, 'normal', false),
|
||||
('黄金', 'fluent-emoji-flat:3rd-place-medal', 30, 500000, 20, 'normal', false),
|
||||
('钻石', 'streamline-color:diamond-2', 40, 1000000, 30, 'normal', false);
|
||||
('白银', 'fluent-emoji-flat:1st-place-medal', 20, 10000, 15, 'normal', false),
|
||||
('黄金', 'fluent-emoji-flat:3rd-place-medal', 30, 50000, 20, 'normal', false),
|
||||
('钻石', 'streamline-color:diamond-2', 40, 300000, 30, 'normal', false);
|
||||
|
||||
@@ -23,6 +23,7 @@ CREATE TABLE "cd_invite_user_plan"
|
||||
"enabled" boolean NOT NULL DEFAULT (false),
|
||||
"level_id" bigint NOT NULL DEFAULT 0,
|
||||
"level_locked" boolean NOT NULL DEFAULT (false),
|
||||
"promotion_amount" bigint NOT NULL DEFAULT 0,
|
||||
"agreement_time" bigint NOT NULL DEFAULT 0,
|
||||
"create_time" timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
||||
"update_time" timestamp NOT NULL DEFAULT (CURRENT_TIMESTAMP)
|
||||
@@ -31,6 +32,6 @@ CREATE UNIQUE INDEX "index_invite_user_plan_user_id" ON "cd_invite_user_plan" ("
|
||||
|
||||
INSERT INTO "cd_invite_level" ("name", "icon", "sort", "min_amount", "commission_rate", "level_type", "disabled")
|
||||
VALUES ('青铜', 'fluent-emoji-flat:2nd-place-medal', 10, 0, 10, 'normal', false),
|
||||
('白银', 'fluent-emoji-flat:1st-place-medal', 20, 100000, 15, 'normal', false),
|
||||
('黄金', 'fluent-emoji-flat:3rd-place-medal', 30, 500000, 20, 'normal', false),
|
||||
('钻石', 'streamline-color:diamond-2', 40, 1000000, 30, 'normal', false);
|
||||
('白银', 'fluent-emoji-flat:1st-place-medal', 20, 10000, 15, 'normal', false),
|
||||
('黄金', 'fluent-emoji-flat:3rd-place-medal', 30, 50000, 20, 'normal', false),
|
||||
('钻石', 'streamline-color:diamond-2', 40, 300000, 30, 'normal', false);
|
||||
|
||||
@@ -23,6 +23,7 @@ CREATE TABLE "cd_invite_user_plan"
|
||||
"enabled" boolean NOT NULL DEFAULT (false),
|
||||
"level_id" integer NOT NULL DEFAULT 0,
|
||||
"level_locked" boolean NOT NULL DEFAULT (false),
|
||||
"promotion_amount" integer NOT NULL DEFAULT 0,
|
||||
"agreement_time" integer NOT NULL DEFAULT 0,
|
||||
"create_time" datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP),
|
||||
"update_time" datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP)
|
||||
@@ -31,6 +32,6 @@ CREATE UNIQUE INDEX "index_invite_user_plan_user_id" ON "cd_invite_user_plan" ("
|
||||
|
||||
INSERT INTO "cd_invite_level" ("name", "icon", "sort", "min_amount", "commission_rate", "level_type", "disabled")
|
||||
VALUES ('青铜', 'fluent-emoji-flat:2nd-place-medal', 10, 0, 10, 'normal', false),
|
||||
('白银', 'fluent-emoji-flat:1st-place-medal', 20, 100000, 15, 'normal', false),
|
||||
('黄金', 'fluent-emoji-flat:3rd-place-medal', 30, 500000, 20, 'normal', false),
|
||||
('钻石', 'streamline-color:diamond-2', 40, 1000000, 30, 'normal', false);
|
||||
('白银', 'fluent-emoji-flat:1st-place-medal', 20, 10000, 15, 'normal', false),
|
||||
('黄金', 'fluent-emoji-flat:3rd-place-medal', 30, 50000, 20, 'normal', false),
|
||||
('钻石', 'streamline-color:diamond-2', 40, 300000, 30, 'normal', false);
|
||||
|
||||
@@ -137,6 +137,5 @@ export class MainConfiguration {
|
||||
});
|
||||
|
||||
logger.info('当前环境:', this.app.getEnv()); // prod
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ export class RegisterController extends BaseController {
|
||||
password: body.password,
|
||||
} as any;
|
||||
const newUser = await this.userService.register(body.type, registerUser, async txManager => {
|
||||
await this.inviteService.bindInvitee(registerUser.id, body.inviteCode, txManager);
|
||||
await this.inviteService.bindInvitee({ manager: txManager }, { inviteeUserId: registerUser.id, inviteCode: body.inviteCode });
|
||||
});
|
||||
return this.ok(newUser);
|
||||
} else if (body.type === 'mobile') {
|
||||
@@ -85,7 +85,7 @@ export class RegisterController extends BaseController {
|
||||
password: body.password,
|
||||
} as any;
|
||||
const newUser = await this.userService.register(body.type, registerUser, async txManager => {
|
||||
await this.inviteService.bindInvitee(registerUser.id, body.inviteCode, txManager);
|
||||
await this.inviteService.bindInvitee({ manager: txManager }, { inviteeUserId: registerUser.id, inviteCode: body.inviteCode });
|
||||
});
|
||||
return this.ok(newUser);
|
||||
} else if (body.type === 'email') {
|
||||
@@ -104,7 +104,7 @@ export class RegisterController extends BaseController {
|
||||
password: body.password,
|
||||
} as any;
|
||||
const newUser = await this.userService.register(body.type, registerUser, async txManager => {
|
||||
await this.inviteService.bindInvitee(registerUser.id, body.inviteCode, txManager);
|
||||
await this.inviteService.bindInvitee({ manager: txManager }, { inviteeUserId: registerUser.id, inviteCode: body.inviteCode });
|
||||
});
|
||||
return this.ok(newUser);
|
||||
}
|
||||
|
||||
@@ -65,6 +65,8 @@ export class BasicSettingsController extends BaseController {
|
||||
const setting = await this.sysSettingsService.getSetting<SysInviteCommissionSetting>(SysInviteCommissionSetting);
|
||||
return {
|
||||
enabled: setting.enabled,
|
||||
levelEnabled: setting.levelEnabled === true,
|
||||
fixedCommissionRate: setting.fixedCommissionRate || 10,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -139,7 +139,7 @@ export class LoginService {
|
||||
password: '',
|
||||
} as any;
|
||||
info = await this.userService.register('mobile', registerUser, async txManager => {
|
||||
await this.inviteService.bindInvitee(registerUser.id, req.inviteCode, txManager);
|
||||
await this.inviteService.bindInvitee({ manager: txManager }, { inviteeUserId: registerUser.id, inviteCode: req.inviteCode });
|
||||
});
|
||||
}
|
||||
this.clearCacheOnSuccess(mobile);
|
||||
|
||||
Reference in New Issue
Block a user