@chevre/domain 21.9.0-alpha.13 → 21.9.0-alpha.15

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.
@@ -146,38 +146,61 @@ class MongoRepository {
146
146
  return (result.length > 0) ? result[0].numItems : 0;
147
147
  });
148
148
  }
149
- search(params) {
149
+ search(params, projection) {
150
150
  var _a;
151
151
  return __awaiter(this, void 0, void 0, function* () {
152
152
  const conditions = MongoRepository.CREATE_MONGO_CONDITIONS(params);
153
153
  const matchStages = conditions.map((condition) => {
154
154
  return { $match: condition };
155
155
  });
156
+ let projectStage = {
157
+ _id: 0,
158
+ name: '$name',
159
+ description: '$description',
160
+ project: '$project',
161
+ typeOf: '$typeOf',
162
+ id: { $toString: '$_id' },
163
+ identifier: '$identifier',
164
+ itemOffered: '$itemOffered',
165
+ additionalProperty: '$additionalProperty',
166
+ relatedOffer: '$relatedOffer',
167
+ numberOfItems: {
168
+ $cond: {
169
+ if: { $isArray: '$itemListElement' },
170
+ then: { $size: '$itemListElement' },
171
+ else: 0
172
+ }
173
+ },
174
+ itemListElementTypeOf: { $first: '$itemListElement.typeOf' },
175
+ dateSynced: '$dateSynced'
176
+ };
177
+ const positiveProjectionFields = Object.keys(projection)
178
+ .filter((key) => projection[key] !== 0);
179
+ const negativeProjectionFields = Object.keys(projection)
180
+ .filter((key) => projection[key] === 0);
181
+ if (positiveProjectionFields.length > 0) {
182
+ projectStage = {
183
+ _id: 0,
184
+ id: { $toString: '$_id' }
185
+ };
186
+ positiveProjectionFields.forEach((field) => {
187
+ if (field !== '_id' && field !== 'id') {
188
+ projectStage[field] = `$${field}`;
189
+ }
190
+ });
191
+ }
192
+ else if (negativeProjectionFields.length > 0) {
193
+ negativeProjectionFields.forEach((field) => {
194
+ if (projectStage[field] !== undefined && projectStage[field] !== null) {
195
+ // tslint:disable-next-line:no-dynamic-delete
196
+ delete projectStage[field];
197
+ }
198
+ });
199
+ }
156
200
  const aggregate = this.offerCatalogItemModel.aggregate([
157
201
  ...(((_a = params.sort) === null || _a === void 0 ? void 0 : _a.identifier) !== undefined) ? [{ $sort: { identifier: params.sort.identifier } }] : [],
158
202
  ...matchStages,
159
- {
160
- $project: {
161
- _id: 0,
162
- name: '$name',
163
- description: '$description',
164
- project: '$project',
165
- typeOf: '$typeOf',
166
- id: { $toString: '$_id' },
167
- identifier: '$identifier',
168
- itemOffered: '$itemOffered',
169
- additionalProperty: '$additionalProperty',
170
- relatedOffer: '$relatedOffer',
171
- numberOfItems: {
172
- $cond: {
173
- if: { $isArray: '$itemListElement' },
174
- then: { $size: '$itemListElement' },
175
- else: 0
176
- }
177
- },
178
- itemListElementTypeOf: { $first: '$itemListElement.typeOf' }
179
- }
180
- }
203
+ { $project: projectStage }
181
204
  ]);
182
205
  if (typeof params.limit === 'number' && params.limit > 0) {
183
206
  const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
@@ -74,7 +74,7 @@ export declare class MongoRepository {
74
74
  */
75
75
  $nin?: factory.taskName[];
76
76
  };
77
- }): Promise<Pick<import("@chevre/factory/lib/task").ITask | import("@chevre/factory/lib/task/confirmMoneyTransfer").ITask | import("@chevre/factory/lib/task/confirmRegisterService").ITask | import("@chevre/factory/lib/task/confirmPayTransaction").ITask | import("@chevre/factory/lib/task/confirmRegisterServiceTransaction").ITask | import("@chevre/factory/lib/task/confirmReserveTransaction").ITask | import("@chevre/factory/lib/task/createEvent").ITask | import("@chevre/factory/lib/task/deleteTransaction").ITask | import("@chevre/factory/lib/task/givePointAward").ITask | import("@chevre/factory/lib/task/onAssetTransactionStatusChanged").ITask | import("@chevre/factory/lib/task/onAuthorizationCreated").ITask | import("@chevre/factory/lib/task/onEventChanged").ITask | import("@chevre/factory/lib/task/onResourceUpdated").ITask | import("@chevre/factory/lib/task/onOrderPaymentCompleted").ITask | import("@chevre/factory/lib/task/placeOrder").ITask | import("@chevre/factory/lib/task/returnOrder").ITask | import("@chevre/factory/lib/task/returnMoneyTransfer").ITask | import("@chevre/factory/lib/task/returnPayTransaction").ITask | import("@chevre/factory/lib/task/returnPointAward").ITask | import("@chevre/factory/lib/task/returnReserveTransaction").ITask | import("@chevre/factory/lib/task/sendEmailMessage").ITask | import("@chevre/factory/lib/task/sendOrder").ITask | import("@chevre/factory/lib/task/syncAggregateOffer").ITask | import("@chevre/factory/lib/task/syncScreeningRooms").ITask | import("@chevre/factory/lib/task/triggerWebhook").ITask | import("@chevre/factory/lib/task/useReservation").ITask | import("@chevre/factory/lib/task/voidMoneyTransferTransaction").ITask | import("@chevre/factory/lib/task/voidPayTransaction").ITask | import("@chevre/factory/lib/task/voidRegisterServiceTransaction").ITask | import("@chevre/factory/lib/task/voidReserveTransaction").ITask, "id" | "name" | "status">[]>;
77
+ }): Promise<Pick<import("@chevre/factory/lib/task").ITask | import("@chevre/factory/lib/task/confirmMoneyTransfer").ITask | import("@chevre/factory/lib/task/confirmRegisterService").ITask | import("@chevre/factory/lib/task/confirmPayTransaction").ITask | import("@chevre/factory/lib/task/confirmRegisterServiceTransaction").ITask | import("@chevre/factory/lib/task/confirmReserveTransaction").ITask | import("@chevre/factory/lib/task/createEvent").ITask | import("@chevre/factory/lib/task/deleteTransaction").ITask | import("@chevre/factory/lib/task/givePointAward").ITask | import("@chevre/factory/lib/task/onAssetTransactionStatusChanged").ITask | import("@chevre/factory/lib/task/onAuthorizationCreated").ITask | import("@chevre/factory/lib/task/onEventChanged").ITask | import("@chevre/factory/lib/task/onResourceUpdated").ITask | import("@chevre/factory/lib/task/onOrderPaymentCompleted").ITask | import("@chevre/factory/lib/task/placeOrder").ITask | import("@chevre/factory/lib/task/returnOrder").ITask | import("@chevre/factory/lib/task/returnMoneyTransfer").ITask | import("@chevre/factory/lib/task/returnPayTransaction").ITask | import("@chevre/factory/lib/task/returnPointAward").ITask | import("@chevre/factory/lib/task/returnReserveTransaction").ITask | import("@chevre/factory/lib/task/sendEmailMessage").ITask | import("@chevre/factory/lib/task/sendOrder").ITask | import("@chevre/factory/lib/task/syncScreeningRooms").ITask | import("@chevre/factory/lib/task/triggerWebhook").ITask | import("@chevre/factory/lib/task/useReservation").ITask | import("@chevre/factory/lib/task/voidMoneyTransferTransaction").ITask | import("@chevre/factory/lib/task/voidPayTransaction").ITask | import("@chevre/factory/lib/task/voidRegisterServiceTransaction").ITask | import("@chevre/factory/lib/task/voidReserveTransaction").ITask, "id" | "name" | "status">[]>;
78
78
  retry(params: {
79
79
  intervalInMinutes: number;
80
80
  }): Promise<void>;
@@ -1,6 +1,7 @@
1
1
  import { MongoRepository as EventRepo } from '../../../repo/event';
2
2
  import { MongoRepository as OfferRepo } from '../../../repo/offer';
3
3
  import { MongoRepository as OfferCatalogRepo } from '../../../repo/offerCatalog';
4
+ import { MongoRepository as OfferCatalogItemRepo } from '../../../repo/offerCatalogItem';
4
5
  import { MongoRepository as PriceSpecificationRepo } from '../../../repo/priceSpecification';
5
6
  import { MongoRepository as ProductRepo } from '../../../repo/product';
6
7
  import { RedisRepository as OfferRateLimitRepo } from '../../../repo/rateLimit/offer';
@@ -77,4 +78,53 @@ declare function searchOfferAppliesToMovieTicket(params: {
77
78
  offerCatalog: OfferCatalogRepo;
78
79
  product: ProductRepo;
79
80
  }) => Promise<Pick<factory.priceSpecification.unitPrice.IAppliesToMovieTicket, 'serviceOutput'>[]>;
80
- export { searchEventTicketOffers, searchOfferAppliesToMovieTicket };
81
+ type ISearchOfferCatalogItemResult = Pick<factory.offerCatalog.IOfferCatalog, 'id' | 'name' | 'description' | 'additionalProperty' | 'relatedOffer'> & {
82
+ elementIndex: number;
83
+ };
84
+ /**
85
+ * サブカタログ検索
86
+ */
87
+ declare function searchOfferCatalogItems(params: {
88
+ event: {
89
+ /**
90
+ * イベントID
91
+ */
92
+ id: string;
93
+ };
94
+ limit: number;
95
+ page: number;
96
+ }): (repos: {
97
+ event: EventRepo;
98
+ offerCatalog: OfferCatalogRepo;
99
+ offerCatalogItem: OfferCatalogItemRepo;
100
+ product: ProductRepo;
101
+ }) => Promise<ISearchOfferCatalogItemResult[]>;
102
+ interface ISearchOfferCatalogItemAvailabilityResult {
103
+ id: string;
104
+ isAvailable: boolean;
105
+ }
106
+ /**
107
+ * サブカタログ利用可能性検索
108
+ */
109
+ declare function searchOfferCatalogItemAvailability(params: {
110
+ event: {
111
+ /**
112
+ * イベントID
113
+ */
114
+ id: string;
115
+ };
116
+ /**
117
+ * どのアプリケーションに対して
118
+ */
119
+ availableAtOrFrom: {
120
+ id: string;
121
+ };
122
+ limit: number;
123
+ page: number;
124
+ }): (repos: {
125
+ event: EventRepo;
126
+ offer: OfferRepo;
127
+ offerCatalog: OfferCatalogRepo;
128
+ product: ProductRepo;
129
+ }) => Promise<ISearchOfferCatalogItemAvailabilityResult[]>;
130
+ export { searchEventTicketOffers, searchOfferAppliesToMovieTicket, searchOfferCatalogItems, searchOfferCatalogItemAvailability };
@@ -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.searchOfferAppliesToMovieTicket = exports.searchEventTicketOffers = void 0;
12
+ exports.searchOfferCatalogItemAvailability = exports.searchOfferCatalogItems = exports.searchOfferAppliesToMovieTicket = exports.searchEventTicketOffers = void 0;
13
13
  const moment = require("moment-timezone");
14
14
  const factory = require("../../../factory");
15
15
  const factory_1 = require("../factory");
@@ -349,3 +349,118 @@ function searchOfferAppliesToMovieTicket(params) {
349
349
  });
