|
|
@ -830,9 +830,9 @@ app.post('/api/supplies/create', async (req, res) => { |
|
|
await connection.beginTransaction(); |
|
|
await connection.beginTransaction(); |
|
|
|
|
|
|
|
|
// 验证必填字段
|
|
|
// 验证必填字段
|
|
|
if (!productName || !price || !quantity || !supplyStatus || !sourceType) { |
|
|
if (!productName || !costprice || !quantity || !supplyStatus || !sourceType) { |
|
|
connection.release(); |
|
|
connection.release(); |
|
|
return sendResponse(res, false, null, '商品名称、价格、最小起订量、货源状态和货源类型不能为空'); |
|
|
return sendResponse(res, false, null, '商品名称、采购价、最小起订量、货源状态和货源类型不能为空'); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 如果sellerId为空,设置一个默认值
|
|
|
// 如果sellerId为空,设置一个默认值
|
|
|
@ -919,7 +919,7 @@ app.post('/api/supplies/create', async (req, res) => { |
|
|
sellerId: sellerId, // 使用前端传入的sellerId
|
|
|
sellerId: sellerId, // 使用前端传入的sellerId
|
|
|
productName, |
|
|
productName, |
|
|
category: category || '', // 添加种类
|
|
|
category: category || '', // 添加种类
|
|
|
price: price.toString(), // 确保是varchar类型
|
|
|
price: (price || '').toString(), // 确保是varchar类型
|
|
|
costprice: costprice || '', // 添加采购价
|
|
|
costprice: costprice || '', // 添加采购价
|
|
|
quantity: quantity, // 保持为逗号分隔的字符串,不转换为整数
|
|
|
quantity: quantity, // 保持为逗号分隔的字符串,不转换为整数
|
|
|
grossWeight, |
|
|
grossWeight, |
|
|
@ -954,7 +954,7 @@ app.post('/api/supplies/create', async (req, res) => { |
|
|
// 没有quality字段,不包含quality字段的插入
|
|
|
// 没有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, 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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'; |
|
|
insertParams = [ |
|
|
insertParams = [ |
|
|
productId, productData.sellerId, productName, category || '', req.body.freshness || '', price.toString(), costprice || '', quantity, grossWeight, |
|
|
productId, productData.sellerId, productName, category || '', req.body.freshness || '', (price || '').toString(), 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 // 添加联系人信息和自动下架时间、小时数
|
|
|
@ -963,7 +963,7 @@ app.post('/api/supplies/create', async (req, res) => { |
|
|
// 有quality字段,包含quality字段的插入
|
|
|
// 有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, 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 (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'; |
|
|
insertParams = [ |
|
|
insertParams = [ |
|
|
productId, productData.sellerId, productName, category || '', req.body.freshness || '', price.toString(), costprice || '', quantity, grossWeight, |
|
|
productId, productData.sellerId, productName, category || '', req.body.freshness || '', (price || '').toString(), costprice || '', quantity, grossWeight, |
|
|
yolk, specification, producting, quality, region, productData.status, productData.supplyStatus, |
|
|
yolk, specification, producting, quality, region, productData.status, productData.supplyStatus, |
|
|
productData.sourceType, productData.description, productData.rejectReason, productData.imageUrls, |
|
|
productData.sourceType, 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 // 添加联系人信息和自动下架时间、小时数
|
|
|
@ -993,7 +993,7 @@ app.post('/api/supplies/create', async (req, res) => { |
|
|
productId: productId, |
|
|
productId: productId, |
|
|
productName, |
|
|
productName, |
|
|
category: category || '', |
|
|
category: category || '', |
|
|
price: price.toString(), |
|
|
price: (price || '').toString(), |
|
|
costprice: costprice || '', |
|
|
costprice: costprice || '', |
|
|
quantity, |
|
|
quantity, |
|
|
grossWeight, |
|
|
grossWeight, |
|
|
@ -1468,7 +1468,7 @@ app.put('/api/supplies/:id/edit', async (req, res) => { |
|
|
`;
|
|
|
`;
|
|
|
|
|
|
|
|
|
await connection.query(updateQuery, [ |
|
|
await connection.query(updateQuery, [ |
|
|
productName, price.toString(), costprice || '', quantityValue, grossWeight, |
|
|
productName, (price || '').toString(), costprice || '', quantityValue, grossWeight, |
|
|
yolk, specification, producting, supplyStatus, description, region, |
|
|
yolk, specification, producting, supplyStatus, description, region, |
|
|
productContact, contactPhone, JSON.stringify(uploadedImageUrls), |
|
|
productContact, contactPhone, JSON.stringify(uploadedImageUrls), |
|
|
autoOfflineTime || null, // 自动下架时间
|
|
|
autoOfflineTime || null, // 自动下架时间
|
|
|
@ -1489,7 +1489,7 @@ app.put('/api/supplies/:id/edit', async (req, res) => { |
|
|
data: { |
|
|
data: { |
|
|
id: productId, |
|
|
id: productId, |
|
|
productName, |
|
|
productName, |
|
|
price: price.toString(), |
|
|
price: (price || '').toString(), |
|
|
costprice: costprice || '', |
|
|
costprice: costprice || '', |
|
|
quantity, |
|
|
quantity, |
|
|
grossWeight, |
|
|
grossWeight, |
|
|
|