database-connector 1.0.7 → 1.1.0
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/CHANGELOG.md +171 -0
- package/models/Bill.js +88 -2
- package/models/Cart.js +53 -0
- package/models/Category.js +48 -3
- package/models/FlashDeal.js +76 -3
- package/models/Notification.js +67 -8
- package/models/Offer.js +75 -1
- package/models/Order.js +97 -0
- package/models/Payment.js +83 -6
- package/models/PaymentType.js +19 -0
- package/models/Plan.js +40 -0
- package/models/Policy.js +208 -90
- package/models/Product.js +109 -9
- package/models/ReductionOffer.js +58 -0
- package/models/ResetPassword.js +31 -2
- package/models/Sale.js +41 -5
- package/models/Store.js +105 -3
- package/models/StoreCategory.js +35 -4
- package/models/StoreRate.js +32 -3
- package/models/Subscription.js +63 -0
- package/models/SubscriptionOffer.js +32 -0
- package/models/User.js +118 -1
- package/models/UserAction.js +39 -0
- package/models/View.js +46 -6
- package/models/index.js +2 -2
- package/package.json +2 -2
- package/models/OrderOld.js +0 -74
package/models/Product.js
CHANGED
|
@@ -1,7 +1,100 @@
|
|
|
1
1
|
const mongoose = require('mongoose');
|
|
2
2
|
const { policySchema } = require('database-connector/models/Policy');
|
|
3
|
-
var ObjectId = require('mongodb').ObjectID;
|
|
4
3
|
|
|
4
|
+
/**
|
|
5
|
+
* @swagger
|
|
6
|
+
* components:
|
|
7
|
+
* schemas:
|
|
8
|
+
* Product:
|
|
9
|
+
* type: object
|
|
10
|
+
* required:
|
|
11
|
+
* - name
|
|
12
|
+
* - description
|
|
13
|
+
* - price
|
|
14
|
+
* - storeCategoryId
|
|
15
|
+
* - categoryId
|
|
16
|
+
* - rayonId
|
|
17
|
+
* - sellerId
|
|
18
|
+
* - storeId
|
|
19
|
+
* properties:
|
|
20
|
+
* id:
|
|
21
|
+
* type: string
|
|
22
|
+
* description: The product identifier
|
|
23
|
+
* name:
|
|
24
|
+
* type: string
|
|
25
|
+
* description: Product name
|
|
26
|
+
* description:
|
|
27
|
+
* type: string
|
|
28
|
+
* description: Product description
|
|
29
|
+
* price:
|
|
30
|
+
* type: number
|
|
31
|
+
* description: Product price
|
|
32
|
+
* storeCategoryId:
|
|
33
|
+
* type: string
|
|
34
|
+
* description: Reference to store category
|
|
35
|
+
* categoryId:
|
|
36
|
+
* type: string
|
|
37
|
+
* description: Reference to category
|
|
38
|
+
* subCategoryId:
|
|
39
|
+
* type: string
|
|
40
|
+
* description: Reference to sub-category
|
|
41
|
+
* rayonId:
|
|
42
|
+
* type: string
|
|
43
|
+
* description: Reference to rayon
|
|
44
|
+
* images:
|
|
45
|
+
* type: array
|
|
46
|
+
* items:
|
|
47
|
+
* type: string
|
|
48
|
+
* description: Product images
|
|
49
|
+
* tags:
|
|
50
|
+
* type: array
|
|
51
|
+
* items:
|
|
52
|
+
* type: string
|
|
53
|
+
* description: Product tags
|
|
54
|
+
* sellerId:
|
|
55
|
+
* type: string
|
|
56
|
+
* description: Reference to seller
|
|
57
|
+
* storeId:
|
|
58
|
+
* type: string
|
|
59
|
+
* description: Reference to store
|
|
60
|
+
* deleted:
|
|
61
|
+
* type: boolean
|
|
62
|
+
* default: false
|
|
63
|
+
* description: Whether the product is deleted
|
|
64
|
+
* discount:
|
|
65
|
+
* type: number
|
|
66
|
+
* default: 0
|
|
67
|
+
* description: Product discount
|
|
68
|
+
* numberOfSales:
|
|
69
|
+
* type: number
|
|
70
|
+
* default: 0
|
|
71
|
+
* description: Number of sales
|
|
72
|
+
* numberOfViews:
|
|
73
|
+
* type: number
|
|
74
|
+
* default: 0
|
|
75
|
+
* description: Number of views
|
|
76
|
+
* averageRating:
|
|
77
|
+
* type: number
|
|
78
|
+
* default: 0
|
|
79
|
+
* description: Average rating
|
|
80
|
+
* createdAt:
|
|
81
|
+
* type: string
|
|
82
|
+
* format: date-time
|
|
83
|
+
* updatedAt:
|
|
84
|
+
* type: string
|
|
85
|
+
* format: date-time
|
|
86
|
+
* example:
|
|
87
|
+
* id: "507f1f77bcf86cd799439011"
|
|
88
|
+
* name: "Wireless Headphones"
|
|
89
|
+
* description: "High-quality wireless headphones"
|
|
90
|
+
* price: 99.99
|
|
91
|
+
* discount: 10
|
|
92
|
+
* numberOfSales: 50
|
|
93
|
+
* numberOfViews: 250
|
|
94
|
+
* averageRating: 4.5
|
|
95
|
+
* createdAt: "2025-11-01T10:30:00.000Z"
|
|
96
|
+
* updatedAt: "2025-12-01T15:45:00.000Z"
|
|
97
|
+
*/
|
|
5
98
|
const productSchema = new mongoose.Schema(
|
|
6
99
|
{
|
|
7
100
|
name: {
|
|
@@ -136,15 +229,19 @@ const productSchema = new mongoose.Schema(
|
|
|
136
229
|
},
|
|
137
230
|
{
|
|
138
231
|
timestamps: true,
|
|
139
|
-
toJSON: { virtuals: true }
|
|
232
|
+
toJSON: { virtuals: true }
|
|
140
233
|
}
|
|
141
|
-
)
|
|
234
|
+
);
|
|
235
|
+
|
|
236
|
+
// Virtual properties for quantity calculations (commented out)
|
|
237
|
+
/*
|
|
142
238
|
productSchema.virtual('quantity').get(function () {
|
|
143
239
|
const variants = this.variants;
|
|
144
240
|
return variants.reduce(function (total, currentValue) {
|
|
145
241
|
return total + currentValue.quantity;
|
|
146
242
|
}, 0);
|
|
147
243
|
});
|
|
244
|
+
|
|
148
245
|
productSchema.virtual('PriceMin').get(function () {
|
|
149
246
|
const variants = this.variants;
|
|
150
247
|
return variants.reduce(function (prev, curr) {
|
|
@@ -157,8 +254,10 @@ productSchema.virtual('PriceMax').get(function () {
|
|
|
157
254
|
return variants.reduce(function (prev, curr) {
|
|
158
255
|
return prev.price > curr.price ? prev : curr;
|
|
159
256
|
}).price;
|
|
160
|
-
})
|
|
161
|
-
|
|
257
|
+
});
|
|
258
|
+
*/
|
|
259
|
+
|
|
260
|
+
// Virtual: array of all product images with full URLs
|
|
162
261
|
productSchema.virtual('imagesss').get(function () {
|
|
163
262
|
if (this.images != null) {
|
|
164
263
|
const images = this.images;
|
|
@@ -169,17 +268,18 @@ productSchema.virtual('imagesss').get(function () {
|
|
|
169
268
|
});
|
|
170
269
|
}
|
|
171
270
|
});
|
|
271
|
+
|
|
272
|
+
// Virtual: discounted price
|
|
172
273
|
productSchema.virtual('discounted').get(function () {
|
|
173
274
|
if (this.offer) {
|
|
174
|
-
console.log('
|
|
175
|
-
|
|
275
|
+
console.log('Discount');
|
|
176
276
|
return this.offer.discount;
|
|
177
|
-
|
|
178
277
|
} else {
|
|
179
278
|
return this.price;
|
|
180
279
|
}
|
|
181
280
|
});
|
|
182
|
-
|
|
281
|
+
|
|
282
|
+
// Virtual: array of all variant images with full URLs
|
|
183
283
|
productSchema.virtual('variantImages').get(function () {
|
|
184
284
|
if (this.variants != null) {
|
|
185
285
|
const variants = this.variants;
|
package/models/ReductionOffer.js
CHANGED
|
@@ -1,5 +1,63 @@
|
|
|
1
1
|
const mongoose = require('mongoose');
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* @swagger
|
|
5
|
+
* components:
|
|
6
|
+
* schemas:
|
|
7
|
+
* ReductionOffer:
|
|
8
|
+
* type: object
|
|
9
|
+
* required:
|
|
10
|
+
* - name
|
|
11
|
+
* - discount
|
|
12
|
+
* - storesNumber
|
|
13
|
+
* - plan
|
|
14
|
+
* properties:
|
|
15
|
+
* id:
|
|
16
|
+
* type: string
|
|
17
|
+
* description: The reduction offer identifier
|
|
18
|
+
* name:
|
|
19
|
+
* type: string
|
|
20
|
+
* description: Unique offer name
|
|
21
|
+
* discount:
|
|
22
|
+
* type: number
|
|
23
|
+
* description: Discount amount or percentage
|
|
24
|
+
* storesNumber:
|
|
25
|
+
* type: number
|
|
26
|
+
* description: Number of stores included
|
|
27
|
+
* plan:
|
|
28
|
+
* type: string
|
|
29
|
+
* description: Reference to the plan
|
|
30
|
+
* StartDate:
|
|
31
|
+
* type: string
|
|
32
|
+
* format: date-time
|
|
33
|
+
* description: Start date of the offer
|
|
34
|
+
* EndDate:
|
|
35
|
+
* type: string
|
|
36
|
+
* format: date-time
|
|
37
|
+
* description: End date of the offer
|
|
38
|
+
* description:
|
|
39
|
+
* type: string
|
|
40
|
+
* description: Offer description
|
|
41
|
+
* status:
|
|
42
|
+
* type: string
|
|
43
|
+
* enum: [inactive, active, expired]
|
|
44
|
+
* default: inactive
|
|
45
|
+
* description: Offer status
|
|
46
|
+
* createdAt:
|
|
47
|
+
* type: string
|
|
48
|
+
* format: date-time
|
|
49
|
+
* updatedAt:
|
|
50
|
+
* type: string
|
|
51
|
+
* format: date-time
|
|
52
|
+
* example:
|
|
53
|
+
* id: "507f1f77bcf86cd799439011"
|
|
54
|
+
* name: "Holiday Special"
|
|
55
|
+
* discount: 15
|
|
56
|
+
* storesNumber: 5
|
|
57
|
+
* status: "active"
|
|
58
|
+
* createdAt: "2025-11-01T10:30:00.000Z"
|
|
59
|
+
* updatedAt: "2025-12-01T15:45:00.000Z"
|
|
60
|
+
*/
|
|
3
61
|
const ReductionOfferSchema = new mongoose.Schema(
|
|
4
62
|
{
|
|
5
63
|
name: {
|
package/models/ResetPassword.js
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
const mongoose = require('mongoose');
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* @swagger
|
|
5
|
+
* components:
|
|
6
|
+
* schemas:
|
|
7
|
+
* ResetPassword:
|
|
8
|
+
* type: object
|
|
9
|
+
* required:
|
|
10
|
+
* - userId
|
|
11
|
+
* - token
|
|
12
|
+
* properties:
|
|
13
|
+
* id:
|
|
14
|
+
* type: string
|
|
15
|
+
* description: The reset password identifier
|
|
16
|
+
* userId:
|
|
17
|
+
* type: string
|
|
18
|
+
* description: Reference to the user
|
|
19
|
+
* token:
|
|
20
|
+
* type: string
|
|
21
|
+
* description: Reset token
|
|
22
|
+
* createAt:
|
|
23
|
+
* type: string
|
|
24
|
+
* format: date-time
|
|
25
|
+
* description: Creation timestamp (expires after 1 hour)
|
|
26
|
+
* example:
|
|
27
|
+
* id: "507f1f77bcf86cd799439011"
|
|
28
|
+
* userId: "507f1f77bcf86cd799439012"
|
|
29
|
+
* token: "abc123xyz789"
|
|
30
|
+
* createAt: "2025-12-07T10:30:00.000Z"
|
|
31
|
+
*/
|
|
3
32
|
const resetPasswordSchema = new mongoose.Schema(
|
|
4
33
|
{
|
|
5
34
|
userId: {
|
|
@@ -9,12 +38,12 @@ const resetPasswordSchema = new mongoose.Schema(
|
|
|
9
38
|
},
|
|
10
39
|
token: {
|
|
11
40
|
type: String,
|
|
12
|
-
required: true
|
|
41
|
+
required: true
|
|
13
42
|
},
|
|
14
43
|
createAt: {
|
|
15
44
|
type: Date,
|
|
16
45
|
default: Date.now,
|
|
17
|
-
|
|
46
|
+
expires: 3600
|
|
18
47
|
}
|
|
19
48
|
},
|
|
20
49
|
{ toJSON: { virtuals: true } }
|
package/models/Sale.js
CHANGED
|
@@ -1,11 +1,47 @@
|
|
|
1
1
|
const mongoose = require('mongoose');
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* @swagger
|
|
5
|
+
* components:
|
|
6
|
+
* schemas:
|
|
7
|
+
* Sale:
|
|
8
|
+
* type: object
|
|
9
|
+
* required:
|
|
10
|
+
* - date
|
|
11
|
+
* properties:
|
|
12
|
+
* id:
|
|
13
|
+
* type: string
|
|
14
|
+
* description: The sale identifier
|
|
15
|
+
* sellerId:
|
|
16
|
+
* type: string
|
|
17
|
+
* description: Reference to the seller
|
|
18
|
+
* storeId:
|
|
19
|
+
* type: string
|
|
20
|
+
* description: Reference to the store
|
|
21
|
+
* productId:
|
|
22
|
+
* type: string
|
|
23
|
+
* description: Reference to the product
|
|
24
|
+
* date:
|
|
25
|
+
* type: string
|
|
26
|
+
* format: date-time
|
|
27
|
+
* description: Date of the sale
|
|
28
|
+
* region:
|
|
29
|
+
* type: string
|
|
30
|
+
* description: Region where the sale occurred
|
|
31
|
+
* example:
|
|
32
|
+
* id: "507f1f77bcf86cd799439011"
|
|
33
|
+
* sellerId: "507f1f77bcf86cd799439012"
|
|
34
|
+
* storeId: "507f1f77bcf86cd799439013"
|
|
35
|
+
* productId: "507f1f77bcf86cd799439014"
|
|
36
|
+
* date: "2025-12-07T10:30:00.000Z"
|
|
37
|
+
* region: "North Region"
|
|
38
|
+
*/
|
|
3
39
|
const Sale = new mongoose.Schema({
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
40
|
+
sellerId: { type: mongoose.Schema.Types.ObjectId, ref: 'Seller' },
|
|
41
|
+
storeId: { type: mongoose.Schema.Types.ObjectId, ref: 'Store' },
|
|
42
|
+
productId: { type: mongoose.Schema.Types.ObjectId, ref: 'Product' },
|
|
43
|
+
date: { type: Date, required: true },
|
|
44
|
+
region: { type: String }
|
|
9
45
|
});
|
|
10
46
|
|
|
11
47
|
module.exports = mongoose.model('Sale', Sale);
|
package/models/Store.js
CHANGED
|
@@ -1,9 +1,111 @@
|
|
|
1
1
|
const mongoose = require('mongoose');
|
|
2
|
-
const User = require('database-connector/models/User');
|
|
3
|
-
const Product = require('database-connector/models/Product');
|
|
4
2
|
const { policySchema } = require('database-connector/models/Policy');
|
|
5
|
-
var ObjectId = require('mongodb').ObjectID;
|
|
6
3
|
|
|
4
|
+
/**
|
|
5
|
+
* @swagger
|
|
6
|
+
* components:
|
|
7
|
+
* schemas:
|
|
8
|
+
* Store:
|
|
9
|
+
* type: object
|
|
10
|
+
* required:
|
|
11
|
+
* - name
|
|
12
|
+
* - sellerId
|
|
13
|
+
* - image
|
|
14
|
+
* - description
|
|
15
|
+
* properties:
|
|
16
|
+
* id:
|
|
17
|
+
* type: string
|
|
18
|
+
* description: The store identifier
|
|
19
|
+
* name:
|
|
20
|
+
* type: string
|
|
21
|
+
* description: Store name
|
|
22
|
+
* sellerId:
|
|
23
|
+
* type: string
|
|
24
|
+
* description: Reference to the seller/owner
|
|
25
|
+
* address:
|
|
26
|
+
* type: object
|
|
27
|
+
* properties:
|
|
28
|
+
* city:
|
|
29
|
+
* type: string
|
|
30
|
+
* streetName:
|
|
31
|
+
* type: string
|
|
32
|
+
* postalCode:
|
|
33
|
+
* type: string
|
|
34
|
+
* country:
|
|
35
|
+
* type: string
|
|
36
|
+
* fullAdress:
|
|
37
|
+
* type: string
|
|
38
|
+
* region:
|
|
39
|
+
* type: string
|
|
40
|
+
* countryCode:
|
|
41
|
+
* type: string
|
|
42
|
+
* phone:
|
|
43
|
+
* type: string
|
|
44
|
+
* location:
|
|
45
|
+
* type: object
|
|
46
|
+
* properties:
|
|
47
|
+
* type:
|
|
48
|
+
* type: string
|
|
49
|
+
* enum: [Point]
|
|
50
|
+
* default: Point
|
|
51
|
+
* coordinates:
|
|
52
|
+
* type: array
|
|
53
|
+
* items:
|
|
54
|
+
* type: number
|
|
55
|
+
* description: [longitude, latitude]
|
|
56
|
+
* image:
|
|
57
|
+
* type: string
|
|
58
|
+
* description: Store image URL
|
|
59
|
+
* description:
|
|
60
|
+
* type: string
|
|
61
|
+
* description: Store description
|
|
62
|
+
* isActive:
|
|
63
|
+
* type: boolean
|
|
64
|
+
* default: true
|
|
65
|
+
* description: Whether the store is active
|
|
66
|
+
* ratingCount:
|
|
67
|
+
* type: number
|
|
68
|
+
* default: 0
|
|
69
|
+
* description: Number of ratings
|
|
70
|
+
* ratingSum:
|
|
71
|
+
* type: number
|
|
72
|
+
* default: 0
|
|
73
|
+
* description: Sum of all ratings
|
|
74
|
+
* revenue:
|
|
75
|
+
* type: number
|
|
76
|
+
* default: 0
|
|
77
|
+
* description: Store revenue
|
|
78
|
+
* templateId:
|
|
79
|
+
* type: number
|
|
80
|
+
* default: 1
|
|
81
|
+
* description: Template identifier
|
|
82
|
+
* activated:
|
|
83
|
+
* type: boolean
|
|
84
|
+
* default: false
|
|
85
|
+
* description: Whether the store is activated
|
|
86
|
+
* subscriptionId:
|
|
87
|
+
* type: string
|
|
88
|
+
* description: Reference to subscription
|
|
89
|
+
* createdAt:
|
|
90
|
+
* type: string
|
|
91
|
+
* format: date-time
|
|
92
|
+
* updatedAt:
|
|
93
|
+
* type: string
|
|
94
|
+
* format: date-time
|
|
95
|
+
* example:
|
|
96
|
+
* id: "507f1f77bcf86cd799439011"
|
|
97
|
+
* name: "Tech Store"
|
|
98
|
+
* sellerId: "507f1f77bcf86cd799439012"
|
|
99
|
+
* description: "Electronics and gadgets store"
|
|
100
|
+
* image: "store-image.jpg"
|
|
101
|
+
* isActive: true
|
|
102
|
+
* ratingCount: 150
|
|
103
|
+
* ratingSum: 735
|
|
104
|
+
* revenue: 25000
|
|
105
|
+
* activated: true
|
|
106
|
+
* createdAt: "2025-11-01T10:30:00.000Z"
|
|
107
|
+
* updatedAt: "2025-12-01T15:45:00.000Z"
|
|
108
|
+
*/
|
|
7
109
|
const storeSchema = new mongoose.Schema(
|
|
8
110
|
{
|
|
9
111
|
name: {
|
package/models/StoreCategory.js
CHANGED
|
@@ -1,13 +1,44 @@
|
|
|
1
1
|
const mongoose = require('mongoose');
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* @swagger
|
|
5
|
+
* components:
|
|
6
|
+
* schemas:
|
|
7
|
+
* StoreCategory:
|
|
8
|
+
* type: object
|
|
9
|
+
* required:
|
|
10
|
+
* - name
|
|
11
|
+
* properties:
|
|
12
|
+
* id:
|
|
13
|
+
* type: string
|
|
14
|
+
* description: The store category identifier
|
|
15
|
+
* name:
|
|
16
|
+
* type: string
|
|
17
|
+
* description: Store category name
|
|
18
|
+
* confirmed:
|
|
19
|
+
* type: boolean
|
|
20
|
+
* default: false
|
|
21
|
+
* description: Whether the category is confirmed
|
|
22
|
+
* createdAt:
|
|
23
|
+
* type: string
|
|
24
|
+
* format: date-time
|
|
25
|
+
* updatedAt:
|
|
26
|
+
* type: string
|
|
27
|
+
* format: date-time
|
|
28
|
+
* example:
|
|
29
|
+
* id: "507f1f77bcf86cd799439011"
|
|
30
|
+
* name: "Grocery Store"
|
|
31
|
+
* confirmed: true
|
|
32
|
+
* createdAt: "2025-11-01T10:30:00.000Z"
|
|
33
|
+
* updatedAt: "2025-12-01T15:45:00.000Z"
|
|
34
|
+
*/
|
|
3
35
|
const storeCategorySchema = new mongoose.Schema(
|
|
4
36
|
{
|
|
5
37
|
name: {
|
|
6
38
|
type: String,
|
|
7
|
-
required: true
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
confirmed : { type : Boolean , default : false } ,
|
|
39
|
+
required: true
|
|
40
|
+
},
|
|
41
|
+
confirmed: { type: Boolean, default: false }
|
|
11
42
|
},
|
|
12
43
|
{ timestamps: true, toJSON: { virtuals: true } }
|
|
13
44
|
);
|
package/models/StoreRate.js
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
const mongoose = require('mongoose');
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* @swagger
|
|
5
|
+
* components:
|
|
6
|
+
* schemas:
|
|
7
|
+
* StoreRate:
|
|
8
|
+
* type: object
|
|
9
|
+
* required:
|
|
10
|
+
* - userId
|
|
11
|
+
* - storeId
|
|
12
|
+
* properties:
|
|
13
|
+
* id:
|
|
14
|
+
* type: string
|
|
15
|
+
* description: The store rate identifier
|
|
16
|
+
* userId:
|
|
17
|
+
* type: string
|
|
18
|
+
* description: Reference to the user
|
|
19
|
+
* storeId:
|
|
20
|
+
* type: string
|
|
21
|
+
* description: Reference to the store
|
|
22
|
+
* rate:
|
|
23
|
+
* type: number
|
|
24
|
+
* default: 0
|
|
25
|
+
* description: Rating value
|
|
26
|
+
* example:
|
|
27
|
+
* id: "507f1f77bcf86cd799439011"
|
|
28
|
+
* userId: "507f1f77bcf86cd799439012"
|
|
29
|
+
* storeId: "507f1f77bcf86cd799439013"
|
|
30
|
+
* rate: 4.5
|
|
31
|
+
*/
|
|
3
32
|
const storeRateSchema = new mongoose.Schema(
|
|
4
33
|
{
|
|
5
34
|
userId: {
|
|
@@ -10,12 +39,12 @@ const storeRateSchema = new mongoose.Schema(
|
|
|
10
39
|
storeId: {
|
|
11
40
|
type: mongoose.Schema.Types.ObjectId,
|
|
12
41
|
required: true,
|
|
13
|
-
ref: 'User'
|
|
42
|
+
ref: 'User'
|
|
14
43
|
},
|
|
15
44
|
rate: {
|
|
16
45
|
type: Number,
|
|
17
|
-
default: 0
|
|
18
|
-
}
|
|
46
|
+
default: 0
|
|
47
|
+
}
|
|
19
48
|
},
|
|
20
49
|
{ toJSON: { virtuals: true } }
|
|
21
50
|
);
|
package/models/Subscription.js
CHANGED
|
@@ -1,5 +1,68 @@
|
|
|
1
1
|
const mongoose = require('mongoose');
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* @swagger
|
|
5
|
+
* components:
|
|
6
|
+
* schemas:
|
|
7
|
+
* Subscription:
|
|
8
|
+
* type: object
|
|
9
|
+
* required:
|
|
10
|
+
* - storeId
|
|
11
|
+
* - paymentAmount
|
|
12
|
+
* - startDate
|
|
13
|
+
* - endDate
|
|
14
|
+
* properties:
|
|
15
|
+
* id:
|
|
16
|
+
* type: string
|
|
17
|
+
* description: The subscription identifier
|
|
18
|
+
* paymentManagerId:
|
|
19
|
+
* type: string
|
|
20
|
+
* description: Reference to the payment manager
|
|
21
|
+
* storeId:
|
|
22
|
+
* type: string
|
|
23
|
+
* description: Reference to the store
|
|
24
|
+
* planId:
|
|
25
|
+
* type: string
|
|
26
|
+
* description: Reference to the plan
|
|
27
|
+
* subscriptionOfferId:
|
|
28
|
+
* type: string
|
|
29
|
+
* description: Reference to subscription offer
|
|
30
|
+
* paymentAmount:
|
|
31
|
+
* type: number
|
|
32
|
+
* description: Payment amount
|
|
33
|
+
* paymentTypeId:
|
|
34
|
+
* type: string
|
|
35
|
+
* description: Reference to payment type
|
|
36
|
+
* reductionOfferId:
|
|
37
|
+
* type: string
|
|
38
|
+
* description: Reference to reduction offer
|
|
39
|
+
* status:
|
|
40
|
+
* type: string
|
|
41
|
+
* enum: [inactive, active, delayed, suspended, upcoming, deleted]
|
|
42
|
+
* default: inactive
|
|
43
|
+
* description: Subscription status
|
|
44
|
+
* startDate:
|
|
45
|
+
* type: string
|
|
46
|
+
* format: date-time
|
|
47
|
+
* description: Subscription start date
|
|
48
|
+
* endDate:
|
|
49
|
+
* type: string
|
|
50
|
+
* format: date-time
|
|
51
|
+
* description: Subscription end date
|
|
52
|
+
* notes:
|
|
53
|
+
* type: array
|
|
54
|
+
* items:
|
|
55
|
+
* type: string
|
|
56
|
+
* description: Notes about the subscription
|
|
57
|
+
* example:
|
|
58
|
+
* id: "507f1f77bcf86cd799439011"
|
|
59
|
+
* storeId: "507f1f77bcf86cd799439012"
|
|
60
|
+
* planId: "507f1f77bcf86cd799439013"
|
|
61
|
+
* paymentAmount: 99.99
|
|
62
|
+
* status: "active"
|
|
63
|
+
* startDate: "2025-12-01T00:00:00.000Z"
|
|
64
|
+
* endDate: "2026-12-01T00:00:00.000Z"
|
|
65
|
+
*/
|
|
3
66
|
const subscriptionSchema = new mongoose.Schema(
|
|
4
67
|
{
|
|
5
68
|
paymentManagerId: {
|
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
const mongoose = require('mongoose');
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* @swagger
|
|
5
|
+
* components:
|
|
6
|
+
* schemas:
|
|
7
|
+
* SubscriptionOffer:
|
|
8
|
+
* type: object
|
|
9
|
+
* required:
|
|
10
|
+
* - discount
|
|
11
|
+
* properties:
|
|
12
|
+
* id:
|
|
13
|
+
* type: string
|
|
14
|
+
* description: The subscription offer identifier
|
|
15
|
+
* discount:
|
|
16
|
+
* type: number
|
|
17
|
+
* description: Discount amount or percentage
|
|
18
|
+
* isActive:
|
|
19
|
+
* type: boolean
|
|
20
|
+
* default: false
|
|
21
|
+
* description: Whether the offer is active
|
|
22
|
+
* createdAt:
|
|
23
|
+
* type: string
|
|
24
|
+
* format: date-time
|
|
25
|
+
* updatedAt:
|
|
26
|
+
* type: string
|
|
27
|
+
* format: date-time
|
|
28
|
+
* example:
|
|
29
|
+
* id: "507f1f77bcf86cd799439011"
|
|
30
|
+
* discount: 20
|
|
31
|
+
* isActive: true
|
|
32
|
+
* createdAt: "2025-11-01T10:30:00.000Z"
|
|
33
|
+
* updatedAt: "2025-12-01T15:45:00.000Z"
|
|
34
|
+
*/
|
|
3
35
|
const subscriptionOfferSchema = new mongoose.Schema(
|
|
4
36
|
{
|
|
5
37
|
discount: {
|