41
This commit is contained in:
@@ -408,6 +408,7 @@ module.exports = {
|
||||
const hashedPassword = await hashPassword(password);
|
||||
|
||||
// 创建新用户(使用统一的小写邮箱和加密密码)
|
||||
// 新用户注册赠送3天试用期
|
||||
const newUser = await pla_account.create({
|
||||
name: email_normalized.split('@')[0], // 默认使用邮箱用户名作为名称
|
||||
sn_code: sn_code,
|
||||
@@ -418,8 +419,8 @@ module.exports = {
|
||||
keyword: '',
|
||||
is_enabled: 1,
|
||||
is_delete: 0,
|
||||
authorization_date: null,
|
||||
authorization_days: 0
|
||||
authorization_date: new Date(), // 新用户从注册日期开始
|
||||
authorization_days: 3 // 赠送3天试用期
|
||||
});
|
||||
|
||||
// 给邀请人增加3天试用期
|
||||
@@ -428,19 +429,26 @@ module.exports = {
|
||||
const currentAuthDate = inviterData.authorization_date;
|
||||
const currentAuthDays = inviterData.authorization_days || 0;
|
||||
|
||||
let newAuthDate = currentAuthDate;
|
||||
let newAuthDays = currentAuthDays + 3; // 增加3天
|
||||
let newAuthDate;
|
||||
let newAuthDays;
|
||||
|
||||
// 如果当前没有授权日期,则从今天开始
|
||||
if (!currentAuthDate) {
|
||||
newAuthDate = new Date();
|
||||
newAuthDays = currentAuthDays + 3; // 累加3天
|
||||
} else {
|
||||
// 如果当前授权已过期,从今天开始计算
|
||||
// 检查当前授权是否已过期
|
||||
const currentEndDate = dayjs(currentAuthDate).add(currentAuthDays, 'day');
|
||||
const now = dayjs();
|
||||
|
||||
if (currentEndDate.isBefore(now)) {
|
||||
// 授权已过期,重新激活并给予3天试用期
|
||||
newAuthDate = new Date();
|
||||
newAuthDays = 3; // 重新设置为3天
|
||||
newAuthDays = 3; // 过期后重新激活给3天
|
||||
} else {
|
||||
// 授权未过期,在现有基础上累加3天
|
||||
newAuthDate = currentAuthDate;
|
||||
newAuthDays = currentAuthDays + 3; // 累加3天
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user