This commit is contained in:
张成
2025-12-26 13:30:20 +08:00
parent 2530f25b86
commit 77789446f3

View File

@@ -73,14 +73,14 @@ module.exports = {
// 时间范围筛选
if (seachOption.startTime || seachOption.endTime) {
where.applyTime = {};
where.create_time = {};
if (seachOption.startTime) {
where.applyTime[op.gte] = new Date(seachOption.startTime);
where.create_time[op.gte] = new Date(seachOption.startTime);
}
if (seachOption.endTime) {
const endTime = new Date(seachOption.endTime);
endTime.setHours(23, 59, 59, 999); // 设置为当天的最后一刻
where.applyTime[op.lte] = endTime;
where.create_time[op.lte] = endTime;
}
}
@@ -106,7 +106,7 @@ module.exports = {
where,
limit,
offset,
order: [['applyTime', 'DESC']]
order: [['create_time', 'DESC']]
});
return ctx.success({
@@ -162,14 +162,14 @@ module.exports = {
// 如果提供了时间范围,则添加到查询条件中
if (startTime || endTime) {
baseWhere.applyTime = {};
baseWhere.create_time = {};
if (startTime) {
baseWhere.applyTime[op.gte] = new Date(startTime);
baseWhere.create_time[op.gte] = new Date(startTime);
}
if (endTime) {
const endTimeDate = new Date(endTime);
endTimeDate.setHours(23, 59, 59, 999); // 设置为当天的最后一刻
baseWhere.applyTime[op.lte] = endTimeDate;
baseWhere.create_time[op.lte] = endTimeDate;
}
}
@@ -221,21 +221,21 @@ module.exports = {
startTime || endTime ? 0 : apply_records.count({
where: {
sn_code: final_sn_code,
applyTime: { [op.gte]: todayStart }
create_time: { [op.gte]: todayStart }
}
}),
// 本周如果提供了时间范围则返回0否则统计本周
startTime || endTime ? 0 : apply_records.count({
where: {
sn_code: final_sn_code,
applyTime: { [op.gte]: weekStart }
create_time: { [op.gte]: weekStart }
}
}),
// 本月如果提供了时间范围则返回0否则统计本月
startTime || endTime ? 0 : apply_records.count({
where: {
sn_code: final_sn_code,
applyTime: { [op.gte]: monthStart }
create_time: { [op.gte]: monthStart }
}
})
]);
@@ -330,12 +330,12 @@ module.exports = {
const records = await apply_records.findAll({
where: {
sn_code: sn_code,
applyTime: {
create_time: {
[op.gte]: sevenDaysAgo,
[op.lte]: today
}
},
attributes: ['applyTime'],
attributes: ['create_time'],
raw: true
});
@@ -350,7 +350,7 @@ module.exports = {
// 统计当天的投递数量
const count = records.filter(record => {
const recordDate = new Date(record.applyTime);
const recordDate = new Date(record.create_time);
recordDate.setHours(0, 0, 0, 0);
return recordDate.getTime() === date.getTime();
}).length;