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) => ({
|
||||
id: item.name,
|
||||
quantity: item.qty,
|
||||
sellQuantity: getItemSellQuantity(item.name),
|
||||
}));
|
||||
const request = {
|
||||
userId: user.username,
|
||||
|
||||
@ -379,7 +379,7 @@ module.exports = function (app, wss, pool) {
|
||||
);
|
||||
if (!userRow)
|
||||
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({
|
||||
ok: false,
|
||||
error: `Insufficient balance for item ${item.id}`,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user