From 1eca4b96b068052561247cd8bbf43ee912128fac Mon Sep 17 00:00:00 2001 From: Default User Date: Sun, 11 Jan 2026 13:18:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=BC=96=E8=BE=91=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=E9=97=AE=E9=A2=98=EF=BC=8C=E7=A7=BB=E9=99=A4=E8=B0=83?= =?UTF-8?q?=E8=AF=95=E6=97=A5=E5=BF=97=E4=B8=AD=E6=9C=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E7=9A=84price=E5=8F=98=E9=87=8F=EF=BC=9B=E4=B8=8B=E6=9E=B6?= =?UTF-8?q?=E8=B4=A7=E6=BA=90=E6=97=B6=E8=87=AA=E5=8A=A8=E9=94=81=E6=AD=BB?= =?UTF-8?q?=E8=B4=A7=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Reject.js | 28 ++++++++++++++-------------- supply.html | 9 +++++---- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/Reject.js b/Reject.js index c2295d5..45ae2c1 100644 --- a/Reject.js +++ b/Reject.js @@ -824,7 +824,7 @@ app.post('/api/supplies/create', async (req, res) => { let connection; try { connection = await pool.getConnection(); - const { productName, price, costprice, quantity, grossWeight, yolk, specification, quality, region, imageUrls, sellerId, supplyStatus, description, sourceType, contactId, category, producting } = req.body; + const { productName, costprice, quantity, grossWeight, yolk, specification, quality, region, imageUrls, sellerId, supplyStatus, description, sourceType, contactId, category, producting } = req.body; // 开始事务 await connection.beginTransaction(); @@ -919,7 +919,7 @@ app.post('/api/supplies/create', async (req, res) => { sellerId: sellerId, // 使用前端传入的sellerId productName, category: category || '', // 添加种类 - price: (price || '').toString(), // 确保是varchar类型 + // 不再使用price字段,移除price字段 costprice: costprice || '', // 添加采购价 quantity: quantity, // 保持为逗号分隔的字符串,不转换为整数 grossWeight, @@ -952,18 +952,18 @@ app.post('/api/supplies/create', async (req, res) => { if (columns.length === 0) { // 没有quality字段,不包含quality字段的插入 - insertQuery = 'INSERT INTO products (productId, sellerId, productName, category, freshness, price, costprice, quantity, grossWeight, yolk, specification, producting, region, status, supplyStatus, sourceType, description, rejectReason, imageUrls, created_at, audit_time, product_contact, contact_phone, autoOfflineTime, autoOfflineDays, autoOfflineHours) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'; + insertQuery = 'INSERT INTO products (productId, sellerId, productName, category, freshness, costprice, quantity, grossWeight, yolk, specification, producting, region, status, supplyStatus, sourceType, description, rejectReason, imageUrls, created_at, audit_time, product_contact, contact_phone, autoOfflineTime, autoOfflineDays, autoOfflineHours) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'; insertParams = [ - productId, productData.sellerId, productName, category || '', req.body.freshness || '', (price || '').toString(), costprice || '', quantity, grossWeight, + productId, productData.sellerId, productName, category || '', req.body.freshness || '', costprice || '', quantity, grossWeight, yolk, specification, producting, region, productData.status, productData.supplyStatus, productData.sourceType, productData.description, productData.rejectReason, productData.imageUrls, new Date(), new Date(), productContact, contactPhone, req.body.autoOfflineTime, req.body.autoOfflineDays, req.body.autoOfflineHours // 添加联系人信息和自动下架时间、小时数 ]; } else { // 有quality字段,包含quality字段的插入 - insertQuery = 'INSERT INTO products (productId, sellerId, productName, category, freshness, price, costprice, quantity, grossWeight, yolk, specification, producting, quality, region, status, supplyStatus, sourceType, description, rejectReason, imageUrls, created_at, audit_time, product_contact, contact_phone, autoOfflineTime, autoOfflineDays, autoOfflineHours) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'; + insertQuery = 'INSERT INTO products (productId, sellerId, productName, category, freshness, costprice, quantity, grossWeight, yolk, specification, producting, quality, region, status, supplyStatus, sourceType, description, rejectReason, imageUrls, created_at, audit_time, product_contact, contact_phone, autoOfflineTime, autoOfflineDays, autoOfflineHours) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'; insertParams = [ - productId, productData.sellerId, productName, category || '', req.body.freshness || '', (price || '').toString(), costprice || '', quantity, grossWeight, + productId, productData.sellerId, productName, category || '', req.body.freshness || '', costprice || '', quantity, grossWeight, yolk, specification, producting, quality, region, productData.status, productData.supplyStatus, productData.sourceType, productData.description, productData.rejectReason, productData.imageUrls, new Date(), new Date(), productContact, contactPhone, req.body.autoOfflineTime, req.body.autoOfflineDays, req.body.autoOfflineHours // 添加联系人信息和自动下架时间、小时数 @@ -993,7 +993,7 @@ app.post('/api/supplies/create', async (req, res) => { productId: productId, productName, category: category || '', - price: (price || '').toString(), + // 不再使用price字段,移除price字段 costprice: costprice || '', quantity, grossWeight, @@ -1160,9 +1160,9 @@ app.post('/api/supplies/:id/unpublish', async (req, res) => { return sendResponse(res, false, null, '货源不存在'); } - // 更新状态为已下架 + // 更新状态为已下架,并将标签设置为已锁定 await connection.query( - 'UPDATE products SET status = ?, updated_at = NOW() WHERE id = ?', + 'UPDATE products SET status = ?, label = 1, updated_at = NOW() WHERE id = ?', ['sold_out', productId] ); @@ -1356,7 +1356,7 @@ app.put('/api/supplies/:id/edit', async (req, res) => { try { const connection = await pool.getConnection(); const productId = req.params.id; - const { productName, price, costprice, quantity, grossWeight, yolk, specification, supplyStatus, description, region, contactId, producting, imageUrls, autoOfflineTime, category, sourceType, freshness, autoOfflineHours } = req.body; + const { productName, costprice, quantity, grossWeight, yolk, specification, supplyStatus, description, region, contactId, producting, imageUrls, autoOfflineTime, category, sourceType, freshness, autoOfflineHours } = req.body; // 开始事务 await connection.beginTransaction(); @@ -1484,7 +1484,7 @@ app.put('/api/supplies/:id/edit', async (req, res) => { // 打印用于调试的更新参数 console.log('更新参数调试:'); console.log('productName:', productName); - console.log('price:', (price || '').toString()); + // 不再使用price字段,移除price调试日志 console.log('costprice:', costprice || ''); console.log('quantityValue:', quantityValue); console.log('grossWeight:', grossWeight); @@ -1507,7 +1507,7 @@ app.put('/api/supplies/:id/edit', async (req, res) => { // 更新货源信息 const updateQuery = ` UPDATE products - SET productName = ?, price = ?, costprice = ?, quantity = ?, grossWeight = ?, + SET productName = ?, costprice = ?, quantity = ?, grossWeight = ?, yolk = ?, specification = ?, producting = ?, supplyStatus = ?, description = ?, region = ?, category = ?, sourceType = ?, freshness = ?, product_contact = ?, contact_phone = ?, imageUrls = ?, @@ -1516,7 +1516,7 @@ app.put('/api/supplies/:id/edit', async (req, res) => { `; const [result] = await connection.query(updateQuery, [ - productName, (price || '').toString(), costprice || '', quantityValue, grossWeight, + productName, costprice || '', quantityValue, grossWeight, yolk, specification, producting, supplyStatus, description, region, category, sourceType, freshness, productContact, contactPhone, imageUrlsToUpdate, @@ -1540,7 +1540,7 @@ app.put('/api/supplies/:id/edit', async (req, res) => { data: { id: productId, productName, - price: (price || '').toString(), + // 不再使用price字段,移除price字段 costprice: costprice || '', quantity, grossWeight, diff --git a/supply.html b/supply.html index 0e4f72b..81ba995 100644 --- a/supply.html +++ b/supply.html @@ -4923,8 +4923,9 @@ resetForm(); // 填充表单字段 - 为所有元素添加null检查 + // 不填充销售价格,因为现在不再使用 const priceInput = document.getElementById('price'); - if (priceInput) priceInput.value = supply.price || ''; + if (priceInput) priceInput.value = ''; const quantityInput = document.getElementById('quantity'); if (quantityInput) quantityInput.value = supply.quantity || ''; @@ -5798,7 +5799,7 @@ productName: productName ? productName.value : '', category: category ? category.value : '', freshness: freshness ? freshness.value : '', - price: price ? price.value : '', + // 不再使用销售价格,移除price字段 quantity: quantity ? quantity.value : '', grossWeight: grossWeight ? grossWeight.value : '', yolk: yolk ? yolk.value : '', @@ -6110,7 +6111,7 @@ const formData = { productName: document.getElementById('productName').value, category: document.getElementById('category').value, - price: document.getElementById('price').value, + // 不再使用销售价格,移除price字段 costprice: costprices.join(','), // 将采购价以英文逗号分隔的字符串形式提交 quantity: quantities.join(','), // 将件数以英文逗号分隔的字符串形式提交 @@ -7973,7 +7974,7 @@ productName: document.getElementById('editProductName').value, sourceType: document.getElementById('editSourceType').value, category: document.getElementById('editCategory').value, - price: document.getElementById('editPrice').value, + // 不再使用销售价格,移除price字段 costprice: costprices.join(','), // 将采购价以英文逗号分隔的字符串形式提交 quantity: quantities.join(','), // 将件数以英文逗号分隔的字符串形式提交