350
350
  }
351
351
  exports.searchOfferAppliesToMovieTicket = searchOfferAppliesToMovieTicket;
352
+ /**
353
+ * サブカタログ検索
354
+ */
355
+ function searchOfferCatalogItems(params) {
356
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
357
+ var _a, _b;
358
+ if (typeof params.limit !== 'number') {
359
+ throw new factory.errors.Argument('limit', 'must be number');
360
+ }
361
+ if (typeof params.page !== 'number') {
362
+ throw new factory.errors.Argument('page', 'must be number');
363
+ }
364
+ let offerCatalogItems = [];
365
+ const event = yield repos.event.findMinimizedIndividualEventById({ id: params.event.id });
366
+ // 興行設定があれば興行のカタログを参照する
367
+ const eventOffers = event.offers;
368
+ let catalogId;
369
+ if (typeof ((_a = eventOffers.itemOffered) === null || _a === void 0 ? void 0 : _a.id) === 'string') {
370
+ const eventService = yield repos.product.findById({ id: eventOffers.itemOffered.id }, ['hasOfferCatalog'], []);
371
+ if (typeof ((_b = eventService.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.id) === 'string') {
372
+ catalogId = eventService.hasOfferCatalog.id;
373
+ }
374
+ }
375
+ if (typeof catalogId !== 'string') {
376
+ throw new factory.errors.NotFound('itemOffered.hasOfferCatalog');
377
+ }
378
+ const offerCatalogFirstElement = yield repos.offerCatalog.findFirstItemListElementById({ id: catalogId });
379
+ if (offerCatalogFirstElement.typeOf === 'OfferCatalog') {
380
+ const catalogItemListElements = yield repos.offerCatalog.searchItemListElementById({
381
+ id: catalogId,
382
+ limit: params.limit,
383
+ page: params.page
384
+ });
385
+ if (catalogItemListElements.length > 0) {
386
+ // サブカタログ検索
387
+ const searchOfferCatalogItemsResult = yield repos.offerCatalogItem.search({
388
+ id: { $in: catalogItemListElements.map((element) => element.id) }
389
+ }, {
390
+ id: 1,
391
+ name: 1,
392
+ description: 1,
393
+ additionalProperty: 1,
394
+ relatedOffer: 1
395
+ });
396
+ offerCatalogItems = catalogItemListElements.map((element) => {
397
+ const offerCatalogItem = searchOfferCatalogItemsResult.find((item) => item.id === element.id);
398
+ if (offerCatalogItem === undefined) {
399
+ throw new factory.errors.NotFound('OfferCatalog', `offerCatalogItem '${element.id}' not found`);
400
+ }
401
+ return Object.assign(Object.assign({}, element), offerCatalogItem);
402
+ });
403
+ }
404
+ }
405
+ else {
406
+ // Offerによるカタログの場合はひとまずempty
407
+ }
408
+ return offerCatalogItems;
409
+ });
410
+ }
411
+ exports.searchOfferCatalogItems = searchOfferCatalogItems;
412
+ /**
413
+ * サブカタログ利用可能性検索
414
+ */
415
+ function searchOfferCatalogItemAvailability(params) {
416
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
417
+ var _a, _b;
418
+ if (typeof params.limit !== 'number') {
419
+ throw new factory.errors.Argument('limit', 'must be number');
420
+ }
421
+ if (typeof params.page !== 'number') {
422
+ throw new factory.errors.Argument('page', 'must be number');
423
+ }
424
+ let availabilities = [];
425
+ const event = yield repos.event.findMinimizedIndividualEventById({ id: params.event.id });
426
+ // 興行設定があれば興行のカタログを参照する
427
+ const eventOffers = event.offers;
428
+ let catalogId;
429
+ if (typeof ((_a = eventOffers.itemOffered) === null || _a === void 0 ? void 0 : _a.id) === 'string') {
430
+ const eventService = yield repos.product.findById({ id: eventOffers.itemOffered.id }, ['hasOfferCatalog'], []);
431
+ if (typeof ((_b = eventService.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.id) === 'string') {
432
+ catalogId = eventService.hasOfferCatalog.id;
433
+ }
434
+ }
435
+ if (typeof catalogId !== 'string') {
436
+ throw new factory.errors.NotFound('itemOffered.hasOfferCatalog');
437
+ }
438
+ const offerCatalogFirstElement = yield repos.offerCatalog.findFirstItemListElementById({ id: catalogId });
439
+ if (offerCatalogFirstElement.typeOf === 'OfferCatalog') {
440
+ const catalogItemListElements = yield repos.offerCatalog.searchItemListElementById({
441
+ id: catalogId,
442
+ limit: params.limit,
443
+ page: params.page
444
+ });
445
+ if (catalogItemListElements.length > 0) {
446
+ // 単価オファーから利用可能なサブカタログを検索
447
+ const availableCatalogs = yield repos.offer.searchAvailableCatalogs({
448
+ project: { id: event.project.id },
449
+ includedInDataCatalog: { id: catalogItemListElements.map((element) => element.id) },
450
+ availableAtOrFrom: { id: params.availableAtOrFrom.id }
451
+ });
452
+ availabilities = catalogItemListElements.map((element) => {
453
+ return {
454
+ id: element.id,
455
+ isAvailable: availableCatalogs.some((item) => item.id === element.id)
456
+ };
457
+ });
458
+ }
459
+ }
460
+ else {
461
+ // Offerによるカタログの場合はひとまずempty
462
+ }
463
+ return availabilities;
464
+ });
465
+ }
466
+ exports.searchOfferCatalogItemAvailability = searchOfferCatalogItemAvailability;
@@ -1,6 +1,6 @@
1
1
  import { authorize } from './event/authorize';
