@b2y/ecommerce-common 1.0.8 → 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/constants/AppConstants.js +4 -1
- package/enum/AccessModeEnum.js +2 -1
- package/model/SubscriptionPlan.js +5 -0
- package/model/TenantSubscription.js +11 -5
- package/package.json +1 -1
- package/utility/OrderTimeFilterUtil.js +1 -0
- package/utility/QueryUtil.js +1 -1
- package/utility/ResolveAccessMode.js +27 -13
package/enum/AccessModeEnum.js
CHANGED
|
@@ -31,6 +31,11 @@ module.exports = (sequelize) => {
|
|
|
31
31
|
type: DataTypes.STRING(10),
|
|
32
32
|
allowNull: false,
|
|
33
33
|
},
|
|
34
|
+
TrialPeriodDays: {
|
|
35
|
+
type: DataTypes.INTEGER,
|
|
36
|
+
allowNull: false,
|
|
37
|
+
defaultValue: 0
|
|
38
|
+
},
|
|
34
39
|
IsActive: {
|
|
35
40
|
type: DataTypes.BOOLEAN,
|
|
36
41
|
defaultValue: true,
|
|
@@ -24,22 +24,28 @@ module.exports = (sequelize) => {
|
|
|
24
24
|
},
|
|
25
25
|
StartDate: {
|
|
26
26
|
type: DataTypes.DATE,
|
|
27
|
-
allowNull: false
|
|
28
|
-
defaultValue: DataTypes.NOW,
|
|
27
|
+
allowNull: false
|
|
29
28
|
},
|
|
30
29
|
EndDate: {
|
|
31
30
|
type: DataTypes.DATE,
|
|
32
31
|
allowNull: false,
|
|
33
|
-
defaultValue: DataTypes.NOW,
|
|
34
32
|
},
|
|
35
33
|
GraceEndDate: {
|
|
36
34
|
type: DataTypes.DATE,
|
|
35
|
+
allowNull: true,
|
|
36
|
+
},
|
|
37
|
+
TrialEndDate: {
|
|
38
|
+
type: DataTypes.DATE,
|
|
39
|
+
allowNull: true
|
|
40
|
+
},
|
|
41
|
+
IsTrial: {
|
|
42
|
+
type: DataTypes.BOOLEAN,
|
|
37
43
|
allowNull: false,
|
|
38
|
-
defaultValue:
|
|
44
|
+
defaultValue: false
|
|
39
45
|
},
|
|
40
46
|
AutoRenew: {
|
|
41
47
|
type: DataTypes.BOOLEAN,
|
|
42
|
-
defaultValue:
|
|
48
|
+
defaultValue: false,
|
|
43
49
|
},
|
|
44
50
|
CreatedBy: {
|
|
45
51
|
type: DataTypes.UUID,
|
package/package.json
CHANGED
package/utility/QueryUtil.js
CHANGED
|
@@ -51,7 +51,7 @@ class QueryUtil {
|
|
|
51
51
|
{ StoreName: { [Sequelize.Op.iLike]: `%${searchText}%` } },
|
|
52
52
|
{ AddressLine1: { [Sequelize.Op.iLike]: `%${searchText}%` } },
|
|
53
53
|
{ AddressLine2: { [Sequelize.Op.iLike]: `%${searchText}%` } },
|
|
54
|
-
{
|
|
54
|
+
{ CityName: { [Sequelize.Op.iLike]: `%${searchText}%` } },
|
|
55
55
|
];
|
|
56
56
|
}
|
|
57
57
|
|
|
@@ -5,21 +5,35 @@ function ResolveAccessMode(subscription) {
|
|
|
5
5
|
|
|
6
6
|
if (!subscription) return AccessModeEnum.BLOCKED;
|
|
7
7
|
|
|
8
|
-
if (
|
|
8
|
+
if ([SubscriptionStatusEnum.CANCELLED, SubscriptionStatusEnum.EXPIRED, SubscriptionStatusEnum.SUSPENDED].includes(subscription.Status)) {
|
|
9
9
|
return AccessModeEnum.BLOCKED;
|
|
10
10
|
}
|
|
11
|
-
|
|
12
|
-
if (
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
11
|
+
|
|
12
|
+
if (subscription.Status === SubscriptionStatusEnum.ACTIVE) {
|
|
13
|
+
if (subscription.IsTrial === true) {
|
|
14
|
+
const trialEndDate = subscription.TrialEndDate
|
|
15
|
+
? new Date(subscription.TrialEndDate)
|
|
16
|
+
: null;
|
|
17
|
+
if (trialEndDate && now < trialEndDate) {
|
|
18
|
+
return AccessModeEnum.FULL;
|
|
19
|
+
}
|
|
20
|
+
return AccessModeEnum.PAYMENT_REQUIRED;
|
|
21
|
+
}
|
|
22
|
+
const endDate = new Date(subscription.EndDate);
|
|
23
|
+
const graceEndDate = subscription.GraceEndDate
|
|
24
|
+
? new Date(subscription.GraceEndDate)
|
|
25
|
+
: null;
|
|
26
|
+
// Still in the paid period
|
|
27
|
+
if (now < endDate) {
|
|
28
|
+
return AccessModeEnum.FULL;
|
|
29
|
+
}
|
|
30
|
+
// Past EndDate, but within Grace Period
|
|
31
|
+
if (graceEndDate && now <= graceEndDate) {
|
|
32
|
+
return AccessModeEnum.READ_ONLY;
|
|
33
|
+
}
|
|
34
|
+
// Past both EndDate and Grace Period
|
|
35
|
+
return AccessModeEnum.BLOCKED;
|
|
36
|
+
}
|
|
23
37
|
return AccessModeEnum.BLOCKED;
|
|
24
38
|
};
|
|
25
39
|
module.exports = ResolveAccessMode;
|