@chevre/domain 20.2.0-alpha.3 → 20.2.0-alpha.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/example/src/chevre/aggregateEventReservation.ts +37 -0
- package/example/src/chevre/aggregation/aggregateSystem.ts +104 -0
- package/example/src/chevre/importEventsFromCOA.ts +8 -1
- package/example/src/chevre/migrateEventOffersItemOfferedAvailableChannel.ts +2 -1
- package/example/src/chevre/migrateProjectSubscription.ts +51 -0
- package/example/src/chevre/searchEventIds.ts +24 -0
- package/example/src/chevre/searchEvents.ts +20 -40
- package/lib/chevre/factory/event.d.ts +2 -0
- package/lib/chevre/factory/event.js +2 -0
- package/lib/chevre/repo/action.d.ts +58 -0
- package/lib/chevre/repo/action.js +187 -0
- package/lib/chevre/repo/aggregation.d.ts +36 -0
- package/lib/chevre/repo/aggregation.js +66 -0
- package/lib/chevre/repo/assetTransaction.d.ts +32 -0
- package/lib/chevre/repo/assetTransaction.js +148 -0
- package/lib/chevre/repo/event.d.ts +47 -13
- package/lib/chevre/repo/event.js +386 -113
- package/lib/chevre/repo/mongoose/model/aggregation.d.ts +7 -0
- package/lib/chevre/repo/mongoose/model/aggregation.js +47 -0
- package/lib/chevre/repo/mongoose/model/event.js +4 -3
- package/lib/chevre/repo/mongoose/model/project.js +7 -1
- package/lib/chevre/repo/mongoose/model/telemetry.js +4 -28
- package/lib/chevre/repo/place.d.ts +15 -1
- package/lib/chevre/repo/place.js +175 -10
- package/lib/chevre/repo/product.d.ts +1 -0
- package/lib/chevre/repo/product.js +5 -0
- package/lib/chevre/repo/project.d.ts +4 -1
- package/lib/chevre/repo/project.js +9 -10
- package/lib/chevre/repo/reservation.d.ts +0 -6
- package/lib/chevre/repo/reservation.js +106 -66
- package/lib/chevre/repo/task.d.ts +31 -3
- package/lib/chevre/repo/task.js +141 -27
- package/lib/chevre/repo/transaction.d.ts +35 -0
- package/lib/chevre/repo/transaction.js +163 -0
- package/lib/chevre/repo/trip.js +33 -27
- package/lib/chevre/repository.d.ts +3 -0
- package/lib/chevre/repository.js +5 -1
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.d.ts +1 -1
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +40 -15
- package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.js +3 -1
- package/lib/chevre/service/aggregation/system.d.ts +86 -0
- package/lib/chevre/service/aggregation/system.js +345 -0
- package/lib/chevre/service/aggregation.d.ts +2 -0
- package/lib/chevre/service/aggregation.js +3 -1
- package/lib/chevre/service/assetTransaction/pay/movieTicket/validation.js +5 -1
- package/lib/chevre/service/assetTransaction/pay/potentialActions.js +2 -4
- package/lib/chevre/service/assetTransaction/pay.d.ts +19 -4
- package/lib/chevre/service/assetTransaction/pay.js +65 -32
- package/lib/chevre/service/assetTransaction/reserve/factory.d.ts +3 -0
- package/lib/chevre/service/assetTransaction/reserve/factory.js +33 -2
- package/lib/chevre/service/assetTransaction/reserve.d.ts +7 -2
- package/lib/chevre/service/assetTransaction/reserve.js +43 -56
- package/lib/chevre/service/delivery/factory.js +1 -0
- package/lib/chevre/service/event.d.ts +2 -4
- package/lib/chevre/service/event.js +34 -13
- package/lib/chevre/service/offer/event/authorize.js +5 -1
- package/lib/chevre/service/offer/event/cancel.js +0 -1
- package/lib/chevre/service/offer/event/factory.d.ts +3 -2
- package/lib/chevre/service/offer/event/factory.js +25 -5
- package/lib/chevre/service/offer/event/searchEventTicketOffers.d.ts +2 -2
- package/lib/chevre/service/offer/event/searchEventTicketOffers.js +124 -9
- package/lib/chevre/service/offer/event/voidTransaction.js +0 -2
- package/lib/chevre/service/offer/eventServiceByCOA/factory.d.ts +2 -1
- package/lib/chevre/service/offer/eventServiceByCOA.js +10 -2
- package/lib/chevre/service/offer.js +36 -20
- package/lib/chevre/service/order/onOrderStatusChanged/factory.js +2 -1
- package/lib/chevre/service/order/onOrderStatusChanged.js +2 -1
- package/lib/chevre/service/order/placeOrder.js +16 -0
- package/lib/chevre/service/payment/any.d.ts +5 -0
- package/lib/chevre/service/payment/movieTicket.d.ts +2 -2
- package/lib/chevre/service/payment/movieTicket.js +8 -2
- package/lib/chevre/service/reserve/confirmReservation.js +7 -10
- package/lib/chevre/service/reserve/useReservation.js +2 -1
- package/lib/chevre/service/task/confirmPayTransaction.js +20 -1
- package/lib/chevre/service/task/confirmReserveTransaction.d.ts +4 -0
- package/lib/chevre/service/task/confirmReserveTransaction.js +5 -5
- package/lib/chevre/service/task/importEventsFromCOA.js +3 -1
- package/lib/chevre/service/task.js +6 -9
- package/lib/chevre/service/transaction/placeOrderInProgress/result/acceptedOffers.js +42 -27
- package/lib/chevre/settings.d.ts +2 -0
- package/lib/chevre/settings.js +7 -2
- package/package.json +3 -3
- package/example/src/chevre/aggregateReservationOnProject.ts +0 -32
- package/example/src/chevre/migratePlaceAdditionalProperties.ts +0 -162
|
@@ -18,6 +18,7 @@ const pecorinoapi = require("../../pecorinoapi");
|
|
|
18
18
|
const factory = require("../../factory");
|
|
19
19
|
const OfferService = require("../offer");
|
|
20
20
|
const cancelReservation_1 = require("../reserve/cancelReservation");
|
|
21
|
+
const confirmReservation_1 = require("../reserve/confirmReservation");
|
|
21
22
|
const settings_1 = require("../../settings");
|
|
22
23
|
const factory_1 = require("./reserve/factory");
|
|
23
24
|
/**
|
|
@@ -71,11 +72,16 @@ function addReservations(params) {
|
|
|
71
72
|
throw new factory.errors.ArgumentNull('object.reservationFor.id');
|
|
72
73
|
}
|
|
73
74
|
const acceptedOffers = (Array.isArray(params.object.acceptedOffer)) ? params.object.acceptedOffer : [];
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
75
|
+
// イベント取得属性最適化(2023-01-23~)
|
|
76
|
+
const event = yield repos.event.findMinimizedIndividualEventById({ id: params.object.reservationFor.id });
|
|
77
|
+
// const event = await repos.event.findById(
|
|
78
|
+
// { id: params.object.reservationFor.id },
|
|
79
|
+
// {
|
|
80
|
+
// // 予約データに不要な属性は取得しない
|
|
81
|
+
// aggregateReservation: 0, aggregateOffer: 0, attendeeCount: 0,
|
|
82
|
+
// checkInCount: 0, maximumAttendeeCapacity: 0, remainingAttendeeCapacity: 0
|
|
83
|
+
// }
|
|
84
|
+
// );
|
|
79
85
|
if (event.typeOf !== factory.eventType.ScreeningEvent && event.typeOf !== factory.eventType.Event) {
|
|
80
86
|
throw new factory.errors.Argument('object.reservationFor.id', `invalid event type ${event.typeOf}`);
|
|
81
87
|
}
|
|
@@ -571,8 +577,14 @@ function confirm(params) {
|
|
|
571
577
|
typeOf: factory.assetTransactionType.Reserve,
|
|
572
578
|
id: transaction.id,
|
|
573
579
|
result: result,
|
|
574
|
-
potentialActions:
|
|
580
|
+
potentialActions: (settings_1.USE_ASSET_TRANSACTION_SYNC_PROCESSING)
|
|
581
|
+
? { reserve: [] }
|
|
582
|
+
: potentialActions
|
|
575
583
|
});
|
|
584
|
+
if (settings_1.USE_ASSET_TRANSACTION_SYNC_PROCESSING) {
|
|
585
|
+
// sync対応(2023-01-13~)
|
|
586
|
+
yield (0, confirmReservation_1.confirmReservation)(potentialActions.reserve)(repos);
|
|
587
|
+
}
|
|
576
588
|
});
|
|
577
589
|
}
|
|
578
590
|
exports.confirm = confirm;
|
|
@@ -614,34 +626,9 @@ function cancel(params) {
|
|
|
614
626
|
});
|
|
615
627
|
// 本来非同期でタスクが実行されるが、同期的に仮予約取消が実行されていないと、サービス利用側が困る可能性があるので、
|
|
616
628
|
// 同期的にもcancelPendingReservationを実行しておく
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
if (pendingReservations.length > 0) {
|
|
621
|
-
const reservationFor = transaction.object.reservationFor;
|
|
622
|
-
if (reservationFor === undefined) {
|
|
623
|
-
throw new factory.errors.NotFound('transaction.object.reservationFor');
|
|
624
|
-
}
|
|
625
|
-
// ReservationPackageに対応(2022-12-23~)
|
|
626
|
-
const reservationPackage = {
|
|
627
|
-
typeOf: factory.reservationType.ReservationPackage,
|
|
628
|
-
reservationNumber: transaction.transactionNumber,
|
|
629
|
-
reservationFor: { typeOf: reservationFor.typeOf, id: String(reservationFor.id) },
|
|
630
|
-
reservationStatus: pendingReservations[0].reservationStatus
|
|
631
|
-
};
|
|
632
|
-
cancelActionAttributes = [{
|
|
633
|
-
project: transaction.project,
|
|
634
|
-
typeOf: factory.actionType.CancelAction,
|
|
635
|
-
purpose: { typeOf: transaction.typeOf, id: transaction.id },
|
|
636
|
-
agent: transaction.project,
|
|
637
|
-
object: reservationPackage,
|
|
638
|
-
potentialActions: {}
|
|
639
|
-
}];
|
|
640
|
-
yield (0, cancelReservation_1.cancelPendingReservation)(cancelActionAttributes)(repos);
|
|
641
|
-
}
|
|
642
|
-
}
|
|
643
|
-
catch (error) {
|
|
644
|
-
// no op
|
|
629
|
+
const cancelActionAttributes = (0, factory_1.createPendingReservationAction)({ transaction });
|
|
630
|
+
if (cancelActionAttributes.length > 0) {
|
|
631
|
+
yield (0, cancelReservation_1.cancelPendingReservation)(cancelActionAttributes)(repos);
|
|
645
632
|
}
|
|
646
633
|
});
|
|
647
634
|
}
|
|
@@ -704,29 +691,29 @@ function exportTasksById(params) {
|
|
|
704
691
|
}
|
|
705
692
|
break;
|
|
706
693
|
case factory.transactionStatusType.Canceled:
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
if (reservationFor === undefined) {
|
|
713
|
-
throw new factory.errors.NotFound('transaction.object.reservationFor');
|
|
714
|
-
}
|
|
715
|
-
// ReservationPackageに対応(2022-12-23~)
|
|
716
|
-
const reservationPackage = {
|
|
717
|
-
typeOf: factory.reservationType.ReservationPackage,
|
|
718
|
-
reservationNumber: transaction.transactionNumber,
|
|
719
|
-
reservationFor: { typeOf: reservationFor.typeOf, id: String(reservationFor.id) },
|
|
720
|
-
reservationStatus: pendingReservations[0].reservationStatus
|
|
721
|
-
};
|
|
722
|
-
cancelActionAttributes = [{
|
|
694
|
+
// sync対応(2023-01-13~)
|
|
695
|
+
if (!settings_1.USE_ASSET_TRANSACTION_SYNC_PROCESSING) {
|
|
696
|
+
const cancelActionAttributes4canceled = (0, factory_1.createPendingReservationAction)({ transaction });
|
|
697
|
+
if (cancelActionAttributes4canceled.length > 0) {
|
|
698
|
+
const cancelPendingReservationTask = {
|
|
723
699
|
project: transaction.project,
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
700
|
+
name: factory.taskName.CancelPendingReservation,
|
|
701
|
+
status: factory.taskStatus.Ready,
|
|
702
|
+
runsAt: new Date(),
|
|
703
|
+
remainingNumberOfTries: 10,
|
|
704
|
+
numberOfTried: 0,
|
|
705
|
+
executionResults: [],
|
|
706
|
+
data: {
|
|
707
|
+
actionAttributes: cancelActionAttributes4canceled
|
|
708
|
+
}
|
|
709
|
+
};
|
|
710
|
+
taskAttributes.push(cancelPendingReservationTask);
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
break;
|
|
714
|
+
case factory.transactionStatusType.Expired:
|
|
715
|
+
const cancelActionAttributes = (0, factory_1.createPendingReservationAction)({ transaction });
|
|
716
|
+
if (cancelActionAttributes.length > 0) {
|
|
730
717
|
const cancelPendingReservationTask = {
|
|
731
718
|
project: transaction.project,
|
|
732
719
|
name: factory.taskName.CancelPendingReservation,
|
|
@@ -22,6 +22,7 @@ function createOwnershipInfosFromOrder(params) {
|
|
|
22
22
|
const ownedBy = createOwnedby(params);
|
|
23
23
|
const itemOfferedType = itemOffered.typeOf;
|
|
24
24
|
switch (itemOfferedType) {
|
|
25
|
+
case factory.reservationType.BusReservation:
|
|
25
26
|
case factory.reservationType.EventReservation:
|
|
26
27
|
ownershipInfo = (0, factory_2.createReservationOwnershipInfo)({
|
|
27
28
|
project: params.order.project,
|
|
@@ -3,6 +3,7 @@ import { MongoRepository as CategoryCodeRepo } from '../repo/categoryCode';
|
|
|
3
3
|
import { MongoRepository as EventRepo } from '../repo/event';
|
|
4
4
|
import { MongoRepository as PlaceRepo } from '../repo/place';
|
|
5
5
|
import { MongoRepository as ProjectRepo } from '../repo/project';
|
|
6
|
+
import { MongoRepository as SellerRepo } from '../repo/seller';
|
|
6
7
|
import { MongoRepository as TaskRepo } from '../repo/task';
|
|
7
8
|
import * as factory from '../factory';
|
|
8
9
|
/**
|
|
@@ -32,6 +33,7 @@ export declare function importFromCOA(params: {
|
|
|
32
33
|
categoryCode: CategoryCodeRepo;
|
|
33
34
|
event: EventRepo;
|
|
34
35
|
place: PlaceRepo;
|
|
36
|
+
seller: SellerRepo;
|
|
35
37
|
}) => Promise<void>;
|
|
36
38
|
/**
|
|
37
39
|
* COA情報からイベントIDを作成する
|
|
@@ -49,10 +51,6 @@ export declare function updateEvent4ttts(params: {
|
|
|
49
51
|
* 旧イベントID
|
|
50
52
|
*/
|
|
51
53
|
oldEventId: string;
|
|
52
|
-
/**
|
|
53
|
-
* 旧IDを使用しない場合、IDは自動発行される
|
|
54
|
-
*/
|
|
55
|
-
useOldEventId: boolean;
|
|
56
54
|
/**
|
|
57
55
|
* イベント属性
|
|
58
56
|
*/
|
|
@@ -89,8 +89,18 @@ function importFromCOA(params) {
|
|
|
89
89
|
endpoint: credentials_1.credentials.coa.endpoint,
|
|
90
90
|
auth: coaAuthClient
|
|
91
91
|
}, { timeout: credentials_1.credentials.coa.timeout });
|
|
92
|
+
// 同ブランチコードの販売者を検索する
|
|
93
|
+
const sellersWithSameBranchCode = yield repos.seller.search({
|
|
94
|
+
limit: 1,
|
|
95
|
+
page: 1,
|
|
96
|
+
branchCode: { $eq: params.locationBranchCode }
|
|
97
|
+
});
|
|
98
|
+
const seller = sellersWithSameBranchCode.shift();
|
|
99
|
+
if (typeof (seller === null || seller === void 0 ? void 0 : seller.id) !== 'string') {
|
|
100
|
+
throw new factory.errors.NotFound('Seller', `Seller with branchCod '${params.locationBranchCode}' not found`);
|
|
101
|
+
}
|
|
92
102
|
// 施設取得
|
|
93
|
-
let movieTheater = createMovieTheaterFromCOA(project, yield masterService.theater({ theaterCode: params.locationBranchCode }), yield masterService.screen({ theaterCode: params.locationBranchCode }));
|
|
103
|
+
let movieTheater = createMovieTheaterFromCOA(project, { id: seller.id }, yield masterService.theater({ theaterCode: params.locationBranchCode }), yield masterService.screen({ theaterCode: params.locationBranchCode }));
|
|
94
104
|
// saveMovieTheater:trueの場合のみ、施設保管(2022-10-10~)
|
|
95
105
|
if (params.saveMovieTheater === true) {
|
|
96
106
|
movieTheater = yield repos.place.saveMovieTheaterByBranchCode4coa(movieTheater);
|
|
@@ -346,8 +356,19 @@ function createScreeningEvents(params) {
|
|
|
346
356
|
}
|
|
347
357
|
function cancelDeletedEvents(params) {
|
|
348
358
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
359
|
+
// distinctでidのみ取得(2023-01-25~)
|
|
349
360
|
// COAから削除されたイベントをキャンセル済ステータスへ変更
|
|
350
|
-
const ids =
|
|
361
|
+
// const ids = await repos.event.search<factory.eventType.ScreeningEvent>({
|
|
362
|
+
// project: { id: { $eq: params.project.id } },
|
|
363
|
+
// typeOf: factory.eventType.ScreeningEvent,
|
|
364
|
+
// superEvent: {
|
|
365
|
+
// locationBranchCodes: [params.locationBranchCode]
|
|
366
|
+
// },
|
|
367
|
+
// startFrom: params.targetImportFrom,
|
|
368
|
+
// startThrough: params.targetImportThrough
|
|
369
|
+
// })
|
|
370
|
+
// .then((events) => events.map((e) => e.id));
|
|
371
|
+
const ids = yield repos.event.searchIds({
|
|
351
372
|
project: { id: { $eq: params.project.id } },
|
|
352
373
|
typeOf: factory.eventType.ScreeningEvent,
|
|
353
374
|
superEvent: {
|
|
@@ -355,8 +376,7 @@ function cancelDeletedEvents(params) {
|
|
|
355
376
|
},
|
|
356
377
|
startFrom: params.targetImportFrom,
|
|
357
378
|
startThrough: params.targetImportThrough
|
|
358
|
-
})
|
|
359
|
-
.then((events) => events.map((e) => e.id));
|
|
379
|
+
});
|
|
360
380
|
const idsShouldBe = params.idsShouldBe;
|
|
361
381
|
const cancelledIds = difference(ids, idsShouldBe);
|
|
362
382
|
debug(`cancelling ${cancelledIds.length} events...`);
|
|
@@ -539,11 +559,12 @@ function createScreeningEventSeriesFromCOA(params) {
|
|
|
539
559
|
kanaName: params.movieTheater.kanaName,
|
|
540
560
|
typeOf: params.movieTheater.typeOf
|
|
541
561
|
},
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
562
|
+
// 不要なので廃止(2023-01-12~)
|
|
563
|
+
// organizer: {
|
|
564
|
+
// typeOf: factory.organizationType.Corporation,
|
|
565
|
+
// identifier: params.movieTheater.id,
|
|
566
|
+
// name: params.movieTheater.name
|
|
567
|
+
// },
|
|
547
568
|
videoFormat: params.eizouKubuns.filter((kubun) => kubun.kubunCode === params.filmFromCOA.kbnEizou)[0],
|
|
548
569
|
soundFormat: [],
|
|
549
570
|
workPerformed: {
|
|
@@ -617,7 +638,7 @@ function createScreeningEventSeriesId(params) {
|
|
|
617
638
|
*/
|
|
618
639
|
// tslint:disable-next-line:no-single-line-block-comment
|
|
619
640
|
/* istanbul ignore next */
|
|
620
|
-
function createMovieTheaterFromCOA(project, theaterFromCOA, screensFromCOA) {
|
|
641
|
+
function createMovieTheaterFromCOA(project, seller, theaterFromCOA, screensFromCOA) {
|
|
621
642
|
const id = `MovieTheater-${theaterFromCOA.theaterCode}`;
|
|
622
643
|
return {
|
|
623
644
|
project: { typeOf: project.typeOf, id: project.id },
|
|
@@ -663,7 +684,8 @@ function createMovieTheaterFromCOA(project, theaterFromCOA, screensFromCOA) {
|
|
|
663
684
|
value: 2678400,
|
|
664
685
|
unitCode: factory.unitCode.Sec
|
|
665
686
|
}
|
|
666
|
-
}
|
|
687
|
+
},
|
|
688
|
+
parentOrganization: { id: seller.id, typeOf: factory.organizationType.Corporation }
|
|
667
689
|
};
|
|
668
690
|
}
|
|
669
691
|
/**
|
|
@@ -731,8 +753,7 @@ function updateEvent4ttts(params) {
|
|
|
731
753
|
try {
|
|
732
754
|
event = yield repos.event.save4ttts({
|
|
733
755
|
oldEventId: params.oldEventId,
|
|
734
|
-
attributes: params.attributes
|
|
735
|
-
useOldEventId: params.useOldEventId
|
|
756
|
+
attributes: params.attributes
|
|
736
757
|
});
|
|
737
758
|
}
|
|
738
759
|
catch (error) {
|
|
@@ -124,7 +124,11 @@ function validateCreateRequest(params) {
|
|
|
124
124
|
if (typeof ((_a = params.object.reservationFor) === null || _a === void 0 ? void 0 : _a.id) !== 'string' || params.object.reservationFor.id.length === 0) {
|
|
125
125
|
throw new factory.errors.ArgumentNull('object.reservationFor.id');
|
|
126
126
|
}
|
|
127
|
-
|
|
127
|
+
// イベント取得属性最適化(2023-01-23~)
|
|
128
|
+
// const event = await repos.event.findById<factory.eventType.ScreeningEvent>({ id: params.object.reservationFor.id });
|
|
129
|
+
const event = yield repos.event.findMinimizedIndividualEventById({
|
|
130
|
+
id: params.object.reservationFor.id
|
|
131
|
+
});
|
|
128
132
|
let offeredThrough = (_b = event.offers) === null || _b === void 0 ? void 0 : _b.offeredThrough;
|
|
129
133
|
if (offeredThrough === undefined) {
|
|
130
134
|
offeredThrough = { typeOf: 'WebAPI', identifier: factory.service.webAPI.Identifier.Chevre };
|
|
@@ -37,7 +37,6 @@ function cancel(params) {
|
|
|
37
37
|
const transactionNumber = (_a = action.object.pendingTransaction) === null || _a === void 0 ? void 0 : _a.transactionNumber;
|
|
38
38
|
if (typeof transactionNumber === 'string') {
|
|
39
39
|
// すでに取消済であったとしても、すべて取消処理(actionStatusに関係なく)
|
|
40
|
-
// await repos.reserveTransaction.cancel({ transactionNumber: action.object.pendingTransaction?.transactionNumber });
|
|
41
40
|
yield ReserveTransactionService.cancel({ transactionNumber })(repos);
|
|
42
41
|
}
|
|
43
42
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as COA from '@motionpicture/coa-service';
|
|
2
2
|
import * as factory from '../../../factory';
|
|
3
|
+
import { IMinimizedIndividualEvent } from '../../../factory/event';
|
|
3
4
|
export declare type IReservationFor = factory.reservation.IReservationFor<factory.reservationType.EventReservation>;
|
|
4
5
|
export declare type IUnitPriceSpecification = factory.priceSpecification.IPriceSpecification<factory.priceSpecificationType.UnitPriceSpecification>;
|
|
5
6
|
export declare type IObjectWithoutDetail = factory.action.authorize.offer.seatReservation.IObjectWithoutDetail4chevre;
|
|
@@ -14,7 +15,7 @@ export declare function createReserveTransactionStartParams(params: {
|
|
|
14
15
|
}): factory.assetTransaction.reserve.IStartParamsWithoutDetail;
|
|
15
16
|
export declare function createAuthorizeSeatReservationActionAttributes(params: {
|
|
16
17
|
acceptedOffers: factory.action.authorize.offer.seatReservation.IAcceptedOffer4chevre[];
|
|
17
|
-
event:
|
|
18
|
+
event: IMinimizedIndividualEvent<factory.eventType.ScreeningEvent>;
|
|
18
19
|
pendingTransaction?: factory.action.authorize.offer.seatReservation.IPendingTransaction | undefined;
|
|
19
20
|
transaction: factory.transaction.ITransaction<factory.transactionType.PlaceOrder>;
|
|
20
21
|
broker?: factory.reservation.IBroker<factory.reservationType.EventReservation>;
|
|
@@ -25,7 +26,7 @@ export declare function acceptedOffers2amount(params: {
|
|
|
25
26
|
declare type IResultAcceptedOffer = factory.action.authorize.offer.seatReservation.IResultAcceptedOffer;
|
|
26
27
|
export declare function responseBody2acceptedOffers4result(params: {
|
|
27
28
|
responseBody: factory.assetTransaction.reserve.ITransaction;
|
|
28
|
-
event:
|
|
29
|
+
event: IMinimizedIndividualEvent<factory.eventType.ScreeningEvent>;
|
|
29
30
|
project: {
|
|
30
31
|
id: string;
|
|
31
32
|
typeOf: factory.organizationType.Project;
|
|
@@ -211,7 +211,7 @@ exports.responseBody2acceptedOffers4result = responseBody2acceptedOffers4result;
|
|
|
211
211
|
*/
|
|
212
212
|
// tslint:disable-next-line:max-func-body-length
|
|
213
213
|
function createReservation(params) {
|
|
214
|
-
var _a;
|
|
214
|
+
var _a, _b, _c, _d;
|
|
215
215
|
const itemOffered = params.itemOffered;
|
|
216
216
|
const event = params.event;
|
|
217
217
|
let reservationItem;
|
|
@@ -243,16 +243,36 @@ function createReservation(params) {
|
|
|
243
243
|
.toDate(),
|
|
244
244
|
// 最適化(2022-05-31~)
|
|
245
245
|
superEvent: Object.assign(Object.assign({ typeOf: event.superEvent.typeOf, id: event.superEvent.id, kanaName: event.superEvent.kanaName, location: event.superEvent.location, name: event.superEvent.name, soundFormat: event.superEvent.soundFormat, videoFormat: event.superEvent.videoFormat, workPerformed }, (typeof event.superEvent.duration === 'string') ? { duration: event.superEvent.duration } : undefined), (event.superEvent.headline !== undefined) ? { headline: event.superEvent.headline } : undefined)
|
|
246
|
-
// 廃止(superEvent.workPerformedへ完全移行)
|
|
247
|
-
// workPerformed: {},
|
|
248
246
|
};
|
|
249
|
-
reservationItem = Object.assign({ project: itemOffered.project, typeOf: itemOffered.typeOf, additionalProperty: itemOffered.additionalProperty, additionalTicketText: itemOffered.additionalTicketText, id: itemOffered.id, issuedThrough: itemOffered.issuedThrough, reservationNumber: itemOffered.reservationNumber, reservationFor
|
|
247
|
+
reservationItem = Object.assign({ project: itemOffered.project, typeOf: itemOffered.typeOf, additionalProperty: itemOffered.additionalProperty, additionalTicketText: itemOffered.additionalTicketText, id: itemOffered.id, issuedThrough: itemOffered.issuedThrough, reservationNumber: itemOffered.reservationNumber, reservationFor,
|
|
248
|
+
reservedTicket }, (typeof ((_a = itemOffered.programMembershipUsed) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string')
|
|
250
249
|
? { programMembershipUsed: itemOffered.programMembershipUsed }
|
|
251
250
|
: undefined);
|
|
252
251
|
}
|
|
253
252
|
else if (itemOffered.typeOf === factory.reservationType.BusReservation
|
|
254
253
|
&& event.typeOf === factory.eventType.Event) {
|
|
255
|
-
|
|
254
|
+
const tripByEvent = (_c = (_b = event.offers) === null || _b === void 0 ? void 0 : _b.itemOffered.serviceOutput) === null || _c === void 0 ? void 0 : _c.reservationFor;
|
|
255
|
+
if (typeof (tripByEvent === null || tripByEvent === void 0 ? void 0 : tripByEvent.typeOf) !== 'string') {
|
|
256
|
+
throw new factory.errors.NotFound('event.offers.itemOffered.serviceOutput.reservationFor');
|
|
257
|
+
}
|
|
258
|
+
const reservationFor = {
|
|
259
|
+
typeOf: tripByEvent.typeOf,
|
|
260
|
+
id: event.id,
|
|
261
|
+
arrivalBusStop: tripByEvent.arrivalBusStop,
|
|
262
|
+
departureBusStop: tripByEvent.departureBusStop,
|
|
263
|
+
name: event.name,
|
|
264
|
+
departureTime: moment(tripByEvent.departureTime)
|
|
265
|
+
.toDate(),
|
|
266
|
+
arrivalTime: moment(tripByEvent.arrivalTime)
|
|
267
|
+
.toDate(),
|
|
268
|
+
busName: tripByEvent.busName,
|
|
269
|
+
busNumber: tripByEvent.busNumber,
|
|
270
|
+
identifier: tripByEvent.identifier
|
|
271
|
+
};
|
|
272
|
+
reservationItem = Object.assign({ project: itemOffered.project, typeOf: itemOffered.typeOf, additionalProperty: itemOffered.additionalProperty, additionalTicketText: itemOffered.additionalTicketText, id: itemOffered.id, issuedThrough: itemOffered.issuedThrough, reservationNumber: itemOffered.reservationNumber, reservationFor,
|
|
273
|
+
reservedTicket }, (typeof ((_d = itemOffered.programMembershipUsed) === null || _d === void 0 ? void 0 : _d.typeOf) === 'string')
|
|
274
|
+
? { programMembershipUsed: itemOffered.programMembershipUsed }
|
|
275
|
+
: undefined);
|
|
256
276
|
}
|
|
257
277
|
else {
|
|
258
278
|
throw new factory.errors.Argument('itemOffered');
|
|
@@ -16,7 +16,7 @@ declare type IAcceptedPaymentMethod = factory.paymentMethod.paymentCard.movieTic
|
|
|
16
16
|
/**
|
|
17
17
|
* 興行オファー検索
|
|
18
18
|
*/
|
|
19
|
-
|
|
19
|
+
declare function searchEventTicketOffers(params: {
|
|
20
20
|
/**
|
|
21
21
|
* どのイベントに対して
|
|
22
22
|
*/
|
|
@@ -73,4 +73,4 @@ export declare function searchEventTicketOffers(params: {
|
|
|
73
73
|
kbnEisyahousiki: string;
|
|
74
74
|
};
|
|
75
75
|
}): ISearchEventTicketOffersOperation<factory.product.ITicketOffer[]>;
|
|
76
|
-
export {};
|
|
76
|
+
export { searchEventTicketOffers };
|
|
@@ -13,6 +13,112 @@ exports.searchEventTicketOffers = void 0;
|
|
|
13
13
|
const moment = require("moment-timezone");
|
|
14
14
|
const factory = require("../../../factory");
|
|
15
15
|
const factory_1 = require("../factory");
|
|
16
|
+
/**
|
|
17
|
+
* 旅客オファー検索
|
|
18
|
+
*/
|
|
19
|
+
function searchTransportationEventTicketOffers(params) {
|
|
20
|
+
// tslint:disable-next-line:max-func-body-length
|
|
21
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
var _a, _b, _c;
|
|
23
|
+
const screeningEvent = params.event;
|
|
24
|
+
const soundFormatTypes = [];
|
|
25
|
+
const videoFormatTypes = [];
|
|
26
|
+
let availableOffers = [];
|
|
27
|
+
// 興行設定があれば興行のカタログを参照する(2022-08-31~)
|
|
28
|
+
const eventOffers = screeningEvent.offers;
|
|
29
|
+
if (typeof ((_a = eventOffers === null || eventOffers === void 0 ? void 0 : eventOffers.itemOffered) === null || _a === void 0 ? void 0 : _a.id) === 'string') {
|
|
30
|
+
const transportation = yield repos.product.findById({ id: eventOffers.itemOffered.id });
|
|
31
|
+
if (typeof ((_b = transportation.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.id) === 'string') {
|
|
32
|
+
availableOffers = yield repos.offer.findOffersByOfferCatalogId({
|
|
33
|
+
offerCatalog: { id: transportation.hasOfferCatalog.id }
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
// hasOfferCatalog参照廃止(2022-09-02~)
|
|
39
|
+
throw new factory.errors.NotFound('event.offers.itemOffered.id');
|
|
40
|
+
}
|
|
41
|
+
const { soundFormatChargeSpecifications, videoFormatChargeSpecifications, movieTicketTypeChargeSpecs } = yield searchPriceSpecs4event({ project: { id: screeningEvent.project.id }, soundFormatTypes, videoFormatTypes })(repos);
|
|
42
|
+
const unacceptedPaymentMethod = getUnacceptedPaymentMethodByEvent({ event: screeningEvent });
|
|
43
|
+
// 不許可決済方法があれば、該当オファーを除外
|
|
44
|
+
if (Array.isArray(unacceptedPaymentMethod) && unacceptedPaymentMethod.length > 0) {
|
|
45
|
+
availableOffers = availableOffers.filter((o) => {
|
|
46
|
+
var _a;
|
|
47
|
+
// 複数決済カード対応(2022-07-11~)
|
|
48
|
+
const priceSpecificationAppliesToMovieTicket = (_a = o.priceSpecification) === null || _a === void 0 ? void 0 : _a.appliesToMovieTicket;
|
|
49
|
+
if (Array.isArray(priceSpecificationAppliesToMovieTicket)) {
|
|
50
|
+
return priceSpecificationAppliesToMovieTicket.every((appliesToMovieTicket) => {
|
|
51
|
+
return !unacceptedPaymentMethod.includes(appliesToMovieTicket.serviceOutput.typeOf);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
// Arrayでないケースは廃止(2022-09-10~)
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
// 適用決済カード条件がある場合、決済カード加算料金が存在しないオファーは除外する
|
|
61
|
+
availableOffers = availableOffers.filter((o) => {
|
|
62
|
+
var _a;
|
|
63
|
+
// 複数決済カード対応(2022-07-26~)
|
|
64
|
+
const priceSpecificationAppliesToMovieTicket = (_a = o.priceSpecification) === null || _a === void 0 ? void 0 : _a.appliesToMovieTicket;
|
|
65
|
+
if (Array.isArray(priceSpecificationAppliesToMovieTicket)) {
|
|
66
|
+
// 適用決済カード数が0であれば除外
|
|
67
|
+
if (priceSpecificationAppliesToMovieTicket.length === 0) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
// 上映方式がなければ除外(2022-11-03~)
|
|
71
|
+
if (videoFormatTypes.length === 0) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
return priceSpecificationAppliesToMovieTicket.every((appliesToMovieTicket) => {
|
|
75
|
+
// すべての上映方式について検証する(2022-10-29~)
|
|
76
|
+
return videoFormatTypes.every((videoFormat) => {
|
|
77
|
+
return movieTicketTypeChargeSpecs.some((s) => {
|
|
78
|
+
var _a, _b, _c, _d;
|
|
79
|
+
return ((_b = (_a = s.appliesToMovieTicket) === null || _a === void 0 ? void 0 : _a.serviceOutput) === null || _b === void 0 ? void 0 : _b.typeOf) === ((_c = appliesToMovieTicket.serviceOutput) === null || _c === void 0 ? void 0 : _c.typeOf)
|
|
80
|
+
&& ((_d = s.appliesToMovieTicket) === null || _d === void 0 ? void 0 : _d.serviceType) === appliesToMovieTicket.serviceType
|
|
81
|
+
&& s.appliesToVideoFormat === videoFormat;
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
// Arrayでないケースは廃止(2022-09-10~)
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
let offers4event = availableOffers.map((availableOffer) => {
|
|
92
|
+
return (0, factory_1.createCompoundPriceSpec4event)({
|
|
93
|
+
eligibleQuantity: eventOffers.eligibleQuantity,
|
|
94
|
+
offer: availableOffer,
|
|
95
|
+
videoFormatChargeSpecifications,
|
|
96
|
+
soundFormatChargeSpecifications,
|
|
97
|
+
movieTicketTypeChargeSpecs,
|
|
98
|
+
videoFormatTypes
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
// レート制限を確認
|
|
102
|
+
offers4event = yield Promise.all(offers4event.map((offer) => __awaiter(this, void 0, void 0, function* () {
|
|
103
|
+
return checkAvailability({ event: screeningEvent, offer })(repos);
|
|
104
|
+
})));
|
|
105
|
+
// アドオン設定があれば、プロダクトオファーを検索
|
|
106
|
+
for (const offer of offers4event) {
|
|
107
|
+
const offerAddOn = [];
|
|
108
|
+
if (Array.isArray(offer.addOn)) {
|
|
109
|
+
for (const addOn of offer.addOn) {
|
|
110
|
+
const productId = (_c = addOn.itemOffered) === null || _c === void 0 ? void 0 : _c.id;
|
|
111
|
+
if (typeof productId === 'string') {
|
|
112
|
+
const productOffers = yield searchAddOns({ product: { id: productId } })(repos);
|
|
113
|
+
offerAddOn.push(...productOffers);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
offer.addOn = offerAddOn;
|
|
118
|
+
}
|
|
119
|
+
return offers4event;
|
|
120
|
+
});
|
|
121
|
+
}
|
|
16
122
|
/**
|
|
17
123
|
* 興行オファー全検索
|
|
18
124
|
*/
|
|
@@ -20,8 +126,11 @@ function searchScreeningEventTicketOffers(params) {
|
|
|
20
126
|
// tslint:disable-next-line:max-func-body-length
|
|
21
127
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
22
128
|
var _a, _b, _c;
|
|
23
|
-
|
|
24
|
-
const
|
|
129
|
+
// イベント取得属性最適化(2023-01-23~)
|
|
130
|
+
// const screeningEvent = await repos.event.findById<factory.eventType.ScreeningEvent>({ id: params.eventId });
|
|
131
|
+
const screeningEvent = params.event;
|
|
132
|
+
// 取得属性最適化(2023-01-25~)
|
|
133
|
+
const superEvent = yield repos.event.findById({ id: screeningEvent.superEvent.id }, { soundFormat: 1, videoFormat: 1 });
|
|
25
134
|
const soundFormatTypes = (Array.isArray(superEvent.soundFormat)) ? superEvent.soundFormat.map((f) => f.typeOf) : [];
|
|
26
135
|
const videoFormatTypes = (Array.isArray(superEvent.videoFormat)) ? superEvent.videoFormat.map((f) => f.typeOf) : [];
|
|
27
136
|
let availableOffers = [];
|
|
@@ -40,10 +149,6 @@ function searchScreeningEventTicketOffers(params) {
|
|
|
40
149
|
throw new factory.errors.NotFound('event.offers.itemOffered.id');
|
|
41
150
|
}
|
|
42
151
|
const { soundFormatChargeSpecifications, videoFormatChargeSpecifications, movieTicketTypeChargeSpecs } = yield searchPriceSpecs4event({ project: { id: screeningEvent.project.id }, soundFormatTypes, videoFormatTypes })(repos);
|
|
43
|
-
const screeningEventOfferSettings = screeningEvent.offers;
|
|
44
|
-
if (screeningEventOfferSettings === undefined) {
|
|
45
|
-
throw new factory.errors.NotFound('event.offers');
|
|
46
|
-
}
|
|
47
152
|
const unacceptedPaymentMethod = getUnacceptedPaymentMethodByEvent({ event: screeningEvent });
|
|
48
153
|
// 不許可決済方法があれば、該当オファーを除外
|
|
49
154
|
if (Array.isArray(unacceptedPaymentMethod) && unacceptedPaymentMethod.length > 0) {
|
|
@@ -95,7 +200,7 @@ function searchScreeningEventTicketOffers(params) {
|
|
|
95
200
|
});
|
|
96
201
|
let offers4event = availableOffers.map((availableOffer) => {
|
|
97
202
|
return (0, factory_1.createCompoundPriceSpec4event)({
|
|
98
|
-
eligibleQuantity:
|
|
203
|
+
eligibleQuantity: eventOffers.eligibleQuantity,
|
|
99
204
|
offer: availableOffer,
|
|
100
205
|
videoFormatChargeSpecifications,
|
|
101
206
|
soundFormatChargeSpecifications,
|
|
@@ -243,7 +348,9 @@ function searchEventTicketOffers(params) {
|
|
|
243
348
|
var _a;
|
|
244
349
|
const now = moment();
|
|
245
350
|
let event;
|
|
246
|
-
|
|
351
|
+
// イベント取得属性最適化(2023-01-23~)
|
|
352
|
+
// event = await repos.event.findById<factory.eventType.ScreeningEvent | factory.eventType.Event>({ id: params.event.id });
|
|
353
|
+
event = yield repos.event.findMinimizedIndividualEventById({
|
|
247
354
|
id: params.event.id
|
|
248
355
|
});
|
|
249
356
|
let offers;
|
|
@@ -259,7 +366,15 @@ function searchEventTicketOffers(params) {
|
|
|
259
366
|
throw new factory.errors.NotImplemented(`booking service '${eventOffers.offeredThrough.identifier}' not implemented`);
|
|
260
367
|
default:
|
|
261
368
|
// Chevreで券種オファーを検索
|
|
262
|
-
|
|
369
|
+
if (event.typeOf === factory.eventType.ScreeningEvent) {
|
|
370
|
+
offers = yield searchScreeningEventTicketOffers({ event })(repos);
|
|
371
|
+
}
|
|
372
|
+
else if (event.typeOf === factory.eventType.Event) {
|
|
373
|
+
offers = yield searchTransportationEventTicketOffers({ event })(repos);
|
|
374
|
+
}
|
|
375
|
+
else {
|
|
376
|
+
throw new factory.errors.NotImplemented(`'${event.typeOf}' not implemented`);
|
|
377
|
+
}
|
|
263
378
|
const specifiedStoreId = (_a = params.store) === null || _a === void 0 ? void 0 : _a.id;
|
|
264
379
|
if (typeof specifiedStoreId === 'string') {
|
|
265
380
|
// アプリケーションが利用可能なオファーに絞る
|
|
@@ -114,8 +114,6 @@ function processVoidTransaction4chevre(params) {
|
|
|
114
114
|
transactionNumber: { $eq: transactionNumber }
|
|
115
115
|
});
|
|
116
116
|
if (assetTransactions.length > 0) {
|
|
117
|
-
// 予約取引サービスで中止
|
|
118
|
-
// await repos.reserveTransaction.cancel({ transactionNumber });
|
|
119
117
|
yield ReserveTransactionService.cancel({ transactionNumber })(repos);
|
|
120
118
|
}
|
|
121
119
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as factory from '../../../factory';
|
|
2
|
+
import { IMinimizedIndividualEvent } from '../../../factory/event';
|
|
2
3
|
export import WebAPIIdentifier = factory.service.webAPI.Identifier;
|
|
3
4
|
export declare function createAuthorizeSeatReservationActionAttributes(params: {
|
|
4
5
|
acceptedOffers: factory.action.authorize.offer.seatReservation.IAcceptedOffer<factory.service.webAPI.Identifier.COA>[];
|
|
@@ -19,7 +20,7 @@ declare type IResultAcceptedOffer = factory.action.authorize.offer.seatReservati
|
|
|
19
20
|
export declare function responseBody2acceptedOffers4result(params: {
|
|
20
21
|
responseBody: factory.action.authorize.offer.seatReservation.IResponseBody<factory.service.webAPI.Identifier.COA>;
|
|
21
22
|
object: factory.action.authorize.offer.seatReservation.IObject<factory.service.webAPI.Identifier.COA>;
|
|
22
|
-
event:
|
|
23
|
+
event: IMinimizedIndividualEvent<factory.eventType.ScreeningEvent>;
|
|
23
24
|
seller: factory.transaction.placeOrder.ISeller;
|
|
24
25
|
bookingTime: Date;
|
|
25
26
|
totalPrice: number;
|
|
@@ -27,7 +27,11 @@ function authorize(params) {
|
|
|
27
27
|
if (transaction.agent.id !== params.agent.id) {
|
|
28
28
|
throw new factory.errors.Forbidden('Transaction not yours');
|
|
29
29
|
}
|
|
30
|
-
|
|
30
|
+
// イベント取得属性最適化(2023-01-23~)
|
|
31
|
+
// const screeningEvent = await repos.event.findById<factory.eventType.ScreeningEvent>({ id: params.object.event.id });
|
|
32
|
+
const screeningEvent = yield repos.event.findMinimizedIndividualEventById({
|
|
33
|
+
id: params.object.event.id
|
|
34
|
+
});
|
|
31
35
|
// 必ず定義されている前提
|
|
32
36
|
// const coaInfo = <factory.event.screeningEvent.ICOAInfo>screeningEvent.coaInfo;
|
|
33
37
|
// const acceptedOffersWithoutDetails = await createAcceptedOffersWithoutDetails({
|
|
@@ -158,7 +162,11 @@ function changeOffers(params) {
|
|
|
158
162
|
throw new factory.errors.Argument('Transaction', 'Action not found in the transaction');
|
|
159
163
|
}
|
|
160
164
|
validate4changeOffer({ action: authorizeAction, object: params.object });
|
|
161
|
-
|
|
165
|
+
// イベント取得属性最適化(2023-01-23~)
|
|
166
|
+
// const screeningEvent = await repos.event.findById<factory.eventType.ScreeningEvent>({ id: params.object.event.id });
|
|
167
|
+
const screeningEvent = yield repos.event.findMinimizedIndividualEventById({
|
|
168
|
+
id: params.object.event.id
|
|
169
|
+
});
|
|
162
170
|
// COA仮予約後にリクエストが来る前提
|
|
163
171
|
const acceptedOffer = params.object.acceptedOffer;
|
|
164
172
|
// 座席区分加算料金などを補完
|