@chevre/domain 22.13.0-alpha.7 → 22.13.0-alpha.8
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 +1 -1
- package/lib/chevre/repo/event.js +13 -7
- package/lib/chevre/service/task/createEvent/createEventBySchedule/factory.d.ts +22 -0
- package/lib/chevre/service/task/createEvent/createEventBySchedule/factory.js +274 -0
- package/lib/chevre/service/task/createEvent/createEventBySchedule/schedule2events.js +20 -290
- package/package.json +1 -1
|
@@ -56,7 +56,7 @@ 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'> & {
|
|
60
60
|
identifier: string;
|
|
61
61
|
};
|
|
62
62
|
/**
|
package/lib/chevre/repo/event.js
CHANGED
|
@@ -667,14 +667,20 @@ class EventRepo {
|
|
|
667
667
|
}
|
|
668
668
|
const uniqid = yield Promise.resolve().then(() => require('uniqid'));
|
|
669
669
|
const id = uniqid();
|
|
670
|
-
const doc = yield this.eventModel.findOneAndUpdate(
|
|
670
|
+
const doc = yield this.eventModel.findOneAndUpdate(
|
|
671
|
+
// 全イベントにidentifierを保証したので、additionalPropertyによるフィルターからidentifierによるフィルターへ変更(2025-09-05~)
|
|
672
|
+
// {
|
|
673
|
+
// 'project.id': { $eq: project.id },
|
|
674
|
+
// typeOf: { $eq: typeOf },
|
|
675
|
+
// // 追加特性をキーに更新
|
|
676
|
+
// additionalProperty: {
|
|
677
|
+
// $exists: true,
|
|
678
|
+
// $all: [{ name: 'oldEventId', value: identifier }]
|
|
679
|
+
// }
|
|
680
|
+
// },
|
|
681
|
+
{
|
|
671
682
|
'project.id': { $eq: project.id },
|
|
672
|
-
|
|
673
|
-
// 追加特性をキーに更新
|
|
674
|
-
additionalProperty: {
|
|
675
|
-
$exists: true,
|
|
676
|
-
$all: [{ name: 'oldEventId', value: identifier }]
|
|
677
|
-
}
|
|
683
|
+
identifier: { $exists: true, $eq: identifier }
|
|
678
684
|
},
|
|
679
685
|
// upsertの場合、createがありうるので属性を除外しない
|
|
680
686
|
{
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ICreatingEvent4ttts } from '../../../../repo/event';
|
|
2
|
+
import type { ICustomerMember } from '../../../../repo/member';
|
|
3
|
+
import * as factory from '../../../../factory';
|
|
4
|
+
declare function tour2creatingEvent(tour: ITourBySchedule, movieTheater: Pick<factory.place.movieTheater.IPlace, 'id' | 'branchCode' | 'parentOrganization'>, screeningRoom: Omit<factory.place.screeningRoom.IPlace, 'containsPlace' | 'parentOrganization'>, existingApplicationMembers: {
|
|
5
|
+
member: ICustomerMember;
|
|
6
|
+
}[], maxValue: number, eventService: Pick<factory.product.IProduct, 'id' | 'name'> & {
|
|
7
|
+
id: string;
|
|
8
|
+
}, screeningEventSeries: Pick<factory.event.screeningEventSeries.IEvent, 'location' | 'additionalProperty' | 'description' | 'endDate' | 'headline' | 'id' | 'kanaName' | 'name' | 'soundFormat' | 'startDate' | 'typeOf' | 'videoFormat' | 'workPerformed'>, project: {
|
|
9
|
+
id: string;
|
|
10
|
+
}): ICreatingEvent4ttts;
|
|
11
|
+
interface ITourBySchedule {
|
|
12
|
+
day: string;
|
|
13
|
+
start_time: string;
|
|
14
|
+
end_time?: never;
|
|
15
|
+
door_time: Date;
|
|
16
|
+
start_date: Date;
|
|
17
|
+
end_date: Date;
|
|
18
|
+
duration?: never;
|
|
19
|
+
tour_number: string;
|
|
20
|
+
}
|
|
21
|
+
declare function schedule2tours(settings: factory.schedule.IEventWithSchedule, createDate: Date): ITourBySchedule[];
|
|
22
|
+
export { tour2creatingEvent, schedule2tours };
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.tour2creatingEvent = tour2creatingEvent;
|
|
4
|
+
exports.schedule2tours = schedule2tours;
|
|
5
|
+
const moment = require("moment-timezone");
|
|
6
|
+
const factory = require("../../../../factory");
|
|
7
|
+
// tslint:disable-next-line:max-func-body-length
|
|
8
|
+
// function schedule2createEventParams(
|
|
9
|
+
// schedule: factory.schedule.IEventWithSchedule,
|
|
10
|
+
// createDate: Date
|
|
11
|
+
// ): factory.event.screeningEvent.ICreateParams[] {
|
|
12
|
+
// const eventServiceId = schedule.offers?.itemOffered?.id;
|
|
13
|
+
// const makesOffer = schedule.offers?.seller?.makesOffer;
|
|
14
|
+
// const applicationIds: string[] = (Array.isArray(makesOffer))
|
|
15
|
+
// ? makesOffer.map(({ availableAtOrFrom }) => availableAtOrFrom.id)
|
|
16
|
+
// : [];
|
|
17
|
+
// const eventSeriesId = schedule.superEvent?.id;
|
|
18
|
+
// if (typeof eventServiceId !== 'string' || eventServiceId === '') {
|
|
19
|
+
// throw new factory.errors.NotFound('schedule.offers.itemOffered.id');
|
|
20
|
+
// }
|
|
21
|
+
// if (typeof eventSeriesId !== 'string' || eventSeriesId === '') {
|
|
22
|
+
// throw new factory.errors.NotFound('schedule.superEvent.id');
|
|
23
|
+
// }
|
|
24
|
+
// // 引数情報取得
|
|
25
|
+
// if (schedule.eventSchedule === undefined) {
|
|
26
|
+
// throw new factory.errors.NotFound('eventSchedule');
|
|
27
|
+
// }
|
|
28
|
+
// const targetInfo = getTargetInfoByEventWithSchedule(schedule, createDate);
|
|
29
|
+
// debug(targetInfo.length, 'targetInfos ->', targetInfo);
|
|
30
|
+
// const createParams: factory.event.screeningEvent.ICreateParams[] = [];
|
|
31
|
+
// for (const performanceInfo of targetInfo) {
|
|
32
|
+
// const oldEventId = [
|
|
33
|
+
// // tslint:disable-next-line:no-magic-numbers
|
|
34
|
+
// performanceInfo.day.slice(-6),
|
|
35
|
+
// workPerformedIdentifier,
|
|
36
|
+
// movieTheater.branchCode,
|
|
37
|
+
// screeningRoom.branchCode,
|
|
38
|
+
// performanceInfo.start_time
|
|
39
|
+
// ].join('');
|
|
40
|
+
// const maxValue = movieTheater.offers?.eligibleQuantity?.maxValue;
|
|
41
|
+
// const availabilityEnds: Date = moment(performanceInfo.end_date)
|
|
42
|
+
// .tz('Asia/Tokyo')
|
|
43
|
+
// .endOf('date')
|
|
44
|
+
// .toDate();
|
|
45
|
+
// const availabilityStarts: Date = moment(performanceInfo.start_date)
|
|
46
|
+
// .tz('Asia/Tokyo')
|
|
47
|
+
// .startOf('date')
|
|
48
|
+
// // tslint:disable-next-line:no-magic-numbers
|
|
49
|
+
// .add(-3, 'months')
|
|
50
|
+
// .toDate();
|
|
51
|
+
// const validThrough: Date = moment(performanceInfo.end_date)
|
|
52
|
+
// .tz('Asia/Tokyo')
|
|
53
|
+
// .endOf('date')
|
|
54
|
+
// .toDate();
|
|
55
|
+
// const validFrom: Date = moment(performanceInfo.start_date)
|
|
56
|
+
// .tz('Asia/Tokyo')
|
|
57
|
+
// .startOf('date')
|
|
58
|
+
// // tslint:disable-next-line:no-magic-numbers
|
|
59
|
+
// .add(-3, 'months')
|
|
60
|
+
// .toDate();
|
|
61
|
+
// // イベント作成
|
|
62
|
+
// createParams.push({
|
|
63
|
+
// eventStatus: factory.eventStatusType.EventScheduled,
|
|
64
|
+
// doorTime: performanceInfo.door_time,
|
|
65
|
+
// startDate: performanceInfo.start_date,
|
|
66
|
+
// endDate: performanceInfo.end_date,
|
|
67
|
+
// offers: {
|
|
68
|
+
// eligibleQuantity: {
|
|
69
|
+
// ...(typeof maxValue === 'number') ? { maxValue } : undefined // ひとまず全座席予約可能なように
|
|
70
|
+
// },
|
|
71
|
+
// itemOffered: {
|
|
72
|
+
// // 興行ID追加(2022-09-01~)
|
|
73
|
+
// id: eventServiceId,
|
|
74
|
+
// serviceOutput: {
|
|
75
|
+
// typeOf: factory.reservationType.EventReservation,
|
|
76
|
+
// reservedTicket: {
|
|
77
|
+
// typeOf: 'Ticket',
|
|
78
|
+
// ticketedSeat: { typeOf: factory.placeType.Seat }
|
|
79
|
+
// }
|
|
80
|
+
// },
|
|
81
|
+
// },
|
|
82
|
+
// seller: {
|
|
83
|
+
// // event.offersにseller.makesOfferを追加(2022-11-18~)
|
|
84
|
+
// makesOffer: applicationIds.map((applicationId) => {
|
|
85
|
+
// return {
|
|
86
|
+
// typeOf: factory.offerType.Offer,
|
|
87
|
+
// availableAtOrFrom: { id: applicationId }, // support no-array(2024-10-13~),
|
|
88
|
+
// availabilityEnds,
|
|
89
|
+
// availabilityStarts,
|
|
90
|
+
// validFrom,
|
|
91
|
+
// validThrough
|
|
92
|
+
// };
|
|
93
|
+
// })
|
|
94
|
+
// }
|
|
95
|
+
// },
|
|
96
|
+
// // 旧フォーマットIDを追加特性に追加(2022-09-08~)
|
|
97
|
+
// additionalProperty: [
|
|
98
|
+
// { name: 'tourNumber', value: String(performanceInfo.tour_number) },
|
|
99
|
+
// { name: 'oldEventId', value: oldEventId }
|
|
100
|
+
// ],
|
|
101
|
+
// identifier: oldEventId
|
|
102
|
+
// });
|
|
103
|
+
// }
|
|
104
|
+
// return createParams;
|
|
105
|
+
// }
|
|
106
|
+
// tslint:disable-next-line:max-func-body-length
|
|
107
|
+
function tour2creatingEvent(tour, movieTheater, screeningRoom, existingApplicationMembers, maxValue, eventService, screeningEventSeries, project) {
|
|
108
|
+
var _a;
|
|
109
|
+
const workPerformedIdentifier = screeningEventSeries.workPerformed.identifier;
|
|
110
|
+
const oldEventId = [
|
|
111
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
112
|
+
tour.day.slice(-6),
|
|
113
|
+
workPerformedIdentifier,
|
|
114
|
+
movieTheater.branchCode,
|
|
115
|
+
screeningRoom.branchCode,
|
|
116
|
+
tour.start_time
|
|
117
|
+
].join('');
|
|
118
|
+
const availabilityEnds = moment(tour.end_date)
|
|
119
|
+
.tz('Asia/Tokyo')
|
|
120
|
+
.endOf('date')
|
|
121
|
+
.toDate();
|
|
122
|
+
const availabilityStarts = moment(tour.start_date)
|
|
123
|
+
.tz('Asia/Tokyo')
|
|
124
|
+
.startOf('date')
|
|
125
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
126
|
+
.add(-3, 'months')
|
|
127
|
+
.toDate();
|
|
128
|
+
const validThrough = moment(tour.end_date)
|
|
129
|
+
.tz('Asia/Tokyo')
|
|
130
|
+
.endOf('date')
|
|
131
|
+
.toDate();
|
|
132
|
+
const validFrom = moment(tour.start_date)
|
|
133
|
+
.tz('Asia/Tokyo')
|
|
134
|
+
.startOf('date')
|
|
135
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
136
|
+
.add(-3, 'months')
|
|
137
|
+
.toDate();
|
|
138
|
+
const seller = movieTheater.parentOrganization;
|
|
139
|
+
const offersSeller = {
|
|
140
|
+
typeOf: factory.organizationType.Corporation,
|
|
141
|
+
id: seller.id,
|
|
142
|
+
// event.offersにseller.makesOfferを追加(2022-11-18~)
|
|
143
|
+
makesOffer: existingApplicationMembers.map((a) => {
|
|
144
|
+
return {
|
|
145
|
+
typeOf: factory.offerType.Offer,
|
|
146
|
+
availableAtOrFrom: { id: a.member.id }, // support no-array(2024-10-13~),
|
|
147
|
+
availabilityEnds,
|
|
148
|
+
availabilityStarts,
|
|
149
|
+
validFrom,
|
|
150
|
+
validThrough
|
|
151
|
+
};
|
|
152
|
+
})
|
|
153
|
+
};
|
|
154
|
+
const offers = {
|
|
155
|
+
typeOf: factory.offerType.Offer,
|
|
156
|
+
eligibleQuantity: {
|
|
157
|
+
typeOf: 'QuantitativeValue',
|
|
158
|
+
unitCode: factory.unitCode.C62,
|
|
159
|
+
maxValue
|
|
160
|
+
},
|
|
161
|
+
itemOffered: Object.assign({
|
|
162
|
+
// 興行ID追加(2022-09-01~)
|
|
163
|
+
id: eventService.id, serviceOutput: {
|
|
164
|
+
typeOf: factory.reservationType.EventReservation,
|
|
165
|
+
reservedTicket: {
|
|
166
|
+
typeOf: 'Ticket',
|
|
167
|
+
ticketedSeat: { typeOf: factory.placeType.Seat }
|
|
168
|
+
}
|
|
169
|
+
}, typeOf: factory.product.ProductType.EventService, availableChannel: {
|
|
170
|
+
typeOf: 'ServiceChannel',
|
|
171
|
+
serviceLocation: {
|
|
172
|
+
typeOf: screeningRoom.typeOf,
|
|
173
|
+
branchCode: screeningRoom.branchCode,
|
|
174
|
+
name: screeningRoom.name,
|
|
175
|
+
containedInPlace: Object.assign({ typeOf: screeningEventSeries.location.typeOf, id: screeningEventSeries.location.id, branchCode: screeningEventSeries.location.branchCode }, (screeningEventSeries.location.name !== undefined)
|
|
176
|
+
? { name: screeningEventSeries.location.name }
|
|
177
|
+
: undefined)
|
|
178
|
+
}
|
|
179
|
+
} }, { name: { ja: (typeof eventService.name === 'string') ? eventService.name : String((_a = eventService.name) === null || _a === void 0 ? void 0 : _a.ja) } }),
|
|
180
|
+
seller: offersSeller
|
|
181
|
+
};
|
|
182
|
+
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))
|
|
183
|
+
? { additionalProperty: screeningEventSeries.additionalProperty }
|
|
184
|
+
: undefined), (screeningEventSeries.startDate !== undefined)
|
|
185
|
+
? { startDate: screeningEventSeries.startDate }
|
|
186
|
+
: undefined), (screeningEventSeries.endDate !== undefined)
|
|
187
|
+
? { endDate: screeningEventSeries.endDate }
|
|
188
|
+
: undefined), (screeningEventSeries.description !== undefined)
|
|
189
|
+
? { description: screeningEventSeries.description }
|
|
190
|
+
: undefined), (screeningEventSeries.headline !== undefined)
|
|
191
|
+
? { headline: screeningEventSeries.headline }
|
|
192
|
+
: undefined);
|
|
193
|
+
const location = Object.assign({ typeOf: screeningRoom.typeOf, branchCode: screeningRoom.branchCode, name: screeningRoom.name }, (screeningRoom.address !== undefined) ? { address: screeningRoom.address } : undefined);
|
|
194
|
+
return {
|
|
195
|
+
project: { id: project.id, typeOf: factory.organizationType.Project },
|
|
196
|
+
typeOf: factory.eventType.ScreeningEvent,
|
|
197
|
+
eventStatus: factory.eventStatusType.EventScheduled,
|
|
198
|
+
name: screeningEventSeries.name,
|
|
199
|
+
doorTime: tour.door_time,
|
|
200
|
+
startDate: tour.start_date,
|
|
201
|
+
endDate: tour.end_date,
|
|
202
|
+
superEvent: screeningEventSuperEvent,
|
|
203
|
+
location,
|
|
204
|
+
offers,
|
|
205
|
+
// 旧フォーマットIDを追加特性に追加(2022-09-08~)
|
|
206
|
+
additionalProperty: [
|
|
207
|
+
{ name: 'tourNumber', value: String(tour.tour_number) },
|
|
208
|
+
{ name: 'oldEventId', value: oldEventId }
|
|
209
|
+
],
|
|
210
|
+
// organizer追加(2023-07-12~)
|
|
211
|
+
organizer: { id: seller.id },
|
|
212
|
+
identifier: oldEventId
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
function schedule2tours(settings, createDate) {
|
|
216
|
+
const tours = [];
|
|
217
|
+
const { eventSchedule } = settings;
|
|
218
|
+
// 作成対象時間: 9,10,11など
|
|
219
|
+
// const hours: string[] = ['9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22'];
|
|
220
|
+
// const minutes = ['00', '15', '30', '45'];
|
|
221
|
+
// const tours = ['1', '2', '3', '4'];
|
|
222
|
+
// 1日分作成する
|
|
223
|
+
const now = (createDate instanceof Date)
|
|
224
|
+
? moment(createDate)
|
|
225
|
+
: moment();
|
|
226
|
+
let startDate = moment.tz(`${now.tz(eventSchedule.scheduleTimezone)
|
|
227
|
+
.format('YYYYMMDD')} ${eventSchedule.startTime}`, 'YYYYMMDD HH:mm:ss', eventSchedule.scheduleTimezone);
|
|
228
|
+
const startDateShouldBeLte = moment.tz(`${now.tz(eventSchedule.scheduleTimezone)
|
|
229
|
+
.format('YYYYMMDD')} ${eventSchedule.endTime}`, 'YYYYMMDD HH:mm:ss', eventSchedule.scheduleTimezone);
|
|
230
|
+
const frequencyInMinutes = moment.duration(eventSchedule.repeatFrequency)
|
|
231
|
+
.asMinutes();
|
|
232
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
233
|
+
const repeatCountInHour = Math.floor(60 / frequencyInMinutes);
|
|
234
|
+
let i = 0;
|
|
235
|
+
while (startDate < startDateShouldBeLte) {
|
|
236
|
+
i += 1;
|
|
237
|
+
if (i > 1) {
|
|
238
|
+
startDate = moment(startDate)
|
|
239
|
+
.add(moment.duration(eventSchedule.repeatFrequency));
|
|
240
|
+
}
|
|
241
|
+
const hour = `0${moment(startDate)
|
|
242
|
+
.format('HH')}`
|
|
243
|
+
// 2桁でない時は'0'詰め
|
|
244
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
245
|
+
.slice(-2);
|
|
246
|
+
let tourIndex = i % repeatCountInHour;
|
|
247
|
+
if (tourIndex === 0) {
|
|
248
|
+
tourIndex = repeatCountInHour;
|
|
249
|
+
}
|
|
250
|
+
const tourNumber = `${hour}${tourIndex}`;
|
|
251
|
+
const endDate = moment(startDate)
|
|
252
|
+
.add(moment.duration(eventSchedule.duration));
|
|
253
|
+
const day = moment(startDate)
|
|
254
|
+
.tz(eventSchedule.scheduleTimezone)
|
|
255
|
+
.format('YYYYMMDD');
|
|
256
|
+
const startTime = moment(startDate)
|
|
257
|
+
.tz(eventSchedule.scheduleTimezone)
|
|
258
|
+
.format('HHmm');
|
|
259
|
+
// const endTime = moment(endDate)
|
|
260
|
+
// .tz(eventSchedule.scheduleTimezone)
|
|
261
|
+
// .format('HHmm');
|
|
262
|
+
tours.push({
|
|
263
|
+
day: day,
|
|
264
|
+
start_time: startTime,
|
|
265
|
+
// end_time: endTime,
|
|
266
|
+
door_time: startDate.toDate(),
|
|
267
|
+
start_date: startDate.toDate(),
|
|
268
|
+
end_date: endDate.toDate(),
|
|
269
|
+
tour_number: tourNumber
|
|
270
|
+
// duration: eventSchedule.duration
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
return tours;
|
|
274
|
+
}
|
|
@@ -11,114 +11,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.schedule2events = schedule2events;
|
|
13
13
|
const createDebug = require("debug");
|
|
14
|
-
const moment = require("moment-timezone");
|
|
15
14
|
const factory = require("../../../../factory");
|
|
16
|
-
|
|
17
|
-
const debug = createDebug('chevre-domain:service:task');
|
|
18
|
-
|
|
19
|
-
//
|
|
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
|
|
15
|
+
const factory_1 = require("./factory");
|
|
16
|
+
const debug = createDebug('chevre-domain:service:task:createEvent');
|
|
17
|
+
function schedule2relatedResources(schedule) {
|
|
18
|
+
// tslint:disable-next-line:max-func-body-length
|
|
119
19
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
120
|
-
var _a, _b, _c, _d, _e, _f, _g, _h
|
|
121
|
-
debug('
|
|
20
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
21
|
+
debug('schedule2relatedResources processing...', JSON.stringify(schedule));
|
|
122
22
|
const eventServiceId = (_b = (_a = schedule.offers) === null || _a === void 0 ? void 0 : _a.itemOffered) === null || _b === void 0 ? void 0 : _b.id;
|
|
123
23
|
const makesOffer = (_d = (_c = schedule.offers) === null || _c === void 0 ? void 0 : _c.seller) === null || _d === void 0 ? void 0 : _d.makesOffer;
|
|
124
24
|
const applicationIds = (Array.isArray(makesOffer))
|
|
@@ -140,17 +40,6 @@ function schedule2events(schedule, createDate) {
|
|
|
140
40
|
throw new factory.errors.NotFound('location.branchCode required');
|
|
141
41
|
}
|
|
142
42
|
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
43
|
// 施設コンテンツ検索
|
|
155
44
|
const screeningEventSeries = (yield repos.eventSeries.projectEventSeriesFields({
|
|
156
45
|
project: { id: { $eq: project.id } },
|
|
@@ -162,7 +51,6 @@ function schedule2events(schedule, createDate) {
|
|
|
162
51
|
if (screeningEventSeries === undefined) {
|
|
163
52
|
throw new factory.errors.NotFound(factory.eventType.ScreeningEventSeries);
|
|
164
53
|
}
|
|
165
|
-
const workPerformedIdentifier = screeningEventSeries.workPerformed.identifier;
|
|
166
54
|
// 劇場検索
|
|
167
55
|
const movieTheater = (yield repos.movieTheater.projectFields({
|
|
168
56
|
limit: 1,
|
|
@@ -173,7 +61,6 @@ function schedule2events(schedule, createDate) {
|
|
|
173
61
|
if (movieTheater === undefined) {
|
|
174
62
|
throw new factory.errors.NotFound(factory.placeType.MovieTheater);
|
|
175
63
|
}
|
|
176
|
-
const seller = movieTheater.parentOrganization;
|
|
177
64
|
const screeningRoom = (yield repos.screeningRoom.searchScreeningRooms({
|
|
178
65
|
limit: 1,
|
|
179
66
|
page: 1,
|
|
@@ -209,178 +96,21 @@ function schedule2events(schedule, createDate) {
|
|
|
209
96
|
}
|
|
210
97
|
});
|
|
211
98
|
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
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;
|
|
99
|
+
return {
|
|
100
|
+
movieTheater, screeningRoom,
|
|
101
|
+
existingApplicationMembers, maxValue, eventService, screeningEventSeries
|
|
102
|
+
};
|
|
325
103
|
});
|
|
326
104
|
}
|
|
327
|
-
function
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
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;
|
|
105
|
+
function schedule2events(schedule, createDate) {
|
|
106
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
107
|
+
if (schedule.eventSchedule === undefined) {
|
|
108
|
+
throw new factory.errors.NotFound('schedule.eventSchedule required');
|
|
361
109
|
}
|
|
362
|
-
const
|
|
363
|
-
const
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
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;
|
|
110
|
+
const { movieTheater, screeningRoom, existingApplicationMembers, maxValue, eventService, screeningEventSeries } = yield schedule2relatedResources(schedule)(repos);
|
|
111
|
+
const project = schedule.project;
|
|
112
|
+
const tours = (0, factory_1.schedule2tours)(schedule, createDate);
|
|
113
|
+
debug(tours.length, 'tours ->', JSON.stringify(tours));
|
|
114
|
+
return tours.map((tour) => (0, factory_1.tour2creatingEvent)(tour, movieTheater, screeningRoom, existingApplicationMembers, maxValue, eventService, screeningEventSeries, project));
|
|
115
|
+
});
|
|
386
116
|
}
|
package/package.json
CHANGED