@chevre/domain 21.9.0-alpha.0 → 21.9.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.
@@ -6,9 +6,12 @@ import { chevre } from '../../../lib/index';
6
6
  async function main() {
7
7
  await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
8
8
 
9
+ const eventRepo = new chevre.repository.Event(mongoose.connection);
9
10
  const offerRepo = new chevre.repository.Offer(mongoose.connection);
11
+ const offerCatalogRepo = new chevre.repository.OfferCatalog(mongoose.connection);
12
+ const productRepo = new chevre.repository.Product(mongoose.connection);
10
13
 
11
- const result = await offerRepo.searchAvaialbleAppliesToMovieTicketByOfferCatalogId({
14
+ let result = await offerRepo.searchAvaialbleAppliesToMovieTicketByOfferCatalogId({
12
15
  limit: 10,
13
16
  page: 1,
14
17
  subOfferCatalog: {
@@ -19,6 +22,21 @@ async function main() {
19
22
  });
20
23
  console.log(result);
21
24
  console.log(result.length);
25
+
26
+ result = await chevre.service.offer.event.searchOfferAppliesToMovieTicket({
27
+ event: { id: 'cllkq475p' },
28
+ onlyValid: true,
29
+ limit: 100,
30
+ page: 1
31
+ // ...(typeof availableAtId === 'string') ? { store: { id: availableAtId } } : undefined
32
+ })({
33
+ event: eventRepo,
34
+ offer: offerRepo,
35
+ offerCatalog: offerCatalogRepo,
36
+ product: productRepo
37
+ });
38
+ console.log(result);
39
+ console.log(result.length);
22
40
  }
23
41
 
24
42
  main()
@@ -54,4 +54,32 @@ declare function searchEventTicketOffers(params: {
54
54
  ticketOffers: ITicketOfferWithSortIndex[];
55
55
  unitPriceOffers: factory.unitPriceOffer.IUnitPriceOffer[];
56
56
  }>;
57
- export { searchEventTicketOffers };
57
+ /**
58
+ * オファーで利用可能な適用決済カード条件を検索する
59
+ */
60
+ declare function searchOfferAppliesToMovieTicket(params: {
61
+ event: {
62
+ /**
63
+ * イベントID
64
+ */
65
+ id: string;
66
+ };
67
+ /**
68
+ * どのアプリケーションに対して
69
+ */
70
+ store?: {
71
+ id?: string;
72
+ };
73
+ limit?: number;
74
+ page?: number;
75
+ /**
76
+ * 有効なオファーのみ対象とするか
77
+ */
78
+ onlyValid?: boolean;
79
+ }): (repos: {
80
+ event: EventRepo;
81
+ offer: OfferRepo;
82
+ offerCatalog: OfferCatalogRepo;
83
+ product: ProductRepo;
84
+ }) => Promise<Pick<factory.priceSpecification.unitPrice.IAppliesToMovieTicket, 'serviceOutput'>[]>;
85
+ export { searchEventTicketOffers, searchOfferAppliesToMovieTicket };
@@ -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.searchEventTicketOffers = void 0;
12
+ 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");
@@ -288,3 +288,59 @@ function searchEventTicketOffers(params) {
288
288
  });
289
289
  }
290
290
  exports.searchEventTicketOffers = searchEventTicketOffers;
291
+ /**
292
+ * オファーで利用可能な適用決済カード条件を検索する
293
+ */
294
+ function searchOfferAppliesToMovieTicket(params) {
295
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
296
+ var _a, _b, _c;
297
+ const event = yield repos.event.findMinimizedIndividualEventById({ id: params.event.id });
298
+ // let soundFormatTypes: string[] = [];
299
+ let videoFormatTypes = [];
300
+ if (event.typeOf === factory.eventType.ScreeningEvent) {
301
+ const superEvents = yield repos.event.search({
302
+ limit: 1,
303
+ page: 1,
304
+ id: { $eq: event.superEvent.id },
305
+ typeOf: factory.eventType.ScreeningEventSeries
306
+ }, { soundFormat: 1, videoFormat: 1 });
307
+ const superEvent = superEvents.shift();
308
+ if (superEvent === undefined) {
309
+ throw new factory.errors.NotFound(factory.eventType.ScreeningEventSeries);
310
+ }
311
+ // soundFormatTypes = (Array.isArray(superEvent.soundFormat)) ? superEvent.soundFormat.map((f) => f.typeOf) : [];
312
+ videoFormatTypes = (Array.isArray(superEvent.videoFormat)) ? superEvent.videoFormat.map((f) => f.typeOf) : [];
313
+ }
314
+ const unacceptedPaymentMethod = getUnacceptedPaymentMethodByEvent({ event });
315
+ // 上映方式がなければMovieTicket除外
316
+ const excludeAppliesToMovieTicket = videoFormatTypes.length === 0;
317
+ // 興行設定があれば興行のカタログを参照する
318
+ const eventOffers = event.offers;
319
+ let catalogId;
320
+ if (typeof ((_a = eventOffers.itemOffered) === null || _a === void 0 ? void 0 : _a.id) === 'string') {
321
+ const eventService = yield repos.product.findById({ id: eventOffers.itemOffered.id }, ['hasOfferCatalog'], []);
322
+ if (typeof ((_b = eventService.hasOfferCatalog) === null || _b === void 0 ? void 0 : _b.id) === 'string') {
323
+ catalogId = eventService.hasOfferCatalog.id;
324
+ }
325
+ }
326
+ if (typeof catalogId !== 'string') {
327
+ throw new factory.errors.NotFound('itemOffered.hasOfferCatalog');
328
+ }
329
+ // サブカタログIDを決定
330
+ let subOfferCatalogId = catalogId;
331
+ const offerCatalogFirstElement = yield repos.offerCatalog.findFirstItemListElementById({ id: catalogId });
332
+ if (offerCatalogFirstElement.typeOf === 'OfferCatalog') {
333
+ subOfferCatalogId = offerCatalogFirstElement.id;
334
+ }
335
+ return repos.offer.searchAvaialbleAppliesToMovieTicketByOfferCatalogId({
336
+ subOfferCatalog: { id: subOfferCatalogId },
337
+ availableAtOrFrom: { id: (_c = params.store) === null || _c === void 0 ? void 0 : _c.id },
338
+ unacceptedPaymentMethod: unacceptedPaymentMethod,
339
+ excludeAppliesToMovieTicket: excludeAppliesToMovieTicket,
340
+ onlyValid: params.onlyValid === true,
341
+ limit: params.limit,
342
+ page: params.page
343
+ });
344
+ });
345
+ }
346
+ exports.searchOfferAppliesToMovieTicket = searchOfferAppliesToMovieTicket;
@@ -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 } from './event/searchEventTicketOffers';
4
+ import { searchEventTicketOffers, searchOfferAppliesToMovieTicket } from './event/searchEventTicketOffers';
5
5
  import { voidTransaction } from './event/voidTransaction';
