flykup_model_development 3.0.7 → 3.0.9

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.
@@ -168,7 +168,7 @@ const orderSchema = new mongoose.Schema(
168
168
  },
169
169
  sourceType: {
170
170
  type: String,
171
- enum: ['static', 'shoppable_video', 'livestream', 'auction'],
171
+ enum: ['static', 'shoppable_video', 'livestream', 'auction','flash_sale'],
172
172
  required: true
173
173
  },
174
174
  sourceRefId: String,
@@ -254,6 +254,19 @@ cancelSource: {
254
254
  enum: ['user', 'seller', 'system'],
255
255
  default: 'user'
256
256
  },
257
+ flashSaleItems: [{
258
+ productId: {
259
+ type: mongoose.Schema.Types.ObjectId,
260
+ ref: 'productlistings'
261
+ },
262
+ flashSaleId: {
263
+ type: mongoose.Schema.Types.ObjectId,
264
+ ref: 'FlashSale'
265
+ },
266
+ quantity: Number,
267
+ flashPrice: Number,
268
+ originalPrice: Number
269
+ }],
257
270
  payment: {
258
271
  type: mongoose.Schema.Types.ObjectId,
259
272
  ref: 'orderPayment'
@@ -273,6 +286,7 @@ payment: {
273
286
  },
274
287
  invoiceError: String
275
288
  },
289
+
276
290
  { timestamps: true }
277
291
  );
278
292
 
@@ -1,3 +1,66 @@
1
+ // import mongoose from 'mongoose';
2
+
3
+ // const paymentSchema = new mongoose.Schema({
4
+ // orderId: {
5
+ // type: mongoose.Schema.Types.ObjectId,
6
+ // ref: 'Order',
7
+ // required: true
8
+ // },
9
+ // userId: {
10
+ // type: mongoose.Schema.Types.ObjectId,
11
+ // ref: 'users',
12
+ // required: true
13
+ // },
14
+ // paymentGateway: {
15
+ // type: String,
16
+ // enum: ['RAZORPAY', 'CASHFREE'],
17
+ // required: true
18
+ // },
19
+ // paymentGatewayOrderId: {
20
+ // type: String,
21
+ // required: false
22
+ // },
23
+ // paymentGatewayPaymentId: {
24
+ // type: String,
25
+ // required: false
26
+ // },
27
+
28
+ // amount: {
29
+ // type: Number,
30
+ // required: true
31
+ // },
32
+ // currency: {
33
+ // type: String,
34
+ // default: 'INR'
35
+ // },
36
+ // status: {
37
+ // type: String,
38
+ // enum: ['PENDING', 'SUCCESS', 'FAILED', 'REFUNDED'],
39
+ // default: 'PENDING'
40
+ // },
41
+ // paymentMethod: String,
42
+ // transactionId: String,
43
+ // transactionTime: Date,
44
+ // sellerPayments: [{
45
+ // sellerId: {
46
+ // type: mongoose.Schema.Types.ObjectId,
47
+ // ref: 'users',
48
+ // required: true
49
+ // },
50
+ // amount: Number,
51
+ // settlementStatus: {
52
+ // type: String,
53
+ // enum: ['PENDING', 'SETTLED'],
54
+ // default: 'PENDING'
55
+ // }
56
+ // }]
57
+ // }, { timestamps: true });
58
+
59
+ // const OrderPayment = mongoose.model('orderPayment', paymentSchema);
60
+ // export default OrderPayment;
61
+
62
+
63
+ // models/OrderPayment.js
1
64
  import mongoose from 'mongoose';
2
65
 
3
66
  const paymentSchema = new mongoose.Schema({
@@ -11,19 +74,37 @@ const paymentSchema = new mongoose.Schema({
11
74
  ref: 'users',
12
75
  required: true
13
76
  },
14
- paymentGateway: {
15
- type: String,
16
- enum: ['RAZORPAY', 'CASHFREE'],
17
- required: true
18
- },
19
- paymentGatewayOrderId: {
20
- type: String,
21
- required: false
22
- },
23
- paymentGatewayPaymentId: {
24
- type: String,
25
- required: false
26
- },
77
+ paymentGateway: {
78
+ type: String,
79
+ enum: ['RAZORPAY', 'CASHFREE'],
80
+ required: true
81
+ },
82
+
83
+ // Razorpay-specific fields
84
+ razorpayOrderId: {
85
+ type: String,
86
+ required: function() {
87
+ return this.paymentGateway === 'RAZORPAY';
88
+ }
89
+ },
90
+ razorpayPaymentId: {
91
+ type: String,
92
+ default: null
93
+ },
94
+
95
+ // Cashfree-specific fields
96
+ cfPaymentSessionId: {
97
+ type: String,
98
+ required: function() {
99
+ return this.paymentGateway === 'CASHFREE';
100
+ }
101
+ },
102
+ cfOrderId: {
103
+ type: String,
104
+ required: function() {
105
+ return this.paymentGateway === 'CASHFREE';
106
+ }
107
+ },
27
108
 
28
109
  amount: {
29
110
  type: Number,
@@ -39,7 +120,6 @@ paymentGatewayPaymentId: {
39
120
  default: 'PENDING'
40
121
  },
41
122
  paymentMethod: String,
42
- transactionId: String,
43
123
  transactionTime: Date,
44
124
  sellerPayments: [{
45
125
  sellerId: {
@@ -56,5 +136,10 @@ paymentGatewayPaymentId: {
56
136
  }]
57
137
  }, { timestamps: true });
58
138
 
139
+ // Create indexes for better performance
140
+ paymentSchema.index({ razorpayOrderId: 1 });
141
+ paymentSchema.index({ cfOrderId: 1 });
142
+ paymentSchema.index({ orderId: 1 });
143
+
59
144
  const OrderPayment = mongoose.model('orderPayment', paymentSchema);
60
- export default OrderPayment;
145
+ export default OrderPayment;
@@ -122,15 +122,15 @@ const ProductListingSchema = new Schema(
122
122
  5: { type: Number, default: 0 },
123
123
  },
124
124
  },
125
- flashSale: {
126
- isActive: { type: Boolean, default: false },
127
- flashSaleId: { type: mongoose.Schema.Types.ObjectId, ref: 'FlashSale' },
128
- flashPrice: { type: Number, default: null },
129
- flashStock: { type: Number, default: 0 },
130
- originalPrice: { type: Number, default: null },
131
- endsAt: { type: Date, default: null },
132
- startsAt: { type: Date, default: null }
133
- },
125
+ flashSale: {
126
+ isActive: { type: Boolean, default: false },
127
+ flashSaleId: { type: mongoose.Schema.Types.ObjectId, ref: 'FlashSale' },
128
+ flashPrice: { type: Number, default: null },
129
+ flashStock: { type: Number, default: 0 },
130
+ originalPrice: { type: Number, default: null },
131
+ endsAt: { type: Date, default: null },
132
+ startsAt: { type: Date, default: null }
133
+ },
134
134
  totalReviews: { type: Number, default: 0 },
135
135
  },
136
136
  { timestamps: true }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flykup_model_development",
3
- "version": "3.0.7",
3
+ "version": "3.0.9",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "private": false,