|
|
@ -851,7 +851,7 @@ app.post('/api/supplies/create', async (req, res) => { |
|
|
let connection; |
|
|
let connection; |
|
|
try { |
|
|
try { |
|
|
connection = await pool.getConnection(); |
|
|
connection = await pool.getConnection(); |
|
|
const { productName, 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, spec_status } = req.body; |
|
|
|
|
|
|
|
|
// 开始事务
|
|
|
// 开始事务
|
|
|
await connection.beginTransaction(); |
|
|
await connection.beginTransaction(); |
|
|
@ -979,21 +979,21 @@ app.post('/api/supplies/create', async (req, res) => { |
|
|
|
|
|
|
|
|
if (columns.length === 0) { |
|
|
if (columns.length === 0) { |
|
|
// 没有quality字段,不包含quality字段的插入
|
|
|
// 没有quality字段,不包含quality字段的插入
|
|
|
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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'; |
|
|
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, spec_status) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'; |
|
|
insertParams = [ |
|
|
insertParams = [ |
|
|
productId, productData.sellerId, productName, category || '', req.body.freshness || '', costprice || '', quantity, grossWeight, |
|
|
productId, productData.sellerId, productName, category || '', req.body.freshness || '', costprice || '', quantity, grossWeight, |
|
|
yolk, specification, producting, region, productData.status, productData.supplyStatus, productData.sourceType, |
|
|
yolk, specification, producting, region, productData.status, productData.supplyStatus, productData.sourceType, |
|
|
productData.description, productData.rejectReason, productData.imageUrls, new Date(), new Date(), |
|
|
productData.description, productData.rejectReason, productData.imageUrls, new Date(), new Date(), |
|
|
productContact, contactPhone, req.body.autoOfflineTime, req.body.autoOfflineDays, req.body.autoOfflineHours // 添加联系人信息和自动下架时间、小时数
|
|
|
productContact, contactPhone, req.body.autoOfflineTime, req.body.autoOfflineDays, req.body.autoOfflineHours, spec_status || '' // 添加联系人信息和自动下架时间、小时数、规格状态
|
|
|
]; |
|
|
]; |
|
|
} else { |
|
|
} else { |
|
|
// 有quality字段,包含quality字段的插入
|
|
|
// 有quality字段,包含quality字段的插入
|
|
|
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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'; |
|
|
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, spec_status) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'; |
|
|
insertParams = [ |
|
|
insertParams = [ |
|
|
productId, productData.sellerId, productName, category || '', req.body.freshness || '', costprice || '', quantity, grossWeight, |
|
|
productId, productData.sellerId, productName, category || '', req.body.freshness || '', costprice || '', quantity, grossWeight, |
|
|
yolk, specification, producting, quality, region, productData.status, productData.supplyStatus, |
|
|
yolk, specification, producting, quality, region, productData.status, productData.supplyStatus, productData.sourceType, |
|
|
productData.sourceType, productData.description, productData.rejectReason, productData.imageUrls, |
|
|
productData.description, productData.rejectReason, productData.imageUrls, |
|
|
new Date(), new Date(), productContact, contactPhone, req.body.autoOfflineTime, req.body.autoOfflineDays, req.body.autoOfflineHours // 添加联系人信息和自动下架时间、小时数
|
|
|
new Date(), new Date(), productContact, contactPhone, req.body.autoOfflineTime, req.body.autoOfflineDays, req.body.autoOfflineHours, spec_status || '' // 添加联系人信息和自动下架时间、小时数、规格状态
|
|
|
]; |
|
|
]; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -1063,7 +1063,8 @@ app.post('/api/supplies/create', async (req, res) => { |
|
|
contact_phone: contactPhone, |
|
|
contact_phone: contactPhone, |
|
|
autoOfflineTime: req.body.autoOfflineTime, |
|
|
autoOfflineTime: req.body.autoOfflineTime, |
|
|
autoOfflineDays: req.body.autoOfflineDays, |
|
|
autoOfflineDays: req.body.autoOfflineDays, |
|
|
autoOfflineHours: req.body.autoOfflineHours |
|
|
autoOfflineHours: req.body.autoOfflineHours, |
|
|
|
|
|
spec_status: spec_status || '' |
|
|
}, '货源创建成功'); |
|
|
}, '货源创建成功'); |
|
|
} catch (error) { |
|
|
} catch (error) { |
|
|
if (connection) { |
|
|
if (connection) { |
|
|
@ -1426,7 +1427,7 @@ app.put('/api/supplies/:id/edit', async (req, res) => { |
|
|
try { |
|
|
try { |
|
|
const connection = await pool.getConnection(); |
|
|
const connection = await pool.getConnection(); |
|
|
const productId = req.params.id; |
|
|
const productId = req.params.id; |
|
|
const { productName, 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, spec_status } = req.body; |
|
|
|
|
|
|
|
|
// 开始事务
|
|
|
// 开始事务
|
|
|
await connection.beginTransaction(); |
|
|
await connection.beginTransaction(); |
|
|
@ -1579,7 +1580,7 @@ app.put('/api/supplies/:id/edit', async (req, res) => { |
|
|
UPDATE products |
|
|
UPDATE products |
|
|
SET productName = ?, costprice = ?, quantity = ?, grossWeight = ?, |
|
|
SET productName = ?, costprice = ?, quantity = ?, grossWeight = ?, |
|
|
yolk = ?, specification = ?, producting = ?, supplyStatus = ?, description = ?, region = ?, |
|
|
yolk = ?, specification = ?, producting = ?, supplyStatus = ?, description = ?, region = ?, |
|
|
category = ?, sourceType = ?, freshness = ?, |
|
|
category = ?, sourceType = ?, freshness = ?, spec_status = ?, |
|
|
product_contact = ?, contact_phone = ?, imageUrls = ?, |
|
|
product_contact = ?, contact_phone = ?, imageUrls = ?, |
|
|
autoOfflineTime = ?, autoOfflineHours = ?, updated_at = ? |
|
|
autoOfflineTime = ?, autoOfflineHours = ?, updated_at = ? |
|
|
WHERE id = ? |
|
|
WHERE id = ? |
|
|
@ -1588,7 +1589,7 @@ app.put('/api/supplies/:id/edit', async (req, res) => { |
|
|
const [result] = await connection.query(updateQuery, [ |
|
|
const [result] = await connection.query(updateQuery, [ |
|
|
productName, costprice || '', quantityValue, grossWeight, |
|
|
productName, costprice || '', quantityValue, grossWeight, |
|
|
yolk, specification, producting, supplyStatus, description, region, |
|
|
yolk, specification, producting, supplyStatus, description, region, |
|
|
category, sourceType, freshness, |
|
|
category, sourceType, freshness, spec_status || '', |
|
|
productContact, contactPhone, imageUrlsToUpdate, |
|
|
productContact, contactPhone, imageUrlsToUpdate, |
|
|
autoOfflineTime || null, // 自动下架时间
|
|
|
autoOfflineTime || null, // 自动下架时间
|
|
|
autoOfflineHours || 24, // 默认24小时
|
|
|
autoOfflineHours || 24, // 默认24小时
|
|
|
|