This commit is contained in:
张成
2025-12-19 22:24:23 +08:00
parent abe2ae3c3a
commit 10aff2f266
12 changed files with 1101 additions and 147 deletions

View File

@@ -294,26 +294,6 @@ module.exports = (db) => {
type: Sequelize.INTEGER,
allowNull: false,
defaultValue: 0
},
remaining_days: {
comment: '剩余天数(虚拟字段,通过计算得出)',
type: Sequelize.VIRTUAL,
get: function () {
const authDate = this.getDataValue('authorization_date');
const authDays = this.getDataValue('authorization_days') || 0;
if (!authDate || authDays <= 0) {
return 0;
}
const startDate = dayjs(authDate);
const endDate = startDate.add(authDays, 'day');
const now = dayjs();
// 计算剩余天数
const remaining = endDate.diff(now, 'day', true);
return Math.max(0, Math.ceil(remaining));
}
}
});