新增原价以及佣金

This commit is contained in:
dzl
2025-10-23 17:27:55 +08:00
parent cb38e0fa3a
commit 9eea43e92e
3 changed files with 36 additions and 8 deletions

View File

@@ -887,12 +887,12 @@ router.put('/:id/status', async (req, res) => {
);
}
// 分佣金额分配
if (status === 'completed') {
const [products] = await getDB().execute(
'SELECT * FROM order_items WHERE order_id = ?',
[orderId]
);
let producers = []
for (const product of products) {
const [producersResult] = await db.execute(
'SELECT * FROM products WHERE id = ?',
@@ -901,7 +901,7 @@ router.put('/:id/status', async (req, res) => {
if (producersResult[0].shop_name) {
await db.execute(
'UPDATE users SET income = income + ? WHERE id = ?',
[1, parseInt(producersResult[0].shop_name)]
[producersResult[0].price * product.quantity, parseInt(producersResult[0].shop_name)]
);
}
}