@chevre/domain 20.4.0-alpha.9 → 20.5.0

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.
Files changed (85) hide show
  1. package/example/src/chevre/aggregateEventReservation.ts +2 -1
  2. package/example/src/chevre/createManyEventsIfNotExist.ts +0 -4
  3. package/example/src/chevre/deleteMovieTicketCategoryChargePriceSpecs.ts +21 -0
  4. package/example/src/chevre/{deleteReservationTicketUnderNames.ts → deleteTasksByName.ts} +4 -2
  5. package/example/src/chevre/reIndex.ts +25 -0
  6. package/example/src/chevre/searchEventTicketOffers.ts +7 -4
  7. package/example/src/chevre/searchOfferCatalogs.ts +14 -16
  8. package/example/src/chevre/searchOffersByCatalog.ts +2 -1
  9. package/example/src/chevre/searchProductOffers.ts +38 -0
  10. package/example/src/chevre/searchTasks.ts +22 -0
  11. package/example/src/chevre/sendEmailMessage.ts +81 -0
  12. package/example/src/chevre/unsetUnnecessaryFields.ts +6 -11
  13. package/lib/chevre/emailMessageBuilder.js +72 -30
  14. package/lib/chevre/errorHandler.js +1 -0
  15. package/lib/chevre/repo/accountTransaction.d.ts +0 -5
  16. package/lib/chevre/repo/accountTransaction.js +44 -38
  17. package/lib/chevre/repo/code.d.ts +0 -7
  18. package/lib/chevre/repo/code.js +0 -17
  19. package/lib/chevre/repo/event.d.ts +5 -4
  20. package/lib/chevre/repo/event.js +8 -17
  21. package/lib/chevre/repo/mongoose/model/accountTransaction.js +0 -5
  22. package/lib/chevre/repo/mongoose/model/member.js +5 -2
  23. package/lib/chevre/repo/mongoose/model/offer.js +19 -9
  24. package/lib/chevre/repo/mongoose/model/priceSpecification.js +19 -52
  25. package/lib/chevre/repo/mongoose/model/product.js +15 -2
  26. package/lib/chevre/repo/offer.d.ts +17 -2
  27. package/lib/chevre/repo/offer.js +77 -44
  28. package/lib/chevre/repo/offerCatalog.d.ts +3 -5
  29. package/lib/chevre/repo/offerCatalog.js +78 -37
  30. package/lib/chevre/repo/priceSpecification.d.ts +11 -0
  31. package/lib/chevre/repo/priceSpecification.js +44 -66
  32. package/lib/chevre/repo/task.d.ts +8 -0
  33. package/lib/chevre/repo/task.js +21 -9
  34. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.d.ts +2 -0
  35. package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +93 -96
  36. package/lib/chevre/service/aggregation/event/aggregateUseActionsOnEvent.js +3 -1
  37. package/lib/chevre/service/assetTransaction/moneyTransfer.js +2 -3
  38. package/lib/chevre/service/assetTransaction/pay.js +2 -3
  39. package/lib/chevre/service/assetTransaction/registerService/factory.d.ts +1 -1
  40. package/lib/chevre/service/assetTransaction/registerService/factory.js +6 -3
  41. package/lib/chevre/service/assetTransaction/registerService.js +3 -1
  42. package/lib/chevre/service/assetTransaction/reserve/factory/price.d.ts +1 -1
  43. package/lib/chevre/service/assetTransaction/reserve/factory/price.js +0 -7
  44. package/lib/chevre/service/assetTransaction/reserve/factory.d.ts +2 -2
  45. package/lib/chevre/service/assetTransaction/reserve/factory.js +0 -1
  46. package/lib/chevre/service/assetTransaction/reserve.js +47 -17
  47. package/lib/chevre/service/assetTransaction.d.ts +1 -1
  48. package/lib/chevre/service/code.d.ts +0 -8
  49. package/lib/chevre/service/code.js +1 -38
  50. package/lib/chevre/service/event.js +20 -3
  51. package/lib/chevre/service/moneyTransfer.d.ts +1 -1
  52. package/lib/chevre/service/moneyTransfer.js +7 -8
  53. package/lib/chevre/service/notification.js +18 -7
  54. package/lib/chevre/service/offer/event/authorize.js +5 -5
  55. package/lib/chevre/service/offer/event/factory.js +1 -1
  56. package/lib/chevre/service/offer/event/searchEventTicketOffers.d.ts +7 -7
  57. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +222 -346
  58. package/lib/chevre/service/offer/factory.d.ts +8 -3
  59. package/lib/chevre/service/offer/factory.js +44 -26
  60. package/lib/chevre/service/offer/product/searchProductOffers.d.ts +11 -1
  61. package/lib/chevre/service/offer/product/searchProductOffers.js +15 -7
  62. package/lib/chevre/service/offer/product.d.ts +11 -4
  63. package/lib/chevre/service/offer/product.js +59 -50
  64. package/lib/chevre/service/payment/any/factory.js +30 -21
  65. package/lib/chevre/service/payment/any.js +11 -4
  66. package/lib/chevre/service/payment/movieTicket/checkByIdentifier.d.ts +22 -0
  67. package/lib/chevre/service/payment/movieTicket/checkByIdentifier.js +183 -0
  68. package/lib/chevre/service/payment/movieTicket/factory.d.ts +1 -1
  69. package/lib/chevre/service/payment/movieTicket/getCredentials.d.ts +13 -0
  70. package/lib/chevre/service/payment/movieTicket/getCredentials.js +45 -0
  71. package/lib/chevre/service/payment/movieTicket/validation.d.ts +15 -0
  72. package/lib/chevre/service/{assetTransaction/pay → payment}/movieTicket/validation.js +8 -7
  73. package/lib/chevre/service/payment/movieTicket.d.ts +10 -22
  74. package/lib/chevre/service/payment/movieTicket.js +19 -219
  75. package/lib/chevre/service/permit.d.ts +5 -1
  76. package/lib/chevre/service/permit.js +18 -11
  77. package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +25 -53
  78. package/lib/chevre/service/task/aggregateScreeningEvent.js +2 -0
  79. package/lib/chevre/service/transaction/orderProgramMembership.js +5 -6
  80. package/lib/chevre/settings.d.ts +4 -1
  81. package/lib/chevre/settings.js +7 -1
  82. package/package.json +3 -3
  83. package/lib/chevre/service/assetTransaction/pay/movieTicket/validation.d.ts +0 -14
  84. package/lib/chevre/service/task/deleteAuthorization.d.ts +0 -6
  85. package/lib/chevre/service/task/deleteAuthorization.js +0 -29
