@b2y/ecommerce-common 1.0.0 → 1.0.1
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/.idea/ecommerce-common.iml +12 -0
- package/.idea/modules.xml +8 -0
- package/.idea/vcs.xml +6 -0
- package/dbconnection/Connect.js +1 -0
- package/enum/EntityTypeEnum.js +3 -1
- package/model/TenantSettings.js +48 -0
- package/package.json +5 -5
- package/utility/QueryUtil.js +40 -21
- package/utility/Razorpay.js +1 -2
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<module type="WEB_MODULE" version="4">
|
|
3
|
+
<component name="NewModuleRootManager">
|
|
4
|
+
<content url="file://$MODULE_DIR$">
|
|
5
|
+
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
|
6
|
+
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
|
7
|
+
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
|
8
|
+
</content>
|
|
9
|
+
<orderEntry type="inheritedJdk" />
|
|
10
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
|
11
|
+
</component>
|
|
12
|
+
</module>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="ProjectModuleManager">
|
|
4
|
+
<modules>
|
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/ecommerce-common.iml" filepath="$PROJECT_DIR$/.idea/ecommerce-common.iml" />
|
|
6
|
+
</modules>
|
|
7
|
+
</component>
|
|
8
|
+
</project>
|
package/.idea/vcs.xml
ADDED
package/dbconnection/Connect.js
CHANGED
package/enum/EntityTypeEnum.js
CHANGED
|
@@ -4,7 +4,9 @@ const EntityTypeEnum = Object.freeze({
|
|
|
4
4
|
CATEGORY: "Category",
|
|
5
5
|
PRODUCT_VARIANT: "ProductVariant",
|
|
6
6
|
BANNER: "Banner",
|
|
7
|
-
FEEDBACK:"Feedback"
|
|
7
|
+
FEEDBACK:"Feedback",
|
|
8
|
+
NOTIFICATION: 'Notification',
|
|
9
|
+
TENANT_SETTINGS: 'TenantSettings',
|
|
8
10
|
});
|
|
9
11
|
|
|
10
12
|
module.exports = EntityTypeEnum;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
const { DataTypes } = require('sequelize');
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
module.exports = (sequelize) => {
|
|
5
|
+
return sequelize.define('TenantSettings', {
|
|
6
|
+
TenantSettingID: {
|
|
7
|
+
type: DataTypes.UUID,
|
|
8
|
+
primaryKey: true,
|
|
9
|
+
allowNull: false,
|
|
10
|
+
defaultValue: DataTypes.UUIDV4
|
|
11
|
+
},
|
|
12
|
+
TenantID: {
|
|
13
|
+
type: DataTypes.UUID,
|
|
14
|
+
allowNull: false,
|
|
15
|
+
references: {
|
|
16
|
+
model: 'Tenant',
|
|
17
|
+
key: 'TenantID'
|
|
18
|
+
},
|
|
19
|
+
onDelete: 'CASCADE',
|
|
20
|
+
onUpdate: 'CASCADE'
|
|
21
|
+
},
|
|
22
|
+
ThemeColour:{
|
|
23
|
+
type:DataTypes.STRING,
|
|
24
|
+
allowNull: true
|
|
25
|
+
},
|
|
26
|
+
CreatedBy: {
|
|
27
|
+
type: DataTypes.UUID,
|
|
28
|
+
allowNull: false
|
|
29
|
+
},
|
|
30
|
+
CreatedAt: {
|
|
31
|
+
type: DataTypes.DATE,
|
|
32
|
+
allowNull: false,
|
|
33
|
+
defaultValue: DataTypes.NOW
|
|
34
|
+
},
|
|
35
|
+
UpdatedBy: {
|
|
36
|
+
type: DataTypes.UUID,
|
|
37
|
+
allowNull: false
|
|
38
|
+
},
|
|
39
|
+
UpdatedAt: {
|
|
40
|
+
type: DataTypes.DATE,
|
|
41
|
+
allowNull: false,
|
|
42
|
+
defaultValue: DataTypes.NOW
|
|
43
|
+
}
|
|
44
|
+
}, {
|
|
45
|
+
tableName: 'TenantSettings',
|
|
46
|
+
timestamps: false
|
|
47
|
+
});
|
|
48
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@b2y/ecommerce-common",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "E-commerce common library",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
"type": "git",
|
|
11
11
|
"url": "git+https://github.com/yuvakrishna29/ecommerce-common.git"
|
|
12
12
|
},
|
|
13
|
-
"publishConfig": {
|
|
14
|
-
|
|
13
|
+
"publishConfig": {
|
|
14
|
+
"access": "public"
|
|
15
15
|
},
|
|
16
16
|
"author": "Shikha",
|
|
17
17
|
"license": "ISC",
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
"url": "https://github.com/yuvakrishna29/ecommerce-common/issues"
|
|
20
20
|
},
|
|
21
21
|
"homepage": "https://github.com/yuvakrishna29/ecommerce-common#readme",
|
|
22
|
-
"
|
|
22
|
+
"peerDependencies": {
|
|
23
23
|
"exceljs": "^4.4.0",
|
|
24
24
|
"luxon": "^3.7.2",
|
|
25
|
-
"
|
|
25
|
+
"sequelize": "^6.37.5"
|
|
26
26
|
}
|
|
27
27
|
}
|
package/utility/QueryUtil.js
CHANGED
|
@@ -5,8 +5,20 @@ const DateUtil = require('../utility/DateUtil');
|
|
|
5
5
|
const PaymentStatusEnum = require('../enum/PaymentStatusEnum');
|
|
6
6
|
const PaymentTypeEnum = require('../enum/PaymentTypeEnum');
|
|
7
7
|
const PaymentMethodEnum = require('../enum/PaymentMethodEnum');
|
|
8
|
+
const {Sequelize} = require('sequelize');
|
|
8
9
|
class QueryUtil {
|
|
9
|
-
static
|
|
10
|
+
static parseId(idParam) {
|
|
11
|
+
if (!idParam) return null;
|
|
12
|
+
if (Array.isArray(idParam))
|
|
13
|
+
return idParam.map((id) => id.toString().trim()).filter((id) => id);
|
|
14
|
+
return idParam
|
|
15
|
+
.toString()
|
|
16
|
+
.split(",")
|
|
17
|
+
.map((id) => id.trim())
|
|
18
|
+
.filter((id) => id);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
static storeWhereClause(filters, tenantID, logger) {
|
|
10
22
|
const { startDate, endDate, IsActive, searchText } = filters;
|
|
11
23
|
let storeWhereClause = {};
|
|
12
24
|
// Date range filter
|
|
@@ -48,10 +60,11 @@ class QueryUtil {
|
|
|
48
60
|
|
|
49
61
|
return storeWhereClause;
|
|
50
62
|
}
|
|
51
|
-
static orderWhereClause(filters, tenantID,
|
|
52
|
-
const { startDate, endDate, searchText, paymentStatus } = filters;
|
|
63
|
+
static orderWhereClause(filters, tenantID, logger) {
|
|
64
|
+
const { startDate, endDate, searchText, paymentStatus, storeId } = filters;
|
|
53
65
|
let orderWhereClause = {};
|
|
54
66
|
let paymentStatusWhere = {};
|
|
67
|
+
let storeWhereClause = {};
|
|
55
68
|
if (tenantID) orderWhereClause.TenantID = tenantID;
|
|
56
69
|
if (startDate && !DateUtil.isValidDate(startDate)) {
|
|
57
70
|
logger.warn("invalid start date");
|
|
@@ -75,6 +88,10 @@ class QueryUtil {
|
|
|
75
88
|
}
|
|
76
89
|
paymentStatusWhere.PaymentStatusName = paymentStatus;
|
|
77
90
|
}
|
|
91
|
+
if(storeId) {
|
|
92
|
+
const storeIDs = this.parseId(storeId);
|
|
93
|
+
storeWhereClause.StoreID = {[Sequelize.Op.in] : storeIDs}
|
|
94
|
+
}
|
|
78
95
|
if (startDate && endDate) {
|
|
79
96
|
orderWhereClause.OrderDate = {
|
|
80
97
|
[Sequelize.Op.between]: [new Date(startDate), new Date(endDate)],
|
|
@@ -84,14 +101,15 @@ class QueryUtil {
|
|
|
84
101
|
} else if (endDate) {
|
|
85
102
|
orderWhereClause.OrderDate = { [Sequelize.Op.lte]: new Date(endDate) };
|
|
86
103
|
}
|
|
87
|
-
return { orderWhereClause, includeWhere: { paymentStatusWhere } };
|
|
104
|
+
return { orderWhereClause, includeWhere: { paymentStatusWhere, storeWhereClause } };
|
|
88
105
|
}
|
|
89
|
-
static paymentWhereClause(filters, tenantID,
|
|
106
|
+
static paymentWhereClause(filters, tenantID, logger) {
|
|
90
107
|
const {
|
|
91
108
|
paymentStatus,
|
|
92
109
|
searchText,
|
|
93
110
|
paymentType,
|
|
94
111
|
paymentMethod,
|
|
112
|
+
storeId,
|
|
95
113
|
startDate,
|
|
96
114
|
endDate,
|
|
97
115
|
} = filters;
|
|
@@ -99,6 +117,7 @@ class QueryUtil {
|
|
|
99
117
|
let paymentStatusWhere = {};
|
|
100
118
|
let paymentTypeWhere = {};
|
|
101
119
|
let paymentMethodWhere = {};
|
|
120
|
+
let storeWhereClause = {};
|
|
102
121
|
if (tenantID) paymentWhereClause.TenantID = tenantID;
|
|
103
122
|
if (startDate && !DateUtil.isValidDate(startDate)) {
|
|
104
123
|
logger.warn("invalid start date");
|
|
@@ -138,6 +157,10 @@ class QueryUtil {
|
|
|
138
157
|
}
|
|
139
158
|
paymentMethodWhere.PaymentMethodName = paymentMethod;
|
|
140
159
|
}
|
|
160
|
+
if(storeId) {
|
|
161
|
+
const storeIDs = this.parseId(storeId);
|
|
162
|
+
storeWhereClause.StoreID = {[Sequelize.Op.in]: storeIDs}
|
|
163
|
+
}
|
|
141
164
|
if (startDate && endDate) {
|
|
142
165
|
paymentWhereClause.PaymentDate = {
|
|
143
166
|
[Sequelize.Op.between]: [new Date(startDate), new Date(endDate)],
|
|
@@ -153,10 +176,11 @@ class QueryUtil {
|
|
|
153
176
|
paymentStatusWhere,
|
|
154
177
|
paymentMethodWhere,
|
|
155
178
|
paymentTypeWhere,
|
|
179
|
+
storeWhereClause
|
|
156
180
|
},
|
|
157
181
|
};
|
|
158
182
|
}
|
|
159
|
-
static customerWhereClause(filters, tenantID,
|
|
183
|
+
static customerWhereClause(filters, tenantID, logger) {
|
|
160
184
|
const { searchText, startDate, endDate } = filters;
|
|
161
185
|
let customerWhereClause = {};
|
|
162
186
|
if (startDate && !DateUtil.isValidDate(startDate)) {
|
|
@@ -185,22 +209,13 @@ class QueryUtil {
|
|
|
185
209
|
}
|
|
186
210
|
return customerWhereClause;
|
|
187
211
|
}
|
|
188
|
-
static productWhereClause(filters, tenantID,
|
|
189
|
-
const { brandId, categoryId, IsActive, searchText, startDate, endDate } =
|
|
212
|
+
static productWhereClause(filters, tenantID, logger) {
|
|
213
|
+
const { brandId, categoryId, storeId, IsActive, searchText, startDate, endDate } =
|
|
190
214
|
filters;
|
|
191
215
|
const brandWhere = {};
|
|
192
216
|
const categoryWhere = {};
|
|
217
|
+
const storeWhere = {};
|
|
193
218
|
const productWhereClause = {};
|
|
194
|
-
const parseIds = (idParam) => {
|
|
195
|
-
if (!idParam) return null;
|
|
196
|
-
if (Array.isArray(idParam))
|
|
197
|
-
return idParam.map((id) => id.toString().trim()).filter((id) => id);
|
|
198
|
-
return idParam
|
|
199
|
-
.toString()
|
|
200
|
-
.split(",")
|
|
201
|
-
.map((id) => id.trim())
|
|
202
|
-
.filter((id) => id);
|
|
203
|
-
};
|
|
204
219
|
if (tenantID) {
|
|
205
220
|
productWhereClause.TenantID = tenantID;
|
|
206
221
|
brandWhere.TenantID = tenantID;
|
|
@@ -238,16 +253,20 @@ class QueryUtil {
|
|
|
238
253
|
productWhereClause.IsActive = isActiveValue;
|
|
239
254
|
}
|
|
240
255
|
if (brandId) {
|
|
241
|
-
const brandIds =
|
|
256
|
+
const brandIds = this.parseId(brandId);
|
|
242
257
|
brandWhere.BrandID = { [Sequelize.Op.in]: brandIds };
|
|
243
258
|
}
|
|
244
259
|
if (categoryId) {
|
|
245
|
-
const categoryIds =
|
|
260
|
+
const categoryIds = this.parseId(categoryId);
|
|
246
261
|
categoryWhere.CategoryID = { [Sequelize.Op.in]: categoryIds };
|
|
247
262
|
}
|
|
263
|
+
if(storeId) {
|
|
264
|
+
const storeIds = this.parseId(storeId);
|
|
265
|
+
storeWhere.StoreID = { [Sequelize.Op.in]: storeIds };
|
|
266
|
+
}
|
|
248
267
|
return {
|
|
249
268
|
productWhereClause,
|
|
250
|
-
includeWhere: { brandWhere, categoryWhere },
|
|
269
|
+
includeWhere: { brandWhere, categoryWhere, storeWhere },
|
|
251
270
|
};
|
|
252
271
|
}
|
|
253
272
|
|
package/utility/Razorpay.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
const Razorpay = require('razorpay');
|
|
2
1
|
const crypto = require('crypto');
|
|
3
2
|
const StatusMessage = require('../constants/StatusMessageConstants');
|
|
4
3
|
class RazorpayUtil {
|
|
5
|
-
constructor(razorpayKeys, logger) {
|
|
4
|
+
constructor(razorpayKeys, logger, Razorpay) {
|
|
6
5
|
this.logger = logger;
|
|
7
6
|
this.instance = new Razorpay({
|
|
8
7
|
key_id: razorpayKeys.keyId,
|