@chevre/domain 23.1.0 → 23.2.0-alpha.1
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/event/importEventSeriesFromCOAByTitle.ts +83 -0
- package/example/src/chevre/event/importEventsFromCOAByTitle.ts +148 -0
- package/lib/chevre/service/aggregation/event/importFromCOA.js +2 -2
- package/lib/chevre/service/event/factory.d.ts +22 -0
- package/lib/chevre/service/event/factory.js +2 -0
- package/lib/chevre/service/event/processUpdateMovieTheater.d.ts +24 -0
- package/lib/chevre/service/event/processUpdateMovieTheater.js +190 -0
- package/lib/chevre/service/event/saveScreeningEventSeries.d.ts +63 -0
- package/lib/chevre/service/event/saveScreeningEventSeries.js +277 -0
- package/lib/chevre/service/event/saveScreeningEvents.d.ts +46 -0
- package/lib/chevre/service/event/saveScreeningEvents.js +321 -0
- package/lib/chevre/service/event.d.ts +4 -34
- package/lib/chevre/service/event.js +12 -698
- package/lib/chevre/service/eventOld.d.ts +60 -0
- package/lib/chevre/service/eventOld.js +864 -0
- package/lib/chevre/service/task/syncResourcesFromCOA.d.ts +6 -0
- package/lib/chevre/service/task/syncResourcesFromCOA.js +166 -0
- package/lib/chevre/service/taskHandler.js +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../../lib/index';
|
|
5
|
+
|
|
6
|
+
const project = { id: String(process.env.PROJECT_ID) };
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* 指定する施設コード
|
|
10
|
+
*/
|
|
11
|
+
const locationBranchCode = '120';
|
|
12
|
+
/**
|
|
13
|
+
* 指定するタイトルコード
|
|
14
|
+
*/
|
|
15
|
+
const titleCode = '80001';
|
|
16
|
+
/**
|
|
17
|
+
* 指定するタイトル枝番
|
|
18
|
+
*/
|
|
19
|
+
const titleBranchNum = '0';
|
|
20
|
+
|
|
21
|
+
async function main() {
|
|
22
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
23
|
+
|
|
24
|
+
const categoryCodeRepo = await chevre.repository.CategoryCode.createInstance(mongoose.connection);
|
|
25
|
+
const creativeWorkRepo = await chevre.repository.CreativeWork.createInstance(mongoose.connection);
|
|
26
|
+
const eventSeriesRepo = await chevre.repository.EventSeries.createInstance(mongoose.connection);
|
|
27
|
+
const movieTheaterRepo = await chevre.repository.place.MovieTheater.createInstance(mongoose.connection);
|
|
28
|
+
|
|
29
|
+
const coaAuthClient = new (await chevre.loadCOA()).auth.RefreshToken({
|
|
30
|
+
endpoint: String(process.env.COA_ENDPOINT),
|
|
31
|
+
refreshToken: process.env.COA_REFRESH_TOKEN,
|
|
32
|
+
useFetch: true
|
|
33
|
+
});
|
|
34
|
+
const masterService = new (await chevre.loadCOA()).service.Master(
|
|
35
|
+
{
|
|
36
|
+
endpoint: String(process.env.COA_ENDPOINT),
|
|
37
|
+
auth: coaAuthClient
|
|
38
|
+
},
|
|
39
|
+
{ timeout: 20000 }
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
const movieTheater = (await movieTheaterRepo.projectFields(
|
|
43
|
+
{
|
|
44
|
+
limit: 1,
|
|
45
|
+
page: 1,
|
|
46
|
+
project: { id: { $eq: project.id } },
|
|
47
|
+
branchCode: { $eq: locationBranchCode }
|
|
48
|
+
},
|
|
49
|
+
['id', 'typeOf', 'branchCode', 'name', 'kanaName', 'parentOrganization']
|
|
50
|
+
// []
|
|
51
|
+
)).shift();
|
|
52
|
+
if (movieTheater === undefined) {
|
|
53
|
+
throw new Error('movieTheater not found');
|
|
54
|
+
}
|
|
55
|
+
console.log('movieTheater:', movieTheater);
|
|
56
|
+
|
|
57
|
+
const result = await (await chevre.service.event.createService()).saveScreeningEventSeries(
|
|
58
|
+
{
|
|
59
|
+
project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
|
|
60
|
+
seller: { id: movieTheater.parentOrganization.id },
|
|
61
|
+
movieTheater,
|
|
62
|
+
locationBranchCode,
|
|
63
|
+
saveScreeningEventSeries: true,
|
|
64
|
+
saveScreeningEventSeriesPeriodInMonth: 3
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
filterFilmsFromCOA: {
|
|
68
|
+
titleBranchNum,
|
|
69
|
+
titleCode
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
)({
|
|
73
|
+
categoryCode: categoryCodeRepo,
|
|
74
|
+
creativeWork: creativeWorkRepo,
|
|
75
|
+
eventSeries: eventSeriesRepo,
|
|
76
|
+
masterService
|
|
77
|
+
});
|
|
78
|
+
console.log('result:', result.savedEventsCount, result.screeningEventSerieses.length);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
main()
|
|
82
|
+
.then(console.log)
|
|
83
|
+
.catch(console.error);
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as moment from 'moment-timezone';
|
|
3
|
+
import * as mongoose from 'mongoose';
|
|
4
|
+
|
|
5
|
+
import { createScreeningEventSeriesId } from '../../../../lib/chevre/service/event/saveScreeningEventSeries';
|
|
6
|
+
import { chevre } from '../../../../lib/index';
|
|
7
|
+
|
|
8
|
+
const project = { id: String(process.env.PROJECT_ID) };
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 指定する施設コード
|
|
12
|
+
*/
|
|
13
|
+
const locationBranchCode = '120';
|
|
14
|
+
/**
|
|
15
|
+
* 指定するルームコード
|
|
16
|
+
*/
|
|
17
|
+
const roomCode = '30';
|
|
18
|
+
/**
|
|
19
|
+
* 指定するタイトルコード
|
|
20
|
+
*/
|
|
21
|
+
const titleCode = '99100';
|
|
22
|
+
/**
|
|
23
|
+
* 指定するタイトル枝番
|
|
24
|
+
*/
|
|
25
|
+
const titleBranchNum = '0';
|
|
26
|
+
/**
|
|
27
|
+
* 指定するスケジュールの開始日(日本時間)
|
|
28
|
+
*/
|
|
29
|
+
const importDay = new Date();
|
|
30
|
+
|
|
31
|
+
// tslint:disable-next-line:max-func-body-length
|
|
32
|
+
async function main() {
|
|
33
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
34
|
+
|
|
35
|
+
const categoryCodeRepo = await chevre.repository.CategoryCode.createInstance(mongoose.connection);
|
|
36
|
+
const creativeWorkRepo = await chevre.repository.CreativeWork.createInstance(mongoose.connection);
|
|
37
|
+
const eventRepo = await chevre.repository.Event.createInstance(mongoose.connection);
|
|
38
|
+
const eventSeriesRepo = await chevre.repository.EventSeries.createInstance(mongoose.connection);
|
|
39
|
+
const movieTheaterRepo = await chevre.repository.place.MovieTheater.createInstance(mongoose.connection);
|
|
40
|
+
const roomRepo = await chevre.repository.place.ScreeningRoom.createInstance(mongoose.connection);
|
|
41
|
+
|
|
42
|
+
const coaAuthClient = new (await chevre.loadCOA()).auth.RefreshToken({
|
|
43
|
+
endpoint: String(process.env.COA_ENDPOINT),
|
|
44
|
+
refreshToken: process.env.COA_REFRESH_TOKEN,
|
|
45
|
+
useFetch: true
|
|
46
|
+
});
|
|
47
|
+
const masterService = new (await chevre.loadCOA()).service.Master(
|
|
48
|
+
{
|
|
49
|
+
endpoint: String(process.env.COA_ENDPOINT),
|
|
50
|
+
auth: coaAuthClient
|
|
51
|
+
},
|
|
52
|
+
{ timeout: 20000 }
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
const movieTheater = (await movieTheaterRepo.projectFields(
|
|
56
|
+
{
|
|
57
|
+
limit: 1,
|
|
58
|
+
page: 1,
|
|
59
|
+
project: { id: { $eq: project.id } },
|
|
60
|
+
branchCode: { $eq: locationBranchCode }
|
|
61
|
+
},
|
|
62
|
+
['id', 'typeOf', 'branchCode', 'name', 'kanaName', 'parentOrganization']
|
|
63
|
+
// []
|
|
64
|
+
)).shift();
|
|
65
|
+
if (movieTheater === undefined) {
|
|
66
|
+
throw new Error('movieTheater not found');
|
|
67
|
+
}
|
|
68
|
+
console.log('movieTheater:', movieTheater);
|
|
69
|
+
|
|
70
|
+
const screeningRooms = await roomRepo.searchScreeningRooms({
|
|
71
|
+
project: { id: { $eq: project.id } },
|
|
72
|
+
containedInPlace: { branchCode: { $eq: movieTheater.branchCode } },
|
|
73
|
+
branchCode: { $eq: roomCode }
|
|
74
|
+
});
|
|
75
|
+
console.log(screeningRooms);
|
|
76
|
+
|
|
77
|
+
const eventSeriesId = createScreeningEventSeriesId({
|
|
78
|
+
theaterCode: locationBranchCode,
|
|
79
|
+
titleCode,
|
|
80
|
+
titleBranchNum
|
|
81
|
+
});
|
|
82
|
+
const eventSeries = (await eventSeriesRepo.projectEventSeriesFields(
|
|
83
|
+
{
|
|
84
|
+
id: { $eq: eventSeriesId },
|
|
85
|
+
project: { id: { $eq: project.id } }
|
|
86
|
+
},
|
|
87
|
+
[
|
|
88
|
+
'project', 'typeOf', 'eventStatus', 'identifier',
|
|
89
|
+
'name', 'kanaName', 'alternativeHeadline', 'location',
|
|
90
|
+
'organizer', 'videoFormat', 'soundFormat', 'workPerformed',
|
|
91
|
+
'duration', 'endDate', 'startDate', 'coaInfo',
|
|
92
|
+
'offers', 'additionalProperty'
|
|
93
|
+
]
|
|
94
|
+
)).shift();
|
|
95
|
+
if (eventSeries === undefined) {
|
|
96
|
+
throw new Error('eventSeries not found');
|
|
97
|
+
}
|
|
98
|
+
console.log(eventSeries);
|
|
99
|
+
|
|
100
|
+
const targetImportFrom = moment(importDay)
|
|
101
|
+
.tz('Asia/Tokyo')
|
|
102
|
+
.startOf('day');
|
|
103
|
+
const targetImportThrough = moment(importDay)
|
|
104
|
+
.tz('Asia/Tokyo')
|
|
105
|
+
.endOf('day');
|
|
106
|
+
const begin: string = moment(targetImportFrom)
|
|
107
|
+
.add(-1, 'day') // 深夜帯スケジュールが前日検索の結果に含まれるため
|
|
108
|
+
.tz('Asia/Tokyo')
|
|
109
|
+
.format('YYYYMMDD'); // COAは日本時間で判断
|
|
110
|
+
const end: string = moment(targetImportThrough)
|
|
111
|
+
// .add(-1, 'day')
|
|
112
|
+
.tz('Asia/Tokyo')
|
|
113
|
+
.format('YYYYMMDD'); // COAは日本時間で判断
|
|
114
|
+
console.log('importing screening events...', targetImportFrom, targetImportThrough, begin, end);
|
|
115
|
+
|
|
116
|
+
const result = await (await chevre.service.event.createService()).saveScreeningEvents(
|
|
117
|
+
{
|
|
118
|
+
project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
|
|
119
|
+
seller: { id: movieTheater.parentOrganization.id },
|
|
120
|
+
movieTheater,
|
|
121
|
+
screeningRooms,
|
|
122
|
+
screeningEventSerieses: [eventSeries],
|
|
123
|
+
targetImportFrom: targetImportFrom.toDate(),
|
|
124
|
+
targetImportThrough: targetImportThrough.toDate(),
|
|
125
|
+
instrument: {
|
|
126
|
+
theaterCode: locationBranchCode,
|
|
127
|
+
begin, // debug(2024-04-24~)
|
|
128
|
+
end, // debug(2024-04-24~)
|
|
129
|
+
typeOf: 'WebAPI',
|
|
130
|
+
identifier: chevre.factory.service.webAPI.Identifier.COA
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
filterSchedulesFromCOA: { titleBranchNum, titleCode, roomCode }
|
|
135
|
+
}
|
|
136
|
+
)({
|
|
137
|
+
categoryCode: categoryCodeRepo,
|
|
138
|
+
creativeWork: creativeWorkRepo,
|
|
139
|
+
event: eventRepo,
|
|
140
|
+
eventSeries: eventSeriesRepo,
|
|
141
|
+
masterService
|
|
142
|
+
});
|
|
143
|
+
console.log('result:', result.length, 'events');
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
main()
|
|
147
|
+
.then(console.log)
|
|
148
|
+
.catch(console.error);
|
|
@@ -12,7 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.importFromCOA = importFromCOA;
|
|
13
13
|
const createDebug = require("debug");
|
|
14
14
|
const moment = require("moment-timezone");
|
|
15
|
-
const
|
|
15
|
+
const saveScreeningEvents_1 = require("../../event/saveScreeningEvents");
|
|
16
16
|
const debug = createDebug('chevre-domain:service');
|
|
17
17
|
/**
|
|
18
18
|
* イベント席数を更新する
|
|
@@ -37,7 +37,7 @@ function importFromCOA(params) {
|
|
|
37
37
|
if (Array.isArray(countFreeSeatDate.listPerformance)) {
|
|
38
38
|
for (const countFreeSeatPerformance of countFreeSeatDate.listPerformance) {
|
|
39
39
|
try {
|
|
40
|
-
const eventId = (0,
|
|
40
|
+
const eventId = (0, saveScreeningEvents_1.createScreeningEventIdFromCOA)({
|
|
41
41
|
theaterCode: countFreeSeatResult.theaterCode,
|
|
42
42
|
titleCode: countFreeSeatPerformance.titleCode,
|
|
43
43
|
titleBranchNum: countFreeSeatPerformance.titleBranchNum,
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as factory from '../../factory';
|
|
2
|
+
export interface IImportFromCOAParams {
|
|
3
|
+
project: {
|
|
4
|
+
id: string;
|
|
5
|
+
typeOf: factory.organizationType.Project;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* 施設コード
|
|
9
|
+
*/
|
|
10
|
+
locationBranchCode: string;
|
|
11
|
+
importFrom: Date;
|
|
12
|
+
importThrough: Date;
|
|
13
|
+
/**
|
|
14
|
+
* 施設を保管するかどうか
|
|
15
|
+
*/
|
|
16
|
+
saveMovieTheater: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* 施設コンテンツを保管するかどうか
|
|
19
|
+
*/
|
|
20
|
+
saveScreeningEventSeries: boolean;
|
|
21
|
+
saveScreeningEventSeriesPeriodInMonth: number;
|
|
22
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type * as COA from '@motionpicture/coa-service';
|
|
2
|
+
import type { ActionRepo } from '../../repo/action';
|
|
3
|
+
import type { CategoryCodeRepo } from '../../repo/categoryCode';
|
|
4
|
+
import type { MovieTheaterRepo } from '../../repo/place/movieTheater';
|
|
5
|
+
import type { ScreeningRoomRepo } from '../../repo/place/screeningRoom';
|
|
6
|
+
import type { SellerRepo } from '../../repo/seller';
|
|
7
|
+
import * as factory from '../../factory';
|
|
8
|
+
import { IImportFromCOAParams } from './factory';
|
|
9
|
+
type IMovieTheater = Pick<factory.place.movieTheater.IPlace, 'id' | 'typeOf' | 'branchCode' | 'name' | 'kanaName'>;
|
|
10
|
+
declare function processUpdateMovieTheater(params: IImportFromCOAParams): (repos: {
|
|
11
|
+
masterService: COA.service.Master;
|
|
12
|
+
action: ActionRepo;
|
|
13
|
+
categoryCode: CategoryCodeRepo;
|
|
14
|
+
movieTheater: MovieTheaterRepo;
|
|
15
|
+
screeningRoom: ScreeningRoomRepo;
|
|
16
|
+
seller: SellerRepo;
|
|
17
|
+
}) => Promise<{
|
|
18
|
+
seller: {
|
|
19
|
+
id: string;
|
|
20
|
+
};
|
|
21
|
+
movieTheater: IMovieTheater;
|
|
22
|
+
screeningRooms: Omit<factory.place.screeningRoom.IPlace, "containsPlace" | "parentOrganization">[];
|
|
23
|
+
}>;
|
|
24
|
+
export { processUpdateMovieTheater };
|
|
@@ -0,0 +1,190 @@
|
|
|
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.processUpdateMovieTheater = processUpdateMovieTheater;
|
|
13
|
+
const factory = require("../../factory");
|
|
14
|
+
// tslint:disable-next-line:max-func-body-length
|
|
15
|
+
function processUpdateMovieTheater(params) {
|
|
16
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
const actionAttributes = {
|
|
18
|
+
project: { typeOf: factory.organizationType.Project, id: params.project.id },
|
|
19
|
+
typeOf: factory.actionType.ReplaceAction,
|
|
20
|
+
agent: { typeOf: factory.organizationType.Project, id: params.project.id },
|
|
21
|
+
object: Object.assign(Object.assign({}, params), { branchCode: params.locationBranchCode, typeOf: factory.placeType.MovieTheater }),
|
|
22
|
+
instrument: {
|
|
23
|
+
theaterCode: params.locationBranchCode,
|
|
24
|
+
typeOf: 'WebAPI',
|
|
25
|
+
identifier: factory.service.webAPI.Identifier.COA
|
|
26
|
+
},
|
|
27
|
+
targetCollection: { typeOf: factory.placeType.MovieTheater }
|
|
28
|
+
};
|
|
29
|
+
const action = yield repos.action.start(actionAttributes);
|
|
30
|
+
let seller;
|
|
31
|
+
let movieTheater;
|
|
32
|
+
let screeningRooms;
|
|
33
|
+
let processTime;
|
|
34
|
+
try {
|
|
35
|
+
// 同ブランチコードの販売者を検索する
|
|
36
|
+
const sellersWithSameBranchCode = yield repos.seller.projectFields({
|
|
37
|
+
limit: 1,
|
|
38
|
+
page: 1,
|
|
39
|
+
project: { id: { $eq: params.project.id } },
|
|
40
|
+
branchCode: { $eq: params.locationBranchCode }
|
|
41
|
+
}, ['id']);
|
|
42
|
+
const sellerWithSameBranchCode = sellersWithSameBranchCode.shift();
|
|
43
|
+
if (typeof (sellerWithSameBranchCode === null || sellerWithSameBranchCode === void 0 ? void 0 : sellerWithSameBranchCode.id) !== 'string') {
|
|
44
|
+
throw new factory.errors.NotFound('Seller', `Seller with branchCode '${params.locationBranchCode}' not found`);
|
|
45
|
+
}
|
|
46
|
+
seller = { id: sellerWithSameBranchCode.id };
|
|
47
|
+
// saveMovieTheater:trueの場合のみ、施設保管(2022-10-10~)
|
|
48
|
+
if (params.saveMovieTheater === true) {
|
|
49
|
+
const processStart = process.hrtime.bigint();
|
|
50
|
+
const savingMovieTheater = createMovieTheaterFromCOA(params.project, { id: seller.id }, yield repos.masterService.theater({ theaterCode: params.locationBranchCode }), yield repos.masterService.screen({ theaterCode: params.locationBranchCode }));
|
|
51
|
+
yield repos.movieTheater.saveMovieTheaterByBranchCode4coa(savingMovieTheater);
|
|
52
|
+
yield repos.screeningRoom.saveScreeningRooms4coa(savingMovieTheater);
|
|
53
|
+
const processEnd = process.hrtime.bigint();
|
|
54
|
+
processTime = processEnd - processStart;
|
|
55
|
+
}
|
|
56
|
+
const movieTheaters = yield repos.movieTheater.projectFields({
|
|
57
|
+
limit: 1,
|
|
58
|
+
page: 1,
|
|
59
|
+
project: { id: { $eq: params.project.id } },
|
|
60
|
+
branchCode: { $eq: params.locationBranchCode }
|
|
61
|
+
}, ['id', 'typeOf', 'branchCode', 'name', 'kanaName']
|
|
62
|
+
// []
|
|
63
|
+
);
|
|
64
|
+
movieTheater = movieTheaters.shift();
|
|
65
|
+
if (movieTheater === undefined) {
|
|
66
|
+
throw new factory.errors.NotFound(factory.placeType.MovieTheater);
|
|
67
|
+
}
|
|
68
|
+
screeningRooms = yield repos.screeningRoom.searchScreeningRooms({
|
|
69
|
+
project: { id: { $eq: params.project.id } },
|
|
70
|
+
containedInPlace: { branchCode: { $eq: movieTheater.branchCode } }
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
try {
|
|
75
|
+
yield repos.action.giveUp({ typeOf: action.typeOf, id: action.id, error });
|
|
76
|
+
}
|
|
77
|
+
catch (__) {
|
|
78
|
+
// 失敗したら仕方ない
|
|
79
|
+
}
|
|
80
|
+
throw error;
|
|
81
|
+
}
|
|
82
|
+
const actionResult = Object.assign({ screeningRoomsCount: screeningRooms.length }, (processTime !== undefined) ? { processTime } : undefined);
|
|
83
|
+
yield repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: actionResult });
|
|
84
|
+
return { seller, movieTheater, screeningRooms };
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* コアマスター抽出結果から作成する
|
|
89
|
+
*/
|
|
90
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
91
|
+
/* istanbul ignore next */
|
|
92
|
+
function createMovieTheaterFromCOA(project, seller, theaterFromCOA, screensFromCOA) {
|
|
93
|
+
// const id = `MovieTheater-${theaterFromCOA.theaterCode}`;
|
|
94
|
+
return {
|
|
95
|
+
project: { typeOf: project.typeOf, id: project.id },
|
|
96
|
+
// id: id,
|
|
97
|
+
// screenCount: screensFromCOA.length,
|
|
98
|
+
branchCode: theaterFromCOA.theaterCode,
|
|
99
|
+
name: {
|
|
100
|
+
ja: theaterFromCOA.theaterName,
|
|
101
|
+
en: theaterFromCOA.theaterNameEng
|
|
102
|
+
},
|
|
103
|
+
kanaName: theaterFromCOA.theaterNameKana,
|
|
104
|
+
containsPlace: screensFromCOA.map((screenFromCOA) => {
|
|
105
|
+
return createScreeningRoomFromCOA(project, seller, screenFromCOA);
|
|
106
|
+
}),
|
|
107
|
+
typeOf: factory.placeType.MovieTheater,
|
|
108
|
+
telephone: theaterFromCOA.theaterTelNum,
|
|
109
|
+
offers: {
|
|
110
|
+
// project: { typeOf: project.typeOf, id: project.id }, // optimize(2023-11-06~)
|
|
111
|
+
// priceCurrency: factory.priceCurrency.JPY, // optimize(2023-11-06~)
|
|
112
|
+
typeOf: factory.offerType.Offer,
|
|
113
|
+
eligibleQuantity: {
|
|
114
|
+
typeOf: 'QuantitativeValue',
|
|
115
|
+
maxValue: 6,
|
|
116
|
+
unitCode: factory.unitCode.C62
|
|
117
|
+
},
|
|
118
|
+
availabilityStartsGraceTime: {
|
|
119
|
+
typeOf: 'QuantitativeValue',
|
|
120
|
+
value: -2,
|
|
121
|
+
unitCode: factory.unitCode.Day
|
|
122
|
+
},
|
|
123
|
+
availabilityEndsGraceTime: {
|
|
124
|
+
typeOf: 'QuantitativeValue',
|
|
125
|
+
value: 1200,
|
|
126
|
+
unitCode: factory.unitCode.Sec
|
|
127
|
+
},
|
|
128
|
+
availabilityStartsGraceTimeOnPOS: {
|
|
129
|
+
typeOf: 'QuantitativeValue',
|
|
130
|
+
value: -93,
|
|
131
|
+
unitCode: factory.unitCode.Day
|
|
132
|
+
},
|
|
133
|
+
availabilityEndsGraceTimeOnPOS: {
|
|
134
|
+
typeOf: 'QuantitativeValue',
|
|
135
|
+
value: 2678400,
|
|
136
|
+
unitCode: factory.unitCode.Sec
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
parentOrganization: { id: seller.id, typeOf: factory.organizationType.Corporation }
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* コアスクリーン抽出結果からルームを作成する
|
|
144
|
+
*/
|
|
145
|
+
// tslint:disable-next-line:no-single-line-block-comment
|
|
146
|
+
/* istanbul ignore next */
|
|
147
|
+
function createScreeningRoomFromCOA(project, seller, screenFromCOA) {
|
|
148
|
+
const sections = [];
|
|
149
|
+
const sectionCodes = [];
|
|
150
|
+
screenFromCOA.listSeat.forEach((seat) => {
|
|
151
|
+
if (sectionCodes.indexOf(seat.seatSection) < 0) {
|
|
152
|
+
sectionCodes.push(seat.seatSection);
|
|
153
|
+
sections.push({
|
|
154
|
+
project: { typeOf: project.typeOf, id: project.id },
|
|
155
|
+
branchCode: seat.seatSection,
|
|
156
|
+
name: {
|
|
157
|
+
ja: `セクション${seat.seatSection}`,
|
|
158
|
+
en: `section${seat.seatSection}`
|
|
159
|
+
},
|
|
160
|
+
containsPlace: [],
|
|
161
|
+
typeOf: factory.placeType.ScreeningRoomSection
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
sections[sectionCodes.indexOf(seat.seatSection)].containsPlace.push({
|
|
165
|
+
project: { typeOf: project.typeOf, id: project.id },
|
|
166
|
+
branchCode: seat.seatNum,
|
|
167
|
+
typeOf: factory.placeType.Seat,
|
|
168
|
+
additionalProperty: [
|
|
169
|
+
{ name: 'flgFree', value: String(seat.flgFree) },
|
|
170
|
+
{ name: 'flgHc', value: String(seat.flgHc) },
|
|
171
|
+
{ name: 'flgPair', value: String(seat.flgPair) },
|
|
172
|
+
{ name: 'flgSpare', value: String(seat.flgSpare) },
|
|
173
|
+
{ name: 'flgSpecial', value: String(seat.flgSpecial) }
|
|
174
|
+
]
|
|
175
|
+
});
|
|
176
|
+
});
|
|
177
|
+
return {
|
|
178
|
+
project: { typeOf: project.typeOf, id: project.id },
|
|
179
|
+
containsPlace: sections,
|
|
180
|
+
branchCode: screenFromCOA.screenCode,
|
|
181
|
+
name: {
|
|
182
|
+
ja: screenFromCOA.screenName,
|
|
183
|
+
en: screenFromCOA.screenNameEng
|
|
184
|
+
},
|
|
185
|
+
typeOf: factory.placeType.ScreeningRoom,
|
|
186
|
+
maximumAttendeeCapacity: sections[0].containsPlace.length,
|
|
187
|
+
// 必須化(2023-07-14~)
|
|
188
|
+
parentOrganization: { id: seller.id, typeOf: factory.organizationType.Corporation }
|
|
189
|
+
};
|
|
190
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type * as COA from '@motionpicture/coa-service';
|
|
2
|
+
import type { CategoryCodeRepo } from '../../repo/categoryCode';
|
|
3
|
+
import type { CreativeWorkRepo } from '../../repo/creativeWork';
|
|
4
|
+
import type { EventSeriesRepo } from '../../repo/eventSeries';
|
|
5
|
+
import * as factory from '../../factory';
|
|
6
|
+
type IMovieTheater = Pick<factory.place.movieTheater.IPlace, 'id' | 'typeOf' | 'branchCode' | 'name' | 'kanaName'>;
|
|
7
|
+
/**
|
|
8
|
+
* - 施設コード
|
|
9
|
+
* - タイトルコード(optional)
|
|
10
|
+
* - タイトル枝番(optional)
|
|
11
|
+
*
|
|
12
|
+
* 指定で、施設コンテンツをインポートする
|
|
13
|
+
*
|
|
14
|
+
* - 作品マスタ抽出
|
|
15
|
+
* - 区分マスタ抽出
|
|
16
|
+
* を使用して、施設コンテンツを作成する
|
|
17
|
+
*/
|
|
18
|
+
declare function saveScreeningEventSeries(params: {
|
|
19
|
+
/**
|
|
20
|
+
* 施設コード
|
|
21
|
+
*/
|
|
22
|
+
locationBranchCode: string;
|
|
23
|
+
/**
|
|
24
|
+
* 事前に施設から検索すること
|
|
25
|
+
*/
|
|
26
|
+
movieTheater: IMovieTheater;
|
|
27
|
+
project: {
|
|
28
|
+
id: string;
|
|
29
|
+
typeOf: factory.organizationType.Project;
|
|
30
|
+
};
|
|
31
|
+
saveScreeningEventSeries: boolean;
|
|
32
|
+
saveScreeningEventSeriesPeriodInMonth: number;
|
|
33
|
+
seller: {
|
|
34
|
+
id: string;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* 強制的にインポート対象の施設コンテンツIDを指定する
|
|
38
|
+
* 2024-09-09~
|
|
39
|
+
*/
|
|
40
|
+
importingIds?: string[];
|
|
41
|
+
}, options: {
|
|
42
|
+
filterFilmsFromCOA?: {
|
|
43
|
+
titleCode: string;
|
|
44
|
+
titleBranchNum: string;
|
|
45
|
+
};
|
|
46
|
+
}): (repos: {
|
|
47
|
+
categoryCode: CategoryCodeRepo;
|
|
48
|
+
creativeWork: CreativeWorkRepo;
|
|
49
|
+
eventSeries: EventSeriesRepo;
|
|
50
|
+
masterService: COA.service.Master;
|
|
51
|
+
}) => Promise<{
|
|
52
|
+
screeningEventSerieses: factory.eventSeries.IEvent[];
|
|
53
|
+
savedEventsCount: number;
|
|
54
|
+
}>;
|
|
55
|
+
/**
|
|
56
|
+
* COA情報からイベント識別子を作成する
|
|
57
|
+
*/
|
|
58
|
+
declare function createScreeningEventSeriesId(params: {
|
|
59
|
+
theaterCode: string;
|
|
60
|
+
titleCode: string;
|
|
61
|
+
titleBranchNum: string;
|
|
62
|
+
}): string;
|
|
63
|
+
export { createScreeningEventSeriesId, saveScreeningEventSeries };
|