6
- export { authorize, cancel, importCategoryCodesFromCOA, importFromCOA, voidTransaction, searchEventTicketOffers };
6
+ export { authorize, cancel, importCategoryCodesFromCOA, importFromCOA, voidTransaction, searchEventTicketOffers, searchOfferAppliesToMovieTicket };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.searchEventTicketOffers = exports.voidTransaction = exports.importFromCOA = exports.importCategoryCodesFromCOA = exports.cancel = exports.authorize = void 0;
3
+ 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");
@@ -10,5 +10,6 @@ Object.defineProperty(exports, "importCategoryCodesFromCOA", { enumerable: true,
10
10
  Object.defineProperty(exports, "importFromCOA", { enumerable: true, get: function () { return importFromCOA_1.importFromCOA; } });
11
11
  const searchEventTicketOffers_1 = require("./event/searchEventTicketOffers");
12
12
  Object.defineProperty(exports, "searchEventTicketOffers", { enumerable: true, get: function () { return searchEventTicketOffers_1.searchEventTicketOffers; } });
13
+ Object.defineProperty(exports, "searchOfferAppliesToMovieTicket", { enumerable: true, get: function () { return searchEventTicketOffers_1.searchOfferAppliesToMovieTicket; } });
13
14
  const voidTransaction_1 = require("./event/voidTransaction");
14
15
  Object.defineProperty(exports, "voidTransaction", { enumerable: true, get: function () { return voidTransaction_1.voidTransaction; } });
package/package.json CHANGED
@@ -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.0"
120
+ "version": "21.9.0-alpha.1"
121
121
  }