@chevre/domain 21.27.0-alpha.10 → 21.27.0-alpha.12

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.
@@ -50,7 +50,6 @@ async function main() {
50
50
  project: { id: project.id },
51
51
  agent: { id: CLIENT_ID },
52
52
  object: {
53
- typeOf: chevre.factory.action.authorize.paymentMethod.any.ResultType.Payment,
54
53
  amount: AMOUNT,
55
54
  paymentMethod: paymentMethodType,
56
55
  issuedThrough: { id: paymentServiceId },
@@ -99,7 +98,6 @@ async function main() {
99
98
  project: { id: project.id },
100
99
  agent: { id: CLIENT_ID },
101
100
  object: {
102
- typeOf: chevre.factory.action.authorize.paymentMethod.any.ResultType.Payment,
103
101
  amount: AMOUNT,
104
102
  paymentMethodId: publishPaymentUrlResult.paymentMethodId,
105
103
  paymentMethod: paymentMethodType,
@@ -17,6 +17,7 @@ const moment = require("moment");
17
17
  const pecorinoapi = require("../../pecorinoapi");
18
18
  const factory = require("../../factory");
19
19
  const OfferService = require("../offer");
20
+ const onEventChanged_1 = require("../offer/onEventChanged");
20
21
  const cancelReservation_1 = require("../reserve/cancelReservation");
21
22
  const confirmReservation_1 = require("../reserve/confirmReservation");
22
23
  const settings_1 = require("../../settings");
@@ -838,7 +839,7 @@ function processLockSeats(params) {
838
839
  function onReservationsCreated(params) {
839
840
  return (repos) => __awaiter(this, void 0, void 0, function* () {
840
841
  // 集計タスク
841
- yield OfferService.createAggregateScreeningEventIfNotExist({
842
+ yield (0, onEventChanged_1.createAggregateScreeningEventIfNotExist)({
842
843
  project: params.event.project,
843
844
  reservationFor: [{ id: params.event.id }],
844
845
  force: false,
@@ -23,7 +23,7 @@ const credentials_1 = require("../credentials");
23
23
  const factory = require("../factory");
24
24
  const createEvent_1 = require("./event/createEvent");
25
25
  Object.defineProperty(exports, "createEvent", { enumerable: true, get: function () { return createEvent_1.createEvent; } });
26
- const offer_1 = require("./offer");
26
+ const onEventChanged_1 = require("./offer/onEventChanged");
27
27
  const debug = createDebug('chevre-domain:service:event');
28
28
  const coaAuthClient = new COA.auth.RefreshToken({
29
29
  endpoint: credentials_1.credentials.coa.endpoint,
@@ -793,7 +793,7 @@ function updateEvent4ttts(params) {
793
793
  }
794
794
  // アクション完了
795
795
  yield repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: { id: event.id } });
796
- yield (0, offer_1.onEventChanged)({
796
+ yield (0, onEventChanged_1.onEventChanged)({
797
797
  id: [event.id],
798
798
  project: { id: event.project.id },
799
799
  typeOf: event.typeOf,
@@ -0,0 +1,25 @@
1
+ import type { MongoRepository as EventRepo } from '../../repo/event';
2
+ import type { MongoRepository as ProjectRepo } from '../../repo/project';
3
+ import type { MongoRepository as TaskRepo } from '../../repo/task';
4
+ import * as factory from '../../factory';
5
+ /**
6
+ * イベント変更時処理
7
+ */
8
+ declare function onEventChanged(params: factory.task.onEventChanged.IData): (repos: {
9
+ event: EventRepo;
10
+ project: ProjectRepo;
11
+ task: TaskRepo;
12
+ }) => Promise<void>;
13
+ declare function createAggregateScreeningEventIfNotExist(params: {
14
+ project: {
15
+ id: string;
16
+ };
17
+ reservationFor: {
18
+ id: string;
19
+ }[];
20
+ force: boolean;
21
+ identifier: string;
22
+ }): (repos: {
23
+ task: TaskRepo;
24
+ }) => Promise<void>;
25
+ export { createAggregateScreeningEventIfNotExist, onEventChanged };
@@ -0,0 +1,217 @@
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.onEventChanged = exports.createAggregateScreeningEventIfNotExist = void 0;
13
+ const factory = require("../../factory");
14
+ const settings_1 = require("../../settings");
15
+ const informEvents = settings_1.settings.onEventChanged.informEvent;
16
+ /**
17
+ * イベント変更時処理
18
+ */
19
+ function onEventChanged(params) {
20
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
21
+ if (params.id.length > 0) {
22
+ // ScreeningEventであれば集計タスク
23
+ if (params.typeOf === factory.eventType.ScreeningEvent) {
24
+ yield createAggregateScreeningEventIfNotExist({
25
+ project: { id: params.project.id },
26
+ reservationFor: params.id.map((id) => {
27
+ return { id };
28
+ }),
29
+ // 新規作成の場合は強制的に集計
30
+ force: params.isNew,
31
+ identifier: `onEventChanged`
32
+ })(repos);
33
+ }
34
+ // 通知タスク作成(2023-06-08~)
35
+ if (params.useInform === true) {
36
+ yield createInformTasks({
37
+ project: { id: params.project.id },
38
+ ids: params.id,
39
+ typeOf: params.typeOf
40
+ })(repos);
41
+ }
42
+ if (params.useSync === true) {
43
+ switch (params.typeOf) {
44
+ case factory.eventType.ScreeningEventSeries:
45
+ // 施設コンテンツを興行イベントへ同期(2023-07-28~)
46
+ yield syncEventSeries2screeningEvents({
47
+ project: { id: params.project.id },
48
+ ids: params.id
49
+ })(repos);
50
+ break;
51
+ default:
52
+ // no op
53
+ }
54
+ }
55
+ }
56
+ });
57
+ }
58
+ exports.onEventChanged = onEventChanged;
59
+ function syncEventSeries2screeningEvents(params) {
60
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
61
+ const now = new Date();
62
+ for (const eventSeriesId of params.ids) {
63
+ yield repos.event.syncScreeningEventSeries2screeningEvents({
64
+ project: { id: params.project.id },
65
+ superEvent: { id: eventSeriesId },
66
+ startDate: { $gte: now }
67
+ });
68
+ }
69
+ });
70
+ }
71
+ function createAggregateScreeningEventIfNotExist(params) {
72
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
73
+ let aggregateTasks = [];
74
+ const runsAt = new Date();
75
+ const remainingNumberOfTries = 2;
76
+ const project = {
77
+ id: params.project.id, typeOf: factory.organizationType.Project
78
+ };
79
+ const nowInMilliseconds = Date.now();
80
+ if (params.force) {
81
+ aggregateTasks = params.reservationFor.map((reservationFor) => {
82
+ const taskIdentifier = `${params.project.id}:${factory.taskName.AggregateScreeningEvent}:${reservationFor.id}:${params.identifier}:${nowInMilliseconds}`;
83
+ return {
84
+ identifier: taskIdentifier,
85
+ project,
86
+ name: factory.taskName.AggregateScreeningEvent,
87
+ status: factory.taskStatus.Ready,
88
+ runsAt,
89
+ remainingNumberOfTries,
90
+ numberOfTried: 0,
91
+ executionResults: [],
92
+ data: { typeOf: factory.eventType.ScreeningEvent, id: reservationFor.id }
93
+ };
94
+ });
95
+ }
96
+ else {
97
+ for (const reservationFor of params.reservationFor) {
98
+ // 冗長な作成を避ける
99
+ const readyAggregateScreeningEventTaskDoc = yield repos.task.taskModel.findOne({
100
+ 'project.id': { $eq: project.id },
101
+ name: { $eq: factory.taskName.AggregateScreeningEvent },
102
+ status: { $eq: factory.taskStatus.Ready },
103
+ 'data.id': { $exists: true, $eq: reservationFor.id }
104
+ }, { _id: 1 })
105
+ .exec();
106
+ if (readyAggregateScreeningEventTaskDoc === null) {
107
+ const taskIdentifier = `${params.project.id}:${factory.taskName.AggregateScreeningEvent}:${reservationFor.id}:${params.identifier}:${nowInMilliseconds}`;
108
+ aggregateTasks.push({
109
+ identifier: taskIdentifier,
110
+ project,
111
+ name: factory.taskName.AggregateScreeningEvent,
112
+ status: factory.taskStatus.Ready,
113
+ runsAt,
114
+ remainingNumberOfTries,
115
+ numberOfTried: 0,
116
+ executionResults: [],
117
+ data: { typeOf: factory.eventType.ScreeningEvent, id: reservationFor.id }
118
+ });
119
+ }
120
+ }
121
+ }
122
+ if (aggregateTasks.length > 0) {
123
+ yield repos.task.saveMany(aggregateTasks, { emitImmediately: true });
124
+ }
125
+ });
126
+ }
127
+ exports.createAggregateScreeningEventIfNotExist = createAggregateScreeningEventIfNotExist;
128
+ function createInformTasks(params) {
129
+ // tslint:disable-next-line:max-func-body-length
130
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
131
+ let events4inform;
132
+ if (params.typeOf === factory.eventType.Event) {
133
+ events4inform = yield repos.event.search({
134
+ id: { $in: params.ids },
135
+ typeOf: params.typeOf
136
+ }, [], [
137
+ 'aggregateEntranceGate', 'aggregateOffer', 'aggregateReservation',
138
+ 'remainingAttendeeCapacity', 'checkInCount', 'attendeeCount'
139
+ ]);
140
+ }
141
+ else if (params.typeOf === factory.eventType.ScreeningEvent) {
142
+ const screeningEvents4inform = yield repos.event.search({
143
+ id: { $in: params.ids },
144
+ typeOf: params.typeOf
145
+ }, [], [
146
+ 'aggregateEntranceGate', 'aggregateOffer', 'aggregateReservation',
147
+ 'remainingAttendeeCapacity', 'checkInCount', 'attendeeCount'
148
+ ]);
149
+ // 最適化(2024-03-22~)
150
+ events4inform = screeningEvents4inform.map(({ project, organizer, typeOf, name, doorTime, endDate, eventStatus, location, startDate, superEvent, offers, id, additionalProperty }) => {
151
+ var _a;
152
+ return Object.assign({ project, organizer, typeOf, name, doorTime, endDate,
153
+ eventStatus, location, startDate, superEvent, id, additionalProperty }, (settings_1.USE_OPTIMIZE_INFORM_EVENT)
154
+ ? {
155
+ offers: (((_a = offers.offeredThrough) === null || _a === void 0 ? void 0 : _a.identifier) === factory.service.webAPI.Identifier.COA)
156
+ ? {
157
+ typeOf: offers.typeOf,
158
+ itemOffered: offers.itemOffered
159
+ }
160
+ : {
161
+ typeOf: offers.typeOf,
162
+ itemOffered: offers.itemOffered,
163
+ seller: {
164
+ id: offers.seller.id,
165
+ typeOf: offers.seller.typeOf
166
+ }
167
+ }
168
+ }
169
+ : { offers });
170
+ });
171
+ }
172
+ else {
173
+ events4inform = yield repos.event.search({
174
+ id: { $in: params.ids },
175
+ typeOf: params.typeOf
176
+ }, [], []);
177
+ }
178
+ if (events4inform.length > 0) {
179
+ const taskRunsAt = new Date();
180
+ const informTasks = [];
181
+ informEvents === null || informEvents === void 0 ? void 0 : informEvents.forEach((informEvent) => {
182
+ var _a;
183
+ const informUrl = String((_a = informEvent.recipient) === null || _a === void 0 ? void 0 : _a.url);
184
+ events4inform.forEach((event4inform) => {
185
+ var _a;
186
+ // _idは不要であり、存在すると予期せぬ影響を及ぼす可能性がある
187
+ delete event4inform._id;
188
+ const informActionAttributes = {
189
+ agent: event4inform.project,
190
+ object: event4inform,
191
+ project: event4inform.project,
192
+ recipient: {
193
+ id: '',
194
+ name: String((_a = informEvent.recipient) === null || _a === void 0 ? void 0 : _a.name),
195
+ typeOf: factory.creativeWorkType.WebApplication,
196
+ url: informUrl
197
+ },
198
+ typeOf: factory.actionType.InformAction
199
+ };
200
+ informTasks.push({
201
+ project: event4inform.project,
202
+ name: factory.taskName.TriggerWebhook,
203
+ status: factory.taskStatus.Ready,
204
+ runsAt: taskRunsAt,
205
+ remainingNumberOfTries: 10,
206
+ numberOfTried: 0,
207
+ executionResults: [],
208
+ data: informActionAttributes
209
+ });
210
+ });
211
+ });
212
+ if (informTasks.length > 0) {
213
+ yield repos.task.saveMany(informTasks, { emitImmediately: true });
214
+ }
215
+ }
216
+ });
217
+ }
@@ -1,9 +1,7 @@
1
1
  import type { MongoRepository as EventRepo } from '../repo/event';
2
2
  import type { MongoRepository as PlaceRepo } from '../repo/place';
3
3
  import type { MongoRepository as PriceSpecificationRepo } from '../repo/priceSpecification';
4
- import type { MongoRepository as ProjectRepo } from '../repo/project';
5
4
  import type { StockHolderRepository as StockHolderRepo } from '../repo/stockHolder';
6
- import type { MongoRepository as TaskRepo } from '../repo/task';
7
5
  import * as factory from '../factory';
8
6
  import * as EventOfferService from './offer/event';
9
7
  import * as EventServiceByCOAOfferService from './offer/eventServiceByCOA';
@@ -46,41 +44,3 @@ export declare function searchEventSeatOffersWithPaging(params: {
46
44
  stockHolder: StockHolderRepo;
47
45
  place: PlaceRepo;
48
46
  }) => Promise<Pick<factory.place.seat.IPlaceWithOffer, 'branchCode' | 'containedInPlace' | 'offers' | 'seatingType' | 'typeOf'>[]>;
49
- /**
50
- * イベント変更時処理
51
- */
52
- export declare function onEventChanged(params: factory.task.onEventChanged.IData): (repos: {
53
- event: EventRepo;
54
- project: ProjectRepo;
55
- task: TaskRepo;
56
- }) => Promise<void>;
57
- export declare function syncEventSeries2screeningEvents(params: {
58
- project: {
59
- id: string;
60
- };
61
- ids: string[];
62
- }): (repos: {
63
- event: EventRepo;
64
- }) => Promise<void>;
65
- export declare function createAggregateScreeningEventIfNotExist(params: {
66
- project: {
67
- id: string;
68
- };
69
- reservationFor: {
70
- id: string;
71
- }[];
72
- force: boolean;
73
- identifier: string;
74
- }): (repos: {
75
- task: TaskRepo;
76
- }) => Promise<void>;
77
- export declare function createInformTasks(params: {
78
- project: {
79
- id: string;
80
- };
81
- ids: string[];
82
- typeOf: factory.eventType;
83
- }): (repos: {
84
- event: EventRepo;
85
- task: TaskRepo;
86
- }) => Promise<void>;
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.createInformTasks = exports.createAggregateScreeningEventIfNotExist = exports.syncEventSeries2screeningEvents = exports.onEventChanged = exports.searchEventSeatOffersWithPaging = exports.addOffers2Seat = exports.product = exports.moneyTransfer = exports.eventServiceByCOA = exports.event = void 0;
12
+ exports.searchEventSeatOffersWithPaging = exports.addOffers2Seat = exports.product = exports.moneyTransfer = exports.eventServiceByCOA = exports.event = void 0;
13
13
  const moment = require("moment");
14
14
  const factory = require("../factory");
15
15
  const EventOfferService = require("./offer/event");
@@ -20,8 +20,6 @@ const MoneyTransferOfferService = require("./offer/moneyTransfer");
20
20
  exports.moneyTransfer = MoneyTransferOfferService;
21
21
  const ProductOfferService = require("./offer/product");
22
22
  exports.product = ProductOfferService;
23
- const settings_1 = require("../settings");
24
- const informEvents = settings_1.settings.onEventChanged.informEvent;
25
23
  /**
26
24
  * 座席にオファー情報を付加する
27
25
  */
@@ -127,184 +125,3 @@ function searchEventSeatOffersWithPaging(params) {
127
125
  });
128
126
  }
129
127
  exports.searchEventSeatOffersWithPaging = searchEventSeatOffersWithPaging;
130
- /**
131
- * イベント変更時処理
132
- */
133
- function onEventChanged(params) {
134
- return (repos) => __awaiter(this, void 0, void 0, function* () {
135
- if (params.id.length > 0) {
136
- // ScreeningEventであれば集計タスク
137
- if (params.typeOf === factory.eventType.ScreeningEvent) {
138
- yield createAggregateScreeningEventIfNotExist({
139
- project: { id: params.project.id },
140
- reservationFor: params.id.map((id) => {
141
- return { id };
142
- }),
143
- // 新規作成の場合は強制的に集計
144
- force: params.isNew,
145
- identifier: `onEventChanged`
146
- })(repos);
147
- }
148
- // 通知タスク作成(2023-06-08~)
149
- if (params.useInform === true) {
150
- yield createInformTasks({
151
- project: { id: params.project.id },
152
- ids: params.id,
153
- typeOf: params.typeOf
154
- })(repos);
155
- }
156
- if (params.useSync === true) {
157
- switch (params.typeOf) {
158
- case factory.eventType.ScreeningEventSeries:
159
- // 施設コンテンツを興行イベントへ同期(2023-07-28~)
160
- yield syncEventSeries2screeningEvents({
161
- project: { id: params.project.id },
162
- ids: params.id
163
- })(repos);
164
- break;
165
- default:
166
- // no op
167
- }
168
- }
169
- }
170
- });
171
- }
172
- exports.onEventChanged = onEventChanged;
173
- function syncEventSeries2screeningEvents(params) {
174
- return (repos) => __awaiter(this, void 0, void 0, function* () {
175
- const now = new Date();
176
- for (const eventSeriesId of params.ids) {
177
- yield repos.event.syncScreeningEventSeries2screeningEvents({
178
- project: { id: params.project.id },
179
- superEvent: { id: eventSeriesId },
180
- startDate: { $gte: now }
181
- });
182
- }
183
- });
184
- }
185
- exports.syncEventSeries2screeningEvents = syncEventSeries2screeningEvents;
186
- function createAggregateScreeningEventIfNotExist(params) {
187
- return (repos) => __awaiter(this, void 0, void 0, function* () {
188
- let aggregateTasks = [];
189
- const runsAt = new Date();
190
- const remainingNumberOfTries = 2;
191
- const project = {
192
- id: params.project.id, typeOf: factory.organizationType.Project
193
- };
194
- const nowInMilliseconds = Date.now();
195
- if (params.force) {
196
- aggregateTasks = params.reservationFor.map((reservationFor) => {
197
- const taskIdentifier = `${params.project.id}:${factory.taskName.AggregateScreeningEvent}:${reservationFor.id}:${params.identifier}:${nowInMilliseconds}`;
198
- return {
199
- identifier: taskIdentifier,
200
- project,
201
- name: factory.taskName.AggregateScreeningEvent,
202
- status: factory.taskStatus.Ready,
203
- runsAt,
204
- remainingNumberOfTries,
205
- numberOfTried: 0,
206
- executionResults: [],
207
- data: { typeOf: factory.eventType.ScreeningEvent, id: reservationFor.id }
208
- };
209
- });
210
- }
211
- else {
212
- for (const reservationFor of params.reservationFor) {
213
- // 冗長な作成を避ける
214
- const readyAggregateScreeningEventTaskDoc = yield repos.task.taskModel.findOne({
215
- 'project.id': { $eq: project.id },
216
- name: { $eq: factory.taskName.AggregateScreeningEvent },
217
- status: { $eq: factory.taskStatus.Ready },
218
- 'data.id': { $exists: true, $eq: reservationFor.id }
219
- }, { _id: 1 })
220
- .exec();
221
- if (readyAggregateScreeningEventTaskDoc === null) {
222
- const taskIdentifier = `${params.project.id}:${factory.taskName.AggregateScreeningEvent}:${reservationFor.id}:${params.identifier}:${nowInMilliseconds}`;
223
- aggregateTasks.push({
224
- identifier: taskIdentifier,
225
- project,
226
- name: factory.taskName.AggregateScreeningEvent,
227
- status: factory.taskStatus.Ready,
228
- runsAt,
229
- remainingNumberOfTries,
230
- numberOfTried: 0,
231
- executionResults: [],
232
- data: { typeOf: factory.eventType.ScreeningEvent, id: reservationFor.id }
233
- });
234
- }
235
- }
236
- }
237
- if (aggregateTasks.length > 0) {
238
- yield repos.task.saveMany(aggregateTasks, { emitImmediately: true });
239
- }
240
- });
241
- }
242
- exports.createAggregateScreeningEventIfNotExist = createAggregateScreeningEventIfNotExist;
243
- function createInformTasks(params) {
244
- return (repos) => __awaiter(this, void 0, void 0, function* () {
245
- let events4inform;
246
- if (params.typeOf === factory.eventType.Event) {
247
- events4inform = yield repos.event.search({
248
- id: { $in: params.ids },
249
- typeOf: params.typeOf
250
- }, [], [
251
- 'aggregateEntranceGate', 'aggregateOffer', 'aggregateReservation',
252
- 'remainingAttendeeCapacity', 'checkInCount', 'attendeeCount'
253
- ]);
254
- }
255
- else if (params.typeOf === factory.eventType.ScreeningEvent) {
256
- events4inform = yield repos.event.search({
257
- id: { $in: params.ids },
258
- typeOf: params.typeOf
259
- }, [], [
260
- 'aggregateEntranceGate', 'aggregateOffer', 'aggregateReservation',
261
- 'remainingAttendeeCapacity', 'checkInCount', 'attendeeCount'
262
- ]);
263
- }
264
- else {
265
- events4inform = yield repos.event.search({
266
- id: { $in: params.ids },
267
- typeOf: params.typeOf
268
- }, [], []);
269
- }
270
- if (events4inform.length > 0) {
271
- const taskRunsAt = new Date();
272
- const informTasks = [];
273
- informEvents === null || informEvents === void 0 ? void 0 : informEvents.forEach((informEvent) => {
274
- var _a;
275
- const informUrl = String((_a = informEvent.recipient) === null || _a === void 0 ? void 0 : _a.url);
276
- events4inform.forEach((event4inform) => {
277
- var _a;
278
- // _idは不要であり、存在すると予期せぬ影響を及ぼす可能性がある
279
- delete event4inform._id;
280
- const informActionAttributes = {
281
- agent: event4inform.project,
282
- object: event4inform,
283
- project: event4inform.project,
284
- recipient: {
285
- id: '',
286
- name: String((_a = informEvent.recipient) === null || _a === void 0 ? void 0 : _a.name),
287
- typeOf: factory.creativeWorkType.WebApplication,
288
- url: informUrl
289
- },
290
- typeOf: factory.actionType.InformAction
291
- };
292
- informTasks.push({
293
- project: event4inform.project,
294
- name: factory.taskName.TriggerWebhook,
295
- status: factory.taskStatus.Ready,
296
- runsAt: taskRunsAt,
297
- remainingNumberOfTries: 10,
298
- numberOfTried: 0,
299
- executionResults: [],
300
- data: informActionAttributes
301
- });
302
- });
303
- });
304
- if (informTasks.length > 0) {
305
- yield repos.task.saveMany(informTasks, { emitImmediately: true });
306
- }
307
- }
308
- });
309
- }
310
- exports.createInformTasks = createInformTasks;
@@ -84,11 +84,12 @@ declare function publishPaymentUrl(params: {
84
84
  agent: {
85
85
  id: string;
86
86
  };
87
- object: factory.action.authorize.paymentMethod.any.IObject;
87
+ object: Pick<IObjectWithoutDetail, 'amount' | 'creditCard' | 'issuedThrough' | 'method' | 'paymentMethod'>;
88
88
  purpose: factory.action.authorize.paymentMethod.any.IPurpose;
89
89
  paymentServiceType: factory.service.paymentService.PaymentServiceType;
90
90
  location: factory.action.trade.pay.ILocation;
91
91
  }): IPublishPaymentUrlOperation<Pick<PayTransactionService.IPublishPaymentUrlResult, 'paymentMethodId' | 'paymentUrl'>>;
92
+ type IObjectWithoutDetail = factory.action.authorize.paymentMethod.any.IObjectWithoutDetail;
92
93
  /**
93
94
  * 決済承認
94
95
  */
@@ -99,7 +100,7 @@ declare function authorize(params: {
99
100
  agent: {
100
101
  id: string;
101
102
  };
102
- object: factory.action.authorize.paymentMethod.any.IObject;
103
+ object: IObjectWithoutDetail;
103
104
  purpose: factory.action.authorize.paymentMethod.any.IPurpose;
104
105
  paymentServiceType: factory.service.paymentService.PaymentServiceType;
105
106
  location?: factory.action.trade.pay.ILocation;
@@ -230,8 +230,9 @@ function publishPaymentUrl(params) {
230
230
  });
231
231
  let result;
232
232
  // URL発行
233
+ const authorizeObject = Object.assign(Object.assign({}, params.object), { accountId: '', paymentMethodId: transactionNumber, typeOf: factory.action.authorize.paymentMethod.any.ResultType.Payment });
233
234
  const startParams = (0, factory_1.creatPayTransactionStartParams)({
234
- object: params.object,
235
+ object: authorizeObject,
235
236
  paymentServiceType,
236
237
  transaction: transaction,
237
238
  transactionNumber: transactionNumber,
@@ -318,7 +319,11 @@ function authorize(params) {
318
319
  const publishTransactionNumberResult = yield repos.transactionNumber.publishByTimestamp({ startDate: new Date() });
319
320
  transactionNumber = publishTransactionNumberResult.transactionNumber;
320
321
  }
321
- const authorizeObject = Object.assign(Object.assign(Object.assign({}, params.object), { paymentMethodId: transactionNumber, typeOf: factory.action.authorize.paymentMethod.any.ResultType.Payment }), (creditCard !== undefined) ? { creditCard } : undefined);
322
+ const { accountId } = yield fixAccountIdIfPossible({
323
+ object: params.object,
324
+ project: { id: transaction.project.id }
325
+ })({ action: repos.action });
326
+ const authorizeObject = Object.assign(Object.assign(Object.assign({}, params.object), { accountId, paymentMethodId: transactionNumber, typeOf: factory.action.authorize.paymentMethod.any.ResultType.Payment }), (creditCard !== undefined) ? { creditCard } : undefined);
322
327
  // 承認アクションを開始する
323
328
  const actionAttributes = {
324
329
  project: transaction.project,
@@ -346,10 +351,6 @@ function authorize(params) {
346
351
  const action = yield repos.action.start(actionAttributes);
347
352
  let payTransaction;
348
353
  try {
349
- const { accountId } = yield validateFromLocation({
350
- object: authorizeObject,
351
- project: { id: transaction.project.id }
352
- })({ action: repos.action });
353
354
  const startParams = (0, factory_1.creatPayTransactionStartParams)({
354
355
  accountId,
355
356
  object: authorizeObject,
@@ -393,6 +394,9 @@ function authorize(params) {
393
394
  });
394
395
  }
395
396
  exports.authorize = authorize;
397
+ /**
398
+ * 注文取引に保管された決済情報を承認しようとしている決済の整合性をを検証する
399
+ */
396
400
  function validatePaymentMethodByTransaction(params) {
397
401
  var _a, _b;
398
402
  const paymentServiceIdByObject = params.object.issuedThrough.id;
@@ -414,11 +418,16 @@ function validatePaymentMethodByTransaction(params) {
414
418
  throw new factory.errors.Argument('object.paymentMethod', 'paymentMethod must match the target of the paymentUrl');
415
419
  }
416
420
  }
417
- function validateFromLocation(params) {
421
+ /**
422
+ * 承認しようとしているobjectからaccountIdを決定する
423
+ */
424
+ function fixAccountIdIfPossible(params) {
418
425
  return (repos) => __awaiter(this, void 0, void 0, function* () {
419
426
  var _a, _b;
420
- let accountId = (_a = params.object) === null || _a === void 0 ? void 0 : _a.accountId;
421
- const fromLocation = (_b = params.object) === null || _b === void 0 ? void 0 : _b.fromLocation;
427
+ // let accountId = params.object?.accountId;
428
+ let accountId = '';
429
+ const fromLocation = (_a = params.object) === null || _a === void 0 ? void 0 : _a.fromLocation;
430
+ const movieTickets = (_b = params.object) === null || _b === void 0 ? void 0 : _b.movieTickets;
422
431
  // トークン化されたペイメントカード情報でリクエストされた場合、実ペイメントカード情報へ変換する
423
432
  if (typeof fromLocation === 'string') {
424
433
  const paymentCardOwnershipInfo = yield (0, code_1.verifyToken)({
@@ -434,6 +443,10 @@ function validateFromLocation(params) {
434
443
  }
435
444
  accountId = paymentCardOwnershipInfo.typeOfGood.identifier;
436
445
  }
446
+ // 購入番号管理番号をaccountIdにセット(2024-03-24~)
447
+ if (Array.isArray(movieTickets) && movieTickets.length > 0) {
448
+ accountId = movieTickets[0].identifier; // 決済カードidentifierは1つのみ許可の前提
449
+ }
437
450
  return { accountId };
438
451
  });
439
452
  }
@@ -15,7 +15,7 @@ exports.onReservationCanceled = void 0;
15
15
  */
16
16
  const factory = require("../../../factory");
17
17
  const settings_1 = require("../../../settings");
18
- const offer_1 = require("../../offer");
18
+ const onEventChanged_1 = require("../../offer/onEventChanged");
19
19
  const factory_1 = require("../factory");
20
20
  const informReservations = settings_1.settings.onReservationStatusChanged.informReservation;
21
21
  function onReservationCanceled(
@@ -94,7 +94,7 @@ reservationFor) {
94
94
  }
95
95
  if (typeof (reservationFor === null || reservationFor === void 0 ? void 0 : reservationFor.id) === 'string') {
96
96
  // 冗長な作成を避ける
97
- yield (0, offer_1.createAggregateScreeningEventIfNotExist)({
97
+ yield (0, onEventChanged_1.createAggregateScreeningEventIfNotExist)({
98
98
  project: { id: reservationFor.project.id },
99
99
  reservationFor: [{ id: reservationFor.id }],
100
100
  force: false,
@@ -15,7 +15,7 @@ exports.onReservationCheckedIn = void 0;
15
15
  */
16
16
  const factory = require("../../../factory");
17
17
  const settings_1 = require("../../../settings");
18
- const offer_1 = require("../../offer");
18
+ const onEventChanged_1 = require("../../offer/onEventChanged");
19
19
  const factory_1 = require("../factory");
20
20
  const informReservations = settings_1.settings.onReservationStatusChanged.informReservation;
21
21
  // tslint:disable-next-line:max-func-body-length
@@ -118,7 +118,7 @@ function onReservationCheckedIn(params) {
118
118
  // { _id: 1 }
119
119
  );
120
120
  if (existingEvents.length > 0) {
121
- yield (0, offer_1.createAggregateScreeningEventIfNotExist)({
121
+ yield (0, onEventChanged_1.createAggregateScreeningEventIfNotExist)({
122
122
  project: { id: params.project.id },
123
123
  reservationFor: [{ id: reservationForId }],
124
124
  force: false,
@@ -15,7 +15,7 @@ exports.onReservationConfirmed = exports.onReservationConfirmedByAction = void 0
15
15
  */
16
16
  const factory = require("../../../factory");
17
17
  const settings_1 = require("../../../settings");
18
- const offer_1 = require("../../offer");
18
+ const onEventChanged_1 = require("../../offer/onEventChanged");
19
19
  const factory_1 = require("../factory");
20
20
  const informReservations = settings_1.settings.onReservationStatusChanged.informReservation;
21
21
  /**
@@ -56,7 +56,7 @@ function onReservationConfirmed(confirmedReservations) {
56
56
  if (Array.isArray(confirmedReservations) && confirmedReservations.length > 0) {
57
57
  // ひとつめの予約からReservationPackageの共有属性を取り出す
58
58
  const { issuedThrough, project, provider, reservationFor, reservationNumber, reservationStatus, underName } = confirmedReservations[0];
59
- yield (0, offer_1.createAggregateScreeningEventIfNotExist)({
59
+ yield (0, onEventChanged_1.createAggregateScreeningEventIfNotExist)({
60
60
  project,
61
61
  reservationFor: [{ id: reservationFor.id }],
62
62
  force: false,
@@ -15,7 +15,7 @@ exports.onReservationUsed = void 0;
15
15
  */
16
16
  const factory = require("../../../factory");
17
17
  const settings_1 = require("../../../settings");
18
- const offer_1 = require("../../offer");
18
+ const onEventChanged_1 = require("../../offer/onEventChanged");
19
19
  const factory_1 = require("../factory");
20
20
  const informReservations = settings_1.settings.onReservationStatusChanged.informReservation;
21
21
  /**
@@ -96,7 +96,7 @@ function onReservationUsed(attendedReservation) {
96
96
  yield repos.task.saveMany(tasks, { emitImmediately: true });
97
97
  }
98
98
  // 冗長な作成を避ける
99
- yield (0, offer_1.createAggregateScreeningEventIfNotExist)({
99
+ yield (0, onEventChanged_1.createAggregateScreeningEventIfNotExist)({
100
100
  project: attendedReservation.project,
101
101
  reservationFor: [{ id: attendedReservation.reservationFor.id }],
102
102
  force: false,
@@ -13,13 +13,13 @@ exports.call = void 0;
13
13
  const event_1 = require("../../repo/event");
14
14
  const project_1 = require("../../repo/project");
15
15
  const task_1 = require("../../repo/task");
16
- const offer_1 = require("../offer");
16
+ const onEventChanged_1 = require("../offer/onEventChanged");
17
17
  /**
18
18
  * タスク実行関数
19
19
  */
20
20
  function call(data) {
21
21
  return (settings) => __awaiter(this, void 0, void 0, function* () {
22
- yield (0, offer_1.onEventChanged)(data)({
22
+ yield (0, onEventChanged_1.onEventChanged)(data)({
23
23
  event: new event_1.MongoRepository(settings.connection),
24
24
  project: new project_1.MongoRepository(settings.connection),
25
25
  task: new task_1.MongoRepository(settings.connection)
@@ -42,6 +42,7 @@ export declare const USE_SEND_EMAIL_MESSAGE_ON_ORDER_PROCESSING: boolean;
42
42
  export declare const USE_OWNERSHIP_INFO_BY_WEB_APPLICATION: boolean;
43
43
  export declare const USE_CHECK_RESOURCE_TASK: boolean;
44
44
  export declare const USE_OPTIMIZE_RESERVATION_EXCEPTIONS: string[];
45
+ export declare const USE_OPTIMIZE_INFORM_EVENT: boolean;
45
46
  export declare const MONGO_MAX_TIME_MS: number;
46
47
  export declare const MONGO_READ_PREFERENCE: string;
47
48
  export declare const MONGO_AUTO_INDEX: boolean;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.settings = exports.DELIVER_ORDER_LIMIT = exports.MONGO_AUTO_INDEX = exports.MONGO_READ_PREFERENCE = exports.MONGO_MAX_TIME_MS = exports.USE_OPTIMIZE_RESERVATION_EXCEPTIONS = exports.USE_CHECK_RESOURCE_TASK = exports.USE_OWNERSHIP_INFO_BY_WEB_APPLICATION = exports.USE_SEND_EMAIL_MESSAGE_ON_ORDER_PROCESSING = exports.USE_FETCH_API = exports.USE_OPTIMIZE_TICKET_OFFER = exports.USE_DELETE_EVENT_BY_ORDER = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_TASKS_EXPORT_AGENT_NAME = exports.DEFAULT_SENDER_EMAIL = exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = exports.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS = exports.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS = exports.MAX_NUM_CREDIT_CARD_PAYMENT_METHOD = exports.ABORTED_TASKS_WITHOUT_REPORT = exports.MAXIMUM_RESERVATION_GRACE_PERIOD_IN_DAYS = exports.TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS = exports.TRIGGER_WEBHOOK_MAX_RETRY_COUNT = void 0;
3
+ exports.settings = exports.DELIVER_ORDER_LIMIT = exports.MONGO_AUTO_INDEX = exports.MONGO_READ_PREFERENCE = exports.MONGO_MAX_TIME_MS = exports.USE_OPTIMIZE_INFORM_EVENT = exports.USE_OPTIMIZE_RESERVATION_EXCEPTIONS = exports.USE_CHECK_RESOURCE_TASK = exports.USE_OWNERSHIP_INFO_BY_WEB_APPLICATION = exports.USE_SEND_EMAIL_MESSAGE_ON_ORDER_PROCESSING = exports.USE_FETCH_API = exports.USE_OPTIMIZE_TICKET_OFFER = exports.USE_DELETE_EVENT_BY_ORDER = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_TASKS_EXPORT_AGENT_NAME = exports.DEFAULT_SENDER_EMAIL = exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = exports.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS = exports.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS = exports.MAX_NUM_CREDIT_CARD_PAYMENT_METHOD = exports.ABORTED_TASKS_WITHOUT_REPORT = exports.MAXIMUM_RESERVATION_GRACE_PERIOD_IN_DAYS = exports.TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS = exports.TRIGGER_WEBHOOK_MAX_RETRY_COUNT = void 0;
4
4
  const factory = require("./factory");
5
5
  const transactionWebhookUrls = (typeof process.env.INFORM_TRANSACTION_URL === 'string')
6
6
  ? process.env.INFORM_TRANSACTION_URL.split(' ')
@@ -68,6 +68,7 @@ exports.USE_CHECK_RESOURCE_TASK = process.env.USE_CHECK_RESOURCE_TASK === '1';
68
68
  exports.USE_OPTIMIZE_RESERVATION_EXCEPTIONS = (typeof process.env.USE_OPTIMIZE_RESERVATION_EXCEPTIONS === 'string')
69
69
  ? process.env.USE_OPTIMIZE_RESERVATION_EXCEPTIONS.split(' ')
70
70
  : [];
71
+ exports.USE_OPTIMIZE_INFORM_EVENT = process.env.USE_OPTIMIZE_INFORM_EVENT === '1';
71
72
  exports.MONGO_MAX_TIME_MS = (typeof process.env.MONGO_MAX_TIME_MS === 'string')
72
73
  ? Number(process.env.MONGO_MAX_TIME_MS)
73
74
  // tslint:disable-next-line:no-magic-numbers
package/package.json CHANGED
@@ -10,8 +10,8 @@
10
10
  ],
11
11
  "dependencies": {
12
12
  "@aws-sdk/credential-providers": "3.433.0",
13
- "@chevre/factory": "4.364.0-alpha.0",
14
- "@cinerino/sdk": "5.14.1",
13
+ "@chevre/factory": "4.364.0-alpha.1",
14
+ "@cinerino/sdk": "5.15.0-alpha.0",
15
15
  "@motionpicture/coa-service": "9.4.0",
16
16
  "@motionpicture/gmo-service": "5.3.0",
17
17
  "@sendgrid/mail": "6.4.0",
@@ -110,5 +110,5 @@
110
110
  "postversion": "git push origin --tags",
111
111
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
112
112
  },
113
- "version": "21.27.0-alpha.10"
113
+ "version": "21.27.0-alpha.12"
114
114
  }