@@ -5,8 +5,13 @@ declare function createCompoundPriceSpec4event(params: {
5
5
  eligibleQuantity: factory.quantitativeValue.IQuantitativeValue<factory.unitCode.C62>;
6
6
  offer: factory.unitPriceOffer.IUnitPriceOffer;
7
7
  movieTicketTypeChargeSpecs: IMovieTicketTypeChargeSpecification[];
8
- videoFormatChargeSpecifications: ICategoryCodeChargeSpecification[];
9
- soundFormatChargeSpecifications: ICategoryCodeChargeSpecification[];
8
+ videoFormatChargeSpecs: ICategoryCodeChargeSpecification[];
9
+ soundFormatChargeSpecs: ICategoryCodeChargeSpecification[];
10
10
  videoFormatTypes: string[];
11
- }): factory.product.ITicketOffer;
11
+ availability?: factory.itemAvailability;
12
+ addOn: factory.product.ITicketAddOn[] | factory.product.IMinimizedTicketAddOn[];
13
+ sortIndex?: number;
14
+ }): factory.product.ITicketOffer & {
15
+ sortIndex?: number;
16
+ };
12
17
  export { createCompoundPriceSpec4event };
@@ -1,15 +1,4 @@
1
1
  "use strict";
2
- var __rest = (this && this.__rest) || function (s, e) {
3
- var t = {};
4
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
- t[p] = s[p];
6
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
- t[p[i]] = s[p[i]];
10
- }
11
- return t;
12
- };
13
2
  Object.defineProperty(exports, "__esModule", { value: true });
14
3
  exports.createCompoundPriceSpec4event = void 0;
15
4
  const factory = require("../../factory");