2
2
  import { cancel } from './event/cancel';
3
3
  import { importCategoryCodesFromCOA, importFromCOA } from './event/importFromCOA';
4
- import { searchEventTicketOffers, searchOfferAppliesToMovieTicket } from './event/searchEventTicketOffers';
4
+ import { searchEventTicketOffers, searchOfferAppliesToMovieTicket, searchOfferCatalogItemAvailability, searchOfferCatalogItems } from './event/searchEventTicketOffers';
5
5
  import { voidTransaction } from './event/voidTransaction';
6
- export { authorize, cancel, importCategoryCodesFromCOA, importFromCOA, voidTransaction, searchEventTicketOffers, searchOfferAppliesToMovieTicket };
6
+ export { authorize, cancel, importCategoryCodesFromCOA, importFromCOA, voidTransaction, searchEventTicketOffers, searchOfferAppliesToMovieTicket, searchOfferCatalogItemAvailability, searchOfferCatalogItems };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.searchOfferAppliesToMovieTicket = exports.searchEventTicketOffers = exports.voidTransaction = exports.importFromCOA = exports.importCategoryCodesFromCOA = exports.cancel = exports.authorize = void 0;
3
+ exports.searchOfferCatalogItems = exports.searchOfferCatalogItemAvailability = exports.searchOfferAppliesToMovieTicket = exports.searchEventTicketOffers = exports.voidTransaction = exports.importFromCOA = exports.importCategoryCodesFromCOA = exports.cancel = exports.authorize = void 0;
4
4
  const authorize_1 = require("./event/authorize");
