🐞 fix(37需求): 注销冷却提示需求

This commit is contained in:
luying
2023-04-18 17:28:44 +08:00
parent e071b411bc
commit 3bf0f7a35e
3 changed files with 18 additions and 3 deletions

View File

@@ -486,14 +486,26 @@ export default class Auth extends Service {
public async closeAccount(roleId: string) {
const ctx = this.ctx;
let role = await RoleModel.closeAccount(roleId, nowSeconds() + 15 * 24 * 60 * 60);
let role = await RoleModel.findByRoleId(roleId, '+cancelCloseTime');
if(!role) return ctx.service.utils.resResult(STATUS.ROLE_NOT_FOUND);
if(role.cancelCloseTime > 0 && role.cancelCloseTime + 24 * 60 * 60 > nowSeconds() )
return ctx.service.utils.resResult(STATUS.ROLE_CLOSE_COOL_DOWN, `注销冷却中,请${this.getCdTimeStr(role.cancelCloseTime)}后再试`);
role = await RoleModel.closeAccount(roleId, nowSeconds() + 15 * 24 * 60 * 60);
return ctx.service.utils.resResult(STATUS.SUCCESS, { closeTime: role.closeTime });
}
private getCdTimeStr(cancelCloseTime: number) {
let gap = cancelCloseTime + 24 * 60 * 60 - nowSeconds();
let h = Math.floor(gap/60/60);
let m = Math.floor((gap - h * 60 * 60 )/60);
let s = gap - h * 60 * 60 - m * 60;
return `${h}小时${m}${s}`
}
public async cancelCloseAccount(roleId: string) {
const ctx = this.ctx;
let role = await RoleModel.cancelCloseAccount(roleId, nowSeconds() + 15 * 24 * 60 * 60);
let role = await RoleModel.cancelCloseAccount(roleId, nowSeconds());
if(!role) return ctx.service.utils.resResult(STATUS.ROLE_CLOSE_TIME_OVER);
return ctx.service.utils.resResult(STATUS.SUCCESS, { closeTime: role.closeTime });
}