@chevre/domain 22.13.0-alpha.6 → 22.13.0-alpha.7
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/lib/chevre/repo/event.d.ts +3 -2
- package/lib/chevre/repo/event.js +8 -4
- package/lib/chevre/service/event.d.ts +4 -33
- package/lib/chevre/service/event.js +0 -55
- package/lib/chevre/service/task/createEvent/createEventBySchedule/schedule2events.d.ts +15 -0
- package/lib/chevre/service/task/createEvent/createEventBySchedule/schedule2events.js +386 -0
- package/lib/chevre/service/task/createEvent/createEventBySchedule.js +61 -325
- package/package.json +2 -2
|
@@ -56,7 +56,9 @@ type IKeyOfProjection4minimizedEvent<T extends AvailableEventType> = T extends f
|
|
|
56
56
|
type IUnset<T extends AvailableEventType> = {
|
|
57
57
|
[key in keyof factory.event.IEvent<T>]?: 1;
|
|
58
58
|
};
|
|
59
|
-
export type ICreatingEvent4ttts = Pick<factory.event.IAttributes<factory.eventType.ScreeningEvent>, 'additionalProperty' | 'doorTime' | 'endDate' | 'eventStatus' | 'location' | 'name' | 'offers' | 'organizer' | 'project' | 'startDate' | 'superEvent' | 'typeOf'
|
|
59
|
+
export type ICreatingEvent4ttts = Pick<factory.event.IAttributes<factory.eventType.ScreeningEvent>, 'additionalProperty' | 'doorTime' | 'endDate' | 'eventStatus' | 'location' | 'name' | 'offers' | 'organizer' | 'project' | 'startDate' | 'superEvent' | 'typeOf' | 'identifier'> & {
|
|
60
|
+
identifier: string;
|
|
61
|
+
};
|
|
60
62
|
/**
|
|
61
63
|
* イベントリポジトリ
|
|
62
64
|
*/
|
|
@@ -160,7 +162,6 @@ export declare class EventRepo {
|
|
|
160
162
|
* tttsイベントを識別子によって冪等作成する
|
|
161
163
|
*/
|
|
162
164
|
saveEventByIdentifier4ttts(params: {
|
|
163
|
-
oldEventId: string;
|
|
164
165
|
attributes: ICreatingEvent4ttts;
|
|
165
166
|
}): Promise<{
|
|
166
167
|
id: string;
|
package/lib/chevre/repo/event.js
CHANGED
|
@@ -659,9 +659,12 @@ class EventRepo {
|
|
|
659
659
|
*/
|
|
660
660
|
saveEventByIdentifier4ttts(params) {
|
|
661
661
|
return __awaiter(this, void 0, void 0, function* () {
|
|
662
|
-
const { oldEventId } = params;
|
|
663
|
-
const _a = params.attributes, { project, typeOf, eventStatus } = _a, updateFields = __rest(_a, ["project", "typeOf", "eventStatus"]);
|
|
664
|
-
const identifier = oldEventId;
|
|
662
|
+
// const { oldEventId } = params;
|
|
663
|
+
const _a = params.attributes, { project, typeOf, eventStatus, identifier, organizer } = _a, updateFields = __rest(_a, ["project", "typeOf", "eventStatus", "identifier", "organizer"]);
|
|
664
|
+
// const identifier = oldEventId;
|
|
665
|
+
if (typeof identifier !== 'string' || identifier.length === 0) {
|
|
666
|
+
throw new factory.errors.ArgumentNull('identifier');
|
|
667
|
+
}
|
|
665
668
|
const uniqid = yield Promise.resolve().then(() => require('uniqid'));
|
|
666
669
|
const id = uniqid();
|
|
667
670
|
const doc = yield this.eventModel.findOneAndUpdate({
|
|
@@ -670,7 +673,7 @@ class EventRepo {
|
|
|
670
673
|
// 追加特性をキーに更新
|
|
671
674
|
additionalProperty: {
|
|
672
675
|
$exists: true,
|
|
673
|
-
$all: [{ name: 'oldEventId', value:
|
|
676
|
+
$all: [{ name: 'oldEventId', value: identifier }]
|
|
674
677
|
}
|
|
675
678
|
},
|
|
676
679
|
// upsertの場合、createがありうるので属性を除外しない
|
|
@@ -680,6 +683,7 @@ class EventRepo {
|
|
|
680
683
|
typeOf,
|
|
681
684
|
project,
|
|
682
685
|
eventStatus,
|
|
686
|
+
organizer,
|
|
683
687
|
identifier // イベントコードを必ず追加(2025-09-03~)
|
|
684
688
|
// ...(typeof identifier === 'string' && identifier !== '') ? { identifier } : undefined
|
|
685
689
|
},
|
|
@@ -5,14 +5,11 @@ import type * as COA from '@motionpicture/coa-service';
|
|
|
5
5
|
import type { ActionRepo } from '../repo/action';
|
|
6
6
|
import type { CategoryCodeRepo } from '../repo/categoryCode';
|
|
7
7
|
import type { CreativeWorkRepo } from '../repo/creativeWork';
|
|
8
|
-
import type { EventRepo
|
|
8
|
+
import type { EventRepo } from '../repo/event';
|
|
9
9
|
import type { EventSeriesRepo } from '../repo/eventSeries';
|
|
10
10
|
import type { MovieTheaterRepo } from '../repo/place/movieTheater';
|
|
11
11
|
import type { ScreeningRoomRepo } from '../repo/place/screeningRoom';
|
|
12
|
-
import type { ProjectRepo } from '../repo/project';
|
|
13
12
|
import type { SellerRepo } from '../repo/seller';
|
|
14
|
-
import type { SettingRepo } from '../repo/setting';
|
|
15
|
-
import type { TaskRepo } from '../repo/task';
|
|
16
13
|
import * as factory from '../factory';
|
|
17
14
|
interface IImportFromCOAParams {
|
|
18
15
|
project: {
|
|
@@ -38,7 +35,7 @@ interface IImportFromCOAParams {
|
|
|
38
35
|
/**
|
|
39
36
|
* イベントをインポートする
|
|
40
37
|
*/
|
|
41
|
-
|
|
38
|
+
declare function importFromCOA(params: IImportFromCOAParams): (repos: {
|
|
42
39
|
action: ActionRepo;
|
|
43
40
|
categoryCode: CategoryCodeRepo;
|
|
44
41
|
creativeWork: CreativeWorkRepo;
|
|
@@ -49,13 +46,10 @@ export declare function importFromCOA(params: IImportFromCOAParams): (repos: {
|
|
|
49
46
|
seller: SellerRepo;
|
|
50
47
|
masterService: COA.service.Master;
|
|
51
48
|
}) => Promise<void>;
|
|
52
|
-
export declare function minimizeSuperEvent(params: {
|
|
53
|
-
superEvent: factory.event.screeningEventSeries.IEvent;
|
|
54
|
-
}): factory.event.screeningEvent.ISuperEvent;
|
|
55
49
|
/**
|
|
56
50
|
* COA情報からイベントIDを作成する
|
|
57
51
|
*/
|
|
58
|
-
|
|
52
|
+
declare function createScreeningEventIdFromCOA(params: {
|
|
59
53
|
theaterCode: string;
|
|
60
54
|
titleCode: string;
|
|
61
55
|
titleBranchNum: string;
|
|
@@ -63,27 +57,4 @@ export declare function createScreeningEventIdFromCOA(params: {
|
|
|
63
57
|
screenCode: string;
|
|
64
58
|
timeBegin: string;
|
|
65
59
|
}): string;
|
|
66
|
-
|
|
67
|
-
* イベントコード指定でtttsイベントを冪等更新する
|
|
68
|
-
*/
|
|
69
|
-
export declare function updateEvent4ttts(params: {
|
|
70
|
-
/**
|
|
71
|
-
* 旧イベントID
|
|
72
|
-
*/
|
|
73
|
-
oldEventId: string;
|
|
74
|
-
/**
|
|
75
|
-
* イベント属性
|
|
76
|
-
*/
|
|
77
|
-
attributes: ICreatingEvent4ttts;
|
|
78
|
-
project: {
|
|
79
|
-
id: string;
|
|
80
|
-
};
|
|
81
|
-
}): (repos: {
|
|
82
|
-
action: ActionRepo;
|
|
83
|
-
event: EventRepo;
|
|
84
|
-
eventSeries: EventSeriesRepo;
|
|
85
|
-
project: ProjectRepo;
|
|
86
|
-
setting: SettingRepo;
|
|
87
|
-
task: TaskRepo;
|
|
88
|
-
}) => Promise<void>;
|
|
89
|
-
export { ICreatingEvent4ttts };
|
|
60
|
+
export { importFromCOA, createScreeningEventIdFromCOA };
|
|
@@ -10,17 +10,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.importFromCOA = importFromCOA;
|
|
13
|
-
exports.minimizeSuperEvent = minimizeSuperEvent;
|
|
14
13
|
exports.createScreeningEventIdFromCOA = createScreeningEventIdFromCOA;
|
|
15
|
-
exports.updateEvent4ttts = updateEvent4ttts;
|
|
16
14
|
const createDebug = require("debug");
|
|
17
15
|
// @ts-ignore
|
|
18
16
|
const difference = require("lodash.difference");
|
|
19
17
|
// import { google } from 'googleapis';
|
|
20
18
|
const moment = require("moment-timezone");
|
|
21
19
|
const factory = require("../factory");
|
|
22
|
-
// import { Settings } from '../settings';
|
|
23
|
-
const onEventChanged_1 = require("./offer/onEventChanged");
|
|
24
20
|
const debug = createDebug('chevre-domain:service:event');
|
|
25
21
|
/**
|
|
26
22
|
* イベントをインポートする
|
|
@@ -858,54 +854,3 @@ function createScreeningRoomFromCOA(project, seller, screenFromCOA) {
|
|
|
858
854
|
parentOrganization: { id: seller.id, typeOf: factory.organizationType.Corporation }
|
|
859
855
|
};
|
|
860
856
|
}
|
|
861
|
-
/**
|
|
862
|
-
* イベントコード指定でtttsイベントを冪等更新する
|
|
863
|
-
*/
|
|
864
|
-
function updateEvent4ttts(params) {
|
|
865
|
-
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
866
|
-
const updateObject = {
|
|
867
|
-
id: params.oldEventId,
|
|
868
|
-
identifier: params.oldEventId, // support identifier(2025-09-03~)
|
|
869
|
-
typeOf: factory.eventType.ScreeningEvent
|
|
870
|
-
};
|
|
871
|
-
const actionAttributes = {
|
|
872
|
-
project: { typeOf: factory.organizationType.Project, id: params.project.id },
|
|
873
|
-
typeOf: factory.actionType.UpdateAction,
|
|
874
|
-
agent: { typeOf: factory.organizationType.Project, id: params.project.id },
|
|
875
|
-
object: updateObject,
|
|
876
|
-
// replacee: reservation,
|
|
877
|
-
// replacer: params.attributes, // $unsetもありうるのでいったん保留
|
|
878
|
-
targetCollection: {
|
|
879
|
-
id: params.oldEventId,
|
|
880
|
-
typeOf: factory.eventType.ScreeningEvent
|
|
881
|
-
}
|
|
882
|
-
};
|
|
883
|
-
const action = yield repos.action.start(actionAttributes);
|
|
884
|
-
let savedEvent;
|
|
885
|
-
try {
|
|
886
|
-
savedEvent = yield repos.event.saveEventByIdentifier4ttts({
|
|
887
|
-
oldEventId: params.oldEventId,
|
|
888
|
-
attributes: params.attributes
|
|
889
|
-
});
|
|
890
|
-
}
|
|
891
|
-
catch (error) {
|
|
892
|
-
try {
|
|
893
|
-
yield repos.action.giveUp({ typeOf: action.typeOf, id: action.id, error });
|
|
894
|
-
}
|
|
895
|
-
catch (__) {
|
|
896
|
-
// 失敗したら仕方ない
|
|
897
|
-
}
|
|
898
|
-
throw error;
|
|
899
|
-
}
|
|
900
|
-
yield repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: { id: savedEvent.id } });
|
|
901
|
-
yield (0, onEventChanged_1.onEventChanged)({
|
|
902
|
-
id: [savedEvent.id],
|
|
903
|
-
project: { id: params.project.id },
|
|
904
|
-
typeOf: factory.eventType.ScreeningEvent,
|
|
905
|
-
isNew: false,
|
|
906
|
-
useInform: true
|
|
907
|
-
})(repos
|
|
908
|
-
// スケジュールによるイベント作成ではendDateに変更がないのでpendingReservationsへの同期はひとまず必要なし
|
|
909
|
-
);
|
|
910
|
-
});
|
|
911
|
-
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ICreatingEvent4ttts } from '../../../../repo/event';
|
|
2
|
+
import type { EventSeriesRepo } from '../../../../repo/eventSeries';
|
|
3
|
+
import type { MemberRepo } from '../../../../repo/member';
|
|
4
|
+
import type { MovieTheaterRepo } from '../../../../repo/place/movieTheater';
|
|
5
|
+
import type { ScreeningRoomRepo } from '../../../../repo/place/screeningRoom';
|
|
6
|
+
import type { ProductRepo } from '../../../../repo/product';
|
|
7
|
+
import * as factory from '../../../../factory';
|
|
8
|
+
declare function schedule2events(schedule: factory.schedule.IEventWithSchedule, createDate: Date): (repos: {
|
|
9
|
+
eventSeries: EventSeriesRepo;
|
|
10
|
+
member: MemberRepo;
|
|
11
|
+
movieTheater: MovieTheaterRepo;
|
|
12
|
+
screeningRoom: ScreeningRoomRepo;
|
|
13
|
+
product: ProductRepo;
|
|
14
|
+
}) => Promise<ICreatingEvent4ttts[]>;
|
|
15
|
+
export { schedule2events };
|
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.schedule2events = schedule2events;
|
|
13
|
+
const createDebug = require("debug");
|
|
14
|
+
const moment = require("moment-timezone");
|
|
15
|
+
const factory = require("../../../../factory");
|
|
16
|
+
// import { Settings } from '../../../settings';
|
|
17
|
+
const debug = createDebug('chevre-domain:service:task');
|
|
18
|
+
// tslint:disable-next-line:max-func-body-length
|
|
19
|
+
// function schedule2createEventParams(
|
|
20
|
+
// schedule: factory.schedule.IEventWithSchedule,
|
|
21
|
+
// createDate: Date
|
|
22
|
+
// ): factory.event.screeningEvent.ICreateParams[] {
|
|
23
|
+
// const eventServiceId = schedule.offers?.itemOffered?.id;
|
|
24
|
+
// const makesOffer = schedule.offers?.seller?.makesOffer;
|
|
25
|
+
// const applicationIds: string[] = (Array.isArray(makesOffer))
|
|
26
|
+
// ? makesOffer.map(({ availableAtOrFrom }) => availableAtOrFrom.id)
|
|
27
|
+
// : [];
|
|
28
|
+
// const eventSeriesId = schedule.superEvent?.id;
|
|
29
|
+
// if (typeof eventServiceId !== 'string' || eventServiceId === '') {
|
|
30
|
+
// throw new factory.errors.NotFound('schedule.offers.itemOffered.id');
|
|
31
|
+
// }
|
|
32
|
+
// if (typeof eventSeriesId !== 'string' || eventSeriesId === '') {
|
|
33
|
+
// throw new factory.errors.NotFound('schedule.superEvent.id');
|
|
34
|
+
// }
|
|
35
|
+
// // 引数情報取得
|
|
36
|
+
// if (schedule.eventSchedule === undefined) {
|
|
37
|
+
// throw new factory.errors.NotFound('eventSchedule');
|
|
38
|
+
// }
|
|
39
|
+
// const targetInfo = getTargetInfoByEventWithSchedule(schedule, createDate);
|
|
40
|
+
// debug(targetInfo.length, 'targetInfos ->', targetInfo);
|
|
41
|
+
// const createParams: factory.event.screeningEvent.ICreateParams[] = [];
|
|
42
|
+
// for (const performanceInfo of targetInfo) {
|
|
43
|
+
// const oldEventId = [
|
|
44
|
+
// // tslint:disable-next-line:no-magic-numbers
|
|
45
|
+
// performanceInfo.day.slice(-6),
|
|
46
|
+
// workPerformedIdentifier,
|
|
47
|
+
// movieTheater.branchCode,
|
|
48
|
+
// screeningRoom.branchCode,
|
|
49
|
+
// performanceInfo.start_time
|
|
50
|
+
// ].join('');
|
|
51
|
+
// const maxValue = movieTheater.offers?.eligibleQuantity?.maxValue;
|
|
52
|
+
// const availabilityEnds: Date = moment(performanceInfo.end_date)
|
|
53
|
+
// .tz('Asia/Tokyo')
|
|
54
|
+
// .endOf('date')
|
|
55
|
+
// .toDate();
|
|
56
|
+
// const availabilityStarts: Date = moment(performanceInfo.start_date)
|
|
57
|
+
// .tz('Asia/Tokyo')
|
|
58
|
+
// .startOf('date')
|
|
59
|
+
// // tslint:disable-next-line:no-magic-numbers
|
|
60
|
+
// .add(-3, 'months')
|
|
61
|
+
// .toDate();
|
|
62
|
+
// const validThrough: Date = moment(performanceInfo.end_date)
|
|
63
|
+
// .tz('Asia/Tokyo')
|
|
64
|
+
// .endOf('date')
|
|
65
|
+
// .toDate();
|
|
66
|
+
// const validFrom: Date = moment(performanceInfo.start_date)
|
|
67
|
+
// .tz('Asia/Tokyo')
|
|
68
|
+
// .startOf('date')
|
|
69
|
+
// // tslint:disable-next-line:no-magic-numbers
|
|
70
|
+
// .add(-3, 'months')
|
|
71
|
+
// .toDate();
|
|
72
|
+
// // イベント作成
|
|
73
|
+
// createParams.push({
|
|
74
|
+
// eventStatus: factory.eventStatusType.EventScheduled,
|
|
75
|
+
// doorTime: performanceInfo.door_time,
|
|
76
|
+
// startDate: performanceInfo.start_date,
|
|
77
|
+
// endDate: performanceInfo.end_date,
|
|
78
|
+
// offers: {
|
|
79
|
+
// eligibleQuantity: {
|
|
80
|
+
// ...(typeof maxValue === 'number') ? { maxValue } : undefined // ひとまず全座席予約可能なように
|
|
81
|
+
// },
|
|
82
|
+
// itemOffered: {
|
|
83
|
+
// // 興行ID追加(2022-09-01~)
|
|
84
|
+
// id: eventServiceId,
|
|
85
|
+
// serviceOutput: {
|
|
86
|
+
// typeOf: factory.reservationType.EventReservation,
|
|
87
|
+
// reservedTicket: {
|
|
88
|
+
// typeOf: 'Ticket',
|
|
89
|
+
// ticketedSeat: { typeOf: factory.placeType.Seat }
|
|
90
|
+
// }
|
|
91
|
+
// },
|
|
92
|
+
// },
|
|
93
|
+
// seller: {
|
|
94
|
+
// // event.offersにseller.makesOfferを追加(2022-11-18~)
|
|
95
|
+
// makesOffer: applicationIds.map((applicationId) => {
|
|
96
|
+
// return {
|
|
97
|
+
// typeOf: factory.offerType.Offer,
|
|
98
|
+
// availableAtOrFrom: { id: applicationId }, // support no-array(2024-10-13~),
|
|
99
|
+
// availabilityEnds,
|
|
100
|
+
// availabilityStarts,
|
|
101
|
+
// validFrom,
|
|
102
|
+
// validThrough
|
|
103
|
+
// };
|
|
104
|
+
// })
|
|
105
|
+
// }
|
|
106
|
+
// },
|
|
107
|
+
// // 旧フォーマットIDを追加特性に追加(2022-09-08~)
|
|
108
|
+
// additionalProperty: [
|
|
109
|
+
// { name: 'tourNumber', value: String(performanceInfo.tour_number) },
|
|
110
|
+
// { name: 'oldEventId', value: oldEventId }
|
|
111
|
+
// ],
|
|
112
|
+
// identifier: oldEventId
|
|
113
|
+
// });
|
|
114
|
+
// }
|
|
115
|
+
// return createParams;
|
|
116
|
+
// }
|
|
117
|
+
function schedule2events(schedule, createDate) {
|
|
118
|
+
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
119
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
120
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
121
|
+
debug('schedule2events processing...', JSON.stringify(schedule), createDate);
|
|
122
|
+
const eventServiceId = (_b = (_a = schedule.offers) === null || _a === void 0 ? void 0 : _a.itemOffered) === null || _b === void 0 ? void 0 : _b.id;
|
|
123
|
+
const makesOffer = (_d = (_c = schedule.offers) === null || _c === void 0 ? void 0 : _c.seller) === null || _d === void 0 ? void 0 : _d.makesOffer;
|
|
124
|
+
const applicationIds = (Array.isArray(makesOffer))
|
|
125
|
+
? makesOffer.map(({ availableAtOrFrom }) => availableAtOrFrom.id)
|
|
126
|
+
: [];
|
|
127
|
+
const eventSeriesId = (_e = schedule.superEvent) === null || _e === void 0 ? void 0 : _e.id;
|
|
128
|
+
const maxValue = (_g = (_f = schedule.offers) === null || _f === void 0 ? void 0 : _f.eligibleQuantity) === null || _g === void 0 ? void 0 : _g.maxValue;
|
|
129
|
+
const locationBranchCode = (_h = schedule.location) === null || _h === void 0 ? void 0 : _h.branchCode;
|
|
130
|
+
if (typeof eventServiceId !== 'string' || eventServiceId === '') {
|
|
131
|
+
throw new factory.errors.NotFound('schedule.offers.itemOffered.id required');
|
|
132
|
+
}
|
|
133
|
+
if (typeof eventSeriesId !== 'string' || eventSeriesId === '') {
|
|
134
|
+
throw new factory.errors.NotFound('schedule.superEvent.id required');
|
|
135
|
+
}
|
|
136
|
+
if (typeof maxValue !== 'number') {
|
|
137
|
+
throw new factory.errors.NotFound('schedule.offers.eligibleQuantity.maxValue required');
|
|
138
|
+
}
|
|
139
|
+
if (typeof locationBranchCode !== 'string' || locationBranchCode === '') {
|
|
140
|
+
throw new factory.errors.NotFound('location.branchCode required');
|
|
141
|
+
}
|
|
142
|
+
const project = schedule.project;
|
|
143
|
+
// 引数情報取得
|
|
144
|
+
if (schedule.eventSchedule === undefined) {
|
|
145
|
+
throw new factory.errors.NotFound('schedule.eventSchedule required');
|
|
146
|
+
}
|
|
147
|
+
const targetInfo = getTargetInfoByEventWithSchedule(schedule, createDate);
|
|
148
|
+
debug(targetInfo.length, 'targetInfos ->', targetInfo);
|
|
149
|
+
// fs.writeFileSync(
|
|
150
|
+
// `${__dirname}/../../../../../targetInfo_${schedule.eventSchedule?.typeOf}.json`,
|
|
151
|
+
// JSON.stringify(targetInfo, null, ' ')
|
|
152
|
+
// );
|
|
153
|
+
// return;
|
|
154
|
+
// 施設コンテンツ検索
|
|
155
|
+
const screeningEventSeries = (yield repos.eventSeries.projectEventSeriesFields({
|
|
156
|
+
project: { id: { $eq: project.id } },
|
|
157
|
+
id: { $eq: eventSeriesId }
|
|
158
|
+
}, [
|
|
159
|
+
'location', 'additionalProperty', 'description', 'endDate', 'headline', 'kanaName', 'name',
|
|
160
|
+
'soundFormat', 'startDate', 'typeOf', 'videoFormat', 'workPerformed'
|
|
161
|
+
])).shift();
|
|
162
|
+
if (screeningEventSeries === undefined) {
|
|
163
|
+
throw new factory.errors.NotFound(factory.eventType.ScreeningEventSeries);
|
|
164
|
+
}
|
|
165
|
+
const workPerformedIdentifier = screeningEventSeries.workPerformed.identifier;
|
|
166
|
+
// 劇場検索
|
|
167
|
+
const movieTheater = (yield repos.movieTheater.projectFields({
|
|
168
|
+
limit: 1,
|
|
169
|
+
page: 1,
|
|
170
|
+
project: { id: { $eq: project.id } },
|
|
171
|
+
branchCode: { $eq: screeningEventSeries.location.branchCode }
|
|
172
|
+
}, ['id', 'branchCode', 'parentOrganization'])).shift();
|
|
173
|
+
if (movieTheater === undefined) {
|
|
174
|
+
throw new factory.errors.NotFound(factory.placeType.MovieTheater);
|
|
175
|
+
}
|
|
176
|
+
const seller = movieTheater.parentOrganization;
|
|
177
|
+
const screeningRoom = (yield repos.screeningRoom.searchScreeningRooms({
|
|
178
|
+
limit: 1,
|
|
179
|
+
page: 1,
|
|
180
|
+
project: { id: { $eq: project.id } },
|
|
181
|
+
containedInPlace: { id: { $eq: movieTheater.id } },
|
|
182
|
+
branchCode: { $eq: locationBranchCode }
|
|
183
|
+
})).shift();
|
|
184
|
+
if (screeningRoom === undefined) {
|
|
185
|
+
throw new factory.errors.NotFound(factory.placeType.ScreeningRoom, `${factory.placeType.ScreeningRoom} ${locationBranchCode} not found`);
|
|
186
|
+
}
|
|
187
|
+
// 興行検索
|
|
188
|
+
const eventService = (yield repos.product.projectFields({
|
|
189
|
+
limit: 1,
|
|
190
|
+
page: 1,
|
|
191
|
+
project: { id: { $eq: project.id } },
|
|
192
|
+
id: { $eq: eventServiceId }
|
|
193
|
+
// productID: { $eq: eventServiceProductID }
|
|
194
|
+
}, ['name'])).shift();
|
|
195
|
+
if (typeof (eventService === null || eventService === void 0 ? void 0 : eventService.id) !== 'string') {
|
|
196
|
+
throw new Error(`EventService ${eventServiceId} not found`);
|
|
197
|
+
}
|
|
198
|
+
let existingApplicationMembers = [];
|
|
199
|
+
if (applicationIds.length > 0) {
|
|
200
|
+
existingApplicationMembers = yield repos.member.searchCustomerMembers({
|
|
201
|
+
limit: 100,
|
|
202
|
+
page: 1,
|
|
203
|
+
project: { id: project.id },
|
|
204
|
+
member: {
|
|
205
|
+
// typeOf: {
|
|
206
|
+
// $eq: factory.creativeWorkType.WebApplication
|
|
207
|
+
// },
|
|
208
|
+
id: { $in: applicationIds }
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
// ロールで絞る(customer or pos)
|
|
213
|
+
// existingApplicationMembers = existingApplicationMembers
|
|
214
|
+
// .filter((m) => {
|
|
215
|
+
// return Array.isArray(m.member.hasRole) && m.member.hasRole.some((r) => AVAILABLE_ROLE_NAMES.includes(r.roleName));
|
|
216
|
+
// });
|
|
217
|
+
const creatingEvents = [];
|
|
218
|
+
for (const performanceInfo of targetInfo) {
|
|
219
|
+
const oldEventId = [
|
|
220
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
221
|
+
performanceInfo.day.slice(-6),
|
|
222
|
+
workPerformedIdentifier,
|
|
223
|
+
movieTheater.branchCode,
|
|
224
|
+
screeningRoom.branchCode,
|
|
225
|
+
performanceInfo.start_time
|
|
226
|
+
].join('');
|
|
227
|
+
// const maxValue = movieTheater.offers?.eligibleQuantity?.maxValue;
|
|
228
|
+
const availabilityEnds = moment(performanceInfo.end_date)
|
|
229
|
+
.tz('Asia/Tokyo')
|
|
230
|
+
.endOf('date')
|
|
231
|
+
.toDate();
|
|
232
|
+
const availabilityStarts = moment(performanceInfo.start_date)
|
|
233
|
+
.tz('Asia/Tokyo')
|
|
234
|
+
.startOf('date')
|
|
235
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
236
|
+
.add(-3, 'months')
|
|
237
|
+
.toDate();
|
|
238
|
+
const validThrough = moment(performanceInfo.end_date)
|
|
239
|
+
.tz('Asia/Tokyo')
|
|
240
|
+
.endOf('date')
|
|
241
|
+
.toDate();
|
|
242
|
+
const validFrom = moment(performanceInfo.start_date)
|
|
243
|
+
.tz('Asia/Tokyo')
|
|
244
|
+
.startOf('date')
|
|
245
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
246
|
+
.add(-3, 'months')
|
|
247
|
+
.toDate();
|
|
248
|
+
const offersSeller = {
|
|
249
|
+
typeOf: factory.organizationType.Corporation,
|
|
250
|
+
id: String(seller === null || seller === void 0 ? void 0 : seller.id),
|
|
251
|
+
// event.offersにseller.makesOfferを追加(2022-11-18~)
|
|
252
|
+
makesOffer: existingApplicationMembers.map((a) => {
|
|
253
|
+
return {
|
|
254
|
+
typeOf: factory.offerType.Offer,
|
|
255
|
+
availableAtOrFrom: { id: a.member.id }, // support no-array(2024-10-13~),
|
|
256
|
+
availabilityEnds,
|
|
257
|
+
availabilityStarts,
|
|
258
|
+
validFrom,
|
|
259
|
+
validThrough
|
|
260
|
+
};
|
|
261
|
+
})
|
|
262
|
+
};
|
|
263
|
+
const offers = {
|
|
264
|
+
typeOf: factory.offerType.Offer,
|
|
265
|
+
eligibleQuantity: {
|
|
266
|
+
typeOf: 'QuantitativeValue',
|
|
267
|
+
unitCode: factory.unitCode.C62,
|
|
268
|
+
maxValue
|
|
269
|
+
},
|
|
270
|
+
itemOffered: Object.assign({
|
|
271
|
+
// 興行ID追加(2022-09-01~)
|
|
272
|
+
id: eventService.id, serviceOutput: {
|
|
273
|
+
typeOf: factory.reservationType.EventReservation,
|
|
274
|
+
reservedTicket: {
|
|
275
|
+
typeOf: 'Ticket',
|
|
276
|
+
ticketedSeat: { typeOf: factory.placeType.Seat }
|
|
277
|
+
}
|
|
278
|
+
}, typeOf: factory.product.ProductType.EventService, availableChannel: {
|
|
279
|
+
typeOf: 'ServiceChannel',
|
|
280
|
+
serviceLocation: {
|
|
281
|
+
typeOf: screeningRoom.typeOf,
|
|
282
|
+
branchCode: screeningRoom.branchCode,
|
|
283
|
+
name: screeningRoom.name,
|
|
284
|
+
containedInPlace: Object.assign({ typeOf: screeningEventSeries.location.typeOf, id: screeningEventSeries.location.id, branchCode: screeningEventSeries.location.branchCode }, (screeningEventSeries.location.name !== undefined)
|
|
285
|
+
? { name: screeningEventSeries.location.name }
|
|
286
|
+
: undefined)
|
|
287
|
+
}
|
|
288
|
+
} }, { name: { ja: (typeof eventService.name === 'string') ? eventService.name : String((_j = eventService.name) === null || _j === void 0 ? void 0 : _j.ja) } }),
|
|
289
|
+
seller: offersSeller
|
|
290
|
+
};
|
|
291
|
+
const screeningEventSuperEvent = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ typeOf: screeningEventSeries.typeOf, id: screeningEventSeries.id, videoFormat: screeningEventSeries.videoFormat, soundFormat: screeningEventSeries.soundFormat, workPerformed: screeningEventSeries.workPerformed, location: screeningEventSeries.location, kanaName: screeningEventSeries.kanaName, name: screeningEventSeries.name }, (Array.isArray(screeningEventSeries.additionalProperty))
|
|
292
|
+
? { additionalProperty: screeningEventSeries.additionalProperty }
|
|
293
|
+
: undefined), (screeningEventSeries.startDate !== undefined)
|
|
294
|
+
? { startDate: screeningEventSeries.startDate }
|
|
295
|
+
: undefined), (screeningEventSeries.endDate !== undefined)
|
|
296
|
+
? { endDate: screeningEventSeries.endDate }
|
|
297
|
+
: undefined), (screeningEventSeries.description !== undefined)
|
|
298
|
+
? { description: screeningEventSeries.description }
|
|
299
|
+
: undefined), (screeningEventSeries.headline !== undefined)
|
|
300
|
+
? { headline: screeningEventSeries.headline }
|
|
301
|
+
: undefined);
|
|
302
|
+
// イベント作成
|
|
303
|
+
creatingEvents.push({
|
|
304
|
+
project: { id: project.id, typeOf: factory.organizationType.Project },
|
|
305
|
+
typeOf: factory.eventType.ScreeningEvent,
|
|
306
|
+
eventStatus: factory.eventStatusType.EventScheduled,
|
|
307
|
+
name: screeningEventSeries.name,
|
|
308
|
+
doorTime: performanceInfo.door_time,
|
|
309
|
+
startDate: performanceInfo.start_date,
|
|
310
|
+
endDate: performanceInfo.end_date,
|
|
311
|
+
superEvent: screeningEventSuperEvent,
|
|
312
|
+
location: Object.assign({ typeOf: screeningRoom.typeOf, branchCode: screeningRoom.branchCode, name: screeningRoom.name }, (screeningRoom.address !== undefined) ? { address: screeningRoom.address } : undefined),
|
|
313
|
+
offers: offers,
|
|
314
|
+
// 旧フォーマットIDを追加特性に追加(2022-09-08~)
|
|
315
|
+
additionalProperty: [
|
|
316
|
+
{ name: 'tourNumber', value: String(performanceInfo.tour_number) },
|
|
317
|
+
{ name: 'oldEventId', value: oldEventId }
|
|
318
|
+
],
|
|
319
|
+
// organizer追加(2023-07-12~)
|
|
320
|
+
organizer: { id: seller.id },
|
|
321
|
+
identifier: oldEventId
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
return creatingEvents;
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
function getTargetInfoByEventWithSchedule(settings, createDate) {
|
|
328
|
+
const performanceInfos = [];
|
|
329
|
+
const { eventSchedule } = settings;
|
|
330
|
+
// 作成対象時間: 9,10,11など
|
|
331
|
+
// const hours: string[] = ['9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22'];
|
|
332
|
+
// const minutes = ['00', '15', '30', '45'];
|
|
333
|
+
// const tours = ['1', '2', '3', '4'];
|
|
334
|
+
// 1日分作成する
|
|
335
|
+
const now = (createDate instanceof Date)
|
|
336
|
+
? moment(createDate)
|
|
337
|
+
: moment();
|
|
338
|
+
let startDate = moment.tz(`${now.tz(eventSchedule.scheduleTimezone)
|
|
339
|
+
.format('YYYYMMDD')} ${eventSchedule.startTime}`, 'YYYYMMDD HH:mm:ss', eventSchedule.scheduleTimezone);
|
|
340
|
+
const startDateShouldBeLte = moment.tz(`${now.tz(eventSchedule.scheduleTimezone)
|
|
341
|
+
.format('YYYYMMDD')} ${eventSchedule.endTime}`, 'YYYYMMDD HH:mm:ss', eventSchedule.scheduleTimezone);
|
|
342
|
+
const frequencyInMinutes = moment.duration(eventSchedule.repeatFrequency)
|
|
343
|
+
.asMinutes();
|
|
344
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
345
|
+
const repeatCountInHour = Math.floor(60 / frequencyInMinutes);
|
|
346
|
+
let i = 0;
|
|
347
|
+
while (startDate < startDateShouldBeLte) {
|
|
348
|
+
i += 1;
|
|
349
|
+
if (i > 1) {
|
|
350
|
+
startDate = moment(startDate)
|
|
351
|
+
.add(moment.duration(eventSchedule.repeatFrequency));
|
|
352
|
+
}
|
|
353
|
+
const hour = `0${moment(startDate)
|
|
354
|
+
.format('HH')}`
|
|
355
|
+
// 2桁でない時は'0'詰め
|
|
356
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
357
|
+
.slice(-2);
|
|
358
|
+
let tourIndex = i % repeatCountInHour;
|
|
359
|
+
if (tourIndex === 0) {
|
|
360
|
+
tourIndex = repeatCountInHour;
|
|
361
|
+
}
|
|
362
|
+
const tourNumber = `${hour}${tourIndex}`;
|
|
363
|
+
const endDate = moment(startDate)
|
|
364
|
+
.add(moment.duration(eventSchedule.duration));
|
|
365
|
+
const day = moment(startDate)
|
|
366
|
+
.tz(eventSchedule.scheduleTimezone)
|
|
367
|
+
.format('YYYYMMDD');
|
|
368
|
+
const startTime = moment(startDate)
|
|
369
|
+
.tz(eventSchedule.scheduleTimezone)
|
|
370
|
+
.format('HHmm');
|
|
371
|
+
const endTime = moment(endDate)
|
|
372
|
+
.tz(eventSchedule.scheduleTimezone)
|
|
373
|
+
.format('HHmm');
|
|
374
|
+
performanceInfos.push({
|
|
375
|
+
day: day,
|
|
376
|
+
start_time: startTime,
|
|
377
|
+
end_time: endTime,
|
|
378
|
+
door_time: startDate.toDate(),
|
|
379
|
+
start_date: startDate.toDate(),
|
|
380
|
+
end_date: endDate.toDate(),
|
|
381
|
+
tour_number: tourNumber,
|
|
382
|
+
duration: eventSchedule.duration
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
return performanceInfos;
|
|
386
|
+
}
|
|
@@ -11,349 +11,85 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.createEventBySchedule = createEventBySchedule;
|
|
13
13
|
const createDebug = require("debug");
|
|
14
|
-
// import * as fs from 'fs';
|
|
15
|
-
const moment = require("moment-timezone");
|
|
16
14
|
const factory = require("../../../factory");
|
|
15
|
+
const onEventChanged_1 = require("../../offer/onEventChanged");
|
|
17
16
|
// import { Settings } from '../../../settings';
|
|
18
|
-
const
|
|
19
|
-
const debug = createDebug('chevre-domain:service:task');
|
|
17
|
+
const schedule2events_1 = require("./createEventBySchedule/schedule2events");
|
|
18
|
+
const debug = createDebug('chevre-domain:service:task:createEvent');
|
|
19
|
+
/**
|
|
20
|
+
* イベントコード指定でtttsイベントを冪等更新する
|
|
21
|
+
*/
|
|
22
|
+
function updateEvent4ttts(params) {
|
|
23
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
const updateObject = {
|
|
25
|
+
id: params.attributes.identifier,
|
|
26
|
+
identifier: params.attributes.identifier, // support identifier(2025-09-03~)
|
|
27
|
+
typeOf: factory.eventType.ScreeningEvent
|
|
28
|
+
};
|
|
29
|
+
const actionAttributes = {
|
|
30
|
+
project: { typeOf: factory.organizationType.Project, id: params.project.id },
|
|
31
|
+
typeOf: factory.actionType.UpdateAction,
|
|
32
|
+
agent: { typeOf: factory.organizationType.Project, id: params.project.id },
|
|
33
|
+
object: updateObject,
|
|
34
|
+
// replacee: reservation,
|
|
35
|
+
// replacer: params.attributes, // $unsetもありうるのでいったん保留
|
|
36
|
+
targetCollection: {
|
|
37
|
+
id: params.attributes.identifier,
|
|
38
|
+
typeOf: factory.eventType.ScreeningEvent
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
const action = yield repos.action.start(actionAttributes);
|
|
42
|
+
let savedEvent;
|
|
43
|
+
try {
|
|
44
|
+
savedEvent = yield repos.event.saveEventByIdentifier4ttts({
|
|
45
|
+
// oldEventId: params.oldEventId,
|
|
46
|
+
attributes: params.attributes
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
try {
|
|
51
|
+
yield repos.action.giveUp({ typeOf: action.typeOf, id: action.id, error });
|
|
52
|
+
}
|
|
53
|
+
catch (__) {
|
|
54
|
+
// 失敗したら仕方ない
|
|
55
|
+
}
|
|
56
|
+
throw error;
|
|
57
|
+
}
|
|
58
|
+
yield repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: { id: savedEvent.id } });
|
|
59
|
+
yield (0, onEventChanged_1.onEventChanged)({
|
|
60
|
+
id: [savedEvent.id],
|
|
61
|
+
project: { id: params.project.id },
|
|
62
|
+
typeOf: factory.eventType.ScreeningEvent,
|
|
63
|
+
isNew: false,
|
|
64
|
+
useInform: true
|
|
65
|
+
})(repos
|
|
66
|
+
// スケジュールによるイベント作成ではendDateに変更がないのでpendingReservationsへの同期はひとまず必要なし
|
|
67
|
+
);
|
|
68
|
+
});
|
|
69
|
+
}
|
|
20
70
|
function createEvents(
|
|
21
71
|
// schedule: factory.schedule.ISchedule4ttts | factory.schedule.IEventWithSchedule,
|
|
22
72
|
schedule, createDate) {
|
|
23
|
-
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
24
73
|
return (repos
|
|
25
74
|
// settings: Settings
|
|
26
75
|
) => __awaiter(this, void 0, void 0, function* () {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
// return;
|
|
30
|
-
const eventServiceId = (_b = (_a = schedule.offers) === null || _a === void 0 ? void 0 : _a.itemOffered) === null || _b === void 0 ? void 0 : _b.id;
|
|
31
|
-
const makesOffer = (_d = (_c = schedule.offers) === null || _c === void 0 ? void 0 : _c.seller) === null || _d === void 0 ? void 0 : _d.makesOffer;
|
|
32
|
-
const applicationIds = (Array.isArray(makesOffer))
|
|
33
|
-
? makesOffer.map(({ availableAtOrFrom }) => availableAtOrFrom.id)
|
|
34
|
-
: [];
|
|
35
|
-
const eventSeriesId = (_e = schedule.superEvent) === null || _e === void 0 ? void 0 : _e.id;
|
|
36
|
-
if (typeof eventServiceId !== 'string' || eventServiceId === '') {
|
|
37
|
-
throw new factory.errors.NotFound('schedule.offers.itemOffered.id');
|
|
38
|
-
}
|
|
39
|
-
if (typeof eventSeriesId !== 'string' || eventSeriesId === '') {
|
|
40
|
-
throw new factory.errors.NotFound('schedule.superEvent.id');
|
|
41
|
-
}
|
|
42
|
-
const project = schedule.project;
|
|
43
|
-
// 引数情報取得
|
|
44
|
-
if (schedule.eventSchedule === undefined) {
|
|
45
|
-
throw new factory.errors.NotFound('eventSchedule');
|
|
46
|
-
}
|
|
47
|
-
const targetInfo = getTargetInfoByEventWithSchedule(schedule, createDate);
|
|
48
|
-
debug(targetInfo.length, 'targetInfos ->', targetInfo);
|
|
49
|
-
// fs.writeFileSync(
|
|
50
|
-
// `${__dirname}/../../../../../targetInfo_${schedule.eventSchedule?.typeOf}.json`,
|
|
51
|
-
// JSON.stringify(targetInfo, null, ' ')
|
|
52
|
-
// );
|
|
53
|
-
// return;
|
|
54
|
-
// 施設コンテンツ検索
|
|
55
|
-
const screeningEventSeries = (yield repos.eventSeries.projectEventSeriesFields({
|
|
56
|
-
project: { id: { $eq: project.id } },
|
|
57
|
-
id: { $eq: eventSeriesId }
|
|
58
|
-
}, [
|
|
59
|
-
'location', 'additionalProperty', 'description', 'endDate', 'headline', 'kanaName', 'name',
|
|
60
|
-
'soundFormat', 'startDate', 'typeOf', 'videoFormat', 'workPerformed'
|
|
61
|
-
])).shift();
|
|
62
|
-
if (screeningEventSeries === undefined) {
|
|
63
|
-
throw new factory.errors.NotFound(factory.eventType.ScreeningEventSeries);
|
|
64
|
-
}
|
|
65
|
-
const workPerformedIdentifier = screeningEventSeries.workPerformed.identifier;
|
|
66
|
-
// 劇場検索
|
|
67
|
-
const movieTheaters = yield repos.movieTheater.projectFields({
|
|
68
|
-
limit: 1,
|
|
69
|
-
page: 1,
|
|
70
|
-
project: { id: { $eq: project.id } },
|
|
71
|
-
branchCode: { $eq: screeningEventSeries.location.branchCode }
|
|
72
|
-
}, ['id', 'branchCode', 'offers', 'parentOrganization']);
|
|
73
|
-
const movieTheater = movieTheaters.shift();
|
|
74
|
-
if (movieTheater === undefined) {
|
|
75
|
-
throw new factory.errors.NotFound(factory.placeType.MovieTheater);
|
|
76
|
-
}
|
|
77
|
-
const seller = movieTheater.parentOrganization;
|
|
78
|
-
const screeningRooms = yield repos.screeningRoom.searchScreeningRooms({
|
|
79
|
-
limit: 1,
|
|
80
|
-
page: 1,
|
|
81
|
-
project: { id: { $eq: project.id } },
|
|
82
|
-
containedInPlace: { id: { $eq: movieTheater.id } }
|
|
83
|
-
});
|
|
84
|
-
const screeningRoom = screeningRooms.shift();
|
|
85
|
-
if (screeningRoom === undefined) {
|
|
86
|
-
throw new factory.errors.NotFound(factory.placeType.ScreeningRoom);
|
|
87
|
-
}
|
|
88
|
-
// 興行検索
|
|
89
|
-
// const eventServiceProductID = schedule.eventServiceProductID; // 興行設定に変更(2023-09-24~)
|
|
90
|
-
const searchEventServicesResult = yield repos.product.projectFields({
|
|
91
|
-
limit: 1,
|
|
92
|
-
page: 1,
|
|
93
|
-
project: { id: { $eq: project.id } },
|
|
94
|
-
id: { $eq: eventServiceId }
|
|
95
|
-
// productID: { $eq: eventServiceProductID }
|
|
96
|
-
}, ['name']);
|
|
97
|
-
const eventService = searchEventServicesResult.shift();
|
|
98
|
-
if (typeof (eventService === null || eventService === void 0 ? void 0 : eventService.id) !== 'string') {
|
|
99
|
-
throw new Error(`EventService ${eventServiceId} not found`);
|
|
100
|
-
}
|
|
101
|
-
let existingApplicationMembers = [];
|
|
102
|
-
if (applicationIds.length > 0) {
|
|
103
|
-
existingApplicationMembers = yield repos.member.searchCustomerMembers({
|
|
104
|
-
limit: 100,
|
|
105
|
-
page: 1,
|
|
106
|
-
project: { id: project.id },
|
|
107
|
-
member: {
|
|
108
|
-
// typeOf: {
|
|
109
|
-
// $eq: factory.creativeWorkType.WebApplication
|
|
110
|
-
// },
|
|
111
|
-
id: { $in: applicationIds }
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
// ロールで絞る(customer or pos)
|
|
116
|
-
// existingApplicationMembers = existingApplicationMembers
|
|
117
|
-
// .filter((m) => {
|
|
118
|
-
// return Array.isArray(m.member.hasRole) && m.member.hasRole.some((r) => AVAILABLE_ROLE_NAMES.includes(r.roleName));
|
|
119
|
-
// });
|
|
120
|
-
for (const performanceInfo of targetInfo) {
|
|
121
|
-
const oldEventId = [
|
|
122
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
123
|
-
performanceInfo.day.slice(-6),
|
|
124
|
-
workPerformedIdentifier,
|
|
125
|
-
movieTheater.branchCode,
|
|
126
|
-
screeningRoom.branchCode,
|
|
127
|
-
performanceInfo.start_time
|
|
128
|
-
].join('');
|
|
129
|
-
const maxValue = (_g = (_f = movieTheater.offers) === null || _f === void 0 ? void 0 : _f.eligibleQuantity) === null || _g === void 0 ? void 0 : _g.maxValue;
|
|
130
|
-
const availabilityEnds = moment(performanceInfo.end_date)
|
|
131
|
-
.tz('Asia/Tokyo')
|
|
132
|
-
.endOf('date')
|
|
133
|
-
.toDate();
|
|
134
|
-
const availabilityStarts = moment(performanceInfo.start_date)
|
|
135
|
-
.tz('Asia/Tokyo')
|
|
136
|
-
.startOf('date')
|
|
137
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
138
|
-
.add(-3, 'months')
|
|
139
|
-
.toDate();
|
|
140
|
-
const validThrough = moment(performanceInfo.end_date)
|
|
141
|
-
.tz('Asia/Tokyo')
|
|
142
|
-
.endOf('date')
|
|
143
|
-
.toDate();
|
|
144
|
-
const validFrom = moment(performanceInfo.start_date)
|
|
145
|
-
.tz('Asia/Tokyo')
|
|
146
|
-
.startOf('date')
|
|
147
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
148
|
-
.add(-3, 'months')
|
|
149
|
-
.toDate();
|
|
150
|
-
const offersSeller = {
|
|
151
|
-
typeOf: factory.organizationType.Corporation,
|
|
152
|
-
id: String(seller === null || seller === void 0 ? void 0 : seller.id),
|
|
153
|
-
// event.offersにseller.makesOfferを追加(2022-11-18~)
|
|
154
|
-
makesOffer: existingApplicationMembers.map((a) => {
|
|
155
|
-
return {
|
|
156
|
-
typeOf: factory.offerType.Offer,
|
|
157
|
-
availableAtOrFrom: { id: a.member.id }, // support no-array(2024-10-13~),
|
|
158
|
-
availabilityEnds,
|
|
159
|
-
availabilityStarts,
|
|
160
|
-
validFrom,
|
|
161
|
-
validThrough
|
|
162
|
-
};
|
|
163
|
-
})
|
|
164
|
-
};
|
|
165
|
-
const offers = Object.assign({ typeOf: factory.offerType.Offer, eligibleQuantity: Object.assign({ typeOf: 'QuantitativeValue', unitCode: factory.unitCode.C62 }, (typeof maxValue === 'number') ? { maxValue } : undefined // ひとまず全座席予約可能なように
|
|
166
|
-
), itemOffered: Object.assign({
|
|
167
|
-
// 興行ID追加(2022-09-01~)
|
|
168
|
-
id: eventService.id, serviceOutput: {
|
|
169
|
-
typeOf: factory.reservationType.EventReservation,
|
|
170
|
-
reservedTicket: {
|
|
171
|
-
typeOf: 'Ticket',
|
|
172
|
-
ticketedSeat: { typeOf: factory.placeType.Seat }
|
|
173
|
-
}
|
|
174
|
-
}, typeOf: factory.product.ProductType.EventService, availableChannel: {
|
|
175
|
-
typeOf: 'ServiceChannel',
|
|
176
|
-
serviceLocation: {
|
|
177
|
-
typeOf: screeningRoom.typeOf,
|
|
178
|
-
branchCode: screeningRoom.branchCode,
|
|
179
|
-
name: screeningRoom.name,
|
|
180
|
-
containedInPlace: Object.assign({ typeOf: screeningEventSeries.location.typeOf, id: screeningEventSeries.location.id, branchCode: screeningEventSeries.location.branchCode }, (screeningEventSeries.location.name !== undefined)
|
|
181
|
-
? { name: screeningEventSeries.location.name }
|
|
182
|
-
: undefined)
|
|
183
|
-
}
|
|
184
|
-
} }, { name: { ja: (typeof eventService.name === 'string') ? eventService.name : String((_h = eventService.name) === null || _h === void 0 ? void 0 : _h.ja) } }), seller: offersSeller }, {
|
|
185
|
-
// availabilityEnds, // discontinue(2024-10-16~)
|
|
186
|
-
// availabilityStarts,
|
|
187
|
-
// validThrough,
|
|
188
|
-
// validFrom
|
|
189
|
-
});
|
|
190
|
-
const screeningEventSuperEvent = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ typeOf: screeningEventSeries.typeOf, id: screeningEventSeries.id, videoFormat: screeningEventSeries.videoFormat, soundFormat: screeningEventSeries.soundFormat, workPerformed: screeningEventSeries.workPerformed, location: screeningEventSeries.location, kanaName: screeningEventSeries.kanaName, name: screeningEventSeries.name }, (Array.isArray(screeningEventSeries.additionalProperty))
|
|
191
|
-
? { additionalProperty: screeningEventSeries.additionalProperty }
|
|
192
|
-
: undefined), (screeningEventSeries.startDate !== undefined)
|
|
193
|
-
? { startDate: screeningEventSeries.startDate }
|
|
194
|
-
: undefined), (screeningEventSeries.endDate !== undefined)
|
|
195
|
-
? { endDate: screeningEventSeries.endDate }
|
|
196
|
-
: undefined), (screeningEventSeries.description !== undefined)
|
|
197
|
-
? { description: screeningEventSeries.description }
|
|
198
|
-
: undefined), (screeningEventSeries.headline !== undefined)
|
|
199
|
-
? { headline: screeningEventSeries.headline }
|
|
200
|
-
: undefined);
|
|
201
|
-
// イベント作成
|
|
202
|
-
const eventAttributes = {
|
|
203
|
-
project: { id: project.id, typeOf: factory.organizationType.Project },
|
|
204
|
-
typeOf: factory.eventType.ScreeningEvent,
|
|
205
|
-
eventStatus: factory.eventStatusType.EventScheduled,
|
|
206
|
-
name: screeningEventSeries.name,
|
|
207
|
-
doorTime: performanceInfo.door_time,
|
|
208
|
-
startDate: performanceInfo.start_date,
|
|
209
|
-
endDate: performanceInfo.end_date,
|
|
210
|
-
superEvent: screeningEventSuperEvent,
|
|
211
|
-
location: Object.assign({ typeOf: screeningRoom.typeOf, branchCode: screeningRoom.branchCode, name: screeningRoom.name }, (screeningRoom.address !== undefined) ? { address: screeningRoom.address } : undefined),
|
|
212
|
-
offers: offers,
|
|
213
|
-
// checkInCount: undefined,
|
|
214
|
-
// attendeeCount: undefined,
|
|
215
|
-
// 旧フォーマットIDを追加特性に追加(2022-09-08~)
|
|
216
|
-
additionalProperty: [
|
|
217
|
-
{ name: 'tourNumber', value: String(performanceInfo.tour_number) },
|
|
218
|
-
{ name: 'oldEventId', value: oldEventId }
|
|
219
|
-
],
|
|
220
|
-
// organizer追加(2023-07-12~)
|
|
221
|
-
organizer: { id: seller.id }
|
|
222
|
-
};
|
|
76
|
+
const creatingEvents = yield (0, schedule2events_1.schedule2events)(schedule, createDate)(repos);
|
|
77
|
+
for (const eventAttributes of creatingEvents) {
|
|
223
78
|
// domain.serviceで実装(2022-09-10~)
|
|
224
|
-
debug('updating event...',
|
|
225
|
-
yield
|
|
226
|
-
oldEventId,
|
|
79
|
+
debug('updating event...', eventAttributes.identifier, eventAttributes.startDate);
|
|
80
|
+
yield updateEvent4ttts({
|
|
81
|
+
// oldEventId,
|
|
227
82
|
attributes: eventAttributes,
|
|
228
83
|
project: { id: eventAttributes.project.id }
|
|
229
84
|
// agent: eventAttributes.project
|
|
230
85
|
})(repos
|
|
231
86
|
// settings
|
|
232
87
|
);
|
|
233
|
-
debug('event update(updateEvent4ttts)',
|
|
88
|
+
debug('event update(updateEvent4ttts)', eventAttributes.identifier, eventAttributes.startDate);
|
|
234
89
|
}
|
|
235
|
-
debug(
|
|
90
|
+
debug(creatingEvents.length, 'events updated');
|
|
236
91
|
});
|
|
237
92
|
}
|
|
238
|
-
/**
|
|
239
|
-
* パフォーマンス作成・作成対象情報取得
|
|
240
|
-
*/
|
|
241
|
-
// function getTargetInfoForCreateFromSetting(
|
|
242
|
-
// settings: factory.schedule.ISchedule4ttts,
|
|
243
|
-
// createDate: Date
|
|
244
|
-
// ): ITargetPerformanceInfo[] {
|
|
245
|
-
// const performanceInfos: ITargetPerformanceInfo[] = [];
|
|
246
|
-
// const { days, duration, noPerformanceTimes, hours, minutes, tours } = settings;
|
|
247
|
-
// // 本日日付+開始日までの日数から作成開始日セット
|
|
248
|
-
// // 作成日数分の作成対象日付作成
|
|
249
|
-
// for (let index = 0; index < days; index = index + 1) {
|
|
250
|
-
// const now = (createDate instanceof Date)
|
|
251
|
-
// ? moment(createDate)
|
|
252
|
-
// .add(index, 'days')
|
|
253
|
-
// : moment()
|
|
254
|
-
// .add(index, 'days');
|
|
255
|
-
// hours.forEach((hourStr) => {
|
|
256
|
-
// // 2桁でない時は'0'詰め
|
|
257
|
-
// // tslint:disable-next-line:no-magic-numbers
|
|
258
|
-
// const hour = `0${hourStr}`.slice(-2);
|
|
259
|
-
// minutes.forEach((minute, minuteIndex) => {
|
|
260
|
-
// // ツアー情報作成
|
|
261
|
-
// const tourNumber = `${hour}${tours[minuteIndex]}`;
|
|
262
|
-
// const startDate = moment(
|
|
263
|
-
// `${now.tz('Asia/Tokyo')
|
|
264
|
-
// .format('YYYYMMDD')} ${hour}:${minute}:00+09:00`,
|
|
265
|
-
// 'YYYYMMDD HH:mm:ssZ'
|
|
266
|
-
// );
|
|
267
|
-
// const endDate = moment(startDate)
|
|
268
|
-
// .add(duration, 'minutes');
|
|
269
|
-
// const day = moment(startDate)
|
|
270
|
-
// .tz('Asia/Tokyo')
|
|
271
|
-
// .format('YYYYMMDD');
|
|
272
|
-
// const startTime = moment(startDate)
|
|
273
|
-
// .tz('Asia/Tokyo')
|
|
274
|
-
// .format('HHmm');
|
|
275
|
-
// const endTime = moment(endDate)
|
|
276
|
-
// .tz('Asia/Tokyo')
|
|
277
|
-
// .format('HHmm');
|
|
278
|
-
// // パフォーマンスを作成しない時刻に指定されていなかったら作成
|
|
279
|
-
// if (noPerformanceTimes.indexOf(`${hour}${minute}`) < 0) {
|
|
280
|
-
// performanceInfos.push({
|
|
281
|
-
// day: day,
|
|
282
|
-
// start_time: startTime,
|
|
283
|
-
// end_time: endTime,
|
|
284
|
-
// door_time: startDate.toDate(),
|
|
285
|
-
// start_date: startDate.toDate(),
|
|
286
|
-
// end_date: endDate.toDate(),
|
|
287
|
-
// tour_number: tourNumber,
|
|
288
|
-
// duration: moment.duration(duration, 'minutes')
|
|
289
|
-
// .toISOString()
|
|
290
|
-
// });
|
|
291
|
-
// }
|
|
292
|
-
// });
|
|
293
|
-
// });
|
|
294
|
-
// }
|
|
295
|
-
// return performanceInfos;
|
|
296
|
-
// }
|
|
297
|
-
function getTargetInfoByEventWithSchedule(settings, createDate) {
|
|
298
|
-
const performanceInfos = [];
|
|
299
|
-
const { eventSchedule } = settings;
|
|
300
|
-
// 作成対象時間: 9,10,11など
|
|
301
|
-
// const hours: string[] = ['9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22'];
|
|
302
|
-
// const minutes = ['00', '15', '30', '45'];
|
|
303
|
-
// const tours = ['1', '2', '3', '4'];
|
|
304
|
-
// 1日分作成する
|
|
305
|
-
const now = (createDate instanceof Date)
|
|
306
|
-
? moment(createDate)
|
|
307
|
-
: moment();
|
|
308
|
-
let startDate = moment.tz(`${now.tz(eventSchedule.scheduleTimezone)
|
|
309
|
-
.format('YYYYMMDD')} ${eventSchedule.startTime}`, 'YYYYMMDD HH:mm:ss', eventSchedule.scheduleTimezone);
|
|
310
|
-
const startDateShouldBeLte = moment.tz(`${now.tz(eventSchedule.scheduleTimezone)
|
|
311
|
-
.format('YYYYMMDD')} ${eventSchedule.endTime}`, 'YYYYMMDD HH:mm:ss', eventSchedule.scheduleTimezone);
|
|
312
|
-
const frequencyInMinutes = moment.duration(eventSchedule.repeatFrequency)
|
|
313
|
-
.asMinutes();
|
|
314
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
315
|
-
const repeatCountInHour = Math.floor(60 / frequencyInMinutes);
|
|
316
|
-
let i = 0;
|
|
317
|
-
while (startDate < startDateShouldBeLte) {
|
|
318
|
-
i += 1;
|
|
319
|
-
if (i > 1) {
|
|
320
|
-
startDate = moment(startDate)
|
|
321
|
-
.add(moment.duration(eventSchedule.repeatFrequency));
|
|
322
|
-
}
|
|
323
|
-
const hour = `0${moment(startDate)
|
|
324
|
-
.format('HH')}`
|
|
325
|
-
// 2桁でない時は'0'詰め
|
|
326
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
327
|
-
.slice(-2);
|
|
328
|
-
let tourIndex = i % repeatCountInHour;
|
|
329
|
-
if (tourIndex === 0) {
|
|
330
|
-
tourIndex = repeatCountInHour;
|
|
331
|
-
}
|
|
332
|
-
const tourNumber = `${hour}${tourIndex}`;
|
|
333
|
-
const endDate = moment(startDate)
|
|
334
|
-
.add(moment.duration(eventSchedule.duration));
|
|
335
|
-
const day = moment(startDate)
|
|
336
|
-
.tz(eventSchedule.scheduleTimezone)
|
|
337
|
-
.format('YYYYMMDD');
|
|
338
|
-
const startTime = moment(startDate)
|
|
339
|
-
.tz(eventSchedule.scheduleTimezone)
|
|
340
|
-
.format('HHmm');
|
|
341
|
-
const endTime = moment(endDate)
|
|
342
|
-
.tz(eventSchedule.scheduleTimezone)
|
|
343
|
-
.format('HHmm');
|
|
344
|
-
performanceInfos.push({
|
|
345
|
-
day: day,
|
|
346
|
-
start_time: startTime,
|
|
347
|
-
end_time: endTime,
|
|
348
|
-
door_time: startDate.toDate(),
|
|
349
|
-
start_date: startDate.toDate(),
|
|
350
|
-
end_date: endDate.toDate(),
|
|
351
|
-
tour_number: tourNumber,
|
|
352
|
-
duration: eventSchedule.duration
|
|
353
|
-
});
|
|
354
|
-
}
|
|
355
|
-
return performanceInfos;
|
|
356
|
-
}
|
|
357
93
|
function createEventBySchedule(params) {
|
|
358
94
|
return (repos
|
|
359
95
|
// settings: Settings
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@aws-sdk/client-cognito-identity-provider": "3.600.0",
|
|
13
13
|
"@aws-sdk/credential-providers": "3.600.0",
|
|
14
|
-
"@chevre/factory": "4.398.0-alpha.
|
|
14
|
+
"@chevre/factory": "4.398.0-alpha.4",
|
|
15
15
|
"@cinerino/sdk": "12.2.0",
|
|
16
16
|
"@motionpicture/coa-service": "9.6.0",
|
|
17
17
|
"@motionpicture/gmo-service": "5.4.0-alpha.1",
|
|
@@ -115,5 +115,5 @@
|
|
|
115
115
|
"postversion": "git push origin --tags",
|
|
116
116
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
117
117
|
},
|
|
118
|
-
"version": "22.13.0-alpha.
|
|
118
|
+
"version": "22.13.0-alpha.7"
|
|
119
119
|
}
|