新增字段

This commit is contained in:
dzl
2025-10-09 17:29:08 +08:00
parent d18ff863b6
commit 83af2cefd6

View File

@@ -27,7 +27,7 @@ router.get('/', auth, async (req, res) => {
const query = `
SELECT
c.id, c.products_id, price, count, type, discount, for_a_amount, precent
c.id, c.products_id, price, count, type, discount, for_a_amount, precent, remain
FROM coupon_products as c
${whereClause}
ORDER BY c.id DESC
@@ -76,9 +76,10 @@ router.post('/', auth, async (req, res) => {
type,
discount,
for_a_amount,
precent
) VALUES (?,?,?,?,?,?,?)`,
[JSON.stringify(req.body.products_id), req.body.price, req.body.count, req.body.type, req.body.discount, req.body.for_a_amount, req.body.precent]
precent,
remain
) VALUES (?,?,?,?,?,?,?,?)`,
[JSON.stringify(req.body.products_id), req.body.price, req.body.count, req.body.type, req.body.discount, req.body.for_a_amount, req.body.precent, req.body.count]
);
res.json({ success: true, data: couponProduct[0] });
} catch (error) {
@@ -93,6 +94,10 @@ router.delete('/:id', auth, async (req, res) => {
`DELETE FROM coupon_products WHERE id = ?`,
[req.params.id]
);
const userCoupon = await db.query(
`DELETE FROM coupon_use WHERE coupon_id = ?`,
[req.params.id]
);
res.json({ success: true, data: couponProduct[0] });
} catch (error) {
res.status(500).json({ success: false, error: error.message });