5
5
  Object.defineProperty(exports, "authorize", { enumerable: true, get: function () { return authorize_1.authorize; } });
6
6
  const cancel_1 = require("./event/cancel");
@@ -11,5 +11,7 @@ Object.defineProperty(exports, "importFromCOA", { enumerable: true, get: functio
11
11
  const searchEventTicketOffers_1 = require("./event/searchEventTicketOffers");
12
12
  Object.defineProperty(exports, "searchEventTicketOffers", { enumerable: true, get: function () { return searchEventTicketOffers_1.searchEventTicketOffers; } });
13
13
  Object.defineProperty(exports, "searchOfferAppliesToMovieTicket", { enumerable: true, get: function () { return searchEventTicketOffers_1.searchOfferAppliesToMovieTicket; } });
14
+ Object.defineProperty(exports, "searchOfferCatalogItemAvailability", { enumerable: true, get: function () { return searchEventTicketOffers_1.searchOfferCatalogItemAvailability; } });
15
+ Object.defineProperty(exports, "searchOfferCatalogItems", { enumerable: true, get: function () { return searchEventTicketOffers_1.searchOfferCatalogItems; } });
14
16
  const voidTransaction_1 = require("./event/voidTransaction");
15
17
  Object.defineProperty(exports, "voidTransaction", { enumerable: true, get: function () { return voidTransaction_1.voidTransaction; } });
@@ -26,17 +26,17 @@ export type IExternalOrder = Pick<factory.order.IOrder, 'project' | 'typeOf' | '
26
26
  */
27
27
  export declare function createOnOrderSentTasksByTransaction(params: {
28
28
  potentialActions?: factory.action.transfer.send.order.IPotentialActions;
29
- }): (import("@chevre/factory/lib/task").IAttributes | import("@chevre/factory/lib/task/confirmMoneyTransfer").IAttributes | import("@chevre/factory/lib/task/confirmRegisterService").IAttributes | import("@chevre/factory/lib/task/confirmPayTransaction").IAttributes | import("@chevre/factory/lib/task/confirmRegisterServiceTransaction").IAttributes | import("@chevre/factory/lib/task/confirmReserveTransaction").IAttributes | import("@chevre/factory/lib/task/createEvent").IAttributes | import("@chevre/factory/lib/task/deleteTransaction").IAttributes | import("@chevre/factory/lib/task/givePointAward").IAttributes | import("@chevre/factory/lib/task/onAssetTransactionStatusChanged").IAttributes | import("@chevre/factory/lib/task/onAuthorizationCreated").IAttributes | import("@chevre/factory/lib/task/onEventChanged").IAttributes | import("@chevre/factory/lib/task/onResourceUpdated").IAttributes | import("@chevre/factory/lib/task/onOrderPaymentCompleted").IAttributes | import("@chevre/factory/lib/task/placeOrder").IAttributes | import("@chevre/factory/lib/task/returnOrder").IAttributes | import("@chevre/factory/lib/task/returnMoneyTransfer").IAttributes | import("@chevre/factory/lib/task/returnPayTransaction").IAttributes | import("@chevre/factory/lib/task/returnPointAward").IAttributes | import("@chevre/factory/lib/task/returnReserveTransaction").IAttributes | import("@chevre/factory/lib/task/sendEmailMessage").IAttributes | import("@chevre/factory/lib/task/sendOrder").IAttributes | import("@chevre/factory/lib/task/syncAggregateOffer").IAttributes | import("@chevre/factory/lib/task/syncScreeningRooms").IAttributes | import("@chevre/factory/lib/task/triggerWebhook").IAttributes | import("@chevre/factory/lib/task/useReservation").IAttributes | import("@chevre/factory/lib/task/voidMoneyTransferTransaction").IAttributes | import("@chevre/factory/lib/task/voidPayTransaction").IAttributes | import("@chevre/factory/lib/task/voidRegisterServiceTransaction").IAttributes | import("@chevre/factory/lib/task/voidReserveTransaction").IAttributes)[];
29
+ }): (import("@chevre/factory/lib/task").IAttributes | import("@chevre/factory/lib/task/confirmMoneyTransfer").IAttributes | import("@chevre/factory/lib/task/confirmRegisterService").IAttributes | import("@chevre/factory/lib/task/confirmPayTransaction").IAttributes | import("@chevre/factory/lib/task/confirmRegisterServiceTransaction").IAttributes | import("@chevre/factory/lib/task/confirmReserveTransaction").IAttributes | import("@chevre/factory/lib/task/createEvent").IAttributes | import("@chevre/factory/lib/task/deleteTransaction").IAttributes | import("@chevre/factory/lib/task/givePointAward").IAttributes | import("@chevre/factory/lib/task/onAssetTransactionStatusChanged").IAttributes | import("@chevre/factory/lib/task/onAuthorizationCreated").IAttributes | import("@chevre/factory/lib/task/onEventChanged").IAttributes | import("@chevre/factory/lib/task/onResourceUpdated").IAttributes | import("@chevre/factory/lib/task/onOrderPaymentCompleted").IAttributes | import("@chevre/factory/lib/task/placeOrder").IAttributes | import("@chevre/factory/lib/task/returnOrder").IAttributes | import("@chevre/factory/lib/task/returnMoneyTransfer").IAttributes | import("@chevre/factory/lib/task/returnPayTransaction").IAttributes | import("@chevre/factory/lib/task/returnPointAward").IAttributes | import("@chevre/factory/lib/task/returnReserveTransaction").IAttributes | import("@chevre/factory/lib/task/sendEmailMessage").IAttributes | import("@chevre/factory/lib/task/sendOrder").IAttributes | import("@chevre/factory/lib/task/syncScreeningRooms").IAttributes | import("@chevre/factory/lib/task/triggerWebhook").IAttributes | import("@chevre/factory/lib/task/useReservation").IAttributes | import("@chevre/factory/lib/task/voidMoneyTransferTransaction").IAttributes | import("@chevre/factory/lib/task/voidPayTransaction").IAttributes | import("@chevre/factory/lib/task/voidRegisterServiceTransaction").IAttributes | import("@chevre/factory/lib/task/voidReserveTransaction").IAttributes)[];
30
30
  /**
31
31
  * 注文返品後のアクション
32
32
  */
