fix bug for /api/shop/items/buy
This commit is contained in:
parent
84fed4acda
commit
5e2ec81d0c
@ -643,6 +643,7 @@ document.getElementById("addressForm").onsubmit = function (e) {
|
|||||||
const items = cart.map((item) => ({
|
const items = cart.map((item) => ({
|
||||||
id: item.name,
|
id: item.name,
|
||||||
quantity: item.qty,
|
quantity: item.qty,
|
||||||
|
sellQuantity: getItemSellQuantity(item.name),
|
||||||
}));
|
}));
|
||||||
const request = {
|
const request = {
|
||||||
userId: user.username,
|
userId: user.username,
|
||||||
|
|||||||
@ -379,7 +379,7 @@ module.exports = function (app, wss, pool) {
|
|||||||
);
|
);
|
||||||
if (!userRow)
|
if (!userRow)
|
||||||
return res.status(404).json({ ok: false, error: "User not found" });
|
return res.status(404).json({ ok: false, error: "User not found" });
|
||||||
if (userRow.balance < price * item.quantity)
|
if (userRow.balance < price * (item.quantity / item.sellQuantity))
|
||||||
return res.status(400).json({
|
return res.status(400).json({
|
||||||
ok: false,
|
ok: false,
|
||||||
error: `Insufficient balance for item ${item.id}`,
|
error: `Insufficient balance for item ${item.id}`,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user