@chevre/domain 20.4.0-alpha.31 → 20.4.0-alpha.33

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.
@@ -9,6 +9,6 @@ export declare function createPrice(params: {
9
9
  };
10
10
  ticketOffer: factory.product.ITicketOffer;
11
11
  seatPriceComponent: factory.place.seat.IPriceComponent[];
12
- acceptedAddOns: factory.offer.IAddOn[];
12
+ acceptedAddOns: factory.product.ITicketAddOn[];
13
13
  appliesToMovieTicket?: factory.assetTransaction.reserve.IAcceptedAppliesToMovieTicket;
14
14
  }): factory.reservation.IPriceSpecification<factory.reservationType.EventReservation>;
@@ -44,27 +44,20 @@ function createUnitPriceSpecsAppliedToAddOn(params) {
44
44
  if (Array.isArray(params.acceptedAddOns)) {
45
45
  unitPriceSpecsAppliedToAddOn = params.acceptedAddOns.map((acceptedAddOn) => {
46
46
  const acceptedAddOnPriceSpec = acceptedAddOn.priceSpecification;
47
- if (acceptedAddOnPriceSpec === undefined || acceptedAddOnPriceSpec === null) {
48
- throw new factory.errors.NotFound('AddOn PriceSpecification');
49
- }
50
47
  // アドオンプロダクトを最適化
51
48
  const itemOffered4appliesToAddOn = {
52
49
  id: acceptedAddOn.itemOffered.id,
53
50
  name: acceptedAddOn.itemOffered.name,
54
51
  productID: acceptedAddOn.itemOffered.productID,
55
- // project: acceptedAddOn.itemOffered.project,
56
52
  typeOf: acceptedAddOn.itemOffered.typeOf
57
53
  };
58
54
  const appliesToAddOn = {
59
- // project: acceptedAddOn.project,
60
55
  typeOf: acceptedAddOn.typeOf,
61
56
  id: acceptedAddOn.id,
62
57
  identifier: acceptedAddOn.identifier,
63
58
  itemOffered: itemOffered4appliesToAddOn
64
- // priceCurrency: acceptedAddOn.priceCurrency
65
59
  };
66
60
  return {
67
- project: params.project,
68
61
  typeOf: factory.priceSpecificationType.UnitPriceSpecification,
69
62
  name: acceptedAddOnPriceSpec.name,
70
63
  price: acceptedAddOnPriceSpec.price,
@@ -59,7 +59,7 @@ export declare function createReservation(params: {
59
59
  additionalTicketText?: string;
60
60
  ticketOffer: factory.product.ITicketOffer;
61
61
  seatPriceComponent: factory.place.seat.IPriceComponent[];
62
- acceptedAddOns: factory.offer.IAddOn[];
62
+ acceptedAddOns: factory.product.ITicketAddOn[];
63
63
  subReservation?: factory.reservation.ISubReservation<factory.reservationType.EventReservation>[];
64
64
  programMembershipUsed?: factory.reservation.IProgramMembershipUsed<factory.reservationType.EventReservation>;
65
65
  availableOffer: factory.unitPriceOffer.IUnitPriceOffer;
@@ -119,7 +119,8 @@ function addReservations(params) {
119
119
  store: { id: (_a = params.availableAtOrFrom) === null || _a === void 0 ? void 0 : _a.id },
120
120
  onlyValid: true,
121
121
  addSortIndex: false,
122
- validateOfferRateLimit: true
122
+ validateOfferRateLimit: true,
123
+ searchAddOns: true
123
124
  })(repos);
124
125
  ticketOffers = searchEventTicketOffersResult.ticketOffers;
125
126
  availableOffers = searchEventTicketOffersResult.unitPriceOffers;
@@ -132,6 +133,7 @@ function addReservations(params) {
132
133
  availableOffers, now,
133
134
  event, availableSeatOffers,
134
135
  transaction,
136
+ availableAtOrFrom: params.availableAtOrFrom,
135
137
  validateAppliesToMovieTicket: params.validateAppliesToMovieTicket
136
138
  })(repos);
137
139
  // 予約イベント最適化
@@ -306,8 +308,14 @@ function createReservations4transactionObject(params) {
306
308
  }
307
309
  // 指定されたアドオンがオファーに存在すれば、アドオンの単価仕様作成
308
310
  let acceptedAddOns = [];
311
+ let availableAddOns;
309
312
  const acceptedAddOnParams = acceptedOffer.addOn;
310
- const availableAddOns = ticketOffer.addOn;
313
+ // availableAddOns = await searchAvailableAddOns({
314
+ // project: { id: params.transaction.project.id },
315
+ // ticketOffer,
316
+ // availableAtOrFrom: params.availableAtOrFrom
317
+ // })(repos);
318
+ availableAddOns = ticketOffer.addOn;
311
319
  if (Array.isArray(availableAddOns) && Array.isArray(acceptedAddOnParams)) {
312
320
  acceptedAddOns = availableAddOns.filter((availableAddOn) => acceptedAddOnParams.some((acceptedAddOn) => availableAddOn.id === acceptedAddOn.id));
313
321
  }
@@ -337,6 +345,63 @@ function createReservations4transactionObject(params) {
337
345
  return reservations;
338
346
  });
339
347
  }
348
+ // function searchAvailableAddOns(params: {
349
+ // project: { id: string };
350
+ // ticketOffer: factory.product.ITicketOffer;
351
+ // availableAtOrFrom?: { id?: string };
352
+ // }) {
353
+ // return async (repos: {
354
+ // offer: OfferRepo;
355
+ // product: ProductRepo;
356
+ // }) => {
357
+ // const availableAddOns: factory.product.ITicketAddOn[] = [];
358
+ // if (Array.isArray(params.ticketOffer.addOn)) {
359
+ // const addOnProductIds = [...new Set(params.ticketOffer.addOn.map((o) => String(o.itemOffered.id)))];
360
+ // for (const addOnProductId of addOnProductIds) {
361
+ // const { offers, product } = await OfferService.product.search({
362
+ // // ids?: string[];
363
+ // project: { id: params.project.id },
364
+ // itemOffered: { id: addOnProductId },
365
+ // onlyValid: true,
366
+ // addSortIndex: false,
367
+ // ...(typeof params.availableAtOrFrom?.id === 'string')
368
+ // ? { availableAt: { id: params.availableAtOrFrom.id } }
369
+ // : undefined
370
+ // })(repos);
371
+ // availableAddOns.push(...offers.map<factory.product.ITicketAddOn>((o) => {
372
+ // const itemOffered4addOn: factory.offer.IItemOffered4addOn = {
373
+ // description: product.description,
374
+ // id: product.id,
375
+ // name: product.name,
376
+ // productID: product.productID,
377
+ // typeOf: product.typeOf
378
+ // };
379
+ // const unitPriceSpec = o.priceSpecification.priceComponent.find((component) => {
380
+ // return component.typeOf === factory.priceSpecificationType.UnitPriceSpecification;
381
+ // });
382
+ // if (unitPriceSpec?.typeOf !== factory.priceSpecificationType.UnitPriceSpecification) {
383
+ // throw new factory.errors.NotFound('UnitPriceSpecification of an addOn');
384
+ // }
385
+ // return {
386
+ // alternateName: o.alternateName,
387
+ // availability: o.availability,
388
+ // description: o.description,
389
+ // id: String(o.id),
390
+ // identifier: o.identifier,
391
+ // itemOffered: itemOffered4addOn,
392
+ // name: o.name,
393
+ // priceCurrency: o.priceCurrency,
394
+ // priceSpecification: unitPriceSpec,
395
+ // typeOf: o.typeOf,
396
+ // ...(o.validFrom instanceof Date) ? { validFrom: o.validFrom } : undefined,
397
+ // ...(o.validThrough instanceof Date) ? { validThrough: o.validThrough } : undefined
398
+ // };
399
+ // }));
400
+ // }
401
+ // }
402
+ // return availableAddOns;
403
+ // };
404
+ // }
340
405
  function getAcceptedSeatNumbersAndSeatSections(params) {
341
406
  const acceptedSeatNumbers = [];
342
407
  const acceptedSeatSections = [];
@@ -226,7 +226,8 @@ function validateAcceptedOffers(params) {
226
226
  store: params.store,
227
227
  onlyValid: true,
228
228
  addSortIndex: false,
229
- validateOfferRateLimit: true
229
+ validateOfferRateLimit: true,
230
+ searchAddOns: true
230
231
  })(repos);
231
232
  // 利用可能なチケットオファーであれば受け入れる
232
233
  const acceptedOffers = (Array.isArray(acceptedOffersWithoutDetail))
@@ -75,6 +75,7 @@ declare function searchEventTicketOffers(params: {
75
75
  page?: number;
76
76
  addSortIndex: boolean;
77
77
  validateOfferRateLimit: boolean;
78
+ searchAddOns: boolean;
78
79
  }): ISearchEventTicketOffersOperation<{
79
80
  ticketOffers: ITicketOfferWithSortIndex[];
80
81
  unitPriceOffers: factory.unitPriceOffer.IUnitPriceOffer[];
@@ -47,6 +47,7 @@ function searchTicketOffersByItemOffered(params) {
47
47
  * イベントから興行(旅客)オファーを検索する
48
48
  */
49
49
  function searchEventTicketOffersByEvent(params) {
50
+ // tslint:disable-next-line:max-func-body-length
50
51
  return (repos) => __awaiter(this, void 0, void 0, function* () {
51
52
  var _a, _b;
52
53
  const event = params.event;
@@ -90,20 +91,25 @@ function searchEventTicketOffersByEvent(params) {
90
91
  availability = yield checkAvailability({ event, unitPriceOffer: availableOffer })(repos);
91
92
  }
92
93
  // アドオン設定があれば、プロダクトオファーを検索
93
- const offerAddOn = [];
94
+ let offerAddOn = [];
94
95
  if (Array.isArray(availableOffer.addOn)) {
95
- for (const addOn of availableOffer.addOn) {
96
- const productId = (_b = addOn.itemOffered) === null || _b === void 0 ? void 0 : _b.id;
97
- if (typeof productId === 'string') {
98
- const productOffers = yield searchAddOns({
99
- product: { id: productId },
100
- store: params.store,
101
- addSortIndex: params.addSortIndex,
102
- onlyValid: params.onlyValid
103
- })(repos);
104
- offerAddOn.push(...productOffers);
96
+ if (params.searchAddOns) {
97
+ for (const addOn of availableOffer.addOn) {
98
+ const productId = (_b = addOn.itemOffered) === null || _b === void 0 ? void 0 : _b.id;
99
+ if (typeof productId === 'string') {
100
+ const productOffers = yield searchAddOns({
101
+ product: { id: productId },
102
+ store: params.store,
103
+ addSortIndex: params.addSortIndex,
104
+ onlyValid: params.onlyValid
105
+ })(repos);
106
+ offerAddOn.push(...productOffers);
107
+ }
105
108
  }
106
109
  }
110
+ else {
111
+ offerAddOn = availableOffer.addOn;
112
+ }
107
113
  }
108
114
  offers4event.push((0, factory_1.createCompoundPriceSpec4event)({
109
115
  eligibleQuantity: eventOffers.eligibleQuantity,
@@ -278,7 +284,8 @@ function searchEventTicketOffers(params) {
278
284
  page: params.page,
279
285
  addSortIndex: params.addSortIndex,
280
286
  validateOfferRateLimit: params.validateOfferRateLimit,
281
- onlyValid: params.onlyValid === true
287
+ onlyValid: params.onlyValid === true,
288
+ searchAddOns: params.searchAddOns
282
289
  })(repos);
283
290
  offers = searchOffersResult.ticketOffers;
284
291
  unitPriceOffers = searchOffersResult.unitPriceOffers;
@@ -9,7 +9,7 @@ declare function createCompoundPriceSpec4event(params: {
9
9
  soundFormatChargeSpecifications: ICategoryCodeChargeSpecification[];
10
10
  videoFormatTypes: string[];
11
11
  availability?: factory.itemAvailability;
12
- addOn: factory.product.ITicketAddOn[];
12
+ addOn: factory.product.ITicketAddOn[] | factory.product.IMinimizedTicketAddOn[];
13
13
  sortIndex?: number;
14
14
  }): factory.product.ITicketOffer & {
15
15
  sortIndex?: number;
@@ -17,6 +17,8 @@ export declare function searchProductOffers(params: {
17
17
  };
18
18
  onlyValid: boolean;
19
19
  addSortIndex: boolean;
20
+ limit?: number;
21
+ page?: number;
20
22
  }): (repos: {
21
23
  offer: OfferRepo;
22
24
  product: ProductRepo;
@@ -27,6 +27,8 @@ function searchProductOffers(params) {
27
27
  ids: params.ids,
28
28
  offerCatalog: { id: offerCatalogId },
29
29
  excludeAppliesToMovieTicket: false,
30
+ limit: params.limit,
31
+ page: params.page,
30
32
  sort: false,
31
33
  onlyValid: params.onlyValid === true,
32
34
  availableAtOrFrom: params.availableAt
@@ -13,7 +13,6 @@ import { MongoRepository as ServiceOutputRepo } from '../../repo/serviceOutput';
13
13
  import { RedisRepository as ServiceOutputIdentifierRepo } from '../../repo/serviceOutputIdentifier';
14
14
  import { MongoRepository as TransactionRepo } from '../../repo/transaction';
15
15
  import { RedisRepository as TransactionNumberRepo } from '../../repo/transactionNumber';
16
- import { searchProductOffers } from './product/searchProductOffers';
17
16
  export interface IAuthorizeOperationRepos {
18
17
  account: AccountRepo;
19
18
  action: ActionRepo;
@@ -32,7 +31,6 @@ export interface IAuthorizeOperationRepos {
32
31
  }
33
32
  export declare type IAuthorizeOperation<T> = (repos: IAuthorizeOperationRepos) => Promise<T>;
34
33
  export declare const ERROR_MESSAGE_ALREADY_REGISTERED = "Already registered";
35
- export { searchProductOffers };
36
34
  /**
37
35
  * プロダクトオファーを検索する
38
36
  */
@@ -54,11 +52,16 @@ export declare function search(params: {
54
52
  id: string;
55
53
  };
56
54
  onlyValid: boolean;
55
+ limit?: number;
56
+ page?: number;
57
57
  addSortIndex: boolean;
58
58
  }): (repos: {
59
59
  offer: OfferRepo;
60
60
  product: ProductRepo;
61
- }) => Promise<factory.product.ITicketOffer[]>;
61
+ }) => Promise<{
62
+ offers: factory.product.ITicketOffer[];
63
+ product: factory.product.IProduct;
64
+ }>;
62
65
  export declare type IAuthorizeOfferAction = factory.action.authorize.offer.product.IAction;
63
66
  /**
64
67
  * サービス(Chevreプロダクト)オファー承認
@@ -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.processUnlockRegisterMembershipService = exports.voidTransaction = exports.authorize = exports.search = exports.searchProductOffers = exports.ERROR_MESSAGE_ALREADY_REGISTERED = void 0;
12
+ exports.processUnlockRegisterMembershipService = exports.voidTransaction = exports.authorize = exports.search = exports.ERROR_MESSAGE_ALREADY_REGISTERED = void 0;
13
13
  const moment = require("moment");
14
14
  const factory = require("../../factory");
15
15
  const accountTransactionIdentifier_1 = require("../../factory/accountTransactionIdentifier");
@@ -18,8 +18,8 @@ const RegisterServiceTransaction = require("../assetTransaction/registerService"
18
18
  const placeOrderInProgress_1 = require("../transaction/placeOrderInProgress");
19
19
  const factory_1 = require("./product/factory");
20
20
  const searchProductOffers_1 = require("./product/searchProductOffers");
21
- Object.defineProperty(exports, "searchProductOffers", { enumerable: true, get: function () { return searchProductOffers_1.searchProductOffers; } });
22
21
  exports.ERROR_MESSAGE_ALREADY_REGISTERED = 'Already registered';
22
+ // export { searchProductOffers };
23
23
  /**
24
24
  * プロダクトオファーを検索する
25
25
  */
@@ -43,7 +43,7 @@ function search(params) {
43
43
  if (typeof ((_a = params.seller) === null || _a === void 0 ? void 0 : _a.id) === 'string') {
44
44
  const productOffers = product.offers;
45
45
  if (!Array.isArray(productOffers)) {
46
- return [];
46
+ return { offers: [], product };
47
47
  }
48
48
  const hasValidOffer = productOffers.some((o) => {
49
49
  var _a, _b;
@@ -56,18 +56,19 @@ function search(params) {
56
56
  .isSameOrAfter(now);
57
57
  });
58
58
  if (!hasValidOffer) {
59
- return [];
59
+ return { offers: [], product };
60
60
  }
61
61
  }
62
62
  }
63
63
  // let offers: factory.product.ITicketOffer[] = [];
64
- return (0, searchProductOffers_1.searchProductOffers)({
64
+ const offers = yield (0, searchProductOffers_1.searchProductOffers)({
65
65
  ids: params.ids,
66
66
  itemOffered: { id: params.itemOffered.id },
67
67
  availableAt: params.availableAt,
68
68
  onlyValid: params.onlyValid,
69
69
  addSortIndex: params.addSortIndex
70
70
  })(repos);
71
+ return { offers, product };
71
72
  // Mongoへ移行(2023-03-01~)
72
73
  // 店舗条件によって対象を絞る
73
74
  // const storeId = params.availableAt?.id;
@@ -210,8 +211,8 @@ function fixProductAndOffers(params) {
210
211
  if (product === undefined) {
211
212
  throw new factory.errors.NotFound('Product');
212
213
  }
213
- const availableOffers = yield search(Object.assign({ ids: params.object.map((o) => String(o.id)), project: { id: params.project.id }, itemOffered: { id: String(product.id) }, onlyValid: true, addSortIndex: false }, (typeof ((_c = params.location) === null || _c === void 0 ? void 0 : _c.id) === 'string') ? { availableAt: { id: params.location.id } } : undefined))(repos);
214
- return { product, availableOffers };
214
+ const { offers } = yield search(Object.assign({ ids: params.object.map((o) => String(o.id)), project: { id: params.project.id }, itemOffered: { id: String(product.id) }, onlyValid: true, addSortIndex: false }, (typeof ((_c = params.location) === null || _c === void 0 ? void 0 : _c.id) === 'string') ? { availableAt: { id: params.location.id } } : undefined))(repos);
215
+ return { product, availableOffers: offers };
215
216
  });
216
217
  }
217
218
  function voidTransaction(params) {
@@ -213,7 +213,7 @@ function processAuthorizeProductOffer(params) {
213
213
  };
214
214
  // オファーにポイント特典設定があるかどうか確認
215
215
  let pointAward;
216
- const offers = yield OfferService.product.search({
216
+ const { offers } = yield OfferService.product.search({
217
217
  project: { id: params.project.id },
218
218
  itemOffered: { id: params.product.id },
219
219
  seller: { id: String(seller.id) },
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  }
10
10
  ],
11
11
  "dependencies": {
12
- "@chevre/factory": "4.292.0",
12
+ "@chevre/factory": "4.293.0-alpha.0",
13
13
  "@cinerino/sdk": "3.143.0",
14
14
  "@motionpicture/coa-service": "9.2.0",
15
15
  "@motionpicture/gmo-service": "5.2.0",
@@ -120,5 +120,5 @@
120
120
  "postversion": "git push origin --tags",
121
121
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
122
122
  },
123
- "version": "20.4.0-alpha.31"
123
+ "version": "20.4.0-alpha.33"
124
124
  }