33
33
  export declare function createOnOrderReturnedTasksByTransaction(params: {
34
34
  potentialActions?: factory.action.transfer.returnAction.order.IPotentialActions;
35
- }): (import("@chevre/factory/lib/task").IAttributes | import("@chevre/factory/lib/task/confirmMoneyTransfer").IAttributes | import("@chevre/factory/lib/task/confirmRegisterService").IAttributes | import("@chevre/factory/lib/task/confirmPayTransaction").IAttributes | import("@chevre/factory/lib/task/confirmRegisterServiceTransaction").IAttributes | import("@chevre/factory/lib/task/confirmReserveTransaction").IAttributes | import("@chevre/factory/lib/task/createEvent").IAttributes | import("@chevre/factory/lib/task/deleteTransaction").IAttributes | import("@chevre/factory/lib/task/givePointAward").IAttributes | import("@chevre/factory/lib/task/onAssetTransactionStatusChanged").IAttributes | import("@chevre/factory/lib/task/onAuthorizationCreated").IAttributes | import("@chevre/factory/lib/task/onEventChanged").IAttributes | import("@chevre/factory/lib/task/onResourceUpdated").IAttributes | import("@chevre/factory/lib/task/onOrderPaymentCompleted").IAttributes | import("@chevre/factory/lib/task/placeOrder").IAttributes | import("@chevre/factory/lib/task/returnOrder").IAttributes | import("@chevre/factory/lib/task/returnMoneyTransfer").IAttributes | import("@chevre/factory/lib/task/returnPayTransaction").IAttributes | import("@chevre/factory/lib/task/returnPointAward").IAttributes | import("@chevre/factory/lib/task/returnReserveTransaction").IAttributes | import("@chevre/factory/lib/task/sendEmailMessage").IAttributes | import("@chevre/factory/lib/task/sendOrder").IAttributes | import("@chevre/factory/lib/task/syncAggregateOffer").IAttributes | import("@chevre/factory/lib/task/syncScreeningRooms").IAttributes | import("@chevre/factory/lib/task/triggerWebhook").IAttributes | import("@chevre/factory/lib/task/useReservation").IAttributes | import("@chevre/factory/lib/task/voidMoneyTransferTransaction").IAttributes | import("@chevre/factory/lib/task/voidPayTransaction").IAttributes | import("@chevre/factory/lib/task/voidRegisterServiceTransaction").IAttributes | import("@chevre/factory/lib/task/voidReserveTransaction").IAttributes)[];
35
+ }): (import("@chevre/factory/lib/task").IAttributes | import("@chevre/factory/lib/task/confirmMoneyTransfer").IAttributes | import("@chevre/factory/lib/task/confirmRegisterService").IAttributes | import("@chevre/factory/lib/task/confirmPayTransaction").IAttributes | import("@chevre/factory/lib/task/confirmRegisterServiceTransaction").IAttributes | import("@chevre/factory/lib/task/confirmReserveTransaction").IAttributes | import("@chevre/factory/lib/task/createEvent").IAttributes | import("@chevre/factory/lib/task/deleteTransaction").IAttributes | import("@chevre/factory/lib/task/givePointAward").IAttributes | import("@chevre/factory/lib/task/onAssetTransactionStatusChanged").IAttributes | import("@chevre/factory/lib/task/onAuthorizationCreated").IAttributes | import("@chevre/factory/lib/task/onEventChanged").IAttributes | import("@chevre/factory/lib/task/onResourceUpdated").IAttributes | import("@chevre/factory/lib/task/onOrderPaymentCompleted").IAttributes | import("@chevre/factory/lib/task/placeOrder").IAttributes | import("@chevre/factory/lib/task/returnOrder").IAttributes | import("@chevre/factory/lib/task/returnMoneyTransfer").IAttributes | import("@chevre/factory/lib/task/returnPayTransaction").IAttributes | import("@chevre/factory/lib/task/returnPointAward").IAttributes | import("@chevre/factory/lib/task/returnReserveTransaction").IAttributes | import("@chevre/factory/lib/task/sendEmailMessage").IAttributes | import("@chevre/factory/lib/task/sendOrder").IAttributes | import("@chevre/factory/lib/task/syncScreeningRooms").IAttributes | import("@chevre/factory/lib/task/triggerWebhook").IAttributes | import("@chevre/factory/lib/task/useReservation").IAttributes | import("@chevre/factory/lib/task/voidMoneyTransferTransaction").IAttributes | import("@chevre/factory/lib/task/voidPayTransaction").IAttributes | import("@chevre/factory/lib/task/voidRegisterServiceTransaction").IAttributes | import("@chevre/factory/lib/task/voidReserveTransaction").IAttributes)[];
36
36
  /**
37
37
  * 注文中止時のアクション
38
38
  */
