@chevre/domain 21.2.0-alpha.135 → 21.2.0-alpha.137
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/searchPaymentServiceProviders.ts +1 -1
- package/lib/chevre/repo/place.d.ts +1 -7
- package/lib/chevre/repo/place.js +42 -29
- package/lib/chevre/repo/stockHolder.d.ts +4 -0
- package/lib/chevre/repo/stockHolder.js +73 -26
- package/lib/chevre/service/event.d.ts +3 -0
- package/lib/chevre/service/event.js +29 -16
- package/lib/chevre/service/payment/movieTicket/validation.js +10 -5
- package/package.json +1 -1
- package/example/src/chevre/findMovieTheaterById.ts +0 -40
|
@@ -6,7 +6,7 @@ import { chevre } from '../../../lib/index';
|
|
|
6
6
|
const PROJECT_ID = process.env.PROJECT_ID;
|
|
7
7
|
|
|
8
8
|
async function main() {
|
|
9
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
9
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
10
10
|
|
|
11
11
|
const productRepo = new chevre.repository.Product(mongoose.connection);
|
|
12
12
|
|
|
@@ -38,13 +38,7 @@ export declare class MongoRepository {
|
|
|
38
38
|
* 施設を保管する
|
|
39
39
|
*/
|
|
40
40
|
saveMovieTheater(params: factory.place.movieTheater.IPlaceWithoutScreeningRoom): Promise<factory.place.movieTheater.IPlaceWithoutScreeningRoom>;
|
|
41
|
-
saveMovieTheaterByBranchCode4coa(params: factory.place.movieTheater.IPlace): Promise<
|
|
42
|
-
findMovieTheaterByBranchCode(params: {
|
|
43
|
-
project: {
|
|
44
|
-
id: string;
|
|
45
|
-
};
|
|
46
|
-
branchCode: string;
|
|
47
|
-
}): Promise<factory.place.movieTheater.IPlace>;
|
|
41
|
+
saveMovieTheaterByBranchCode4coa(params: factory.place.movieTheater.IPlace): Promise<void>;
|
|
48
42
|
/**
|
|
49
43
|
* 施設検索
|
|
50
44
|
*/
|
package/lib/chevre/repo/place.js
CHANGED
|
@@ -239,41 +239,42 @@ class MongoRepository {
|
|
|
239
239
|
return doc.toObject();
|
|
240
240
|
});
|
|
241
241
|
}
|
|
242
|
+
// void化(2023-06-23~)
|
|
242
243
|
saveMovieTheaterByBranchCode4coa(params) {
|
|
243
244
|
return __awaiter(this, void 0, void 0, function* () {
|
|
244
|
-
|
|
245
|
-
'project.id': { $eq: params.project.id },
|
|
246
|
-
branchCode: { $eq: params.branchCode }
|
|
247
|
-
}, params, { new: true })
|
|
248
|
-
.exec()
|
|
249
|
-
.then((doc) => {
|
|
250
|
-
if (doc === null) {
|
|
251
|
-
throw new factory.errors.NotFound(`${factory.placeType.MovieTheater} ${params.branchCode}`);
|
|
252
|
-
}
|
|
253
|
-
return doc.toObject();
|
|
254
|
-
});
|
|
255
|
-
});
|
|
256
|
-
}
|
|
257
|
-
findMovieTheaterByBranchCode(params) {
|
|
258
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
259
|
-
return this.placeModel.findOne({
|
|
245
|
+
yield this.placeModel.updateOne({
|
|
260
246
|
typeOf: { $eq: factory.placeType.MovieTheater },
|
|
261
247
|
'project.id': { $eq: params.project.id },
|
|
262
248
|
branchCode: { $eq: params.branchCode }
|
|
263
|
-
},
|
|
264
|
-
|
|
265
|
-
createdAt: 0,
|
|
266
|
-
updatedAt: 0
|
|
267
|
-
})
|
|
268
|
-
.exec()
|
|
269
|
-
.then((doc) => {
|
|
270
|
-
if (doc === null) {
|
|
271
|
-
throw new factory.errors.NotFound(`${factory.placeType.MovieTheater} ${params.branchCode}`);
|
|
272
|
-
}
|
|
273
|
-
return doc.toObject();
|
|
274
|
-
});
|
|
249
|
+
}, params)
|
|
250
|
+
.exec();
|
|
275
251
|
});
|
|
276
252
|
}
|
|
253
|
+
// 廃止(2023-06-23~)
|
|
254
|
+
// public async findMovieTheaterByBranchCode(params: {
|
|
255
|
+
// project: { id: string };
|
|
256
|
+
// branchCode: string;
|
|
257
|
+
// }): Promise<factory.place.movieTheater.IPlace> {
|
|
258
|
+
// return this.placeModel.findOne(
|
|
259
|
+
// {
|
|
260
|
+
// typeOf: { $eq: factory.placeType.MovieTheater },
|
|
261
|
+
// 'project.id': { $eq: params.project.id },
|
|
262
|
+
// branchCode: { $eq: params.branchCode }
|
|
263
|
+
// },
|
|
264
|
+
// {
|
|
265
|
+
// __v: 0,
|
|
266
|
+
// createdAt: 0,
|
|
267
|
+
// updatedAt: 0
|
|
268
|
+
// }
|
|
269
|
+
// )
|
|
270
|
+
// .exec()
|
|
271
|
+
// .then((doc) => {
|
|
272
|
+
// if (doc === null) {
|
|
273
|
+
// throw new factory.errors.NotFound(`${factory.placeType.MovieTheater} ${params.branchCode}`);
|
|
274
|
+
// }
|
|
275
|
+
// return doc.toObject();
|
|
276
|
+
// });
|
|
277
|
+
// }
|
|
277
278
|
/**
|
|
278
279
|
* 施設検索
|
|
279
280
|
*/
|
|
@@ -376,6 +377,7 @@ class MongoRepository {
|
|
|
376
377
|
return __awaiter(this, void 0, void 0, function* () {
|
|
377
378
|
// 施設存在確認
|
|
378
379
|
let doc = yield this.placeModel.findOne({
|
|
380
|
+
typeOf: { $eq: factory.placeType.MovieTheater },
|
|
379
381
|
'project.id': { $eq: screeningRoom.project.id },
|
|
380
382
|
branchCode: screeningRoom.containedInPlace.branchCode
|
|
381
383
|
}, {
|
|
@@ -387,6 +389,7 @@ class MongoRepository {
|
|
|
387
389
|
}
|
|
388
390
|
// ルームコードが存在しなければ追加する
|
|
389
391
|
doc = yield this.placeModel.findOneAndUpdate({
|
|
392
|
+
typeOf: { $eq: factory.placeType.MovieTheater },
|
|
390
393
|
'project.id': { $eq: screeningRoom.project.id },
|
|
391
394
|
branchCode: screeningRoom.containedInPlace.branchCode,
|
|
392
395
|
'containsPlace.branchCode': { $ne: screeningRoom.branchCode }
|
|
@@ -419,6 +422,7 @@ class MongoRepository {
|
|
|
419
422
|
updateScreeningRoom(screeningRoom, $unset) {
|
|
420
423
|
return __awaiter(this, void 0, void 0, function* () {
|
|
421
424
|
const doc = yield this.placeModel.findOneAndUpdate({
|
|
425
|
+
typeOf: { $eq: factory.placeType.MovieTheater },
|
|
422
426
|
'project.id': { $eq: screeningRoom.project.id },
|
|
423
427
|
branchCode: screeningRoom.containedInPlace.branchCode,
|
|
424
428
|
'containsPlace.branchCode': screeningRoom.branchCode
|
|
@@ -451,6 +455,7 @@ class MongoRepository {
|
|
|
451
455
|
deleteScreeningRoom(screeningRoom) {
|
|
452
456
|
return __awaiter(this, void 0, void 0, function* () {
|
|
453
457
|
const doc = yield this.placeModel.findOneAndUpdate({
|
|
458
|
+
typeOf: { $eq: factory.placeType.MovieTheater },
|
|
454
459
|
'project.id': { $eq: screeningRoom.project.id },
|
|
455
460
|
branchCode: screeningRoom.containedInPlace.branchCode,
|
|
456
461
|
'containsPlace.branchCode': screeningRoom.branchCode
|
|
@@ -482,6 +487,7 @@ class MongoRepository {
|
|
|
482
487
|
}
|
|
483
488
|
// 施設存在確認
|
|
484
489
|
let doc = yield this.placeModel.findOne({
|
|
490
|
+
typeOf: { $eq: factory.placeType.MovieTheater },
|
|
485
491
|
'project.id': { $eq: screeningRoomSection.project.id },
|
|
486
492
|
branchCode: movieTheater.branchCode,
|
|
487
493
|
'containsPlace.branchCode': screeningRoom.branchCode
|
|
@@ -491,6 +497,7 @@ class MongoRepository {
|
|
|
491
497
|
throw new factory.errors.NotFound(factory.placeType.MovieTheater);
|
|
492
498
|
}
|
|
493
499
|
doc = yield this.placeModel.findOneAndUpdate({
|
|
500
|
+
typeOf: { $eq: factory.placeType.MovieTheater },
|
|
494
501
|
'project.id': { $eq: screeningRoomSection.project.id },
|
|
495
502
|
branchCode: movieTheater.branchCode,
|
|
496
503
|
'containsPlace.branchCode': screeningRoom.branchCode
|
|
@@ -531,6 +538,7 @@ class MongoRepository {
|
|
|
531
538
|
throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.branchCode');
|
|
532
539
|
}
|
|
533
540
|
const doc = yield this.placeModel.findOneAndUpdate({
|
|
541
|
+
typeOf: { $eq: factory.placeType.MovieTheater },
|
|
534
542
|
'project.id': { $eq: screeningRoomSection.project.id },
|
|
535
543
|
branchCode: movieTheater.branchCode,
|
|
536
544
|
'containsPlace.branchCode': screeningRoom.branchCode,
|
|
@@ -696,6 +704,7 @@ class MongoRepository {
|
|
|
696
704
|
deleteScreeningRoomSection(screeningRoomSection) {
|
|
697
705
|
return __awaiter(this, void 0, void 0, function* () {
|
|
698
706
|
const doc = yield this.placeModel.findOneAndUpdate({
|
|
707
|
+
typeOf: { $eq: factory.placeType.MovieTheater },
|
|
699
708
|
'project.id': { $eq: screeningRoomSection.project.id },
|
|
700
709
|
branchCode: screeningRoomSection.containedInPlace.containedInPlace.branchCode,
|
|
701
710
|
'containsPlace.branchCode': screeningRoomSection.containedInPlace.branchCode,
|
|
@@ -832,7 +841,7 @@ class MongoRepository {
|
|
|
832
841
|
typeOf: '$typeOf',
|
|
833
842
|
branchCode: '$branchCode',
|
|
834
843
|
name: '$name'
|
|
835
|
-
}, openSeatingAllowed: '$containsPlace.openSeatingAllowed', additionalProperty: '$containsPlace.additionalProperty' }, (((_k = searchConditions.$projection) === null || _k === void 0 ? void 0 : _k.sectionCount) === 1)
|
|
844
|
+
}, openSeatingAllowed: '$containsPlace.openSeatingAllowed', additionalProperty: '$containsPlace.additionalProperty', maximumAttendeeCapacity: '$containsPlace.maximumAttendeeCapacity' }, (((_k = searchConditions.$projection) === null || _k === void 0 ? void 0 : _k.sectionCount) === 1)
|
|
836
845
|
? {
|
|
837
846
|
sectionCount: {
|
|
838
847
|
$cond: {
|
|
@@ -930,6 +939,7 @@ class MongoRepository {
|
|
|
930
939
|
}
|
|
931
940
|
// 施設存在確認
|
|
932
941
|
let doc = yield this.placeModel.findOne({
|
|
942
|
+
typeOf: { $eq: factory.placeType.MovieTheater },
|
|
933
943
|
'project.id': { $eq: seat.project.id },
|
|
934
944
|
branchCode: movieTheater.branchCode,
|
|
935
945
|
'containsPlace.branchCode': screeningRoom.branchCode,
|
|
@@ -942,6 +952,7 @@ class MongoRepository {
|
|
|
942
952
|
throw new factory.errors.NotFound(factory.placeType.MovieTheater);
|
|
943
953
|
}
|
|
944
954
|
doc = yield this.placeModel.findOneAndUpdate({
|
|
955
|
+
typeOf: { $eq: factory.placeType.MovieTheater },
|
|
945
956
|
'project.id': { $eq: seat.project.id },
|
|
946
957
|
branchCode: movieTheater.branchCode,
|
|
947
958
|
'containsPlace.branchCode': screeningRoom.branchCode,
|
|
@@ -988,6 +999,7 @@ class MongoRepository {
|
|
|
988
999
|
throw new factory.errors.ArgumentNull('containedInPlace.containedInPlace.containedInPlace.branchCode');
|
|
989
1000
|
}
|
|
990
1001
|
const doc = yield this.placeModel.findOneAndUpdate({
|
|
1002
|
+
typeOf: { $eq: factory.placeType.MovieTheater },
|
|
991
1003
|
'project.id': { $eq: seat.project.id },
|
|
992
1004
|
branchCode: movieTheater.branchCode,
|
|
993
1005
|
'containsPlace.branchCode': screeningRoom.branchCode,
|
|
@@ -1212,6 +1224,7 @@ class MongoRepository {
|
|
|
1212
1224
|
deleteSeat(seat) {
|
|
1213
1225
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1214
1226
|
const doc = yield this.placeModel.findOneAndUpdate({
|
|
1227
|
+
typeOf: { $eq: factory.placeType.MovieTheater },
|
|
1215
1228
|
'project.id': { $eq: seat.project.id },
|
|
1216
1229
|
branchCode: seat.containedInPlace.containedInPlace.containedInPlace.branchCode,
|
|
1217
1230
|
'containsPlace.branchCode': seat.containedInPlace.containedInPlace.branchCode,
|
|
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.StockHolderRepository = void 0;
|
|
13
13
|
const createDebug = require("debug");
|
|
14
14
|
const moment = require("moment");
|
|
15
|
+
const mongoose_1 = require("mongoose");
|
|
15
16
|
const factory = require("../factory");
|
|
16
17
|
const holdReservation_1 = require("./mongoose/schemas/holdReservation");
|
|
17
18
|
const settings_1 = require("../settings");
|
|
@@ -129,12 +130,12 @@ class StockHolderRepository {
|
|
|
129
130
|
};
|
|
130
131
|
yield this.holdReservationModel.findOneAndUpdate({
|
|
131
132
|
_id: { $eq: id },
|
|
132
|
-
reservationCount: { $lte: reservationCountLte }
|
|
133
|
+
reservationCount: { $lte: reservationCountLte }
|
|
133
134
|
// 'reservationFor.id': { $eq: lockKey.eventId },
|
|
134
135
|
// 座席有無に関わらずsubReservation.identifierはuniqueであるはず
|
|
135
|
-
'reservations.subReservation.identifier': {
|
|
136
|
-
|
|
137
|
-
}
|
|
136
|
+
// 'reservations.subReservation.identifier': {
|
|
137
|
+
// $nin: subReservations.map((r) => r.identifier)
|
|
138
|
+
// }
|
|
138
139
|
}, {
|
|
139
140
|
$inc: { reservationCount: addedReservationCount },
|
|
140
141
|
$push: { reservations: reservationPackage }
|
|
@@ -146,6 +147,8 @@ class StockHolderRepository {
|
|
|
146
147
|
throw new factory.errors.Argument('Event', 'maximumAttendeeCapacity exceeded');
|
|
147
148
|
}
|
|
148
149
|
});
|
|
150
|
+
// 重複検証
|
|
151
|
+
yield this.checkIfAlreadyInUse({ reservationPackage, id });
|
|
149
152
|
}
|
|
150
153
|
else {
|
|
151
154
|
const key = StockHolderRepository.createKey({ eventId: lockKey.eventId, startDate: lockKey.startDate });
|
|
@@ -164,6 +167,7 @@ class StockHolderRepository {
|
|
|
164
167
|
/**
|
|
165
168
|
* 座席をロックする
|
|
166
169
|
*/
|
|
170
|
+
// tslint:disable-next-line:max-func-body-length
|
|
167
171
|
lock(lockKey) {
|
|
168
172
|
return __awaiter(this, void 0, void 0, function* () {
|
|
169
173
|
if (!(lockKey.expires instanceof Date)) {
|
|
@@ -186,24 +190,20 @@ class StockHolderRepository {
|
|
|
186
190
|
reservationNumber: lockKey.holder,
|
|
187
191
|
subReservation: subReservations
|
|
188
192
|
};
|
|
189
|
-
yield this.holdReservationModel.
|
|
190
|
-
_id: { $eq: id }
|
|
193
|
+
yield this.holdReservationModel.updateOne({
|
|
194
|
+
_id: { $eq: id }
|
|
191
195
|
// 'reservationFor.id': { $eq: lockKey.eventId },
|
|
192
196
|
// 座席有無に関わらずsubReservation.identifierはuniqueであるはず
|
|
193
|
-
'reservations.subReservation.identifier': {
|
|
194
|
-
|
|
195
|
-
}
|
|
197
|
+
// 'reservations.subReservation.identifier': {
|
|
198
|
+
// $nin: subReservations.map((r) => r.identifier)
|
|
199
|
+
// }
|
|
196
200
|
}, {
|
|
197
201
|
$inc: { reservationCount: addedReservationCount },
|
|
198
202
|
$push: { reservations: reservationPackage }
|
|
199
|
-
}
|
|
200
|
-
.
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
if (doc === null) {
|
|
204
|
-
throw new factory.errors.AlreadyInUse(factory.reservationType.EventReservation, ['ticketedSeat'], 'Already hold');
|
|
205
|
-
}
|
|
206
|
-
});
|
|
203
|
+
})
|
|
204
|
+
.exec();
|
|
205
|
+
// 重複検証
|
|
206
|
+
yield this.checkIfAlreadyInUse({ reservationPackage, id });
|
|
207
207
|
}
|
|
208
208
|
else {
|
|
209
209
|
const value = lockKey.holder;
|
|
@@ -261,11 +261,12 @@ class StockHolderRepository {
|
|
|
261
261
|
yield this.checkIfConflicted({ key, eventId: params.eventId, useMongoose });
|
|
262
262
|
if (useMongoose) {
|
|
263
263
|
// [id]あるいは[seatNumber+seatSection]でreservations.subReservationsから$pull+$incする
|
|
264
|
-
yield this.initializeHoldReservation({ project: params.project, eventId: params.eventId, startDate: params.startDate });
|
|
264
|
+
const { id } = yield this.initializeHoldReservation({ project: params.project, eventId: params.eventId, startDate: params.startDate });
|
|
265
265
|
const subReservation = StockHolderRepository.offer2subReservation(params.offer, params.hasTicketedSeat);
|
|
266
266
|
const reservationNumber = params.holder;
|
|
267
|
-
const updateResult = yield this.holdReservationModel.
|
|
268
|
-
|
|
267
|
+
const updateResult = yield this.holdReservationModel.updateOne({
|
|
268
|
+
_id: { $eq: id },
|
|
269
|
+
// 'reservationFor.id': { $eq: params.eventId },
|
|
269
270
|
'reservations.reservationNumber': {
|
|
270
271
|
$exists: true,
|
|
271
272
|
$eq: reservationNumber
|
|
@@ -278,18 +279,17 @@ class StockHolderRepository {
|
|
|
278
279
|
$inc: { reservationCount: -1 },
|
|
279
280
|
$pull: { 'reservations.$[reservationPackage].subReservation': { identifier: { $eq: subReservation.identifier } } }
|
|
280
281
|
}, {
|
|
281
|
-
new: true,
|
|
282
282
|
arrayFilters: [
|
|
283
283
|
{ 'reservationPackage.reservationNumber': reservationNumber }
|
|
284
284
|
]
|
|
285
285
|
})
|
|
286
|
-
.select({ _id: 1 })
|
|
287
286
|
.exec();
|
|
288
287
|
// docが存在しなくてもよい
|
|
289
288
|
debug('unlock processed. updateResult:', updateResult, 'reservationNumber:', reservationNumber, 'identifier:', subReservation.identifier);
|
|
290
289
|
// subReservationがemptyのreservationsをpull
|
|
291
|
-
const pullReservationPackageResult = yield this.holdReservationModel.
|
|
292
|
-
|
|
290
|
+
const pullReservationPackageResult = yield this.holdReservationModel.updateOne({
|
|
291
|
+
_id: { $eq: id },
|
|
292
|
+
// 'reservationFor.id': { $eq: params.eventId },
|
|
293
293
|
'reservations.reservationNumber': { $exists: true, $eq: reservationNumber }
|
|
294
294
|
}, {
|
|
295
295
|
$pull: {
|
|
@@ -298,8 +298,7 @@ class StockHolderRepository {
|
|
|
298
298
|
subReservation: { $size: 0 }
|
|
299
299
|
}
|
|
300
300
|
}
|
|
301
|
-
}
|
|
302
|
-
.select({ _id: 1 })
|
|
301
|
+
})
|
|
303
302
|
.exec();
|
|
304
303
|
debug('unlock processed. pullReservationPackageResult:', pullReservationPackageResult, 'reservationNumber:', reservationNumber, 'identifier:', subReservation.identifier);
|
|
305
304
|
}
|
|
@@ -738,6 +737,54 @@ class StockHolderRepository {
|
|
|
738
737
|
return { id: initializedResult.id };
|
|
739
738
|
});
|
|
740
739
|
}
|
|
740
|
+
/**
|
|
741
|
+
* 仮で追加したholdReservationsが重複していないかどうか検証する
|
|
742
|
+
*/
|
|
743
|
+
checkIfAlreadyInUse(params) {
|
|
744
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
745
|
+
const objectId = new mongoose_1.Types.ObjectId(params.id);
|
|
746
|
+
const matchStages = [
|
|
747
|
+
{ $match: { _id: { $eq: objectId } } },
|
|
748
|
+
{
|
|
749
|
+
$match: {
|
|
750
|
+
'reservations.subReservation.identifier': {
|
|
751
|
+
$exists: true,
|
|
752
|
+
$in: params.reservationPackage.subReservation.map((r) => r.identifier)
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
];
|
|
757
|
+
const aggregate = this.holdReservationModel.aggregate([
|
|
758
|
+
{ $unwind: '$reservations' },
|
|
759
|
+
{ $unwind: '$reservations.subReservation' },
|
|
760
|
+
...matchStages,
|
|
761
|
+
{
|
|
762
|
+
$project: {
|
|
763
|
+
_id: 0,
|
|
764
|
+
reservationNumber: '$reservations.reservationNumber'
|
|
765
|
+
}
|
|
766
|
+
},
|
|
767
|
+
{
|
|
768
|
+
$group: {
|
|
769
|
+
_id: '$reservationNumber'
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
]);
|
|
773
|
+
const subReservationsByDoc = yield aggregate.exec();
|
|
774
|
+
debug('checkIfAlreadyInUse:subReservationsByDoc:', subReservationsByDoc);
|
|
775
|
+
if (subReservationsByDoc.length > 1) {
|
|
776
|
+
// 仮追加したsubReservationsを削除
|
|
777
|
+
debug('canceling hold reservationPackage...reservationNumber:', params.reservationPackage.reservationNumber);
|
|
778
|
+
const updateOneResult = yield this.holdReservationModel.updateOne({ _id: { $eq: objectId } }, {
|
|
779
|
+
$inc: { reservationCount: -params.reservationPackage.subReservation.length },
|
|
780
|
+
$pull: { reservations: { reservationNumber: { $eq: params.reservationPackage.reservationNumber } } }
|
|
781
|
+
})
|
|
782
|
+
.exec();
|
|
783
|
+
debug('hold reservationPackage canceled. reservationNumber:', params.reservationPackage.reservationNumber, updateOneResult);
|
|
784
|
+
throw new factory.errors.AlreadyInUse(factory.reservationType.EventReservation, ['ticketedSeat'], 'Already hold');
|
|
785
|
+
}
|
|
786
|
+
});
|
|
787
|
+
}
|
|
741
788
|
}
|
|
742
789
|
StockHolderRepository.KEY_PREFIX_NEW = 'stockHolder';
|
|
743
790
|
StockHolderRepository.KEY_PREFIX = 'chevre:itemAvailability:screeningEvent';
|
|
@@ -22,7 +22,6 @@ const moment = require("moment-timezone");
|
|
|
22
22
|
const credentials_1 = require("../credentials");
|
|
23
23
|
const factory = require("../factory");
|
|
24
24
|
const offer_1 = require("./offer");
|
|
25
|
-
// const customsearch = google.customsearch('v1');
|
|
26
25
|
const debug = createDebug('chevre-domain:service:event');
|
|
27
26
|
const coaAuthClient = new COA.auth.RefreshToken({
|
|
28
27
|
endpoint: credentials_1.credentials.coa.endpoint,
|
|
@@ -99,18 +98,29 @@ function importFromCOA(params) {
|
|
|
99
98
|
if (typeof (seller === null || seller === void 0 ? void 0 : seller.id) !== 'string') {
|
|
100
99
|
throw new factory.errors.NotFound('Seller', `Seller with branchCod '${params.locationBranchCode}' not found`);
|
|
101
100
|
}
|
|
102
|
-
// 施設取得
|
|
103
|
-
let movieTheater = createMovieTheaterFromCOA(project, { id: seller.id }, yield masterService.theater({ theaterCode: params.locationBranchCode }), yield masterService.screen({ theaterCode: params.locationBranchCode }));
|
|
104
101
|
// saveMovieTheater:trueの場合のみ、施設保管(2022-10-10~)
|
|
105
102
|
if (params.saveMovieTheater === true) {
|
|
106
|
-
|
|
103
|
+
const savingMovieTheater = createMovieTheaterFromCOA(project, { id: seller.id }, yield masterService.theater({ theaterCode: params.locationBranchCode }), yield masterService.screen({ theaterCode: params.locationBranchCode }));
|
|
104
|
+
yield repos.place.saveMovieTheaterByBranchCode4coa(savingMovieTheater);
|
|
105
|
+
// } else {
|
|
106
|
+
// movieTheater = await repos.place.findMovieTheaterByBranchCode({
|
|
107
|
+
// project: { id: project.id },
|
|
108
|
+
// branchCode: creatingMovieTheater.branchCode
|
|
109
|
+
// });
|
|
107
110
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
111
|
+
const movieTheaters = yield repos.place.searchMovieTheaters({
|
|
112
|
+
limit: 1,
|
|
113
|
+
page: 1,
|
|
114
|
+
project: { id: { $eq: project.id } },
|
|
115
|
+
branchCode: { $eq: params.locationBranchCode }
|
|
116
|
+
}, ['_id', 'typeOf', 'branchCode', 'name', 'kanaName'], []);
|
|
117
|
+
const movieTheater = movieTheaters.shift();
|
|
118
|
+
if (movieTheater === undefined) {
|
|
119
|
+
throw new factory.errors.NotFound(factory.placeType.MovieTheater);
|
|
113
120
|
}
|
|
121
|
+
const screeningRooms = yield repos.place.searchScreeningRooms({
|
|
122
|
+
containedInPlace: { branchCode: { $eq: movieTheater.branchCode } }
|
|
123
|
+
});
|
|
114
124
|
const targetImportFrom = moment(`${moment(params.importFrom)
|
|
115
125
|
.tz('Asia/Tokyo')
|
|
116
126
|
.format('YYYY-MM-DD')}T00:00:00+09:00`);
|
|
@@ -121,7 +131,7 @@ function importFromCOA(params) {
|
|
|
121
131
|
debug('importing screening events...', targetImportFrom, targetImportThrough);
|
|
122
132
|
const { screeningEventSerieses, savedEventsCount } = yield saveScreeningEventSeries({
|
|
123
133
|
locationBranchCode: params.locationBranchCode,
|
|
124
|
-
movieTheater
|
|
134
|
+
movieTheater,
|
|
125
135
|
project: project,
|
|
126
136
|
saveScreeningEventSeries: params.saveScreeningEventSeries
|
|
127
137
|
})(repos);
|
|
@@ -130,7 +140,8 @@ function importFromCOA(params) {
|
|
|
130
140
|
// イベント永続化
|
|
131
141
|
const screeningEvents = yield saveScreeningEvents({
|
|
132
142
|
locationBranchCode: params.locationBranchCode,
|
|
133
|
-
movieTheater: movieTheater,
|
|
143
|
+
// movieTheater: movieTheater,
|
|
144
|
+
screeningRooms,
|
|
134
145
|
screeningEventSerieses: screeningEventSerieses,
|
|
135
146
|
project: project,
|
|
136
147
|
targetImportFrom: targetImportFrom.toDate(),
|
|
@@ -183,7 +194,6 @@ function importFromCOA(params) {
|
|
|
183
194
|
exports.importFromCOA = importFromCOA;
|
|
184
195
|
function saveScreeningEventSeries(params) {
|
|
185
196
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
186
|
-
const movieTheater = params.movieTheater;
|
|
187
197
|
const project = params.project;
|
|
188
198
|
const masterService = new COA.service.Master({
|
|
189
199
|
endpoint: credentials_1.credentials.coa.endpoint,
|
|
@@ -219,7 +229,7 @@ function saveScreeningEventSeries(params) {
|
|
|
219
229
|
return createScreeningEventSeriesFromCOA({
|
|
220
230
|
project: project,
|
|
221
231
|
filmFromCOA: filmFromCOA,
|
|
222
|
-
movieTheater: movieTheater,
|
|
232
|
+
movieTheater: params.movieTheater,
|
|
223
233
|
eirinKubuns: eirinKubuns,
|
|
224
234
|
eizouKubuns: eizouKubuns,
|
|
225
235
|
joueihousikiKubuns: joueihousikiKubuns,
|
|
@@ -293,7 +303,7 @@ function saveScreeningEvents(params) {
|
|
|
293
303
|
}
|
|
294
304
|
function createScreeningEvents(params) {
|
|
295
305
|
return () => __awaiter(this, void 0, void 0, function* () {
|
|
296
|
-
const movieTheater = params.movieTheater;
|
|
306
|
+
// const movieTheater = params.movieTheater;
|
|
297
307
|
const screeningEventSerieses = params.screeningEventSerieses;
|
|
298
308
|
const project = params.project;
|
|
299
309
|
const masterService = new COA.service.Master({
|
|
@@ -329,8 +339,11 @@ function createScreeningEvents(params) {
|
|
|
329
339
|
titleCode: scheduleFromCOA.titleCode,
|
|
330
340
|
titleBranchNum: scheduleFromCOA.titleBranchNum
|
|
331
341
|
});
|
|
332
|
-
//
|
|
333
|
-
const screenRoom =
|
|
342
|
+
// ルーム存在チェック
|
|
343
|
+
const screenRoom = params.screeningRooms.find((place) => place.branchCode === scheduleFromCOA.screenCode);
|
|
344
|
+
// const screenRoom = <factory.place.screeningRoom.IPlace | undefined>movieTheater.containsPlace.find(
|
|
345
|
+
// (place) => place.branchCode === scheduleFromCOA.screenCode
|
|
346
|
+
// );
|
|
334
347
|
if (screenRoom === undefined) {
|
|
335
348
|
// tslint:disable-next-line:no-console
|
|
336
349
|
console.error('screenRoom not found.', scheduleFromCOA.screenCode);
|
|
@@ -20,19 +20,24 @@ function validateMovieTicket(params, paymentServiceId, useCheckMovieTicketBefore
|
|
|
20
20
|
var _a, _b, _c, _d;
|
|
21
21
|
const movieTickets = (_a = params.object.paymentMethod) === null || _a === void 0 ? void 0 : _a.movieTickets;
|
|
22
22
|
if (!Array.isArray(movieTickets)) {
|
|
23
|
-
throw new factory.errors.Argument('object.paymentMethod.movieTickets must be an array');
|
|
23
|
+
throw new factory.errors.Argument('movieTickets', 'object.paymentMethod.movieTickets must be an array');
|
|
24
24
|
}
|
|
25
25
|
// イベント1つのみ許可
|
|
26
|
-
const eventIds = [...new Set(movieTickets
|
|
26
|
+
const eventIds = [...new Set(movieTickets.map((t) => t.serviceOutput.reservationFor.id))];
|
|
27
27
|
if (eventIds.length !== 1) {
|
|
28
28
|
throw new factory.errors.Argument('movieTickets', 'Number of events must be 1');
|
|
29
29
|
}
|
|
30
|
-
//
|
|
31
|
-
const movieTicketIdentifiers = [...new Set(movieTickets
|
|
30
|
+
// 決済カードidentifierは1つのみ許可
|
|
31
|
+
const movieTicketIdentifiers = [...new Set(movieTickets.map((t) => t.identifier))];
|
|
32
32
|
if (movieTicketIdentifiers.length !== 1) {
|
|
33
33
|
throw new factory.errors.Argument('movieTickets', 'Number of movie ticket identifiers must be 1');
|
|
34
34
|
}
|
|
35
35
|
const movieTicketIdentifier = movieTicketIdentifiers[0];
|
|
36
|
+
// 決済カードaccessCodeは1つのみ許可(2023-06-23~)
|
|
37
|
+
const accessCodes = [...new Set(movieTickets.map((t) => t.accessCode))];
|
|
38
|
+
if (accessCodes.length !== 1) {
|
|
39
|
+
throw new factory.errors.Argument('movieTickets', 'Number of movie ticket accessCodes must be 1');
|
|
40
|
+
}
|
|
36
41
|
// ムビチケ系統の決済方法タイプは動的
|
|
37
42
|
const paymentMethodType = (_b = params.object.paymentMethod) === null || _b === void 0 ? void 0 : _b.typeOf;
|
|
38
43
|
if (typeof paymentMethodType !== 'string') {
|
|
@@ -71,7 +76,7 @@ function validateMovieTicket(params, paymentServiceId, useCheckMovieTicketBefore
|
|
|
71
76
|
var _a, _b;
|
|
72
77
|
const requiredMovieTicketsCountByServiceType = movieTickets.filter((t) => t.serviceType === serviceType).length;
|
|
73
78
|
let availableMovieTicketsCountByServiceType = 0;
|
|
74
|
-
const ykknInfos = (_b = (_a = checkResult.purchaseNumberAuthResult.knyknrNoInfoOut) === null || _a === void 0 ? void 0 : _a.find((knyknrNoInfoOut) => knyknrNoInfoOut.knyknrNo ===
|
|
79
|
+
const ykknInfos = (_b = (_a = checkResult.purchaseNumberAuthResult.knyknrNoInfoOut) === null || _a === void 0 ? void 0 : _a.find((knyknrNoInfoOut) => knyknrNoInfoOut.knyknrNo === movieTicketIdentifier)) === null || _b === void 0 ? void 0 : _b.ykknInfo;
|
|
75
80
|
const ykknInfoOfServiceType = ykknInfos === null || ykknInfos === void 0 ? void 0 : ykknInfos.find((ykknInfo) => ykknInfo.ykknshTyp === serviceType);
|
|
76
81
|
const ykknKnshbtsmiNum = ykknInfoOfServiceType === null || ykknInfoOfServiceType === void 0 ? void 0 : ykknInfoOfServiceType.ykknKnshbtsmiNum;
|
|
77
82
|
if (typeof ykknKnshbtsmiNum === 'string') {
|
package/package.json
CHANGED
|
@@ -1,40 +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 = process.env.PROJECT_ID;
|
|
7
|
-
|
|
8
|
-
async function main() {
|
|
9
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
10
|
-
|
|
11
|
-
const placeRepo = new chevre.repository.Place(mongoose.connection);
|
|
12
|
-
|
|
13
|
-
const movieTheater = await placeRepo.findById(
|
|
14
|
-
{ id: '5d1da6853736344e714efbb8' },
|
|
15
|
-
[
|
|
16
|
-
'additionalProperty',
|
|
17
|
-
'branchCode',
|
|
18
|
-
'hasEntranceGate',
|
|
19
|
-
'hasPOS',
|
|
20
|
-
'kanaName',
|
|
21
|
-
'name',
|
|
22
|
-
'parentOrganization',
|
|
23
|
-
'project',
|
|
24
|
-
'telephone',
|
|
25
|
-
'url',
|
|
26
|
-
'typeOf',
|
|
27
|
-
'containsPlace.branchCode',
|
|
28
|
-
'containsPlace.name',
|
|
29
|
-
'containsPlace.typeOf',
|
|
30
|
-
'containsPlace.additionalProperty',
|
|
31
|
-
'containsPlace.address'
|
|
32
|
-
],
|
|
33
|
-
[]
|
|
34
|
-
);
|
|
35
|
-
console.log('place found', movieTheater);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
main()
|
|
39
|
-
.then(console.log)
|
|
40
|
-
.catch(console.error);
|