🐞 fix(账号): 账号注销问题修复

This commit is contained in:
luying
2023-04-19 14:55:08 +08:00
parent 489122fff9
commit d3de6a9014
2 changed files with 9 additions and 6 deletions

View File

@@ -486,11 +486,11 @@ export default class Auth extends Service {
public async closeAccount(roleId: string) {
const ctx = this.ctx;
let role = await RoleModel.findByRoleId(roleId, '+cancelCloseTime');
if(!role) return ctx.service.utils.resResult(STATUS.ROLE_NOT_FOUND);
let role = await RoleModel.findByRoleId(roleId, '+closeTime +cancelCloseTime userInfo');
if(!role || role.userInfo.uid != ctx.uid ) 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)}后再试`);
if(role.closeTime > 0) return ctx.service.utils.resResult(STATUS.ROLE_CLOSED);
role = await RoleModel.closeAccount(roleId, nowSeconds() + 15 * 24 * 60 * 60);
return ctx.service.utils.resResult(STATUS.SUCCESS, { closeTime: role.closeTime });
}
@@ -505,7 +505,10 @@ export default class Auth extends Service {
public async cancelCloseAccount(roleId: string) {
const ctx = this.ctx;
let role = await RoleModel.cancelCloseAccount(roleId, nowSeconds());
let role = await RoleModel.findByRoleId(roleId, '+cancelCloseTime userInfo');
if(!role || role.userInfo.uid != ctx.uid ) return ctx.service.utils.resResult(STATUS.ROLE_NOT_FOUND);
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 });
}