39
39
  export declare function createOnOrderCancelledTasksByTransaction(params: {
40
40
  transaction?: factory.transaction.placeOrder.ITransaction;
41
- }): (import("@chevre/factory/lib/task").IAttributes | import("@chevre/factory/lib/task/confirmMoneyTransfer").IAttributes | import("@chevre/factory/lib/task/confirmRegisterService").IAttributes | import("@chevre/factory/lib/task/confirmPayTransaction").IAttributes | import("@chevre/factory/lib/task/confirmRegisterServiceTransaction").IAttributes | import("@chevre/factory/lib/task/confirmReserveTransaction").IAttributes | import("@chevre/factory/lib/task/createEvent").IAttributes | import("@chevre/factory/lib/task/deleteTransaction").IAttributes | import("@chevre/factory/lib/task/givePointAward").IAttributes | import("@chevre/factory/lib/task/onAssetTransactionStatusChanged").IAttributes | import("@chevre/factory/lib/task/onAuthorizationCreated").IAttributes | import("@chevre/factory/lib/task/onEventChanged").IAttributes | import("@chevre/factory/lib/task/onResourceUpdated").IAttributes | import("@chevre/factory/lib/task/onOrderPaymentCompleted").IAttributes | import("@chevre/factory/lib/task/placeOrder").IAttributes | import("@chevre/factory/lib/task/returnOrder").IAttributes | import("@chevre/factory/lib/task/returnMoneyTransfer").IAttributes | import("@chevre/factory/lib/task/returnPayTransaction").IAttributes | import("@chevre/factory/lib/task/returnPointAward").IAttributes | import("@chevre/factory/lib/task/returnReserveTransaction").IAttributes | import("@chevre/factory/lib/task/sendEmailMessage").IAttributes | import("@chevre/factory/lib/task/sendOrder").IAttributes | import("@chevre/factory/lib/task/syncAggregateOffer").IAttributes | import("@chevre/factory/lib/task/syncScreeningRooms").IAttributes | import("@chevre/factory/lib/task/triggerWebhook").IAttributes | import("@chevre/factory/lib/task/useReservation").IAttributes | import("@chevre/factory/lib/task/voidMoneyTransferTransaction").IAttributes | import("@chevre/factory/lib/task/voidPayTransaction").IAttributes | import("@chevre/factory/lib/task/voidRegisterServiceTransaction").IAttributes | import("@chevre/factory/lib/task/voidReserveTransaction").IAttributes)[];
41
+ }): (import("@chevre/factory/lib/task").IAttributes | import("@chevre/factory/lib/task/confirmMoneyTransfer").IAttributes | import("@chevre/factory/lib/task/confirmRegisterService").IAttributes | import("@chevre/factory/lib/task/confirmPayTransaction").IAttributes | import("@chevre/factory/lib/task/confirmRegisterServiceTransaction").IAttributes | import("@chevre/factory/lib/task/confirmReserveTransaction").IAttributes | import("@chevre/factory/lib/task/createEvent").IAttributes | import("@chevre/factory/lib/task/deleteTransaction").IAttributes | import("@chevre/factory/lib/task/givePointAward").IAttributes | import("@chevre/factory/lib/task/onAssetTransactionStatusChanged").IAttributes | import("@chevre/factory/lib/task/onAuthorizationCreated").IAttributes | import("@chevre/factory/lib/task/onEventChanged").IAttributes | import("@chevre/factory/lib/task/onResourceUpdated").IAttributes | import("@chevre/factory/lib/task/onOrderPaymentCompleted").IAttributes | import("@chevre/factory/lib/task/placeOrder").IAttributes | import("@chevre/factory/lib/task/returnOrder").IAttributes | import("@chevre/factory/lib/task/returnMoneyTransfer").IAttributes | import("@chevre/factory/lib/task/returnPayTransaction").IAttributes | import("@chevre/factory/lib/task/returnPointAward").IAttributes | import("@chevre/factory/lib/task/returnReserveTransaction").IAttributes | import("@chevre/factory/lib/task/sendEmailMessage").IAttributes | import("@chevre/factory/lib/task/sendOrder").IAttributes | import("@chevre/factory/lib/task/syncScreeningRooms").IAttributes | import("@chevre/factory/lib/task/triggerWebhook").IAttributes | import("@chevre/factory/lib/task/useReservation").IAttributes | import("@chevre/factory/lib/task/voidMoneyTransferTransaction").IAttributes | import("@chevre/factory/lib/task/voidPayTransaction").IAttributes | import("@chevre/factory/lib/task/voidRegisterServiceTransaction").IAttributes | import("@chevre/factory/lib/task/voidReserveTransaction").IAttributes)[];
42
42
  export {};