@@ -21,6 +10,7 @@ function mvtkChargePriceSpec2component(params) {
21
10
  var _a;
22
11
  return Object.assign({ id: params.id, typeOf: params.typeOf, name: params.name, price: params.price, priceCurrency: params.priceCurrency, valueAddedTaxIncluded: params.valueAddedTaxIncluded, appliesToVideoFormat: params.appliesToVideoFormat, appliesToMovieTicket: params.appliesToMovieTicket }, (typeof ((_a = params.accounting) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string') ? { accounting: params.accounting } : undefined);
23
12
  }
13
+ // tslint:disable-next-line:max-func-body-length
24
14
  function createCompoundPriceSpec4event(params) {
25
15
  var _a;
26
16
  // priceSpecificationはマスタ管理の仕様上必ず存在するはず
@@ -33,26 +23,44 @@ function createCompoundPriceSpec4event(params) {
33
23
  // 区分加算料金を適用しないオプションを追加(2023-01-26~)
34
24
  const ignoreCategoryCodeChargeSpec = ((_a = params.offer.settings) === null || _a === void 0 ? void 0 : _a.ignoreCategoryCodeChargeSpec) === true;
35
25
  if (!ignoreCategoryCodeChargeSpec) {
36
- videoFormatChargeSpecComponents = params.videoFormatChargeSpecifications.map(categoryCodeChargePriceSpec2component);
37
- soundFormatChargeSpecComponents = params.soundFormatChargeSpecifications.map(categoryCodeChargePriceSpec2component);
26
+ videoFormatChargeSpecComponents = params.videoFormatChargeSpecs.map(categoryCodeChargePriceSpec2component);
27
+ soundFormatChargeSpecComponents = params.soundFormatChargeSpecs.map(categoryCodeChargePriceSpec2component);
38
28
  }
39
29
  const mvtkPriceComponents = [];
40
30
  // 複数決済カード対応(2022-07-11~)
41
31
  if (Array.isArray(unitPriceSpec.appliesToMovieTicket)) {
32
+ // 決済カード加算料金自動補完(2023-02-21~)
42
33
  unitPriceSpec.appliesToMovieTicket.forEach((appliesToMovieTicket) => {
43
- // すべての上映方式に該当する加算料金を追加(2022-10-29~)
44
- const mvtkSpecs4appliesToMovieTicket = params.movieTicketTypeChargeSpecs.filter((s) => {
45
- var _a;
46
- return ((_a = s.appliesToMovieTicket.serviceOutput) === null || _a === void 0 ? void 0 : _a.typeOf) === appliesToMovieTicket.serviceOutput.typeOf
47
- && s.appliesToMovieTicket.serviceType === appliesToMovieTicket.serviceType
48
- && params.videoFormatTypes.includes(s.appliesToVideoFormat);
34
+ // すべての上映方式に該当する加算料金を追加
35
+ params.videoFormatTypes.forEach((videoFormatType) => {
36
+ let existingMvtkSpec4appliesToMovieTicket = params.movieTicketTypeChargeSpecs.find((s) => {
37
+ var _a;
38
+ return ((_a = s.appliesToMovieTicket.serviceOutput) === null || _a === void 0 ? void 0 : _a.typeOf) === appliesToMovieTicket.serviceOutput.typeOf
39
+ && s.appliesToMovieTicket.serviceType === appliesToMovieTicket.serviceType
40
+ && s.appliesToVideoFormat === videoFormatType;
41
+ });
42
+ // 加算料金が存在しなければprice: 0で自動補完
43
+ if (existingMvtkSpec4appliesToMovieTicket === undefined) {
44
+ existingMvtkSpec4appliesToMovieTicket = {
45
+ typeOf: factory.priceSpecificationType.MovieTicketTypeChargeSpecification,
46
+ price: 0,
47
+ priceCurrency: factory.priceCurrency.JPY,
48
+ appliesToVideoFormat: videoFormatType,
49
+ valueAddedTaxIncluded: true,
50
+ project: params.offer.project,
51
+ id: '',
52
+ name: params.offer.name,
53
+ appliesToMovieTicket: {
54
+ typeOf: factory.service.paymentService.PaymentServiceType.MovieTicket,
55
+ serviceType: appliesToMovieTicket.serviceType,
56
+ serviceOutput: { typeOf: appliesToMovieTicket.serviceOutput.typeOf }
57
+ }
58
+ };
59
+ }
60
+ mvtkPriceComponents.push(mvtkChargePriceSpec2component(existingMvtkSpec4appliesToMovieTicket));
49
61
  });
50
- mvtkPriceComponents.push(...mvtkSpecs4appliesToMovieTicket.map(mvtkChargePriceSpec2component));
51
62
  });
52
63
  }
53
- else {
54
- // Arrayでないケースは廃止(2022-09-12~)
55
- }
56
64
  // 区分加算料金は決済カード適用でも価格要素に含まれるはず(2022-11-02~)
57
65
  const priceComponent = [
58
66
  unitPriceSpec,
@@ -68,8 +76,18 @@ function createCompoundPriceSpec4event(params) {
68
76
  valueAddedTaxIncluded: true,
69
77
  priceComponent
70
78
  };
71
- // 不要な属性を除外(2022-11-07~)
72
- const _b = params.offer, { project } = _b, unitOfferFields4ticketOffer = __rest(_b, ["project"]);
73
- return Object.assign(Object.assign({}, unitOfferFields4ticketOffer), { eligibleQuantity: params.eligibleQuantity, priceSpecification: compoundPriceSpecification });
79
+ // 必要な属性のみに限定(2023-02-24~)
80
+ // const { project, ...unitOfferFields4ticketOffer } = params.offer;
81
+ const { name, description, alternateName, color, typeOf, id,
82
+ // addOn,
83
+ availability, availableAtOrFrom, category, eligibleMembershipType, eligibleSeatingType, eligibleMonetaryAmount, eligibleSubReservation, priceCurrency, validFrom, validThrough, validRateLimit, additionalProperty, identifier, itemOffered } = params.offer;
84
+ return Object.assign(Object.assign({ name, description, alternateName, color, typeOf, id,
85
+ // addOn,
86
+ // availability,
87
+ availableAtOrFrom, category,
88
+ eligibleMembershipType, eligibleSeatingType, eligibleMonetaryAmount, eligibleSubReservation,
89
+ priceCurrency,
90
+ validFrom, validThrough, validRateLimit, additionalProperty,
91
+ identifier, itemOffered, addOn: params.addOn, eligibleQuantity: params.eligibleQuantity, priceSpecification: compoundPriceSpecification }, (typeof params.availability === 'string') ? { availability: params.availability } : { availability }), (typeof params.sortIndex === 'number') ? { sortIndex: params.sortIndex } : undefined);
74
92
  }
75
93
  exports.createCompoundPriceSpec4event = createCompoundPriceSpec4event;
@@ -5,10 +5,20 @@ import { MongoRepository as ProductRepo } from '../../../repo/product';
5
5
  * プロダクトオファーを検索する
6
6
  */
7
7
  export declare function searchProductOffers(params: {
8
+ /**
9
+ * 指定したIDのオファーだけ取得する場合
10
+ */
11
+ ids?: string[];
8
12
  itemOffered: {
9
13
  id: string;
10
14
  };
11
- sort: boolean;
15
+ availableAt?: {
16
+ id: string;
17
+ };
18
+ onlyValid: boolean;
19
+ addSortIndex: boolean;
20
+ limit?: number;
21
+ page?: number;
12
22
  }): (repos: {
13
23
  offer: OfferRepo;
14
24
  product: ProductRepo;
@@ -23,12 +23,23 @@ function searchProductOffers(params) {
23
23
  if (typeof offerCatalogId !== 'string') {
24
24
  return [];
25
25
  }
26
- const offers = yield repos.offer.findOffersByOfferCatalogId({ offerCatalog: { id: offerCatalogId }, sort: params.sort });
26
+ const { offers, sortedOfferIds } = yield repos.offer.findOffersByOfferCatalogId({
27
+ ids: params.ids,
28
+ offerCatalog: { id: offerCatalogId },
29
+ excludeAppliesToMovieTicket: false,
30
+ limit: params.limit,
31
+ page: params.page,
32
+ sort: false,
33
+ onlyValid: params.onlyValid === true,
34
+ availableAtOrFrom: params.availableAt
35
+ });
27
36
  return offers.map((o) => {
37
+ let sortIndex;
38
+ if (params.addSortIndex) {
39
+ sortIndex = sortedOfferIds.indexOf(String(o.id));
40
+ }
28
41
  const unitSpec = o.priceSpecification;
29
42
  const compoundPriceSpecification = {
30
- // 不要な属性を除外(2022-11-02~)
31
- // project: productWithOffers.project,
32
43
  typeOf: factory.priceSpecificationType.CompoundPriceSpecification,
33
44
  priceCurrency: factory.priceCurrency.JPY,
34
45
  valueAddedTaxIncluded: true,
@@ -36,10 +47,7 @@ function searchProductOffers(params) {
36
47
  ...(unitSpec !== undefined) ? [unitSpec] : []
37
48
  ]
38
49
  };
39
- return Object.assign(Object.assign({ additionalProperty: (Array.isArray(o.additionalProperty)) ? o.additionalProperty : [], alternateName: o.alternateName, availability: o.availability, availableAtOrFrom: o.availableAtOrFrom, color: o.color, description: o.description, id: o.id, identifier: o.identifier, itemOffered: o.itemOffered, name: o.name, priceCurrency: o.priceCurrency,
40
- // 不要な属性を除外(2022-11-07~)
41
- // project: o.project,
42
- typeOf: o.typeOf, priceSpecification: compoundPriceSpecification }, (o.validFrom instanceof Date) ? { validFrom: o.validFrom } : undefined), (o.validThrough instanceof Date) ? { validThrough: o.validThrough } : undefined);
50
+ return Object.assign(Object.assign(Object.assign({ additionalProperty: (Array.isArray(o.additionalProperty)) ? o.additionalProperty : [], alternateName: o.alternateName, availability: o.availability, availableAtOrFrom: o.availableAtOrFrom, color: o.color, description: o.description, id: o.id, identifier: o.identifier, itemOffered: o.itemOffered, name: o.name, priceCurrency: o.priceCurrency, typeOf: o.typeOf, priceSpecification: compoundPriceSpecification }, (o.validFrom instanceof Date) ? { validFrom: o.validFrom } : undefined), (o.validThrough instanceof Date) ? { validThrough: o.validThrough } : undefined), (typeof sortIndex === 'number') ? { sortIndex } : undefined);
43
51
  });
44
52
  });
45
53
  }
@@ -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,11 +31,14 @@ 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
  */
39
37
  export declare function search(params: {
38
+ /**
39
+ * 指定したIDのオファーだけ取得する場合
40
+ */
41
+ ids?: string[];
40
42
  project: {
41
43
  id: string;
42
44
  };
@@ -50,11 +52,16 @@ export declare function search(params: {
50
52
  id: string;
51
53
  };
52
54
  onlyValid: boolean;
53
- sort: boolean;
55
+ limit?: number;
56
+ page?: number;
57
+ addSortIndex: boolean;
54
58
  }): (repos: {
55
59
  offer: OfferRepo;
56
60
  product: ProductRepo;
57
- }) => Promise<factory.product.ITicketOffer[]>;
61
+ }) => Promise<{
62
+ offers: factory.product.ITicketOffer[];
63
+ product: factory.product.IProduct;
64
+ }>;
58
65
  export declare type IAuthorizeOfferAction = factory.action.authorize.offer.product.IAction;
59
66
  /**
60
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,16 +18,15 @@ 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
  */
26
26
  function search(params) {
27
27
  return (repos) => __awaiter(this, void 0, void 0, function* () {
28
- var _a, _b;
28
+ var _a;
29
29
  const now = moment();
30
- let offers = [];
31
30
  const searchProductsResult = yield repos.product.search({
32
31
  limit: 1,
33
32
  page: 1,
@@ -39,54 +38,64 @@ function search(params) {
39
38
  throw new factory.errors.NotFound('Product');
40
39
  }
41
40
  // 販売者指定の場合、検証
42
- if (typeof ((_a = params.seller) === null || _a === void 0 ? void 0 : _a.id) === 'string') {
43
- const productOffers = product.offers;
44
- if (!Array.isArray(productOffers)) {
45
- return offers;
46
- }
47
- const hasValidOffer = productOffers.some((o) => {
48
- var _a, _b;
49
- return ((_a = o.seller) === null || _a === void 0 ? void 0 : _a.id) === ((_b = params.seller) === null || _b === void 0 ? void 0 : _b.id)
50
- && o.validFrom !== undefined
51
- && moment(o.validFrom)
52
- .isSameOrBefore(now)
53
- && o.validThrough !== undefined
54
- && moment(o.validThrough)
55
- .isSameOrAfter(now);
56
- });
57
- if (!hasValidOffer) {
58
- return offers;
41
+ if (product.typeOf === factory.product.ProductType.MembershipService
42
+ || product.typeOf === factory.product.ProductType.PaymentCard) {
43
+ if (typeof ((_a = params.seller) === null || _a === void 0 ? void 0 : _a.id) === 'string') {
44
+ const productOffers = product.offers;
45
+ if (!Array.isArray(productOffers)) {
46
+ return { offers: [], product };
47
+ }
48
+ const hasValidOffer = productOffers.some((o) => {
49
+ var _a, _b;
50
+ return ((_a = o.seller) === null || _a === void 0 ? void 0 : _a.id) === ((_b = params.seller) === null || _b === void 0 ? void 0 : _b.id)
51
+ && o.validFrom !== undefined
52
+ && moment(o.validFrom)
53
+ .isSameOrBefore(now)
54
+ && o.validThrough !== undefined
55
+ && moment(o.validThrough)
56
+ .isSameOrAfter(now);
57
+ });
58
+ if (!hasValidOffer) {
59
+ return { offers: [], product };
60
+ }
59
61
  }
60
62
  }
61
- offers = yield (0, searchProductOffers_1.searchProductOffers)({
63
+ // let offers: factory.product.ITicketOffer[] = [];
64
+ const offers = yield (0, searchProductOffers_1.searchProductOffers)({
65
+ ids: params.ids,
62
66
  itemOffered: { id: params.itemOffered.id },
63
- sort: params.sort
67
+ availableAt: params.availableAt,
68
+ onlyValid: params.onlyValid,
69
+ addSortIndex: params.addSortIndex
64
70
  })(repos);
71
+ return { offers, product };
72
+ // Mongoへ移行(2023-03-01~)
65
73
  // 店舗条件によって対象を絞る
66
- const storeId = (_b = params.availableAt) === null || _b === void 0 ? void 0 : _b.id;
67
- if (typeof storeId === 'string') {
68
- // アプリケーションが利用可能なオファーに絞る
69
- offers = offers.filter((o) => {
70
- return Array.isArray(o.availableAtOrFrom)
71
- && o.availableAtOrFrom.some((availableApplication) => availableApplication.id === storeId);
72
- });
73
- }
74
+ // const storeId = params.availableAt?.id;
75
+ // if (typeof storeId === 'string') {
76
+ // // アプリケーションが利用可能なオファーに絞る
77
+ // offers = offers.filter((o) => {
78
+ // return Array.isArray(o.availableAtOrFrom)
79
+ // && o.availableAtOrFrom.some((availableApplication) => availableApplication.id === storeId);
80
+ // });
81
+ // }
82
+ // Mongoへ移行(2023-03-01~)
74
83
  // 有効期間を適用
75
- if (params.onlyValid === true) {
76
- offers = offers.filter((o) => {
77
- let isValid = true;
78
- if (o.validFrom !== undefined && moment(o.validFrom)
79
- .isAfter(now)) {
80
- isValid = false;
81
- }
82
- if (o.validThrough !== undefined && moment(o.validThrough)
83
- .isBefore(now)) {
84
- isValid = false;
85
- }
86
- return isValid;
87
- });
88
- }
89
- return offers;
84
+ // if (params.onlyValid === true) {
85
+ // offers = offers.filter((o) => {
86
+ // let isValid = true;
87
+ // if (o.validFrom !== undefined && moment(o.validFrom)
88
+ // .isAfter(now)) {
89
+ // isValid = false;
90
+ // }
91
+ // if (o.validThrough !== undefined && moment(o.validThrough)
92
+ // .isBefore(now)) {
93
+ // isValid = false;
94
+ // }
95
+ // return isValid;
96
+ // });
97
+ // }
98
+ // return offers;
90
99
  });
91
100
  }
92
101
  exports.search = search;
@@ -202,9 +211,8 @@ function fixProductAndOffers(params) {
202
211
  if (product === undefined) {
203
212
  throw new factory.errors.NotFound('Product');
204
213
  }
205
- const availableOffers = yield search(Object.assign(Object.assign({ project: { id: params.project.id }, itemOffered: { id: String(product.id) }, onlyValid: true }, (typeof ((_c = params.location) === null || _c === void 0 ? void 0 : _c.id) === 'string') ? { availableAt: { id: params.location.id } } : undefined), { sort: false // ソート不要(2023-01-27~)
206
- }))(repos);
207
- 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 };
208
216
  });
209
217
  }
210
218
  function voidTransaction(params) {
@@ -339,7 +347,8 @@ function validateAcceptedOffers(params) {
339
347
  pointAward = Object.assign({ recipient: (_g = offerWithoutDetail.itemOffered.pointAward) === null || _g === void 0 ? void 0 : _g.recipient, toLocation: {
340
348
  identifier: pointAwardToLocationIdentifier,
341
349
  // toLocation.issuedThroughを保証する
342
- issuedThrough: { id: pointAwardToLocationIssuedThroughId }
350
+ issuedThrough: { id: pointAwardToLocationIssuedThroughId },
351
+ typeOf: factory.permit.PermitType.Permit
343
352
  }, typeOf: factory.actionType.MoneyTransfer, purpose: { identifier: pointAwardPurposeIdentifier } }, (typeof ((_h = offerWithoutDetail.itemOffered.pointAward) === null || _h === void 0 ? void 0 : _h.description) === 'string')
344
353
  ? { description: offerWithoutDetail.itemOffered.pointAward.description }
345
354
  : undefined);
@@ -13,8 +13,9 @@ function creatPayTransactionStartParams(params) {
13
13
  const accountId = (typeof params.accountId === 'string')
14
14
  ? params.accountId
15
15
  : (typeof params.object.accountId === 'string') ? params.object.accountId : undefined;
16
+ // movieTickets最適化(2023-02-24~)
17
+ const movieTickets = (Array.isArray(params.object.movieTickets)) ? params.object.movieTickets.map(createMovieTicket) : undefined;
16
18
  return Object.assign(Object.assign({ project: { id: params.transaction.project.id, typeOf: factory.organizationType.Project }, typeOf: factory.assetTransactionType.Pay, transactionNumber: params.transactionNumber, agent: {
17
- // Sellerに変更(2022-05-30~)
18
19
  typeOf: params.transaction.seller.typeOf,
19
20
  id: String(params.transaction.seller.id),
20
21
  name: (typeof params.transaction.seller.name === 'string')
@@ -38,7 +39,7 @@ function creatPayTransactionStartParams(params) {
38
39
  typeOf: params.paymentServiceType,
39
40
  // 決済サービスIDを連携(2022-04-12~)
40
41
  id: issuedThroughId,
41
- paymentMethod: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ typeOf: params.object.paymentMethod, amount: params.object.amount, additionalProperty: (Array.isArray(params.object.additionalProperty)) ? params.object.additionalProperty : [] }, (typeof params.object.method === 'string') ? { method: params.object.method } : undefined), (typeof params.object.name === 'string') ? { name: params.object.name } : undefined), (typeof accountId === 'string') ? { accountId } : undefined), (typeof params.object.description === 'string') ? { description: params.object.description } : undefined), (typeof params.object.fromLocation === 'string') ? { fromLocation: params.object.fromLocation } : undefined), (params.object.creditCard !== undefined) ? { creditCard: params.object.creditCard } : undefined), (Array.isArray(params.object.movieTickets)) ? { movieTickets: params.object.movieTickets } : undefined)
42
+ paymentMethod: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ typeOf: params.object.paymentMethod, amount: params.object.amount, additionalProperty: (Array.isArray(params.object.additionalProperty)) ? params.object.additionalProperty : [] }, (typeof params.object.method === 'string') ? { method: params.object.method } : undefined), (typeof params.object.name === 'string') ? { name: params.object.name } : undefined), (typeof accountId === 'string') ? { accountId } : undefined), (typeof params.object.description === 'string') ? { description: params.object.description } : undefined), (typeof params.object.fromLocation === 'string') ? { fromLocation: params.object.fromLocation } : undefined), (params.object.creditCard !== undefined) ? { creditCard: params.object.creditCard } : undefined), (Array.isArray(movieTickets)) ? { movieTickets } : undefined)
42
43
  }, expires: expires }, (typeof confirmationNumber === 'string')
