Spaces:
Paused
Paused
Update server.js
Browse files
server.js
CHANGED
|
@@ -425,12 +425,16 @@ app.post('/api/gift-cards', checkOtpAuth, async (req, res) => {
|
|
| 425 |
ticket_user_name,
|
| 426 |
gc_code,
|
| 427 |
gc_phone,
|
|
|
|
| 428 |
upi_id,
|
| 429 |
amount,
|
| 430 |
proof_video_url
|
| 431 |
} = req.body;
|
| 432 |
const userId = req.headers['x-user-id'];
|
| 433 |
|
|
|
|
|
|
|
|
|
|
| 434 |
if (!ticket_user_name || !gc_code || !gc_phone || !upi_id || !amount || !proof_video_url) {
|
| 435 |
return res.status(400).json({
|
| 436 |
success: false,
|
|
@@ -445,11 +449,12 @@ app.post('/api/gift-cards', checkOtpAuth, async (req, res) => {
|
|
| 445 |
ticket_user_name,
|
| 446 |
gc_code,
|
| 447 |
gc_phone,
|
|
|
|
| 448 |
upi_id,
|
| 449 |
amount,
|
| 450 |
proof_video_url
|
| 451 |
-
) VALUES ($1, $2, $3, $4, $5, $6, $7) RETURNING id`,
|
| 452 |
-
[userId, ticket_user_name, gc_code, gc_phone, upi_id, amount, proof_video_url]
|
| 453 |
);
|
| 454 |
res.json({
|
| 455 |
success: true,
|
|
|
|
| 425 |
ticket_user_name,
|
| 426 |
gc_code,
|
| 427 |
gc_phone,
|
| 428 |
+
ticket_number,
|
| 429 |
upi_id,
|
| 430 |
amount,
|
| 431 |
proof_video_url
|
| 432 |
} = req.body;
|
| 433 |
const userId = req.headers['x-user-id'];
|
| 434 |
|
| 435 |
+
// Generate ticket number if not provided
|
| 436 |
+
const finalTicketNumber = ticket_number || `TKT-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
| 437 |
+
|
| 438 |
if (!ticket_user_name || !gc_code || !gc_phone || !upi_id || !amount || !proof_video_url) {
|
| 439 |
return res.status(400).json({
|
| 440 |
success: false,
|
|
|
|
| 449 |
ticket_user_name,
|
| 450 |
gc_code,
|
| 451 |
gc_phone,
|
| 452 |
+
ticket_number,
|
| 453 |
upi_id,
|
| 454 |
amount,
|
| 455 |
proof_video_url
|
| 456 |
+
) VALUES ($1, $2, $3, $4, $5, $6, $7, $8) RETURNING id`,
|
| 457 |
+
[userId, ticket_user_name, gc_code, gc_phone, finalTicketNumber, upi_id, amount, proof_video_url]
|
| 458 |
);
|
| 459 |
res.json({
|
| 460 |
success: true,
|