Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wheel bug #12

Merged
merged 1 commit into from
Sep 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions api/router/ticket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import express, { Request, Response } from "express";
import { ResultSetHeader, RowDataPacket } from "mysql2";
import mysql_connect from "./../utils/mysqlConnect";
import { FormationTicket, Ticket } from "../types/Ticket";
import { KRAFormation, TicketType } from "../kra/KRAClient";
import { KRAFormation, KRATicket, TicketType } from "../kra/KRAClient";

const router = express.Router();
const con = mysql_connect();
Expand Down Expand Up @@ -45,7 +45,9 @@ router.get("/get/:ticket_id", async (req: Request, res: Response<Ticket>) => {
router.post("/add", async (req: Request<Ticket>, res: Response<Ticket>) => {
const [checkMoneyRows] = await con.query<RowDataPacket[]>("SELECT having_money FROM users WHERE user_id = ?", [req.body.user_id])
if (checkMoneyRows.length === 0) throw new Error("The User is not found.")
const setMoney = checkMoneyRows[0].having_money - parseInt(req.body.bet)
const oisiiyammuy: KRATicket = new KRATicket(req.body.type, req.body.bet, req.body.horse, req.body.option, req.body.optNum, req.body.user_id)
const size = oisiiyammuy.build().length;
const setMoney = checkMoneyRows[0].having_money - parseInt(req.body.bet) * size;
if (setMoney < 0) throw new Error("You do not have enough money to complete the bet.")
const [addTicketRows] = await con.query<ResultSetHeader>(
"INSERT INTO ticket (user_id, horse, type, option, optNum, bet, race) VALUES (?, JSON_ARRAY(?), ?, ?, ?, ?, ?)",
Expand Down
Loading