@@ -0,0 +1,20 @@
1
+ import * as factory from '../../../factory';
2
+ import { MongoRepository as AggregateOfferRepo } from '../../../repo/aggregateOffer';
3
+ import { MongoRepository as OfferCatalogRepo } from '../../../repo/offerCatalog';
4
+ import { MongoRepository as OfferCatalogItemRepo } from '../../../repo/offerCatalogItem';
5
+ /**
6
+ * オファーカタログ変更時処理
7
+ */
8
+ export declare function onOfferCatalogUpdated(params: {
9
+ project: {
10
+ id: string;
11
+ };
12
+ ids: string[];
13
+ typeOf: factory.task.onResourceUpdated.OfferCatalogType;
14
+ isDeleted: boolean;
15
+ isOfferCatalogItem: boolean;
16
+ }): (repos: {
17
+ aggregateOffer: AggregateOfferRepo;
18
+ offerCatalog: OfferCatalogRepo;
19
+ offerCatalogItem: OfferCatalogItemRepo;
20
+ }) => Promise<void>;
@@ -0,0 +1,28 @@
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.onOfferCatalogUpdated = void 0;
13
+ const syncOfferCatalog_1 = require("./syncOfferCatalog");
14
+ /**
15
+ * オファーカタログ変更時処理
16
+ */
17
+ function onOfferCatalogUpdated(params) {
18
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
19
+ yield (0, syncOfferCatalog_1.syncOfferCatalog)({
20
+ project: { id: params.project.id },
21
+ ids: params.ids,
22
+ typeOf: params.typeOf,
23
+ isDeleted: false,
24
+ isOfferCatalogItem: params.isOfferCatalogItem === true
25
+ })(repos);
26
+ });
27
+ }
28
+ exports.onOfferCatalogUpdated = onOfferCatalogUpdated;
@@ -29,27 +29,13 @@ function syncOfferCatalog(params) {
29
29
  includedInDataCatalog: { $elemMatch: { id: { $eq: offerCatalogId } } }
30
30
  }
31
31
  });
32
- // 記載サブカタログ同期
33
- yield repos.aggregateOffer.pullIncludedInOfferCatalogItemByCatalogId({
34
- project: { id: params.project.id },
35
- $pull: {
36
- includedInOfferCatalogItem: { $elemMatch: { includedInDataCatalog: { id: { $eq: offerCatalogId } } } }
37
- }
38
- });
39
- // 記載サブカタログ同期
40
- yield repos.aggregateOffer.pullIncludedInOfferCatalogItemByCatalogItemId({
41
- project: { id: params.project.id },
42
- $pull: {
43
- includedInOfferCatalogItem: { $elemMatch: { id: { $eq: offerCatalogId } } }
44
- }
45
- });
46
32
  }
47
33
  }
48
34
  else {
49
35
  for (const offerCatalogId of params.ids) {
50
36
  let offerCatalogs = [];
51
37
  if (params.isOfferCatalogItem) {
52
- offerCatalogs = yield repos.offerCatalogItem.search({ id: { $in: [offerCatalogId] } });
38
+ offerCatalogs = yield repos.offerCatalogItem.search({ id: { $in: [offerCatalogId] } }, {});
53
39
  }
54
40
  else {
55
41
  offerCatalogs = yield repos.offerCatalog.search({ id: { $in: [offerCatalogId] } });
@@ -63,13 +49,6 @@ function syncOfferCatalog(params) {
63
49
  project: { id: params.project.id },
64
50
  isOfferCatalogItem: params.isOfferCatalogItem
65
51
  })(repos);
66
- if (params.isOfferCatalogItem) {
67
- // offerCatalogItemの場合、記載サブカタログ情報を単価オファーへ同期(2023-09-21~)
68
- yield syncOfferCatalogItem2offer({
69
- id: offerCatalogId,
70
- project: { id: params.project.id }
71
- })(repos);
72
- }
73
52
  // 同期済記録を補完
74
53
  if (params.isOfferCatalogItem) {
75
54
  yield repos.offerCatalogItem.updateDateSynced({ id: offerCatalogId, dateSynced: new Date() });
@@ -79,11 +58,7 @@ function syncOfferCatalog(params) {
79
58
  }
80
59
  break;
81
60
  case 'OfferCatalog':
82
- // 記載サブカタログ情報を単価オファーへ同期(2023-09-21~)
83
- yield syncOfferCatalog2offer({
84
- id: offerCatalogId,
85
- project: { id: params.project.id }
86
- })(repos);
61
+ // 特に何もしない
87
62
  yield repos.offerCatalog.updateDateSynced({ id: offerCatalogId, dateSynced: new Date() });
88
63
  break;
89
64
  default:
@@ -128,103 +103,3 @@ function syncOfferCatalogOfOffer2offer(params) {
128
103
  }
129
104
  });
130
105
  }
