@chevre/domain 20.4.0-alpha.8 → 20.4.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/example/src/chevre/aggregateEventReservation.ts +2 -1
- package/example/src/chevre/deleteMovieTicketCategoryChargePriceSpecs.ts +21 -0
- package/example/src/chevre/{deleteReservationTicketUnderNames.ts → deleteTasksByName.ts} +4 -2
- package/example/src/chevre/migrateMoneyTransferPendingTransactionIdentifier.ts +96 -0
- package/example/src/chevre/reIndex.ts +25 -0
- package/example/src/chevre/searchEventTicketOffers.ts +7 -4
- package/example/src/chevre/searchOfferCatalogs.ts +14 -16
- package/example/src/chevre/searchOffersByCatalog.ts +2 -1
- package/example/src/chevre/searchProductOffers.ts +38 -0
- package/example/src/chevre/searchTasks.ts +22 -0
- package/example/src/chevre/unsetUnnecessaryFields.ts +6 -11
- package/lib/chevre/errorHandler.js +1 -0
- package/lib/chevre/repo/accountTransaction.d.ts +0 -5
- package/lib/chevre/repo/accountTransaction.js +44 -38
- package/lib/chevre/repo/assetTransaction.d.ts +1 -0
- package/lib/chevre/repo/assetTransaction.js +5 -0
- package/lib/chevre/repo/code.d.ts +0 -7
- package/lib/chevre/repo/code.js +0 -17
- package/lib/chevre/repo/event.d.ts +5 -4
- package/lib/chevre/repo/event.js +8 -17
- package/lib/chevre/repo/mongoose/model/accountTransaction.js +0 -5
- package/lib/chevre/repo/mongoose/model/member.js +5 -2
- package/lib/chevre/repo/mongoose/model/offer.js +19 -9
- package/lib/chevre/repo/mongoose/model/priceSpecification.js +19 -52
- package/lib/chevre/repo/mongoose/model/product.js +15 -2
- package/lib/chevre/repo/offer.d.ts +17 -2
- package/lib/chevre/repo/offer.js +77 -44
- package/lib/chevre/repo/offerCatalog.d.ts +3 -5
- package/lib/chevre/repo/offerCatalog.js +78 -37
- package/lib/chevre/repo/priceSpecification.d.ts +11 -0
- package/lib/chevre/repo/priceSpecification.js +44 -66
- package/lib/chevre/repo/task.d.ts +8 -0
- package/lib/chevre/repo/task.js +21 -9
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.d.ts +2 -0
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +93 -96
- package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.js +3 -1
- package/lib/chevre/service/assetTransaction/moneyTransfer.js +19 -11
- package/lib/chevre/service/assetTransaction/pay.js +2 -3
- package/lib/chevre/service/assetTransaction/registerService/factory.d.ts +1 -1
- package/lib/chevre/service/assetTransaction/registerService/factory.js +6 -3
- package/lib/chevre/service/assetTransaction/registerService.js +3 -1
- package/lib/chevre/service/assetTransaction/reserve/factory/price.d.ts +1 -1
- package/lib/chevre/service/assetTransaction/reserve/factory/price.js +0 -7
- package/lib/chevre/service/assetTransaction/reserve/factory.d.ts +2 -2
- package/lib/chevre/service/assetTransaction/reserve/factory.js +0 -1
- package/lib/chevre/service/assetTransaction/reserve.js +47 -17
- package/lib/chevre/service/assetTransaction.d.ts +1 -1
- package/lib/chevre/service/code.d.ts +0 -8
- package/lib/chevre/service/code.js +1 -38
- package/lib/chevre/service/delivery.js +12 -3
- package/lib/chevre/service/event.js +0 -3
- package/lib/chevre/service/moneyTransfer.d.ts +1 -1
- package/lib/chevre/service/moneyTransfer.js +7 -8
- package/lib/chevre/service/offer/event/authorize.js +5 -5
- package/lib/chevre/service/offer/event/factory.js +1 -1
- package/lib/chevre/service/offer/event/searchEventTicketOffers.d.ts +7 -7
- package/lib/chevre/service/offer/event/searchEventTicketOffers.js +222 -346
- package/lib/chevre/service/offer/factory.d.ts +8 -3
- package/lib/chevre/service/offer/factory.js +44 -26
- package/lib/chevre/service/offer/moneyTransfer/authorize.js +0 -1
- package/lib/chevre/service/offer/moneyTransfer/returnMoneyTransfer.js +0 -1
- package/lib/chevre/service/offer/product/searchProductOffers.d.ts +11 -1
- package/lib/chevre/service/offer/product/searchProductOffers.js +15 -7
- package/lib/chevre/service/offer/product.d.ts +11 -4
- package/lib/chevre/service/offer/product.js +59 -50
- package/lib/chevre/service/payment/any/factory.js +30 -21
- package/lib/chevre/service/payment/any.js +11 -4
- package/lib/chevre/service/payment/movieTicket/checkByIdentifier.d.ts +22 -0
- package/lib/chevre/service/payment/movieTicket/checkByIdentifier.js +183 -0
- package/lib/chevre/service/payment/movieTicket/factory.d.ts +1 -1
- package/lib/chevre/service/payment/movieTicket/getCredentials.d.ts +13 -0
- package/lib/chevre/service/payment/movieTicket/getCredentials.js +45 -0
- package/lib/chevre/service/payment/movieTicket/validation.d.ts +15 -0
- package/lib/chevre/service/{assetTransaction/pay → payment}/movieTicket/validation.js +8 -7
- package/lib/chevre/service/payment/movieTicket.d.ts +10 -22
- package/lib/chevre/service/payment/movieTicket.js +15 -210
- package/lib/chevre/service/permit.d.ts +5 -1
- package/lib/chevre/service/permit.js +18 -11
- package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +25 -53
- package/lib/chevre/service/task/aggregateScreeningEvent.js +2 -0
- package/lib/chevre/service/transaction/moneyTransfer.js +0 -1
- package/lib/chevre/service/transaction/orderProgramMembership.js +5 -6
- package/lib/chevre/settings.d.ts +4 -0
- package/lib/chevre/settings.js +8 -2
- package/package.json +3 -3
- package/example/src/chevre/migrateAccountTitleAdditionalProperties.ts +0 -157
- package/lib/chevre/service/assetTransaction/pay/movieTicket/validation.d.ts +0 -14
- package/lib/chevre/service/task/deleteAuthorization.d.ts +0 -6
- package/lib/chevre/service/task/deleteAuthorization.js +0 -29
|
@@ -30,5 +30,16 @@ export declare class MongoRepository {
|
|
|
30
30
|
id: string;
|
|
31
31
|
};
|
|
32
32
|
}): Promise<void>;
|
|
33
|
+
deleteUnnecessaryMovieTicketTypeChargePriceSpecs(params: {
|
|
34
|
+
project?: {
|
|
35
|
+
id?: string;
|
|
36
|
+
};
|
|
37
|
+
}): Promise<{
|
|
38
|
+
ok?: number | undefined;
|
|
39
|
+
n?: number | undefined;
|
|
40
|
+
} & {
|
|
41
|
+
deletedCount?: number | undefined;
|
|
42
|
+
}>;
|
|
33
43
|
getCursor(conditions: any, projection: any): import("mongoose").QueryCursor<any>;
|
|
44
|
+
reIndex(): Promise<any>;
|
|
34
45
|
}
|
|
@@ -32,37 +32,23 @@ class MongoRepository {
|
|
|
32
32
|
}
|
|
33
33
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
34
34
|
static CREATE_MONGO_CONDITIONS(params) {
|
|
35
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
35
36
|
const andConditions = [];
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (params.project.id !== undefined && params.project.id !== null) {
|
|
40
|
-
if (typeof params.project.id.$eq === 'string') {
|
|
41
|
-
andConditions.push({
|
|
42
|
-
'project.id': {
|
|
43
|
-
$eq: params.project.id.$eq
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
}
|
|
37
|
+
const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
38
|
+
if (typeof projectIdEq === 'string') {
|
|
39
|
+
andConditions.push({ 'project.id': { $eq: projectIdEq } });
|
|
48
40
|
}
|
|
49
41
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
50
42
|
/* istanbul ignore else */
|
|
51
43
|
if (params.id !== undefined && params.id !== null) {
|
|
52
44
|
if (typeof params.id.$eq === 'string') {
|
|
53
|
-
andConditions.push({
|
|
54
|
-
_id: {
|
|
55
|
-
$eq: params.id.$eq
|
|
56
|
-
}
|
|
57
|
-
});
|
|
45
|
+
andConditions.push({ _id: { $eq: params.id.$eq } });
|
|
58
46
|
}
|
|
59
47
|
}
|
|
60
48
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
61
49
|
/* istanbul ignore else */
|
|
62
50
|
if (params.typeOf !== undefined) {
|
|
63
|
-
andConditions.push({
|
|
64
|
-
typeOf: params.typeOf
|
|
65
|
-
});
|
|
51
|
+
andConditions.push({ typeOf: params.typeOf });
|
|
66
52
|
}
|
|
67
53
|
if (params.appliesToCategoryCode !== undefined && params.appliesToCategoryCode !== null) {
|
|
68
54
|
if (params.appliesToCategoryCode.$elemMatch !== undefined && params.appliesToCategoryCode.$elemMatch !== null) {
|
|
@@ -122,15 +108,23 @@ class MongoRepository {
|
|
|
122
108
|
}
|
|
123
109
|
});
|
|
124
110
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
111
|
+
const appliesToMovieTicketServiceTypeIn = (_c = params.appliesToMovieTicket) === null || _c === void 0 ? void 0 : _c.serviceTypes;
|
|
112
|
+
if (Array.isArray(appliesToMovieTicketServiceTypeIn)) {
|
|
113
|
+
andConditions.push({
|
|
114
|
+
'appliesToMovieTicket.serviceType': {
|
|
115
|
+
$exists: true,
|
|
116
|
+
$in: appliesToMovieTicketServiceTypeIn
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
const appliesToMovieTicketServiceOutputTypeOfEq = (_f = (_e = (_d = params.appliesToMovieTicket) === null || _d === void 0 ? void 0 : _d.serviceOutput) === null || _e === void 0 ? void 0 : _e.typeOf) === null || _f === void 0 ? void 0 : _f.$eq;
|
|
121
|
+
if (typeof appliesToMovieTicketServiceOutputTypeOfEq === 'string') {
|
|
122
|
+
andConditions.push({
|
|
123
|
+
'appliesToMovieTicket.serviceOutput.typeOf': {
|
|
124
|
+
$exists: true,
|
|
125
|
+
$eq: appliesToMovieTicketServiceOutputTypeOfEq
|
|
126
|
+
}
|
|
127
|
+
});
|
|
134
128
|
}
|
|
135
129
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
136
130
|
/* istanbul ignore else */
|
|
@@ -152,45 +146,12 @@ class MongoRepository {
|
|
|
152
146
|
}
|
|
153
147
|
});
|
|
154
148
|
}
|
|
149
|
+
const priceEq = (_g = params.price) === null || _g === void 0 ? void 0 : _g.$eq;
|
|
150
|
+
if (typeof priceEq === 'number') {
|
|
151
|
+
andConditions.push({ price: { $eq: priceEq } });
|
|
152
|
+
}
|
|
155
153
|
return andConditions;
|
|
156
154
|
}
|
|
157
|
-
// public async countCompoundPriceSpecifications<T extends factory.priceSpecificationType>(
|
|
158
|
-
// params: factory.compoundPriceSpecification.ISearchConditions<T>
|
|
159
|
-
// ): Promise<number> {
|
|
160
|
-
// const conditions = MongoRepository.CREATE_COMPOUND_PRICE_SPECIFICATION_MONGO_CONDITIONS(params);
|
|
161
|
-
// return this.priceSpecificationModel.countDocuments(
|
|
162
|
-
// { $and: conditions }
|
|
163
|
-
// )
|
|
164
|
-
// .setOptions({ maxTimeMS: 10000 })
|
|
165
|
-
// .exec();
|
|
166
|
-
// }
|
|
167
|
-
// public async searchCompoundPriceSpecifications<T extends factory.priceSpecificationType>(
|
|
168
|
-
// params: factory.compoundPriceSpecification.ISearchConditions<T>
|
|
169
|
-
// ): Promise<factory.compoundPriceSpecification.IPriceSpecification<T>[]> {
|
|
170
|
-
// const conditions = MongoRepository.CREATE_COMPOUND_PRICE_SPECIFICATION_MONGO_CONDITIONS(params);
|
|
171
|
-
// const query = this.priceSpecificationModel.find(
|
|
172
|
-
// { $and: conditions },
|
|
173
|
-
// {
|
|
174
|
-
// __v: 0,
|
|
175
|
-
// createdAt: 0,
|
|
176
|
-
// updatedAt: 0
|
|
177
|
-
// }
|
|
178
|
-
// );
|
|
179
|
-
// // tslint:disable-next-line:no-single-line-block-comment
|
|
180
|
-
// /* istanbul ignore else */
|
|
181
|
-
// if (params.limit !== undefined && params.page !== undefined) {
|
|
182
|
-
// query.limit(params.limit)
|
|
183
|
-
// .skip(params.limit * (params.page - 1));
|
|
184
|
-
// }
|
|
185
|
-
// // tslint:disable-next-line:no-single-line-block-comment
|
|
186
|
-
// /* istanbul ignore else */
|
|
187
|
-
// if (params.sort !== undefined) {
|
|
188
|
-
// query.sort(params.sort);
|
|
189
|
-
// }
|
|
190
|
-
// return query.setOptions({ maxTimeMS: 10000 })
|
|
191
|
-
// .exec()
|
|
192
|
-
// .then((docs) => docs.map((doc) => doc.toObject()));
|
|
193
|
-
// }
|
|
194
155
|
count(params) {
|
|
195
156
|
return __awaiter(this, void 0, void 0, function* () {
|
|
196
157
|
const conditions = MongoRepository.CREATE_MONGO_CONDITIONS(params);
|
|
@@ -277,10 +238,27 @@ class MongoRepository {
|
|
|
277
238
|
.exec();
|
|
278
239
|
});
|
|
279
240
|
}
|
|
241
|
+
deleteUnnecessaryMovieTicketTypeChargePriceSpecs(params) {
|
|
242
|
+
var _a;
|
|
243
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
244
|
+
return this.priceSpecificationModel.deleteMany(Object.assign({ typeOf: { $eq: factory.priceSpecificationType.MovieTicketTypeChargeSpecification }, price: { $eq: 0 } }, (typeof ((_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === 'string')
|
|
245
|
+
? { 'project.id': { $eq: params.project.id } }
|
|
246
|
+
: undefined))
|
|
247
|
+
.exec();
|
|
248
|
+
});
|
|
249
|
+
}
|
|
280
250
|
getCursor(conditions, projection) {
|
|
281
251
|
return this.priceSpecificationModel.find(conditions, projection)
|
|
282
252
|
.sort({ price: factory.sortType.Ascending })
|
|
283
253
|
.cursor();
|
|
284
254
|
}
|
|
255
|
+
reIndex() {
|
|
256
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
257
|
+
// return this.priceSpecificationModel.collection.name;
|
|
258
|
+
return this.priceSpecificationModel.db.db.command({
|
|
259
|
+
reIndex: this.priceSpecificationModel.collection.name
|
|
260
|
+
});
|
|
261
|
+
});
|
|
262
|
+
}
|
|
285
263
|
}
|
|
286
264
|
exports.MongoRepository = MongoRepository;
|
|
@@ -55,6 +55,14 @@ export declare class MongoRepository {
|
|
|
55
55
|
id: string;
|
|
56
56
|
};
|
|
57
57
|
}): Promise<void>;
|
|
58
|
+
deleteByName(params: {
|
|
59
|
+
name: factory.taskName;
|
|
60
|
+
}): Promise<{
|
|
61
|
+
ok?: number | undefined;
|
|
62
|
+
n?: number | undefined;
|
|
63
|
+
} & {
|
|
64
|
+
deletedCount?: number | undefined;
|
|
65
|
+
}>;
|
|
58
66
|
aggregateTask(params: {
|
|
59
67
|
project?: {
|
|
60
68
|
id?: {
|
package/lib/chevre/repo/task.js
CHANGED
|
@@ -29,9 +29,13 @@ class MongoRepository {
|
|
|
29
29
|
}
|
|
30
30
|
// tslint:disable-next-line:max-func-body-length
|
|
31
31
|
static CREATE_MONGO_CONDITIONS(params) {
|
|
32
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
32
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
33
33
|
const andConditions = [];
|
|
34
|
-
const
|
|
34
|
+
const idEq = (_a = params.id) === null || _a === void 0 ? void 0 : _a.$eq;
|
|
35
|
+
if (typeof idEq === 'string') {
|
|
36
|
+
andConditions.push({ _id: { $eq: idEq } });
|
|
37
|
+
}
|
|
38
|
+
const projectIdEq = (_c = (_b = params.project) === null || _b === void 0 ? void 0 : _b.id) === null || _c === void 0 ? void 0 : _c.$eq;
|
|
35
39
|
if (typeof projectIdEq === 'string') {
|
|
36
40
|
andConditions.push({ 'project.id': { $eq: projectIdEq } });
|
|
37
41
|
}
|
|
@@ -39,11 +43,11 @@ class MongoRepository {
|
|
|
39
43
|
andConditions.push({ name: { $eq: params.name } });
|
|
40
44
|
}
|
|
41
45
|
else {
|
|
42
|
-
const nameIn = (
|
|
46
|
+
const nameIn = (_d = params.name) === null || _d === void 0 ? void 0 : _d.$in;
|
|
43
47
|
if (Array.isArray(nameIn)) {
|
|
44
48
|
andConditions.push({ name: { $in: nameIn } });
|
|
45
49
|
}
|
|
46
|
-
const nameNin = (
|
|
50
|
+
const nameNin = (_e = params.name) === null || _e === void 0 ? void 0 : _e.$nin;
|
|
47
51
|
if (Array.isArray(nameNin)) {
|
|
48
52
|
andConditions.push({ name: { $nin: nameNin } });
|
|
49
53
|
}
|
|
@@ -89,7 +93,7 @@ class MongoRepository {
|
|
|
89
93
|
}
|
|
90
94
|
});
|
|
91
95
|
}
|
|
92
|
-
const dateAbortedGte = (
|
|
96
|
+
const dateAbortedGte = (_f = params.dateAborted) === null || _f === void 0 ? void 0 : _f.$gte;
|
|
93
97
|
if (dateAbortedGte instanceof Date) {
|
|
94
98
|
andConditions.push({
|
|
95
99
|
dateAborted: {
|
|
@@ -98,7 +102,7 @@ class MongoRepository {
|
|
|
98
102
|
}
|
|
99
103
|
});
|
|
100
104
|
}
|
|
101
|
-
const dateAbortedLte = (
|
|
105
|
+
const dateAbortedLte = (_g = params.dateAborted) === null || _g === void 0 ? void 0 : _g.$lte;
|
|
102
106
|
if (dateAbortedLte instanceof Date) {
|
|
103
107
|
andConditions.push({
|
|
104
108
|
dateAborted: {
|
|
@@ -107,7 +111,7 @@ class MongoRepository {
|
|
|
107
111
|
}
|
|
108
112
|
});
|
|
109
113
|
}
|
|
110
|
-
const objectTransactionNumberEq = (
|
|
114
|
+
const objectTransactionNumberEq = (_k = (_j = (_h = params.data) === null || _h === void 0 ? void 0 : _h.object) === null || _j === void 0 ? void 0 : _j.transactionNumber) === null || _k === void 0 ? void 0 : _k.$eq;
|
|
111
115
|
if (typeof objectTransactionNumberEq === 'string') {
|
|
112
116
|
andConditions.push({
|
|
113
117
|
'data.object.transactionNumber': {
|
|
@@ -116,7 +120,7 @@ class MongoRepository {
|
|
|
116
120
|
}
|
|
117
121
|
});
|
|
118
122
|
}
|
|
119
|
-
const objectPurposeIdEq = (
|
|
123
|
+
const objectPurposeIdEq = (_o = (_m = (_l = params.data) === null || _l === void 0 ? void 0 : _l.purpose) === null || _m === void 0 ? void 0 : _m.id) === null || _o === void 0 ? void 0 : _o.$eq;
|
|
120
124
|
if (typeof objectPurposeIdEq === 'string') {
|
|
121
125
|
andConditions.push({
|
|
122
126
|
'data.purpose.id': {
|
|
@@ -125,7 +129,7 @@ class MongoRepository {
|
|
|
125
129
|
}
|
|
126
130
|
});
|
|
127
131
|
}
|
|
128
|
-
const objectPurposeOrderNumberEq = (
|
|
132
|
+
const objectPurposeOrderNumberEq = (_r = (_q = (_p = params.data) === null || _p === void 0 ? void 0 : _p.purpose) === null || _q === void 0 ? void 0 : _q.orderNumber) === null || _r === void 0 ? void 0 : _r.$eq;
|
|
129
133
|
if (typeof objectPurposeOrderNumberEq === 'string') {
|
|
130
134
|
andConditions.push({
|
|
131
135
|
'data.purpose.orderNumber': {
|
|
@@ -306,6 +310,14 @@ class MongoRepository {
|
|
|
306
310
|
.exec();
|
|
307
311
|
});
|
|
308
312
|
}
|
|
313
|
+
deleteByName(params) {
|
|
314
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
315
|
+
return this.taskModel.deleteMany({
|
|
316
|
+
name: { $eq: params.name }
|
|
317
|
+
})
|
|
318
|
+
.exec();
|
|
319
|
+
});
|
|
320
|
+
}
|
|
309
321
|
aggregateTask(params) {
|
|
310
322
|
return __awaiter(this, void 0, void 0, function* () {
|
|
311
323
|
const statuses = yield Promise.all([
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { MongoRepository as EventRepo } from '../../../repo/event';
|
|
2
2
|
import { RedisRepository as EventAvailabilityRepo } from '../../../repo/itemAvailability/screeningEvent';
|
|
3
3
|
import { MongoRepository as OfferRepo } from '../../../repo/offer';
|
|
4
|
+
import { MongoRepository as OfferCatalogRepo } from '../../../repo/offerCatalog';
|
|
4
5
|
import { MongoRepository as PlaceRepo } from '../../../repo/place';
|
|
5
6
|
import { MongoRepository as ProductRepo } from '../../../repo/product';
|
|
6
7
|
import { MongoRepository as ProjectRepo } from '../../../repo/project';
|
|
@@ -12,6 +13,7 @@ export declare type IAggregateScreeningEventOperation<T> = (repos: {
|
|
|
12
13
|
event: EventRepo;
|
|
13
14
|
eventAvailability: EventAvailabilityRepo;
|
|
14
15
|
offer: OfferRepo;
|
|
16
|
+
offerCatalog: OfferCatalogRepo;
|
|
15
17
|
offerRateLimit: OfferRateLimitRepo;
|
|
16
18
|
place: PlaceRepo;
|
|
17
19
|
product: ProductRepo;
|
|
@@ -17,6 +17,7 @@ const createDebug = require("debug");
|
|
|
17
17
|
const moment = require("moment-timezone");
|
|
18
18
|
const event_1 = require("../../../repo/event");
|
|
19
19
|
const factory = require("../../../factory");
|
|
20
|
+
const settings_1 = require("../../../settings");
|
|
20
21
|
const debug = createDebug('chevre-domain:service');
|
|
21
22
|
/**
|
|
22
23
|
* イベントデータをID指定で集計する
|
|
@@ -28,31 +29,34 @@ function aggregateScreeningEvent(params) {
|
|
|
28
29
|
// const event = await repos.event.findById<factory.eventType.ScreeningEvent | factory.eventType.Event>(params);
|
|
29
30
|
const event = yield repos.event.findMinimizedIndividualEventById(params);
|
|
30
31
|
let aggregatingEvents = [event];
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
.
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
32
|
+
// プロジェクト限定(2023-02-22~)
|
|
33
|
+
if (settings_1.settings.useOfferRateLimitProjects.includes(event.project.id)) {
|
|
34
|
+
const availableOffers = yield findOffers({ event })(repos);
|
|
35
|
+
const offerRateLimitExists = availableOffers.some((o) => { var _a; return typeof ((_a = o.validRateLimit) === null || _a === void 0 ? void 0 : _a.scope) === 'string'; });
|
|
36
|
+
if (offerRateLimitExists) {
|
|
37
|
+
// 同location、かつ同時間帯、のイベントに関しても集計する(ttts暫定対応)
|
|
38
|
+
const startFrom = moment(event.startDate)
|
|
39
|
+
.startOf('hour')
|
|
40
|
+
.toDate();
|
|
41
|
+
const startThrough = moment(startFrom)
|
|
42
|
+
.add(1, 'hour')
|
|
43
|
+
.add(-1, 'second')
|
|
44
|
+
.toDate();
|
|
45
|
+
// 取得属性最適化(2023-01-25~)
|
|
46
|
+
aggregatingEvents = yield repos.event.search({
|
|
47
|
+
limit: 100,
|
|
48
|
+
page: 1,
|
|
49
|
+
project: { id: { $eq: event.project.id } },
|
|
50
|
+
typeOf: event.typeOf,
|
|
51
|
+
eventStatuses: [factory.eventStatusType.EventScheduled],
|
|
52
|
+
startFrom: startFrom,
|
|
53
|
+
startThrough: startThrough,
|
|
54
|
+
location: { branchCode: { $eq: event.location.branchCode } }
|
|
55
|
+
}, event_1.PROJECTION_MINIMIZED_EVENT);
|
|
56
|
+
// ID指定されたイベントについてはEventScheduledでなくても集計したいので、集計対象を調整
|
|
57
|
+
aggregatingEvents = aggregatingEvents.filter((e) => e.id !== event.id);
|
|
58
|
+
aggregatingEvents = [event, ...aggregatingEvents];
|
|
59
|
+
}
|
|
56
60
|
}
|
|
57
61
|
debug(aggregatingEvents.length, 'aggregatingEvents found', aggregatingEvents.map((e) => e.id));
|
|
58
62
|
for (const aggregatingEvent of aggregatingEvents) {
|
|
@@ -79,20 +83,6 @@ function aggregateByEvent(params) {
|
|
|
79
83
|
branchCode: { $eq: event.location.branchCode },
|
|
80
84
|
containedInPlace: { id: { $eq: movieTheaterId } }
|
|
81
85
|
});
|
|
82
|
-
// 施設取得
|
|
83
|
-
// const movieTheater = await findLocation(params)(repos);
|
|
84
|
-
// // 万が一施設が存在しなければ処理終了
|
|
85
|
-
// if (movieTheater === undefined) {
|
|
86
|
-
// return;
|
|
87
|
-
// }
|
|
88
|
-
// const screeningRoom = <factory.place.screeningRoom.IPlace | undefined>
|
|
89
|
-
// movieTheater.containsPlace.find((p) => p.branchCode === event.location.branchCode);
|
|
90
|
-
// if (screeningRoom === undefined) {
|
|
91
|
-
// // 基本的にありえないはずだが、万が一スクリーンが見つからなければcapacityは0のまま
|
|
92
|
-
// // tslint:disable-next-line:no-console
|
|
93
|
-
// console.error(new Error(`Screening room not found. branchCode: ${event.location.branchCode}`));
|
|
94
|
-
// return;
|
|
95
|
-
// }
|
|
96
86
|
// 予約集計
|
|
97
87
|
const { maximumAttendeeCapacity, remainingAttendeeCapacity, aggregateReservation } = yield aggregateReservationByEvent({
|
|
98
88
|
aggregateDate: now,
|
|
@@ -100,7 +90,8 @@ function aggregateByEvent(params) {
|
|
|
100
90
|
screeningRoom: screeningRoom
|
|
101
91
|
})(repos);
|
|
102
92
|
// オファーごとの集計
|
|
103
|
-
|
|
93
|
+
let aggregateOffer;
|
|
94
|
+
aggregateOffer = yield aggregateOfferByEvent({
|
|
104
95
|
aggregateDate: now,
|
|
105
96
|
event: Object.assign(Object.assign({}, event), { maximumAttendeeCapacity,
|
|
106
97
|
remainingAttendeeCapacity }),
|
|
@@ -109,11 +100,9 @@ function aggregateByEvent(params) {
|
|
|
109
100
|
debug('offers aggregated', aggregateOffer);
|
|
110
101
|
// 値がundefinedの場合に更新しないように注意
|
|
111
102
|
const update = {
|
|
112
|
-
$set: Object.assign(Object.assign(Object.assign(Object.assign({ updatedAt: new Date(), // $setオブジェクトが空だとMongoエラーになるので
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
aggregateOffer }, (maximumAttendeeCapacity !== undefined) ? { maximumAttendeeCapacity: maximumAttendeeCapacity } : undefined), (remainingAttendeeCapacity !== undefined) ? { remainingAttendeeCapacity: remainingAttendeeCapacity } : undefined), (aggregateReservation.checkInCount !== undefined) ? { checkInCount: aggregateReservation.checkInCount } : undefined), (aggregateReservation.attendeeCount !== undefined) ? { attendeeCount: aggregateReservation.attendeeCount } : undefined),
|
|
116
|
-
$unset: Object.assign(Object.assign({ noExistingAttributeName: 1 }, (maximumAttendeeCapacity === undefined) ? { maximumAttendeeCapacity: '' } : undefined), (remainingAttendeeCapacity === undefined) ? { remainingAttendeeCapacity: '' } : undefined)
|
|
103
|
+
$set: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ updatedAt: new Date(), // $setオブジェクトが空だとMongoエラーになるので
|
|
104
|
+
aggregateReservation }, (typeof (aggregateOffer === null || aggregateOffer === void 0 ? void 0 : aggregateOffer.typeOf) === 'string') ? { aggregateOffer: aggregateOffer } : undefined), (maximumAttendeeCapacity !== undefined) ? { maximumAttendeeCapacity: maximumAttendeeCapacity } : undefined), (remainingAttendeeCapacity !== undefined) ? { remainingAttendeeCapacity: remainingAttendeeCapacity } : undefined), (aggregateReservation.checkInCount !== undefined) ? { checkInCount: aggregateReservation.checkInCount } : undefined), (aggregateReservation.attendeeCount !== undefined) ? { attendeeCount: aggregateReservation.attendeeCount } : undefined),
|
|
105
|
+
$unset: Object.assign(Object.assign(Object.assign({ noExistingAttributeName: 1 }, (typeof (aggregateOffer === null || aggregateOffer === void 0 ? void 0 : aggregateOffer.typeOf) !== 'string') ? { aggregateOffer: '' } : undefined), (maximumAttendeeCapacity === undefined) ? { maximumAttendeeCapacity: '' } : undefined), (remainingAttendeeCapacity === undefined) ? { remainingAttendeeCapacity: '' } : undefined)
|
|
117
106
|
};
|
|
118
107
|
debug('update:', update);
|
|
119
108
|
// 保管
|
|
@@ -125,37 +114,6 @@ function aggregateByEvent(params) {
|
|
|
125
114
|
});
|
|
126
115
|
}
|
|
127
116
|
exports.aggregateByEvent = aggregateByEvent;
|
|
128
|
-
/**
|
|
129
|
-
* イベントロケーション取得
|
|
130
|
-
* NotFoundエラーをハンドリングする
|
|
131
|
-
*/
|
|
132
|
-
// function findLocation(params: {
|
|
133
|
-
// event: factory.event.screeningEvent.IEvent | factory.event.event.IEvent;
|
|
134
|
-
// }) {
|
|
135
|
-
// return async (repos: {
|
|
136
|
-
// place: PlaceRepo;
|
|
137
|
-
// }): Promise<factory.place.movieTheater.IPlace | undefined> => {
|
|
138
|
-
// let movieTheater: factory.place.movieTheater.IPlace | undefined;
|
|
139
|
-
// try {
|
|
140
|
-
// if (params.event.typeOf === factory.eventType.ScreeningEvent) {
|
|
141
|
-
// movieTheater = await repos.place.findById({ id: params.event.superEvent.location.id });
|
|
142
|
-
// } else {
|
|
143
|
-
// const movieTheaterId: string =
|
|
144
|
-
// String(params.event.offers?.itemOffered.availableChannel.serviceLocation.containedInPlace.id);
|
|
145
|
-
// movieTheater = await repos.place.findById({ id: movieTheaterId });
|
|
146
|
-
// }
|
|
147
|
-
// } catch (error) {
|
|
148
|
-
// let throwsError = true;
|
|
149
|
-
// if (error instanceof factory.errors.NotFound) {
|
|
150
|
-
// throwsError = false;
|
|
151
|
-
// }
|
|
152
|
-
// if (throwsError) {
|
|
153
|
-
// throw error;
|
|
154
|
-
// }
|
|
155
|
-
// }
|
|
156
|
-
// return movieTheater;
|
|
157
|
-
// };
|
|
158
|
-
// }
|
|
159
117
|
/**
|
|
160
118
|
* 集計後アクション
|
|
161
119
|
*/
|
|
@@ -172,26 +130,36 @@ function reservedSeatsAvailable(params) {
|
|
|
172
130
|
function aggregateOfferByEvent(params) {
|
|
173
131
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
174
132
|
var _a, _b, _c;
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
const
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
133
|
+
// プロジェクト限定(2023-02-22~)
|
|
134
|
+
if (settings_1.settings.useAggregateOfferProjects.includes(params.event.project.id)) {
|
|
135
|
+
const availableOffers = yield findOffers(params)(repos);
|
|
136
|
+
// オファーごとの予約集計
|
|
137
|
+
const offersWithAggregateReservation = [];
|
|
138
|
+
for (const o of availableOffers) {
|
|
139
|
+
const { maximumAttendeeCapacity, remainingAttendeeCapacity, aggregateReservation } = yield aggregateReservationByOffer({
|
|
140
|
+
aggregateDate: params.aggregateDate,
|
|
141
|
+
event: params.event,
|
|
142
|
+
screeningRoom: params.screeningRoom,
|
|
143
|
+
offer: o
|
|
144
|
+
})(repos);
|
|
145
|
+
offersWithAggregateReservation.push(Object.assign(Object.assign(Object.assign({ typeOf: o.typeOf, id: o.id, identifier: o.identifier, aggregateReservation: aggregateReservation, name: {
|
|
146
|
+
en: (_a = o.name) === null || _a === void 0 ? void 0 : _a.en,
|
|
147
|
+
ja: (_b = o.name) === null || _b === void 0 ? void 0 : _b.ja
|
|
148
|
+
} }, (typeof maximumAttendeeCapacity === 'number') ? { maximumAttendeeCapacity } : undefined), (typeof remainingAttendeeCapacity === 'number') ? { remainingAttendeeCapacity } : undefined), (typeof ((_c = o.category) === null || _c === void 0 ? void 0 : _c.codeValue) === 'string') ? { category: o.category } : undefined));
|
|
149
|
+
}
|
|
150
|
+
return {
|
|
151
|
+
typeOf: factory.offerType.AggregateOffer,
|
|
152
|
+
offerCount: availableOffers.length,
|
|
153
|
+
offers: offersWithAggregateReservation
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
const { offerCount } = yield calculateOfferCount({ event: params.event })(repos);
|
|
158
|
+
return {
|
|
159
|
+
typeOf: factory.offerType.AggregateOffer,
|
|
160
|
+
offerCount
|
|
161
|
+
};
|
|
189
162
|
}
|
|
190
|
-
return {
|
|
191
|
-
typeOf: factory.offerType.AggregateOffer,
|
|
192
|
-
offerCount: availableOffers.length,
|
|
193
|
-
offers: offersWithAggregateReservation
|
|
194
|
-
};
|
|
195
163
|
});
|
|
196
164
|
}
|
|
197
165
|
/**
|
|
@@ -208,10 +176,12 @@ function findOffers(params) {
|
|
|
208
176
|
if (typeof ((_a = eventOffers === null || eventOffers === void 0 ? void 0 : eventOffers.itemOffered) === null || _a === void 0 ? void 0 : _a.id) === 'string') {
|
|
209
177
|
const eventService = yield repos.product.findById({ id: eventOffers.itemOffered.id });
|
|
210
178
|
if (typeof ((_b = eventService.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.id) === 'string') {
|
|
211
|
-
|
|
179
|
+
const findOffersByOfferCatalogIdResult = yield repos.offer.findOffersByOfferCatalogId({
|
|
212
180
|
offerCatalog: { id: eventService.hasOfferCatalog.id },
|
|
181
|
+
excludeAppliesToMovieTicket: false,
|
|
213
182
|
sort: false // ソート不要(2023-01-27~)
|
|
214
183
|
});
|
|
184
|
+
availableOffers = findOffersByOfferCatalogIdResult.offers;
|
|
215
185
|
}
|
|
216
186
|
}
|
|
217
187
|
else {
|
|
@@ -231,6 +201,33 @@ function findOffers(params) {
|
|
|
231
201
|
return availableOffers;
|
|
232
202
|
});
|
|
233
203
|
}
|
|
204
|
+
function calculateOfferCount(params) {
|
|
205
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
206
|
+
var _a, _b, _c;
|
|
207
|
+
let offerCount = 0;
|
|
208
|
+
try {
|
|
209
|
+
const eventOffers = params.event.offers;
|
|
210
|
+
if (typeof ((_a = eventOffers === null || eventOffers === void 0 ? void 0 : eventOffers.itemOffered) === null || _a === void 0 ? void 0 : _a.id) === 'string') {
|
|
211
|
+
const eventService = yield repos.product.findById({ id: eventOffers.itemOffered.id });
|
|
212
|
+
if (typeof ((_b = eventService.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.id) === 'string') {
|
|
213
|
+
const catalogs = yield repos.offerCatalog.search({
|
|
214
|
+
limit: 1,
|
|
215
|
+
page: 1,
|
|
216
|
+
id: { $in: [eventService.hasOfferCatalog.id] }
|
|
217
|
+
});
|
|
218
|
+
const numberOfItems = (_c = catalogs.shift()) === null || _c === void 0 ? void 0 : _c.numberOfItems;
|
|
219
|
+
if (typeof numberOfItems === 'number') {
|
|
220
|
+
offerCount = numberOfItems;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
catch (error) {
|
|
226
|
+
throw error;
|
|
227
|
+
}
|
|
228
|
+
return { offerCount };
|
|
229
|
+
});
|
|
230
|
+
}
|
|
234
231
|
function aggregateReservationByOffer(params) {
|
|
235
232
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
236
233
|
let reservationCount4offer;
|
|
@@ -91,10 +91,12 @@ function findOffers(params) {
|
|
|
91
91
|
if (typeof ((_a = eventOffers === null || eventOffers === void 0 ? void 0 : eventOffers.itemOffered) === null || _a === void 0 ? void 0 : _a.id) === 'string') {
|
|
92
92
|
const eventService = yield repos.product.findById({ id: eventOffers.itemOffered.id });
|
|
93
93
|
if (typeof ((_b = eventService.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.id) === 'string') {
|
|
94
|
-
|
|
94
|
+
const findOffersByOfferCatalogIdResult = yield repos.offer.findOffersByOfferCatalogId({
|
|
95
95
|
offerCatalog: { id: eventService.hasOfferCatalog.id },
|
|
96
|
+
excludeAppliesToMovieTicket: false,
|
|
96
97
|
sort: false // ソート不要(2023-01-27~)
|
|
97
98
|
});
|
|
99
|
+
availableOffers = findOffersByOfferCatalogIdResult.offers;
|
|
98
100
|
}
|
|
99
101
|
}
|
|
100
102
|
else {
|
|
@@ -62,20 +62,29 @@ function start(params) {
|
|
|
62
62
|
recipient: params.recipient,
|
|
63
63
|
object: Object.assign(Object.assign({ amount,
|
|
64
64
|
fromLocation,
|
|
65
|
-
toLocation, pendingTransaction: Object.assign({ typeOf: transactionType,
|
|
65
|
+
toLocation, pendingTransaction: Object.assign({ typeOf: transactionType, transactionNumber: transactionNumber }, (typeof params.identifier === 'string') ? { identifier: params.identifier } : undefined) }, (typeof params.object.description === 'string') ? { description: params.object.description } : {}), { force: params.object.force === true }),
|
|
66
66
|
expires: params.expires
|
|
67
67
|
};
|
|
68
68
|
// 取引開始
|
|
69
69
|
let transaction;
|
|
70
70
|
try {
|
|
71
71
|
transaction = yield repos.assetTransaction.start(startParams);
|
|
72
|
-
const pendingTransaction =
|
|
73
|
-
yield
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
72
|
+
// const pendingTransaction = await authorizeAccount({ transaction })(repos);
|
|
73
|
+
yield authorizeAccount({ transaction })(repos);
|
|
74
|
+
// 更新不要(2023-02-20~)
|
|
75
|
+
// await repos.assetTransaction.findByIdAndUpdate<factory.assetTransactionType.MoneyTransfer>({
|
|
76
|
+
// id: transaction.id,
|
|
77
|
+
// update: {
|
|
78
|
+
// 'object.pendingTransaction': {
|
|
79
|
+
// typeOf: pendingTransaction.typeOf,
|
|
80
|
+
// id: pendingTransaction.id,
|
|
81
|
+
// transactionNumber: pendingTransaction.transactionNumber,
|
|
82
|
+
// ...(typeof pendingTransaction.identifier === 'string')
|
|
83
|
+
// ? { identifier: pendingTransaction.identifier }
|
|
84
|
+
// : undefined
|
|
85
|
+
// }
|
|
86
|
+
// }
|
|
87
|
+
// });
|
|
79
88
|
}
|
|
80
89
|
catch (error) {
|
|
81
90
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
@@ -113,13 +122,12 @@ function authorizeAccount(params) {
|
|
|
113
122
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
114
123
|
var _a, _b, _c;
|
|
115
124
|
const transaction = params.transaction;
|
|
116
|
-
let pendingTransaction;
|
|
117
125
|
const fromLocation = transaction.object.fromLocation;
|
|
118
126
|
const toLocation = transaction.object.toLocation;
|
|
119
127
|
if (typeof ((_a = transaction.object.pendingTransaction) === null || _a === void 0 ? void 0 : _a.typeOf) !== 'string') {
|
|
120
128
|
throw new factory.errors.NotFound('transaction.object.pendingTransaction.typeOf');
|
|
121
129
|
}
|
|
122
|
-
|
|
130
|
+
yield MoneyTransferService.authorize({
|
|
123
131
|
typeOf: transaction.object.pendingTransaction.typeOf,
|
|
124
132
|
identifier: transaction.object.pendingTransaction.identifier,
|
|
125
133
|
transactionNumber: transaction.object.pendingTransaction.transactionNumber,
|
|
@@ -143,7 +151,7 @@ function authorizeAccount(params) {
|
|
|
143
151
|
recipient: transaction.recipient,
|
|
144
152
|
purpose: { typeOf: transaction.typeOf, id: transaction.id }
|
|
145
153
|
})(repos);
|
|
146
|
-
return pendingTransaction;
|
|
154
|
+
// return pendingTransaction;
|
|
147
155
|
});
|
|
148
156
|
}
|
|
149
157
|
function fixMonetaryAmount(params, product) {
|
|
@@ -269,11 +269,10 @@ function processAuthorizeCreditCard(params, transaction, paymentServiceId) {
|
|
|
269
269
|
}
|
|
270
270
|
function processAuthorizeMovieTicket(params, transaction, paymentServiceId) {
|
|
271
271
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
272
|
-
|
|
273
|
-
const authorizeResult = yield MovieTicketPayment.authorize(params, transaction, paymentServiceId)(repos);
|
|
272
|
+
const { accountId, checkResult, payAction } = yield MovieTicketPayment.authorize(params, transaction, paymentServiceId)(repos);
|
|
274
273
|
return saveAuthorizeResult({
|
|
275
274
|
id: transaction.id,
|
|
276
|
-
update: Object.assign({ 'object.accountId':
|
|
275
|
+
update: Object.assign({ 'object.accountId': accountId, 'object.paymentMethod.accountId': accountId, 'object.payAction': payAction }, (checkResult !== undefined) ? { 'object.checkResult': checkResult } : undefined)
|
|
277
276
|
})(repos);
|
|
278
277
|
});
|
|
279
278
|
}
|