租房记录
This commit is contained in:
parent
5ff4bbe0b4
commit
baecadb626
|
|
@ -65,6 +65,7 @@ const getRoomStatusStatistics = async (req, res) => {
|
||||||
|
|
||||||
// 初始化统计数据
|
// 初始化统计数据
|
||||||
let empty = 0;
|
let empty = 0;
|
||||||
|
let reserved = 0;
|
||||||
let rented = 0;
|
let rented = 0;
|
||||||
let soon_expire = 0;
|
let soon_expire = 0;
|
||||||
let expired = 0;
|
let expired = 0;
|
||||||
|
|
@ -75,6 +76,8 @@ const getRoomStatusStatistics = async (req, res) => {
|
||||||
rooms.forEach(room => {
|
rooms.forEach(room => {
|
||||||
if (room.status === 'empty') {
|
if (room.status === 'empty') {
|
||||||
empty++;
|
empty++;
|
||||||
|
} else if (room.status === 'reserved') {
|
||||||
|
reserved++;
|
||||||
} else if (room.status === 'rented') {
|
} else if (room.status === 'rented') {
|
||||||
rented++;
|
rented++;
|
||||||
// 统计附属状态
|
// 统计附属状态
|
||||||
|
|
@ -94,6 +97,7 @@ const getRoomStatusStatistics = async (req, res) => {
|
||||||
|
|
||||||
const roomStatusStatistics = [
|
const roomStatusStatistics = [
|
||||||
{ status: '空房', count: empty },
|
{ status: '空房', count: empty },
|
||||||
|
{ status: '预订', count: reserved },
|
||||||
{ status: '在租', count: rented },
|
{ status: '在租', count: rented },
|
||||||
{ status: '即将到期', count: soon_expire },
|
{ status: '即将到期', count: soon_expire },
|
||||||
{ status: '到期', count: expired },
|
{ status: '到期', count: expired },
|
||||||
|
|
@ -126,6 +130,7 @@ const getRegionHouseStatistics = async (req, res) => {
|
||||||
|
|
||||||
const regionHouseStatistics = regions.map(region => {
|
const regionHouseStatistics = regions.map(region => {
|
||||||
let empty = 0;
|
let empty = 0;
|
||||||
|
let reserved = 0;
|
||||||
let rented = 0;
|
let rented = 0;
|
||||||
let soon_expire = 0;
|
let soon_expire = 0;
|
||||||
let expired = 0;
|
let expired = 0;
|
||||||
|
|
@ -136,6 +141,8 @@ const getRegionHouseStatistics = async (req, res) => {
|
||||||
apartment.Rooms.forEach(room => {
|
apartment.Rooms.forEach(room => {
|
||||||
if (room.status === 'empty') {
|
if (room.status === 'empty') {
|
||||||
empty++;
|
empty++;
|
||||||
|
} else if (room.status === 'reserved') {
|
||||||
|
reserved++;
|
||||||
} else if (room.status === 'rented') {
|
} else if (room.status === 'rented') {
|
||||||
rented++;
|
rented++;
|
||||||
// 统计附属状态
|
// 统计附属状态
|
||||||
|
|
@ -157,12 +164,13 @@ const getRegionHouseStatistics = async (req, res) => {
|
||||||
return {
|
return {
|
||||||
region: region.name,
|
region: region.name,
|
||||||
empty,
|
empty,
|
||||||
|
reserved,
|
||||||
rented,
|
rented,
|
||||||
soon_expire,
|
soon_expire,
|
||||||
expired,
|
expired,
|
||||||
cleaning,
|
cleaning,
|
||||||
maintenance,
|
maintenance,
|
||||||
total: empty + rented
|
total: empty + reserved + rented
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -194,6 +202,7 @@ const getRegionApartmentHouseStatistics = async (req, res) => {
|
||||||
regions.forEach(region => {
|
regions.forEach(region => {
|
||||||
region.Apartments.forEach(apartment => {
|
region.Apartments.forEach(apartment => {
|
||||||
let empty = 0;
|
let empty = 0;
|
||||||
|
let reserved = 0;
|
||||||
let rented = 0;
|
let rented = 0;
|
||||||
let soon_expire = 0;
|
let soon_expire = 0;
|
||||||
let expired = 0;
|
let expired = 0;
|
||||||
|
|
@ -203,6 +212,8 @@ const getRegionApartmentHouseStatistics = async (req, res) => {
|
||||||
apartment.Rooms.forEach(room => {
|
apartment.Rooms.forEach(room => {
|
||||||
if (room.status === 'empty') {
|
if (room.status === 'empty') {
|
||||||
empty++;
|
empty++;
|
||||||
|
} else if (room.status === 'reserved') {
|
||||||
|
reserved++;
|
||||||
} else if (room.status === 'rented') {
|
} else if (room.status === 'rented') {
|
||||||
rented++;
|
rented++;
|
||||||
// 统计附属状态
|
// 统计附属状态
|
||||||
|
|
@ -224,12 +235,13 @@ const getRegionApartmentHouseStatistics = async (req, res) => {
|
||||||
region: region.name,
|
region: region.name,
|
||||||
apartment: apartment.name,
|
apartment: apartment.name,
|
||||||
empty,
|
empty,
|
||||||
|
reserved,
|
||||||
rented,
|
rented,
|
||||||
soon_expire,
|
soon_expire,
|
||||||
expired,
|
expired,
|
||||||
cleaning,
|
cleaning,
|
||||||
maintenance,
|
maintenance,
|
||||||
total: empty + rented
|
total: empty + reserved + rented
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
@ -247,11 +259,12 @@ const getDashboardStatistics = async (req, res) => {
|
||||||
const { Region, Apartment, Room, WaterBill, Rental } = require('../models');
|
const { Region, Apartment, Room, WaterBill, Rental } = require('../models');
|
||||||
|
|
||||||
// 并行查询所有统计数据
|
// 并行查询所有统计数据
|
||||||
const [regionCount, apartmentCount, roomCount, emptyRoomCount, rentedRoomCount, soonExpireRoomCount, expiredRoomCount, collectedRentAmount, collectedWaterAmount] = await Promise.all([
|
const [regionCount, apartmentCount, roomCount, emptyRoomCount, reservedRoomCount, rentedRoomCount, soonExpireRoomCount, expiredRoomCount, collectedRentAmount, collectedWaterAmount] = await Promise.all([
|
||||||
Region.count({ where: { isDeleted: 0 } }),
|
Region.count({ where: { isDeleted: 0 } }),
|
||||||
Apartment.count({ where: { isDeleted: 0 } }),
|
Apartment.count({ where: { isDeleted: 0 } }),
|
||||||
Room.count({ where: { isDeleted: 0 } }),
|
Room.count({ where: { isDeleted: 0 } }),
|
||||||
Room.count({ where: { status: 'empty', isDeleted: 0 } }),
|
Room.count({ where: { status: 'empty', isDeleted: 0 } }),
|
||||||
|
Room.count({ where: { status: 'reserved', isDeleted: 0 } }),
|
||||||
Room.count({ where: { status: 'rented', isDeleted: 0 } }),
|
Room.count({ where: { status: 'rented', isDeleted: 0 } }),
|
||||||
Room.count({ where: { status: 'rented', subStatus: 'soon_expire', isDeleted: 0 } }),
|
Room.count({ where: { status: 'rented', subStatus: 'soon_expire', isDeleted: 0 } }),
|
||||||
Room.count({ where: { status: 'rented', subStatus: 'expired', isDeleted: 0 } }),
|
Room.count({ where: { status: 'rented', subStatus: 'expired', isDeleted: 0 } }),
|
||||||
|
|
@ -267,6 +280,7 @@ const getDashboardStatistics = async (req, res) => {
|
||||||
apartmentCount,
|
apartmentCount,
|
||||||
roomCount,
|
roomCount,
|
||||||
emptyRoomCount,
|
emptyRoomCount,
|
||||||
|
reservedRoomCount,
|
||||||
rentedRoomCount,
|
rentedRoomCount,
|
||||||
soonExpireRoomCount,
|
soonExpireRoomCount,
|
||||||
expiredRoomCount,
|
expiredRoomCount,
|
||||||
|
|
|
||||||
|
|
@ -39,10 +39,10 @@ const Room = sequelize.define('Room', {
|
||||||
comment: '年租金'
|
comment: '年租金'
|
||||||
},
|
},
|
||||||
status: {
|
status: {
|
||||||
type: DataTypes.ENUM('empty', 'rented'),
|
type: DataTypes.ENUM('empty', 'reserved', 'rented'),
|
||||||
allowNull: false,
|
allowNull: false,
|
||||||
defaultValue: 'empty',
|
defaultValue: 'empty',
|
||||||
comment: '房间状态(empty:空房,rented:在租)'
|
comment: '房间状态(empty:空房,reserved:预订,rented:在租)'
|
||||||
},
|
},
|
||||||
subStatus: {
|
subStatus: {
|
||||||
type: DataTypes.ENUM('normal', 'soon_expire', 'expired'),
|
type: DataTypes.ENUM('normal', 'soon_expire', 'expired'),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue