1
This commit is contained in:
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user