43
44
  ? {
44
45
  purpose: {
@@ -51,6 +52,33 @@ function creatPayTransactionStartParams(params) {
51
52
  : undefined);
52
53
  }
53
54
  exports.creatPayTransactionStartParams = creatPayTransactionStartParams;
55
+ function createMovieTicket(params) {
56
+ var _a;
57
+ const serviceOutput = {
58
+ reservationFor: {
59
+ typeOf: params.serviceOutput.reservationFor.typeOf,
60
+ id: params.serviceOutput.reservationFor.id
61
+ },
62
+ reservedTicket: {
63
+ ticketedSeat: {
64
+ typeOf: factory.placeType.Seat,
65
+ seatNumber: params.serviceOutput.reservedTicket.ticketedSeat.seatNumber,
66
+ seatRow: params.serviceOutput.reservedTicket.ticketedSeat.seatRow,
67
+ seatSection: params.serviceOutput.reservedTicket.ticketedSeat.seatSection
68
+ }
69
+ }
70
+ };
71
+ return {
72
+ // optimize(2023-03-06~)
73
+ // project: { id: params.project.id, typeOf: factory.organizationType.Project },
74
+ typeOf: params.typeOf,
75
+ identifier: params.identifier,
76
+ accessCode: params.accessCode,
77
+ category: { codeValue: (typeof ((_a = params.category) === null || _a === void 0 ? void 0 : _a.codeValue) === 'string') ? params.category.codeValue : '' },
78
+ serviceType: params.serviceType,
79
+ serviceOutput
80
+ };
81
+ }
54
82
  function createAuthorizeResult(params) {
55
83
  var _a, _b, _c, _d;
56
84
  const payTransactionObject = params.payTransaction.object;
@@ -58,22 +86,6 @@ function createAuthorizeResult(params) {
58
86
  if (typeof (totalPaymentDue === null || totalPaymentDue === void 0 ? void 0 : totalPaymentDue.typeOf) !== 'string') {
59
87
  throw new factory.errors.ServiceUnavailable('payTransaction.object.paymentMethod.totalPaymentDue undefined');
60
88
  }
61
- // let serviceOutput: factory.action.authorize.paymentMethod.any.IPaymentServiceOutput | undefined;
62
- // if (payTransactionObject.typeOf === factory.service.paymentService.PaymentServiceType.MovieTicket) {
63
- // const movieTicketsByPayTransaction = payTransactionObject.paymentMethod?.movieTickets;
64
- // if (Array.isArray(movieTicketsByPayTransaction)) {
65
- // serviceOutput = movieTicketsByPayTransaction.map((m) => {
66
- // // mask accessCode
67
- // return {
68
- // identifier: m.identifier,
69
- // project: m.project,
70
- // serviceOutput: m.serviceOutput,
71
- // serviceType: m.serviceType,
72
- // typeOf: m.typeOf
73
- // };
74
- // });
75
- // }
76
- // }
77
89
  return {
78
90
  accountId: (typeof ((_b = payTransactionObject.paymentMethod) === null || _b === void 0 ? void 0 : _b.accountId) === 'string')
79
91
  ? payTransactionObject.paymentMethod.accountId
@@ -82,9 +94,6 @@ function createAuthorizeResult(params) {
82
94
  issuedThrough: {
83
95
  typeOf: payTransactionObject.typeOf,
84
96
  id: (typeof payTransactionObject.id === 'string') ? payTransactionObject.id : ''
85
- // ↓不要になったのでいったん保留(2022-05-02~)
86
- // MovieTicketの場合、カード情報としてserviceOutputを追加
87
- // ...(serviceOutput !== undefined) ? { serviceOutput } : undefined
88
97
  },
89
98
  paymentMethod: params.object.paymentMethod,
90
99
  paymentStatus: factory.paymentStatusType.PaymentDue,
@@ -97,10 +97,17 @@ exports.invalidatePaymentUrl = invalidatePaymentUrl;
97
97
  */
98
98
  function processVoidPayTransaction(params) {
99
99
  return (repos) => __awaiter(this, void 0, void 0, function* () {
100
- const transaction = yield repos.transaction.findById({
101
- typeOf: params.purpose.typeOf,
102
- id: params.purpose.id
103
- });
100
+ let transaction;
101
+ // アクションID指定の場合、進行中取引検証(2023-02-24~)
102
+ if (typeof params.id === 'string') {
103
+ transaction = yield repos.transaction.findInProgressById({ typeOf: params.purpose.typeOf, id: params.purpose.id });
104
+ }
105
+ else {
106
+ transaction = yield repos.transaction.findById({
107
+ typeOf: params.purpose.typeOf,
108
+ id: params.purpose.id
109
+ });
110
+ }
104
111
  // 承認アクションを取得
105
112
  let authorizeActions;
106
113
  if (typeof params.id === 'string') {
@@ -0,0 +1,22 @@
1
+ import { IMinimizedIndividualEvent } from '../../../repo/event';
2
+ import { MongoRepository as ProductRepo } from '../../../repo/product';
3
+ import { MongoRepository as ProjectRepo } from '../../../repo/project';
4
+ import * as factory from '../../../factory';
5
+ interface ICheckResult {
6
+ purchaseNumberAuthIn: factory.action.check.paymentMethod.movieTicket.IPurchaseNumberAuthIn;
7
+ purchaseNumberAuthResult: factory.action.check.paymentMethod.movieTicket.IPurchaseNumberAuthResult;
8
+ movieTickets: factory.action.check.paymentMethod.movieTicket.IMovieTicket[];
9
+ }
10
+ /**
11
+ * MovieTicket認証
12
+ */
13
+ declare function checkByIdentifier(params: {
14
+ movieTickets: factory.action.check.paymentMethod.movieTicket.IMovieTicket[];
15
+ seller: factory.seller.ISeller;
16
+ screeningEvent: IMinimizedIndividualEvent<factory.eventType.ScreeningEvent>;
17
+ paymentServiceId: string;
18
+ }): (repos: {
19
+ product: ProductRepo;
20
+ project: ProjectRepo;
21
+ }) => Promise<ICheckResult>;
22
+ export { ICheckResult, checkByIdentifier };