131
- function syncOfferCatalog2offer(params) {
132
- return (repos) => __awaiter(this, void 0, void 0, function* () {
133
- // サブカタログIDリストを検索
134
- let offerCatalogItemIds;
135
- const { itemListElement } = yield repos.offerCatalog.findItemListElementById({
136
- id: params.id,
137
- project: { id: params.project.id }
138
- });
139
- offerCatalogItemIds = itemListElement.map((element) => element.id);
140
- // サブカタログごとに同期
141
- if (offerCatalogItemIds.length > 0) {
142
- // カタログに含まれるがサブカタログに含まれないものを除外
143
- yield repos.aggregateOffer.pullIncludedInOfferCatalogItemByCatalogId({
144
- project: { id: params.project.id },
145
- $pull: {
146
- includedInOfferCatalogItem: {
147
- $elemMatch: {
148
- id: { $nin: offerCatalogItemIds },
149
- includedInDataCatalog: { id: { $eq: params.id } }
150
- }
151
- }
152
- }
153
- });
154
- for (const offerCatalogItemId of offerCatalogItemIds) {
155
- yield syncSubCatalogs2offer({
156
- id: offerCatalogItemId,
157
- includedInDataCatalog: { id: params.id },
158
- project: params.project
159
- })(repos);
160
- }
161
- }
162
- else {
163
- // 全てpull
164
- yield repos.aggregateOffer.pullIncludedInOfferCatalogItemByCatalogId({
165
- project: { id: params.project.id },
166
- $pull: {
167
- includedInOfferCatalogItem: {
168
- $elemMatch: {
169
- includedInDataCatalog: { id: { $eq: params.id } }
170
- }
171
- }
172
- }
173
- });
174
- }
175
- });
176
- }
177
- function syncOfferCatalogItem2offer(params) {
178
- return (repos) => __awaiter(this, void 0, void 0, function* () {
179
- // 記載カタログを検索
180
- const offerCatalogs = yield repos.offerCatalog.search({
181
- project: { id: { $eq: params.project.id } },
182
- itemListElement: {
183
- id: { $in: [params.id] },
184
- typeOf: { $eq: 'OfferCatalog' }
185
- }
186
- });
187
- for (const offerCatalog of offerCatalogs) {
188
- yield syncSubCatalogs2offer({
189
- id: params.id,
190
- includedInDataCatalog: { id: String(offerCatalog.id) },
191
- project: params.project
192
- })(repos);
193
- }
194
- });
195
- }
196
- /**
197
- * サブカタログ+カタログを単価オファーへ同期する
198
- */
199
- function syncSubCatalogs2offer(params) {
200
- return (repos) => __awaiter(this, void 0, void 0, function* () {
201
- const offerCatalogItemId = params.id;
202
- // 集計オファーIDリストを検索
203
- let aggregateOfferIds;
204
- const findSubCatalogItemListElementResult = yield repos.offerCatalogItem.findItemListElementById({
205
- id: offerCatalogItemId,
206
- project: { id: params.project.id }
207
- });
208
- aggregateOfferIds = findSubCatalogItemListElementResult.itemListElement.map((element) => element.id);
209
- yield repos.aggregateOffer.pullIncludedInOfferCatalogItem(Object.assign({ project: { id: params.project.id }, $pull: {
210
- includedInOfferCatalogItem: {
211
- $elemMatch: {
212
- id: { $eq: offerCatalogItemId },
213
- includedInDataCatalog: { id: { $eq: params.includedInDataCatalog.id } }
214
- }
215
- }
216
- } }, (aggregateOfferIds.length > 0) ? { id: { $nin: aggregateOfferIds } } : undefined));
217
- if (aggregateOfferIds.length > 0) {
218
- yield repos.aggregateOffer.pushIncludedInOfferCatalogItem({
219
- project: { id: params.project.id },
220
- id: { $in: aggregateOfferIds },
221
- $push: {
222
- includedInOfferCatalogItem: {
223
- id: { $eq: offerCatalogItemId },
224
- includedInDataCatalog: { id: { $eq: params.includedInDataCatalog.id } }
225
- }
226
- }
227
- });
228
- }
229
- });
230
- }
@@ -26,8 +26,8 @@ const place_1 = require("../../repo/place");
26
26
  const product_1 = require("../../repo/product");
27
27
  const productOffer_1 = require("../../repo/productOffer");
28
28
  const task_1 = require("../../repo/task");
29
+ const onOfferCatalogUpdated_1 = require("./onResourceUpdated/onOfferCatalogUpdated");
29
30
  const onResourceDeleted_1 = require("./onResourceUpdated/onResourceDeleted");
30
- const syncOfferCatalog_1 = require("./onResourceUpdated/syncOfferCatalog");
31
31
  const settings_1 = require("../../settings");
32
32
  const informResources = settings_1.settings.onResourceUpdated.informResource;
33
33
  /**
@@ -114,7 +114,7 @@ function onResourceUpdated(params) {
114
114
  break;
115
115
  // カタログに対応(2023-09-12~)
116
116
  case 'OfferCatalog':
117
- yield (0, syncOfferCatalog_1.syncOfferCatalog)({
117
+ yield (0, onOfferCatalogUpdated_1.onOfferCatalogUpdated)({
118
118
  project: { id: params.project.id },
119
119
  ids: params.id,
120
120
  typeOf: params.typeOf,
package/package.json CHANGED
@@ -9,8 +9,8 @@
9
9
  }
10
10
  ],
11
11
  "dependencies": {
12
- "@chevre/factory": "4.330.0-alpha.3",
13
- "@cinerino/sdk": "3.168.0",
12
+ "@chevre/factory": "4.330.0",
13
+ "@cinerino/sdk": "3.169.0-alpha.1",
14
14
  "@motionpicture/coa-service": "9.2.0",
15
15
  "@motionpicture/gmo-service": "5.2.0",
16
16
  "@sendgrid/mail": "6.4.0",
@@ -117,5 +117,5 @@
117
117
  "postversion": "git push origin --tags",
118
118
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
119
119
  },
120
- "version": "21.9.0-alpha.13"
120
+ "version": "21.9.0-alpha.15"
121
121
  }