@chevre/domain 22.5.0-alpha.1 → 22.5.0-alpha.3
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/projectFields.ts +3 -3
- package/lib/chevre/repo/mongoose/schemas/offerCatalogItem.js +1 -1
- package/lib/chevre/repo/offerCatalog.d.ts +4 -2
- package/lib/chevre/repo/offerCatalog.js +39 -22
- package/lib/chevre/repo/offerCatalogItem.d.ts +3 -6
- package/lib/chevre/repo/offerCatalogItem.js +84 -45
- package/lib/chevre/repo/paymentService.js +0 -10
- package/lib/chevre/repo/product.d.ts +3 -0
- package/lib/chevre/repo/product.js +13 -2
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +8 -6
- package/lib/chevre/service/aggregation/event/findEventOffers.js +3 -2
- package/lib/chevre/service/offer/event/searchEventTicketOffers.js +38 -26
- package/lib/chevre/service/offer/product/searchProductOffers.js +4 -3
- package/lib/chevre/service/task/onResourceUpdated/onOfferCatalogUpdated.js +2 -2
- package/lib/chevre/service/task/onResourceUpdated/syncOfferCatalog.js +2 -2
- package/package.json +3 -3
- package/example/src/chevre/offerCatalog2offerCatalogItem.ts +0 -161
|
@@ -8,15 +8,15 @@ const project = { id: String(process.env.PROJECT_ID) };
|
|
|
8
8
|
async function main() {
|
|
9
9
|
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
10
10
|
|
|
11
|
-
const repo = await chevre.repository.
|
|
11
|
+
const repo = await chevre.repository.OfferCatalogItem.createInstance(mongoose.connection);
|
|
12
12
|
|
|
13
13
|
const docs = await repo.projectFields(
|
|
14
14
|
{
|
|
15
|
-
limit:
|
|
15
|
+
limit: 10,
|
|
16
16
|
page: 1,
|
|
17
17
|
project: { id: { $eq: project.id } }
|
|
18
18
|
},
|
|
19
|
-
['
|
|
19
|
+
['relatedOffer']
|
|
20
20
|
);
|
|
21
21
|
// tslint:disable-next-line:no-null-keyword
|
|
22
22
|
console.dir(docs, { depth: null });
|
|
@@ -30,8 +30,9 @@ export type IAggregatedOfferCatalog = Pick<factory.offerCatalog.IOfferCatalog, '
|
|
|
30
30
|
numberOfItems?: number;
|
|
31
31
|
itemListElementTypeOf: factory.offerType.Offer | 'OfferCatalog';
|
|
32
32
|
};
|
|
33
|
+
type IKeyOfProjection = 'name' | 'description' | 'project' | 'typeOf' | 'id' | 'identifier' | 'itemOffered' | 'additionalProperty' | 'numberOfItems' | 'itemListElementTypeOf' | 'dateSynced';
|
|
33
34
|
/**
|
|
34
|
-
*
|
|
35
|
+
* カタログリポジトリ
|
|
35
36
|
*/
|
|
36
37
|
export declare class OfferCatalogRepo {
|
|
37
38
|
private readonly offerCatalogModel;
|
|
@@ -105,7 +106,7 @@ export declare class OfferCatalogRepo {
|
|
|
105
106
|
};
|
|
106
107
|
};
|
|
107
108
|
}): Promise<import("mongoose").UpdateWriteOpResult | undefined>;
|
|
108
|
-
|
|
109
|
+
projectFields(params: factory.offerCatalog.ISearchConditions, inclusion: IKeyOfProjection[]): Promise<IAggregatedOfferCatalog[]>;
|
|
109
110
|
findItemListElementById(params: {
|
|
110
111
|
id: string;
|
|
111
112
|
project: {
|
|
@@ -155,3 +156,4 @@ export declare class OfferCatalogRepo {
|
|
|
155
156
|
_id: string;
|
|
156
157
|
}>>>;
|
|
157
158
|
}
|
|
159
|
+
export {};
|
|
@@ -23,8 +23,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
23
23
|
exports.OfferCatalogRepo = void 0;
|
|
24
24
|
const factory = require("../factory");
|
|
25
25
|
const offerCatalog_1 = require("./mongoose/schemas/offerCatalog");
|
|
26
|
+
const AVAILABLE_PROJECT_FIELDS = [
|
|
27
|
+
'name',
|
|
28
|
+
'description',
|
|
29
|
+
'project',
|
|
30
|
+
'typeOf',
|
|
31
|
+
'identifier',
|
|
32
|
+
'itemOffered',
|
|
33
|
+
'additionalProperty',
|
|
34
|
+
'numberOfItems',
|
|
35
|
+
'itemListElementTypeOf',
|
|
36
|
+
'dateSynced'
|
|
37
|
+
];
|
|
26
38
|
/**
|
|
27
|
-
*
|
|
39
|
+
* カタログリポジトリ
|
|
28
40
|
*/
|
|
29
41
|
class OfferCatalogRepo {
|
|
30
42
|
constructor(connection) {
|
|
@@ -294,39 +306,44 @@ class OfferCatalogRepo {
|
|
|
294
306
|
.exec();
|
|
295
307
|
});
|
|
296
308
|
}
|
|
297
|
-
|
|
309
|
+
projectFields(params, inclusion) {
|
|
298
310
|
var _a;
|
|
299
311
|
return __awaiter(this, void 0, void 0, function* () {
|
|
300
312
|
const conditions = OfferCatalogRepo.CREATE_MONGO_CONDITIONS(params);
|
|
301
313
|
const matchStages = conditions.map((condition) => {
|
|
302
314
|
return { $match: condition };
|
|
303
315
|
});
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
itemOffered: '$itemOffered',
|
|
317
|
-
additionalProperty: '$additionalProperty',
|
|
318
|
-
numberOfItems: {
|
|
316
|
+
let positiveProjectionFields = AVAILABLE_PROJECT_FIELDS;
|
|
317
|
+
if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
318
|
+
positiveProjectionFields = inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key));
|
|
319
|
+
}
|
|
320
|
+
else {
|
|
321
|
+
// throw new factory.errors.ArgumentNull('inclusion', 'inclusion must be specified');
|
|
322
|
+
}
|
|
323
|
+
const projection = Object.assign({ _id: 0, id: '$_id' }, Object.fromEntries(positiveProjectionFields.map((key) => {
|
|
324
|
+
let value;
|
|
325
|
+
switch (key) {
|
|
326
|
+
case 'numberOfItems':
|
|
327
|
+
value = {
|
|
319
328
|
$cond: {
|
|
320
329
|
if: { $isArray: '$itemListElement' },
|
|
321
330
|
then: { $size: '$itemListElement' },
|
|
322
331
|
else: 0
|
|
323
332
|
}
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
333
|
+
};
|
|
334
|
+
break;
|
|
335
|
+
case 'itemListElementTypeOf':
|
|
336
|
+
value = { $first: '$itemListElement.typeOf' };
|
|
337
|
+
break;
|
|
338
|
+
default:
|
|
339
|
+
value = 1;
|
|
329
340
|
}
|
|
341
|
+
return [key, value];
|
|
342
|
+
})));
|
|
343
|
+
const aggregate = this.offerCatalogModel.aggregate([
|
|
344
|
+
...(((_a = params.sort) === null || _a === void 0 ? void 0 : _a.identifier) !== undefined) ? [{ $sort: { identifier: params.sort.identifier } }] : [],
|
|
345
|
+
...matchStages,
|
|
346
|
+
{ $project: projection }
|
|
330
347
|
]);
|
|
331
348
|
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
332
349
|
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
@@ -29,12 +29,9 @@ export type IAggregatedOfferCatalog = Pick<factory.offerCatalog.IOfferCatalog, '
|
|
|
29
29
|
numberOfItems?: number;
|
|
30
30
|
itemListElementTypeOf: factory.offerType.Offer;
|
|
31
31
|
};
|
|
32
|
-
type
|
|
33
|
-
type IProjection = {
|
|
34
|
-
[key in KeyOfOfferCatalogItem]?: 0 | 1;
|
|
35
|
-
};
|
|
32
|
+
type IKeyOfProjection = 'name' | 'description' | 'project' | 'typeOf' | 'id' | 'identifier' | 'itemOffered' | 'additionalProperty' | 'numberOfItems' | 'itemListElementTypeOf' | 'dateSynced' | 'relatedOffer';
|
|
36
33
|
/**
|
|
37
|
-
*
|
|
34
|
+
* サブカタログリポジトリ
|
|
38
35
|
*/
|
|
39
36
|
export declare class OfferCatalogItemRepo {
|
|
40
37
|
private readonly offerCatalogItemModel;
|
|
@@ -93,7 +90,7 @@ export declare class OfferCatalogItemRepo {
|
|
|
93
90
|
};
|
|
94
91
|
}): Promise<void>;
|
|
95
92
|
count(params: Omit<factory.offerCatalog.ISearchConditions, 'limit' | 'page' | 'sort'>): Promise<number>;
|
|
96
|
-
|
|
93
|
+
projectFields(params: factory.offerCatalog.ISearchConditions, inclusion: IKeyOfProjection[]): Promise<IAggregatedOfferCatalog[]>;
|
|
97
94
|
findItemListElementById(params: {
|
|
98
95
|
id: string;
|
|
99
96
|
project: {
|
|
@@ -24,8 +24,21 @@ exports.OfferCatalogItemRepo = void 0;
|
|
|
24
24
|
const mongoose_1 = require("mongoose");
|
|
25
25
|
const factory = require("../factory");
|
|
26
26
|
const offerCatalogItem_1 = require("./mongoose/schemas/offerCatalogItem");
|
|
27
|
+
const AVAILABLE_PROJECT_FIELDS = [
|
|
28
|
+
'name',
|
|
29
|
+
'description',
|
|
30
|
+
'project',
|
|
31
|
+
'typeOf',
|
|
32
|
+
'identifier',
|
|
33
|
+
'itemOffered',
|
|
34
|
+
'additionalProperty',
|
|
35
|
+
'numberOfItems',
|
|
36
|
+
'itemListElementTypeOf',
|
|
37
|
+
'dateSynced',
|
|
38
|
+
'relatedOffer'
|
|
39
|
+
];
|
|
27
40
|
/**
|
|
28
|
-
*
|
|
41
|
+
* サブカタログリポジトリ
|
|
29
42
|
*/
|
|
30
43
|
class OfferCatalogItemRepo {
|
|
31
44
|
constructor(connection) {
|
|
@@ -248,61 +261,87 @@ class OfferCatalogItemRepo {
|
|
|
248
261
|
return (result.length > 0) ? result[0].numItems : 0;
|
|
249
262
|
});
|
|
250
263
|
}
|
|
251
|
-
|
|
264
|
+
projectFields(params, inclusion) {
|
|
252
265
|
var _a;
|
|
253
266
|
return __awaiter(this, void 0, void 0, function* () {
|
|
254
267
|
const conditions = OfferCatalogItemRepo.CREATE_MONGO_CONDITIONS(params);
|
|
255
268
|
const matchStages = conditions.map((condition) => {
|
|
256
269
|
return { $match: condition };
|
|
257
270
|
});
|
|
258
|
-
let
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
description: '$description',
|
|
262
|
-
project: '$project',
|
|
263
|
-
typeOf: '$typeOf',
|
|
264
|
-
id: { $toString: '$_id' },
|
|
265
|
-
identifier: '$identifier',
|
|
266
|
-
itemOffered: '$itemOffered',
|
|
267
|
-
additionalProperty: '$additionalProperty',
|
|
268
|
-
relatedOffer: '$relatedOffer',
|
|
269
|
-
numberOfItems: {
|
|
270
|
-
$cond: {
|
|
271
|
-
if: { $isArray: '$itemListElement' },
|
|
272
|
-
then: { $size: '$itemListElement' },
|
|
273
|
-
else: 0
|
|
274
|
-
}
|
|
275
|
-
},
|
|
276
|
-
itemListElementTypeOf: { $first: '$itemListElement.typeOf' },
|
|
277
|
-
dateSynced: '$dateSynced'
|
|
278
|
-
};
|
|
279
|
-
const positiveProjectionFields = Object.keys(projection)
|
|
280
|
-
.filter((key) => projection[key] !== 0);
|
|
281
|
-
const negativeProjectionFields = Object.keys(projection)
|
|
282
|
-
.filter((key) => projection[key] === 0);
|
|
283
|
-
if (positiveProjectionFields.length > 0) {
|
|
284
|
-
projectStage = {
|
|
285
|
-
_id: 0,
|
|
286
|
-
id: { $toString: '$_id' }
|
|
287
|
-
};
|
|
288
|
-
positiveProjectionFields.forEach((field) => {
|
|
289
|
-
if (field !== '_id' && field !== 'id') {
|
|
290
|
-
projectStage[field] = `$${field}`;
|
|
291
|
-
}
|
|
292
|
-
});
|
|
271
|
+
let positiveProjectionFields = AVAILABLE_PROJECT_FIELDS;
|
|
272
|
+
if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
273
|
+
positiveProjectionFields = inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key));
|
|
293
274
|
}
|
|
294
|
-
else
|
|
295
|
-
|
|
296
|
-
if (projectStage[field] !== undefined && projectStage[field] !== null) {
|
|
297
|
-
// tslint:disable-next-line:no-dynamic-delete
|
|
298
|
-
delete projectStage[field];
|
|
299
|
-
}
|
|
300
|
-
});
|
|
275
|
+
else {
|
|
276
|
+
// throw new factory.errors.ArgumentNull('inclusion', 'inclusion must be specified');
|
|
301
277
|
}
|
|
278
|
+
const projection = Object.assign({ _id: 0, id: { $toString: '$_id' } }, Object.fromEntries(positiveProjectionFields.map((key) => {
|
|
279
|
+
let value;
|
|
280
|
+
switch (key) {
|
|
281
|
+
case 'numberOfItems':
|
|
282
|
+
value = {
|
|
283
|
+
$cond: {
|
|
284
|
+
if: { $isArray: '$itemListElement' },
|
|
285
|
+
then: { $size: '$itemListElement' },
|
|
286
|
+
else: 0
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
break;
|
|
290
|
+
case 'itemListElementTypeOf':
|
|
291
|
+
value = { $first: '$itemListElement.typeOf' };
|
|
292
|
+
break;
|
|
293
|
+
default:
|
|
294
|
+
value = 1;
|
|
295
|
+
}
|
|
296
|
+
return [key, value];
|
|
297
|
+
})));
|
|
298
|
+
// let projectStage: { [field: string]: AnyExpression } = {
|
|
299
|
+
// _id: 0,
|
|
300
|
+
// name: '$name',
|
|
301
|
+
// description: '$description',
|
|
302
|
+
// project: '$project',
|
|
303
|
+
// typeOf: '$typeOf',
|
|
304
|
+
// id: { $toString: '$_id' },
|
|
305
|
+
// identifier: '$identifier',
|
|
306
|
+
// itemOffered: '$itemOffered',
|
|
307
|
+
// additionalProperty: '$additionalProperty',
|
|
308
|
+
// relatedOffer: '$relatedOffer',
|
|
309
|
+
// numberOfItems: {
|
|
310
|
+
// $cond: {
|
|
311
|
+
// if: { $isArray: '$itemListElement' },
|
|
312
|
+
// then: { $size: '$itemListElement' },
|
|
313
|
+
// else: 0
|
|
314
|
+
// }
|
|
315
|
+
// },
|
|
316
|
+
// itemListElementTypeOf: { $first: '$itemListElement.typeOf' },
|
|
317
|
+
// dateSynced: '$dateSynced'
|
|
318
|
+
// };
|
|
319
|
+
// const positiveProjectionFields: string[] = Object.keys(projection)
|
|
320
|
+
// .filter((key) => projection[<KeyOfOfferCatalogItem>key] !== 0);
|
|
321
|
+
// const negativeProjectionFields: string[] = Object.keys(projection)
|
|
322
|
+
// .filter((key) => projection[<KeyOfOfferCatalogItem>key] === 0);
|
|
323
|
+
// if (positiveProjectionFields.length > 0) {
|
|
324
|
+
// projectStage = {
|
|
325
|
+
// _id: 0,
|
|
326
|
+
// id: { $toString: '$_id' }
|
|
327
|
+
// };
|
|
328
|
+
// positiveProjectionFields.forEach((field) => {
|
|
329
|
+
// if (field !== '_id' && field !== 'id') {
|
|
330
|
+
// projectStage[field] = `$${field}`;
|
|
331
|
+
// }
|
|
332
|
+
// });
|
|
333
|
+
// } else if (negativeProjectionFields.length > 0) {
|
|
334
|
+
// negativeProjectionFields.forEach((field) => {
|
|
335
|
+
// if (projectStage[field] !== undefined && projectStage[field] !== null) {
|
|
336
|
+
// // tslint:disable-next-line:no-dynamic-delete
|
|
337
|
+
// delete projectStage[field];
|
|
338
|
+
// }
|
|
339
|
+
// });
|
|
340
|
+
// }
|
|
302
341
|
const aggregate = this.offerCatalogItemModel.aggregate([
|
|
303
342
|
...(((_a = params.sort) === null || _a === void 0 ? void 0 : _a.identifier) !== undefined) ? [{ $sort: { identifier: params.sort.identifier } }] : [],
|
|
304
343
|
...matchStages,
|
|
305
|
-
{ $project:
|
|
344
|
+
{ $project: projection }
|
|
306
345
|
]);
|
|
307
346
|
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
308
347
|
const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
@@ -65,16 +65,6 @@ class PaymentServiceRepo {
|
|
|
65
65
|
typeOf: { $in: typeOfIn }
|
|
66
66
|
});
|
|
67
67
|
}
|
|
68
|
-
// discontinue(2024-08-20~)
|
|
69
|
-
// const hasOfferCatalogIdEq = params.hasOfferCatalog?.id?.$eq;
|
|
70
|
-
// if (typeof hasOfferCatalogIdEq === 'string') {
|
|
71
|
-
// andConditions.push({
|
|
72
|
-
// 'hasOfferCatalog.id': {
|
|
73
|
-
// $exists: true,
|
|
74
|
-
// $eq: hasOfferCatalogIdEq
|
|
75
|
-
// }
|
|
76
|
-
// });
|
|
77
|
-
// }
|
|
78
68
|
const idEq = (_e = params.id) === null || _e === void 0 ? void 0 : _e.$eq;
|
|
79
69
|
if (typeof idEq === 'string') {
|
|
80
70
|
andConditions.push({ _id: { $eq: idEq } });
|
|
@@ -95,6 +95,9 @@ export declare class ProductRepo {
|
|
|
95
95
|
typeOf: factory.service.paymentService.PaymentServiceType.PaymentCard;
|
|
96
96
|
id: string;
|
|
97
97
|
}): Promise<factory.product.IAvailableChannel>;
|
|
98
|
+
/**
|
|
99
|
+
* 指定カタログの設定されたプロダクトを削除する
|
|
100
|
+
*/
|
|
98
101
|
deleteByHasOfferCatalog(params: {
|
|
99
102
|
project: {
|
|
100
103
|
id: string;
|
|
@@ -69,8 +69,15 @@ class ProductRepo {
|
|
|
69
69
|
}
|
|
70
70
|
const hasOfferCatalogIdEq = (_f = (_e = params.hasOfferCatalog) === null || _e === void 0 ? void 0 : _e.id) === null || _f === void 0 ? void 0 : _f.$eq;
|
|
71
71
|
if (typeof hasOfferCatalogIdEq === 'string') {
|
|
72
|
+
// migrate to itemListElement(2024-09-30~)
|
|
73
|
+
// andConditions.push({
|
|
74
|
+
// 'hasOfferCatalog.id': {
|
|
75
|
+
// $exists: true,
|
|
76
|
+
// $eq: hasOfferCatalogIdEq
|
|
77
|
+
// }
|
|
78
|
+
// });
|
|
72
79
|
andConditions.push({
|
|
73
|
-
'hasOfferCatalog.id': {
|
|
80
|
+
'hasOfferCatalog.itemListElement.id': {
|
|
74
81
|
$exists: true,
|
|
75
82
|
$eq: hasOfferCatalogIdEq
|
|
76
83
|
}
|
|
@@ -338,11 +345,15 @@ class ProductRepo {
|
|
|
338
345
|
return availableChannel;
|
|
339
346
|
});
|
|
340
347
|
}
|
|
348
|
+
/**
|
|
349
|
+
* 指定カタログの設定されたプロダクトを削除する
|
|
350
|
+
*/
|
|
341
351
|
deleteByHasOfferCatalog(params) {
|
|
342
352
|
return __awaiter(this, void 0, void 0, function* () {
|
|
343
353
|
return this.productModel.deleteMany({
|
|
344
354
|
'project.id': { $eq: params.project.id },
|
|
345
|
-
'hasOfferCatalog.id': { $exists: true, $eq: params.hasOfferCatalog.id }
|
|
355
|
+
// 'hasOfferCatalog.id': { $exists: true, $eq: params.hasOfferCatalog.id } // migrate to itemListElement(2024-09-30~)
|
|
356
|
+
'hasOfferCatalog.itemListElement.id': { $exists: true, $eq: params.hasOfferCatalog.id }
|
|
346
357
|
})
|
|
347
358
|
.exec();
|
|
348
359
|
});
|
|
@@ -160,7 +160,7 @@ function aggregateOfferByEvent(params) {
|
|
|
160
160
|
}
|
|
161
161
|
function calculateOfferCount(params) {
|
|
162
162
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
163
|
-
var _a, _b, _c;
|
|
163
|
+
var _a, _b, _c, _d;
|
|
164
164
|
let offerCount = 0;
|
|
165
165
|
try {
|
|
166
166
|
const eventOffers = params.event.offers;
|
|
@@ -175,13 +175,15 @@ function calculateOfferCount(params) {
|
|
|
175
175
|
if (eventService === undefined) {
|
|
176
176
|
throw new factory.errors.NotFound(factory.product.ProductType.EventService);
|
|
177
177
|
}
|
|
178
|
-
|
|
179
|
-
|
|
178
|
+
// const firstCatalogIdOfProduct = eventService.hasOfferCatalog?.id; // migrate to itemListElement(2024-09-30~)
|
|
179
|
+
const firstCatalogIdOfProduct = (_c = (_b = eventService.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.itemListElement.at(0)) === null || _c === void 0 ? void 0 : _c.id;
|
|
180
|
+
if (typeof firstCatalogIdOfProduct === 'string') {
|
|
181
|
+
const catalogs = yield repos.offerCatalog.projectFields({
|
|
180
182
|
limit: 1,
|
|
181
183
|
page: 1,
|
|
182
|
-
id: { $in: [
|
|
183
|
-
});
|
|
184
|
-
const numberOfItems = (
|
|
184
|
+
id: { $in: [firstCatalogIdOfProduct] }
|
|
185
|
+
}, ['numberOfItems']);
|
|
186
|
+
const numberOfItems = (_d = catalogs.shift()) === null || _d === void 0 ? void 0 : _d.numberOfItems;
|
|
185
187
|
if (typeof numberOfItems === 'number') {
|
|
186
188
|
offerCount = numberOfItems;
|
|
187
189
|
}
|
|
@@ -17,7 +17,7 @@ const factory = require("../../../factory");
|
|
|
17
17
|
*/
|
|
18
18
|
function findEventOffers(params) {
|
|
19
19
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
20
|
-
var _a, _b;
|
|
20
|
+
var _a, _b, _c;
|
|
21
21
|
let availableOffers = [];
|
|
22
22
|
try {
|
|
23
23
|
// 興行設定があれば興行のカタログを参照する
|
|
@@ -33,7 +33,8 @@ function findEventOffers(params) {
|
|
|
33
33
|
if (eventService === undefined) {
|
|
34
34
|
throw new factory.errors.NotFound(factory.product.ProductType.EventService);
|
|
35
35
|
}
|
|
36
|
-
const offerCatalogId =
|
|
36
|
+
// const offerCatalogId = eventService.hasOfferCatalog?.id; // migrate to itemListElement(2024-09-30~)
|
|
37
|
+
const offerCatalogId = (_c = (_b = eventService.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.itemListElement.at(0)) === null || _c === void 0 ? void 0 : _c.id;
|
|
37
38
|
if (typeof offerCatalogId === 'string') {
|
|
38
39
|
// サブカタログIDを決定
|
|
39
40
|
let subOfferCatalogId = offerCatalogId;
|
|
@@ -17,7 +17,7 @@ const factory_1 = require("../factory");
|
|
|
17
17
|
function searchTicketOffersByItemOffered(params) {
|
|
18
18
|
// tslint:disable-next-line:max-func-body-length
|
|
19
19
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
20
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
20
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
21
21
|
let catalogId;
|
|
22
22
|
const eventService = (yield repos.product.projectFields({
|
|
23
23
|
limit: 1,
|
|
@@ -29,8 +29,10 @@ function searchTicketOffersByItemOffered(params) {
|
|
|
29
29
|
if (eventService === undefined) {
|
|
30
30
|
throw new factory.errors.NotFound(factory.product.ProductType.EventService);
|
|
31
31
|
}
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
// const firstCatalogIdOfProduct = eventService.hasOfferCatalog?.id; // migrate to itemListElement(2024-09-30~)
|
|
33
|
+
const firstCatalogIdOfProduct = (_c = (_b = eventService.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.itemListElement.at(0)) === null || _c === void 0 ? void 0 : _c.id;
|
|
34
|
+
if (typeof firstCatalogIdOfProduct === 'string') {
|
|
35
|
+
catalogId = firstCatalogIdOfProduct;
|
|
34
36
|
}
|
|
35
37
|
if (typeof catalogId !== 'string') {
|
|
36
38
|
throw new factory.errors.NotFound('itemOffered.hasOfferCatalog');
|
|
@@ -49,7 +51,7 @@ function searchTicketOffersByItemOffered(params) {
|
|
|
49
51
|
throw new factory.errors.NotImplemented('id specification on addSortIndex not implemented');
|
|
50
52
|
}
|
|
51
53
|
// 明示的にカタログ指定可能にする
|
|
52
|
-
if (typeof ((
|
|
54
|
+
if (typeof ((_d = params.includedInDataCatalog) === null || _d === void 0 ? void 0 : _d.id) === 'string' && params.includedInDataCatalog.id.length > 0) {
|
|
53
55
|
if (isOfferCatalogItem) {
|
|
54
56
|
// no op
|
|
55
57
|
}
|
|
@@ -64,12 +66,14 @@ function searchTicketOffersByItemOffered(params) {
|
|
|
64
66
|
// サブカタログの適用決済カード条件を考慮
|
|
65
67
|
if (isOfferCatalogItem) {
|
|
66
68
|
// サブカタログ参照
|
|
67
|
-
const offerCatalogItem = (yield repos.offerCatalogItem.
|
|
69
|
+
const offerCatalogItem = (yield repos.offerCatalogItem.projectFields({ id: { $in: [subOfferCatalogId] } }, ['relatedOffer']
|
|
70
|
+
// { relatedOffer: 1 }
|
|
71
|
+
)).shift();
|
|
68
72
|
if (offerCatalogItem === undefined) {
|
|
69
73
|
throw new factory.errors.NotFound('OfferCatalogItem');
|
|
70
74
|
}
|
|
71
75
|
// 強制的にサブカタログの適用決済カード条件に変更
|
|
72
|
-
const appliesToMovieTicketBySubCatalog = (
|
|
76
|
+
const appliesToMovieTicketBySubCatalog = (_f = (_e = offerCatalogItem.relatedOffer) === null || _e === void 0 ? void 0 : _e.priceSpecification) === null || _f === void 0 ? void 0 : _f.appliesToMovieTicket;
|
|
73
77
|
if (Array.isArray(appliesToMovieTicketBySubCatalog)) {
|
|
74
78
|
priceSpecificationCondition = {
|
|
75
79
|
appliesToMovieTicket: {
|
|
@@ -90,7 +94,7 @@ function searchTicketOffersByItemOffered(params) {
|
|
|
90
94
|
}
|
|
91
95
|
const { offers, sortedOfferIds } = yield repos.offer.searchByOfferCatalogIdWithSortIndex({
|
|
92
96
|
offerCatalog: { id: subOfferCatalogId, isOfferCatalogItem },
|
|
93
|
-
availableAtOrFrom: { id: (
|
|
97
|
+
availableAtOrFrom: { id: (_g = params.store) === null || _g === void 0 ? void 0 : _g.id },
|
|
94
98
|
unacceptedPaymentMethod: params.unacceptedPaymentMethod,
|
|
95
99
|
excludeAppliesToMovieTicket: params.excludeAppliesToMovieTicket,
|
|
96
100
|
priceSpecification: priceSpecificationCondition,
|
|
@@ -118,7 +122,7 @@ function searchTicketOffersByItemOffered(params) {
|
|
|
118
122
|
const availableOffers = yield repos.offer.searchAllByIdsAndOfferCatalogId({
|
|
119
123
|
ids: params.ids,
|
|
120
124
|
includedInDataCatalog: { id: includedInDataCatalogIds, isOfferCatalogItem },
|
|
121
|
-
availableAtOrFrom: { id: (
|
|
125
|
+
availableAtOrFrom: { id: (_h = params.store) === null || _h === void 0 ? void 0 : _h.id },
|
|
122
126
|
unacceptedPaymentMethod: params.unacceptedPaymentMethod,
|
|
123
127
|
excludeAppliesToMovieTicket: params.excludeAppliesToMovieTicket,
|
|
124
128
|
onlyValid: params.onlyValid === true
|
|
@@ -354,7 +358,7 @@ exports.searchEventTicketOffers = searchEventTicketOffers;
|
|
|
354
358
|
*/
|
|
355
359
|
function searchOfferAppliesToMovieTicket(params) {
|
|
356
360
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
357
|
-
var _a, _b, _c;
|
|
361
|
+
var _a, _b, _c, _d;
|
|
358
362
|
// optimize(2024-07-18~)
|
|
359
363
|
const event = yield repos.event.projectEventFieldsById({ id: params.event.id }, ['project', 'startDate', 'typeOf', 'superEvent.id', 'offers.itemOffered.id', 'offers.unacceptedPaymentMethod']);
|
|
360
364
|
// let soundFormatTypes: string[] = [];
|
|
@@ -390,8 +394,10 @@ function searchOfferAppliesToMovieTicket(params) {
|
|
|
390
394
|
if (eventService === undefined) {
|
|
391
395
|
throw new factory.errors.NotFound(factory.product.ProductType.EventService);
|
|
392
396
|
}
|
|
393
|
-
|
|
394
|
-
|
|
397
|
+
// const firstCatalogIdOfProduct = eventService.hasOfferCatalog?.id; // migrate to itemListElement(2024-09-30~)
|
|
398
|
+
const firstCatalogIdOfProduct = (_c = (_b = eventService.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.itemListElement.at(0)) === null || _c === void 0 ? void 0 : _c.id;
|
|
399
|
+
if (typeof firstCatalogIdOfProduct === 'string') {
|
|
400
|
+
catalogId = firstCatalogIdOfProduct;
|
|
395
401
|
}
|
|
396
402
|
}
|
|
397
403
|
if (typeof catalogId !== 'string') {
|
|
@@ -408,7 +414,7 @@ function searchOfferAppliesToMovieTicket(params) {
|
|
|
408
414
|
return repos.offer.searchAvaialbleAppliesToMovieTicketByOfferCatalogId({
|
|
409
415
|
// subOfferCatalog: { id: subOfferCatalogId, isOfferCatalogItem },
|
|
410
416
|
subOfferCatalog: { id: subOfferCatalogId },
|
|
411
|
-
availableAtOrFrom: { id: (
|
|
417
|
+
availableAtOrFrom: { id: (_d = params.store) === null || _d === void 0 ? void 0 : _d.id },
|
|
412
418
|
unacceptedPaymentMethod: unacceptedPaymentMethod,
|
|
413
419
|
excludeAppliesToMovieTicket: excludeAppliesToMovieTicket,
|
|
414
420
|
onlyValid: params.onlyValid === true,
|
|
@@ -424,7 +430,7 @@ exports.searchOfferAppliesToMovieTicket = searchOfferAppliesToMovieTicket;
|
|
|
424
430
|
*/
|
|
425
431
|
function searchOfferCatalogItems(params) {
|
|
426
432
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
427
|
-
var _a, _b;
|
|
433
|
+
var _a, _b, _c;
|
|
428
434
|
if (typeof params.limit !== 'number') {
|
|
429
435
|
throw new factory.errors.Argument('limit', 'must be number');
|
|
430
436
|
}
|
|
@@ -448,8 +454,10 @@ function searchOfferCatalogItems(params) {
|
|
|
448
454
|
if (eventService === undefined) {
|
|
449
455
|
throw new factory.errors.NotFound(factory.product.ProductType.EventService);
|
|
450
456
|
}
|
|
451
|
-
|
|
452
|
-
|
|
457
|
+
// const firstCatalogIdOfProduct = eventService.hasOfferCatalog?.id; // migrate to itemListElement(2024-09-30~)
|
|
458
|
+
const firstCatalogIdOfProduct = (_c = (_b = eventService.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.itemListElement.at(0)) === null || _c === void 0 ? void 0 : _c.id;
|
|
459
|
+
if (typeof firstCatalogIdOfProduct === 'string') {
|
|
460
|
+
catalogId = firstCatalogIdOfProduct;
|
|
453
461
|
}
|
|
454
462
|
}
|
|
455
463
|
if (typeof catalogId !== 'string') {
|
|
@@ -464,15 +472,17 @@ function searchOfferCatalogItems(params) {
|
|
|
464
472
|
});
|
|
465
473
|
if (catalogItemListElements.length > 0) {
|
|
466
474
|
// サブカタログ検索
|
|
467
|
-
const searchOfferCatalogItemsResult = yield repos.offerCatalogItem.
|
|
475
|
+
const searchOfferCatalogItemsResult = yield repos.offerCatalogItem.projectFields({
|
|
468
476
|
id: { $in: catalogItemListElements.map((element) => element.id) }
|
|
469
|
-
},
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
477
|
+
}, ['description', 'name', 'additionalProperty', 'relatedOffer']
|
|
478
|
+
// {
|
|
479
|
+
// id: 1,
|
|
480
|
+
// name: 1,
|
|
481
|
+
// description: 1,
|
|
482
|
+
// additionalProperty: 1,
|
|
483
|
+
// relatedOffer: 1
|
|
484
|
+
// }
|
|
485
|
+
);
|
|
476
486
|
offerCatalogItems = catalogItemListElements.map((element) => {
|
|
477
487
|
const offerCatalogItem = searchOfferCatalogItemsResult.find((item) => item.id === element.id);
|
|
478
488
|
if (offerCatalogItem === undefined) {
|
|
@@ -494,7 +504,7 @@ exports.searchOfferCatalogItems = searchOfferCatalogItems;
|
|
|
494
504
|
*/
|
|
495
505
|
function searchOfferCatalogItemAvailability(params) {
|
|
496
506
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
497
|
-
var _a, _b;
|
|
507
|
+
var _a, _b, _c;
|
|
498
508
|
const { considerUnacceptedPaymentMethod } = params.options;
|
|
499
509
|
if (typeof params.limit !== 'number') {
|
|
500
510
|
throw new factory.errors.Argument('limit', 'must be number');
|
|
@@ -519,8 +529,10 @@ function searchOfferCatalogItemAvailability(params) {
|
|
|
519
529
|
if (eventService === undefined) {
|
|
520
530
|
throw new factory.errors.NotFound(factory.product.ProductType.EventService);
|
|
521
531
|
}
|
|
522
|
-
|
|
523
|
-
|
|
532
|
+
// const firstCatalogIdOfProduct = eventService.hasOfferCatalog?.id; // migrate to itemListElement(2024-09-30~)
|
|
533
|
+
const firstCatalogIdOfProduct = (_c = (_b = eventService.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.itemListElement.at(0)) === null || _c === void 0 ? void 0 : _c.id;
|
|
534
|
+
if (typeof firstCatalogIdOfProduct === 'string') {
|
|
535
|
+
catalogId = firstCatalogIdOfProduct;
|
|
524
536
|
}
|
|
525
537
|
}
|
|
526
538
|
if (typeof catalogId !== 'string') {
|
|
@@ -17,7 +17,7 @@ const factory = require("../../../factory");
|
|
|
17
17
|
function searchProductOffers(params) {
|
|
18
18
|
// tslint:disable-next-line:max-func-body-length
|
|
19
19
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
20
|
-
var _a, _b;
|
|
20
|
+
var _a, _b, _c;
|
|
21
21
|
// プロダクト検索
|
|
22
22
|
const productWithOffers = (yield repos.product.projectFields({
|
|
23
23
|
limit: 1,
|
|
@@ -29,7 +29,8 @@ function searchProductOffers(params) {
|
|
|
29
29
|
if (productWithOffers === undefined) {
|
|
30
30
|
throw new factory.errors.NotFound('Product');
|
|
31
31
|
}
|
|
32
|
-
const offerCatalogId =
|
|
32
|
+
// const offerCatalogId = productWithOffers.hasOfferCatalog?.id; // migrate to itemListElement(2024-09-30~)
|
|
33
|
+
const offerCatalogId = (_b = (_a = productWithOffers.hasOfferCatalog) === null || _a === void 0 ? void 0 : _a.itemListElement.at(0)) === null || _b === void 0 ? void 0 : _b.id;
|
|
33
34
|
if (typeof offerCatalogId !== 'string') {
|
|
34
35
|
return [];
|
|
35
36
|
}
|
|
@@ -49,7 +50,7 @@ function searchProductOffers(params) {
|
|
|
49
50
|
throw new factory.errors.NotImplemented('id specification on addSortIndex not implemented');
|
|
50
51
|
}
|
|
51
52
|
// 明示的にカタログ指定可能にする
|
|
52
|
-
if (typeof ((
|
|
53
|
+
if (typeof ((_c = params.includedInDataCatalog) === null || _c === void 0 ? void 0 : _c.id) === 'string' && params.includedInDataCatalog.id.length > 0) {
|
|
53
54
|
if (isOfferCatalogItem) {
|
|
54
55
|
// no op
|
|
55
56
|
}
|
|
@@ -19,10 +19,10 @@ function createInformOfferCatalogTasks(params) {
|
|
|
19
19
|
}
|
|
20
20
|
let offerCatalogs = [];
|
|
21
21
|
if (params.isOfferCatalogItem) {
|
|
22
|
-
offerCatalogs = yield repos.offerCatalogItem.
|
|
22
|
+
offerCatalogs = yield repos.offerCatalogItem.projectFields({ id: { $in: params.ids } }, ['identifier', 'name', 'numberOfItems', 'project', 'typeOf']);
|
|
23
23
|
}
|
|
24
24
|
else {
|
|
25
|
-
offerCatalogs = yield repos.offerCatalog.
|
|
25
|
+
offerCatalogs = yield repos.offerCatalog.projectFields({ id: { $in: params.ids } }, ['identifier', 'name', 'numberOfItems', 'project', 'typeOf']);
|
|
26
26
|
}
|
|
27
27
|
const informResources = settings.onResourceUpdated.informResource;
|
|
28
28
|
const offerCatalogs4inform = offerCatalogs.map(({ id, typeOf, name, identifier, project, numberOfItems }) => {
|
|
@@ -35,10 +35,10 @@ function syncOfferCatalog(params) {
|
|
|
35
35
|
for (const offerCatalogId of params.ids) {
|
|
36
36
|
let offerCatalogs = [];
|
|
37
37
|
if (params.isOfferCatalogItem) {
|
|
38
|
-
offerCatalogs = yield repos.offerCatalogItem.
|
|
38
|
+
offerCatalogs = yield repos.offerCatalogItem.projectFields({ id: { $in: [offerCatalogId] } }, ['id', 'itemListElementTypeOf']);
|
|
39
39
|
}
|
|
40
40
|
else {
|
|
41
|
-
offerCatalogs = yield repos.offerCatalog.
|
|
41
|
+
offerCatalogs = yield repos.offerCatalog.projectFields({ id: { $in: [offerCatalogId] } }, ['id', 'itemListElementTypeOf']);
|
|
42
42
|
}
|
|
43
43
|
const itemListElementTypeOf = (_a = offerCatalogs.shift()) === null || _a === void 0 ? void 0 : _a.itemListElementTypeOf;
|
|
44
44
|
switch (itemListElementTypeOf) {
|
package/package.json
CHANGED
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
}
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@chevre/factory": "4.
|
|
13
|
-
"@cinerino/sdk": "10.
|
|
12
|
+
"@chevre/factory": "4.386.0-alpha.0",
|
|
13
|
+
"@cinerino/sdk": "10.12.0-alpha.0",
|
|
14
14
|
"@motionpicture/coa-service": "9.5.0",
|
|
15
15
|
"@motionpicture/gmo-service": "5.3.0",
|
|
16
16
|
"@sendgrid/mail": "6.4.0",
|
|
@@ -110,5 +110,5 @@
|
|
|
110
110
|
"postversion": "git push origin --tags",
|
|
111
111
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
112
112
|
},
|
|
113
|
-
"version": "22.5.0-alpha.
|
|
113
|
+
"version": "22.5.0-alpha.3"
|
|
114
114
|
}
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
2
|
-
import * as mongoose from 'mongoose';
|
|
3
|
-
|
|
4
|
-
import { chevre } from '../../../lib/index';
|
|
5
|
-
|
|
6
|
-
const PROJECT_ID = String(process.env.PROJECT_ID);
|
|
7
|
-
// const OFFER_CATALOG_ID = String(process.env.OFFER_CATALOG_ID);
|
|
8
|
-
|
|
9
|
-
// tslint:disable-next-line:max-func-body-length
|
|
10
|
-
async function main() {
|
|
11
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
12
|
-
|
|
13
|
-
const offerRepo = await chevre.repository.Offer.createInstance(mongoose.connection);
|
|
14
|
-
const offerCatalogRepo = await chevre.repository.OfferCatalog.createInstance(mongoose.connection);
|
|
15
|
-
|
|
16
|
-
const offerCatalogs = (await offerCatalogRepo.search({
|
|
17
|
-
project: { id: { $eq: PROJECT_ID } }
|
|
18
|
-
// id: { $in: [OFFER_CATALOG_ID] }
|
|
19
|
-
}));
|
|
20
|
-
|
|
21
|
-
let i = 0;
|
|
22
|
-
let maxOfferCatalogItemNumItemListElement = 0;
|
|
23
|
-
let maxIdentifierLength = 0;
|
|
24
|
-
let maxOfferCatalogItemLength = 0;
|
|
25
|
-
for (const offerCatalog of offerCatalogs) {
|
|
26
|
-
i += 1;
|
|
27
|
-
maxIdentifierLength = Math.max(maxIdentifierLength, offerCatalog.identifier.length);
|
|
28
|
-
|
|
29
|
-
const { itemListElement } = await offerCatalogRepo.findItemListElementById({
|
|
30
|
-
id: String(offerCatalog.id),
|
|
31
|
-
project: { id: PROJECT_ID }
|
|
32
|
-
});
|
|
33
|
-
const aggregateOfferIds = itemListElement.map((element) => element.id);
|
|
34
|
-
const unitPriceOffers = await offerRepo.search({
|
|
35
|
-
parentOffer: { id: { $in: aggregateOfferIds } }
|
|
36
|
-
});
|
|
37
|
-
// console.log(unitPriceOffers);
|
|
38
|
-
console.log(unitPriceOffers.length, 'unitPriceOffers found', i);
|
|
39
|
-
|
|
40
|
-
let paymentMethodTypeSets = unitPriceOffers.reduce<{ identifier: string; codeValues: string[] }[]>(
|
|
41
|
-
(a, b) => {
|
|
42
|
-
let appliesToMovieTicketPaymentMethodTypes = b.priceSpecification.appliesToMovieTicket?.map((appliesToMovieTicket) => {
|
|
43
|
-
return appliesToMovieTicket.serviceOutput.typeOf;
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
if (Array.isArray(appliesToMovieTicketPaymentMethodTypes)) {
|
|
47
|
-
appliesToMovieTicketPaymentMethodTypes = appliesToMovieTicketPaymentMethodTypes.sort(
|
|
48
|
-
(aCodeValue, bCodeValue) => (aCodeValue > bCodeValue) ? 1 : -1 // 順序保証
|
|
49
|
-
);
|
|
50
|
-
const setIdentifier = appliesToMovieTicketPaymentMethodTypes.join(',');
|
|
51
|
-
|
|
52
|
-
if (!a.some((paymentMethodTypeSet) => paymentMethodTypeSet.identifier === setIdentifier)) {
|
|
53
|
-
return [
|
|
54
|
-
...a,
|
|
55
|
-
{
|
|
56
|
-
identifier: setIdentifier,
|
|
57
|
-
codeValues: appliesToMovieTicketPaymentMethodTypes
|
|
58
|
-
}
|
|
59
|
-
];
|
|
60
|
-
} else {
|
|
61
|
-
return a;
|
|
62
|
-
}
|
|
63
|
-
} else {
|
|
64
|
-
return a;
|
|
65
|
-
}
|
|
66
|
-
},
|
|
67
|
-
[]
|
|
68
|
-
);
|
|
69
|
-
paymentMethodTypeSets = paymentMethodTypeSets.sort((a, b) => (a.identifier > b.identifier) ? 1 : -1); // 順序保証
|
|
70
|
-
console.log(paymentMethodTypeSets);
|
|
71
|
-
|
|
72
|
-
const offerCatalogItems: chevre.factory.offerCatalog.IOfferCatalog[] = [];
|
|
73
|
-
|
|
74
|
-
// 適用決済カード条件なしのオファーについてサブカタログを作成
|
|
75
|
-
offerCatalogItems.push({
|
|
76
|
-
project: { id: PROJECT_ID, typeOf: chevre.factory.organizationType.Project },
|
|
77
|
-
typeOf: 'OfferCatalog',
|
|
78
|
-
// id?: string;
|
|
79
|
-
identifier: `${offerCatalog.identifier}IDX${offerCatalogItems.length}`,
|
|
80
|
-
name: {
|
|
81
|
-
ja: `${offerCatalog.name.ja}`
|
|
82
|
-
},
|
|
83
|
-
itemListElement: unitPriceOffers.filter((offer) => {
|
|
84
|
-
return !Array.isArray(offer.priceSpecification.appliesToMovieTicket);
|
|
85
|
-
})
|
|
86
|
-
.map((offer) => {
|
|
87
|
-
return {
|
|
88
|
-
typeOf: chevre.factory.offerType.Offer,
|
|
89
|
-
/**
|
|
90
|
-
* 集計オファーID
|
|
91
|
-
*/
|
|
92
|
-
id: String(offer.parentOffer?.id)
|
|
93
|
-
};
|
|
94
|
-
}),
|
|
95
|
-
itemOffered: { typeOf: chevre.factory.product.ProductType.EventService },
|
|
96
|
-
additionalProperty: []
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
// 適用決済カード条件ありのオファーについてサブカタログを作成
|
|
100
|
-
paymentMethodTypeSets.forEach((paymentMethodTypeSet) => {
|
|
101
|
-
offerCatalogItems.push({
|
|
102
|
-
project: { id: PROJECT_ID, typeOf: chevre.factory.organizationType.Project },
|
|
103
|
-
typeOf: 'OfferCatalog',
|
|
104
|
-
// id?: string;
|
|
105
|
-
identifier: `${offerCatalog.identifier}IDX${offerCatalogItems.length}`,
|
|
106
|
-
name: {
|
|
107
|
-
ja: `${offerCatalog.name.ja}[${paymentMethodTypeSet.identifier}]`,
|
|
108
|
-
en: `${offerCatalog.name.en}[${paymentMethodTypeSet.identifier}]`
|
|
109
|
-
},
|
|
110
|
-
itemListElement: unitPriceOffers.filter((offer) => {
|
|
111
|
-
return Array.isArray(offer.priceSpecification.appliesToMovieTicket)
|
|
112
|
-
&& paymentMethodTypeSet.codeValues.length === offer.priceSpecification.appliesToMovieTicket.length
|
|
113
|
-
&& paymentMethodTypeSet.codeValues.every((paymentMethodType) => {
|
|
114
|
-
return Array.isArray(offer.priceSpecification.appliesToMovieTicket)
|
|
115
|
-
&& offer.priceSpecification.appliesToMovieTicket.some(
|
|
116
|
-
(appliesToMovieTicket) => appliesToMovieTicket.serviceOutput.typeOf === paymentMethodType);
|
|
117
|
-
});
|
|
118
|
-
})
|
|
119
|
-
.map((offer) => {
|
|
120
|
-
return {
|
|
121
|
-
typeOf: chevre.factory.offerType.Offer,
|
|
122
|
-
/**
|
|
123
|
-
* 集計オファーID
|
|
124
|
-
*/
|
|
125
|
-
id: String(offer.parentOffer?.id)
|
|
126
|
-
};
|
|
127
|
-
}),
|
|
128
|
-
itemOffered: { typeOf: chevre.factory.product.ProductType.EventService },
|
|
129
|
-
additionalProperty: [],
|
|
130
|
-
relatedOffer: {
|
|
131
|
-
typeOf: chevre.factory.offerType.Offer,
|
|
132
|
-
priceSpecification: {
|
|
133
|
-
appliesToMovieTicket: [{ serviceOutput: { typeOf: paymentMethodTypeSet.codeValues[0] } }]
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
// tslint:disable-next-line:no-null-keyword
|
|
140
|
-
// console.dir(offerCatalogItems, { depth: null });
|
|
141
|
-
console.dir(offerCatalogItems.map((offerCatalogItem) => {
|
|
142
|
-
return `${offerCatalogItem.itemListElement.length} items on ${offerCatalogItem.identifier} ${offerCatalogItem.name.ja} `;
|
|
143
|
-
}));
|
|
144
|
-
|
|
145
|
-
offerCatalogItems.forEach((offerCatalogItem) => {
|
|
146
|
-
maxOfferCatalogItemNumItemListElement =
|
|
147
|
-
Math.max(maxOfferCatalogItemNumItemListElement, offerCatalogItem.itemListElement.length);
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
maxOfferCatalogItemLength = Math.max(maxOfferCatalogItemLength, offerCatalogItems.length);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
console.log(i, 'offerCatalogs checked');
|
|
154
|
-
console.log('maxOfferCatalogItemNumItemListElement:', maxOfferCatalogItemNumItemListElement);
|
|
155
|
-
console.log('maxIdentifierLength:', maxIdentifierLength);
|
|
156
|
-
console.log('maxOfferCatalogItemLength:', maxOfferCatalogItemLength);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
main()
|
|
160
|
-
.then(console.log)
|
|
161
|
-
.catch(console.error);
|