@chevre/domain 22.1.0-alpha.3 → 22.1.0-alpha.5
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/aggregation/createAggregateEventTasks.ts +2 -3
- package/example/src/chevre/createManyEvents.ts +75 -0
- package/example/src/chevre/{searchEvents.ts → projectEventFields.ts} +6 -3
- package/example/src/chevre/searchScreeningEventSeries.ts +2 -3
- package/lib/chevre/repo/event.d.ts +8 -8
- package/lib/chevre/repo/event.js +70 -40
- package/lib/chevre/service/aggregation/event/aggregateOffers.js +12 -14
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +4 -8
- package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.js +10 -13
- package/lib/chevre/service/offer/event/searchEventTicketOffers.js +4 -8
- package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer.js +1 -1
- package/lib/chevre/service/offer/onEventChanged.js +9 -17
- package/lib/chevre/service/offer.d.ts +2 -1
- package/lib/chevre/service/offer.js +30 -20
- package/lib/chevre/service/reserve/potentialActions/onReservationCheckedIn.js +2 -2
- package/lib/chevre/service/transaction/returnOrder/preStart.js +2 -2
- package/package.json +1 -1
|
@@ -15,7 +15,7 @@ async function main() {
|
|
|
15
15
|
const events = <Pick<
|
|
16
16
|
chevre.factory.event.IEvent<chevre.factory.eventType.ScreeningEvent>,
|
|
17
17
|
'id' | 'typeOf' | 'startDate' | 'project'
|
|
18
|
-
>[]>await eventRepo.
|
|
18
|
+
>[]>await eventRepo.projectFields<chevre.factory.eventType.ScreeningEvent>(
|
|
19
19
|
{
|
|
20
20
|
typeOf: chevre.factory.eventType.ScreeningEvent,
|
|
21
21
|
project: { id: { $eq: PROJECT.id } },
|
|
@@ -26,8 +26,7 @@ async function main() {
|
|
|
26
26
|
// startThrough: moment().add(1, 'day').toDate(),
|
|
27
27
|
// startThrough: now
|
|
28
28
|
},
|
|
29
|
-
['
|
|
30
|
-
[]
|
|
29
|
+
['typeOf', 'startDate', 'project']
|
|
31
30
|
);
|
|
32
31
|
|
|
33
32
|
// console.log(events);
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
import { chevre } from '../../../lib/index';
|
|
4
|
+
|
|
5
|
+
const PROJECT_ID = String(process.env.PROJECT_ID);
|
|
6
|
+
|
|
7
|
+
async function main() {
|
|
8
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
9
|
+
|
|
10
|
+
const eventRepo: chevre.repository.Event = await chevre.repository.Event.createInstance(mongoose.connection);
|
|
11
|
+
|
|
12
|
+
const ids = await eventRepo.createMany<chevre.factory.eventType.ScreeningEvent>(
|
|
13
|
+
{
|
|
14
|
+
attributes: [{
|
|
15
|
+
typeOf: chevre.factory.eventType.ScreeningEvent,
|
|
16
|
+
project: { id: PROJECT_ID, typeOf: chevre.factory.organizationType.Project },
|
|
17
|
+
organizer: { id: '59d20831e53ebc2b4e774466' },
|
|
18
|
+
location: {
|
|
19
|
+
typeOf: chevre.factory.placeType.ScreeningRoom,
|
|
20
|
+
branchCode: '70',
|
|
21
|
+
name: {
|
|
22
|
+
ja: 'シネマ7',
|
|
23
|
+
en: 'CINEMA7'
|
|
24
|
+
},
|
|
25
|
+
address: {
|
|
26
|
+
ja: '',
|
|
27
|
+
en: ''
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
name: { ja: 'xxx', en: 'xxx' },
|
|
31
|
+
superEvent: <any>{
|
|
32
|
+
typeOf: chevre.factory.eventType.ScreeningEventSeries,
|
|
33
|
+
id: '7k9ayl8hc'
|
|
34
|
+
},
|
|
35
|
+
offers: {
|
|
36
|
+
availabilityEnds: new Date('2024-08-02T00:00:00+09:00'),
|
|
37
|
+
availabilityStarts: new Date('2024-08-02T00:00:00+09:00'),
|
|
38
|
+
validFrom: new Date('2024-08-02T00:00:00+09:00'),
|
|
39
|
+
validThrough: new Date('2024-08-02T00:00:00+09:00'),
|
|
40
|
+
typeOf: chevre.factory.offerType.Offer,
|
|
41
|
+
eligibleQuantity: { maxValue: 1, typeOf: 'QuantitativeValue' },
|
|
42
|
+
itemOffered: {
|
|
43
|
+
id: '655dc6b02cbb99d946cb6081',
|
|
44
|
+
name: {
|
|
45
|
+
ja: '通常興行カタログ(サブカタログ版)'
|
|
46
|
+
},
|
|
47
|
+
serviceOutput: {
|
|
48
|
+
typeOf: chevre.factory.reservationType.EventReservation,
|
|
49
|
+
reservedTicket: {
|
|
50
|
+
typeOf: 'Ticket'
|
|
51
|
+
// ticketedSeat: {
|
|
52
|
+
// typeOf: chevre.fa
|
|
53
|
+
// }
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
typeOf: chevre.factory.product.ProductType.EventService,
|
|
57
|
+
availableChannel: <any>{}
|
|
58
|
+
},
|
|
59
|
+
seller: <any>{}
|
|
60
|
+
},
|
|
61
|
+
eventStatus: chevre.factory.eventStatusType.EventScheduled,
|
|
62
|
+
doorTime: new Date('2024-08-02T11:00:00+09:00'),
|
|
63
|
+
startDate: new Date('2024-08-02T11:00:00+09:00'),
|
|
64
|
+
endDate: new Date('2024-08-02T12:00:00+09:00')
|
|
65
|
+
}],
|
|
66
|
+
expectsNoContent: false
|
|
67
|
+
}
|
|
68
|
+
);
|
|
69
|
+
// tslint:disable-next-line:no-null-keyword
|
|
70
|
+
console.dir(ids, { depth: null });
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
main()
|
|
74
|
+
.then(console.log)
|
|
75
|
+
.catch(console.error);
|
|
@@ -13,7 +13,7 @@ async function main() {
|
|
|
13
13
|
|
|
14
14
|
const eventRepo: chevre.repository.Event = await chevre.repository.Event.createInstance(mongoose.connection);
|
|
15
15
|
|
|
16
|
-
const events = await eventRepo.
|
|
16
|
+
const events = await eventRepo.projectFields<chevre.factory.eventType.ScreeningEvent>(
|
|
17
17
|
{
|
|
18
18
|
limit: 1,
|
|
19
19
|
page: 1,
|
|
@@ -23,8 +23,11 @@ async function main() {
|
|
|
23
23
|
// id: { $eq: '120162210202407171202250' }
|
|
24
24
|
id: { $eq: 'blxonxv1m' }
|
|
25
25
|
},
|
|
26
|
-
[
|
|
27
|
-
|
|
26
|
+
[
|
|
27
|
+
'location', 'project', 'startDate', 'typeOf'
|
|
28
|
+
// 'superEvent.location.id'
|
|
29
|
+
// 'offers.itemOffered'
|
|
30
|
+
]
|
|
28
31
|
);
|
|
29
32
|
// tslint:disable-next-line:no-null-keyword
|
|
30
33
|
console.dir(events, { depth: null });
|
|
@@ -13,7 +13,7 @@ async function main() {
|
|
|
13
13
|
|
|
14
14
|
const eventRepo: chevre.repository.Event = await chevre.repository.Event.createInstance(mongoose.connection);
|
|
15
15
|
|
|
16
|
-
const events = await eventRepo.
|
|
16
|
+
const events = await eventRepo.projectFields(
|
|
17
17
|
{
|
|
18
18
|
limit: 100,
|
|
19
19
|
page: 1,
|
|
@@ -23,8 +23,7 @@ async function main() {
|
|
|
23
23
|
// id: { $eq: 'al6aff83y' },
|
|
24
24
|
typeOfIn: [chevre.factory.eventType.ScreeningEventSeries]
|
|
25
25
|
},
|
|
26
|
-
[]
|
|
27
|
-
[]
|
|
26
|
+
['eventStatus']
|
|
28
27
|
);
|
|
29
28
|
console.log(events);
|
|
30
29
|
console.log(events.length, 'events found');
|
|
@@ -69,7 +69,7 @@ interface IAggregateEvent {
|
|
|
69
69
|
statuses: IStatus[];
|
|
70
70
|
}
|
|
71
71
|
export import IMinimizedIndividualEvent = EventFactory.IMinimizedIndividualEvent;
|
|
72
|
-
type IKeyOfProjection<T extends factory.eventType> = keyof factory.event.IEvent<T
|
|
72
|
+
type IKeyOfProjection<T extends factory.eventType> = Exclude<keyof factory.event.IEvent<T>, 'id'> | 'aggregateEntranceGate' | 'aggregateOffer' | 'superEvent.location.id' | 'offers.itemOffered';
|
|
73
73
|
/**
|
|
74
74
|
* minimizedEvent検索時のprojection候補
|
|
75
75
|
* add(2024-07-18~)
|
|
@@ -91,7 +91,7 @@ export declare class EventRepo {
|
|
|
91
91
|
createMany<T extends factory.eventType>(params: {
|
|
92
92
|
attributes: factory.event.IAttributes<T>[];
|
|
93
93
|
expectsNoContent: boolean;
|
|
94
|
-
}): Promise<
|
|
94
|
+
}): Promise<string[] | void>;
|
|
95
95
|
/**
|
|
96
96
|
* 特定の追加特性をキーにして、存在しなければ作成する(複数対応)
|
|
97
97
|
* 存在すれば、eventStatusのみ更新する
|
|
@@ -162,9 +162,9 @@ export declare class EventRepo {
|
|
|
162
162
|
id: string;
|
|
163
163
|
}>;
|
|
164
164
|
/**
|
|
165
|
-
* イベントを検索する
|
|
165
|
+
* イベントを検索する(inclusion projection)
|
|
166
166
|
*/
|
|
167
|
-
|
|
167
|
+
projectFields<T extends factory.eventType>(params: ISearchConditions<T>, inclusion: IKeyOfProjection<T>[]): Promise<Omit<factory.event.IEvent<T>, 'aggregateEntranceGate' | 'aggregateOffer'>[]>;
|
|
168
168
|
/**
|
|
169
169
|
* IDのみで検索する
|
|
170
170
|
* projectionなし
|
|
@@ -329,9 +329,9 @@ export declare class EventRepo {
|
|
|
329
329
|
/**
|
|
330
330
|
* 集計属性を更新する
|
|
331
331
|
*/
|
|
332
|
-
updateAggregationById
|
|
332
|
+
updateAggregationById(params: {
|
|
333
333
|
id: string;
|
|
334
|
-
}, update: IUpdateAggregateReservationParams): Promise<
|
|
334
|
+
}, update: IUpdateAggregateReservationParams): Promise<void>;
|
|
335
335
|
bulkWrite(bulkWriteOps: any[]): Promise<BulkWriteResult & {
|
|
336
336
|
mongoose?: {
|
|
337
337
|
validationErrors: import("mongoose").Error[];
|
|
@@ -345,7 +345,7 @@ export declare class EventRepo {
|
|
|
345
345
|
makesOffer: factory.event.screeningEvent.ISellerMakesOffer;
|
|
346
346
|
};
|
|
347
347
|
};
|
|
348
|
-
}): Promise<
|
|
348
|
+
}): Promise<void>;
|
|
349
349
|
deleteAvailableAtOrFrom(params: {
|
|
350
350
|
id: string;
|
|
351
351
|
offers: {
|
|
@@ -357,7 +357,7 @@ export declare class EventRepo {
|
|
|
357
357
|
};
|
|
358
358
|
};
|
|
359
359
|
};
|
|
360
|
-
}): Promise<
|
|
360
|
+
}): Promise<void>;
|
|
361
361
|
unsetUnnecessaryFields<T extends factory.eventType>(params: {
|
|
362
362
|
filter: FilterQuery<factory.event.IEvent<T>>;
|
|
363
363
|
$unset: IUnset<T>;
|
package/lib/chevre/repo/event.js
CHANGED
|
@@ -482,12 +482,14 @@ class EventRepo {
|
|
|
482
482
|
createMany(params) {
|
|
483
483
|
return __awaiter(this, void 0, void 0, function* () {
|
|
484
484
|
const uniqid = yield Promise.resolve().then(() => require('uniqid'));
|
|
485
|
-
let docs;
|
|
485
|
+
// let docs: HydratedDocument<factory.event.IEvent<T>>[];
|
|
486
486
|
const insertingDocs = params.attributes.map((p) => {
|
|
487
487
|
return Object.assign({ _id: uniqid() }, p);
|
|
488
488
|
});
|
|
489
489
|
try {
|
|
490
|
-
|
|
490
|
+
yield this.eventModel.insertMany(insertingDocs, { rawResult: true } // rawResult(2024-08-02~)
|
|
491
|
+
);
|
|
492
|
+
// console.dir(insertResult, { depth: null });
|
|
491
493
|
}
|
|
492
494
|
catch (error) {
|
|
493
495
|
if (yield (0, errorHandler_1.isMongoError)(error)) {
|
|
@@ -500,7 +502,8 @@ class EventRepo {
|
|
|
500
502
|
if (params.expectsNoContent) {
|
|
501
503
|
return;
|
|
502
504
|
}
|
|
503
|
-
return docs.map((doc) => doc.toObject());
|
|
505
|
+
// return docs.map((doc) => doc.toObject<factory.event.IEvent<T>>());
|
|
506
|
+
return insertingDocs.map(({ _id }) => _id);
|
|
504
507
|
});
|
|
505
508
|
}
|
|
506
509
|
/**
|
|
@@ -827,30 +830,62 @@ class EventRepo {
|
|
|
827
830
|
// return <factory.event.IEvent<factory.eventType.ScreeningEvent>>doc.toObject();
|
|
828
831
|
});
|
|
829
832
|
}
|
|
833
|
+
// migrate to projectFields
|
|
834
|
+
// public async search<T extends factory.eventType>(
|
|
835
|
+
// params: ISearchConditions<T>,
|
|
836
|
+
// inclusion: IKeyOfProjection<T>[],
|
|
837
|
+
// exclusion?: IKeyOfProjection<T>[]
|
|
838
|
+
// ): Promise<Omit<factory.event.IEvent<T>, 'aggregateEntranceGate' | 'aggregateOffer'>[]> {
|
|
839
|
+
// const conditions = EventRepo.CREATE_MONGO_CONDITIONS<T>(params);
|
|
840
|
+
// let projection: IProjection<T> = {};
|
|
841
|
+
// if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
842
|
+
// inclusion.forEach((field) => {
|
|
843
|
+
// projection[field] = 1;
|
|
844
|
+
// });
|
|
845
|
+
// } else {
|
|
846
|
+
// projection = {
|
|
847
|
+
// __v: 0,
|
|
848
|
+
// createdAt: 0,
|
|
849
|
+
// updatedAt: 0
|
|
850
|
+
// };
|
|
851
|
+
// if (Array.isArray(exclusion) && exclusion.length > 0) {
|
|
852
|
+
// exclusion.forEach((field) => {
|
|
853
|
+
// projection[field] = 0;
|
|
854
|
+
// });
|
|
855
|
+
// }
|
|
856
|
+
// }
|
|
857
|
+
// const query = this.eventModel.find<HydratedDocument<factory.event.IEvent<T>>>({ $and: conditions }, projection);
|
|
858
|
+
// if (typeof params.limit === 'number' && params.limit > 0) {
|
|
859
|
+
// const page: number = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
860
|
+
// query.limit(params.limit)
|
|
861
|
+
// .skip(params.limit * (page - 1));
|
|
862
|
+
// }
|
|
863
|
+
// // tslint:disable-next-line:no-single-line-block-comment
|
|
864
|
+
// /* istanbul ignore else */
|
|
865
|
+
// if (params.sort?.startDate !== undefined) {
|
|
866
|
+
// query.sort({ startDate: params.sort.startDate });
|
|
867
|
+
// }
|
|
868
|
+
// return query.setOptions({ maxTimeMS: MONGO_MAX_TIME_MS })
|
|
869
|
+
// .exec()
|
|
870
|
+
// .then((docs) => docs.map((doc) => doc.toObject()));
|
|
871
|
+
// }
|
|
830
872
|
/**
|
|
831
|
-
* イベントを検索する
|
|
873
|
+
* イベントを検索する(inclusion projection)
|
|
832
874
|
*/
|
|
833
|
-
|
|
875
|
+
projectFields(params, inclusion) {
|
|
834
876
|
var _a;
|
|
835
877
|
return __awaiter(this, void 0, void 0, function* () {
|
|
836
878
|
const conditions = EventRepo.CREATE_MONGO_CONDITIONS(params);
|
|
837
879
|
let projection = {};
|
|
880
|
+
const positiveProjectionFields = (Array.isArray(inclusion))
|
|
881
|
+
? inclusion.filter((key) => key !== 'id' && key !== '_id')
|
|
882
|
+
: [];
|
|
838
883
|
if (Array.isArray(inclusion) && inclusion.length > 0) {
|
|
839
|
-
|
|
840
|
-
projection[field] = 1;
|
|
841
|
-
});
|
|
884
|
+
projection = Object.assign({ _id: 0, id: { $toString: '$_id' } }, Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1]))));
|
|
842
885
|
}
|
|
843
886
|
else {
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
createdAt: 0,
|
|
847
|
-
updatedAt: 0
|
|
848
|
-
};
|
|
849
|
-
if (Array.isArray(exclusion) && exclusion.length > 0) {
|
|
850
|
-
exclusion.forEach((field) => {
|
|
851
|
-
projection[field] = 0;
|
|
852
|
-
});
|
|
853
|
-
}
|
|
887
|
+
// discontinue(2024-07-24~)
|
|
888
|
+
throw new factory.errors.ArgumentNull('inclusion', 'inclusion must be specified');
|
|
854
889
|
}
|
|
855
890
|
const query = this.eventModel.find({ $and: conditions }, projection);
|
|
856
891
|
if (typeof params.limit === 'number' && params.limit > 0) {
|
|
@@ -872,8 +907,8 @@ class EventRepo {
|
|
|
872
907
|
// console.log(explainResult);
|
|
873
908
|
// return [];
|
|
874
909
|
return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
875
|
-
.
|
|
876
|
-
.
|
|
910
|
+
.lean() // lean(2024-08-01~)
|
|
911
|
+
.exec();
|
|
877
912
|
});
|
|
878
913
|
}
|
|
879
914
|
/**
|
|
@@ -948,10 +983,10 @@ class EventRepo {
|
|
|
948
983
|
*/
|
|
949
984
|
cancel(params) {
|
|
950
985
|
return __awaiter(this, void 0, void 0, function* () {
|
|
951
|
-
yield this.eventModel.
|
|
952
|
-
_id: params.id,
|
|
986
|
+
yield this.eventModel.updateOne({
|
|
987
|
+
_id: { $eq: params.id },
|
|
953
988
|
'project.id': { $eq: params.project.id }
|
|
954
|
-
}, { eventStatus: factory.eventStatusType.EventCancelled })
|
|
989
|
+
}, { $set: { eventStatus: factory.eventStatusType.EventCancelled } }, { rawResult: true })
|
|
955
990
|
.exec();
|
|
956
991
|
});
|
|
957
992
|
}
|
|
@@ -960,7 +995,7 @@ class EventRepo {
|
|
|
960
995
|
*/
|
|
961
996
|
syncScreeningEventSeries2screeningEvents(params) {
|
|
962
997
|
return __awaiter(this, void 0, void 0, function* () {
|
|
963
|
-
const superEvents = yield this.
|
|
998
|
+
const superEvents = yield this.projectFields({
|
|
964
999
|
limit: 1,
|
|
965
1000
|
page: 1,
|
|
966
1001
|
typeOf: factory.eventType.ScreeningEventSeries,
|
|
@@ -970,7 +1005,7 @@ class EventRepo {
|
|
|
970
1005
|
'additionalProperty', 'alternativeHeadline', 'description', 'dubLanguage',
|
|
971
1006
|
'endDate', 'headline', 'kanaName', 'location', 'name',
|
|
972
1007
|
'soundFormat', 'startDate', 'subtitleLanguage', 'typeOf', 'videoFormat', 'workPerformed'
|
|
973
|
-
]
|
|
1008
|
+
]);
|
|
974
1009
|
const superEventFromDB = superEvents.shift();
|
|
975
1010
|
if (superEventFromDB === undefined) {
|
|
976
1011
|
throw new factory.errors.NotFound(factory.eventType.ScreeningEventSeries);
|
|
@@ -1123,23 +1158,18 @@ class EventRepo {
|
|
|
1123
1158
|
/**
|
|
1124
1159
|
* 集計属性を更新する
|
|
1125
1160
|
*/
|
|
1126
|
-
updateAggregationById(params, update
|
|
1127
|
-
// | IUpdateAggregateOfferParams // 廃止(2024-03-28)
|
|
1128
|
-
// | IUpdateAggregateUseActionsParams // 廃止(2024-03-28)
|
|
1129
|
-
) {
|
|
1161
|
+
updateAggregationById(params, update) {
|
|
1130
1162
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1131
|
-
const doc = yield this.eventModel.findOneAndUpdate({ _id: params.id }, update, {
|
|
1132
|
-
new:
|
|
1133
|
-
projection: {
|
|
1134
|
-
typeOf: 1,
|
|
1135
|
-
project: 1
|
|
1136
|
-
}
|
|
1163
|
+
const doc = yield this.eventModel.findOneAndUpdate({ _id: { $eq: params.id } }, update, {
|
|
1164
|
+
new: false,
|
|
1165
|
+
projection: { _id: 1 }
|
|
1137
1166
|
})
|
|
1167
|
+
.lean()
|
|
1138
1168
|
.exec();
|
|
1139
1169
|
if (doc === null) {
|
|
1140
1170
|
throw new factory.errors.NotFound(this.eventModel.modelName);
|
|
1141
1171
|
}
|
|
1142
|
-
return doc.toObject();
|
|
1172
|
+
// return doc.toObject();
|
|
1143
1173
|
});
|
|
1144
1174
|
}
|
|
1145
1175
|
bulkWrite(bulkWriteOps) {
|
|
@@ -1154,23 +1184,23 @@ class EventRepo {
|
|
|
1154
1184
|
}
|
|
1155
1185
|
addAvailableAtOrFrom(params) {
|
|
1156
1186
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1157
|
-
|
|
1187
|
+
yield this.eventModel.updateOne({ _id: { $eq: params.id } }, {
|
|
1158
1188
|
$push: {
|
|
1159
1189
|
'offers.seller.makesOffer': params.offers.seller.makesOffer
|
|
1160
1190
|
}
|
|
1161
|
-
})
|
|
1191
|
+
}, { rawResult: true })
|
|
1162
1192
|
.exec();
|
|
1163
1193
|
});
|
|
1164
1194
|
}
|
|
1165
1195
|
deleteAvailableAtOrFrom(params) {
|
|
1166
1196
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1167
|
-
|
|
1197
|
+
yield this.eventModel.updateOne({ _id: { $eq: params.id } }, {
|
|
1168
1198
|
$pull: {
|
|
1169
1199
|
'offers.seller.makesOffer': {
|
|
1170
1200
|
'availableAtOrFrom.id': { $eq: params.offers.seller.makesOffer.availableAtOrFrom.id }
|
|
1171
1201
|
}
|
|
1172
1202
|
}
|
|
1173
|
-
})
|
|
1203
|
+
}, { rawResult: true })
|
|
1174
1204
|
.exec();
|
|
1175
1205
|
});
|
|
1176
1206
|
}
|
|
@@ -25,12 +25,12 @@ function aggregateOffers(params) {
|
|
|
25
25
|
'location', 'project', 'startDate', 'typeOf', 'superEvent.location.id', 'offers.itemOffered'
|
|
26
26
|
] // projection(2024-07-21~)
|
|
27
27
|
);
|
|
28
|
-
const eventCapacity = (yield repos.event.
|
|
28
|
+
const eventCapacity = (yield repos.event.projectFields({
|
|
29
29
|
limit: 1,
|
|
30
30
|
page: 1,
|
|
31
31
|
id: { $eq: params.id },
|
|
32
32
|
typeOf: params.typeOf
|
|
33
|
-
}, ['maximumAttendeeCapacity', 'remainingAttendeeCapacity']
|
|
33
|
+
}, ['maximumAttendeeCapacity', 'remainingAttendeeCapacity'])).shift();
|
|
34
34
|
debug('processing aggregateOffersByEvent...', eventCapacity);
|
|
35
35
|
yield aggregateOffersByEvent({
|
|
36
36
|
event: Object.assign(Object.assign(Object.assign({}, event), (typeof (eventCapacity === null || eventCapacity === void 0 ? void 0 : eventCapacity.maximumAttendeeCapacity) === 'number')
|
|
@@ -66,18 +66,16 @@ function aggregateOffersByEvent(params) {
|
|
|
66
66
|
event,
|
|
67
67
|
screeningRoom: screeningRoom
|
|
68
68
|
})(repos);
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
//
|
|
78
|
-
//
|
|
79
|
-
// debug('aggregateOffersByEvent processd', saveResult);
|
|
80
|
-
// aggregateReservationsにも保管(2024-03-25~)
|
|
69
|
+
// const update: IUpdateAggregateReservationParams = {
|
|
70
|
+
// $set: {
|
|
71
|
+
// // updatedAt: new Date(), // $setオブジェクトが空だとMongoエラーになるので
|
|
72
|
+
// ...(typeof aggregateOffer?.typeOf === 'string') ? { aggregateOffer: aggregateOffer } : undefined
|
|
73
|
+
// }
|
|
74
|
+
// // $unset: {
|
|
75
|
+
// // noExistingAttributeName: 1 // $unsetは空だとエラーになるので
|
|
76
|
+
// // }
|
|
77
|
+
// };
|
|
78
|
+
// aggregateReservationsに保管(2024-03-25~)
|
|
81
79
|
yield repos.aggregateReservation.save({
|
|
82
80
|
project: event.project,
|
|
83
81
|
reservationFor: {
|
|
@@ -40,7 +40,7 @@ function aggregateScreeningEvent(params) {
|
|
|
40
40
|
.add(-1, 'second')
|
|
41
41
|
.toDate();
|
|
42
42
|
if (event.typeOf === factory.eventType.Event) {
|
|
43
|
-
aggregatingEvents = yield repos.event.
|
|
43
|
+
aggregatingEvents = yield repos.event.projectFields({
|
|
44
44
|
limit: 100,
|
|
45
45
|
page: 1,
|
|
46
46
|
project: { id: { $eq: event.project.id } },
|
|
@@ -49,12 +49,10 @@ function aggregateScreeningEvent(params) {
|
|
|
49
49
|
startFrom: startFrom,
|
|
50
50
|
startThrough: startThrough,
|
|
51
51
|
location: { branchCode: { $eq: event.location.branchCode } }
|
|
52
|
-
}, ['location', 'project', 'startDate', 'typeOf', 'superEvent.location.id', 'offers.itemOffered']
|
|
53
|
-
// PROJECTION_MINIMIZED_EVENT
|
|
54
|
-
);
|
|
52
|
+
}, ['location', 'project', 'startDate', 'typeOf', 'superEvent.location.id', 'offers.itemOffered']);
|
|
55
53
|
}
|
|
56
54
|
else if (event.typeOf === factory.eventType.ScreeningEvent) {
|
|
57
|
-
aggregatingEvents = yield repos.event.
|
|
55
|
+
aggregatingEvents = yield repos.event.projectFields({
|
|
58
56
|
limit: 100,
|
|
59
57
|
page: 1,
|
|
60
58
|
project: { id: { $eq: event.project.id } },
|
|
@@ -63,9 +61,7 @@ function aggregateScreeningEvent(params) {
|
|
|
63
61
|
startFrom: startFrom,
|
|
64
62
|
startThrough: startThrough,
|
|
65
63
|
location: { branchCode: { $eq: event.location.branchCode } }
|
|
66
|
-
}, ['location', 'project', 'startDate', 'typeOf', 'superEvent.location.id', 'offers.itemOffered']
|
|
67
|
-
// PROJECTION_MINIMIZED_EVENT
|
|
68
|
-
);
|
|
64
|
+
}, ['location', 'project', 'startDate', 'typeOf', 'superEvent.location.id', 'offers.itemOffered']);
|
|
69
65
|
}
|
|
70
66
|
// ID指定されたイベントについてはEventScheduledでなくても集計したいので、集計対象を調整
|
|
71
67
|
aggregatingEvents = aggregatingEvents.filter((e) => e.id !== event.id);
|
|
@@ -33,19 +33,16 @@ function aggregateUseActionsOnEvent(params) {
|
|
|
33
33
|
entranceGates
|
|
34
34
|
})(repos);
|
|
35
35
|
debug('entrances aggregated', aggregateEntranceGate);
|
|
36
|
-
const update = {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
// 廃止(2024-03-28~)
|
|
47
|
-
// await repos.event.updateAggregationById({ id: event.id }, update);
|
|
48
|
-
// aggregateReservationsにも保管(2024-03-25~)
|
|
36
|
+
// const update: IUpdateAggregateReservationParams = {
|
|
37
|
+
// $set: {
|
|
38
|
+
// // updatedAt: new Date(), // $setオブジェクトが空だとMongoエラーになるので
|
|
39
|
+
// aggregateEntranceGate
|
|
40
|
+
// }
|
|
41
|
+
// // $unset: {
|
|
42
|
+
// // noExistingAttributeName: 1 // $unsetは空だとエラーになるので
|
|
43
|
+
// // }
|
|
44
|
+
// };
|
|
45
|
+
// aggregateReservationsに保管(2024-03-25~)
|
|
49
46
|
yield repos.aggregateReservation.save({
|
|
50
47
|
project: event.project,
|
|
51
48
|
reservationFor: {
|
|
@@ -138,14 +138,12 @@ function searchEventTicketOffersByEvent(params) {
|
|
|
138
138
|
let soundFormatTypes = [];
|
|
139
139
|
let videoFormatTypes = [];
|
|
140
140
|
if (event.typeOf === factory.eventType.ScreeningEvent) {
|
|
141
|
-
const superEvents = yield repos.event.
|
|
141
|
+
const superEvents = yield repos.event.projectFields({
|
|
142
142
|
limit: 1,
|
|
143
143
|
page: 1,
|
|
144
144
|
id: { $eq: event.superEvent.id },
|
|
145
145
|
typeOf: factory.eventType.ScreeningEventSeries
|
|
146
|
-
}, ['soundFormat', 'videoFormat']
|
|
147
|
-
// { soundFormat: 1, videoFormat: 1 }
|
|
148
|
-
);
|
|
146
|
+
}, ['soundFormat', 'videoFormat']);
|
|
149
147
|
const superEvent = superEvents.shift();
|
|
150
148
|
if (superEvent === undefined) {
|
|
151
149
|
throw new factory.errors.NotFound(factory.eventType.ScreeningEventSeries);
|
|
@@ -362,14 +360,12 @@ function searchOfferAppliesToMovieTicket(params) {
|
|
|
362
360
|
// let soundFormatTypes: string[] = [];
|
|
363
361
|
let videoFormatTypes = [];
|
|
364
362
|
if (event.typeOf === factory.eventType.ScreeningEvent) {
|
|
365
|
-
const superEvents = yield repos.event.
|
|
363
|
+
const superEvents = yield repos.event.projectFields({
|
|
366
364
|
limit: 1,
|
|
367
365
|
page: 1,
|
|
368
366
|
id: { $eq: event.superEvent.id },
|
|
369
367
|
typeOf: factory.eventType.ScreeningEventSeries
|
|
370
|
-
}, ['soundFormat', 'videoFormat']
|
|
371
|
-
// { soundFormat: 1, videoFormat: 1 }
|
|
372
|
-
);
|
|
368
|
+
}, ['soundFormat', 'videoFormat']);
|
|
373
369
|
const superEvent = superEvents.shift();
|
|
374
370
|
if (superEvent === undefined) {
|
|
375
371
|
throw new factory.errors.NotFound(factory.eventType.ScreeningEventSeries);
|
|
@@ -23,7 +23,7 @@ function findCOAInfo(params) {
|
|
|
23
23
|
typeOf: factory.eventType.ScreeningEvent,
|
|
24
24
|
id: { $eq: params.id }
|
|
25
25
|
};
|
|
26
|
-
const event = (yield repos.event.
|
|
26
|
+
const event = (yield repos.event.projectFields(searchConditions, ['coaInfo'])).shift();
|
|
27
27
|
if (event === undefined) {
|
|
28
28
|
throw new factory.errors.NotFound(factory.eventType.ScreeningEvent);
|
|
29
29
|
}
|
|
@@ -129,17 +129,14 @@ function createInformTasks(params) {
|
|
|
129
129
|
let events4inform;
|
|
130
130
|
const informEvents = settings.onEventChanged.informEvent;
|
|
131
131
|
if (params.typeOf === factory.eventType.Event) {
|
|
132
|
-
const eventsFromDB = yield repos.event.
|
|
132
|
+
const eventsFromDB = yield repos.event.projectFields({
|
|
133
133
|
id: { $in: params.ids },
|
|
134
134
|
typeOf: params.typeOf
|
|
135
135
|
}, [
|
|
136
136
|
'project', 'organizer', 'typeOf', 'name', 'doorTime', 'endDate',
|
|
137
137
|
'eventStatus', 'location', 'startDate', 'additionalProperty'
|
|
138
|
-
]
|
|
139
|
-
|
|
140
|
-
// 'aggregateEntranceGate', 'aggregateOffer', 'aggregateReservation',
|
|
141
|
-
// 'remainingAttendeeCapacity', 'checkInCount', 'attendeeCount'
|
|
142
|
-
]);
|
|
138
|
+
] // inclusion(2024-07-30~)
|
|
139
|
+
);
|
|
143
140
|
// 最適化(2024-03-26~)
|
|
144
141
|
events4inform = eventsFromDB.map(({ project, organizer, typeOf, name, doorTime, endDate, eventStatus, location, startDate, id, additionalProperty }) => {
|
|
145
142
|
return {
|
|
@@ -149,17 +146,14 @@ function createInformTasks(params) {
|
|
|
149
146
|
});
|
|
150
147
|
}
|
|
151
148
|
else if (params.typeOf === factory.eventType.ScreeningEvent) {
|
|
152
|
-
const screeningEvents4inform = yield repos.event.
|
|
149
|
+
const screeningEvents4inform = yield repos.event.projectFields({
|
|
153
150
|
id: { $in: params.ids },
|
|
154
151
|
typeOf: params.typeOf
|
|
155
152
|
}, [
|
|
156
153
|
'project', 'organizer', 'typeOf', 'name', 'doorTime', 'endDate',
|
|
157
154
|
'eventStatus', 'location', 'startDate', 'superEvent', 'offers', 'additionalProperty'
|
|
158
|
-
]
|
|
159
|
-
|
|
160
|
-
// 'aggregateEntranceGate', 'aggregateOffer', 'aggregateReservation',
|
|
161
|
-
// 'remainingAttendeeCapacity', 'checkInCount', 'attendeeCount'
|
|
162
|
-
]);
|
|
155
|
+
] // inclusion(2024-07-30~)
|
|
156
|
+
);
|
|
163
157
|
// 最適化(2024-03-22~)
|
|
164
158
|
events4inform = screeningEvents4inform.map(({ project, organizer, typeOf, name, doorTime, endDate, eventStatus, location, startDate, superEvent, offers, id, additionalProperty }) => {
|
|
165
159
|
var _a;
|
|
@@ -187,17 +181,15 @@ function createInformTasks(params) {
|
|
|
187
181
|
});
|
|
188
182
|
}
|
|
189
183
|
else {
|
|
190
|
-
const screeningEventSeries4inform = yield repos.event.
|
|
184
|
+
const screeningEventSeries4inform = yield repos.event.projectFields({
|
|
191
185
|
id: { $in: params.ids },
|
|
192
186
|
typeOf: params.typeOf
|
|
193
187
|
}, [
|
|
194
188
|
'project', 'organizer', 'typeOf', 'name', 'location', 'videoFormat', 'soundFormat', 'workPerformed', 'kanaName', 'eventStatus',
|
|
195
189
|
'endDate', 'startDate', 'additionalProperty', 'subtitleLanguage', 'dubLanguage',
|
|
196
190
|
'alternativeHeadline', 'description', 'duration', 'headline'
|
|
197
|
-
]
|
|
198
|
-
|
|
199
|
-
// 'offers'
|
|
200
|
-
]);
|
|
191
|
+
] // inclusion(2024-07-30~)
|
|
192
|
+
);
|
|
201
193
|
// 最適化(2024-03-25~)
|
|
202
194
|
events4inform = screeningEventSeries4inform.map(({ project, organizer, typeOf, name, location, id, videoFormat, soundFormat, workPerformed, kanaName, eventStatus, endDate, startDate, additionalProperty, subtitleLanguage, dubLanguage, alternativeHeadline, description, duration, headline }) => {
|
|
203
195
|
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ project, organizer, typeOf, name, location, id, videoFormat, soundFormat, workPerformed, kanaName, eventStatus }, (endDate !== undefined) ? { endDate } : undefined), (startDate !== undefined) ? { startDate } : undefined), (Array.isArray(additionalProperty)) ? { additionalProperty } : undefined), (subtitleLanguage !== undefined) ? {} : undefined), (dubLanguage !== undefined) ? { dubLanguage } : undefined), (alternativeHeadline !== undefined) ? { alternativeHeadline } : undefined), (description !== undefined) ? { description } : undefined), (typeof duration === 'string') ? { duration } : undefined), (headline !== undefined) ? { headline } : undefined);
|
|
@@ -20,6 +20,7 @@ export declare function addOffers2Seat(params: {
|
|
|
20
20
|
*/
|
|
21
21
|
priceSpecs: ICategoryCodeChargeSpecification[];
|
|
22
22
|
}): factory.place.seat.IPlaceWithOffer;
|
|
23
|
+
type ISeatAsEventOffer = Pick<factory.place.seat.IPlaceWithOffer, 'branchCode' | 'containedInPlace' | 'offers' | 'seatingType' | 'typeOf' | 'name'>;
|
|
23
24
|
/**
|
|
24
25
|
* イベントに対する座席オファーを検索する
|
|
25
26
|
*/
|
|
@@ -43,4 +44,4 @@ export declare function searchEventSeatOffersWithPaging(params: {
|
|
|
43
44
|
priceSpecification: PriceSpecificationRepo;
|
|
44
45
|
stockHolder: StockHolderRepo;
|
|
45
46
|
seat: SeatRepo;
|
|
46
|
-
}) => Promise<
|
|
47
|
+
}) => Promise<ISeatAsEventOffer[]>;
|
|
@@ -28,17 +28,16 @@ function addOffers2Seat(params) {
|
|
|
28
28
|
const seatingTypes = (Array.isArray(params.seat.seatingType))
|
|
29
29
|
? params.seat.seatingType
|
|
30
30
|
: (typeof params.seat.seatingType === 'string' && params.seat.seatingType.length > 0) ? [params.seat.seatingType] : [];
|
|
31
|
-
const priceComponent = params.priceSpecs.filter((
|
|
31
|
+
const priceComponent = params.priceSpecs.filter(({ appliesToCategoryCode }) => {
|
|
32
32
|
// 適用カテゴリーコードに座席タイプが含まれる価格仕様を検索
|
|
33
|
-
return (Array.isArray(
|
|
34
|
-
&&
|
|
35
|
-
return seatingTypes.includes(categoryCode.codeValue);
|
|
36
|
-
});
|
|
33
|
+
return (Array.isArray(appliesToCategoryCode))
|
|
34
|
+
&& appliesToCategoryCode.some(({ codeValue }) => seatingTypes.includes(codeValue));
|
|
37
35
|
})
|
|
38
36
|
.map(({ appliesToCategoryCode, name, price, priceCurrency, typeOf, valueAddedTaxIncluded }) => {
|
|
39
37
|
return {
|
|
40
|
-
appliesToCategoryCode
|
|
41
|
-
//
|
|
38
|
+
// optimize appliesToCategoryCode(2024-08-02~)
|
|
39
|
+
// appliesToCategoryCode,
|
|
40
|
+
appliesToCategoryCode: appliesToCategoryCode.map(({ codeValue, inCodeSet }) => ({ codeValue, inCodeSet, typeOf: 'CategoryCode' })),
|
|
42
41
|
name, price, priceCurrency, typeOf, valueAddedTaxIncluded
|
|
43
42
|
};
|
|
44
43
|
});
|
|
@@ -50,11 +49,8 @@ function addOffers2Seat(params) {
|
|
|
50
49
|
if (typeof params.availability === 'string') {
|
|
51
50
|
availability = params.availability;
|
|
52
51
|
}
|
|
53
|
-
return Object.assign(Object.assign({}, params.seat), { offers: [Object.assign({
|
|
54
|
-
|
|
55
|
-
availability }, (priceSpecification.priceComponent.length > 0)
|
|
56
|
-
? { priceSpecification } // priceComponentの存在する場合のみ追加(2023-11-08~)
|
|
57
|
-
: undefined)] });
|
|
52
|
+
return Object.assign(Object.assign({}, params.seat), { offers: [Object.assign({ availability }, (priceSpecification.priceComponent.length > 0) ? { priceSpecification } : undefined // priceComponentの存在する場合のみ追加(2023-11-08~)
|
|
53
|
+
)] });
|
|
58
54
|
}
|
|
59
55
|
exports.addOffers2Seat = addOffers2Seat;
|
|
60
56
|
/**
|
|
@@ -71,14 +67,6 @@ function searchEventSeatOffersWithPaging(params) {
|
|
|
71
67
|
const eventOffers = event.offers;
|
|
72
68
|
const reservedSeatsAvailable = ((_b = (_a = eventOffers === null || eventOffers === void 0 ? void 0 : eventOffers.itemOffered.serviceOutput) === null || _a === void 0 ? void 0 : _a.reservedTicket) === null || _b === void 0 ? void 0 : _b.ticketedSeat) !== undefined;
|
|
73
69
|
if (reservedSeatsAvailable) {
|
|
74
|
-
// 座席タイプ価格仕様を検索
|
|
75
|
-
const priceSpecs = yield repos.priceSpecification.search({
|
|
76
|
-
project: { id: { $eq: event.project.id } },
|
|
77
|
-
typeOf: factory.priceSpecificationType.CategoryCodeChargeSpecification,
|
|
78
|
-
appliesToCategoryCode: {
|
|
79
|
-
inCodeSet: { identifier: { $eq: factory.categoryCode.CategorySetIdentifier.SeatingType } }
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
70
|
const roomBranchCode = String((_d = (_c = eventOffers.itemOffered) === null || _c === void 0 ? void 0 : _c.availableChannel) === null || _d === void 0 ? void 0 : _d.serviceLocation.branchCode);
|
|
83
71
|
const movieTheaterBranchCode = String((_f = (_e = eventOffers.itemOffered) === null || _e === void 0 ? void 0 : _e.availableChannel) === null || _f === void 0 ? void 0 : _f.serviceLocation.containedInPlace.branchCode);
|
|
84
72
|
const seats = yield repos.seat.searchSeats(Object.assign(Object.assign({}, params), { project: { id: { $eq: event.project.id } }, containedInPlace: {
|
|
@@ -109,6 +97,28 @@ function searchEventSeatOffersWithPaging(params) {
|
|
|
109
97
|
};
|
|
110
98
|
})
|
|
111
99
|
});
|
|
100
|
+
// tslint:disable-next-line:no-suspicious-comment
|
|
101
|
+
// TODO 必要な座席区分のみ検索?
|
|
102
|
+
// const uniqueSeatingTypes: string[] = [...new Set(seats.reduce<string[]>(
|
|
103
|
+
// (a, { seatingType }) => {
|
|
104
|
+
// if (Array.isArray(seatingType)) {
|
|
105
|
+
// return [...a, ...seatingType];
|
|
106
|
+
// } else if (typeof seatingType === 'string') {
|
|
107
|
+
// return [...a, seatingType];
|
|
108
|
+
// } else {
|
|
109
|
+
// return a;
|
|
110
|
+
// }
|
|
111
|
+
// },
|
|
112
|
+
// []
|
|
113
|
+
// ))];
|
|
114
|
+
// 座席タイプ価格仕様を検索
|
|
115
|
+
const priceSpecs = yield repos.priceSpecification.search({
|
|
116
|
+
project: { id: { $eq: event.project.id } },
|
|
117
|
+
typeOf: factory.priceSpecificationType.CategoryCodeChargeSpecification,
|
|
118
|
+
appliesToCategoryCode: {
|
|
119
|
+
inCodeSet: { identifier: { $eq: factory.categoryCode.CategorySetIdentifier.SeatingType } }
|
|
120
|
+
}
|
|
121
|
+
});
|
|
112
122
|
offers = seats.map((seat, index) => {
|
|
113
123
|
return addOffers2Seat({
|
|
114
124
|
seat,
|
|
@@ -110,10 +110,10 @@ function onReservationCheckedIn(params) {
|
|
|
110
110
|
yield Promise.all(reservationForIds.map((reservationForId) => __awaiter(this, void 0, void 0, function* () {
|
|
111
111
|
var _b;
|
|
112
112
|
// すでにイベントが削除されているケースに備えて、イベント存在検証(2023-09-12~)
|
|
113
|
-
const existingEvents = yield repos.event.
|
|
113
|
+
const existingEvents = yield repos.event.projectFields({
|
|
114
114
|
id: { $eq: reservationForId },
|
|
115
115
|
typeOfIn: [factory.eventType.Event, factory.eventType.ScreeningEvent] // 指定しないとArgumentNullError
|
|
116
|
-
}, ['typeOf']
|
|
116
|
+
}, ['typeOf']);
|
|
117
117
|
if (existingEvents.length > 0) {
|
|
118
118
|
yield (0, onEventChanged_1.createAggregateScreeningEventIfNotExist)({
|
|
119
119
|
project: { id: params.project.id },
|
|
@@ -55,10 +55,10 @@ function preStart(params) {
|
|
|
55
55
|
// イベント開始日時取得
|
|
56
56
|
let events = [];
|
|
57
57
|
if (eventIds.length > 0) {
|
|
58
|
-
events = yield repos.event.
|
|
58
|
+
events = yield repos.event.projectFields({
|
|
59
59
|
id: { $in: eventIds },
|
|
60
60
|
typeOf: factory.eventType.ScreeningEvent
|
|
61
|
-
}, ['startDate']
|
|
61
|
+
}, ['startDate']);
|
|
62
62
|
}
|
|
63
63
|
let returnPolicies = seller.hasMerchantReturnPolicy;
|
|
64
64
|
if (!Array.isArray(returnPolicies)) {
|
package/package.json
CHANGED