flykup_model_development 3.1.15 → 3.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/models/order.modal.js +392 -49
- package/models/shows.model.js +18 -166
- package/package.json +1 -1
package/models/order.modal.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
// order.
|
|
1
|
+
// order.model.js - CORRECTED SCHEMA STRUCTURE
|
|
2
2
|
import mongoose from 'mongoose';
|
|
3
3
|
import { nanoid } from 'nanoid';
|
|
4
4
|
|
|
5
5
|
const orderSchema = new mongoose.Schema(
|
|
6
6
|
{
|
|
7
|
-
|
|
7
|
+
orderId: {
|
|
8
8
|
type: String,
|
|
9
9
|
required: true,
|
|
10
10
|
unique: true,
|
|
@@ -48,15 +48,7 @@ const orderSchema = new mongoose.Schema(
|
|
|
48
48
|
type: String,
|
|
49
49
|
enum: ['CGST+SGST', 'IGST',"NON-GST"],
|
|
50
50
|
required: true
|
|
51
|
-
}
|
|
52
|
-
isFlashSale: {
|
|
53
|
-
type: Boolean,
|
|
54
|
-
default: false
|
|
55
|
-
},
|
|
56
|
-
flashPrice: {
|
|
57
|
-
type: Number,
|
|
58
|
-
default: null // Store the specific flash price used for this item
|
|
59
|
-
}
|
|
51
|
+
}
|
|
60
52
|
}],
|
|
61
53
|
totalBaseAmount: {
|
|
62
54
|
type: Number,
|
|
@@ -84,30 +76,75 @@ const orderSchema = new mongoose.Schema(
|
|
|
84
76
|
amount: Number
|
|
85
77
|
}
|
|
86
78
|
},
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
addressModified: {
|
|
79
|
+
deliveryAddress: {
|
|
80
|
+
name: { type: String, maxLength: 50, trim: true, required: true },
|
|
81
|
+
mobile: { type: String, trim: true, maxLength: 15, required: true },
|
|
82
|
+
alternateMobile: { type: String, trim: true, maxLength: 15, default: null },
|
|
83
|
+
line1: { type: String, trim: true, maxLength: 100, required: true },
|
|
84
|
+
line2: { type: String, trim: true, maxLength: 100, default: "" },
|
|
85
|
+
city: { type: String, trim: true, maxLength: 50, required: true },
|
|
86
|
+
state: { type: String, trim: true, maxLength: 50, required: true },
|
|
87
|
+
pincode: { type: String, maxLength: 6, trim: true, required: true },
|
|
88
|
+
addressType: {
|
|
89
|
+
type: String,
|
|
90
|
+
enum: ['home', 'work', 'other'],
|
|
91
|
+
default: 'home'
|
|
92
|
+
},
|
|
93
|
+
addressModified: {
|
|
103
94
|
type: Boolean,
|
|
104
95
|
default: false
|
|
105
|
-
|
|
106
|
-
|
|
96
|
+
},
|
|
97
|
+
addressModifiedAt: {
|
|
107
98
|
type: Date,
|
|
108
99
|
default: null
|
|
109
|
-
|
|
110
|
-
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
// CORRECT PLACEMENT - TOP LEVEL FIELDS
|
|
103
|
+
logisticsDetails: {
|
|
104
|
+
shipmentMethod: {
|
|
105
|
+
type: String,
|
|
106
|
+
enum: ['self_shipment', 'flykup_logistics'],
|
|
107
|
+
default: 'flykup_logistics'
|
|
108
|
+
},
|
|
109
|
+
awbNumber: String,
|
|
110
|
+
carrier: String,
|
|
111
|
+
carrierId: String,
|
|
112
|
+
trackingNumber: String,
|
|
113
|
+
trackingUrl: String,
|
|
114
|
+
expectedDeliveryDate: Date,
|
|
115
|
+
shipmentBookedAt: Date,
|
|
116
|
+
logisticsResponse: mongoose.Schema.Types.Mixed,
|
|
117
|
+
shipmentBookingStatus: {
|
|
118
|
+
type: String,
|
|
119
|
+
enum: ['pending', 'booked', 'failed'],
|
|
120
|
+
default: 'pending'
|
|
121
|
+
},
|
|
122
|
+
shipmentBookingError: String,
|
|
123
|
+
multipleSellers: {
|
|
124
|
+
type: Boolean,
|
|
125
|
+
default: false
|
|
126
|
+
},
|
|
127
|
+
selectedCourier: {
|
|
128
|
+
courierId: String,
|
|
129
|
+
courierName: String,
|
|
130
|
+
deliveryCharges: Number,
|
|
131
|
+
estimatedDays: Number,
|
|
132
|
+
deliveryDate: String
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
packageDetails: {
|
|
136
|
+
totalWeight: Number,
|
|
137
|
+
weightUnit: {
|
|
138
|
+
type: String,
|
|
139
|
+
default: 'grams'
|
|
140
|
+
},
|
|
141
|
+
dimensions: {
|
|
142
|
+
length: Number,
|
|
143
|
+
width: Number,
|
|
144
|
+
height: Number
|
|
145
|
+
},
|
|
146
|
+
volumetricWeight: Number
|
|
147
|
+
},
|
|
111
148
|
pickupAddresses: [{
|
|
112
149
|
sellerUserId: {
|
|
113
150
|
type: mongoose.Schema.Types.ObjectId,
|
|
@@ -144,7 +181,7 @@ const orderSchema = new mongoose.Schema(
|
|
|
144
181
|
}],
|
|
145
182
|
paymentMethod: {
|
|
146
183
|
type: String,
|
|
147
|
-
enum: ['CARD', 'UPI', 'NETBANKING', 'WALLET', 'COD', "PENDING_PAYMENT", "CASHFREE",
|
|
184
|
+
enum: ['CARD', 'UPI', 'NETBANKING', 'WALLET', 'COD', "PENDING_PAYMENT", "CASHFREE", "Online"],
|
|
148
185
|
required: true
|
|
149
186
|
},
|
|
150
187
|
paymentStatus: {
|
|
@@ -176,12 +213,13 @@ const orderSchema = new mongoose.Schema(
|
|
|
176
213
|
},
|
|
177
214
|
sourceType: {
|
|
178
215
|
type: String,
|
|
179
|
-
enum: ['static', 'shoppable_video', 'livestream', 'auction'
|
|
216
|
+
enum: ['static', 'shoppable_video', 'livestream', 'auction'],
|
|
180
217
|
required: true
|
|
181
218
|
},
|
|
182
219
|
sourceRefId: String,
|
|
183
220
|
deliveryCharge: {
|
|
184
221
|
type: Number,
|
|
222
|
+
default: 40
|
|
185
223
|
},
|
|
186
224
|
statusTimeline: {
|
|
187
225
|
ordered: Date,
|
|
@@ -261,19 +299,6 @@ cancelSource: {
|
|
|
261
299
|
enum: ['user', 'seller', 'system'],
|
|
262
300
|
default: 'user'
|
|
263
301
|
},
|
|
264
|
-
flashSaleItems: [{
|
|
265
|
-
productId: {
|
|
266
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
267
|
-
ref: 'productlistings'
|
|
268
|
-
},
|
|
269
|
-
flashSaleId: {
|
|
270
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
271
|
-
ref: 'FlashSale'
|
|
272
|
-
},
|
|
273
|
-
quantity: Number,
|
|
274
|
-
flashPrice: Number,
|
|
275
|
-
originalPrice: Number
|
|
276
|
-
}],
|
|
277
302
|
payment: {
|
|
278
303
|
type: mongoose.Schema.Types.ObjectId,
|
|
279
304
|
ref: 'orderPayment'
|
|
@@ -292,13 +317,331 @@ payment: {
|
|
|
292
317
|
default: 0
|
|
293
318
|
},
|
|
294
319
|
invoiceError: String
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
|
|
295
326
|
},
|
|
296
|
-
|
|
327
|
+
|
|
297
328
|
{ timestamps: true }
|
|
298
329
|
);
|
|
299
330
|
|
|
300
331
|
|
|
332
|
+
const Order = mongoose.model('Order', orderSchema);
|
|
333
|
+
export default Order;
|
|
301
334
|
|
|
302
335
|
|
|
303
|
-
const Order = mongoose.models.Order || mongoose.model('Order', orderSchema);
|
|
304
|
-
export default Order;
|
|
336
|
+
// const Order = mongoose.models.Order || mongoose.model('Order', orderSchema);
|
|
337
|
+
// export default Order;
|
|
338
|
+
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
// // order.modal.js
|
|
344
|
+
// import mongoose from 'mongoose';
|
|
345
|
+
// import { nanoid } from 'nanoid';
|
|
346
|
+
|
|
347
|
+
// const orderSchema = new mongoose.Schema(
|
|
348
|
+
// {
|
|
349
|
+
// orderId: {
|
|
350
|
+
// type: String,
|
|
351
|
+
// required: true,
|
|
352
|
+
// unique: true,
|
|
353
|
+
// default: () => `ORD-${nanoid(8)}`
|
|
354
|
+
// },
|
|
355
|
+
// userId: {
|
|
356
|
+
// type: mongoose.Schema.Types.ObjectId,
|
|
357
|
+
// ref: 'users',
|
|
358
|
+
// required: true,
|
|
359
|
+
// index: true
|
|
360
|
+
// },
|
|
361
|
+
// products: [{
|
|
362
|
+
// productId: {
|
|
363
|
+
// type: mongoose.Schema.Types.ObjectId,
|
|
364
|
+
// ref: 'productlistings',
|
|
365
|
+
// required: true
|
|
366
|
+
// },
|
|
367
|
+
// sellerUserId: {
|
|
368
|
+
// type: mongoose.Schema.Types.ObjectId,
|
|
369
|
+
// ref: 'users',
|
|
370
|
+
// required: true
|
|
371
|
+
// },
|
|
372
|
+
// quantity: {
|
|
373
|
+
// type: Number,
|
|
374
|
+
// required: true,
|
|
375
|
+
// min: 1
|
|
376
|
+
// },
|
|
377
|
+
// basePrice: {
|
|
378
|
+
// type: Number,
|
|
379
|
+
// required: true
|
|
380
|
+
// },
|
|
381
|
+
// gstRate: {
|
|
382
|
+
// type: Number,
|
|
383
|
+
// required: true
|
|
384
|
+
// },
|
|
385
|
+
// gstAmount: {
|
|
386
|
+
// type: Number,
|
|
387
|
+
// required: true
|
|
388
|
+
// },
|
|
389
|
+
// gstType: {
|
|
390
|
+
// type: String,
|
|
391
|
+
// enum: ['CGST+SGST', 'IGST',"NON-GST"],
|
|
392
|
+
// required: true
|
|
393
|
+
// },
|
|
394
|
+
// isFlashSale: {
|
|
395
|
+
// type: Boolean,
|
|
396
|
+
// default: false
|
|
397
|
+
// },
|
|
398
|
+
// flashPrice: {
|
|
399
|
+
// type: Number,
|
|
400
|
+
// default: null // Store the specific flash price used for this item
|
|
401
|
+
// }
|
|
402
|
+
// }],
|
|
403
|
+
// totalBaseAmount: {
|
|
404
|
+
// type: Number,
|
|
405
|
+
// required: true
|
|
406
|
+
// },
|
|
407
|
+
// totalGstAmount: {
|
|
408
|
+
// type: Number,
|
|
409
|
+
// required: true
|
|
410
|
+
// },
|
|
411
|
+
// totalAmount: {
|
|
412
|
+
// type: Number,
|
|
413
|
+
// required: true
|
|
414
|
+
// },
|
|
415
|
+
// gstSplit: {
|
|
416
|
+
// cgst: {
|
|
417
|
+
// rate: Number,
|
|
418
|
+
// amount: Number
|
|
419
|
+
// },
|
|
420
|
+
// sgst: {
|
|
421
|
+
// rate: Number,
|
|
422
|
+
// amount: Number
|
|
423
|
+
// },
|
|
424
|
+
// igst: {
|
|
425
|
+
// rate: Number,
|
|
426
|
+
// amount: Number
|
|
427
|
+
// }
|
|
428
|
+
// },
|
|
429
|
+
// deliveryAddress: {
|
|
430
|
+
// name: { type: String, maxLength: 50, trim: true, required: true },
|
|
431
|
+
// mobile: { type: String, trim: true, maxLength: 15, required: true },
|
|
432
|
+
// alternateMobile: { type: String, trim: true, maxLength: 15, default: null },
|
|
433
|
+
// line1: { type: String, trim: true, maxLength: 100, required: true },
|
|
434
|
+
// line2: { type: String, trim: true, maxLength: 100, default: "" },
|
|
435
|
+
// city: { type: String, trim: true, maxLength: 50, required: true },
|
|
436
|
+
// state: { type: String, trim: true, maxLength: 50, required: true },
|
|
437
|
+
// pincode: { type: String, maxLength: 6, trim: true, required: true },
|
|
438
|
+
// addressType: {
|
|
439
|
+
// type: String,
|
|
440
|
+
// enum: ['home', 'work', 'other'],
|
|
441
|
+
// default: 'home'
|
|
442
|
+
// },
|
|
443
|
+
// // --- ADD THESE FIELDS INSIDE deliveryAddress ---
|
|
444
|
+
// addressModified: {
|
|
445
|
+
// type: Boolean,
|
|
446
|
+
// default: false
|
|
447
|
+
// },
|
|
448
|
+
// addressModifiedAt: {
|
|
449
|
+
// type: Date,
|
|
450
|
+
// default: null
|
|
451
|
+
// }
|
|
452
|
+
// },
|
|
453
|
+
// pickupAddresses: [{
|
|
454
|
+
// sellerUserId: {
|
|
455
|
+
// type: mongoose.Schema.Types.ObjectId,
|
|
456
|
+
// ref: 'users',
|
|
457
|
+
// required: true
|
|
458
|
+
// },
|
|
459
|
+
// name: String,
|
|
460
|
+
// mobile: String,
|
|
461
|
+
// addressLine1: {
|
|
462
|
+
// type: String,
|
|
463
|
+
// trim: true,
|
|
464
|
+
// maxLength: 150,
|
|
465
|
+
// },
|
|
466
|
+
// addressLine2: {
|
|
467
|
+
// type: String,
|
|
468
|
+
// trim: true,
|
|
469
|
+
// maxLength: 150,
|
|
470
|
+
// },
|
|
471
|
+
// city: {
|
|
472
|
+
// type: String,
|
|
473
|
+
// trim: true,
|
|
474
|
+
// maxLength: 50,
|
|
475
|
+
// },
|
|
476
|
+
// state: {
|
|
477
|
+
// type: String,
|
|
478
|
+
// trim: true,
|
|
479
|
+
// maxLength: 50,
|
|
480
|
+
// },
|
|
481
|
+
// pincode: {
|
|
482
|
+
// type: String,
|
|
483
|
+
// trim: true,
|
|
484
|
+
// maxLength: 6,
|
|
485
|
+
// },
|
|
486
|
+
// }],
|
|
487
|
+
// paymentMethod: {
|
|
488
|
+
// type: String,
|
|
489
|
+
// enum: ['CARD', 'UPI', 'NETBANKING', 'WALLET', 'COD', "PENDING_PAYMENT", "CASHFREE","RAZORPAY", "Online"],
|
|
490
|
+
// required: true
|
|
491
|
+
// },
|
|
492
|
+
// paymentStatus: {
|
|
493
|
+
// type: String,
|
|
494
|
+
// enum: ['PENDING', 'PAID', 'FAILED', 'REFUNDED'],
|
|
495
|
+
// default: 'PENDING',
|
|
496
|
+
// required: true
|
|
497
|
+
// },
|
|
498
|
+
// orderStatus: {
|
|
499
|
+
// type: String,
|
|
500
|
+
// enum: [
|
|
501
|
+
// 'PENDING_PAYMENT',
|
|
502
|
+
// 'ORDERED',
|
|
503
|
+
// 'PACKED',
|
|
504
|
+
// 'SHIPPED',
|
|
505
|
+
// 'OUT_FOR_DELIVERY',
|
|
506
|
+
// 'DELIVERED',
|
|
507
|
+
// 'CANCELLED',
|
|
508
|
+
// 'RETURN_REQUESTED',
|
|
509
|
+
// 'RETURN_APPROVED',
|
|
510
|
+
// 'RETURN_SHIPPED',
|
|
511
|
+
// 'RETURN_RECEIVED',
|
|
512
|
+
// 'REFUNDED',
|
|
513
|
+
// 'REPLACEMENT_SHIPPED',
|
|
514
|
+
// 'REPLACEMENT_DELIVERED'
|
|
515
|
+
// ],
|
|
516
|
+
// // default: 'ORDERED', // Default should be the initial state
|
|
517
|
+
// required: true
|
|
518
|
+
// },
|
|
519
|
+
// sourceType: {
|
|
520
|
+
// type: String,
|
|
521
|
+
// enum: ['static', 'shoppable_video', 'livestream', 'auction','flash_sale'],
|
|
522
|
+
// required: true
|
|
523
|
+
// },
|
|
524
|
+
// sourceRefId: String,
|
|
525
|
+
// deliveryCharge: {
|
|
526
|
+
// type: Number,
|
|
527
|
+
// default: 40
|
|
528
|
+
// },
|
|
529
|
+
// statusTimeline: {
|
|
530
|
+
// ordered: Date,
|
|
531
|
+
// paid: Date,
|
|
532
|
+
// packed: Date,
|
|
533
|
+
// shipped: Date,
|
|
534
|
+
// outForDelivery: Date,
|
|
535
|
+
// delivered: Date,
|
|
536
|
+
// cancelled: Date,
|
|
537
|
+
// returnRequested: Date,
|
|
538
|
+
// returnApproved: Date,
|
|
539
|
+
// returnShipped: Date,
|
|
540
|
+
// returnReceived: Date,
|
|
541
|
+
// refunded: Date,
|
|
542
|
+
// replacementShipped: Date,
|
|
543
|
+
// replacementDelivered: Date
|
|
544
|
+
// },
|
|
545
|
+
// courierDetails: {
|
|
546
|
+
// carrier: String,
|
|
547
|
+
// trackingNumber: String,
|
|
548
|
+
// estimatedDelivery: Date
|
|
549
|
+
// },
|
|
550
|
+
// returnDetails: {
|
|
551
|
+
// reason: String,
|
|
552
|
+
// type: {
|
|
553
|
+
// type: String,
|
|
554
|
+
// enum: ['REFUND', 'REPLACE']
|
|
555
|
+
// },
|
|
556
|
+
// items: [{
|
|
557
|
+
// productId: mongoose.Schema.Types.ObjectId,
|
|
558
|
+
// quantity: Number
|
|
559
|
+
// }]
|
|
560
|
+
// },
|
|
561
|
+
// refundDetails: {
|
|
562
|
+
// amount: Number,
|
|
563
|
+
// method: String,
|
|
564
|
+
// transactionId: String
|
|
565
|
+
// },
|
|
566
|
+
// replacementDetails: {
|
|
567
|
+
// trackingNumber: String,
|
|
568
|
+
// replacementOrderId: mongoose.Schema.Types.ObjectId
|
|
569
|
+
// },
|
|
570
|
+
// returnRequests: [{
|
|
571
|
+
// _id: { type: mongoose.Schema.Types.ObjectId, auto: true },
|
|
572
|
+
// orderItemId: { // Reference to the specific item in the order
|
|
573
|
+
// type: mongoose.Schema.Types.ObjectId,
|
|
574
|
+
// required: true
|
|
575
|
+
// },
|
|
576
|
+
// reason: String,
|
|
577
|
+
// additionalNotes: String,
|
|
578
|
+
// images: [String],
|
|
579
|
+
// status: {
|
|
580
|
+
// type: String,
|
|
581
|
+
// enum: ['PENDING',
|
|
582
|
+
// 'APPROVED',
|
|
583
|
+
// 'REJECTED',
|
|
584
|
+
// 'RETURN_SHIPPED',
|
|
585
|
+
// 'RETURN_RECEIVED',
|
|
586
|
+
// 'REFUNDED'],
|
|
587
|
+
// default: 'PENDING'
|
|
588
|
+
// },
|
|
589
|
+
// shipmentDetails: {
|
|
590
|
+
// carrier: String,
|
|
591
|
+
// trackingNumber: String,
|
|
592
|
+
// receiptImage: String, // S3 key for uploaded image
|
|
593
|
+
// shippedAt: Date
|
|
594
|
+
// },
|
|
595
|
+
// receivedAt: Date,
|
|
596
|
+
// refundProcessedAt: Date,
|
|
597
|
+
// sellerResponse: String,
|
|
598
|
+
// requestedAt: Date,
|
|
599
|
+
// processedAt: Date
|
|
600
|
+
// }],
|
|
601
|
+
// cancelReason: String,
|
|
602
|
+
// cancelSource: {
|
|
603
|
+
// type: String,
|
|
604
|
+
// enum: ['user', 'seller', 'system'],
|
|
605
|
+
// default: 'user'
|
|
606
|
+
// },
|
|
607
|
+
// flashSaleItems: [{
|
|
608
|
+
// productId: {
|
|
609
|
+
// type: mongoose.Schema.Types.ObjectId,
|
|
610
|
+
// ref: 'productlistings'
|
|
611
|
+
// },
|
|
612
|
+
// flashSaleId: {
|
|
613
|
+
// type: mongoose.Schema.Types.ObjectId,
|
|
614
|
+
// ref: 'FlashSale'
|
|
615
|
+
// },
|
|
616
|
+
// quantity: Number,
|
|
617
|
+
// flashPrice: Number,
|
|
618
|
+
// originalPrice: Number
|
|
619
|
+
// }],
|
|
620
|
+
// payment: {
|
|
621
|
+
// type: mongoose.Schema.Types.ObjectId,
|
|
622
|
+
// ref: 'orderPayment'
|
|
623
|
+
// },
|
|
624
|
+
// invoiceKey: {
|
|
625
|
+
// type: String,
|
|
626
|
+
// default: null
|
|
627
|
+
// },
|
|
628
|
+
// invoiceStatus: {
|
|
629
|
+
// type: String,
|
|
630
|
+
// enum: ['pending', 'processing', 'completed', 'failed'],
|
|
631
|
+
// default: 'pending'
|
|
632
|
+
// },
|
|
633
|
+
// invoiceRetries: {
|
|
634
|
+
// type: Number,
|
|
635
|
+
// default: 0
|
|
636
|
+
// },
|
|
637
|
+
// invoiceError: String
|
|
638
|
+
// },
|
|
639
|
+
|
|
640
|
+
// { timestamps: true }
|
|
641
|
+
// );
|
|
642
|
+
|
|
643
|
+
|
|
644
|
+
|
|
645
|
+
|
|
646
|
+
// const Order = mongoose.models.Order || mongoose.model('Order', orderSchema);
|
|
647
|
+
// export default Order;
|
package/models/shows.model.js
CHANGED
|
@@ -1,99 +1,6 @@
|
|
|
1
1
|
import mongoose from "mongoose";
|
|
2
2
|
const { Schema } = mongoose;
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
// Comment Schema
|
|
6
|
-
const commentSchema = new Schema({
|
|
7
|
-
user: {
|
|
8
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
9
|
-
ref: "users", // Reference to the User model
|
|
10
|
-
},
|
|
11
|
-
text: {
|
|
12
|
-
type: String,
|
|
13
|
-
},
|
|
14
|
-
timeStamp: {
|
|
15
|
-
type: Date,
|
|
16
|
-
default: Date.now,
|
|
17
|
-
},
|
|
18
|
-
createdAt: {
|
|
19
|
-
type: Date,
|
|
20
|
-
default: Date.now,
|
|
21
|
-
},
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
const bidSchema = new mongoose.Schema({
|
|
25
|
-
user: {
|
|
26
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
27
|
-
ref: "users", // Reference to the User model
|
|
28
|
-
required: true,
|
|
29
|
-
},
|
|
30
|
-
amount: {
|
|
31
|
-
type: Number,
|
|
32
|
-
required: true,
|
|
33
|
-
},
|
|
34
|
-
createdAt: {
|
|
35
|
-
type: Date,
|
|
36
|
-
default: Date.now,
|
|
37
|
-
},
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
// Auction Schema
|
|
41
|
-
const auctionSchema = new mongoose.Schema(
|
|
42
|
-
{
|
|
43
|
-
streamId: {
|
|
44
|
-
type: String,
|
|
45
|
-
required: true,
|
|
46
|
-
},
|
|
47
|
-
product: {
|
|
48
|
-
type: String,
|
|
49
|
-
},
|
|
50
|
-
auctionType: {
|
|
51
|
-
type: String, // 'default' or other types
|
|
52
|
-
},
|
|
53
|
-
startingBid: {
|
|
54
|
-
type: Number,
|
|
55
|
-
},
|
|
56
|
-
increment: {
|
|
57
|
-
type: Number,
|
|
58
|
-
default: 500,
|
|
59
|
-
},
|
|
60
|
-
currentHighestBid: {
|
|
61
|
-
type: Number,
|
|
62
|
-
default: 0,
|
|
63
|
-
},
|
|
64
|
-
nextBid1: {
|
|
65
|
-
type: Number,
|
|
66
|
-
default: 0,
|
|
67
|
-
},
|
|
68
|
-
nextBid2: {
|
|
69
|
-
type: Number,
|
|
70
|
-
default: 0,
|
|
71
|
-
},
|
|
72
|
-
highestBidder: {
|
|
73
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
74
|
-
ref: "users", // Store reference to the highest bidder
|
|
75
|
-
default: null,
|
|
76
|
-
},
|
|
77
|
-
bidderWon: {
|
|
78
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
79
|
-
ref: "users", // Store reference to the highest bidder
|
|
80
|
-
default: null,
|
|
81
|
-
},
|
|
82
|
-
bids: [bidSchema], // Array of bids
|
|
83
|
-
endsAt: {
|
|
84
|
-
type: Date,
|
|
85
|
-
},
|
|
86
|
-
isActive: {
|
|
87
|
-
type: Boolean,
|
|
88
|
-
default: true,
|
|
89
|
-
},
|
|
90
|
-
uniqueStreamId: {
|
|
91
|
-
type: String,
|
|
92
|
-
},
|
|
93
|
-
},
|
|
94
|
-
{ timestamps: true }
|
|
95
|
-
);
|
|
96
|
-
|
|
97
4
|
const giveawayProductSchema = new Schema({
|
|
98
5
|
_id: false,
|
|
99
6
|
productId: { type: Schema.Types.ObjectId, ref: "productlistings", required: true },
|
|
@@ -119,22 +26,22 @@ const giveawayProductSchema = new Schema({
|
|
|
119
26
|
// Show Schema
|
|
120
27
|
const showSchema = new Schema(
|
|
121
28
|
{
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
29
|
+
|
|
30
|
+
sellerId: { // <--- REMOVE or comment out this line
|
|
31
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
32
|
+
ref: "sellers",
|
|
33
|
+
},
|
|
34
|
+
// === Host Information ===
|
|
35
|
+
host: { // Host (Seller or Dropshipper)
|
|
128
36
|
type: mongoose.Schema.Types.ObjectId,
|
|
129
37
|
required: true,
|
|
130
38
|
refPath: 'hostModel' // Dynamic reference
|
|
131
39
|
},
|
|
132
|
-
hostModel: { //
|
|
40
|
+
hostModel: { // Type of host
|
|
133
41
|
type: String,
|
|
134
42
|
required: true,
|
|
135
43
|
enum: ['sellers', 'dropshippers'] // Allowed host types
|
|
136
44
|
},
|
|
137
|
-
// === MODIFIED END: Host Information ===
|
|
138
45
|
|
|
139
46
|
title: {
|
|
140
47
|
type: String,
|
|
@@ -191,7 +98,6 @@ const showSchema = new Schema(
|
|
|
191
98
|
enum: ['created', 'live', 'cancelled', 'ended'],
|
|
192
99
|
default: 'created'
|
|
193
100
|
},
|
|
194
|
-
comments: [commentSchema], // Array of comments
|
|
195
101
|
likes: {
|
|
196
102
|
type: Number,
|
|
197
103
|
default: 0,
|
|
@@ -201,14 +107,16 @@ const showSchema = new Schema(
|
|
|
201
107
|
ref: 'users',
|
|
202
108
|
default: [],
|
|
203
109
|
},
|
|
204
|
-
|
|
205
|
-
|
|
110
|
+
currentAuction: {
|
|
111
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
112
|
+
ref: 'auctions',
|
|
113
|
+
default: null
|
|
114
|
+
},
|
|
206
115
|
buyNowProducts: {
|
|
207
116
|
type: [
|
|
208
117
|
{
|
|
209
118
|
_id: false,
|
|
210
119
|
productId: { type: Schema.Types.ObjectId, ref: "productlistings" },
|
|
211
|
-
// --- ADDED productOwnerSellerId ---
|
|
212
120
|
productOwnerSellerId: { type: Schema.Types.ObjectId, ref: 'sellers', required: true },
|
|
213
121
|
productPrice: { type: Number, min: 0, default: null }, // Price set by host for this show
|
|
214
122
|
},
|
|
@@ -220,64 +128,10 @@ const showSchema = new Schema(
|
|
|
220
128
|
{
|
|
221
129
|
_id: false,
|
|
222
130
|
productId: { type: Schema.Types.ObjectId, ref: "productlistings" },
|
|
223
|
-
// --- ADDED productOwnerSellerId ---
|
|
224
131
|
productOwnerSellerId: { type: Schema.Types.ObjectId, ref: 'sellers', required: true },
|
|
225
132
|
startingPrice: { type: Number, min: 0, default: null },
|
|
226
133
|
reservedPrice: { type: Number, min: 0, default: null },
|
|
227
|
-
|
|
228
|
-
type: Boolean,
|
|
229
|
-
default: false
|
|
230
|
-
},
|
|
231
|
-
streamId: {
|
|
232
|
-
type: String,
|
|
233
|
-
},
|
|
234
|
-
// product: {
|
|
235
|
-
// type: String,
|
|
236
|
-
// },
|
|
237
|
-
auctionType: {
|
|
238
|
-
type: String, // 'default' or other types
|
|
239
|
-
},
|
|
240
|
-
startingBid: {
|
|
241
|
-
type: Number,
|
|
242
|
-
},
|
|
243
|
-
increment: {
|
|
244
|
-
type: Number,
|
|
245
|
-
default: 5,
|
|
246
|
-
},
|
|
247
|
-
currentHighestBid: {
|
|
248
|
-
type: Number,
|
|
249
|
-
default: 0,
|
|
250
|
-
},
|
|
251
|
-
nextBid1: {
|
|
252
|
-
type: Number,
|
|
253
|
-
default: 0,
|
|
254
|
-
},
|
|
255
|
-
nextBid2: {
|
|
256
|
-
type: Number,
|
|
257
|
-
default: 0,
|
|
258
|
-
},
|
|
259
|
-
highestBidder: {
|
|
260
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
261
|
-
ref: "users", // Store reference to the highest bidder
|
|
262
|
-
default: null,
|
|
263
|
-
},
|
|
264
|
-
bidderWon: {
|
|
265
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
266
|
-
ref: "users", // Store reference to the highest bidder
|
|
267
|
-
default: null,
|
|
268
|
-
},
|
|
269
|
-
bids: [bidSchema], // Array of bids
|
|
270
|
-
endsAt: {
|
|
271
|
-
type: Date,
|
|
272
|
-
},
|
|
273
|
-
isActive: {
|
|
274
|
-
type: Boolean,
|
|
275
|
-
default: true,
|
|
276
|
-
},
|
|
277
|
-
uniqueStreamId: {
|
|
278
|
-
type: String,
|
|
279
|
-
},
|
|
280
|
-
auctionNumber: { // <-- New field in auctionProducts sub-schema
|
|
134
|
+
auctionNumber: {
|
|
281
135
|
type: Number,
|
|
282
136
|
}
|
|
283
137
|
},
|
|
@@ -291,16 +145,14 @@ const showSchema = new Schema(
|
|
|
291
145
|
},
|
|
292
146
|
|
|
293
147
|
enabledProductTypes: {
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
}
|
|
298
|
-
,
|
|
148
|
+
buyNow: { type: Boolean, default: false },
|
|
149
|
+
auction: { type: Boolean, default: false },
|
|
150
|
+
giveaway: { type: Boolean, default: false }
|
|
151
|
+
},
|
|
299
152
|
notes: {
|
|
300
153
|
type: String,
|
|
301
154
|
default: ''
|
|
302
155
|
},
|
|
303
|
-
// giveaways: [giveawaySchema], // Array of giveaways
|
|
304
156
|
},
|
|
305
157
|
{ timestamps: true }
|
|
306
158
|
);
|