@chevre/domain 22.9.0-alpha.96 → 22.9.0-alpha.98
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/example/src/chevre/playAroundAdvanceBookingRequirement.ts +1 -0
- package/example/src/chevre/reIndex.ts +1 -1
- package/example/src/moment.ts +19 -18
- package/lib/chevre/repo/aggregateOffer.d.ts +2 -14
- package/lib/chevre/repo/aggregateOffer.js +94 -124
- package/lib/chevre/repo/mongoose/schemas/aggregateOffer.js +9 -3
- package/lib/chevre/repo/offer.d.ts +1 -3
- package/lib/chevre/repo/offer.js +6 -392
- package/lib/chevre/service/assetTransaction/reserve/start/createSubReservations.js +14 -3
- package/lib/chevre/service/payment/movieTicket/refundMovieTicket.js +0 -2
- package/package.json +1 -1
- package/example/src/chevre/optimizeOffers.ts +0 -16
|
@@ -33,6 +33,7 @@ async function main() {
|
|
|
33
33
|
identifier: 'sampleRequirement',
|
|
34
34
|
project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
|
|
35
35
|
typeOf: 'QuantitativeValue',
|
|
36
|
+
unitCode: chevre.factory.unitCode.Day,
|
|
36
37
|
// maxValue: 3,
|
|
37
38
|
$unset: { maxValue: 1 }
|
|
38
39
|
}
|
|
@@ -11,7 +11,7 @@ mongoose.Model.on('index', (...args) => {
|
|
|
11
11
|
async function main() {
|
|
12
12
|
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
13
13
|
|
|
14
|
-
await chevre.repository.
|
|
14
|
+
await chevre.repository.AggregateOffer.createInstance(mongoose.connection);
|
|
15
15
|
console.log('success!');
|
|
16
16
|
}
|
|
17
17
|
|
package/example/src/moment.ts
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
// tslint:disable:no-console
|
|
2
|
-
import * as moment from 'moment
|
|
2
|
+
import * as moment from 'moment';
|
|
3
3
|
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
.startOf('day');
|
|
9
|
-
const targetImportThrough = moment(importThrough)
|
|
10
|
-
.tz('Asia/Tokyo')
|
|
11
|
-
.endOf('day');
|
|
12
|
-
console.log(targetImportFrom.toDate(), targetImportThrough.toDate());
|
|
4
|
+
const eventStartDate = '2025-04-10T01:00:00Z';
|
|
5
|
+
// const timeFormat = 'HH:mm:ssZ';
|
|
6
|
+
const time = '00:00:00+09:00';
|
|
7
|
+
// const time = '00:00:00Z';
|
|
13
8
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
9
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
10
|
+
const offset = time.slice(8);
|
|
11
|
+
console.log('offset:', offset);
|
|
12
|
+
|
|
13
|
+
// const opensMoment = moment(time, timeFormat, true);
|
|
14
|
+
// const utcOffset = opensMoment.utcOffset();
|
|
15
|
+
|
|
16
|
+
// const eventStartDateMoment = moment.utc(eventStartDate);
|
|
17
|
+
const eventStartDateMoment = moment(eventStartDate, true);
|
|
18
|
+
console.log(eventStartDateMoment);
|
|
19
|
+
console.log(eventStartDateMoment.utcOffset(offset));
|
|
20
|
+
|
|
21
|
+
const usageDate = moment(`${eventStartDateMoment.format('YYYY-MM-DD')}T${time}`, true);
|
|
22
|
+
console.log(usageDate);
|
|
@@ -5,25 +5,17 @@ type KeyOfUnitPriceOffer = keyof factory.unitPriceOffer.IUnitPriceOffer;
|
|
|
5
5
|
type IProjection = {
|
|
6
6
|
[key in KeyOfUnitPriceOffer]?: 0 | 1;
|
|
7
7
|
};
|
|
8
|
-
export type IUnitPriceOfferFromAggregateOffer = factory.unitPriceOffer.IUnitPriceOffer & {
|
|
9
|
-
offerIndex?: number;
|
|
10
|
-
parentOffer?: {
|
|
11
|
-
id: string;
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
type ISearchConditions = factory.unitPriceOffer.ISearchConditions;
|
|
15
8
|
/**
|
|
16
9
|
* 集計オファーリポジトリ
|
|
17
10
|
*/
|
|
18
11
|
export declare class AggregateOfferRepo {
|
|
19
12
|
private readonly aggregateOfferModel;
|
|
20
13
|
constructor(connection: Connection);
|
|
21
|
-
static
|
|
14
|
+
static CREATE_MATCH_STAGE(params: Omit<factory.unitPriceOffer.ISearchConditions, 'limit' | 'page' | 'sort'>): IMatchStage[];
|
|
22
15
|
static CREATE_AGGREGATE_OFFERS_PROJECTION(params: IProjection): {
|
|
23
16
|
[field: string]: AnyExpression;
|
|
24
17
|
};
|
|
25
|
-
|
|
26
|
-
search(params: ISearchConditions, projection?: IProjection): Promise<factory.aggregateOffer.IAggregateOffer[]>;
|
|
18
|
+
search(params: factory.unitPriceOffer.ISearchConditions, projection?: IProjection): Promise<factory.aggregateOffer.IAggregateOffer[]>;
|
|
27
19
|
pushIncludedInDataCatalog(params: {
|
|
28
20
|
project: {
|
|
29
21
|
id: string;
|
|
@@ -65,10 +57,6 @@ export declare class AggregateOfferRepo {
|
|
|
65
57
|
};
|
|
66
58
|
id: string;
|
|
67
59
|
}): Promise<void>;
|
|
68
|
-
/**
|
|
69
|
-
* 単価オファー最適化作業における一時的な処理
|
|
70
|
-
*/
|
|
71
|
-
optimizeOffers(): Promise<import("mongoose").UpdateWriteOpResult>;
|
|
72
60
|
unsetUnnecessaryFields(params: {
|
|
73
61
|
filter: FilterQuery<factory.aggregateOffer.IAggregateOffer>;
|
|
74
62
|
$unset: any;
|
|
@@ -21,125 +21,91 @@ class AggregateOfferRepo {
|
|
|
21
21
|
this.aggregateOfferModel = connection.model(aggregateOffer_1.modelName, (0, aggregateOffer_1.createSchema)());
|
|
22
22
|
}
|
|
23
23
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
24
|
-
static
|
|
25
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44;
|
|
24
|
+
static CREATE_MATCH_STAGE(params) {
|
|
25
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50;
|
|
26
26
|
const matchStages = [];
|
|
27
27
|
const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
28
28
|
if (typeof projectIdEq === 'string') {
|
|
29
29
|
matchStages.push({
|
|
30
|
-
$match: {
|
|
31
|
-
'project.id': { $eq: projectIdEq }
|
|
32
|
-
}
|
|
30
|
+
$match: { 'project.id': { $eq: projectIdEq } }
|
|
33
31
|
});
|
|
34
32
|
}
|
|
35
|
-
const
|
|
33
|
+
const parentOfferIdIn = (_d = (_c = params.parentOffer) === null || _c === void 0 ? void 0 : _c.id) === null || _d === void 0 ? void 0 : _d.$in;
|
|
34
|
+
if (Array.isArray(parentOfferIdIn)) {
|
|
35
|
+
matchStages.push({ $match: { _id: { $in: parentOfferIdIn } } });
|
|
36
|
+
}
|
|
37
|
+
// aggregateOffer.includedInDataCatalogで検索する(2023-09-21~)
|
|
38
|
+
const includedInDataCatalogIdIn = (_f = (_e = params.includedInDataCatalog) === null || _e === void 0 ? void 0 : _e.id) === null || _f === void 0 ? void 0 : _f.$in;
|
|
39
|
+
if (Array.isArray(includedInDataCatalogIdIn)) {
|
|
40
|
+
matchStages.push({ $match: { 'includedInDataCatalog.id': { $exists: true, $in: includedInDataCatalogIdIn } } });
|
|
41
|
+
}
|
|
42
|
+
const idEq = (_g = params.id) === null || _g === void 0 ? void 0 : _g.$eq;
|
|
36
43
|
if (typeof idEq === 'string') {
|
|
37
44
|
matchStages.push({
|
|
38
|
-
$match: {
|
|
39
|
-
// 'offers.id': { $eq: idEq }
|
|
40
|
-
_id: { $eq: idEq } // _idに変更(2023-12-22~)
|
|
41
|
-
}
|
|
45
|
+
$match: { _id: { $eq: idEq } } // _idに変更(2023-12-22~)
|
|
42
46
|
});
|
|
43
47
|
}
|
|
44
|
-
const idIn = (
|
|
48
|
+
const idIn = (_h = params.id) === null || _h === void 0 ? void 0 : _h.$in;
|
|
45
49
|
if (Array.isArray(idIn)) {
|
|
46
50
|
matchStages.push({
|
|
47
|
-
$match: {
|
|
48
|
-
// 'offers.id': { $in: idIn }
|
|
49
|
-
_id: { $in: idIn } // _idに変更(2023-12-22~)
|
|
50
|
-
}
|
|
51
|
+
$match: { _id: { $in: idIn } } // _idに変更(2023-12-22~)
|
|
51
52
|
});
|
|
52
53
|
}
|
|
53
|
-
const identifierEq = (
|
|
54
|
+
const identifierEq = (_j = params.identifier) === null || _j === void 0 ? void 0 : _j.$eq;
|
|
54
55
|
if (typeof identifierEq === 'string') {
|
|
55
56
|
matchStages.push({
|
|
56
57
|
$match: {
|
|
57
|
-
'offers.identifier': {
|
|
58
|
-
$exists: true,
|
|
59
|
-
$eq: identifierEq
|
|
60
|
-
}
|
|
58
|
+
'offers.identifier': { $exists: true, $eq: identifierEq }
|
|
61
59
|
}
|
|
62
60
|
});
|
|
63
61
|
}
|
|
64
|
-
const identifierIn = (
|
|
62
|
+
const identifierIn = (_k = params.identifier) === null || _k === void 0 ? void 0 : _k.$in;
|
|
65
63
|
if (Array.isArray(identifierIn)) {
|
|
66
64
|
matchStages.push({
|
|
67
65
|
$match: {
|
|
68
|
-
'offers.identifier': {
|
|
69
|
-
$exists: true,
|
|
70
|
-
$in: identifierIn
|
|
71
|
-
}
|
|
66
|
+
'offers.identifier': { $exists: true, $in: identifierIn }
|
|
72
67
|
}
|
|
73
68
|
});
|
|
74
69
|
}
|
|
75
|
-
const identifierRegex = (
|
|
70
|
+
const identifierRegex = (_l = params.identifier) === null || _l === void 0 ? void 0 : _l.$regex;
|
|
76
71
|
if (typeof identifierRegex === 'string' && identifierRegex.length > 0) {
|
|
77
72
|
matchStages.push({
|
|
78
73
|
$match: {
|
|
79
|
-
'offers.identifier': {
|
|
80
|
-
$exists: true,
|
|
81
|
-
$regex: new RegExp(identifierRegex)
|
|
82
|
-
}
|
|
74
|
+
'offers.identifier': { $exists: true, $regex: new RegExp(identifierRegex) }
|
|
83
75
|
}
|
|
84
76
|
});
|
|
85
77
|
}
|
|
86
|
-
const nameRegex = (
|
|
78
|
+
const nameRegex = (_m = params.name) === null || _m === void 0 ? void 0 : _m.$regex;
|
|
87
79
|
if (typeof nameRegex === 'string' && nameRegex.length > 0) {
|
|
88
80
|
const nameRegexExp = new RegExp(nameRegex);
|
|
89
81
|
matchStages.push({
|
|
90
82
|
$match: {
|
|
91
83
|
$or: [
|
|
92
|
-
{
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
'offers.name.en': {
|
|
100
|
-
$exists: true,
|
|
101
|
-
$regex: nameRegexExp
|
|
102
|
-
}
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
'offers.alternateName.ja': {
|
|
106
|
-
$exists: true,
|
|
107
|
-
$regex: nameRegexExp
|
|
108
|
-
}
|
|
109
|
-
},
|
|
110
|
-
{
|
|
111
|
-
'offers.alternateName.en': {
|
|
112
|
-
$exists: true,
|
|
113
|
-
$regex: nameRegexExp
|
|
114
|
-
}
|
|
115
|
-
}
|
|
84
|
+
{ 'offers.name.ja': { $exists: true, $regex: nameRegexExp } },
|
|
85
|
+
{ 'offers.name.en': { $exists: true, $regex: nameRegexExp } },
|
|
86
|
+
{ 'offers.alternateName.ja': { $exists: true, $regex: nameRegexExp } },
|
|
87
|
+
{ 'offers.alternateName.en': { $exists: true, $regex: nameRegexExp } }
|
|
116
88
|
]
|
|
117
89
|
}
|
|
118
90
|
});
|
|
119
91
|
}
|
|
120
|
-
const itemOfferedTypeOfEq = (
|
|
92
|
+
const itemOfferedTypeOfEq = (_p = (_o = params.itemOffered) === null || _o === void 0 ? void 0 : _o.typeOf) === null || _p === void 0 ? void 0 : _p.$eq;
|
|
121
93
|
if (typeof itemOfferedTypeOfEq === 'string') {
|
|
122
94
|
matchStages.push({
|
|
123
95
|
$match: {
|
|
124
|
-
'offers.itemOffered.typeOf': {
|
|
125
|
-
$exists: true,
|
|
126
|
-
$eq: itemOfferedTypeOfEq
|
|
127
|
-
}
|
|
96
|
+
'offers.itemOffered.typeOf': { $exists: true, $eq: itemOfferedTypeOfEq }
|
|
128
97
|
}
|
|
129
98
|
});
|
|
130
99
|
}
|
|
131
|
-
const categoryCodeValueIn = (
|
|
100
|
+
const categoryCodeValueIn = (_r = (_q = params.category) === null || _q === void 0 ? void 0 : _q.codeValue) === null || _r === void 0 ? void 0 : _r.$in;
|
|
132
101
|
if (Array.isArray(categoryCodeValueIn)) {
|
|
133
102
|
matchStages.push({
|
|
134
103
|
$match: {
|
|
135
|
-
'offers.category.codeValue': {
|
|
136
|
-
$exists: true,
|
|
137
|
-
$in: categoryCodeValueIn
|
|
138
|
-
}
|
|
104
|
+
'offers.category.codeValue': { $exists: true, $in: categoryCodeValueIn }
|
|
139
105
|
}
|
|
140
106
|
});
|
|
141
107
|
}
|
|
142
|
-
const eligibleMembershipTypeCodeValueEq = (
|
|
108
|
+
const eligibleMembershipTypeCodeValueEq = (_t = (_s = params.eligibleMembershipType) === null || _s === void 0 ? void 0 : _s.codeValue) === null || _t === void 0 ? void 0 : _t.$eq;
|
|
143
109
|
if (typeof eligibleMembershipTypeCodeValueEq === 'string') {
|
|
144
110
|
matchStages.push({
|
|
145
111
|
$match: {
|
|
@@ -150,7 +116,7 @@ class AggregateOfferRepo {
|
|
|
150
116
|
}
|
|
151
117
|
});
|
|
152
118
|
}
|
|
153
|
-
const eligibleMonetaryAmountCurrencyEq = (
|
|
119
|
+
const eligibleMonetaryAmountCurrencyEq = (_v = (_u = params.eligibleMonetaryAmount) === null || _u === void 0 ? void 0 : _u.currency) === null || _v === void 0 ? void 0 : _v.$eq;
|
|
154
120
|
if (typeof eligibleMonetaryAmountCurrencyEq === 'string') {
|
|
155
121
|
matchStages.push({
|
|
156
122
|
$match: {
|
|
@@ -161,7 +127,7 @@ class AggregateOfferRepo {
|
|
|
161
127
|
}
|
|
162
128
|
});
|
|
163
129
|
}
|
|
164
|
-
const eligibleSeatingTypeCodeValueEq = (
|
|
130
|
+
const eligibleSeatingTypeCodeValueEq = (_x = (_w = params.eligibleSeatingType) === null || _w === void 0 ? void 0 : _w.codeValue) === null || _x === void 0 ? void 0 : _x.$eq;
|
|
165
131
|
if (typeof eligibleSeatingTypeCodeValueEq === 'string') {
|
|
166
132
|
matchStages.push({
|
|
167
133
|
$match: {
|
|
@@ -172,13 +138,13 @@ class AggregateOfferRepo {
|
|
|
172
138
|
}
|
|
173
139
|
});
|
|
174
140
|
}
|
|
175
|
-
const appliesToMovieTicketSize = (
|
|
141
|
+
const appliesToMovieTicketSize = (_z = (_y = params.priceSpecification) === null || _y === void 0 ? void 0 : _y.appliesToMovieTicket) === null || _z === void 0 ? void 0 : _z.$size;
|
|
176
142
|
if (typeof appliesToMovieTicketSize === 'number') {
|
|
177
143
|
matchStages.push({
|
|
178
144
|
$match: { 'offers.priceSpecification.appliesToMovieTicket': { $exists: true, $size: appliesToMovieTicketSize } }
|
|
179
145
|
});
|
|
180
146
|
}
|
|
181
|
-
const appliesToMovieTicketServiceTypeExist = (
|
|
147
|
+
const appliesToMovieTicketServiceTypeExist = (_2 = (_1 = (_0 = params.priceSpecification) === null || _0 === void 0 ? void 0 : _0.appliesToMovieTicket) === null || _1 === void 0 ? void 0 : _1.serviceType) === null || _2 === void 0 ? void 0 : _2.$exists;
|
|
182
148
|
if (typeof appliesToMovieTicketServiceTypeExist === 'boolean') {
|
|
183
149
|
matchStages.push({
|
|
184
150
|
$match: {
|
|
@@ -188,7 +154,7 @@ class AggregateOfferRepo {
|
|
|
188
154
|
}
|
|
189
155
|
});
|
|
190
156
|
}
|
|
191
|
-
const appliesToMovieTicketServiceTypeEq = (
|
|
157
|
+
const appliesToMovieTicketServiceTypeEq = (_5 = (_4 = (_3 = params.priceSpecification) === null || _3 === void 0 ? void 0 : _3.appliesToMovieTicket) === null || _4 === void 0 ? void 0 : _4.serviceType) === null || _5 === void 0 ? void 0 : _5.$eq;
|
|
192
158
|
if (typeof appliesToMovieTicketServiceTypeEq === 'string') {
|
|
193
159
|
matchStages.push({
|
|
194
160
|
$match: {
|
|
@@ -199,7 +165,7 @@ class AggregateOfferRepo {
|
|
|
199
165
|
}
|
|
200
166
|
});
|
|
201
167
|
}
|
|
202
|
-
const appliesToMovieTicketServiceOutputTypeOfEq = (
|
|
168
|
+
const appliesToMovieTicketServiceOutputTypeOfEq = (_9 = (_8 = (_7 = (_6 = params.priceSpecification) === null || _6 === void 0 ? void 0 : _6.appliesToMovieTicket) === null || _7 === void 0 ? void 0 : _7.serviceOutput) === null || _8 === void 0 ? void 0 : _8.typeOf) === null || _9 === void 0 ? void 0 : _9.$eq;
|
|
203
169
|
if (typeof appliesToMovieTicketServiceOutputTypeOfEq === 'string') {
|
|
204
170
|
matchStages.push({
|
|
205
171
|
$match: {
|
|
@@ -210,7 +176,7 @@ class AggregateOfferRepo {
|
|
|
210
176
|
}
|
|
211
177
|
});
|
|
212
178
|
}
|
|
213
|
-
const appliesToMovieTicketServiceOutputTypeOfAll = (
|
|
179
|
+
const appliesToMovieTicketServiceOutputTypeOfAll = (_13 = (_12 = (_11 = (_10 = params.priceSpecification) === null || _10 === void 0 ? void 0 : _10.appliesToMovieTicket) === null || _11 === void 0 ? void 0 : _11.serviceOutput) === null || _12 === void 0 ? void 0 : _12.typeOf) === null || _13 === void 0 ? void 0 : _13.$all;
|
|
214
180
|
if (Array.isArray(appliesToMovieTicketServiceOutputTypeOfAll)) {
|
|
215
181
|
matchStages.push({
|
|
216
182
|
$match: {
|
|
@@ -221,7 +187,7 @@ class AggregateOfferRepo {
|
|
|
221
187
|
}
|
|
222
188
|
});
|
|
223
189
|
}
|
|
224
|
-
const appliesToMovieTicketServiceOutputTypeOfNin = (
|
|
190
|
+
const appliesToMovieTicketServiceOutputTypeOfNin = (_17 = (_16 = (_15 = (_14 = params.priceSpecification) === null || _14 === void 0 ? void 0 : _14.appliesToMovieTicket) === null || _15 === void 0 ? void 0 : _15.serviceOutput) === null || _16 === void 0 ? void 0 : _16.typeOf) === null || _17 === void 0 ? void 0 : _17.$nin;
|
|
225
191
|
if (Array.isArray(appliesToMovieTicketServiceOutputTypeOfNin)) {
|
|
226
192
|
matchStages.push({
|
|
227
193
|
$match: {
|
|
@@ -232,7 +198,7 @@ class AggregateOfferRepo {
|
|
|
232
198
|
});
|
|
233
199
|
}
|
|
234
200
|
if (params.priceSpecification !== undefined && params.priceSpecification !== null) {
|
|
235
|
-
const priceSpecificationPriceGte = (
|
|
201
|
+
const priceSpecificationPriceGte = (_18 = params.priceSpecification.price) === null || _18 === void 0 ? void 0 : _18.$gte;
|
|
236
202
|
if (typeof priceSpecificationPriceGte === 'number') {
|
|
237
203
|
matchStages.push({
|
|
238
204
|
$match: {
|
|
@@ -243,7 +209,7 @@ class AggregateOfferRepo {
|
|
|
243
209
|
}
|
|
244
210
|
});
|
|
245
211
|
}
|
|
246
|
-
const priceSpecificationPriceLte = (
|
|
212
|
+
const priceSpecificationPriceLte = (_19 = params.priceSpecification.price) === null || _19 === void 0 ? void 0 : _19.$lte;
|
|
247
213
|
if (typeof priceSpecificationPriceLte === 'number') {
|
|
248
214
|
matchStages.push({
|
|
249
215
|
$match: {
|
|
@@ -254,7 +220,7 @@ class AggregateOfferRepo {
|
|
|
254
220
|
}
|
|
255
221
|
});
|
|
256
222
|
}
|
|
257
|
-
const accountsReceivableGte = (
|
|
223
|
+
const accountsReceivableGte = (_21 = (_20 = params.priceSpecification.accounting) === null || _20 === void 0 ? void 0 : _20.accountsReceivable) === null || _21 === void 0 ? void 0 : _21.$gte;
|
|
258
224
|
if (typeof accountsReceivableGte === 'number') {
|
|
259
225
|
matchStages.push({
|
|
260
226
|
$match: {
|
|
@@ -265,7 +231,7 @@ class AggregateOfferRepo {
|
|
|
265
231
|
}
|
|
266
232
|
});
|
|
267
233
|
}
|
|
268
|
-
const accountsReceivableLte = (
|
|
234
|
+
const accountsReceivableLte = (_23 = (_22 = params.priceSpecification.accounting) === null || _22 === void 0 ? void 0 : _22.accountsReceivable) === null || _23 === void 0 ? void 0 : _23.$lte;
|
|
269
235
|
if (typeof accountsReceivableLte === 'number') {
|
|
270
236
|
matchStages.push({
|
|
271
237
|
$match: {
|
|
@@ -276,7 +242,7 @@ class AggregateOfferRepo {
|
|
|
276
242
|
}
|
|
277
243
|
});
|
|
278
244
|
}
|
|
279
|
-
const accountingCodeValueEq = (
|
|
245
|
+
const accountingCodeValueEq = (_26 = (_25 = (_24 = params.priceSpecification.accounting) === null || _24 === void 0 ? void 0 : _24.operatingRevenue) === null || _25 === void 0 ? void 0 : _25.codeValue) === null || _26 === void 0 ? void 0 : _26.$eq;
|
|
280
246
|
if (typeof accountingCodeValueEq === 'string') {
|
|
281
247
|
matchStages.push({
|
|
282
248
|
$match: {
|
|
@@ -287,7 +253,7 @@ class AggregateOfferRepo {
|
|
|
287
253
|
}
|
|
288
254
|
});
|
|
289
255
|
}
|
|
290
|
-
const accountingCodeValueIn = (
|
|
256
|
+
const accountingCodeValueIn = (_29 = (_28 = (_27 = params.priceSpecification.accounting) === null || _27 === void 0 ? void 0 : _27.operatingRevenue) === null || _28 === void 0 ? void 0 : _28.codeValue) === null || _29 === void 0 ? void 0 : _29.$in;
|
|
291
257
|
if (Array.isArray(accountingCodeValueIn)) {
|
|
292
258
|
matchStages.push({
|
|
293
259
|
$match: {
|
|
@@ -298,7 +264,7 @@ class AggregateOfferRepo {
|
|
|
298
264
|
}
|
|
299
265
|
});
|
|
300
266
|
}
|
|
301
|
-
const referenceQuantityValueEq = (
|
|
267
|
+
const referenceQuantityValueEq = (_31 = (_30 = params.priceSpecification.referenceQuantity) === null || _30 === void 0 ? void 0 : _30.value) === null || _31 === void 0 ? void 0 : _31.$eq;
|
|
302
268
|
if (typeof referenceQuantityValueEq === 'number') {
|
|
303
269
|
matchStages.push({
|
|
304
270
|
$match: {
|
|
@@ -310,7 +276,7 @@ class AggregateOfferRepo {
|
|
|
310
276
|
});
|
|
311
277
|
}
|
|
312
278
|
}
|
|
313
|
-
const availabilityEq = (
|
|
279
|
+
const availabilityEq = (_32 = params.availability) === null || _32 === void 0 ? void 0 : _32.$eq;
|
|
314
280
|
if (typeof availabilityEq === 'string') {
|
|
315
281
|
matchStages.push({
|
|
316
282
|
$match: {
|
|
@@ -318,7 +284,7 @@ class AggregateOfferRepo {
|
|
|
318
284
|
}
|
|
319
285
|
});
|
|
320
286
|
}
|
|
321
|
-
const availableAtOrFromIdEq = (
|
|
287
|
+
const availableAtOrFromIdEq = (_34 = (_33 = params.availableAtOrFrom) === null || _33 === void 0 ? void 0 : _33.id) === null || _34 === void 0 ? void 0 : _34.$eq;
|
|
322
288
|
if (typeof availableAtOrFromIdEq === 'string') {
|
|
323
289
|
matchStages.push({
|
|
324
290
|
$match: {
|
|
@@ -329,7 +295,7 @@ class AggregateOfferRepo {
|
|
|
329
295
|
}
|
|
330
296
|
});
|
|
331
297
|
}
|
|
332
|
-
const availableAtOrFromIdIn = (
|
|
298
|
+
const availableAtOrFromIdIn = (_36 = (_35 = params.availableAtOrFrom) === null || _35 === void 0 ? void 0 : _35.id) === null || _36 === void 0 ? void 0 : _36.$in;
|
|
333
299
|
if (Array.isArray(availableAtOrFromIdIn)) {
|
|
334
300
|
matchStages.push({
|
|
335
301
|
$match: {
|
|
@@ -340,7 +306,7 @@ class AggregateOfferRepo {
|
|
|
340
306
|
}
|
|
341
307
|
});
|
|
342
308
|
}
|
|
343
|
-
const addOnItemOfferedIdEq = (
|
|
309
|
+
const addOnItemOfferedIdEq = (_39 = (_38 = (_37 = params.addOn) === null || _37 === void 0 ? void 0 : _37.itemOffered) === null || _38 === void 0 ? void 0 : _38.id) === null || _39 === void 0 ? void 0 : _39.$eq;
|
|
344
310
|
if (typeof addOnItemOfferedIdEq === 'string') {
|
|
345
311
|
matchStages.push({
|
|
346
312
|
$match: {
|
|
@@ -348,7 +314,7 @@ class AggregateOfferRepo {
|
|
|
348
314
|
}
|
|
349
315
|
});
|
|
350
316
|
}
|
|
351
|
-
const addOnItemOfferedIdIn = (
|
|
317
|
+
const addOnItemOfferedIdIn = (_42 = (_41 = (_40 = params.addOn) === null || _40 === void 0 ? void 0 : _40.itemOffered) === null || _41 === void 0 ? void 0 : _41.id) === null || _42 === void 0 ? void 0 : _42.$in;
|
|
352
318
|
if (Array.isArray(addOnItemOfferedIdIn)) {
|
|
353
319
|
matchStages.push({
|
|
354
320
|
$match: {
|
|
@@ -356,7 +322,7 @@ class AggregateOfferRepo {
|
|
|
356
322
|
}
|
|
357
323
|
});
|
|
358
324
|
}
|
|
359
|
-
const hasMerchantReturnPolicyIdEq = (
|
|
325
|
+
const hasMerchantReturnPolicyIdEq = (_44 = (_43 = params.hasMerchantReturnPolicy) === null || _43 === void 0 ? void 0 : _43.id) === null || _44 === void 0 ? void 0 : _44.$eq;
|
|
360
326
|
if (typeof hasMerchantReturnPolicyIdEq === 'string') {
|
|
361
327
|
matchStages.push({
|
|
362
328
|
$match: {
|
|
@@ -367,7 +333,7 @@ class AggregateOfferRepo {
|
|
|
367
333
|
}
|
|
368
334
|
});
|
|
369
335
|
}
|
|
370
|
-
const acceptedPaymentMethodIdentifierIn = (
|
|
336
|
+
const acceptedPaymentMethodIdentifierIn = (_46 = (_45 = params.acceptedPaymentMethod) === null || _45 === void 0 ? void 0 : _45.identifier) === null || _46 === void 0 ? void 0 : _46.$in;
|
|
371
337
|
if (Array.isArray(acceptedPaymentMethodIdentifierIn)) {
|
|
372
338
|
matchStages.push({
|
|
373
339
|
$match: {
|
|
@@ -378,7 +344,7 @@ class AggregateOfferRepo {
|
|
|
378
344
|
}
|
|
379
345
|
});
|
|
380
346
|
}
|
|
381
|
-
const additionalPropertyAll = (
|
|
347
|
+
const additionalPropertyAll = (_47 = params.additionalProperty) === null || _47 === void 0 ? void 0 : _47.$all;
|
|
382
348
|
if (Array.isArray(additionalPropertyAll)) {
|
|
383
349
|
matchStages.push({
|
|
384
350
|
$match: {
|
|
@@ -389,7 +355,7 @@ class AggregateOfferRepo {
|
|
|
389
355
|
}
|
|
390
356
|
});
|
|
391
357
|
}
|
|
392
|
-
const additionalPropertyElemMatch = (
|
|
358
|
+
const additionalPropertyElemMatch = (_48 = params.additionalProperty) === null || _48 === void 0 ? void 0 : _48.$elemMatch;
|
|
393
359
|
if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
|
|
394
360
|
matchStages.push({
|
|
395
361
|
$match: {
|
|
@@ -418,6 +384,11 @@ class AggregateOfferRepo {
|
|
|
418
384
|
}
|
|
419
385
|
});
|
|
420
386
|
}
|
|
387
|
+
// add advanceBookingRequirement.id.$eq(2025-04-08~)
|
|
388
|
+
const advanceBookingRequirementIdEq = (_50 = (_49 = params.advanceBookingRequirement) === null || _49 === void 0 ? void 0 : _49.id) === null || _50 === void 0 ? void 0 : _50.$eq;
|
|
389
|
+
if (typeof advanceBookingRequirementIdEq === 'string') {
|
|
390
|
+
matchStages.push({ $match: { 'offers.advanceBookingRequirement.id': { $exists: true, $eq: advanceBookingRequirementIdEq } } });
|
|
391
|
+
}
|
|
421
392
|
return matchStages;
|
|
422
393
|
}
|
|
423
394
|
static CREATE_AGGREGATE_OFFERS_PROJECTION(params) {
|
|
@@ -462,23 +433,23 @@ class AggregateOfferRepo {
|
|
|
462
433
|
}
|
|
463
434
|
return projectStage;
|
|
464
435
|
}
|
|
465
|
-
count(
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
}
|
|
436
|
+
// public async count(
|
|
437
|
+
// params: Omit<factory.unitPriceOffer.ISearchConditions, 'limit' | 'page' | 'sort'>
|
|
438
|
+
// ): Promise<number> {
|
|
439
|
+
// const matchStages = AggregateOfferRepo.CREATE_AGGREGATE_OFFERS_MATCH_CONDITIONS(params);
|
|
440
|
+
// const result = await this.aggregateOfferModel.aggregate<{ offerCount: number }>([
|
|
441
|
+
// ...matchStages,
|
|
442
|
+
// {
|
|
443
|
+
// $count: 'offerCount'
|
|
444
|
+
// }
|
|
445
|
+
// ])
|
|
446
|
+
// .exec();
|
|
447
|
+
// return (result.length > 0) ? result[0].offerCount : 0;
|
|
448
|
+
// }
|
|
478
449
|
search(params, projection) {
|
|
479
450
|
return __awaiter(this, void 0, void 0, function* () {
|
|
480
451
|
var _a, _b;
|
|
481
|
-
const matchStages = AggregateOfferRepo.
|
|
452
|
+
const matchStages = AggregateOfferRepo.CREATE_MATCH_STAGE(params);
|
|
482
453
|
const projectStage = AggregateOfferRepo.CREATE_AGGREGATE_OFFERS_PROJECTION(Object.assign({}, projection));
|
|
483
454
|
const sortByPrice = (_a = params.sort) === null || _a === void 0 ? void 0 : _a['priceSpecification.price'];
|
|
484
455
|
const sortByIdentifier = (_b = params.sort) === null || _b === void 0 ? void 0 : _b.identifier;
|
|
@@ -568,26 +539,25 @@ class AggregateOfferRepo {
|
|
|
568
539
|
.exec();
|
|
569
540
|
});
|
|
570
541
|
}
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
}
|
|
542
|
+
// 単価オファー最適化作業における一時的な処理
|
|
543
|
+
// public async optimizeOffers() {
|
|
544
|
+
// return this.aggregateOfferModel.updateMany(
|
|
545
|
+
// {
|
|
546
|
+
// $or: [
|
|
547
|
+
// { 'offers.id': { $exists: true } },
|
|
548
|
+
// { 'offers.project': { $exists: true } }
|
|
549
|
+
// ]
|
|
550
|
+
// },
|
|
551
|
+
// {
|
|
552
|
+
// $set: {},
|
|
553
|
+
// $unset: {
|
|
554
|
+
// 'offers.0.id': 1,
|
|
555
|
+
// 'offers.0.project': 1
|
|
556
|
+
// }
|
|
557
|
+
// }
|
|
558
|
+
// )
|
|
559
|
+
// .exec();
|
|
560
|
+
// }
|
|
591
561
|
unsetUnnecessaryFields(params) {
|
|
592
562
|
return __awaiter(this, void 0, void 0, function* () {
|
|
593
563
|
return this.aggregateOfferModel.updateMany(params.filter, { $unset: params.$unset }, { timestamps: false })
|
|
@@ -13,9 +13,6 @@ const schemaDefinition = {
|
|
|
13
13
|
typeOf: String,
|
|
14
14
|
offers: [mongoose_1.SchemaTypes.Mixed],
|
|
15
15
|
includedInDataCatalog: [mongoose_1.SchemaTypes.Mixed]
|
|
16
|
-
// createdAt: SchemaTypes.Mixed,
|
|
17
|
-
// updatedAt: SchemaTypes.Mixed,
|
|
18
|
-
// __v: SchemaTypes.Mixed
|
|
19
16
|
};
|
|
20
17
|
const schemaOptions = {
|
|
21
18
|
autoIndex: settings_1.MONGO_AUTO_INDEX,
|
|
@@ -272,6 +269,15 @@ const indexes = [
|
|
|
272
269
|
'offers.acceptedPaymentMethod.identifier': { $exists: true }
|
|
273
270
|
}
|
|
274
271
|
}
|
|
272
|
+
],
|
|
273
|
+
[
|
|
274
|
+
{ 'offers.advanceBookingRequirement.id': 1 },
|
|
275
|
+
{
|
|
276
|
+
name: 'advanceBookingRequirementId',
|
|
277
|
+
partialFilterExpression: {
|
|
278
|
+
'offers.advanceBookingRequirement.id': { $exists: true }
|
|
279
|
+
}
|
|
280
|
+
}
|
|
275
281
|
]
|
|
276
282
|
];
|
|
277
283
|
exports.indexes = indexes;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { BulkWriteResult } from 'mongodb';
|
|
2
|
-
import { AnyExpression, Connection, Document
|
|
2
|
+
import { AnyExpression, Connection, Document } from 'mongoose';
|
|
3
3
|
import * as factory from '../factory';
|
|
4
4
|
import { IDocType as IAggregateOfferDocType } from './mongoose/schemas/aggregateOffer';
|
|
5
|
-
type IMatchStage = PipelineStage.Match;
|
|
6
5
|
type KeyOfUnitPriceOffer = keyof Omit<factory.unitPriceOffer.IUnitPriceOffer, 'id'>;
|
|
7
6
|
type IProjection = {
|
|
8
7
|
[key in KeyOfUnitPriceOffer]?: 0 | 1;
|
|
@@ -42,7 +41,6 @@ export declare class OfferRepo {
|
|
|
42
41
|
private readonly offerCatalogModel;
|
|
43
42
|
private readonly offerCatalogItemModel;
|
|
44
43
|
constructor(connection: Connection);
|
|
45
|
-
static CREATE_AGGREGATE_OFFERS_MATCH_CONDITIONS(params: Omit<factory.unitPriceOffer.ISearchConditions, 'limit' | 'page' | 'sort'>): IMatchStage[];
|
|
46
44
|
static CREATE_AGGREGATE_OFFERS_PROJECTION(params: IProjection): {
|
|
47
45
|
[field: string]: AnyExpression;
|
|
48
46
|
};
|
package/lib/chevre/repo/offer.js
CHANGED
|
@@ -23,7 +23,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
23
23
|
exports.OfferRepo = void 0;
|
|
24
24
|
const mongoose_1 = require("mongoose");
|
|
25
25
|
const factory = require("../factory");
|
|
26
|
-
const aggregateOffer_1 = require("./
|
|
26
|
+
const aggregateOffer_1 = require("./aggregateOffer");
|
|
27
|
+
const aggregateOffer_2 = require("./mongoose/schemas/aggregateOffer");
|
|
27
28
|
const offerCatalog_1 = require("./mongoose/schemas/offerCatalog");
|
|
28
29
|
const offerCatalogItem_1 = require("./mongoose/schemas/offerCatalogItem");
|
|
29
30
|
const OFFERS_ARRAY_INDEX_NAME = 'offerIndex';
|
|
@@ -32,397 +33,10 @@ const OFFERS_ARRAY_INDEX_NAME = 'offerIndex';
|
|
|
32
33
|
*/
|
|
33
34
|
class OfferRepo {
|
|
34
35
|
constructor(connection) {
|
|
35
|
-
this.aggregateOfferModel = connection.model(
|
|
36
|
+
this.aggregateOfferModel = connection.model(aggregateOffer_2.modelName, (0, aggregateOffer_2.createSchema)());
|
|
36
37
|
this.offerCatalogModel = connection.model(offerCatalog_1.modelName, (0, offerCatalog_1.createSchema)());
|
|
37
38
|
this.offerCatalogItemModel = connection.model(offerCatalogItem_1.modelName, (0, offerCatalogItem_1.createSchema)());
|
|
38
39
|
}
|
|
39
|
-
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
40
|
-
static CREATE_AGGREGATE_OFFERS_MATCH_CONDITIONS(params) {
|
|
41
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50;
|
|
42
|
-
const matchStages = [];
|
|
43
|
-
const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
44
|
-
if (typeof projectIdEq === 'string') {
|
|
45
|
-
matchStages.push({
|
|
46
|
-
$match: { 'project.id': { $eq: projectIdEq } }
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
const parentOfferIdIn = (_d = (_c = params.parentOffer) === null || _c === void 0 ? void 0 : _c.id) === null || _d === void 0 ? void 0 : _d.$in;
|
|
50
|
-
if (Array.isArray(parentOfferIdIn)) {
|
|
51
|
-
matchStages.push({ $match: { _id: { $in: parentOfferIdIn } } });
|
|
52
|
-
}
|
|
53
|
-
// aggregateOffer.includedInDataCatalogで検索する(2023-09-21~)
|
|
54
|
-
const includedInDataCatalogIdIn = (_f = (_e = params.includedInDataCatalog) === null || _e === void 0 ? void 0 : _e.id) === null || _f === void 0 ? void 0 : _f.$in;
|
|
55
|
-
// if (Array.isArray(includedInDataCatalogIdIn)) {
|
|
56
|
-
// matchStages.push({ $match: { 'offers.includedInDataCatalog.id': { $exists: true, $in: includedInDataCatalogIdIn } } });
|
|
57
|
-
// }
|
|
58
|
-
if (Array.isArray(includedInDataCatalogIdIn)) {
|
|
59
|
-
matchStages.push({ $match: { 'includedInDataCatalog.id': { $exists: true, $in: includedInDataCatalogIdIn } } });
|
|
60
|
-
}
|
|
61
|
-
// const includedInOfferCatalogItemIncludedInDataCatalogIdIn = params.includedInOfferCatalogItem?.includedInDataCatalog?.id?.$in;
|
|
62
|
-
// if (Array.isArray(includedInOfferCatalogItemIncludedInDataCatalogIdIn)) {
|
|
63
|
-
// matchStages.push({
|
|
64
|
-
// $match: {
|
|
65
|
-
// 'offers.includedInOfferCatalogItem.includedInDataCatalog.id': {
|
|
66
|
-
// $exists: true,
|
|
67
|
-
// $in: includedInOfferCatalogItemIncludedInDataCatalogIdIn
|
|
68
|
-
// }
|
|
69
|
-
// }
|
|
70
|
-
// });
|
|
71
|
-
// }
|
|
72
|
-
const idEq = (_g = params.id) === null || _g === void 0 ? void 0 : _g.$eq;
|
|
73
|
-
if (typeof idEq === 'string') {
|
|
74
|
-
matchStages.push({
|
|
75
|
-
// $match: { 'offers.id': { $eq: idEq } }
|
|
76
|
-
$match: { _id: { $eq: idEq } } // _idに変更(2023-12-22~)
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
const idIn = (_h = params.id) === null || _h === void 0 ? void 0 : _h.$in;
|
|
80
|
-
if (Array.isArray(idIn)) {
|
|
81
|
-
matchStages.push({
|
|
82
|
-
// $match: { 'offers.id': { $in: idIn } }
|
|
83
|
-
$match: { _id: { $in: idIn } } // _idに変更(2023-12-22~)
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
const identifierEq = (_j = params.identifier) === null || _j === void 0 ? void 0 : _j.$eq;
|
|
87
|
-
if (typeof identifierEq === 'string') {
|
|
88
|
-
matchStages.push({
|
|
89
|
-
$match: {
|
|
90
|
-
'offers.identifier': { $exists: true, $eq: identifierEq }
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
const identifierIn = (_k = params.identifier) === null || _k === void 0 ? void 0 : _k.$in;
|
|
95
|
-
if (Array.isArray(identifierIn)) {
|
|
96
|
-
matchStages.push({
|
|
97
|
-
$match: {
|
|
98
|
-
'offers.identifier': { $exists: true, $in: identifierIn }
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
const identifierRegex = (_l = params.identifier) === null || _l === void 0 ? void 0 : _l.$regex;
|
|
103
|
-
if (typeof identifierRegex === 'string' && identifierRegex.length > 0) {
|
|
104
|
-
matchStages.push({
|
|
105
|
-
$match: {
|
|
106
|
-
'offers.identifier': { $exists: true, $regex: new RegExp(identifierRegex) }
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
const nameRegex = (_m = params.name) === null || _m === void 0 ? void 0 : _m.$regex;
|
|
111
|
-
if (typeof nameRegex === 'string' && nameRegex.length > 0) {
|
|
112
|
-
const nameRegexExp = new RegExp(nameRegex);
|
|
113
|
-
matchStages.push({
|
|
114
|
-
$match: {
|
|
115
|
-
$or: [
|
|
116
|
-
{ 'offers.name.ja': { $exists: true, $regex: nameRegexExp } },
|
|
117
|
-
{ 'offers.name.en': { $exists: true, $regex: nameRegexExp } },
|
|
118
|
-
{ 'offers.alternateName.ja': { $exists: true, $regex: nameRegexExp } },
|
|
119
|
-
{ 'offers.alternateName.en': { $exists: true, $regex: nameRegexExp } }
|
|
120
|
-
]
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
const itemOfferedTypeOfEq = (_p = (_o = params.itemOffered) === null || _o === void 0 ? void 0 : _o.typeOf) === null || _p === void 0 ? void 0 : _p.$eq;
|
|
125
|
-
if (typeof itemOfferedTypeOfEq === 'string') {
|
|
126
|
-
matchStages.push({
|
|
127
|
-
$match: {
|
|
128
|
-
'offers.itemOffered.typeOf': { $exists: true, $eq: itemOfferedTypeOfEq }
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
const categoryCodeValueIn = (_r = (_q = params.category) === null || _q === void 0 ? void 0 : _q.codeValue) === null || _r === void 0 ? void 0 : _r.$in;
|
|
133
|
-
if (Array.isArray(categoryCodeValueIn)) {
|
|
134
|
-
matchStages.push({
|
|
135
|
-
$match: {
|
|
136
|
-
'offers.category.codeValue': { $exists: true, $in: categoryCodeValueIn }
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
const eligibleMembershipTypeCodeValueEq = (_t = (_s = params.eligibleMembershipType) === null || _s === void 0 ? void 0 : _s.codeValue) === null || _t === void 0 ? void 0 : _t.$eq;
|
|
141
|
-
if (typeof eligibleMembershipTypeCodeValueEq === 'string') {
|
|
142
|
-
matchStages.push({
|
|
143
|
-
$match: {
|
|
144
|
-
'offers.eligibleMembershipType.codeValue': {
|
|
145
|
-
$exists: true,
|
|
146
|
-
$eq: eligibleMembershipTypeCodeValueEq
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
const eligibleMonetaryAmountCurrencyEq = (_v = (_u = params.eligibleMonetaryAmount) === null || _u === void 0 ? void 0 : _u.currency) === null || _v === void 0 ? void 0 : _v.$eq;
|
|
152
|
-
if (typeof eligibleMonetaryAmountCurrencyEq === 'string') {
|
|
153
|
-
matchStages.push({
|
|
154
|
-
$match: {
|
|
155
|
-
'offers.eligibleMonetaryAmount.currency': {
|
|
156
|
-
$exists: true,
|
|
157
|
-
$eq: eligibleMonetaryAmountCurrencyEq
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
const eligibleSeatingTypeCodeValueEq = (_x = (_w = params.eligibleSeatingType) === null || _w === void 0 ? void 0 : _w.codeValue) === null || _x === void 0 ? void 0 : _x.$eq;
|
|
163
|
-
if (typeof eligibleSeatingTypeCodeValueEq === 'string') {
|
|
164
|
-
matchStages.push({
|
|
165
|
-
$match: {
|
|
166
|
-
'offers.eligibleSeatingType.codeValue': {
|
|
167
|
-
$exists: true,
|
|
168
|
-
$eq: eligibleSeatingTypeCodeValueEq
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
const appliesToMovieTicketSize = (_z = (_y = params.priceSpecification) === null || _y === void 0 ? void 0 : _y.appliesToMovieTicket) === null || _z === void 0 ? void 0 : _z.$size;
|
|
174
|
-
if (typeof appliesToMovieTicketSize === 'number') {
|
|
175
|
-
matchStages.push({
|
|
176
|
-
$match: { 'offers.priceSpecification.appliesToMovieTicket': { $exists: true, $size: appliesToMovieTicketSize } }
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
const appliesToMovieTicketServiceTypeExist = (_2 = (_1 = (_0 = params.priceSpecification) === null || _0 === void 0 ? void 0 : _0.appliesToMovieTicket) === null || _1 === void 0 ? void 0 : _1.serviceType) === null || _2 === void 0 ? void 0 : _2.$exists;
|
|
180
|
-
if (typeof appliesToMovieTicketServiceTypeExist === 'boolean') {
|
|
181
|
-
matchStages.push({
|
|
182
|
-
$match: {
|
|
183
|
-
'offers.priceSpecification.appliesToMovieTicket.serviceType': {
|
|
184
|
-
$exists: appliesToMovieTicketServiceTypeExist
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
const appliesToMovieTicketServiceTypeEq = (_5 = (_4 = (_3 = params.priceSpecification) === null || _3 === void 0 ? void 0 : _3.appliesToMovieTicket) === null || _4 === void 0 ? void 0 : _4.serviceType) === null || _5 === void 0 ? void 0 : _5.$eq;
|
|
190
|
-
if (typeof appliesToMovieTicketServiceTypeEq === 'string') {
|
|
191
|
-
matchStages.push({
|
|
192
|
-
$match: {
|
|
193
|
-
'offers.priceSpecification.appliesToMovieTicket.serviceType': {
|
|
194
|
-
$exists: true,
|
|
195
|
-
$eq: appliesToMovieTicketServiceTypeEq
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
const appliesToMovieTicketServiceOutputTypeOfEq = (_9 = (_8 = (_7 = (_6 = params.priceSpecification) === null || _6 === void 0 ? void 0 : _6.appliesToMovieTicket) === null || _7 === void 0 ? void 0 : _7.serviceOutput) === null || _8 === void 0 ? void 0 : _8.typeOf) === null || _9 === void 0 ? void 0 : _9.$eq;
|
|
201
|
-
if (typeof appliesToMovieTicketServiceOutputTypeOfEq === 'string') {
|
|
202
|
-
matchStages.push({
|
|
203
|
-
$match: {
|
|
204
|
-
'offers.priceSpecification.appliesToMovieTicket.serviceOutput.typeOf': {
|
|
205
|
-
$exists: true,
|
|
206
|
-
$eq: appliesToMovieTicketServiceOutputTypeOfEq
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
const appliesToMovieTicketServiceOutputTypeOfAll = (_13 = (_12 = (_11 = (_10 = params.priceSpecification) === null || _10 === void 0 ? void 0 : _10.appliesToMovieTicket) === null || _11 === void 0 ? void 0 : _11.serviceOutput) === null || _12 === void 0 ? void 0 : _12.typeOf) === null || _13 === void 0 ? void 0 : _13.$all;
|
|
212
|
-
if (Array.isArray(appliesToMovieTicketServiceOutputTypeOfAll)) {
|
|
213
|
-
matchStages.push({
|
|
214
|
-
$match: {
|
|
215
|
-
'offers.priceSpecification.appliesToMovieTicket.serviceOutput.typeOf': {
|
|
216
|
-
$exists: true,
|
|
217
|
-
$all: appliesToMovieTicketServiceOutputTypeOfAll
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
});
|
|
221
|
-
}
|
|
222
|
-
const appliesToMovieTicketServiceOutputTypeOfNin = (_17 = (_16 = (_15 = (_14 = params.priceSpecification) === null || _14 === void 0 ? void 0 : _14.appliesToMovieTicket) === null || _15 === void 0 ? void 0 : _15.serviceOutput) === null || _16 === void 0 ? void 0 : _16.typeOf) === null || _17 === void 0 ? void 0 : _17.$nin;
|
|
223
|
-
if (Array.isArray(appliesToMovieTicketServiceOutputTypeOfNin)) {
|
|
224
|
-
matchStages.push({
|
|
225
|
-
$match: {
|
|
226
|
-
'offers.priceSpecification.appliesToMovieTicket.serviceOutput.typeOf': {
|
|
227
|
-
$nin: appliesToMovieTicketServiceOutputTypeOfNin
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
});
|
|
231
|
-
}
|
|
232
|
-
if (params.priceSpecification !== undefined && params.priceSpecification !== null) {
|
|
233
|
-
const priceSpecificationPriceGte = (_18 = params.priceSpecification.price) === null || _18 === void 0 ? void 0 : _18.$gte;
|
|
234
|
-
if (typeof priceSpecificationPriceGte === 'number') {
|
|
235
|
-
matchStages.push({
|
|
236
|
-
$match: {
|
|
237
|
-
'offers.priceSpecification.price': {
|
|
238
|
-
$exists: true,
|
|
239
|
-
$gte: priceSpecificationPriceGte
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
});
|
|
243
|
-
}
|
|
244
|
-
const priceSpecificationPriceLte = (_19 = params.priceSpecification.price) === null || _19 === void 0 ? void 0 : _19.$lte;
|
|
245
|
-
if (typeof priceSpecificationPriceLte === 'number') {
|
|
246
|
-
matchStages.push({
|
|
247
|
-
$match: {
|
|
248
|
-
'offers.priceSpecification.price': {
|
|
249
|
-
$exists: true,
|
|
250
|
-
$lte: priceSpecificationPriceLte
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
});
|
|
254
|
-
}
|
|
255
|
-
const accountsReceivableGte = (_21 = (_20 = params.priceSpecification.accounting) === null || _20 === void 0 ? void 0 : _20.accountsReceivable) === null || _21 === void 0 ? void 0 : _21.$gte;
|
|
256
|
-
if (typeof accountsReceivableGte === 'number') {
|
|
257
|
-
matchStages.push({
|
|
258
|
-
$match: {
|
|
259
|
-
'offers.priceSpecification.accounting.accountsReceivable': {
|
|
260
|
-
$exists: true,
|
|
261
|
-
$gte: accountsReceivableGte
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
});
|
|
265
|
-
}
|
|
266
|
-
const accountsReceivableLte = (_23 = (_22 = params.priceSpecification.accounting) === null || _22 === void 0 ? void 0 : _22.accountsReceivable) === null || _23 === void 0 ? void 0 : _23.$lte;
|
|
267
|
-
if (typeof accountsReceivableLte === 'number') {
|
|
268
|
-
matchStages.push({
|
|
269
|
-
$match: {
|
|
270
|
-
'offers.priceSpecification.accounting.accountsReceivable': {
|
|
271
|
-
$exists: true,
|
|
272
|
-
$lte: accountsReceivableLte
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
});
|
|
276
|
-
}
|
|
277
|
-
const accountingCodeValueEq = (_26 = (_25 = (_24 = params.priceSpecification.accounting) === null || _24 === void 0 ? void 0 : _24.operatingRevenue) === null || _25 === void 0 ? void 0 : _25.codeValue) === null || _26 === void 0 ? void 0 : _26.$eq;
|
|
278
|
-
if (typeof accountingCodeValueEq === 'string') {
|
|
279
|
-
matchStages.push({
|
|
280
|
-
$match: {
|
|
281
|
-
'offers.priceSpecification.accounting.operatingRevenue.codeValue': {
|
|
282
|
-
$exists: true,
|
|
283
|
-
$eq: accountingCodeValueEq
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
});
|
|
287
|
-
}
|
|
288
|
-
const accountingCodeValueIn = (_29 = (_28 = (_27 = params.priceSpecification.accounting) === null || _27 === void 0 ? void 0 : _27.operatingRevenue) === null || _28 === void 0 ? void 0 : _28.codeValue) === null || _29 === void 0 ? void 0 : _29.$in;
|
|
289
|
-
if (Array.isArray(accountingCodeValueIn)) {
|
|
290
|
-
matchStages.push({
|
|
291
|
-
$match: {
|
|
292
|
-
'offers.priceSpecification.accounting.operatingRevenue.codeValue': {
|
|
293
|
-
$exists: true,
|
|
294
|
-
$in: accountingCodeValueIn
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
});
|
|
298
|
-
}
|
|
299
|
-
const referenceQuantityValueEq = (_31 = (_30 = params.priceSpecification.referenceQuantity) === null || _30 === void 0 ? void 0 : _30.value) === null || _31 === void 0 ? void 0 : _31.$eq;
|
|
300
|
-
if (typeof referenceQuantityValueEq === 'number') {
|
|
301
|
-
matchStages.push({
|
|
302
|
-
$match: {
|
|
303
|
-
'offers.priceSpecification.referenceQuantity.value': {
|
|
304
|
-
$exists: true,
|
|
305
|
-
$eq: referenceQuantityValueEq
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
});
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
const availabilityEq = (_32 = params.availability) === null || _32 === void 0 ? void 0 : _32.$eq;
|
|
312
|
-
if (typeof availabilityEq === 'string') {
|
|
313
|
-
matchStages.push({
|
|
314
|
-
$match: {
|
|
315
|
-
'offers.availability': { $eq: availabilityEq }
|
|
316
|
-
}
|
|
317
|
-
});
|
|
318
|
-
}
|
|
319
|
-
const availableAtOrFromIdEq = (_34 = (_33 = params.availableAtOrFrom) === null || _33 === void 0 ? void 0 : _33.id) === null || _34 === void 0 ? void 0 : _34.$eq;
|
|
320
|
-
if (typeof availableAtOrFromIdEq === 'string') {
|
|
321
|
-
matchStages.push({
|
|
322
|
-
$match: {
|
|
323
|
-
'offers.availableAtOrFrom.id': {
|
|
324
|
-
$exists: true,
|
|
325
|
-
$eq: availableAtOrFromIdEq
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
});
|
|
329
|
-
}
|
|
330
|
-
const availableAtOrFromIdIn = (_36 = (_35 = params.availableAtOrFrom) === null || _35 === void 0 ? void 0 : _35.id) === null || _36 === void 0 ? void 0 : _36.$in;
|
|
331
|
-
if (Array.isArray(availableAtOrFromIdIn)) {
|
|
332
|
-
matchStages.push({
|
|
333
|
-
$match: {
|
|
334
|
-
'offers.availableAtOrFrom.id': {
|
|
335
|
-
$exists: true,
|
|
336
|
-
$in: availableAtOrFromIdIn
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
});
|
|
340
|
-
}
|
|
341
|
-
const addOnItemOfferedIdEq = (_39 = (_38 = (_37 = params.addOn) === null || _37 === void 0 ? void 0 : _37.itemOffered) === null || _38 === void 0 ? void 0 : _38.id) === null || _39 === void 0 ? void 0 : _39.$eq;
|
|
342
|
-
if (typeof addOnItemOfferedIdEq === 'string') {
|
|
343
|
-
matchStages.push({
|
|
344
|
-
$match: {
|
|
345
|
-
'offers.addOn.itemOffered.id': { $exists: true, $eq: addOnItemOfferedIdEq }
|
|
346
|
-
}
|
|
347
|
-
});
|
|
348
|
-
}
|
|
349
|
-
const addOnItemOfferedIdIn = (_42 = (_41 = (_40 = params.addOn) === null || _40 === void 0 ? void 0 : _40.itemOffered) === null || _41 === void 0 ? void 0 : _41.id) === null || _42 === void 0 ? void 0 : _42.$in;
|
|
350
|
-
if (Array.isArray(addOnItemOfferedIdIn)) {
|
|
351
|
-
matchStages.push({
|
|
352
|
-
$match: {
|
|
353
|
-
'offers.addOn.itemOffered.id': { $exists: true, $in: addOnItemOfferedIdIn }
|
|
354
|
-
}
|
|
355
|
-
});
|
|
356
|
-
}
|
|
357
|
-
const hasMerchantReturnPolicyIdEq = (_44 = (_43 = params.hasMerchantReturnPolicy) === null || _43 === void 0 ? void 0 : _43.id) === null || _44 === void 0 ? void 0 : _44.$eq;
|
|
358
|
-
if (typeof hasMerchantReturnPolicyIdEq === 'string') {
|
|
359
|
-
matchStages.push({
|
|
360
|
-
$match: {
|
|
361
|
-
'offers.hasMerchantReturnPolicy.id': {
|
|
362
|
-
$exists: true,
|
|
363
|
-
$eq: hasMerchantReturnPolicyIdEq
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
});
|
|
367
|
-
}
|
|
368
|
-
const acceptedPaymentMethodIdentifierIn = (_46 = (_45 = params.acceptedPaymentMethod) === null || _45 === void 0 ? void 0 : _45.identifier) === null || _46 === void 0 ? void 0 : _46.$in;
|
|
369
|
-
if (Array.isArray(acceptedPaymentMethodIdentifierIn)) {
|
|
370
|
-
matchStages.push({
|
|
371
|
-
$match: {
|
|
372
|
-
'offers.acceptedPaymentMethod.identifier': {
|
|
373
|
-
$exists: true,
|
|
374
|
-
$in: acceptedPaymentMethodIdentifierIn
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
});
|
|
378
|
-
}
|
|
379
|
-
const additionalPropertyAll = (_47 = params.additionalProperty) === null || _47 === void 0 ? void 0 : _47.$all;
|
|
380
|
-
if (Array.isArray(additionalPropertyAll)) {
|
|
381
|
-
matchStages.push({
|
|
382
|
-
$match: {
|
|
383
|
-
'offers.additionalProperty': {
|
|
384
|
-
$exists: true,
|
|
385
|
-
$all: additionalPropertyAll
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
});
|
|
389
|
-
}
|
|
390
|
-
const additionalPropertyElemMatch = (_48 = params.additionalProperty) === null || _48 === void 0 ? void 0 : _48.$elemMatch;
|
|
391
|
-
if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
|
|
392
|
-
matchStages.push({
|
|
393
|
-
$match: {
|
|
394
|
-
'offers.additionalProperty': {
|
|
395
|
-
$exists: true,
|
|
396
|
-
$elemMatch: additionalPropertyElemMatch
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
});
|
|
400
|
-
}
|
|
401
|
-
if (params.onlyValid === true) {
|
|
402
|
-
const now = new Date();
|
|
403
|
-
matchStages.push({
|
|
404
|
-
$match: {
|
|
405
|
-
$or: [
|
|
406
|
-
{ 'offers.validFrom': { $exists: false } },
|
|
407
|
-
{ 'offers.validFrom': { $exists: true, $lte: now } }
|
|
408
|
-
]
|
|
409
|
-
}
|
|
410
|
-
}, {
|
|
411
|
-
$match: {
|
|
412
|
-
$or: [
|
|
413
|
-
{ 'offers.validThrough': { $exists: false } },
|
|
414
|
-
{ 'offers.validThrough': { $exists: true, $gte: now } }
|
|
415
|
-
]
|
|
416
|
-
}
|
|
417
|
-
});
|
|
418
|
-
}
|
|
419
|
-
// add advanceBookingRequirement.id.$eq(2025-04-08~)
|
|
420
|
-
const advanceBookingRequirementIdEq = (_50 = (_49 = params.advanceBookingRequirement) === null || _49 === void 0 ? void 0 : _49.id) === null || _50 === void 0 ? void 0 : _50.$eq;
|
|
421
|
-
if (typeof advanceBookingRequirementIdEq === 'string') {
|
|
422
|
-
matchStages.push({ $match: { 'offers.advanceBookingRequirement.id': { $exists: true, $eq: advanceBookingRequirementIdEq } } });
|
|
423
|
-
}
|
|
424
|
-
return matchStages;
|
|
425
|
-
}
|
|
426
40
|
static CREATE_AGGREGATE_OFFERS_PROJECTION(params) {
|
|
427
41
|
let projectStage = {
|
|
428
42
|
_id: 0,
|
|
@@ -645,7 +259,7 @@ class OfferRepo {
|
|
|
645
259
|
? { serviceOutput: { typeOf: { $nin: params.unacceptedPaymentMethod } } }
|
|
646
260
|
: undefined)
|
|
647
261
|
}, onlyValid: params.onlyValid === true });
|
|
648
|
-
const matchStages =
|
|
262
|
+
const matchStages = aggregateOffer_1.AggregateOfferRepo.CREATE_MATCH_STAGE(searchOffersConditions);
|
|
649
263
|
const aggregate = this.aggregateOfferModel.aggregate([
|
|
650
264
|
{ $unwind: { path: '$offers' } },
|
|
651
265
|
{ $unwind: { path: '$offers.priceSpecification.appliesToMovieTicket' } },
|
|
@@ -707,7 +321,7 @@ class OfferRepo {
|
|
|
707
321
|
}
|
|
708
322
|
count(params) {
|
|
709
323
|
return __awaiter(this, void 0, void 0, function* () {
|
|
710
|
-
const matchStages =
|
|
324
|
+
const matchStages = aggregateOffer_1.AggregateOfferRepo.CREATE_MATCH_STAGE(params);
|
|
711
325
|
const result = yield this.aggregateOfferModel.aggregate([
|
|
712
326
|
{
|
|
713
327
|
$unwind: { path: '$offers' }
|
|
@@ -724,7 +338,7 @@ class OfferRepo {
|
|
|
724
338
|
search(params, projection) {
|
|
725
339
|
return __awaiter(this, void 0, void 0, function* () {
|
|
726
340
|
var _a, _b;
|
|
727
|
-
const matchStages =
|
|
341
|
+
const matchStages = aggregateOffer_1.AggregateOfferRepo.CREATE_MATCH_STAGE(params);
|
|
728
342
|
const projectStage = OfferRepo.CREATE_AGGREGATE_OFFERS_PROJECTION(Object.assign({}, projection));
|
|
729
343
|
const sortByPrice = (_a = params.sort) === null || _a === void 0 ? void 0 : _a['priceSpecification.price'];
|
|
730
344
|
const sortByIdentifier = (_b = params.sort) === null || _b === void 0 ? void 0 : _b.identifier;
|
|
@@ -259,7 +259,7 @@ function validateQuantityRequirement(params) {
|
|
|
259
259
|
* 事前予約要件を検証する
|
|
260
260
|
*/
|
|
261
261
|
function validateAdvanceBookingRequirement(params) {
|
|
262
|
-
var _a;
|
|
262
|
+
var _a, _b;
|
|
263
263
|
let requirementSatisfied = true;
|
|
264
264
|
// reimplement using advanceBookingRequirementRepo(2025-04-08~)
|
|
265
265
|
const advanceBookingRequirementId = (_a = params.unitPriceOffer.advanceBookingRequirement) === null || _a === void 0 ? void 0 : _a.id;
|
|
@@ -271,7 +271,18 @@ function validateAdvanceBookingRequirement(params) {
|
|
|
271
271
|
const advanceBookingRequirementMaxValue = advanceBookingRequirement.maxValue;
|
|
272
272
|
const advanceBookingRequirementMinValue = advanceBookingRequirement.minValue;
|
|
273
273
|
const advanceBookingRequirementUnitCode = advanceBookingRequirement.unitCode;
|
|
274
|
-
const
|
|
274
|
+
const valueReferenceOpens = (_b = advanceBookingRequirement.valueReference) === null || _b === void 0 ? void 0 : _b.opens;
|
|
275
|
+
let usageDate = moment(params.reservationFor.startDate, true);
|
|
276
|
+
if (typeof valueReferenceOpens === 'string') {
|
|
277
|
+
// support valueReference(2025-04-10~)
|
|
278
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
279
|
+
const opensOffset = valueReferenceOpens.slice(8); // format: HH:mm:ssZ
|
|
280
|
+
// tslint:disable-next-line:no-console
|
|
281
|
+
debug('opensOffset:', opensOffset);
|
|
282
|
+
usageDate = usageDate.utcOffset(opensOffset);
|
|
283
|
+
usageDate = moment(`${usageDate.format('YYYY-MM-DD')}T${valueReferenceOpens}`, true);
|
|
284
|
+
}
|
|
285
|
+
debug('usageDate:', usageDate);
|
|
275
286
|
if (typeof advanceBookingRequirementMaxValue === 'number' && typeof advanceBookingRequirementUnitCode === 'string') {
|
|
276
287
|
if (advanceBookingRequirementMaxValue < 0) {
|
|
277
288
|
throw new factory.errors.NotImplemented('negative value as advanceBookingRequirement.maxValue not implemented');
|
|
@@ -280,7 +291,7 @@ function validateAdvanceBookingRequirement(params) {
|
|
|
280
291
|
throw new factory.errors.NotImplemented(`only ${factory.unitCode.Day} implemented`);
|
|
281
292
|
}
|
|
282
293
|
const usageDateMustBeBefore = moment(params.now)
|
|
283
|
-
.add(
|
|
294
|
+
.add(advanceBookingRequirementMaxValue, 'days');
|
|
284
295
|
if (!usageDate.isSameOrBefore(usageDateMustBeBefore)) {
|
|
285
296
|
requirementSatisfied = false;
|
|
286
297
|
}
|
|
@@ -31,8 +31,6 @@ function wait4payActionDelayIfNeeded(params) {
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
if (waitingNecessary) {
|
|
34
|
-
// tslint:disable-next-line:no-console
|
|
35
|
-
console.log('wait4payActionDelayIfNeeded: waiting... minIntervalBetweenPayAndRefund:', minIntervalBetweenPayAndRefund);
|
|
36
34
|
yield new Promise((resolve) => {
|
|
37
35
|
setTimeout(() => {
|
|
38
36
|
resolve();
|
package/package.json
CHANGED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
2
|
-
import * as mongoose from 'mongoose';
|
|
3
|
-
|
|
4
|
-
import { chevre } from '../../../lib/index';
|
|
5
|
-
|
|
6
|
-
async function main() {
|
|
7
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
8
|
-
|
|
9
|
-
const aggregateOfferRepo = await chevre.repository.AggregateOffer.createInstance(mongoose.connection);
|
|
10
|
-
const result = await aggregateOfferRepo.optimizeOffers();
|
|
11
|
-
console.log('result:', result);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
main()
|
|
15
|
-
.then(console.log)
|
|
16
|
-
.catch(console.error);
|