diff --git a/Reject.js b/Reject.js
index 94c38b5..759b19f 100644
--- a/Reject.js
+++ b/Reject.js
@@ -2565,9 +2565,9 @@ async function checkPreCreateSupplies() {
}
}
-// 启动定时任务(每两分钟检查一次)
-setInterval(checkPreCreateSupplies, 120000);
-console.log('预创建货源检查定时任务已启动,每两分钟执行一次');
+// 启动定时任务(每分钟检查一次)
+setInterval(checkPreCreateSupplies, 60000);
+console.log('预创建货源检查定时任务已启动,每分钟执行一次');
// 启动服务器
startServer();
diff --git a/package-lock.json b/package-lock.json
index 20889c7..71d1de7 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,5 +1,5 @@
{
- "name": "boss",
+ "name": "Review2",
"lockfileVersion": 3,
"requires": true,
"packages": {
diff --git a/supply.html b/supply.html
index 888ecb8..ad4abae 100644
--- a/supply.html
+++ b/supply.html
@@ -1853,7 +1853,7 @@
-
+
@@ -2279,7 +2279,7 @@
-
+
@@ -5022,15 +5022,11 @@
// 构建查询参数,获取所有数据
const queryParams = new URLSearchParams({
+ sellerId: userInfo.userId,
page: 1,
pageSize: 1000 // 设置较大的pageSize,确保获取所有记录
});
- // 非管理员才添加sellerId参数,管理员获取所有货源
- if (userInfo.projectName !== '管理员') {
- queryParams.append('sellerId', userInfo.userId);
- }
-
const apiUrl = `/api/supplies?${queryParams}`;
console.log('加载货源列表API请求:', apiUrl);
@@ -5054,21 +5050,13 @@
// 获取当前登录用户的userId,用于对比
const userInfo = JSON.parse(localStorage.getItem('userInfo'));
const currentUserId = userInfo?.userId || userInfo?.id || '未获取到';
- const isAdmin = userInfo?.projectName === '管理员';
console.log(`=== 处理货源数据 ===`);
console.log(`当前登录用户ID: ${currentUserId}`);
- console.log(`当前用户是否是管理员: ${isAdmin}`);
console.log(`API返回的货源总数: ${supplies.length}`);
- // 管理员保留所有货源,非管理员只保留当前用户的货源
- let filteredSupplies;
- if (isAdmin) {
- console.log('管理员模式:保留所有货源');
- filteredSupplies = supplies;
- } else {
- // 检查每个货源的sellerId,确保只包含当前用户的货源
- filteredSupplies = supplies.filter(supply => {
+ // 检查每个货源的sellerId,确保只包含当前用户的货源
+ const filteredSupplies = supplies.filter(supply => {
// 如果货源没有sellerId,默认包含
if (!supply.sellerId) {
console.warn(`货源 ${supply.id || supply.productId} 没有sellerId,默认包含`);
@@ -5089,8 +5077,7 @@
console.log(`货源 ${supply.id || supply.productId} 的created_at:`, supply.created_at);
}
return match;
- });
- }
+ });
console.log(`过滤后保留的货源数量: ${filteredSupplies.length}`);
@@ -7014,9 +7001,16 @@
// 将分钟转换为小时(用于存储到数据库),确保有默认值
const minutes = parseFloat(autoOfflineMinutes) || 1440; // 默认24小时(1440分钟)
const autoOfflineHours = minutes / 60;
- // 计算自动下架时间(当前时间 + 分钟数)
+ // 计算自动下架时间
const autoOfflineTime = new Date();
- autoOfflineTime.setMinutes(autoOfflineTime.getMinutes() + minutes);
+ const preCreateTimeStr = document.getElementById('preCreateTime').value;
+ if (preCreateTimeStr) {
+ // 如果设置了预创建时间,基于预创建时间计算自动下架时间
+ autoOfflineTime.setTime(new Date(preCreateTimeStr).getTime() + minutes * 60 * 1000);
+ } else {
+ // 否则基于当前时间计算
+ autoOfflineTime.setMinutes(autoOfflineTime.getMinutes() + minutes);
+ }
// 格式化为数据库存储的北京时间格式 (YYYY-MM-DD HH:mm:ss)
const autoOfflineTimeStr = autoOfflineTime.getFullYear() + '-' +
String(autoOfflineTime.getMonth() + 1).padStart(2, '0') + '-' +
@@ -9224,9 +9218,16 @@
// 将分钟转换为小时(用于存储到数据库),确保有默认值
const minutes = parseFloat(autoOfflineMinutes) || 1440; // 默认24小时(1440分钟)
const autoOfflineHours = minutes / 60;
- // 计算自动下架时间(当前时间 + 分钟数)
+ // 计算自动下架时间
const autoOfflineTime = new Date();
- autoOfflineTime.setMinutes(autoOfflineTime.getMinutes() + minutes);
+ const preCreateTimeStr = document.getElementById('editPreCreateTime')?.value;
+ if (preCreateTimeStr) {
+ // 如果设置了预创建时间,基于预创建时间计算自动下架时间
+ autoOfflineTime.setTime(new Date(preCreateTimeStr).getTime() + minutes * 60 * 1000);
+ } else {
+ // 否则基于当前时间计算
+ autoOfflineTime.setMinutes(autoOfflineTime.getMinutes() + minutes);
+ }
// 格式化为数据库存储的北京时间格式 (YYYY-MM-DD HH:mm:ss)
const autoOfflineTimeStr = autoOfflineTime.getFullYear() + '-' +
String(autoOfflineTime.getMonth() + 1).padStart(2, '0') + '-' +